Dashboard API route registrars
packages/dashboard/src/routes.ts remains the single public entrypoint (createApiRoutes(store, options)), but route definitions are registered by domain modules in this directory.
Shared context contract
All registrars receive ApiRoutesContext from ./types.ts, built by createApiRoutesContext() in ./context.ts.
The context centralizes cross-cutting dependencies so registrars preserve behavior without re-implementing plumbing:
- Request/project scoping:
getProjectIdFromRequest,getScopedStore,getProjectContext - Engine-aware fallback behavior for project-bound and root-store APIs
- Runtime loggers and diagnostics emitters (
runtimeLogger,planningLogger,proxyLogger,chatLogger) - Proxy/auth/audit helpers (
proxyToRemoteNode,emitRemoteRouteDiagnostic,emitAuthSyncAuditLog) - Automation/routine resolvers and scope parsing helpers
- Shared error normalization (
rethrowAsApiError)
Registrar module map
register-settings-memory.ts— settings, memory backend, memory file APIsregister-tasks.ts— tasks, comments, documents, activity, task lifecycle operationsregister-planning-chat.ts— planning sessions, subtasks, chat session routesregister-messaging-scripts.ts— scripts API and mailbox/message routesregister-git-github.ts— git/GitHub workflows and related helpersregister-files-terminal-workspaces.ts— files, terminal, workspace file operationsregister-agents-projects-nodes.ts— agents, project metadata, node routesregister-plugins-automation.ts— plugin CRUD, automation, routines/webhooksregister-proxy.ts— remote-node proxy forwarding and SSE proxy routes
Ordering rules (critical)
Express matches in registration order. Keep registrar and in-registrar route ordering stable:
- Specific operation routes before generic parameterized routes (
/runs,/runs/:id,/copy,/deletebefore/:idstyle handlers) - Specific operation routes before wildcard paths (
/files/{*filepath}/copy|move|deletebefore catch-all file write routes) - Do not move proxy/script/message/file wildcards ahead of specific routes
If adding a new endpoint, place it in the domain registrar and verify it does not shadow existing handlers.
Integration mounts that stay in routes.ts
These routers remain mounted directly by the orchestrator and must keep their current prefixes/options wiring:
createMissionRouter→/api/missionscreateRoadmapRouter→/api/roadmapscreateInsightsRouter→/api/insightscreateDevServerRouter→/api/dev-server
Do not re-home these mounts without explicit migration and regression coverage.