Documentation menu
Reference

File conventions

The public API starts with a small set of files. Their location determines routing, generated types, and runtime behavior.

The whole project at a glance

Start with agent.ts. Add neighboring files only when the agent needs that interface or capability. Folder paths become routes; the final URL segment chooses a durable instance.

project tree
my-agent/
├── agents/
│   ├── app.tsx                  # optional home dashboard at /
│   ├── middleware.ts           # applies to every route
│   ├── inventory/
│   │   ├── agent.ts            # /inventory/:instance
│   │   ├── app.tsx             # browser interface
│   │   ├── tools.ts            # isolated workerd tools
│   │   ├── tools.host.ts       # permissioned Bun host tools
│   │   ├── workflow.ts         # co-located durable workflow
│   │   └── docs.md             # route documentation
│   └── orders/
│       └── agent.ts            # /orders/:instance
├── cli.ts                      # terminal interface
├── package.json
└── tsconfig.json

Files and where to learn them

FilePurposeLearn it
agent.tsState, lifecycle, callable methods, and behavior in workerd.Write an agent →
app.tsxBrowser UI with a generated, route-bound hook.Browser client →
agents/app.tsxHome dashboard or cross-agent interface at /.Human interfaces →
tools.tsModel tools executed beside the agent in workerd.Tools →
tools.host.tsExplicit file, shell, database, and Bun host capabilities.Host bridge →
workflow.tsCo-located durable, multi-step work.Workflows →
middleware.tsInherited authentication, logging, and request policy.Routing & middleware →
docs.mdAgent-specific documentation behind the same middleware.Route docs ↓
cli.tsForeground terminal program powered by Bun.Run command →

Routing

agents/research/agent.ts is available at /research/:instance. The instance segment identifies durable state: /research/acme and /research/personal are independent agents.

Route groups

Parenthesized folders organize code and apply middleware without becoming part of the URL. For example, agents/(internal)/review/agent.ts still maps to /review/:instance.

Route documentation

A neighboring docs.md is served at /inventory/docs and passes through the same middleware as the agent. Use it for operator instructions or an agent-specific contract; use this website’s tutorials for framework concepts.