Daemon
Examples
End-to-end, keyless examples. Each one runs in CI, prints a deterministic transcript and asserts its outcome.
Every example lives at examples/ts/<name>/main.ts, imports only the package's public entry points, and runs with
no API key, no claude binary and no network beyond loopback. Agents are scripted fakes from
@viewportai/daemon/testing, or a scripted query() for claude-code.
make examples # typecheck and run all of them
corepack pnpm exec tsx scripts/run-examples.ts pair-direct # one of them| Example | What it proves | Docs |
|---|---|---|
cli-quickstart | The CLI on a temp home: up, run mirrors the exit code, start, ls, stop, pair printing "Paired with phone (viewer)" once a viewer redeems the link over the direct channel, peers ls, peers revoke, down | Quickstart |
quickstart | A supervisor starts an agent session, a policy allows one tool call and denies another, the caller reads messages and the result; a plain command runs through the same supervisor | Quickstart |
pair-direct | A daemon serves on a temp home and offers a link; a viewer pairs over the direct channel with its own identity and store, both sides confirm full fingerprints in groups of 4, then the viewer reconnects in session mode and lists sessions | Pairing |
pair-relay | A daemon with no listening port registers on a relay; a viewer pairs through the relay link, reconnects through the relay and streams a session | Pairing |
claude-code-stream | A viewer starts a claude-code session and streams partial and final messages, tool calls, model_call usage and exit, with contiguous seqs and the Claude session id as agent_session_id | Sessions and streaming |
approval-round-trip | A viewer sees approval_requested with its action_digest, allows with actor and the digest, has a stale digest refused, denies the next call; the agent continues after each answer | Approvals |
crash-recovery | A file-store daemon dies with a live session; the next daemon on the same home fails it with daemon.interrupted_by_restart; the viewer reconnects without re-pairing and resumes the conversation with resume and an idempotency_key, and a retried start returns the same session | Recovery and retries |
The docs never copy code: every snippet is an <include> of a // #region in these files, and make docs fails
when a page has a TypeScript or Python fence or an include that points at a missing region.