@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
|
@@ -1,35 +1,246 @@
|
|
|
1
|
-
|
|
1
|
+
// Phase 1.3: inference candidates come from the active TeamProfile.
|
|
2
|
+
import { getActiveRoles } from "../profile-loader.js";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Minimum length for ASCII (latin letter / digit) tokens. Two-character
|
|
5
|
+
* tokens such as "qa", "pm", "ci", "ui" are meaningful role identifiers and
|
|
6
|
+
* must participate in scoring. The previous `length > 2` filter dropped them.
|
|
7
|
+
*/
|
|
8
|
+
const ASCII_TOKEN_MIN_LENGTH = 2;
|
|
9
|
+
/**
|
|
10
|
+
* Minimum length for CJK run tokens, in characters. Single CJK characters
|
|
11
|
+
* are too ambiguous to score on; runs of two or more characters are kept.
|
|
12
|
+
*/
|
|
13
|
+
const CJK_TOKEN_MIN_LENGTH = 2;
|
|
14
|
+
const ASCII_TOKEN_PATTERN = /[a-z0-9]+/g;
|
|
15
|
+
// A token made purely of ASCII letters/digits (all tokens the pattern above
|
|
16
|
+
// extracts). Such tokens match as STANDALONE WORDS, never as substrings of a
|
|
17
|
+
// longer ASCII word: "data" must not hit "database", "test" must not hit
|
|
18
|
+
// "testing", "pm" must not hit "npm". Multi-word phrases ("software
|
|
19
|
+
// architect") and CJK runs keep whole-phrase containment semantics.
|
|
20
|
+
const ASCII_WORD_TOKEN_PATTERN = /^[a-z0-9]+$/;
|
|
21
|
+
// CJK Unified Ideographs, Extension A, and CJK Compatibility Ideographs.
|
|
22
|
+
const CJK_RUN_PATTERN = /[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]+/g;
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Phase 2.5 tiered scoring (vertical-team-profiles-design.md section 2.3).
|
|
25
|
+
//
|
|
26
|
+
// Token hits are weighted by their SOURCE tier:
|
|
27
|
+
// labelZh full phrase > label full phrase > id/label word > capability word
|
|
28
|
+
// ("labelZh 完整词 > 高区分度业务词 > 泛化词"). Weights are integers so the
|
|
29
|
+
// fallback margin below is measured in whole tiers or whole token hits.
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
const WEIGHT_LABELZH_PHRASE = 8;
|
|
32
|
+
const WEIGHT_LABEL_PHRASE = 6;
|
|
33
|
+
const WEIGHT_ID_LABEL_WORD = 3;
|
|
34
|
+
const WEIGHT_CAPABILITY_WORD = 1;
|
|
35
|
+
/**
|
|
36
|
+
* Rarity stopword threshold (design 2.3): a token that appears in MORE THAN
|
|
37
|
+
* one third of the active profile's roles discriminates nothing
|
|
38
|
+
* ("分析/管理/合规 全员命中等于没命中") and is dropped from scoring entirely.
|
|
39
|
+
* Computed per inference call over the active role set, so a token that is
|
|
40
|
+
* generic in one profile (合规 in banking) can stay distinctive in another.
|
|
41
|
+
*/
|
|
42
|
+
const RARITY_STOPWORD_FRACTION = 1 / 3;
|
|
43
|
+
/**
|
|
44
|
+
* LLM-fallback margin (design 2.3): the token fast path is confident only
|
|
45
|
+
* when the runner-up scores strictly below the winner by at least this much.
|
|
46
|
+
* Any tie (margin < 1) escalates to the LLM fallback instead of the old
|
|
47
|
+
* "并列取数组靠前" registry-order determinism. The value is 1 - not higher -
|
|
48
|
+
* because the design's own high-distinctiveness examples (反洗钱→aml-analyst,
|
|
49
|
+
* 贷审→approver) are single capability-tier hits with margin exactly 1 and
|
|
50
|
+
* must stay on the fast path.
|
|
51
|
+
*/
|
|
52
|
+
const LLM_FALLBACK_SCORE_MARGIN = 1;
|
|
53
|
+
function isAsciiAlphanumeric(char) {
|
|
54
|
+
if (!char) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return (char >= "0" && char <= "9") || (char >= "a" && char <= "z");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check whether a pure-ASCII word token occurs in `text` as a standalone
|
|
61
|
+
* word rather than inside a longer ASCII word. Plain substring containment
|
|
62
|
+
* would misroute texts like "npm install fails" to the "pm" role, "build a
|
|
63
|
+
* guide page" to the "ui" role, or (Phase 2.5 regression found in testing)
|
|
64
|
+
* "Design the database schema" to the data-engineer role via "data" inside
|
|
65
|
+
* "database". Non-ASCII neighbours (CJK characters, punctuation, string
|
|
66
|
+
* boundaries, hyphens in kebab ids) still count as boundaries, so "qa"
|
|
67
|
+
* matches inside "处理QA登录问题" after lowercasing.
|
|
68
|
+
*/
|
|
69
|
+
function asciiWordTokenInText(token, text) {
|
|
70
|
+
let index = text.indexOf(token);
|
|
71
|
+
while (index !== -1) {
|
|
72
|
+
const boundedBefore = !isAsciiAlphanumeric(text[index - 1]);
|
|
73
|
+
const boundedAfter = !isAsciiAlphanumeric(text[index + token.length]);
|
|
74
|
+
if (boundedBefore && boundedAfter) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
index = text.indexOf(token, index + 1);
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
function tokenInText(token, text) {
|
|
82
|
+
if (ASCII_WORD_TOKEN_PATTERN.test(token)) {
|
|
83
|
+
return asciiWordTokenInText(token, text);
|
|
84
|
+
}
|
|
85
|
+
return text.includes(token);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Extract scoring tokens from one role-facing string (id, label, capability).
|
|
4
89
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
90
|
+
* Two kinds of tokens are produced:
|
|
91
|
+
* - ASCII alphanumeric runs of at least 2 characters ("qa", "deployment").
|
|
92
|
+
* - Contiguous CJK runs of at least 2 characters ("核保", "架构设计"), kept
|
|
93
|
+
* whole: `text.includes(token)` then has exact-phrase semantics and cannot
|
|
94
|
+
* produce crossing-window false positives.
|
|
8
95
|
*/
|
|
9
|
-
export function
|
|
96
|
+
export function extractRoleTokens(entry) {
|
|
97
|
+
const lowered = entry.toLowerCase();
|
|
98
|
+
const tokens = [];
|
|
99
|
+
for (const match of lowered.matchAll(ASCII_TOKEN_PATTERN)) {
|
|
100
|
+
if (match[0].length >= ASCII_TOKEN_MIN_LENGTH) {
|
|
101
|
+
tokens.push(match[0]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const match of lowered.matchAll(CJK_RUN_PATTERN)) {
|
|
105
|
+
if (match[0].length >= CJK_TOKEN_MIN_LENGTH) {
|
|
106
|
+
tokens.push(match[0]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return tokens;
|
|
110
|
+
}
|
|
111
|
+
/** Scoring units of one role: token/phrase -> its highest source-tier weight. */
|
|
112
|
+
function buildRoleScoringUnits(role) {
|
|
113
|
+
const units = new Map();
|
|
114
|
+
const put = (token, weight) => {
|
|
115
|
+
const current = units.get(token);
|
|
116
|
+
if (current === undefined || weight > current) {
|
|
117
|
+
units.set(token, weight);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const labelZh = typeof role.labelZh === "string" ? role.labelZh.trim().toLowerCase() : "";
|
|
121
|
+
if (labelZh) {
|
|
122
|
+
put(labelZh, WEIGHT_LABELZH_PHRASE);
|
|
123
|
+
for (const token of extractRoleTokens(labelZh)) {
|
|
124
|
+
put(token, WEIGHT_ID_LABEL_WORD);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const label = role.label.trim().toLowerCase();
|
|
128
|
+
if (label) {
|
|
129
|
+
put(label, WEIGHT_LABEL_PHRASE);
|
|
130
|
+
}
|
|
131
|
+
for (const entry of [role.id, role.label]) {
|
|
132
|
+
for (const token of extractRoleTokens(entry)) {
|
|
133
|
+
put(token, WEIGHT_ID_LABEL_WORD);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const capability of role.capabilities) {
|
|
137
|
+
for (const token of extractRoleTokens(capability)) {
|
|
138
|
+
put(token, WEIGHT_CAPABILITY_WORD);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return units;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Rank the active profile's roles against the task text with tiered,
|
|
145
|
+
* rarity-adjusted token scoring and report the confidence verdict.
|
|
146
|
+
*
|
|
147
|
+
* Pure function: no LLM calls. Callers that need a decision when
|
|
148
|
+
* `needsLlmFallback` is true own the fallback (see
|
|
149
|
+
* resolveTaskRoleWithLlmFallback in kickoff-orchestrator.ts).
|
|
150
|
+
*/
|
|
151
|
+
export function inferTaskRoleWithConfidence(task) {
|
|
10
152
|
if (task.assignedRole) {
|
|
11
|
-
return
|
|
153
|
+
return {
|
|
154
|
+
role: task.assignedRole,
|
|
155
|
+
runnerUp: null,
|
|
156
|
+
topScore: 0,
|
|
157
|
+
runnerUpScore: 0,
|
|
158
|
+
topScoreMinusRunnerUp: 0,
|
|
159
|
+
needsLlmFallback: false,
|
|
160
|
+
reason: "assigned",
|
|
161
|
+
};
|
|
12
162
|
}
|
|
163
|
+
const roles = getActiveRoles();
|
|
13
164
|
const text = `${task.title} ${task.description}`.toLowerCase();
|
|
165
|
+
const unitMaps = roles.map((role) => buildRoleScoringUnits(role));
|
|
166
|
+
// Rarity stopwords over the active profile's role set: token -> number of
|
|
167
|
+
// roles carrying it at any tier.
|
|
168
|
+
const documentFrequency = new Map();
|
|
169
|
+
for (const units of unitMaps) {
|
|
170
|
+
for (const token of units.keys()) {
|
|
171
|
+
documentFrequency.set(token, (documentFrequency.get(token) ?? 0) + 1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const stopwordCount = roles.length * RARITY_STOPWORD_FRACTION;
|
|
175
|
+
const isStopword = (token) => (documentFrequency.get(token) ?? 0) > stopwordCount;
|
|
14
176
|
let bestRole = null;
|
|
15
177
|
let bestScore = 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
178
|
+
let runnerUpRole = null;
|
|
179
|
+
let runnerUpScore = 0;
|
|
180
|
+
roles.forEach((role, index) => {
|
|
181
|
+
let score = 0;
|
|
182
|
+
for (const [token, weight] of unitMaps[index]) {
|
|
183
|
+
if (isStopword(token)) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (tokenInText(token, text)) {
|
|
187
|
+
score += weight;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
24
190
|
if (score > bestScore) {
|
|
25
|
-
|
|
191
|
+
runnerUpRole = bestRole;
|
|
192
|
+
runnerUpScore = bestScore;
|
|
26
193
|
bestRole = role.id;
|
|
194
|
+
bestScore = score;
|
|
195
|
+
}
|
|
196
|
+
else if (score > runnerUpScore) {
|
|
197
|
+
runnerUpRole = role.id;
|
|
198
|
+
runnerUpScore = score;
|
|
27
199
|
}
|
|
200
|
+
});
|
|
201
|
+
if (bestScore <= 0) {
|
|
202
|
+
return {
|
|
203
|
+
role: null,
|
|
204
|
+
runnerUp: null,
|
|
205
|
+
topScore: 0,
|
|
206
|
+
runnerUpScore: 0,
|
|
207
|
+
topScoreMinusRunnerUp: 0,
|
|
208
|
+
needsLlmFallback: true,
|
|
209
|
+
reason: "all-zero",
|
|
210
|
+
};
|
|
28
211
|
}
|
|
29
|
-
|
|
212
|
+
const margin = bestScore - runnerUpScore;
|
|
213
|
+
if (margin < LLM_FALLBACK_SCORE_MARGIN) {
|
|
214
|
+
return {
|
|
215
|
+
role: bestRole,
|
|
216
|
+
runnerUp: runnerUpRole,
|
|
217
|
+
topScore: bestScore,
|
|
218
|
+
runnerUpScore,
|
|
219
|
+
topScoreMinusRunnerUp: margin,
|
|
220
|
+
needsLlmFallback: true,
|
|
221
|
+
reason: "tie",
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
role: bestRole,
|
|
226
|
+
runnerUp: runnerUpRole,
|
|
227
|
+
topScore: bestScore,
|
|
228
|
+
runnerUpScore,
|
|
229
|
+
topScoreMinusRunnerUp: margin,
|
|
230
|
+
needsLlmFallback: false,
|
|
231
|
+
reason: "confident",
|
|
232
|
+
};
|
|
30
233
|
}
|
|
31
234
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
235
|
+
* Infer the most appropriate role for a task based on text analysis.
|
|
236
|
+
*
|
|
237
|
+
* If `task.assignedRole` is already set, returns it directly. Otherwise the
|
|
238
|
+
* tiered token fast path decides only when it is confident (design 2.3): a
|
|
239
|
+
* tie between the top two roles - the old "并列取数组靠前" registry-order
|
|
240
|
+
* determinism - or an all-zero scoreboard returns `null` so the caller can
|
|
241
|
+
* escalate to the controller LLM fallback (or its own default role).
|
|
34
242
|
*/
|
|
35
|
-
export
|
|
243
|
+
export function inferTaskRole(task) {
|
|
244
|
+
const verdict = inferTaskRoleWithConfidence(task);
|
|
245
|
+
return verdict.needsLlmFallback ? null : verdict.role;
|
|
246
|
+
}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { webUiRootRoute, webUiIndexRoute, webUiGithubLoginPageRoute, webUiAssetsRoute, } from "./webui-routes.js";
|
|
2
|
+
import { githubAuthStatusRoute, githubAuthLoginRoute, githubAuthCallbackRoute, githubAuthLogoutRoute, githubAuthRefreshRoute, } from "./auth-routes.js";
|
|
3
|
+
import { workspaceStatusRoute, workspaceChangeDirRoute, modelsConfigGetRoute, modelsConfigPutRoute, workspaceTreeRoute, workspaceSubtreeRoute, workspaceFileRoute, workspaceProjectPathRoute, workspaceRawFileRoute, } from "./workspace-routes.js";
|
|
4
|
+
import { controllerManifestRoute, controllerRunsListRoute, projectDeleteRoute, controllerRunDeleteRoute, controllerIntakeRoute, } from "./controller-routes.js";
|
|
5
|
+
import { teamStatsRoute, teamStatusRoute, teamRolesRoute, teamProfilesListRoute, teamProfileGetRoute, teamProfileSwitchRoute, archivedTeamsRoute, } from "./status-routes.js";
|
|
6
|
+
import { reportsListRoute, reportsSessionRoute, healthRoute, } from "./report-routes.js";
|
|
7
|
+
import { handleTeamAutoActivityRequest, handleTeamAutoReposListRequest, handleTeamAutoRepoCandidatesRequest, handleTeamAutoRepoBindRequest, handleTeamAutoRepoItemRequest, } from "./teamauto-routes.js";
|
|
8
|
+
import { handleRepoStatusRequest, handleRepoBundleRequest, repoImportRoute, } from "./repo-routes.js";
|
|
9
|
+
import { handlePreviewProxyRequest } from "./preview-proxy.js";
|
|
10
|
+
// Issue #226 W2: the tunnel-side tables (gate page + management API, with
|
|
11
|
+
// their inline handler bodies, the gate-page HTML rendering and the tunnel
|
|
12
|
+
// form reader) live in ./tunnel-routes.ts; both factories are re-exported
|
|
13
|
+
// below so http-server.ts's imports are unchanged.
|
|
14
|
+
export { createTunnelGateRoutes, createTunnelManagementRoutes } from "./tunnel-routes.js";
|
|
15
|
+
import { handleWorkerDeleteRequest, handleWorkerHeartbeatRequest, handleWorkerListRequest, handleWorkerRegisterRequest, } from "./worker-routes.js";
|
|
16
|
+
import { handleTaskAssignRequest, handleTaskCheckpointRequest, handleTaskCreateRequest, handleTaskDeleteRequest, handleTaskExecutionEventRequest, handleTaskExecutionGetRequest, handleTaskGetRequest, handleTaskHandoffRequest, handleTaskListRequest, handleTaskParallelHelpRequest, handleTaskPatchRequest, handleTaskResultContractRequest, handleTaskResultRequest, } from "./task-routes.js";
|
|
17
|
+
import { handleBroadcastMessageRequest, handleDirectMessageRequest, handleMessageListRequest, handleReviewRequestMessageRequest, } from "./message-routes.js";
|
|
18
|
+
import { handleClarificationAnswerRequest, handleClarificationCreateRequest, handleClarificationListRequest, } from "./clarification-routes.js";
|
|
19
|
+
// Issue #23 (backend wave): device-pairing security domain module. It owns
|
|
20
|
+
// the token/pairing primitives, the auth middleware (wired by
|
|
21
|
+
// http-server.ts), the WS upgrade guard and the handlers registered in the
|
|
22
|
+
// security section of the table below. It imports this file as TYPE ONLY
|
|
23
|
+
// (RouteContext), so the module graph stays acyclic.
|
|
24
|
+
import { handleSecurityDeviceDeleteRequest, handleSecurityEnableRequest, handleSecurityGetRequest, handleSecurityPairAutoRequest, handleSecurityPairRequest, handleSecurityPairStartRequest, handleSecurityResetRequest, } from "./security.js";
|
|
25
|
+
// Design 2.4 workflows backend: POST /api/v1/workflows/{id}/start handler
|
|
26
|
+
// (engine + route live in ./workflow-routes.ts).
|
|
27
|
+
import { workflowStartRoute } from "./workflow-routes.js";
|
|
28
|
+
function routeMethodMatches(routeMethod, method) {
|
|
29
|
+
if (routeMethod === "*") {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return Array.isArray(routeMethod) ? routeMethod.includes(method) : routeMethod === method;
|
|
33
|
+
}
|
|
34
|
+
function routePathMatches(route, pathname) {
|
|
35
|
+
if (typeof route.path === "string") {
|
|
36
|
+
return route.prefix === true ? pathname.startsWith(route.path) : pathname === route.path;
|
|
37
|
+
}
|
|
38
|
+
return route.path.test(pathname);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Matches `ctx` against `routes` in array order. Returns true when a route
|
|
42
|
+
* handled the request (handler did not return false); false when the table
|
|
43
|
+
* was exhausted, in which case the caller answers the final 404.
|
|
44
|
+
*/
|
|
45
|
+
export async function dispatchRoutes(routes, ctx) {
|
|
46
|
+
const method = ctx.req.method ?? "";
|
|
47
|
+
for (const route of routes) {
|
|
48
|
+
if (!routeMethodMatches(route.method, method)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (!routePathMatches(route, ctx.pathname)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const handled = await route.handler(ctx);
|
|
55
|
+
if (handled !== false) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
// handler declined (teamauto per-repo pattern): keep matching.
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// ===========================================================================
|
|
63
|
+
// Shared helpers. W2 of issue #226: the helpers whose consumers moved out
|
|
64
|
+
// (shell escaping, LAN-URL building, the GitHub callback HTML renderer,
|
|
65
|
+
// workspace error mapping, team stats, the tunnel form reader) moved with
|
|
66
|
+
// them; nothing inline remains in this module.
|
|
67
|
+
// ===========================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Retry hint shared by the transition-matrix gate (http-server.ts, task
|
|
70
|
+
* submission / repo import) and the intake handler. Declared in
|
|
71
|
+
* ./controller-routes.ts since W2 (it moved with the intake handler body);
|
|
72
|
+
* re-exported here so http-server.ts's gate import is unchanged.
|
|
73
|
+
*/
|
|
74
|
+
export { SWITCH_TASK_SUBMISSION_RETRY_AFTER_SECONDS } from "./controller-routes.js";
|
|
75
|
+
// ===========================================================================
|
|
76
|
+
// Route handlers. The PR-A/B/C domain handlers are forwarded to unchanged;
|
|
77
|
+
// every handler body that was still inline here moved verbatim into its
|
|
78
|
+
// domain module with W2 of issue #226 (see the import block): route-table
|
|
79
|
+
// binds the exported handlers directly, exactly like the issue-#23 security
|
|
80
|
+
// handlers. Only the thin forwarder shells for the PR-A/B/C domain modules
|
|
81
|
+
// (whose handlers predate RouteContext) and the preview-proxy fire-and-
|
|
82
|
+
// forget shell remain below.
|
|
83
|
+
// ===========================================================================
|
|
84
|
+
// ---- TeamAuto (pre-PR-D lines 631-654; handlers in ./teamauto-routes.ts) ----
|
|
85
|
+
async function teamAutoActivityRoute(ctx) {
|
|
86
|
+
await handleTeamAutoActivityRequest(ctx.deps, ctx.res);
|
|
87
|
+
}
|
|
88
|
+
async function teamAutoReposListRoute(ctx) {
|
|
89
|
+
await handleTeamAutoReposListRequest(ctx.deps, ctx.res);
|
|
90
|
+
}
|
|
91
|
+
// Selectable repos for the bind picker (the logged-in GitHub account's).
|
|
92
|
+
async function teamAutoRepoCandidatesRoute(ctx) {
|
|
93
|
+
await handleTeamAutoRepoCandidatesRequest(ctx.deps, ctx.res);
|
|
94
|
+
}
|
|
95
|
+
async function teamAutoRepoBindRoute(ctx) {
|
|
96
|
+
await handleTeamAutoRepoBindRequest(ctx.deps, ctx.req, ctx.res);
|
|
97
|
+
}
|
|
98
|
+
// Any-method prefix route: the handler self-dispatches by method and
|
|
99
|
+
// DECLINES (returns false) for methods it does not own, falling through to
|
|
100
|
+
// the rest of the table - preserved by returning its boolean upstream.
|
|
101
|
+
function teamAutoRepoItemRoute(ctx) {
|
|
102
|
+
return handleTeamAutoRepoItemRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
103
|
+
}
|
|
104
|
+
// ---- Worker Management (pre-PR-D lines 939-960; handlers in ./worker-routes.ts) ----
|
|
105
|
+
async function workerRegisterRoute(ctx) {
|
|
106
|
+
await handleWorkerRegisterRequest(ctx.deps, ctx.req, ctx.res);
|
|
107
|
+
}
|
|
108
|
+
async function workerDeleteRoute(ctx) {
|
|
109
|
+
await handleWorkerDeleteRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
110
|
+
}
|
|
111
|
+
async function workerListRoute(ctx) {
|
|
112
|
+
await handleWorkerListRequest(ctx.deps, ctx.res);
|
|
113
|
+
}
|
|
114
|
+
async function workerHeartbeatRoute(ctx) {
|
|
115
|
+
await handleWorkerHeartbeatRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
116
|
+
}
|
|
117
|
+
// ---- Task Management (pre-PR-D lines 968-1100; handlers in ./task-routes.ts) ----
|
|
118
|
+
async function taskCreateRoute(ctx) {
|
|
119
|
+
await handleTaskCreateRequest(ctx.deps, ctx.req, ctx.res);
|
|
120
|
+
}
|
|
121
|
+
async function taskListRoute(ctx) {
|
|
122
|
+
await handleTaskListRequest(ctx.deps, ctx.res);
|
|
123
|
+
}
|
|
124
|
+
async function taskGetRoute(ctx) {
|
|
125
|
+
await handleTaskGetRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
126
|
+
}
|
|
127
|
+
async function taskDeleteRoute(ctx) {
|
|
128
|
+
await handleTaskDeleteRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
129
|
+
}
|
|
130
|
+
async function taskExecutionGetRoute(ctx) {
|
|
131
|
+
await handleTaskExecutionGetRequest(ctx.deps, ctx.res, ctx.pathname);
|
|
132
|
+
}
|
|
133
|
+
async function taskPatchRoute(ctx) {
|
|
134
|
+
await handleTaskPatchRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
135
|
+
}
|
|
136
|
+
async function taskAssignRoute(ctx) {
|
|
137
|
+
await handleTaskAssignRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
138
|
+
}
|
|
139
|
+
async function taskHandoffRoute(ctx) {
|
|
140
|
+
await handleTaskHandoffRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
141
|
+
}
|
|
142
|
+
// POST /api/v1/tasks/:id/checkpoint - worker persists an execution progress
|
|
143
|
+
// snapshot so an interrupted task can resume instead of restarting.
|
|
144
|
+
async function taskCheckpointRoute(ctx) {
|
|
145
|
+
await handleTaskCheckpointRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
146
|
+
}
|
|
147
|
+
async function taskResultContractRoute(ctx) {
|
|
148
|
+
await handleTaskResultContractRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
149
|
+
}
|
|
150
|
+
async function taskResultRoute(ctx) {
|
|
151
|
+
await handleTaskResultRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
152
|
+
}
|
|
153
|
+
async function taskExecutionEventRoute(ctx) {
|
|
154
|
+
await handleTaskExecutionEventRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
155
|
+
}
|
|
156
|
+
async function taskParallelHelpRoute(ctx) {
|
|
157
|
+
await handleTaskParallelHelpRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
158
|
+
}
|
|
159
|
+
// ---- Message Routing (pre-PR-D lines 1292-1313; handlers in ./message-routes.ts) ----
|
|
160
|
+
async function messageDirectRoute(ctx) {
|
|
161
|
+
await handleDirectMessageRequest(ctx.deps, ctx.req, ctx.res);
|
|
162
|
+
}
|
|
163
|
+
async function messageBroadcastRoute(ctx) {
|
|
164
|
+
await handleBroadcastMessageRequest(ctx.deps, ctx.req, ctx.res);
|
|
165
|
+
}
|
|
166
|
+
async function messageReviewRequestRoute(ctx) {
|
|
167
|
+
await handleReviewRequestMessageRequest(ctx.deps, ctx.req, ctx.res);
|
|
168
|
+
}
|
|
169
|
+
async function messageListRoute(ctx) {
|
|
170
|
+
await handleMessageListRequest(ctx.deps, ctx.res, ctx.requestUrl);
|
|
171
|
+
}
|
|
172
|
+
// ---- Clarification Requests (pre-PR-D lines 1318-1333; handlers in ./clarification-routes.ts) ----
|
|
173
|
+
async function clarificationCreateRoute(ctx) {
|
|
174
|
+
await handleClarificationCreateRequest(ctx.deps, ctx.req, ctx.res);
|
|
175
|
+
}
|
|
176
|
+
async function clarificationListRoute(ctx) {
|
|
177
|
+
await handleClarificationListRequest(ctx.deps, ctx.res);
|
|
178
|
+
}
|
|
179
|
+
async function clarificationAnswerRoute(ctx) {
|
|
180
|
+
await handleClarificationAnswerRequest(ctx.deps, ctx.req, ctx.res, ctx.pathname);
|
|
181
|
+
}
|
|
182
|
+
// ---- Git Collaboration (pre-PR-D lines 1342-1412) ----
|
|
183
|
+
// PR-B of issue #204: the repo status/bundle handlers and the shared
|
|
184
|
+
// refreshControllerRepoState glue live in ./repo-routes.ts; the POST
|
|
185
|
+
// /repo/import handler body joined them with W2 of issue #226 (its
|
|
186
|
+
// recordTaskExecutionEvent dependency is task-lifecycle glue owned by the
|
|
187
|
+
// PR-C cut - acyclic, see the repo-routes.ts header).
|
|
188
|
+
async function repoStatusRoute(ctx) {
|
|
189
|
+
await handleRepoStatusRequest(ctx.deps, ctx.res);
|
|
190
|
+
}
|
|
191
|
+
async function repoBundleRoute(ctx) {
|
|
192
|
+
await handleRepoBundleRequest(ctx.deps, ctx.res);
|
|
193
|
+
}
|
|
194
|
+
// ---- Previews / reports / health (pre-PR-D lines 1580-1633) ----
|
|
195
|
+
// W2 of issue #226: the reports list/session and health handler bodies live
|
|
196
|
+
// in ./report-routes.ts; only the fire-and-forget preview-proxy shell stays.
|
|
197
|
+
// /api/v1/previews/:id/* — proxy to preview subprocess.
|
|
198
|
+
// PR-B of issue #204: the proxy implementation lives in ./preview-proxy.ts.
|
|
199
|
+
// Deliberately NOT awaited (fire-and-forget proxy), exactly as before.
|
|
200
|
+
function previewsProxyRoute(ctx) {
|
|
201
|
+
handlePreviewProxyRequest(ctx.deps, ctx.req, ctx.res, ctx.requestUrl, ctx.pathname);
|
|
202
|
+
}
|
|
203
|
+
// ===========================================================================
|
|
204
|
+
// The controller route table. ORDER IS LOAD-BEARING: it mirrors the pre-PR-D
|
|
205
|
+
// if/startsWith chain of http-server.ts one-to-one (the "old lines" in the
|
|
206
|
+
// section comments refer to http-server.ts at e223767, the merge base of
|
|
207
|
+
// this branch). tests/test-route-table.mjs asserts this order against both
|
|
208
|
+
// a hardcoded expectation and that git snapshot.
|
|
209
|
+
// ===========================================================================
|
|
210
|
+
export const controllerRouteTable = [
|
|
211
|
+
// ==================== Web UI (old lines 588-625) ====================
|
|
212
|
+
{ method: "GET", path: "/", handler: webUiRootRoute },
|
|
213
|
+
{ method: "GET", path: "/ui", handler: webUiIndexRoute },
|
|
214
|
+
{ method: "GET", path: "/ui/", handler: webUiIndexRoute },
|
|
215
|
+
// Standalone GitHub device-login page (big user code + prefilled link + polling).
|
|
216
|
+
{ method: "GET", path: "/ui/auth/github", handler: webUiGithubLoginPageRoute },
|
|
217
|
+
{ method: "GET", path: "/ui/auth/github/", handler: webUiGithubLoginPageRoute },
|
|
218
|
+
{ method: "GET", path: "/ui/", prefix: true, handler: webUiAssetsRoute },
|
|
219
|
+
// ==================== TeamAuto (old lines 631-654) ====================
|
|
220
|
+
{ method: "GET", path: "/api/v1/teamauto/activity", handler: teamAutoActivityRoute },
|
|
221
|
+
{ method: "GET", path: "/api/v1/teamauto/repos", handler: teamAutoReposListRoute },
|
|
222
|
+
// Selectable repos for the bind picker (the logged-in GitHub account's).
|
|
223
|
+
{ method: "GET", path: "/api/v1/teamauto/repo-candidates", handler: teamAutoRepoCandidatesRoute },
|
|
224
|
+
{ method: "POST", path: "/api/v1/teamauto/repos", handler: teamAutoRepoBindRoute },
|
|
225
|
+
// Per-repo prefix, any method: exact entries above win first; the handler
|
|
226
|
+
// declines (false) for unknown methods and dispatch falls through.
|
|
227
|
+
{ method: "*", path: "/api/v1/teamauto/repos/", prefix: true, handler: teamAutoRepoItemRoute },
|
|
228
|
+
// ==================== GitHub Auth (old lines 658-753) ====================
|
|
229
|
+
{ method: "GET", path: "/api/v1/auth/github/status", handler: githubAuthStatusRoute },
|
|
230
|
+
{ method: "POST", path: "/api/v1/auth/github/login", handler: githubAuthLoginRoute },
|
|
231
|
+
{ method: "GET", path: "/api/v1/auth/github/callback", handler: githubAuthCallbackRoute },
|
|
232
|
+
{ method: "POST", path: "/api/v1/auth/github/logout", handler: githubAuthLogoutRoute },
|
|
233
|
+
{ method: "POST", path: "/api/v1/auth/github/refresh", handler: githubAuthRefreshRoute },
|
|
234
|
+
// ==================== Workspace Browser (old lines 757-931) ====================
|
|
235
|
+
{ method: "GET", path: "/api/v1/workspace/status", handler: workspaceStatusRoute },
|
|
236
|
+
{ method: "POST", path: "/api/v1/workspace/change-dir", handler: workspaceChangeDirRoute },
|
|
237
|
+
// GET /api/v1/models/config - model catalog + current selection for the UI settings dialog
|
|
238
|
+
{ method: "GET", path: "/api/v1/models/config", handler: modelsConfigGetRoute },
|
|
239
|
+
// PUT /api/v1/models/config - persist default and per-role model selection
|
|
240
|
+
{ method: "PUT", path: "/api/v1/models/config", handler: modelsConfigPutRoute },
|
|
241
|
+
{ method: "GET", path: "/api/v1/workspace/tree", handler: workspaceTreeRoute },
|
|
242
|
+
{ method: "GET", path: "/api/v1/workspace/subtree", handler: workspaceSubtreeRoute },
|
|
243
|
+
{ method: "GET", path: "/api/v1/workspace/file", handler: workspaceFileRoute },
|
|
244
|
+
{ method: "GET", path: "/api/v1/workspace/project-path", handler: workspaceProjectPathRoute },
|
|
245
|
+
{ method: "GET", path: "/api/v1/workspace/raw/", prefix: true, handler: workspaceRawFileRoute },
|
|
246
|
+
// ==================== Worker Management (old lines 939-960) ====================
|
|
247
|
+
// POST /api/v1/workers/register
|
|
248
|
+
{ method: "POST", path: "/api/v1/workers/register", handler: workerRegisterRoute },
|
|
249
|
+
// DELETE /api/v1/workers/:id
|
|
250
|
+
{ method: "DELETE", path: /^\/api\/v1\/workers\/[^/]+$/, handler: workerDeleteRoute },
|
|
251
|
+
// GET /api/v1/workers
|
|
252
|
+
{ method: "GET", path: "/api/v1/workers", handler: workerListRoute },
|
|
253
|
+
// POST /api/v1/workers/:id/heartbeat
|
|
254
|
+
{ method: "POST", path: /^\/api\/v1\/workers\/[^/]+\/heartbeat$/, handler: workerHeartbeatRoute },
|
|
255
|
+
// ==================== Task Management (old lines 968-1100) ====================
|
|
256
|
+
// POST /api/v1/tasks
|
|
257
|
+
{ method: "POST", path: "/api/v1/tasks", handler: taskCreateRoute },
|
|
258
|
+
// GET /api/v1/tasks
|
|
259
|
+
{ method: "GET", path: "/api/v1/tasks", handler: taskListRoute },
|
|
260
|
+
// GET /api/v1/stats
|
|
261
|
+
{ method: "GET", path: "/api/v1/stats", handler: teamStatsRoute },
|
|
262
|
+
// GET /api/v1/tasks/:id
|
|
263
|
+
{ method: "GET", path: /^\/api\/v1\/tasks\/[^/]+$/, handler: taskGetRoute },
|
|
264
|
+
// DELETE /api/v1/tasks/:id
|
|
265
|
+
{ method: "DELETE", path: /^\/api\/v1\/tasks\/[^/]+$/, handler: taskDeleteRoute },
|
|
266
|
+
// GET /api/v1/tasks/:id/execution
|
|
267
|
+
{ method: "GET", path: /^\/api\/v1\/tasks\/[^/]+\/execution$/, handler: taskExecutionGetRoute },
|
|
268
|
+
// PATCH /api/v1/tasks/:id
|
|
269
|
+
{ method: "PATCH", path: /^\/api\/v1\/tasks\/[^/]+$/, handler: taskPatchRoute },
|
|
270
|
+
// POST /api/v1/tasks/:id/assign
|
|
271
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/assign$/, handler: taskAssignRoute },
|
|
272
|
+
// POST /api/v1/tasks/:id/handoff
|
|
273
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/handoff$/, handler: taskHandoffRoute },
|
|
274
|
+
// POST /api/v1/tasks/:id/checkpoint - worker persists an execution progress
|
|
275
|
+
// snapshot so an interrupted task can resume instead of restarting.
|
|
276
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/checkpoint$/, handler: taskCheckpointRoute },
|
|
277
|
+
// POST /api/v1/tasks/:id/result-contract
|
|
278
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/result-contract$/, handler: taskResultContractRoute },
|
|
279
|
+
// POST /api/v1/tasks/:id/result
|
|
280
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/result$/, handler: taskResultRoute },
|
|
281
|
+
// POST /api/v1/tasks/:id/execution
|
|
282
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/execution$/, handler: taskExecutionEventRoute },
|
|
283
|
+
// POST /api/v1/tasks/:id/parallel-help
|
|
284
|
+
{ method: "POST", path: /^\/api\/v1\/tasks\/[^/]+\/parallel-help$/, handler: taskParallelHelpRoute },
|
|
285
|
+
// ==================== Message Routing (old lines 1109-1313) ====================
|
|
286
|
+
// POST /api/v1/controller/manifest
|
|
287
|
+
{ method: "POST", path: "/api/v1/controller/manifest", handler: controllerManifestRoute },
|
|
288
|
+
// GET /api/v1/controller/runs
|
|
289
|
+
{ method: "GET", path: "/api/v1/controller/runs", handler: controllerRunsListRoute },
|
|
290
|
+
// DELETE /api/v1/projects/:projectDir
|
|
291
|
+
{ method: "DELETE", path: /^\/api\/v1\/projects\/[^/]+$/, handler: projectDeleteRoute },
|
|
292
|
+
// DELETE /api/v1/controller/runs/:id
|
|
293
|
+
{ method: "DELETE", path: /^\/api\/v1\/controller\/runs\/[^/]+$/, handler: controllerRunDeleteRoute },
|
|
294
|
+
// POST /api/v1/controller/intake
|
|
295
|
+
{ method: "POST", path: "/api/v1/controller/intake", handler: controllerIntakeRoute },
|
|
296
|
+
// POST /api/v1/messages/direct
|
|
297
|
+
{ method: "POST", path: "/api/v1/messages/direct", handler: messageDirectRoute },
|
|
298
|
+
// POST /api/v1/messages/broadcast
|
|
299
|
+
{ method: "POST", path: "/api/v1/messages/broadcast", handler: messageBroadcastRoute },
|
|
300
|
+
// POST /api/v1/messages/review-request
|
|
301
|
+
{ method: "POST", path: "/api/v1/messages/review-request", handler: messageReviewRequestRoute },
|
|
302
|
+
// GET /api/v1/messages
|
|
303
|
+
{ method: "GET", path: "/api/v1/messages", handler: messageListRoute },
|
|
304
|
+
// ==================== Clarification Requests (old lines 1318-1333) ====================
|
|
305
|
+
// POST /api/v1/clarifications
|
|
306
|
+
{ method: "POST", path: "/api/v1/clarifications", handler: clarificationCreateRoute },
|
|
307
|
+
// GET /api/v1/clarifications
|
|
308
|
+
{ method: "GET", path: "/api/v1/clarifications", handler: clarificationListRoute },
|
|
309
|
+
// POST /api/v1/clarifications/:id/answer
|
|
310
|
+
{ method: "POST", path: /^\/api\/v1\/clarifications\/[^/]+\/answer$/, handler: clarificationAnswerRoute },
|
|
311
|
+
// ==================== Git Collaboration (old lines 1342-1412) ====================
|
|
312
|
+
// GET /api/v1/repo
|
|
313
|
+
{ method: "GET", path: "/api/v1/repo", handler: repoStatusRoute },
|
|
314
|
+
// GET /api/v1/repo/bundle
|
|
315
|
+
{ method: "GET", path: "/api/v1/repo/bundle", handler: repoBundleRoute },
|
|
316
|
+
// POST /api/v1/repo/import
|
|
317
|
+
{ method: "POST", path: "/api/v1/repo/import", handler: repoImportRoute },
|
|
318
|
+
// ==================== Team Info (old lines 1417-1576) ====================
|
|
319
|
+
// GET /api/v1/team/status
|
|
320
|
+
{ method: "GET", path: "/api/v1/team/status", handler: teamStatusRoute },
|
|
321
|
+
// GET /api/v1/roles
|
|
322
|
+
{ method: "GET", path: "/api/v1/roles", handler: teamRolesRoute },
|
|
323
|
+
// GET /api/v1/profiles — list the available team profile packages
|
|
324
|
+
// (Phase 2.1, design section 4: the switcher UI reads this list).
|
|
325
|
+
{ method: "GET", path: "/api/v1/profiles", handler: teamProfilesListRoute },
|
|
326
|
+
// GET /api/v1/team/profile — active profile detail incl. capabilities
|
|
327
|
+
// (design section 4: UI hides capability-gated entries based on this).
|
|
328
|
+
{ method: "GET", path: "/api/v1/team/profile", handler: teamProfileGetRoute },
|
|
329
|
+
// POST /api/v1/team/profile { profileId } — six-step switch semantics
|
|
330
|
+
// (Phase 2.1, design section 2.3). Returns 202; progress arrives via the
|
|
331
|
+
// team.switch_started / team.switch_completed WS events.
|
|
332
|
+
{ method: "POST", path: "/api/v1/team/profile", handler: teamProfileSwitchRoute },
|
|
333
|
+
// GET /api/v1/archived-teams — archived team metadata list
|
|
334
|
+
// (Phase 2.1, design section 4: profileId/teamName/time/taskCount; detail
|
|
335
|
+
// queries and the archive UI stay v1.1).
|
|
336
|
+
{ method: "GET", path: "/api/v1/archived-teams", handler: archivedTeamsRoute },
|
|
337
|
+
// ==================== Previews / reports / health (old lines 1580-1633) ====================
|
|
338
|
+
// /api/v1/previews/:id/* — proxy to preview subprocess (5-method
|
|
339
|
+
// whitelist, prefix route; sits after every exact /api/v1 route so it can
|
|
340
|
+
// never shadow them).
|
|
341
|
+
{ method: ["GET", "HEAD", "POST", "PUT", "DELETE"], path: "/api/v1/previews/", prefix: true, handler: previewsProxyRoute },
|
|
342
|
+
// GET /api/v1/reports — list all delivery reports
|
|
343
|
+
{ method: "GET", path: "/api/v1/reports", handler: reportsListRoute },
|
|
344
|
+
// GET /api/v1/reports/:sessionKey — serve delivery report page
|
|
345
|
+
{ method: "GET", path: "/api/v1/reports/", prefix: true, handler: reportsSessionRoute },
|
|
346
|
+
// GET /api/v1/health
|
|
347
|
+
{ method: "GET", path: "/api/v1/health", handler: healthRoute },
|
|
348
|
+
// ==================== Device pairing security (issue #23) ====================
|
|
349
|
+
// The five POST endpoints are EXEMPT from the device-auth middleware and
|
|
350
|
+
// enforce their own stricter origin rules inside controller/security.ts:
|
|
351
|
+
// enable - loopback only (mints the FIRST device; remote = attacker)
|
|
352
|
+
// pair/start- authenticated device or loopback (mints a fresh code,
|
|
353
|
+
// invalidating the previous one)
|
|
354
|
+
// pair - one-shot 60s code exchange -> {token, deviceId}
|
|
355
|
+
// pair-auto - LAN peer + config.security.autoPair + protection on
|
|
356
|
+
// reset - authenticated device or loopback (anti-lockout hatch)
|
|
357
|
+
// GET /security and DELETE /security/devices/:id are NOT exempt: the
|
|
358
|
+
// middleware itself guarantees the caller holds a valid device token.
|
|
359
|
+
{ method: "POST", path: "/api/v1/security/enable", handler: handleSecurityEnableRequest },
|
|
360
|
+
{ method: "POST", path: "/api/v1/security/pair/start", handler: handleSecurityPairStartRequest },
|
|
361
|
+
{ method: "POST", path: "/api/v1/security/pair", handler: handleSecurityPairRequest },
|
|
362
|
+
{ method: "POST", path: "/api/v1/security/pair-auto", handler: handleSecurityPairAutoRequest },
|
|
363
|
+
{ method: "GET", path: "/api/v1/security", handler: handleSecurityGetRequest },
|
|
364
|
+
{ method: "DELETE", path: /^\/api\/v1\/security\/devices\/[^/]+$/, handler: handleSecurityDeviceDeleteRequest },
|
|
365
|
+
{ method: "POST", path: "/api/v1/security/reset", handler: handleSecurityResetRequest },
|
|
366
|
+
// ==================== Workflow templates (design 2.4) ====================
|
|
367
|
+
// Appended after the historical table + security suffix (no path overlap
|
|
368
|
+
// with any earlier route, so the append cannot reorder historical
|
|
369
|
+
// matching - same append-only precedent as the security entries above).
|
|
370
|
+
// POST /api/v1/workflows/{id}/start - kick off a declarative workflow run
|
|
371
|
+
// of the active profile (banking: credit-approval); body may carry
|
|
372
|
+
// { context } (initial business context). The handler enforces the
|
|
373
|
+
// transition-matrix 503 itself (see workflow-routes.ts).
|
|
374
|
+
{ method: "POST", path: /^\/api\/v1\/workflows\/[^/]+\/start$/, handler: workflowStartRoute },
|
|
375
|
+
];
|