Surface / foldkit-surface

Actions

An Action defines a named capability—such as an AI agent tool or a page Block button—that validates input and produces one of your application's Messages so effects stay in update:

ts
import { Action } from 'foldkit-surface'

const SelectTodo = Action.define({
  name: 'selectTodo',
  description: 'Select a todo',
  input: Schema.Struct({ id: Schema.String }),
  toMessage: input => Message.SelectedTodo(input),
})

Action.run(SelectTodo, { id: 't1' }) // Result: the Message, or why the input was refused

Action.run decodes inputs against input before toMessage runs, so untrusted payloads from a Document or tool call are validated first. Declare once and pass to Agent.action(SelectTodo) or a page Catalog.