Agent / Expose, do not reimplement
Linking capabilities to UI controls with parts
Capabilities name what an agent can do; parts map them to specific headings, buttons, or repeated rows from the contract alone:
const AssistantParts = AgentBuilder.parts(AssistantAgent, {
title: Agent.part({ label: 'List title', role: 'heading', field: 'listTitle' }),
clear: Agent.part({ label: 'Clear completed', role: 'button', invokes: Message.ClearedCompleted }),
toggle: Agent.part({
role: 'checkbox',
invokes: Message.ToggledTodo,
each: context => context.todos,
key: todo => todo.id,
label: todo => todo.title,
input: todo => ({ id: todo.id }),
}),
})
const partsRuntime = AgentBuilder.bind({ definition: AssistantAgent, host, parts: AssistantParts })Parts reference context keys (field), exposed capability constructors (invokes/sets), and repeated context items (each, key, label, input):
- Zero extra authority: Invoking a part dispatches through
messages.dispatchwith full availability, schema decoding,authorize, and completion checks. - Follows availability and context schemas: Unavailable capabilities drop from
parts.list, and callbacks receive schema-filtered context data. - Ambiguity checks:
parts.find({ label })returnsAmbiguouswith all matches instead of picking arbitrarily when labels collide. - DOM test hooks:
AssistantParts.attributes(h, 'clear')andattributes(h, 'toggle', todo.id)emitdata-fk-partanddata-fk-part-keyattributes for browser adapters and tests.
How every call flows through the pipeline
Every adapter translates incoming protocol requests into one shared eight-step contract pipeline:
- Resolve the capability by name.
- Check
available(model). - Decode protocol
inputagainst its Schema. - Check
authorizefor the currentprincipal. - Check
applies(model, input, principal). - Construct the application
MessageviatoMessage. - Dispatch the
Messageto the host. - Wait for correlated
completionif configured.
Any refusal prior to dispatch stops before reaching update, keeping validation and policy uniform across every transport.
Complementary client and server policy
Client authorize checks refuse unauthorized tool calls early with typed errors. For server-backed or synchronized state, enforce the same predicate inside your server APIs or Sync journal (authorize) as well—the contract improves UX while the server remains the trusted boundary.