@@ -1593,6 +1593,59 @@ await session.addMcp({
15931593
15941594---
15951595
1596+ ## Filesystem-First Agents
1597+
1598+ A durable agent can be defined entirely by a ** directory** — no code — and run by
1599+ the built-in ` serve ` daemon. One folder holds the agent's role, config, skills,
1600+ cron schedules, and tools:
1601+
1602+ ``` text
1603+ my-agent/
1604+ ├── instructions.md (required) Role/guidelines — injected as a prompt SLOT.
1605+ ├── agent.acl (optional) Model, providers, queue.
1606+ ├── skills/ (optional) *.md skills.
1607+ ├── schedules/ (optional) *.md cron jobs (frontmatter `cron:` + body prompt).
1608+ └── tools/ (optional) *.md tools: `kind: mcp` (MCP server) or
1609+ `kind: script` (sandboxed QuickJS over `program`).
1610+ ```
1611+
1612+ ` AgentDir::load ` synthesizes the existing config objects from that folder — it adds
1613+ no new runtime or prompt system. ` serve_agent_dir ` then runs each enabled schedule
1614+ on its own durable session, and every fire is a FULL harness turn (context, tool
1615+ visibility, safety gate, verification), never a raw model call. ` instructions.md `
1616+ is a prompt * slot* , so the harness keeps ` BOUNDARIES ` , the response contract, and
1617+ verification authoritative.
1618+
1619+ ``` rust
1620+ use a3s_code_core :: {Agent , config :: AgentDir , serve :: serve_agent_dir};
1621+ use tokio_util :: sync :: CancellationToken ;
1622+
1623+ let agent_dir = AgentDir :: load (" ./my-agent" )? ;
1624+ let agent = Agent :: from_config (agent_dir . config. clone ()). await ? ;
1625+ serve_agent_dir (& agent , & agent_dir , " ./workspace" , None , CancellationToken :: new ()). await ? ;
1626+ ```
1627+
1628+ From the SDKs:
1629+
1630+ ``` js
1631+ const handle = await agent .serveAgentDir (' ./my-agent' , ' ./workspace' )
1632+ // ... runs in the background until:
1633+ await handle .stop ()
1634+ ```
1635+
1636+ - ** ` tools/ ` ** — ` kind: mcp ` registers an MCP server (namespaced
1637+ ` mcp__<server>__<tool> ` ); ` kind: script ` exposes a sandboxed QuickJS tool over the
1638+ ` program ` path, with a fail-closed ` allowed_tools ` allow-list (an omitted list
1639+ grants no tools).
1640+ - ** Rehydrate-on-boot** — pass a ` SessionStore ` and each schedule session resumes
1641+ its accumulated context across daemon restarts (history is restored; the current
1642+ ` instructions.md ` / ` skills/ ` / ` tools/ ` are re-applied each boot).
1643+ - Gated behind the ` serve ` Cargo feature; library-only embedders pay nothing.
1644+
1645+ See [ Filesystem-First Agents] ( https://a3s-lab.github.io/a3s/docs/code/agent-dir ) for the full guide.
1646+
1647+ ---
1648+
15961649## Slash Commands
15971650
15981651Sessions support slash commands:
@@ -1683,6 +1736,7 @@ Full reference and guides: [a3s-lab.github.io/a3s/docs/code](https://a3s-lab.git
16831736- [ Tools & Structured Output] ( https://a3s-lab.github.io/a3s/docs/code/tools )
16841737- [ AHP Protocol] ( https://a3s-lab.github.io/a3s/docs/code/ahp-integration )
16851738- [ Skills] ( https://a3s-lab.github.io/a3s/docs/code/skills )
1739+ - [ Filesystem-First Agents] ( https://a3s-lab.github.io/a3s/docs/code/agent-dir )
16861740- [ Memory] ( https://a3s-lab.github.io/a3s/docs/code/memory )
16871741- [ Security] ( https://a3s-lab.github.io/a3s/docs/code/security )
16881742- [ Hooks] ( https://a3s-lab.github.io/a3s/docs/code/hooks )
0 commit comments