Examples
Every example in the repo, and whether it needs a real API key. The *-mock-test.ts files run against createMockProvider() or real local infrastructure (SQLite, a mock WebSocket server, the built CLI) — no external calls, no API key.
examples/basic.tsMinimal createClient() + tool call round-trip against a real provider.
examples/agent-handoff.tsTwo agents, a real provider, one handing off packing advice to the other.
examples/agent-runtime-mock-test.tsTool calls, handoffs, loop prevention, and session persistence — no API key needed.
examples/agent-structured-output-mock-test.tsgenerateObject() validate + repair loop — no API key needed.
examples/reliability-mock-test.tswithTimeout(), tool guardrails, and the full approval workflow — no API key needed.
examples/resilience-tracing-mock-test.tsRetries, fallbacks, and timeouts exercised against real wrappers, asserted visible in RunTrace.
examples/session-stores-mock-test.tsSqliteSessionStore against a real on-disk database, plus RedisSessionStore logic.
examples/provider-conversion-mock-test.tsBedrock/Anthropic message + prompt-caching conversion logic — no API key needed.
examples/rag-mock-test.tsVector store + retrieval tool, embed → search → return, end to end — no API key needed.
examples/cli-mock-test.tsRuns the real built CLI binary, typechecks the scaffolded output.
examples/checkpoint-resume-mock-test.tsGenuine simulated crash mid-run + resume, proves no tool call is re-executed.
examples/testing-utils-mock-test.tscreateMockProvider(), withConcurrencyLimit(), withRateLimit() — real timing assertions.
examples/otel-export-mock-test.tsexportRunTraceToOtel() against the real @opentelemetry/sdk-trace-base in-memory exporter.
examples/trace-viewer-mock-test.tsrenderTraceHTML() content + the real CLI trace server, fetched over HTTP.
examples/generate-object.tsgenerateObject() against a real provider with a zod schema.
examples/stream-object.tsstreamObject() driving a progressively-filled UI card.
examples/react-usage.tsxuseAgent() driving a chat component end to end.
examples/vue-usage-mock-test.tsVue useAgent() against real Vue reactivity.
examples/svelte-usage-mock-test.tsSvelte useAgent() against a real store subscription.
examples/graph-memory-mock-test.tsenableGraphMemory() sweep -> tool call -> fake driver, asserted end to end.
examples/graph-memory-self-correction-mock-test.tsPlants duplicate nodes/generic relations/overload; curator's fix asserted against the driver.
examples/graph-memory-self-correction-clean-mock-test.tsA clean graph correctly skips the curator entirely.
examples/graph-memory-feed-engine-mock-test.tsHybrid ranking: a low-like post with social+interest match outranks raw virality.
examples/graph-memory-admin-mock-test.tsDB uniqueness constraints + deleteUserGraph(), both shallow and deep modes.
examples/graph-memory-fact-lifecycle-mock-test.tsupsert_fact timestamping/contradictions, decay math, and an actual injection attempt rejected.
examples/graph-memory-metrics-mock-test.tscreateMetricsCollector() aggregation across every recorded event, asserted numerically.
examples/graph-memory-manager-mock-test.tsShared driver across users, cached per-user, closed exactly once on stopAll().
Running them
npm run example:basic
npm run example:agent-handoff # needs ANTHROPIC_API_KEY
npm run example:agent-runtime-mock-test # no API key needed
npm run example:reliability-mock-test # no API key needed
npm run example:resilience-tracing-mock-test # no API key needed
npm run example:session-stores-mock-test # no API key needed
npm run example:checkpoint-resume-mock-test # no API key needed
npm run example:otel-export-mock-test # no API key needed
npm run example:graph-memory-mock-test # no API key needed
npm test # runs all 28 mock-test suites together