initial implementation: brain-dump session server with dual LLM backends

Headless Koa v3 server exposing REST + SSE around the brain-dump skill:
- AgentBackend adapter seam with two implementations: Claude Agent SDK
  (skill loading, session resume via sdk_session_id) and a hand-rolled
  OpenAI-compatible tool-calling loop (vault-scoped file tools, SKILL.md
  injected into the system prompt, history persisted in SQLite)
- session CRUD + one-turn-at-a-time SSE streaming (text deltas, file_write
  events, turn_complete), per-session lock, abort on disconnect
- node:sqlite storage (sessions, messages, turn_events) with migrations
- vault allow-list + symlink-aware path-escape prevention (incl. dangling
  symlink defense), read-only git status/diff endpoints, configurable CORS
- deterministic mock chat-completions server (scripts/mock-openai.ts) for
  end-to-end testing without a real model

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-18 13:48:17 +00:00
co-authored by Claude
parent d579ac744e
commit a5f62512e8
34 changed files with 5092 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
{
"port": 3000,
"dbPath": "./braindump.sqlite",
"cors": { "origins": ["app://obsidian.md", "http://localhost:5173"] },
"skillPath": "~/.claude/skills/brain-dump/SKILL.md",
"defaultBackend": "claude-sdk",
"vaults": [{ "name": "brain", "path": "~/git/brain" }],
"backends": {
"claude-sdk": { "model": "claude-sonnet-5", "permissionMode": "acceptEdits" },
"openai-compat": {
"baseUrl": "http://localhost:11434/v1",
"apiKey": "${OPENROUTER_API_KEY}",
"model": "qwen2.5-coder:32b",
// max tool-call loop iterations per turn (optional, default 32)
"maxToolIterations": 32
}
}
}