Orchestration State 2
Related plan: Orchestration Plan 2
- ✅ Task 1 — Scaffold the Orchestrator Railway Service
- ✅ Create
orchestrator/directory at repo root - ✅ Initialize TypeScript project:
package.json,tsconfig.json,.gitignore - ✅ Install dependencies:
hono,@hono/node-server,dotenv,pg,cuid2,eventsource - ✅ Create entry point:
src/index.ts— Hono server on PORT - ✅ Add health endpoint:
GET /health - ✅ Add basic project structure files (auth, chat-client, dispatcher, db, types)
- ✅ Add scripts to
package.json:dev,build,typecheck - ✅ Verify service starts locally and responds on
/health
- ✅ Create
- ✅ Task 2 — Implement JWT Auth Manager
- ✅ Create
src/auth.tswithAuthManagerclass - ✅ Implement
login(email, password)flow - ✅ Implement
refresh(refreshToken)flow (no Authorization header) - ✅ Implement
getValidToken()with auto-refresh - ✅ Handle orchestrator restart: full re-login
- ✅ Add browser User-Agent header to all requests
- ✅ Store credentials in Railway env vars
- ✅ Unit test: login → getValidToken → wait → getValidToken triggers refresh
- ✅ Create
- ✅ Task 3 — Implement UI Chat API Client
- ✅ Create
src/chat-client.tswithChatClientclass - ✅ Implement
invokeAgent() - ✅ Implement
subscribeToStream()with SSE parsing - ✅ Implement
checkStatus() - ✅ Implement
abortGeneration() - ✅ Create
src/types.tswith all TypeScript interfaces - Integration test: invoke agent, subscribe to stream, capture final event
- ✅ Create
- ✅ Task 4 — Implement Postgres Orchestration State
- ✅ Create
src/db.tswith Postgres connection + pooling - ✅ Create
AgentJobtable schema - ✅ Create
Projecttable schema - ✅ Create indexes
- ✅ Configure
FORGE_DB_URLenv var - ✅ Create
src/ids.tswith Cuid2 ID generation - ✅ Add helper functions:
createJob(),updateJobStatus(),getJob(),upsertProject(),getActiveProjects() - ✅ Create
forgedatabase on Railway VectorDB and run DDL
- ✅ Create
- ✅ Task 5 — Implement Basic HTTP Dispatcher
- ✅ Create
src/dispatcher.tswith dispatch logic - ✅ Implement
POST /orchestrator/runendpoint - ✅ Implement disconnect mode
- ✅ Implement monitor mode placeholder
- ✅ Add
GET /orchestrator/jobs/:jobIdstatus endpoint - ✅ Add
GET /orchestrator/jobslist endpoint - ✅ Wire up dispatcher routes in
src/index.ts - Integration test: invoke agent via endpoint, verify job in Postgres
- ✅ Create
- ✴️ Task 6 — Deploy Orchestrator to Railway
- ✅ Add
railway.jsonconfig - ✅ Create Railway service
Forge Orchestratorwith env vars - ✅ Deploy and verify
/health, auth login, Postgres connection - ✴️ End-to-end test:
POST /orchestrator/run→ agent runs → job tracked
- ✅ Add