Agent reference
Every action an agent can call on a calendar, with its arguments, results and errors, and every field of the calendar's snapshot entry.
This page lists what a calendar gives ui-sdk's agent bridge. The guides start at Agents in your app.
Root props
Three props on Root are for agents:
| Prop | Type | Default | Effect |
|---|---|---|---|
label | string | none | The calendar's name for agents: label in its snapshot entry. Without it, the title is the name |
allowAgentDelete | boolean | false | Gives the calendar its deleteEvent action. Without it, any delete an agent causes is refused |
formatAgentEventLabel | (event: CalendarAgentEvent) => string | none | Writes each event's label in the snapshot's items, in place of the default |
An agent's change also needs onEventChange, as every change does. A calendar is listed for agents
only when it renders Calendar.Frame.
The bridge
The bridge is ui-sdk's, from @ui-sdk/react/agent:
"use client";
import { createAgent } from "@ui-sdk/react/agent";
export const agent = createAgent({
// Optional. Asked before every step; `false` refuses it.
allow: ({ component, action }) => component === "calendar" && action !== "setTimeZone",
// Optional. How long a step waits for a promise from `allow`, in milliseconds. 5 minutes by default.
timeout: 60_000,
});| Member | What it does |
|---|---|
agent.snapshot() | Returns an entry for every component on the page |
agent.query({ text?, within?, kind? }) | Resolves with the entries that match. within with a calendar's label returns it with the events in view |
agent.act({ steps }, { signal? }) | Runs steps in order and resolves with the result. Stops at the first that fails |
agent.subscribe(listener) | Calls listener for each settled state change, an agent's or a person's. Returns the unsubscribe function |
agentTools | The definitions of snapshot, act and query for a model: { name, description, inputSchema } |
registerTools(agent, { allow }) | Registers the three tools with WebMCP. Returns the unregister function |
agentTools and registerTools are exports of the same entry as createAgent. On a server, import
agentTools from @ui-sdk/core/agent.
subscribe reports changes to the calendar's state: view, anchorDate, timeZone,
selection, focus and expandedResourceIds. It doesn't report events changing, since your app
holds them. Use onEventChangeResult for those.
The three tools are the bridge's own and the same for every component. act's definition says a
step has a ref, an action and args. It can't say what a calendar's actions take: that's in
describeCalendar().actions, and in the message of a call that got it wrong.
Snapshot entry
| Field | Type | Contents |
|---|---|---|
ref | string | The bridge's handle, such as "c1". Stays with the calendar while it's on the page |
component | "calendar" | The component's kind |
label | string | Root's label, or the calendar's title |
actions | string[] | The actions this calendar offers now, in alphabetical order |
view | string | The active view's name |
anchorDate | string, as "2026-10-08" | The date the visible range is built around |
timeZone | string | The IANA time zone times are shown in |
selection | your selection type, or null | What's selected |
focus | your focus type, or null | What has keyboard focus inside the calendar |
expandedResourceIds | array of resource IDs | The expanded resource groups |
items | { value: string; label: string }[] | The events in the visible range. Absent when there are none |
text | string[] | The calendar's title, such as "Oct 5 – 11, 2026" |
offPage | true | Only on a calendar that left the page, which the bridge remembers for a while |
Which actions a calendar offers:
Root has | actions |
|---|---|
No onEventChange | The ten that read, navigate and select |
onEventChange | Those, and createEvent, updateEvent, moveEvent and resizeEvent: fourteen |
onEventChange and allowAgentDelete | All fifteen, with deleteEvent |
A calendar lists all fifteen for one microtask after it mounts, and the ones it doesn't offer
leave after that. A step for an action that isn't offered fails with the bridge's
calendar c1 takes no deleteEvent now. It takes: ….
In items, value is the event's ID turned into a string. label is the event's title, a middle
dot, and when it happens, in ISO 8601 and not in Root's locale:
| Event | Label |
|---|---|
| Timed | Design review · 2026-10-08T15:00 to 2026-10-08T16:00 (Europe/Berlin) |
| All-day, one day | Offsite · 2026-10-06 (all day) |
| All-day, several | Conference · 2026-10-06 to 2026-10-08 (all day). The last day is included |
| Floating | Lunch · 2026-10-08T12:00 to 2026-10-08T13:00 (local time) |
A timed event's times are wall-clock times in the calendar's time zone, which the label names. An event without a title has only the time. All-day events come first, then the rest by start.
An all-day label ends on the event's last day, and listEvents gives the same event an exclusive
end: the conference above has "end": "2026-10-09" there.
formatAgentEventLabel replaces the label. It gets the event as listEvents
describes it:
<Calendar.Root
label="Team calendar"
formatAgentEventLabel={(event) => `${event.title} (${event.start} to ${event.end})`}
/* …the rest of your props */
/>Keep ISO dates in it. A model reads 2026-10-08T15:00 back exactly, and a localized date it has to
guess at.
selection and focus are your own values, sent as JSON. Keep them serializable if agents should
read them.
In the object agent.snapshot() returns in the page, anchorDate is a Temporal.PlainDate. It
becomes the string above once the snapshot is serialized, which every tool call does.
Actions
A step names the calendar by ref: its ref, its label, or "calendar". An action takes nothing, or
exactly one JSON object as args[0]. An action that takes nothing accepts {} too. A second
argument, a value that isn't an object, a key the action doesn't have, a null and a missing
required key each fail the step with calendar-agent-invalid-arguments.
Reading
| Action | Input | Returns |
|---|---|---|
describeCalendar | nothing | The calendar's description |
listEvents | nothing, or { start?, end? } | A list of events |
getChange | { changeId } | A change by its ID, as it is now |
These change nothing and call no handler of yours. They're steps, so the bridge's allow is asked
for each.
describeCalendar
| Field | Type | Contents |
|---|---|---|
actions | Record<string, string> | Each action the calendar offers now, with its input as the tables on this page give it |
conventions | string | How dates, times, ranges and IDs are written, in a sentence for the model |
today | string, as "2026-10-06" | Today in the calendar's time zone |
now | string, as "2026-10-06T11:42:07.512+02:00" | The current time, with the calendar's time zone's offset |
timeZone | string | The IANA time zone times are shown in |
locale | string | Root's locale |
view | string | The active view |
views | string[] | The names setView takes |
anchorDate | string | The date the visible range is built around |
visibleRange | { start, end } or null | The dates in view. end is exclusive |
resources | { id, parentId, title }[] | Your resources, for resourceIds. Empty without any |
selectedEventId | an event ID, or null | The selected event, when the selection is the default kind |
pendingChanges | changes | The changes being checked or saved now, a person's included |
readOnly | boolean | true when Root has no onEventChange |
canDelete | boolean | Whether the calendar offers deleteEvent |
today and now follow Root's now or clock prop when you pass one.
listEvents
Without input, the events of the visible range. With start, end or both, the events of those
dates, in view or not; the one left out is the visible range's. Both are ISO dates, and end is
exclusive. A start that isn't before the end fails with calendar-agent-invalid-range.
| Field | Type | Contents |
|---|---|---|
id | string or number | The event's ID as your adapter gives it. What eventId takes |
title | string | The adapter's title |
kind | "timed", "all-day" or "floating" | How start and end are written |
start | string | See below |
end | string | Exclusive |
resourceIds | array of resource IDs | The resources the event is on |
pending | true | Only while a change to the event is being checked or saved |
readOnly | true | Only on an event that can't be changed |
kind | start and end |
|---|---|
timed | A date-time with the calendar's time zone's offset: "2026-10-08T15:00:00+02:00" |
all-day | A date: "2026-10-06". One day on October 6 ends on "2026-10-07" |
floating | A date-time without an offset: "2026-10-08T12:00:00" |
The list has all-day events first and then the rest by start. It shows events as the calendar does, with pending changes applied. It has the adapter's fields and none of your record's others: what else an event holds is your app's to tell a model.
Navigation and state
| Action | Input | Effect | Handler on Root |
|---|---|---|---|
navigateNext | nothing | Moves one range forward, by the active view's step | onAnchorDateChange |
navigatePrevious | nothing | Moves one range back | onAnchorDateChange |
navigateToday | nothing | Shows the range that holds today | onAnchorDateChange |
goToDate | { date: "2026-10-09" } | Shows the range that holds the date | onAnchorDateChange |
setView | { view }: one of views | Switches the view | onViewChange |
setTimeZone | { timeZone: "America/New_York" } | Shows times in that zone | onTimeZoneChange |
selectEvent | { eventId }: an ID, or null | Selects the event, or clears the selection | onSelectionChange |
Each handler gets detail.source of "agent" and detail.reason of "imperative", with no
detail.event. detail.cancel() keeps the value, and the step still succeeds, with no changes.
That's for the actions in this table: when the agent presses one of the calendar's triggers
instead, the handler gets the trigger's own reason, such as "next-press".
goToDate also takes a date-time and uses its date. setTimeZone changes how times are shown and
moves no event.
selectEvent sets the selection to { kind: "event", eventId }, the calendar's default selection
for an event. It writes that shape on a calendar with a
selection type of its own as well. If yours differs, map it in
onSelectionChange with selection controlled, or refuse selectEvent in allow.
Events
| Action | Input | Proposes |
|---|---|---|
createEvent | { start, end, title?, resourceIds?, fields? } | cause: "create", with eventId: null and event: null |
updateEvent | { eventId, title?, start?, end?, resourceIds?, fields? } | cause: "update". Needs one key beside eventId |
moveEvent | { eventId, start, end?, resourceIds? } | cause: "move". Without end the event keeps its length |
resizeEvent | { eventId, start } or { eventId, end } | cause: "resize-start" or "resize-end". The other edge stays |
deleteEvent | { eventId } | cause: "delete". Offered only when Root has allowAgentDelete |
Each is a proposal with detail.input of "agent": policies see it, and so do onEventChange and
onEventChangeResult. Each returns a change.
eventId is an id from listEvents, or an item's value. A number ID matches as a number or
as its string. Any event you passed to events can be named, in view or not.
title and fields are for your record. createEvent and updateEvent take them, and the other
three don't. They reach your policies and your onEventChange as detail.fields: the fields
object, with title in it as fields.title. The calendar checks that title is a string and
fields an object, and that the title isn't given both ways. It checks nothing inside fields.
Save what the agent sent has the handler.
updateEvent with start and no end keeps the event's length, as moveEvent does. With end
alone the start stays. With neither, the event keeps its times, and the change still has them as
proposed.
How start and end are read depends on the event:
| Event | start and end | Examples |
|---|---|---|
| Timed | A date-time. Without an offset it's wall-clock time in the calendar's time zone; with Z, an offset or a bracketed zone it's that exact moment | "2026-10-09T10:00", "2026-10-09T08:00Z", "2026-10-09T10:00+02:00[Europe/Berlin]" |
| All-day | A date. The end is exclusive: one day on October 9 ends on October 10 | "2026-10-09" |
| Floating | A date-time without an offset | "2026-10-09T10:00" |
What listEvents returns for an event's start and end is valid input for them.
Dates are in the ISO calendar. A date or a time annotated with another calendar, such as
"2026-10-09[u-ca=hebrew]", fails with calendar-agent-unsupported-calendar: the calendar doesn't
convert it.
createEvent makes an all-day event when both start and end are dates, and a timed one
otherwise.
resourceIds is a list of resource IDs from describeCalendar's resources. On a calendar that
has resources, an ID that isn't one of them fails with calendar-agent-unknown-resource, which
lists the ones there are. A calendar without resources doesn't check them.
A wall-clock time that a daylight saving change skips or repeats is resolved with Root's
disambiguation, "compatible" by default.
Recurring events
With recurring events, each occurrence is an event of its own in listEvents,
with the ID your expansion gives it, such as standup::2026-10-20T09:00:00Z. An agent names an
occurrence by that ID.
Which occurrences a change covers is your app's choice, so it travels as a field. An agent sends it
with updateEvent, the one action for an existing event that takes fields:
{
"ref": "Team calendar",
"action": "updateEvent",
"args": [
{
"eventId": "standup::2026-10-20T09:00:00Z",
"start": "2026-10-20T10:00",
"fields": { "scope": "all" }
}
]
}Your handler reads detail.fields?.scope and applies the change to that occurrence or to the
series, as it does for a person's choice in a dialog. moveEvent, resizeEvent and deleteEvent
take no fields, so they act on the occurrence named, with your handler's default scope. After a
change to a series, occurrence IDs can differ, and the agent calls listEvents again.
Results
act resolves with:
| Field | Contents |
|---|---|
ok | true when every step ran |
error | { step, message } for the step that failed. step counts from zero |
steps | The steps that ran: { step, ref, changes?, result? } |
appeared | Components that came onto the page during the call |
values | The values of form fields on the page. A calendar adds nothing here |
What a calendar's step reports:
| Step | Reports |
|---|---|
| Navigation or state, applied | changes: [{ component: "calendar", label, key, value }], with key such as "anchorDate" |
| Navigation or state, cancelled or unchanged | Neither changes nor result |
describeCalendar, listEvents | result: the description, or the list |
An event action, and getChange | result: a change |
A failed step stops the call. Steps before it stay applied.
A change
What createEvent, updateEvent, moveEvent, resizeEvent, deleteEvent and getChange
return:
| Field | Type | Contents |
|---|---|---|
changeId | string | Names the change on this calendar, for getChange |
cause | "create", "update", "move", "resize-start", "resize-end" or "delete" | What was proposed |
eventId | an event ID, or null | The event. null for a create: your app makes the event and its ID |
proposed | { start, end, kind, resourceIds }, or null | Where the event lands, written as listEvents writes it. null for a delete |
status | "saved", "saving", "validating" or "rejected" | Where the change is |
reason | string | Only with "rejected": one of the rejection reasons |
status | When |
|---|---|
saved | Your onEventChange returned, or the promise it returned resolved |
saving | Your onEventChange returned a promise that hasn't settled |
validating | A policy returned a promise that hasn't settled. Your onEventChange hasn't been called |
rejected | A policy or your handler refused the change after the step had returned it |
A refusal that comes at once never returns as a change: it fails the step. So a step's
own result is saved, saving or validating, and rejected is something getChange reports.
saved means your handler took the change. It doesn't say your events prop has the event in its
new place yet. listEvents reads your events with the changes still pending on top, so what it
shows after the step depends on your handler:
Your onEventChange | listEvents after the step |
|---|---|
Updates events before it returns | The event in its new place |
| Returns a promise | The new place, with pending: true while it saves and from events after |
Returns nothing and updates events later | The old place, until events changes |
The third is a handler that starts a save and doesn't return its promise. The calendar takes a change for saved the moment such a handler returns, a person's drag included, so return the promise.
A new event is listed once your events has it. While a createEvent is saving, listEvents
doesn't have the event yet.
A calendar keeps the last 50 changes agents proposed on it, for as long as it's mounted, and
getChange reads those however they ended. It also reads any change that's still being checked
or saved, a person's included, by the ID describeCalendar's pendingChanges gives it. Once a
person's change has ended, the calendar no longer has it. getChange with an ID it doesn't have
fails with calendar-agent-unknown-change and lists the agents' last ten.
Errors
A failed step's message starts with a code.
| Code | When | The message also says |
|---|---|---|
calendar-agent-invalid-arguments | The input isn't one object with the action's keys | What the action takes, and what was wrong |
calendar-agent-invalid-date | A date isn't an ISO date | The key, an example, and what was sent |
calendar-agent-invalid-time | A time isn't an ISO date-time | An example in the calendar's time zone, and what was sent |
calendar-agent-invalid-time-zone | setTimeZone got something that isn't an IANA time zone | An example, and what was sent |
calendar-agent-unsupported-calendar | A date or a time is in a calendar other than ISO 8601 | The calendar it names, and what was sent |
calendar-agent-invalid-resources | resourceIds isn't a list of strings or numbers | What was sent |
calendar-agent-unknown-resource | resourceIds has an ID that none of the calendar's resources has | The first 20 resource IDs |
calendar-agent-invalid-range | listEvents got a start that isn't before its end | What was sent |
calendar-agent-unknown-event | No event has that ID | The first 20 event IDs |
calendar-agent-unknown-change | getChange got an ID the calendar doesn't have | The last ten change IDs |
calendar-unknown-view | setView got a name that isn't registered | The registered view names |
calendar-event-change-rejected | A policy, the calendar or your handler refused the change at once | The reason |
What calendar-agent-invalid-arguments says after the code:
moveEvent takes { eventId: ID, start: ISO date or date-time, end?: same, resourceIds?: ID[] }; it takes one object, not 2 arguments
moveEvent takes { eventId: ID, start: ISO date or date-time, end?: same, resourceIds?: ID[] }; it has no "fields"
moveEvent takes { eventId: ID, start: ISO date or date-time, end?: same, resourceIds?: ID[] }; start is missing
goToDate takes { date: ISO date }; got "2026-09-01"
updateEvent changes something: { eventId: ID, title?: string, start?: ISO date or date-time, end?: same, resourceIds?: ID[], fields?: object }
resizeEvent takes one of start and end: { eventId: ID, start?: ISO date or date-time, end?: same }, one of start and end
give the title as title or as fields.title, not bothThe bridge has messages of its own:
| Message | When |
|---|---|
The app refused moveEvent on c1. | allow returned false |
deleteEvent on c1 was cancelled. | The signal passed to act aborted while the step waited |
No component "Team calendar" on the page. Its labels: … | Nothing has that ref, label or kind |
calendar c1 takes no deleteEvent now. It takes: createEvent, … | The calendar doesn't offer the action, or has no such one |
"Private calendar" isn't available to agents here. Ask the person. | The calendar is inside data-agent-hidden |
Rejection reasons
What follows calendar-event-change-rejected: in a failed step, and what a rejected change has as
reason:
| Reason | Meaning |
|---|---|
| a policy's reason | A policy rejected the change, such as agents-book-weekdays-only |
read-only | The event is read-only |
unknown-event | No event has the change's ID |
agent-delete-not-allowed | An agent caused a delete on a Root without allowAgentDelete |
invalid-placement | The range is empty or reversed, such as an end before the start |
handler-error | Your onEventChange threw, or the promise it returned rejected |
policy-error | A policy threw |
superseded | A newer change to the same event replaced this one |
A failed step adds the thrown error's message in parentheses:
calendar-event-change-rejected: handler-error (This slot was just taken). A rejected change's
reason is the reason alone.
The calendar's own actions look the event up before they propose, so a step that names a missing
event fails with calendar-agent-unknown-event, which lists the IDs there are. unknown-event is
what your onEventChangeResult gets for a proposal made another way, such as a button of yours
that proposes a change to an event that's gone.
Who made a change
| Where | Field | Values |
|---|---|---|
State handlers, such as onViewChange(view, detail) | detail.source | "agent", "mouse", "touch", "pen", "keyboard", "virtual", "programmatic" |
onEventChange(change, detail) | detail.input | "agent", "pointer", "keyboard", "api" |
onEventChangeResult(result, detail) | detail.input | The same |
A policy's second argument, { detail } | detail?.input | The same |
A history step, from useCalendarHistory(history).past | input | The same |
The same detail has fields for an agent's createEvent or updateEvent that sent a title
or fields, and no fields key otherwise.
An undo or redo also has detail.history, "undo" or "redo", and its input is "api" unless
you pass another to undo({ input }).
Anything a step causes is the agent's, not only the calendar's own actions. When an agent presses
a ui-sdk button of yours and its handler calls proposeEventChange, an action such as setView,
or a history's undo, your policies and handlers hear "agent", whatever input your code passed.
That holds for what the handler does before it returns: a call it makes after an await, in a
timer or in an effect reads as your own code, as
Who made a change explains.
A delete an agent causes that way is refused on a Root without allowAgentDelete, as
Deleting describes.
A person's keys report "keyboard" in a state handler: arrow-key navigation, moving focus between
cells and events, and expanding or collapsing a resource. "programmatic" is left for calls your
own code makes.
Each of an agent's proposals reaches onEventChangeResult once, however it ends: committed, or
rejected with the reason, a policy's refusal included.
What isn't there yet
- Tool definitions for the actions. The bridge's
actcan't describe an action's input. A model learns it fromdescribeCalendar().actionsor from a failed call's message. - A dry run. An agent can't ask whether a change would be accepted. It proposes the change and reads the refusal.
- A selection of your own shape from
selectEvent. It writes{ kind: "event", eventId }whatever selection type the calendar has, andselectedEventIdreads only that kind. - A settled list of actions at mount. A calendar lists every action for one microtask after it mounts, before the ones it doesn't offer leave.
- Your record's other fields in
listEvents. It has the adapter's ID, title, times and resources. - The new event's ID from
createEvent. The change haseventId: null, and the agent finds the event withlistEvents. - Event changes in
subscribe. It reports state.onEventChangeResultreports events.
Types
The actions' TypeScript types are in @moltenship/calendar-primitives, for
code that wraps the bridge or builds on the calendar's ui-sdk primitive. Apps don't have that
package as a direct dependency, so install it to import from it:
pnpm add @moltenship/calendar-primitivesimport {
calendarAgentActions,
type CalendarAgentApi,
type CalendarAgentChange,
type CalendarAgentDescription,
type CalendarAgentEvent,
} from "@moltenship/calendar-primitives";
// The fifteen action names. A snapshot lists the ones a calendar offers, in alphabetical order.
export const actionNames: readonly (keyof CalendarAgentApi)[] = calendarAgentActions;
/** What `describeCalendar`, `listEvents` and an event action return, for code that reads them. */
export interface CalendarReads {
readonly description: CalendarAgentDescription;
readonly events: readonly CalendarAgentEvent[];
readonly change: CalendarAgentChange;
}Apps don't need them: an agent calls the actions by name through the bridge, and TypeScript
infers the CalendarAgentEvent that a formatAgentEventLabel written inline takes.