@teamclaws/teamclaw 2026.8.1 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +318 -17
- package/dist/index.js +54 -32
- package/dist/src/config.js +57 -2
- package/dist/src/controller/auth-routes.js +129 -0
- package/dist/src/controller/clarification-routes.js +315 -0
- package/dist/src/controller/controller-intake.js +895 -0
- package/dist/src/controller/controller-planning.js +814 -0
- package/dist/src/controller/controller-routes.js +195 -0
- package/dist/src/controller/controller-runs.js +175 -0
- package/dist/src/controller/controller-service.js +338 -50
- package/dist/src/controller/controller-tools.js +14 -7
- package/dist/src/controller/github-auth.js +2 -1
- package/dist/src/controller/http-server.js +290 -6003
- package/dist/src/controller/kickoff-orchestrator.js +33 -43
- package/dist/src/controller/message-delivery.js +31 -0
- package/dist/src/controller/message-routes.js +114 -0
- package/dist/src/controller/orchestration-manifest.js +11 -93
- package/dist/src/controller/preview-manager.js +51 -3
- package/dist/src/controller/preview-proxy.js +98 -0
- package/dist/src/controller/profile-switch.js +309 -0
- package/dist/src/controller/project-registry.js +294 -0
- package/dist/src/controller/prompt-injector.js +19 -9
- package/dist/src/controller/provisioning/backend-contract.js +9 -0
- package/dist/src/controller/provisioning/container-shared.js +64 -0
- package/dist/src/controller/provisioning/docker.js +214 -0
- package/dist/src/controller/provisioning/kubernetes.js +244 -0
- package/dist/src/controller/provisioning/plugin-root.js +41 -0
- package/dist/src/controller/provisioning/process-supervisor.js +190 -0
- package/dist/src/controller/provisioning-config.js +239 -0
- package/dist/src/controller/repo-routes.js +129 -0
- package/dist/src/controller/report-routes.js +56 -0
- package/dist/src/controller/role-inference.js +231 -20
- package/dist/src/controller/route-table.js +375 -0
- package/dist/src/controller/security.js +775 -0
- package/dist/src/controller/status-routes.js +287 -0
- package/dist/src/controller/task-assignment.js +511 -0
- package/dist/src/controller/task-cleanup.js +258 -0
- package/dist/src/controller/task-execution.js +271 -0
- package/dist/src/controller/task-results.js +471 -0
- package/dist/src/controller/task-router.js +74 -4
- package/dist/src/controller/task-routes.js +703 -0
- package/dist/src/controller/teamauto-routes.js +124 -0
- package/dist/src/controller/tunnel-manager.js +41 -8
- package/dist/src/controller/tunnel-routes.js +225 -0
- package/dist/src/controller/ui-assets.js +68 -0
- package/dist/src/controller/websocket.js +6 -2
- package/dist/src/controller/webui-routes.js +49 -0
- package/dist/src/controller/worker-provisioning.js +69 -953
- package/dist/src/controller/worker-routes.js +188 -0
- package/dist/src/controller/workflow-routes.js +407 -0
- package/dist/src/controller/workspace-routes.js +200 -0
- package/dist/src/git-collaboration.js +4 -9
- package/dist/src/identity.js +15 -3
- package/dist/src/interaction-contracts.js +7 -7
- package/dist/src/openclaw-workspace.js +40 -18
- package/dist/src/profile-loader.js +604 -0
- package/dist/src/profiles/banking.json +202 -0
- package/dist/src/profiles/crossborder-ecom.json +253 -0
- package/dist/src/profiles/insurance.json +157 -0
- package/dist/src/profiles/knowledge/hs-structure.md +97 -0
- package/dist/src/profiles/knowledge/incoterms-2020.md +188 -0
- package/dist/src/profiles/knowledge/vat-principles.md +85 -0
- package/dist/src/profiles/schema.json +281 -0
- package/dist/src/profiles/securities.json +137 -0
- package/dist/src/profiles/software-rd.json +264 -0
- package/dist/src/profiles/trading-co.json +200 -0
- package/dist/src/prompt-policy.js +42 -17
- package/dist/src/protocol.js +66 -3
- package/dist/src/role-ids.js +29 -0
- package/dist/src/roles.js +54 -13
- package/dist/src/session-roles.js +14 -0
- package/dist/src/shared/clarification-schema.js +65 -0
- package/dist/src/shared/github-auth.js +15 -0
- package/dist/src/shared/kickoff-prompt.js +37 -0
- package/dist/src/shared/utils.js +47 -0
- package/dist/src/state.js +275 -11
- package/dist/src/task-executor.js +7 -17
- package/dist/src/teamauto/github-client.js +18 -0
- package/dist/src/teamauto/repo-sync.js +228 -6
- package/dist/src/teamauto/scanner.js +40 -12
- package/dist/src/teamauto/scheduler.js +231 -12
- package/dist/src/types.js +77 -16
- package/dist/src/ui/app.js +1434 -82
- package/dist/src/ui/github-login.html +1 -0
- package/dist/src/ui/index.html +144 -45
- package/dist/src/ui/style.css +194 -0
- package/dist/src/worker/http-handler.js +59 -0
- package/dist/src/worker/prompt-injector.js +44 -8
- package/dist/src/worker/skill-installer.js +6 -10
- package/dist/src/worker/tools.js +20 -10
- package/dist/src/worker/worker-service.js +93 -7
- package/index.ts +61 -32
- package/openclaw.plugin.json +50 -2
- package/package.json +3 -2
- package/src/config.ts +57 -2
- package/src/controller/auth-routes.ts +157 -0
- package/src/controller/clarification-routes.ts +404 -0
- package/src/controller/controller-intake.ts +1113 -0
- package/src/controller/controller-planning.ts +1037 -0
- package/src/controller/controller-routes.ts +237 -0
- package/src/controller/controller-runs.ts +239 -0
- package/src/controller/controller-service.ts +422 -50
- package/src/controller/controller-tools.ts +16 -9
- package/src/controller/github-auth.ts +28 -63
- package/src/controller/http-server.ts +336 -6964
- package/src/controller/kickoff-orchestrator.ts +69 -45
- package/src/controller/message-delivery.ts +52 -0
- package/src/controller/message-routes.ts +137 -0
- package/src/controller/orchestration-manifest.ts +14 -100
- package/src/controller/preview-manager.ts +53 -3
- package/src/controller/preview-proxy.ts +127 -0
- package/src/controller/profile-switch.ts +396 -0
- package/src/controller/project-registry.ts +361 -0
- package/src/controller/prompt-injector.ts +23 -8
- package/src/controller/provisioning/backend-contract.ts +51 -0
- package/src/controller/provisioning/container-shared.ts +84 -0
- package/src/controller/provisioning/docker.ts +260 -0
- package/src/controller/provisioning/kubernetes.ts +263 -0
- package/src/controller/provisioning/plugin-root.ts +42 -0
- package/src/controller/provisioning/process-supervisor.ts +214 -0
- package/src/controller/provisioning-config.ts +289 -0
- package/src/controller/repo-routes.ts +163 -0
- package/src/controller/report-routes.ts +64 -0
- package/src/controller/role-inference.ts +260 -22
- package/src/controller/route-table.ts +597 -0
- package/src/controller/security.ts +899 -0
- package/src/controller/status-routes.ts +354 -0
- package/src/controller/task-assignment.ts +622 -0
- package/src/controller/task-cleanup.ts +344 -0
- package/src/controller/task-execution.ts +399 -0
- package/src/controller/task-results.ts +556 -0
- package/src/controller/task-router.ts +98 -6
- package/src/controller/task-routes.ts +812 -0
- package/src/controller/teamauto-routes.ts +121 -0
- package/src/controller/tunnel-manager.ts +45 -8
- package/src/controller/tunnel-routes.ts +231 -0
- package/src/controller/ui-assets.ts +70 -0
- package/src/controller/websocket.ts +32 -4
- package/src/controller/webui-routes.ts +55 -0
- package/src/controller/worker-provisioning.ts +83 -1121
- package/src/controller/worker-routes.ts +241 -0
- package/src/controller/workflow-routes.ts +498 -0
- package/src/controller/workspace-routes.ts +222 -0
- package/src/git-collaboration.ts +4 -9
- package/src/identity.ts +16 -3
- package/src/interaction-contracts.ts +7 -7
- package/src/openclaw-workspace.ts +44 -18
- package/src/profile-loader.ts +816 -0
- package/src/profiles/banking.json +202 -0
- package/src/profiles/crossborder-ecom.json +253 -0
- package/src/profiles/insurance.json +157 -0
- package/src/profiles/knowledge/hs-structure.md +97 -0
- package/src/profiles/knowledge/incoterms-2020.md +188 -0
- package/src/profiles/knowledge/vat-principles.md +85 -0
- package/src/profiles/schema.json +281 -0
- package/src/profiles/securities.json +137 -0
- package/src/profiles/software-rd.json +264 -0
- package/src/profiles/trading-co.json +200 -0
- package/src/prompt-policy.ts +44 -17
- package/src/protocol.ts +72 -2
- package/src/role-ids.ts +31 -0
- package/src/roles.ts +60 -14
- package/src/session-roles.ts +14 -0
- package/src/shared/clarification-schema.ts +81 -0
- package/src/shared/github-auth.ts +92 -0
- package/src/shared/kickoff-prompt.ts +47 -0
- package/src/shared/utils.ts +51 -0
- package/src/state.ts +326 -10
- package/src/task-executor.ts +7 -18
- package/src/teamauto/github-client.ts +23 -1
- package/src/teamauto/repo-sync.ts +248 -7
- package/src/teamauto/scanner.ts +47 -13
- package/src/teamauto/scheduler.ts +261 -17
- package/src/teamauto/store.ts +12 -0
- package/src/types.ts +263 -17
- package/src/ui/app.js +1434 -82
- package/src/ui/github-login.html +1 -0
- package/src/ui/index.html +144 -45
- package/src/ui/style.css +194 -0
- package/src/worker/http-handler.ts +64 -1
- package/src/worker/prompt-injector.ts +48 -8
- package/src/worker/skill-installer.ts +6 -10
- package/src/worker/tools.ts +21 -10
- package/src/worker/worker-service.ts +101 -7
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { TeamState } from "../types.js";
|
|
3
|
+
// PR-D of issue #204: this module owns the declarative route table + the
|
|
4
|
+
// dispatcher that replaced http-server.ts's serial if/startsWith chain. It
|
|
5
|
+
// imports the domain route modules (PR-A/B/C cuts) and must never be
|
|
6
|
+
// imported by the domain modules at runtime and never imports http-server.ts
|
|
7
|
+
// at RUNTIME (only the ControllerHttpDeps type, which is erased at compile
|
|
8
|
+
// time) so the module graph stays acyclic.
|
|
9
|
+
// Issue #226 W2: the handler bodies that PR-D had still kept inline here
|
|
10
|
+
// (web UI / GitHub auth / workspace+model config / controller runs+intake /
|
|
11
|
+
// team status+profiles+switch / reports+health / repo import) moved verbatim
|
|
12
|
+
// into the domain modules below; route-table is now the pure table +
|
|
13
|
+
// dispatcher (+ the tunnel-side tables, whose handlers never read state).
|
|
14
|
+
import type { ControllerHttpDeps } from "./http-server.js";
|
|
15
|
+
import {
|
|
16
|
+
webUiRootRoute,
|
|
17
|
+
webUiIndexRoute,
|
|
18
|
+
webUiGithubLoginPageRoute,
|
|
19
|
+
webUiAssetsRoute,
|
|
20
|
+
} from "./webui-routes.js";
|
|
21
|
+
import {
|
|
22
|
+
githubAuthStatusRoute,
|
|
23
|
+
githubAuthLoginRoute,
|
|
24
|
+
githubAuthCallbackRoute,
|
|
25
|
+
githubAuthLogoutRoute,
|
|
26
|
+
githubAuthRefreshRoute,
|
|
27
|
+
} from "./auth-routes.js";
|
|
28
|
+
import {
|
|
29
|
+
workspaceStatusRoute,
|
|
30
|
+
workspaceChangeDirRoute,
|
|
31
|
+
modelsConfigGetRoute,
|
|
32
|
+
modelsConfigPutRoute,
|
|
33
|
+
workspaceTreeRoute,
|
|
34
|
+
workspaceSubtreeRoute,
|
|
35
|
+
workspaceFileRoute,
|
|
36
|
+
workspaceProjectPathRoute,
|
|
37
|
+
workspaceRawFileRoute,
|
|
38
|
+
} from "./workspace-routes.js";
|
|
39
|
+
import {
|
|
40
|
+
controllerManifestRoute,
|
|
41
|
+
controllerRunsListRoute,
|
|
42
|
+
projectDeleteRoute,
|
|
43
|
+
controllerRunDeleteRoute,
|
|
44
|
+
controllerIntakeRoute,
|
|
45
|
+
} from "./controller-routes.js";
|
|
46
|
+
import {
|
|
47
|
+
teamStatsRoute,
|
|
48
|
+
teamStatusRoute,
|
|
49
|
+
teamRolesRoute,
|
|
50
|
+
teamProfilesListRoute,
|
|
51
|
+
teamProfileGetRoute,
|
|
52
|
+
teamProfileSwitchRoute,
|
|
53
|
+
archivedTeamsRoute,
|
|
54
|
+
} from "./status-routes.js";
|
|
55
|
+
import {
|
|
56
|
+
reportsListRoute,
|
|
57
|
+
reportsSessionRoute,
|
|
58
|
+
healthRoute,
|
|
59
|
+
} from "./report-routes.js";
|
|
60
|
+
import {
|
|
61
|
+
handleTeamAutoActivityRequest,
|
|
62
|
+
handleTeamAutoReposListRequest,
|
|
63
|
+
handleTeamAutoRepoCandidatesRequest,
|
|
64
|
+
handleTeamAutoRepoBindRequest,
|
|
65
|
+
handleTeamAutoRepoItemRequest,
|
|
66
|
+
} from "./teamauto-routes.js";
|
|
67
|
+
import {
|
|
68
|
+
handleRepoStatusRequest,
|
|
69
|
+
handleRepoBundleRequest,
|
|
70
|
+
repoImportRoute,
|
|
71
|
+
} from "./repo-routes.js";
|
|
72
|
+
import { handlePreviewProxyRequest } from "./preview-proxy.js";
|
|
73
|
+
// Issue #226 W2: the tunnel-side tables (gate page + management API, with
|
|
74
|
+
// their inline handler bodies, the gate-page HTML rendering and the tunnel
|
|
75
|
+
// form reader) live in ./tunnel-routes.ts; both factories are re-exported
|
|
76
|
+
// below so http-server.ts's imports are unchanged.
|
|
77
|
+
export { createTunnelGateRoutes, createTunnelManagementRoutes } from "./tunnel-routes.js";
|
|
78
|
+
import {
|
|
79
|
+
handleWorkerDeleteRequest,
|
|
80
|
+
handleWorkerHeartbeatRequest,
|
|
81
|
+
handleWorkerListRequest,
|
|
82
|
+
handleWorkerRegisterRequest,
|
|
83
|
+
} from "./worker-routes.js";
|
|
84
|
+
import {
|
|
85
|
+
handleTaskAssignRequest,
|
|
86
|
+
handleTaskCheckpointRequest,
|
|
87
|
+
handleTaskCreateRequest,
|
|
88
|
+
handleTaskDeleteRequest,
|
|
89
|
+
handleTaskExecutionEventRequest,
|
|
90
|
+
handleTaskExecutionGetRequest,
|
|
91
|
+
handleTaskGetRequest,
|
|
92
|
+
handleTaskHandoffRequest,
|
|
93
|
+
handleTaskListRequest,
|
|
94
|
+
handleTaskParallelHelpRequest,
|
|
95
|
+
handleTaskPatchRequest,
|
|
96
|
+
handleTaskResultContractRequest,
|
|
97
|
+
handleTaskResultRequest,
|
|
98
|
+
} from "./task-routes.js";
|
|
99
|
+
import {
|
|
100
|
+
handleBroadcastMessageRequest,
|
|
101
|
+
handleDirectMessageRequest,
|
|
102
|
+
handleMessageListRequest,
|
|
103
|
+
handleReviewRequestMessageRequest,
|
|
104
|
+
} from "./message-routes.js";
|
|
105
|
+
import {
|
|
106
|
+
handleClarificationAnswerRequest,
|
|
107
|
+
handleClarificationCreateRequest,
|
|
108
|
+
handleClarificationListRequest,
|
|
109
|
+
} from "./clarification-routes.js";
|
|
110
|
+
// Issue #23 (backend wave): device-pairing security domain module. It owns
|
|
111
|
+
// the token/pairing primitives, the auth middleware (wired by
|
|
112
|
+
// http-server.ts), the WS upgrade guard and the handlers registered in the
|
|
113
|
+
// security section of the table below. It imports this file as TYPE ONLY
|
|
114
|
+
// (RouteContext), so the module graph stays acyclic.
|
|
115
|
+
import {
|
|
116
|
+
handleSecurityDeviceDeleteRequest,
|
|
117
|
+
handleSecurityEnableRequest,
|
|
118
|
+
handleSecurityGetRequest,
|
|
119
|
+
handleSecurityPairAutoRequest,
|
|
120
|
+
handleSecurityPairRequest,
|
|
121
|
+
handleSecurityPairStartRequest,
|
|
122
|
+
handleSecurityResetRequest,
|
|
123
|
+
} from "./security.js";
|
|
124
|
+
import type { SecurityPeer } from "./security.js";
|
|
125
|
+
// Design 2.4 workflows backend: POST /api/v1/workflows/{id}/start handler
|
|
126
|
+
// (engine + route live in ./workflow-routes.ts).
|
|
127
|
+
import { workflowStartRoute } from "./workflow-routes.js";
|
|
128
|
+
|
|
129
|
+
// ===========================================================================
|
|
130
|
+
// PR-D of issue #204: declarative route table + dispatcher.
|
|
131
|
+
//
|
|
132
|
+
// Every request that survives the dispatch-layer gates in http-server.ts
|
|
133
|
+
// (CORS preflight -> tunnel gate -> transition matrix -> capability 404
|
|
134
|
+
// gates) is matched against `controllerRouteTable` BELOW IN ARRAY ORDER -
|
|
135
|
+
// the order is a compatibility contract and mirrors the historical
|
|
136
|
+
// if/startsWith chain of http-server.ts one-to-one (order-sensitive pairs:
|
|
137
|
+
// the exact /ui/auth/github routes precede the /ui/ prefix; the exact
|
|
138
|
+
// teamauto repos routes precede the per-repo prefix whose handler may
|
|
139
|
+
// decline with `false` and fall through; the preview proxy prefix sits
|
|
140
|
+
// after every /api/v1 exact route and before reports/health). The parity
|
|
141
|
+
// is pinned by tests/test-route-table.mjs against the pre-PR-D source.
|
|
142
|
+
//
|
|
143
|
+
// RouteDef semantics:
|
|
144
|
+
// - `method`: exact HTTP method, array whitelist, or "*" (any method -
|
|
145
|
+
// used by the teamauto per-repo prefix whose handler self-dispatches).
|
|
146
|
+
// - `path` + `prefix`: a string path is exact pathname equality, unless
|
|
147
|
+
// `prefix: true` marks it as a startsWith prefix (kept as plain strings
|
|
148
|
+
// so the prefix literals stay greppable); a RegExp path is
|
|
149
|
+
// `.test(pathname)` (anchored, for :id routes).
|
|
150
|
+
// - `handler`: receives the RouteContext; returning `false` means "not
|
|
151
|
+
// handled - continue matching" (fall-through), anything else (void,
|
|
152
|
+
// true, a thrown error) ends dispatch. No match at all => the caller
|
|
153
|
+
// answers the final 404.
|
|
154
|
+
// ===========================================================================
|
|
155
|
+
|
|
156
|
+
export type RouteContext = {
|
|
157
|
+
req: IncomingMessage;
|
|
158
|
+
res: ServerResponse;
|
|
159
|
+
/** The parsed request URL (query params via searchParams). */
|
|
160
|
+
requestUrl: URL;
|
|
161
|
+
/** The URL pathname of the request. */
|
|
162
|
+
pathname: string;
|
|
163
|
+
deps: ControllerHttpDeps;
|
|
164
|
+
/**
|
|
165
|
+
* Team state captured once at handleRequest entry (the transition matrix
|
|
166
|
+
* gate reads the same snapshot); null for the tunnel-side tables, whose
|
|
167
|
+
* handlers never read state.
|
|
168
|
+
*/
|
|
169
|
+
currentState: TeamState | null;
|
|
170
|
+
/**
|
|
171
|
+
* Issue #23: per-request peer classification (loopback/LAN/tunnel)
|
|
172
|
+
* computed by the composition root alongside the device-auth gate; the
|
|
173
|
+
* pairing handlers read it to enforce their origin rules (enable:
|
|
174
|
+
* loopback only; pair-auto: LAN only). Absent for the tunnel-side
|
|
175
|
+
* tables.
|
|
176
|
+
*/
|
|
177
|
+
peer?: SecurityPeer;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export type RouteHandler = (ctx: RouteContext) => Promise<boolean | void> | boolean | void;
|
|
181
|
+
|
|
182
|
+
export type RouteDef = {
|
|
183
|
+
/** HTTP method, method whitelist, or "*" for any method. */
|
|
184
|
+
method: string | string[];
|
|
185
|
+
/** Exact pathname (string), startsWith prefix (string + prefix: true), or predicate (RegExp). */
|
|
186
|
+
path: string | RegExp;
|
|
187
|
+
/** Treat a string `path` as a startsWith prefix instead of exact equality. */
|
|
188
|
+
prefix?: boolean;
|
|
189
|
+
handler: RouteHandler;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
function routeMethodMatches(routeMethod: string | string[], method: string): boolean {
|
|
193
|
+
if (routeMethod === "*") {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
return Array.isArray(routeMethod) ? routeMethod.includes(method) : routeMethod === method;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function routePathMatches(route: RouteDef, pathname: string): boolean {
|
|
200
|
+
if (typeof route.path === "string") {
|
|
201
|
+
return route.prefix === true ? pathname.startsWith(route.path) : pathname === route.path;
|
|
202
|
+
}
|
|
203
|
+
return route.path.test(pathname);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Matches `ctx` against `routes` in array order. Returns true when a route
|
|
208
|
+
* handled the request (handler did not return false); false when the table
|
|
209
|
+
* was exhausted, in which case the caller answers the final 404.
|
|
210
|
+
*/
|
|
211
|
+
export async function dispatchRoutes(routes: readonly RouteDef[], ctx: RouteContext): Promise<boolean> {
|
|
212
|
+
const method = ctx.req.method ?? "";
|
|
213
|
+
for (const route of routes) {
|
|
214
|
+
if (!routeMethodMatches(route.method, method)) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (!routePathMatches(route, ctx.pathname)) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const handled = await route.handler(ctx);
|
|
221
|
+
if (handled !== false) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
// handler declined (teamauto per-repo pattern): keep matching.
|
|
225
|
+
}
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ===========================================================================
|
|
230
|
+
// Shared helpers. W2 of issue #226: the helpers whose consumers moved out
|
|
231
|
+
// (shell escaping, LAN-URL building, the GitHub callback HTML renderer,
|
|
232
|
+
// workspace error mapping, team stats, the tunnel form reader) moved with
|
|
233
|
+
// them; nothing inline remains in this module.
|
|
234
|
+
// ===========================================================================
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Retry hint shared by the transition-matrix gate (http-server.ts, task
|
|
238
|
+
* submission / repo import) and the intake handler. Declared in
|
|
239
|
+
* ./controller-routes.ts since W2 (it moved with the intake handler body);
|
|
240
|
+
* re-exported here so http-server.ts's gate import is unchanged.
|
|
241
|
+
*/
|
|
242
|
+
export { SWITCH_TASK_SUBMISSION_RETRY_AFTER_SECONDS } from "./controller-routes.js";
|
|
243
|
+
|
|
244
|
+
// ===========================================================================
|
|
245
|
+
// Route handlers. The PR-A/B/C domain handlers are forwarded to unchanged;
|
|
246
|
+
// every handler body that was still inline here moved verbatim into its
|
|
247
|
+
// domain module with W2 of issue #226 (see the import block): route-table
|
|
248
|
+
// binds the exported handlers directly, exactly like the issue-#23 security
|
|
249
|
+
// handlers. Only the thin forwarder shells for the PR-A/B/C domain modules
|
|
250
|
+
// (whose handlers predate RouteContext) and the preview-proxy fire-and-
|
|
251
|
+
// forget shell remain below.
|
|
252
|
+
// ===========================================================================
|
|
253
|
+
|
|
254
|
+
// ---- TeamAuto (pre-PR-D lines 631-654; handlers in ./teamauto-routes.ts) ----
|
|
255
|
+
|
|
256
|
+
async function teamAutoActivityRoute(ctx: RouteContext): Promise<void> {
|
|
257
|
+
await handleTeamAutoActivityRequest(ctx.deps, ctx.res);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function teamAutoReposListRoute(ctx: RouteContext): Promise<void> {
|
|
261
|
+
await handleTeamAutoReposListRequest(ctx.deps, ctx.res);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Selectable repos for the bind picker (the logged-in GitHub account's).
|
|
265
|
+
async function teamAutoRepoCandidatesRoute(ctx: RouteContext): Promise<void> {
|
|
266
|
+
await handleTeamAutoRepoCandidatesRequest(ctx.deps, ctx.res);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function teamAutoRepoBindRoute(ctx: RouteContext): Promise<void> {
|
|
270
|
+
await handleTeamAutoRepoBindRequest(ctx.deps, ctx.req, ctx.res);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Any-method prefix route: the handler self-dispatches by method and
|
|
274
|
+
// DECLINES (returns false) for methods it does not own, falling through to
|
|
275
|
+
// the rest of the table - preserved by returning its boolean upstream.
|
|
276
|
+
function teamAutoRepoItemRoute(ctx: RouteContext): Promise<boolean> {
|
|
277
|
+
return handleTeamAutoRepoItemRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---- Worker Management (pre-PR-D lines 939-960; handlers in ./worker-routes.ts) ----
|
|
281
|
+
|
|
282
|
+
async function workerRegisterRoute(ctx: RouteContext): Promise<void> {
|
|
283
|
+
await handleWorkerRegisterRequest(ctx.deps, ctx.req, ctx.res);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
async function workerDeleteRoute(ctx: RouteContext): Promise<void> {
|
|
287
|
+
await handleWorkerDeleteRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async function workerListRoute(ctx: RouteContext): Promise<void> {
|
|
291
|
+
await handleWorkerListRequest(ctx.deps, ctx.res);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async function workerHeartbeatRoute(ctx: RouteContext): Promise<void> {
|
|
295
|
+
await handleWorkerHeartbeatRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ---- Task Management (pre-PR-D lines 968-1100; handlers in ./task-routes.ts) ----
|
|
299
|
+
|
|
300
|
+
async function taskCreateRoute(ctx: RouteContext): Promise<void> {
|
|
301
|
+
await handleTaskCreateRequest(ctx.deps, ctx.req, ctx.res);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function taskListRoute(ctx: RouteContext): Promise<void> {
|
|
305
|
+
await handleTaskListRequest(ctx.deps, ctx.res);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async function taskGetRoute(ctx: RouteContext): Promise<void> {
|
|
309
|
+
await handleTaskGetRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async function taskDeleteRoute(ctx: RouteContext): Promise<void> {
|
|
313
|
+
await handleTaskDeleteRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
async function taskExecutionGetRoute(ctx: RouteContext): Promise<void> {
|
|
317
|
+
await handleTaskExecutionGetRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
async function taskPatchRoute(ctx: RouteContext): Promise<void> {
|
|
321
|
+
await handleTaskPatchRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async function taskAssignRoute(ctx: RouteContext): Promise<void> {
|
|
325
|
+
await handleTaskAssignRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async function taskHandoffRoute(ctx: RouteContext): Promise<void> {
|
|
329
|
+
await handleTaskHandoffRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// POST /api/v1/tasks/:id/checkpoint - worker persists an execution progress
|
|
333
|
+
// snapshot so an interrupted task can resume instead of restarting.
|
|
334
|
+
async function taskCheckpointRoute(ctx: RouteContext): Promise<void> {
|
|
335
|
+
await handleTaskCheckpointRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function taskResultContractRoute(ctx: RouteContext): Promise<void> {
|
|
339
|
+
await handleTaskResultContractRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function taskResultRoute(ctx: RouteContext): Promise<void> {
|
|
343
|
+
await handleTaskResultRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
async function taskExecutionEventRoute(ctx: RouteContext): Promise<void> {
|
|
347
|
+
await handleTaskExecutionEventRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
async function taskParallelHelpRoute(ctx: RouteContext): Promise<void> {
|
|
351
|
+
await handleTaskParallelHelpRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// ---- Message Routing (pre-PR-D lines 1292-1313; handlers in ./message-routes.ts) ----
|
|
355
|
+
|
|
356
|
+
async function messageDirectRoute(ctx: RouteContext): Promise<void> {
|
|
357
|
+
await handleDirectMessageRequest(ctx.deps, ctx.req, ctx.res);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async function messageBroadcastRoute(ctx: RouteContext): Promise<void> {
|
|
361
|
+
await handleBroadcastMessageRequest(ctx.deps, ctx.req, ctx.res);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async function messageReviewRequestRoute(ctx: RouteContext): Promise<void> {
|
|
365
|
+
await handleReviewRequestMessageRequest(ctx.deps, ctx.req, ctx.res);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function messageListRoute(ctx: RouteContext): Promise<void> {
|
|
369
|
+
await handleMessageListRequest(ctx.deps, ctx.res, ctx.requestUrl);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// ---- Clarification Requests (pre-PR-D lines 1318-1333; handlers in ./clarification-routes.ts) ----
|
|
373
|
+
|
|
374
|
+
async function clarificationCreateRoute(ctx: RouteContext): Promise<void> {
|
|
375
|
+
await handleClarificationCreateRequest(ctx.deps, ctx.req, ctx.res);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
async function clarificationListRoute(ctx: RouteContext): Promise<void> {
|
|
379
|
+
await handleClarificationListRequest(ctx.deps, ctx.res);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async function clarificationAnswerRoute(ctx: RouteContext): Promise<void> {
|
|
383
|
+
await handleClarificationAnswerRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// ---- Git Collaboration (pre-PR-D lines 1342-1412) ----
|
|
387
|
+
// PR-B of issue #204: the repo status/bundle handlers and the shared
|
|
388
|
+
// refreshControllerRepoState glue live in ./repo-routes.ts; the POST
|
|
389
|
+
// /repo/import handler body joined them with W2 of issue #226 (its
|
|
390
|
+
// recordTaskExecutionEvent dependency is task-lifecycle glue owned by the
|
|
391
|
+
// PR-C cut - acyclic, see the repo-routes.ts header).
|
|
392
|
+
|
|
393
|
+
async function repoStatusRoute(ctx: RouteContext): Promise<void> {
|
|
394
|
+
await handleRepoStatusRequest(ctx.deps, ctx.res);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async function repoBundleRoute(ctx: RouteContext): Promise<void> {
|
|
398
|
+
await handleRepoBundleRequest(ctx.deps, ctx.res);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ---- Previews / reports / health (pre-PR-D lines 1580-1633) ----
|
|
402
|
+
// W2 of issue #226: the reports list/session and health handler bodies live
|
|
403
|
+
// in ./report-routes.ts; only the fire-and-forget preview-proxy shell stays.
|
|
404
|
+
|
|
405
|
+
// /api/v1/previews/:id/* — proxy to preview subprocess.
|
|
406
|
+
// PR-B of issue #204: the proxy implementation lives in ./preview-proxy.ts.
|
|
407
|
+
// Deliberately NOT awaited (fire-and-forget proxy), exactly as before.
|
|
408
|
+
function previewsProxyRoute(ctx: RouteContext): void {
|
|
409
|
+
handlePreviewProxyRequest(ctx.deps, ctx.req, ctx.res, ctx.requestUrl, ctx.pathname);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// ===========================================================================
|
|
413
|
+
// The controller route table. ORDER IS LOAD-BEARING: it mirrors the pre-PR-D
|
|
414
|
+
// if/startsWith chain of http-server.ts one-to-one (the "old lines" in the
|
|
415
|
+
// section comments refer to http-server.ts at e223767, the merge base of
|
|
416
|
+
// this branch). tests/test-route-table.mjs asserts this order against both
|
|
417
|
+
// a hardcoded expectation and that git snapshot.
|
|
418
|
+
// ===========================================================================
|
|
419
|
+
|
|
420
|
+
export const controllerRouteTable: readonly RouteDef[] = [
|
|
421
|
+
// ==================== Web UI (old lines 588-625) ====================
|
|
422
|
+
{ method: "GET", path: "/", handler: webUiRootRoute },
|
|
423
|
+
{ method: "GET", path: "/ui", handler: webUiIndexRoute },
|
|
424
|
+
{ method: "GET", path: "/ui/", handler: webUiIndexRoute },
|
|
425
|
+
// Standalone GitHub device-login page (big user code + prefilled link + polling).
|
|
426
|
+
{ method: "GET", path: "/ui/auth/github", handler: webUiGithubLoginPageRoute },
|
|
427
|
+
{ method: "GET", path: "/ui/auth/github/", handler: webUiGithubLoginPageRoute },
|
|
428
|
+
{ method: "GET", path: "/ui/", prefix: true, handler: webUiAssetsRoute },
|
|
429
|
+
|
|
430
|
+
// ==================== TeamAuto (old lines 631-654) ====================
|
|
431
|
+
{ method: "GET", path: "/api/v1/teamauto/activity", handler: teamAutoActivityRoute },
|
|
432
|
+
{ method: "GET", path: "/api/v1/teamauto/repos", handler: teamAutoReposListRoute },
|
|
433
|
+
// Selectable repos for the bind picker (the logged-in GitHub account's).
|
|
434
|
+
{ method: "GET", path: "/api/v1/teamauto/repo-candidates", handler: teamAutoRepoCandidatesRoute },
|
|
435
|
+
{ method: "POST", path: "/api/v1/teamauto/repos", handler: teamAutoRepoBindRoute },
|
|
436
|
+
// Per-repo prefix, any method: exact entries above win first; the handler
|
|
437
|
+
// declines (false) for unknown methods and dispatch falls through.
|
|
438
|
+
{ method: "*", path: "/api/v1/teamauto/repos/", prefix: true, handler: teamAutoRepoItemRoute },
|
|
439
|
+
|
|
440
|
+
// ==================== GitHub Auth (old lines 658-753) ====================
|
|
441
|
+
{ method: "GET", path: "/api/v1/auth/github/status", handler: githubAuthStatusRoute },
|
|
442
|
+
{ method: "POST", path: "/api/v1/auth/github/login", handler: githubAuthLoginRoute },
|
|
443
|
+
{ method: "GET", path: "/api/v1/auth/github/callback", handler: githubAuthCallbackRoute },
|
|
444
|
+
{ method: "POST", path: "/api/v1/auth/github/logout", handler: githubAuthLogoutRoute },
|
|
445
|
+
{ method: "POST", path: "/api/v1/auth/github/refresh", handler: githubAuthRefreshRoute },
|
|
446
|
+
|
|
447
|
+
// ==================== Workspace Browser (old lines 757-931) ====================
|
|
448
|
+
{ method: "GET", path: "/api/v1/workspace/status", handler: workspaceStatusRoute },
|
|
449
|
+
{ method: "POST", path: "/api/v1/workspace/change-dir", handler: workspaceChangeDirRoute },
|
|
450
|
+
// GET /api/v1/models/config - model catalog + current selection for the UI settings dialog
|
|
451
|
+
{ method: "GET", path: "/api/v1/models/config", handler: modelsConfigGetRoute },
|
|
452
|
+
// PUT /api/v1/models/config - persist default and per-role model selection
|
|
453
|
+
{ method: "PUT", path: "/api/v1/models/config", handler: modelsConfigPutRoute },
|
|
454
|
+
{ method: "GET", path: "/api/v1/workspace/tree", handler: workspaceTreeRoute },
|
|
455
|
+
{ method: "GET", path: "/api/v1/workspace/subtree", handler: workspaceSubtreeRoute },
|
|
456
|
+
{ method: "GET", path: "/api/v1/workspace/file", handler: workspaceFileRoute },
|
|
457
|
+
{ method: "GET", path: "/api/v1/workspace/project-path", handler: workspaceProjectPathRoute },
|
|
458
|
+
{ method: "GET", path: "/api/v1/workspace/raw/", prefix: true, handler: workspaceRawFileRoute },
|
|
459
|
+
|
|
460
|
+
// ==================== Worker Management (old lines 939-960) ====================
|
|
461
|
+
// POST /api/v1/workers/register
|
|
462
|
+
{ method: "POST", path: "/api/v1/workers/register", handler: workerRegisterRoute },
|
|
463
|
+
// DELETE /api/v1/workers/:id
|
|
464
|
+
{ method: "DELETE", path: /^\/api\/v1\/workers\/[^/]+$/, handler: workerDeleteRoute },
|
|
465
|
+
// GET /api/v1/workers
|
|
466
|
+
{ method: "GET", path: "/api/v1/workers", handler: workerListRoute },
|
|
467
|
+
// POST /api/v1/workers/:id/heartbeat
|
|
468
|
+
{ method: "POST", path: /^\/api\/v1\/workers\/[^/]+\/heartbeat$/, handler: workerHeartbeatRoute },
|
|
469
|
+
|
|
470
|
+
// ==================== Task Management (old lines 968-1100) ====================
|
|
471
|
+
// POST /api/v1/tasks
|
|
472
|
+
{ method: "POST", path: "/api/v1/tasks", handler: taskCreateRoute },
|
|
473
|
+
// GET /api/v1/tasks
|
|
474
|
+
{ method: "GET", path: "/api/v1/tasks", handler: taskListRoute },
|
|
475
|
+
// GET /api/v1/stats
|
|
476
|
+
{ method: "GET", path: "/api/v1/stats", handler: teamStatsRoute },
|
|
477
|
+
// GET /api/v1/tasks/:id
|
|
478
|
+
{ method: "GET", path: /^\/api\/v1\/tasks\/[^/]+$/, handler: taskGetRoute },
|
|
479
|
+
// DELETE /api/v1/tasks/:id
|
|
480
|
+
{ method: "DELETE", path: /^\/api\/v1\/tasks\/[^/]+$/, handler: taskDeleteRoute },
|
|
481
|
+
// GET /api/v1/tasks/:id/execution
|
|
482
|
+
{ method: "GET", path: /^\/api\/v1\/tasks\/[^/]+\/execution$/, handler: taskExecutionGetRoute },
|
|
483
|
+
// PATCH /api/v1/tasks/:id
|
|
484
|
+
{ method: "PATCH", path: /^\/api\/v1\/tasks\/[^/]+$/, handler: taskPatchRoute },
|
|
485
|
+
// POST /api/v1/tasks/:id/assign
|
|
486
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/assign$/, handler: taskAssignRoute },
|
|
487
|
+
// POST /api/v1/tasks/:id/handoff
|
|
488
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/handoff$/, handler: taskHandoffRoute },
|
|
489
|
+
// POST /api/v1/tasks/:id/checkpoint - worker persists an execution progress
|
|
490
|
+
// snapshot so an interrupted task can resume instead of restarting.
|
|
491
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/checkpoint$/, handler: taskCheckpointRoute },
|
|
492
|
+
// POST /api/v1/tasks/:id/result-contract
|
|
493
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/result-contract$/, handler: taskResultContractRoute },
|
|
494
|
+
// POST /api/v1/tasks/:id/result
|
|
495
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/result$/, handler: taskResultRoute },
|
|
496
|
+
// POST /api/v1/tasks/:id/execution
|
|
497
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/execution$/, handler: taskExecutionEventRoute },
|
|
498
|
+
// POST /api/v1/tasks/:id/parallel-help
|
|
499
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/parallel-help$/, handler: taskParallelHelpRoute },
|
|
500
|
+
|
|
501
|
+
// ==================== Message Routing (old lines 1109-1313) ====================
|
|
502
|
+
// POST /api/v1/controller/manifest
|
|
503
|
+
{ method: "POST", path: "/api/v1/controller/manifest", handler: controllerManifestRoute },
|
|
504
|
+
// GET /api/v1/controller/runs
|
|
505
|
+
{ method: "GET", path: "/api/v1/controller/runs", handler: controllerRunsListRoute },
|
|
506
|
+
// DELETE /api/v1/projects/:projectDir
|
|
507
|
+
{ method: "DELETE", path: /^\/api\/v1\/projects\/[^/]+$/, handler: projectDeleteRoute },
|
|
508
|
+
// DELETE /api/v1/controller/runs/:id
|
|
509
|
+
{ method: "DELETE", path: /^\/api\/v1\/controller\/runs\/[^/]+$/, handler: controllerRunDeleteRoute },
|
|
510
|
+
// POST /api/v1/controller/intake
|
|
511
|
+
{ method: "POST", path: "/api/v1/controller/intake", handler: controllerIntakeRoute },
|
|
512
|
+
// POST /api/v1/messages/direct
|
|
513
|
+
{ method: "POST", path: "/api/v1/messages/direct", handler: messageDirectRoute },
|
|
514
|
+
// POST /api/v1/messages/broadcast
|
|
515
|
+
{ method: "POST", path: "/api/v1/messages/broadcast", handler: messageBroadcastRoute },
|
|
516
|
+
// POST /api/v1/messages/review-request
|
|
517
|
+
{ method: "POST", path: "/api/v1/messages/review-request", handler: messageReviewRequestRoute },
|
|
518
|
+
// GET /api/v1/messages
|
|
519
|
+
{ method: "GET", path: "/api/v1/messages", handler: messageListRoute },
|
|
520
|
+
|
|
521
|
+
// ==================== Clarification Requests (old lines 1318-1333) ====================
|
|
522
|
+
// POST /api/v1/clarifications
|
|
523
|
+
{ method: "POST", path: "/api/v1/clarifications", handler: clarificationCreateRoute },
|
|
524
|
+
// GET /api/v1/clarifications
|
|
525
|
+
{ method: "GET", path: "/api/v1/clarifications", handler: clarificationListRoute },
|
|
526
|
+
// POST /api/v1/clarifications/:id/answer
|
|
527
|
+
{ method: "POST", path: /^\/api\/v1\/clarifications\/[^/]+\/answer$/, handler: clarificationAnswerRoute },
|
|
528
|
+
|
|
529
|
+
// ==================== Git Collaboration (old lines 1342-1412) ====================
|
|
530
|
+
// GET /api/v1/repo
|
|
531
|
+
{ method: "GET", path: "/api/v1/repo", handler: repoStatusRoute },
|
|
532
|
+
// GET /api/v1/repo/bundle
|
|
533
|
+
{ method: "GET", path: "/api/v1/repo/bundle", handler: repoBundleRoute },
|
|
534
|
+
// POST /api/v1/repo/import
|
|
535
|
+
{ method: "POST", path: "/api/v1/repo/import", handler: repoImportRoute },
|
|
536
|
+
|
|
537
|
+
// ==================== Team Info (old lines 1417-1576) ====================
|
|
538
|
+
// GET /api/v1/team/status
|
|
539
|
+
{ method: "GET", path: "/api/v1/team/status", handler: teamStatusRoute },
|
|
540
|
+
// GET /api/v1/roles
|
|
541
|
+
{ method: "GET", path: "/api/v1/roles", handler: teamRolesRoute },
|
|
542
|
+
// GET /api/v1/profiles — list the available team profile packages
|
|
543
|
+
// (Phase 2.1, design section 4: the switcher UI reads this list).
|
|
544
|
+
{ method: "GET", path: "/api/v1/profiles", handler: teamProfilesListRoute },
|
|
545
|
+
// GET /api/v1/team/profile — active profile detail incl. capabilities
|
|
546
|
+
// (design section 4: UI hides capability-gated entries based on this).
|
|
547
|
+
{ method: "GET", path: "/api/v1/team/profile", handler: teamProfileGetRoute },
|
|
548
|
+
// POST /api/v1/team/profile { profileId } — six-step switch semantics
|
|
549
|
+
// (Phase 2.1, design section 2.3). Returns 202; progress arrives via the
|
|
550
|
+
// team.switch_started / team.switch_completed WS events.
|
|
551
|
+
{ method: "POST", path: "/api/v1/team/profile", handler: teamProfileSwitchRoute },
|
|
552
|
+
// GET /api/v1/archived-teams — archived team metadata list
|
|
553
|
+
// (Phase 2.1, design section 4: profileId/teamName/time/taskCount; detail
|
|
554
|
+
// queries and the archive UI stay v1.1).
|
|
555
|
+
{ method: "GET", path: "/api/v1/archived-teams", handler: archivedTeamsRoute },
|
|
556
|
+
|
|
557
|
+
// ==================== Previews / reports / health (old lines 1580-1633) ====================
|
|
558
|
+
// /api/v1/previews/:id/* — proxy to preview subprocess (5-method
|
|
559
|
+
// whitelist, prefix route; sits after every exact /api/v1 route so it can
|
|
560
|
+
// never shadow them).
|
|
561
|
+
{ method: ["GET", "HEAD", "POST", "PUT", "DELETE"], path: "/api/v1/previews/", prefix: true, handler: previewsProxyRoute },
|
|
562
|
+
// GET /api/v1/reports — list all delivery reports
|
|
563
|
+
{ method: "GET", path: "/api/v1/reports", handler: reportsListRoute },
|
|
564
|
+
// GET /api/v1/reports/:sessionKey — serve delivery report page
|
|
565
|
+
{ method: "GET", path: "/api/v1/reports/", prefix: true, handler: reportsSessionRoute },
|
|
566
|
+
// GET /api/v1/health
|
|
567
|
+
{ method: "GET", path: "/api/v1/health", handler: healthRoute },
|
|
568
|
+
|
|
569
|
+
// ==================== Device pairing security (issue #23) ====================
|
|
570
|
+
// The five POST endpoints are EXEMPT from the device-auth middleware and
|
|
571
|
+
// enforce their own stricter origin rules inside controller/security.ts:
|
|
572
|
+
// enable - loopback only (mints the FIRST device; remote = attacker)
|
|
573
|
+
// pair/start- authenticated device or loopback (mints a fresh code,
|
|
574
|
+
// invalidating the previous one)
|
|
575
|
+
// pair - one-shot 60s code exchange -> {token, deviceId}
|
|
576
|
+
// pair-auto - LAN peer + config.security.autoPair + protection on
|
|
577
|
+
// reset - authenticated device or loopback (anti-lockout hatch)
|
|
578
|
+
// GET /security and DELETE /security/devices/:id are NOT exempt: the
|
|
579
|
+
// middleware itself guarantees the caller holds a valid device token.
|
|
580
|
+
{ method: "POST", path: "/api/v1/security/enable", handler: handleSecurityEnableRequest },
|
|
581
|
+
{ method: "POST", path: "/api/v1/security/pair/start", handler: handleSecurityPairStartRequest },
|
|
582
|
+
{ method: "POST", path: "/api/v1/security/pair", handler: handleSecurityPairRequest },
|
|
583
|
+
{ method: "POST", path: "/api/v1/security/pair-auto", handler: handleSecurityPairAutoRequest },
|
|
584
|
+
{ method: "GET", path: "/api/v1/security", handler: handleSecurityGetRequest },
|
|
585
|
+
{ method: "DELETE", path: /^\/api\/v1\/security\/devices\/[^/]+$/, handler: handleSecurityDeviceDeleteRequest },
|
|
586
|
+
{ method: "POST", path: "/api/v1/security/reset", handler: handleSecurityResetRequest },
|
|
587
|
+
|
|
588
|
+
// ==================== Workflow templates (design 2.4) ====================
|
|
589
|
+
// Appended after the historical table + security suffix (no path overlap
|
|
590
|
+
// with any earlier route, so the append cannot reorder historical
|
|
591
|
+
// matching - same append-only precedent as the security entries above).
|
|
592
|
+
// POST /api/v1/workflows/{id}/start - kick off a declarative workflow run
|
|
593
|
+
// of the active profile (banking: credit-approval); body may carry
|
|
594
|
+
// { context } (initial business context). The handler enforces the
|
|
595
|
+
// transition-matrix 503 itself (see workflow-routes.ts).
|
|
596
|
+
{ method: "POST", path: /^\/api\/v1\/workflows\/[^/]+\/start$/, handler: workflowStartRoute },
|
|
597
|
+
];
|