feat(dx): real-workerd DO test, README + docs/concepts, 3 examples#30
Conversation
…ples Three days of substrate changes (#28 model-resolution, #29 durable-run supervisor + DO) shipped with no docs and no real-workerd test. This catches the surface up. - Real-workerd integration test for SessionSupervisorDO via @cloudflare/vitest-pool-workers — runs the DO under actual workerd with real DurableObjectState + real ReadableStream + real Response. Pinned to a vitest-3-compatible pool version; separate vitest.workers.config.ts so the main Node suite is unaffected. - README rewrite: entry-point table covers every current primitive — durable turn, supervisor + DO, model resolution, defineAgent, durable chat-turn engine, analyst loop, platform clients. - docs/concepts.md: real mental-model doc — the five layers, the three durability levels, the reconnect-adapter contract, model resolution, reading order for new consumers. Replaces the dead src/index.ts JSDoc link. - examples/model-resolution — resolveChatModel + validateChatModelId (fail-closed) + withConfiguredModels. Runs offline. - examples/durable-supervisor — cross-worker resume keystone: w1 drains 2 of 5, lease lapses, w2 resumes from cursor, full sequence exactly once. Runs offline. - examples/agent-into-reviewer — pipe one runtime's stream into a reviewer agent (the "two-runtime" pattern). Runs offline. Verified: typecheck 0, Node suite 251, workerd suite 2 (real DO), biome clean, build green. All three new examples runnable end-to-end.
tangletools
left a comment
There was a problem hiding this comment.
Verified. Adds @cloudflare/vitest-pool-workers (pinned to v0.8 for vitest-3 compat) + wrangler.workers.toml + a separate vitest.workers.config.ts so SessionSupervisorDO is exercised under real workerd (real DurableObjectState + ReadableStream + Response). README rewrite covers every current primitive in the entry-point table; docs/concepts.md is a real mental-model doc replacing the dead JSDoc link. Three new offline examples — model-resolution, durable-supervisor (cross-worker resume keystone), agent-into-reviewer (two-runtime pipe pattern) — all runnable. typecheck 0, Node suite 251 green, workerd suite 2 green, biome clean (1 pre-existing warning), build green. Substrate lifts (runAnalystEval, parseAgentStream) deliberately deferred to their own focused PRs.
Summary
Three days of substrate changes (#28 model-resolution, #29 durable-run supervisor + DO) shipped with no docs and no real-
workerdtest. This catches the surface up — without over-scoping into a substrate lift.Test it for real
@cloudflare/vitest-pool-workers+wrangler.workers.toml+ a separatevitest.workers.config.ts— runsSessionSupervisorDOunder realworkerdwith realDurableObjectState, realReadableStream, realResponse. The fake-state Node suite covers the supervisor logic exhaustively; this proves the same host works against the actual Cloudflare runtime.@cloudflare/vitest-pool-workers ^0.8— v0.16+ requires vitest 4; pinned to the latest vitest-3-compatible pool.pnpm testis unaffected:vitest.config.tsexcludestests/workers/**, which onlypnpm test:workersruns.Docs
defineAgent, durable chat-turn engine, analyst loop, platform clients. New sections for the durable supervisor, DO host wiring (wrangler.tomlblock), model resolution,defineAgent.docs/concepts.md— real mental-model doc: the five layers, the three durability levels (runAgentTask/runDurableTurn/runSupervisedTurn), theSandboxReconnectAdaptercontract, model resolution, reading order for new consumers. Replaces the deadsrc/index.tsJSDoc link.New examples (3)
All offline-runnable; each in its own dir with a short README.
examples/model-resolution/—resolveChatModel(precedence),validateChatModelId(fail-closed admission + allowlist short-circuit),withConfiguredModels.examples/durable-supervisor/— the cross-worker resume keystone: w1 drains 2 of 5 events, lease lapses, w2 resumes from cursor → caller sees the complete sequence exactly once.examples/agent-into-reviewer/— pipe one runtime's stream into a reviewer agent (the "two-runtime" pattern). Reviewer is just anAgentAdapter; no separate framework.Out of scope (deliberate — would be its own focused PR)
runAnalystEvallift (the ~1,200 LOC byte-identicalanalyst-loop.tsduplication across 4 agents). Real, but it's a substrate primitive + multi-repo refactor — should not muddy a docs/test PR.parseAgentStream(the 4-5 hand-rolled NDJSON decoders).runSimulatedConversation/ retireAgentDriver. Different repo.Test plan
pnpm typecheck— 0 errorspnpm test— 251 passed (17 files)pnpm test:workers— 2 passed under realworkerdpnpm exec biome check src tests examples— clean (1 pre-existing warning)pnpm build— greenpnpm tsx examples/<dir>/<name>.ts