Agent / foldkit-agent
Name UI controls with Parts
Parts map exposed capabilities and context fields onto screen controls (label, role, field, invokes, each, key) so in-page adapters or tests can locate them without adding separate authority:
ts
const AppParts = TodoAgent.parts(AppAgent, {
selected: Agent.part({ label: 'Selected todo', role: 'status', field: 'selectedTodoId' }),
create: Agent.part({ label: 'New todo', role: 'button', invokes: Message.RequestedCreateTodo }),
remove: Agent.part({
role: 'button',
invokes: Message.RequestedDeleteTodo,
each: context => context.todos,
key: todo => todo.id,
label: todo => `Delete ${todo.title}`,
input: todo => ({ id: todo.id }),
}),
})
const partsRuntime = TodoAgent.bind({ definition: AppAgent, host, parts: AppParts })
const found = await Effect.runPromise(partsRuntime.parts.find({ label: 'Delete Milk' }))
const named = Agent.Found.$match(found, {
One: ({ part }) => part.capability,
Ambiguous: () => Option.none(),
None: () => Option.none(),
})AppParts.attributes(h, 'create') (or attributes(h, 'remove', todo.id)) adds data-fk-part and data-fk-part-key attributes in views. runtime.parts.list reads the projected context snapshot (filtering unavailable capabilities) and foldkit-agent-mcp serves it at app://parts.