Build A Natural-Language Workspace Agent
Outcome
Section titled “Outcome”User intent reaches agentOS submit, the AgentOS Durable Object constructs
request-local workspace tools, workspace metadata is read through ledger
projections, and the product UI consumes typed/redacted run projections or
AG-UI frames instead of raw ledger payloads.
Prerequisites
Section titled “Prerequisites”- Expose one Worker HTTP route that accepts a natural-language prompt.
- Send only serializable intent and context to an AgentOS Durable Object RPC.
- Construct workspace tools inside the AgentOS Durable Object, not in the Worker caller.
- Use
createWorkspaceToolsfrom@agent-os/workspace-envwith a concrete workspace adapter such as@agent-os/workspace-env-cloudflare. - Let the shared workspace tools provide
read_file,write_file,edit_file,glob_files,grep_files,delete_path, andrun_shell. Product code must not author raw JSON Schema for these tool contracts. - Use
walkWorkspaceFilesanddiffWorkspaceFilesfor scan/diff. The product still owns itsworkspace.file.*event vocabulary and projection shape. - Configure
submitwith a provider route such asopenAIChat({ endpoint, credential, model })or anLlmTransportroute exposed by the backend. - Bind endpoint and credential through material refs; do not parse provider responses in product code.
- Let the model select product-owned tools through
submit; do not useunsafeRunToolByNamefor LLM-selected tool calls. - Store workspace metadata in ledger facts and materialized projections.
- Keep file bytes, provider URLs, credentials, and tokens out of ledger and projection state.
- Decode agentOS-owned runtime facts with
decodeRuntimeLedgerEventor useprojectRunTrace/projectRunsPage. Runtime payload fallback parsers in product code are a boundary failure. - For UI protocols, project typed runtime facts with
@agent-os/ag-uiand consume the framework binding (@agent-os/ag-ui-reactor@agent-os/ag-ui-svelte). AG-UI frames are derived edge frames, not ledger facts. - Expose product API JSON as a redacted run projection or redacted AG-UI frame stream. Do not expose raw ledger payloads, provider-native metadata, resolved material values, credentials, tokens, or full file bytes.