Documentation
¶
Overview ¶
Command website shows how a website embeds the harness as a Go library: one process serving its own pages and endpoints next to the agent.
WEBSITE_ADDR=:8080 LLM_API_KEY=... go run ./examples/website
What it demonstrates (docs/embedding.md has the step-by-step):
- an Authenticator that maps the site's session to a user id (here a header set by the site's own auth layer; never trust one from a browser);
- per-user thread listing, with ownership enforced by the harness (a thread of another user is "not found");
- a host-defined tool (lookup_order) registered with a Feature, scoped to the user the run belongs to;
- a per-request choice of Sandbox: off for questions and API calls, auto (sandbox created lazily on the first command) when the user asks for code;
- hosts/web's JSON+SSE handler mounted under /agent/;
- graceful shutdown: stop accepting requests, let in-flight runs finish.
One process (this file) uses the in-memory queue and event log. To scale out, keep the same code but give harness.Options a Postgres store (store/pgstore) and Redis (Options.Redis); the web processes then never call h.Run (they only Send and stream events) and the agent processes run hosts/worker; see docs/embedding.md.