Agent / foldkit-agent
Record decisions with the audit log
Attach Agent.auditLog({ capacity, principal, includeInput?, redact? }) when binding to record every accepted, refused, and unknown outcome in a bounded ring buffer:
ts
type User = { readonly id: string }
const UserAgent = Agent.forApplication(App).withPrincipal<User>()
const audit = Agent.auditLog({
capacity: 500,
principal: (caller: User) => caller.id,
})
const audited = UserAgent.bind({
definition: UserAgent.make({
messages: UserAgent.expose(Message, { RequestedCreateTodo: 'Create a new todo' }),
}),
host: { ...host, principal: () => ({ id: 'user-1' }) },
audit,
})By default the log omits raw inputs (opt in with includeInput: true and redact), requires an explicit principal projector, and never stores the Model. A failing AuditSink never breaks dispatch.
Generate manifests and inspect contracts
Contracts are inspectable data, testable without an LLM, and exportable as committed snapshots:
ts
Agent.messages(AppAgent).map(message => message.name)
// ['requested_create_todo', 'delete_todo']
const manifestJson = JSON.stringify(Agent.toManifest(AppAgent), null, 2)
const markdownDocs = Agent.toMarkdown(AppAgent)Main exports
- Contract builders:
Agent.forApplication(App),Agent.forModel<Model>(),Agent.make,Agent.expose,Agent.exposeSubset,Agent.variant,Agent.action,Agent.resource,Agent.when - UI parts:
Agent.part,Agent.parts,Agent.Found - Runtime hosts:
Agent.host,Agent.headless,Agent.bind - Introspection and audit:
Agent.messages,Agent.resources,Agent.schema,Agent.contextSchema,Agent.toManifest,Agent.toMarkdown,Agent.auditLog,Agent.summarize,Agent.newInvocationId
Why capabilities are Messages and hosts wrap config
- Messages over Model setters: Exposing Messages keeps every transition inside
update, preserving replay, validation, and side effects rather than adding a second mutation path. Agent.hostwrapping: Foldkit'smakeApplicationreturns a handle without directmodel()ordispatch()accessors, soAgent.host(config)instrumentsupdateandsubscriptionsonce beforerun,hydrate,embed, orSSR.hydrate.forApplication/forModelinference: FixingModelupfront lets TypeScript infermodelinside inlineavailable,authorize, andappliescallbacks without type annotations.
Next
- Serve the contract over stdio or HTTP MCP:
foldkit-agent-mcp - Publish tools in the browser with WebMCP:
foldkit-agent-webmcp - Serve A2A tasks or Agent Native actions:
foldkit-agent-a2a,foldkit-agent-native - Read the end-to-end architecture guide: Agents guide