feat(broker): scaffold apps/broker workspace (bun WS runtime, no port yet)

- @claudemesh/broker package with bun dev/start scripts
- src/index.ts stub: WS server on BROKER_PORT, SIGTERM cleanup
- src/env.ts: Zod-validated env (BROKER_PORT, DATABASE_URL, STATUS_TTL_SECONDS, HOOK_FRESH_WINDOW_SECONDS)
- src/db.ts: re-exports Drizzle client from @turbostarter/db
- src/broker.ts + src/types.ts: placeholders for step 8 port
- README documents run commands, env vars, deploy targets
- tsconfig extends @turbostarter/tsconfig base
- eslint.config.js extends @turbostarter/eslint-config/base

Dependencies declared but not installed yet (ws, drizzle-orm, zod,
libsodium-wrappers + workspace deps). turbo.json unchanged: the global
dev task already has persistent=true + cache=false which is what the
broker needs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-04 21:24:17 +01:00
parent d3163a5bff
commit d5d0e6fdbb
9 changed files with 264 additions and 0 deletions

12
apps/broker/src/broker.ts Normal file
View File

@@ -0,0 +1,12 @@
// TODO: port from ~/tools/claude-intercom/broker.ts in step 8
//
// That implementation carries the battle-tested pieces we'll migrate:
// - status_source column (hook > manual > jsonl) + writeStatus rules
// - TTL sweeper for stuck-"working" peers
// - Pending hook statuses (first-turn race handler)
// - /hook/set-status endpoint for Claude Code hook scripts
//
// The port swaps SQLite prepared statements for Drizzle queries against
// the `mesh` pgSchema (see packages/db/src/schema/mesh.ts). All logic
// and test patterns are ported verbatim — only the persistence layer
// changes.