Skip to content

feat: phase3 sub-project 7 — agent protocol + sqlite storage#175

Open
blove wants to merge 21 commits into
mainfrom
feat/phase3-agent-protocol
Open

feat: phase3 sub-project 7 — agent protocol + sqlite storage#175
blove wants to merge 21 commits into
mainfrom
feat/phase3-agent-protocol

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 23, 2026

Summary

  • New @dawn-ai/sqlite-storage package: Dawn-native BaseCheckpointSaver + threads store on Node 22's built-in node:sqlite (no native deps).
  • HTTP layer rewritten to Agent Protocol shape: /threads, /threads/{id}/runs/stream, /threads/{id}/runs/wait, /threads/{id}/state, /threads/{id}/resume.
  • MemorySaver removed from @dawn-ai/langchain; checkpointer is now pluggable via dawn.config.ts.checkpointer and .threadsStore, with SQLite-backed defaults at .dawn/checkpoints.sqlite + .dawn/threads.sqlite.
  • Conversation state survives server restart, verified by new integration test test/runtime/run-agent-protocol.test.ts.

Test plan

  • Unit tests for checkpointer + threads store + migrations (17 pass in @dawn-ai/sqlite-storage)
  • Integration: AP state persistence across server kill+restart (run-agent-protocol.test.ts)
  • Resume regression under new /threads/{id}/resume URL (existing resume-endpoint.test.ts)
  • CLI tests ported to AP shape (run, test, check, typegen, dev)
  • Verification harness packs @dawn-ai/sqlite-storage
  • Full lint + test green (524/524 unit tests)
  • Chrome MCP smoke against chat example: two messages in same thread, restart server, verify context persists

Spec: docs/superpowers/specs/2026-05-22-phase3-agent-protocol-design.md
Plan: docs/superpowers/plans/2026-05-22-phase3-agent-protocol.md

🤖 Generated with Claude Code

blove and others added 21 commits May 22, 2026 09:23
Spec for AP-compatible HTTP endpoints + Dawn-native SQLite checkpointer.
Single @dawn-ai/sqlite-storage package using node:sqlite directly.
One SQLite per concern: checkpoints.sqlite + threads.sqlite + existing
permissions.json. Replaces ad-hoc /runs/stream with thread-keyed AP shape.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
16 tasks covering @dawn-ai/sqlite-storage package, agent-adapter rewiring,
AP HTTP routes, chat-example proxy updates, harness packing, and
restart-persistence integration test.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements getTuple, list, put, putWrites, and deleteThread against
node:sqlite via the existing openDb/runMigrations infrastructure.
Adds @langchain/core as peer+devDep so RunnableConfig resolves at compile time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tics

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds optional BaseCheckpointSaver + ThreadsStore fields so applications can
inject custom persistence. CLI runtime instantiates sqlite-backed defaults
when these are unset (T10).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Remove the module-level MemorySaver singleton from agent-adapter and require
callers to supply a BaseCheckpointSaver via AgentOptions.checkpointer (and
materializeAgentGraph options). Tests supply new MemorySaver() explicitly,
keeping the "tests own their dependencies" pattern intact. T10 will wire the
SQLite-backed checkpointer from the CLI runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wire @dawn-ai/sqlite-storage into execute-route: prepareRouteExecution
now loads dawn.config and creates sqliteCheckpointer (checkpoints.sqlite)
and createThreadsStore (threads.sqlite) under .dawn/ by default, or uses
user-provided values from dawn.config. The checkpointer is passed to every
executeAgent/streamAgent call site. A new resolveThreadsStore() helper is
exported so the HTTP server layer (T11+) can obtain the same store.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace ad-hoc /runs/stream and /runs/wait routes with thread-keyed
Agent Protocol routes: POST/GET/DELETE /threads/:id, POST
/threads/:id/runs/stream and /threads/:id/runs/wait (SSE + blocking),
GET /threads/:id/state (checkpoint read), POST /threads/:id/resume
(interrupt resolution). Adds resolveCheckpointer + invokeResolvedRoute
exports to execute-route.ts and threads-store lifecycle (busy/idle)
around each run. Updates dev-command tests to the new AP shape.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update /api/chat to POST to /threads/:thread_id/runs/stream with the
new AP body shape (input + route). The permission-resume proxy already
targets /threads/:thread_id/resume and required no changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add @dawn-ai/sqlite-storage to all packing manifests and dependency-
rewrite blocks so the verification harnesses can install it from a
local tarball rather than the (unpublished) npm registry.

Also add as a direct dependency (not just pnpm.overrides) because pnpm
cannot apply overrides for packages that have never been published to
the registry — it requires a metadata lookup to succeed first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update execute-route-server.ts and test harnesses to use the thread-keyed
AP URL shape (POST /threads/:id/runs/wait with {input, route} body) that
replaced the legacy /runs/wait endpoint in T11+T12. Suppress Node's
node:sqlite ExperimentalWarning in spawned child processes via
NODE_NO_WARNINGS=1 so non-empty stderr no longer trips the harness's
stderr-clean check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds test/runtime/run-agent-protocol.test.ts which proves that
LangGraph checkpoint state written via POST /threads/:id/runs/wait
survives a Dawn dev-server kill and restart on a fresh port, by
reading GET /threads/:id/state from the new process and asserting
that messages and config.configurable match the pre-restart capture.

The echo-agent overlay is a zero-LLM LangGraph StateGraph compiled
against the same .dawn/checkpoints.sqlite path that Dawn uses; no
real model calls are made. The vitest.config.ts include list is
updated to run both runtime test files under pnpm test:runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Auto-fix from biome after T11+T12 AP route updates.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Fake agent servers in run-command + test-command match /threads/:id/runs/wait
- run-command body assertion updated to {input, route} shape
- typegen-command packs @dawn-ai/sqlite-storage tarball
- check + typegen subprocesses set NODE_NO_WARNINGS=1 to silence
  node:sqlite experimental warning

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dawnai Ready Ready Preview, Comment May 23, 2026 3:17pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant