AI & agents
Patties includes optional AI primitives for projects that need agents, tools, jobs, and generated AGENTS.md metadata.
Definitions
Patties exposes:
- agent and tool config types
- job config types
defineAgent()defineTool()defineJob()generateAgentsMd- AI runtime helpers under
patties/ai
App layout
The current repository fixtures show the intended layout:
app/agents/for agent definitionsapp/tools/for callable toolsapp/jobs/for scheduled jobs
Core types
AgentConfigdefines the model, tools, triggers, and token settingsToolConfigdefines description, Zod input schema, and handlerJobConfigdefines the cron schedule, timezone, and handlerAiContextprovides request identity, optional user state, variables, and an Anthropic-like client
Discovery
Build-time scanning collects modules from agents, tools, and jobs directories. Missing directories are allowed, and test files are ignored.
During patties build and patties dev, Patties attempts to regenerate the root AGENTS.md file from the app definition so downstream tools can inspect routes, agents, tools, jobs, and middleware.
Bundle footprint
The AI primitives are opt-in at build time. The generated server entry imports patties/ai only when the app has agents, tools, or jobs, and the Anthropic SDK is loaded lazily when an agent first runs. An app without them carries neither the SDK nor the agent registry in its bun/edge bundle or its --compile binary (which is built from the same entry). @anthropic-ai/sdk stays an optional peer dependency; a regression test asserts the exclusion.