@teamclaws/teamclaw 2026.11.0 → 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 +272 -2
- package/dist/index.js +54 -32
- package/dist/src/config.js +24 -0
- package/dist/src/controller/auth-routes.js +129 -0
- package/dist/src/controller/clarification-routes.js +1 -1
- package/dist/src/controller/controller-planning.js +1 -0
- package/dist/src/controller/controller-routes.js +195 -0
- package/dist/src/controller/controller-service.js +67 -10
- package/dist/src/controller/controller-tools.js +3 -1
- package/dist/src/controller/github-auth.js +2 -1
- package/dist/src/controller/http-server.js +51 -16
- package/dist/src/controller/kickoff-orchestrator.js +3 -39
- package/dist/src/controller/message-delivery.js +4 -1
- package/dist/src/controller/orchestration-manifest.js +5 -65
- package/dist/src/controller/preview-manager.js +51 -3
- package/dist/src/controller/profile-switch.js +42 -22
- 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 +70 -4
- package/dist/src/controller/report-routes.js +56 -0
- package/dist/src/controller/route-table.js +67 -1045
- package/dist/src/controller/security.js +775 -0
- package/dist/src/controller/status-routes.js +287 -0
- package/dist/src/controller/task-assignment.js +5 -2
- package/dist/src/controller/task-execution.js +31 -0
- package/dist/src/controller/task-results.js +10 -0
- package/dist/src/controller/tunnel-manager.js +41 -8
- package/dist/src/controller/tunnel-routes.js +225 -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 +39 -949
- 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 +12 -1
- package/dist/src/profile-loader.js +119 -1
- package/dist/src/profiles/banking.json +26 -2
- package/dist/src/profiles/schema.json +82 -2
- package/dist/src/prompt-policy.js +18 -6
- package/dist/src/protocol.js +66 -3
- 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 +89 -3
- package/dist/src/types.js +15 -1
- package/dist/src/ui/app.js +846 -62
- package/dist/src/ui/github-login.html +1 -0
- package/dist/src/ui/index.html +102 -36
- package/dist/src/worker/http-handler.js +59 -0
- package/dist/src/worker/skill-installer.js +3 -9
- package/dist/src/worker/tools.js +20 -10
- package/dist/src/worker/worker-service.js +17 -4
- package/index.ts +61 -32
- package/openclaw.plugin.json +23 -2
- package/package.json +1 -1
- package/src/config.ts +24 -0
- package/src/controller/auth-routes.ts +157 -0
- package/src/controller/clarification-routes.ts +1 -1
- package/src/controller/controller-planning.ts +8 -0
- package/src/controller/controller-routes.ts +237 -0
- package/src/controller/controller-service.ts +128 -10
- package/src/controller/controller-tools.ts +5 -2
- package/src/controller/github-auth.ts +28 -63
- package/src/controller/http-server.ts +66 -17
- package/src/controller/kickoff-orchestrator.ts +3 -42
- package/src/controller/message-delivery.ts +4 -1
- package/src/controller/orchestration-manifest.ts +8 -71
- package/src/controller/preview-manager.ts +53 -3
- package/src/controller/profile-switch.ts +53 -23
- 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 +84 -12
- package/src/controller/report-routes.ts +64 -0
- package/src/controller/route-table.ts +133 -1152
- package/src/controller/security.ts +899 -0
- package/src/controller/status-routes.ts +354 -0
- package/src/controller/task-assignment.ts +5 -1
- package/src/controller/task-execution.ts +43 -0
- package/src/controller/task-results.ts +12 -0
- package/src/controller/tunnel-manager.ts +45 -8
- package/src/controller/tunnel-routes.ts +231 -0
- package/src/controller/websocket.ts +19 -3
- package/src/controller/webui-routes.ts +55 -0
- package/src/controller/worker-provisioning.ts +51 -1117
- 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 +13 -1
- package/src/profile-loader.ts +167 -1
- package/src/profiles/banking.json +26 -2
- package/src/profiles/schema.json +82 -2
- package/src/prompt-policy.ts +19 -6
- package/src/protocol.ts +72 -2
- 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 +92 -3
- package/src/teamauto/github-client.ts +2 -1
- package/src/teamauto/repo-sync.ts +2 -1
- package/src/teamauto/scheduler.ts +2 -1
- package/src/types.ts +130 -1
- package/src/ui/app.js +846 -62
- package/src/ui/github-login.html +1 -0
- package/src/ui/index.html +102 -36
- package/src/worker/http-handler.ts +64 -1
- package/src/worker/skill-installer.ts +3 -9
- package/src/worker/tools.ts +21 -10
- package/src/worker/worker-service.ts +18 -4
|
@@ -279,6 +279,114 @@ function loadBuiltinProfiles() {
|
|
|
279
279
|
}
|
|
280
280
|
return profiles;
|
|
281
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Design 2.4 workflow red lines that the JSON Schema subset cannot express:
|
|
284
|
+
* step-id uniqueness, step.role must be a role of this profile, `on` keys must
|
|
285
|
+
* come from the step's conclusion enum, `on` targets must resolve to an
|
|
286
|
+
* existing step id (or "next"), and every inputs[] key must be an outputs[]
|
|
287
|
+
* key declared by some step of the same workflow. All failures are FATAL load
|
|
288
|
+
* errors (design 2.2), same as the role-reference red line.
|
|
289
|
+
*/
|
|
290
|
+
function crossValidateWorkflows(profile, roleIdSet, referenceErrors) {
|
|
291
|
+
const workflows = profile.workflows ?? [];
|
|
292
|
+
const workflowIds = new Set();
|
|
293
|
+
for (const workflow of workflows) {
|
|
294
|
+
const workflowLabel = `workflow "${workflow.id}"`;
|
|
295
|
+
if (workflowIds.has(workflow.id)) {
|
|
296
|
+
referenceErrors.push(`${workflowLabel} id is declared more than once`);
|
|
297
|
+
}
|
|
298
|
+
workflowIds.add(workflow.id);
|
|
299
|
+
const stepKey = (stepId) => String(stepId);
|
|
300
|
+
const stepIds = new Set(workflow.steps.map((step) => stepKey(step.id)));
|
|
301
|
+
if (stepIds.size !== workflow.steps.length) {
|
|
302
|
+
referenceErrors.push(`${workflowLabel} has duplicate step ids`);
|
|
303
|
+
}
|
|
304
|
+
// #251 L7: runs start at steps[0] (workflow-routes "按 steps 建任务链"),
|
|
305
|
+
// so the first step must sit on the numeric spine - a branch-only string
|
|
306
|
+
// id first step would route nowhere on completion and the run dies
|
|
307
|
+
// instantly. Load validation refuses such templates.
|
|
308
|
+
const firstStepId = workflow.steps[0]?.id;
|
|
309
|
+
if (firstStepId !== undefined && typeof firstStepId !== "number") {
|
|
310
|
+
referenceErrors.push(`${workflowLabel} first step must be a numeric spine step (design 2.4): runs start at steps[0], and the branch-only string id ${JSON.stringify(firstStepId)} would end the run immediately`);
|
|
311
|
+
}
|
|
312
|
+
const outputKeys = new Set();
|
|
313
|
+
for (const step of workflow.steps) {
|
|
314
|
+
for (const output of step.outputs ?? []) {
|
|
315
|
+
if (outputKeys.has(output.key)) {
|
|
316
|
+
referenceErrors.push(`${workflowLabel} declares output key "${output.key}" more than once`);
|
|
317
|
+
}
|
|
318
|
+
outputKeys.add(output.key);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
for (const step of workflow.steps) {
|
|
322
|
+
const stepLabel = `${workflowLabel} step ${JSON.stringify(step.id)}`;
|
|
323
|
+
const stepIdTypeOk = (typeof step.id === "number" && Number.isSafeInteger(step.id))
|
|
324
|
+
|| (typeof step.id === "string" && step.id.trim().length > 0);
|
|
325
|
+
if (!stepIdTypeOk) {
|
|
326
|
+
referenceErrors.push(`${stepLabel}: step id must be a safe integer (linear spine) or a non-empty string (branch-only target), got ${typeof step.id}`);
|
|
327
|
+
}
|
|
328
|
+
if (!roleIdSet.has(step.role)) {
|
|
329
|
+
referenceErrors.push(`${stepLabel} role "${step.role}" is not a role of this profile`);
|
|
330
|
+
}
|
|
331
|
+
const conclusion = step.conclusion ?? [];
|
|
332
|
+
for (const [jumpConclusion, target] of Object.entries(step.on ?? {})) {
|
|
333
|
+
if (!conclusion.includes(jumpConclusion)) {
|
|
334
|
+
referenceErrors.push(`${stepLabel} on-jump key "${jumpConclusion}" is not in the step's conclusion enum (dead routing, design 2.4)`);
|
|
335
|
+
}
|
|
336
|
+
if (target !== "next" && !stepIds.has(stepKey(target))) {
|
|
337
|
+
referenceErrors.push(`${stepLabel} on-jump "${jumpConclusion}" targets ${JSON.stringify(target)}, which is not a step id of this workflow`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
for (const inputKey of step.inputs ?? []) {
|
|
341
|
+
if (!outputKeys.has(inputKey)) {
|
|
342
|
+
referenceErrors.push(`${stepLabel} inputs key "${inputKey}" is not declared as an output of any step of this workflow (dangling input, design 2.4)`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// #251 M2 static cycle red line: explicit on-jumps between DISTINCT steps
|
|
347
|
+
// must not form a cycle. Without this check a mutual-jump template loads
|
|
348
|
+
// fine and the cycle is only cut off at runtime by the visit cap, after
|
|
349
|
+
// burning real LLM calls. A step jumping back to ITSELF stays legal - it
|
|
350
|
+
// is the bounded self-retry pattern the banking pack ships
|
|
351
|
+
// (需补充材料 -> re-run intake), still guarded by MAX_WORKFLOW_STEP_VISITS.
|
|
352
|
+
const jumpTargets = new Map();
|
|
353
|
+
for (const step of workflow.steps) {
|
|
354
|
+
const targets = [];
|
|
355
|
+
for (const target of Object.values(step.on ?? {})) {
|
|
356
|
+
if (target !== "next" && stepKey(target) !== stepKey(step.id)) {
|
|
357
|
+
targets.push(stepKey(target));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (targets.length > 0) {
|
|
361
|
+
jumpTargets.set(stepKey(step.id), targets);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
for (const startId of jumpTargets.keys()) {
|
|
365
|
+
const path = [];
|
|
366
|
+
const onPath = new Set();
|
|
367
|
+
const visit = (nodeId) => {
|
|
368
|
+
path.push(nodeId);
|
|
369
|
+
onPath.add(nodeId);
|
|
370
|
+
for (const nextId of jumpTargets.get(nodeId) ?? []) {
|
|
371
|
+
if (onPath.has(nextId)) {
|
|
372
|
+
referenceErrors.push(`${workflowLabel} explicit on-jump cycle ${[...path.slice(path.indexOf(nextId)), nextId].join(" -> ")} `
|
|
373
|
+
+ "(design 2.4: the runtime visit cap would only stop it after burning real LLM calls)");
|
|
374
|
+
return true;
|
|
375
|
+
}
|
|
376
|
+
if (visit(nextId)) {
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
path.pop();
|
|
381
|
+
onPath.delete(nodeId);
|
|
382
|
+
return false;
|
|
383
|
+
};
|
|
384
|
+
if (visit(startId)) {
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
282
390
|
/** Structural checks that sit outside what the JSON Schema subset can express. */
|
|
283
391
|
function crossValidateProfile(profile, profileFile) {
|
|
284
392
|
const roleIds = profile.roles.map((role) => role.id);
|
|
@@ -311,6 +419,7 @@ function crossValidateProfile(profile, profileFile) {
|
|
|
311
419
|
}
|
|
312
420
|
}
|
|
313
421
|
}
|
|
422
|
+
crossValidateWorkflows(profile, roleIdSet, referenceErrors);
|
|
314
423
|
if (referenceErrors.length > 0) {
|
|
315
424
|
throw new Error(`TeamClaw profile ${profileFile} ("${profile.id}") has dangling role references (design 2.2 - refusing to start):\n`
|
|
316
425
|
+ referenceErrors.map((line) => ` - ${line}`).join("\n"));
|
|
@@ -423,6 +532,15 @@ function getActiveKnowledgePacks() {
|
|
|
423
532
|
function getActiveRole(id) {
|
|
424
533
|
return getActiveRoles().find((role) => role.id === id);
|
|
425
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Design 2.4: the active profile's validated workflow templates, or an empty
|
|
537
|
+
* array when the profile ships none (software-rd baseline). Consumers: the
|
|
538
|
+
* POST /api/v1/workflows/{id}/start route and the task-completion routing
|
|
539
|
+
* hook (controller/workflow-routes.ts).
|
|
540
|
+
*/
|
|
541
|
+
function getActiveWorkflows() {
|
|
542
|
+
return getActiveProfile().workflows ?? [];
|
|
543
|
+
}
|
|
426
544
|
/**
|
|
427
545
|
* Phase 2.6 labelZh fallback rule (vertical-team-profiles-design.md 2.1/2.6):
|
|
428
546
|
* the zh display name is labelZh when the role carries one, otherwise the
|
|
@@ -483,4 +601,4 @@ function resolveActiveRoleSkills(roleId, taskSkills = []) {
|
|
|
483
601
|
const roleSkills = roleId ? (getActiveRole(roleId)?.recommendedSkills ?? []) : [];
|
|
484
602
|
return normalizeRecommendedSkills([...roleSkills, ...taskSkills]);
|
|
485
603
|
}
|
|
486
|
-
export { BUILTIN_PROFILES, SOFTWARE_RD_PROFILE_ID, validateProfilePackage, hasProfile, setActiveProfileId, getActiveProfileId, getActiveProfile, getActiveRoles, getActiveRoleIds, getActiveDefaultRole, getActiveDomainInstructions, getActiveKnowledgePacks, getActiveRole, validateActiveRoleId, normalizeRecommendedSkills, resolveActiveRoleSkills, resolveRoleDisplayName, };
|
|
604
|
+
export { BUILTIN_PROFILES, SOFTWARE_RD_PROFILE_ID, validateProfilePackage, hasProfile, setActiveProfileId, getActiveProfileId, getActiveProfile, getActiveRoles, getActiveRoleIds, getActiveDefaultRole, getActiveDomainInstructions, getActiveKnowledgePacks, getActiveWorkflows, getActiveRole, validateActiveRoleId, normalizeRecommendedSkills, resolveActiveRoleSkills, resolveRoleDisplayName, };
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
"nameZh": "银行对公信贷团队",
|
|
6
6
|
"industry": "banking",
|
|
7
7
|
"icon": "🏦",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.2",
|
|
9
9
|
"reviewedBy": [
|
|
10
10
|
"drafted-by: Agent N (implementation team)",
|
|
11
11
|
"AI domain review 2026-11-08: approved conditional on removing bare 「押品」 token from banking risk-reviewer capabilities (applied); securities/insurance approved as-is; glossary version-cutoff implemented as no-citation-number policy (accepted deviation). Human sign-off recorded 2026-11-08.",
|
|
12
|
-
"Human sign-off: zhanju (repo owner), 2026-11-08 - approved via the TeamProfile implementation session after AI domain review conditions were applied."
|
|
12
|
+
"Human sign-off: zhanju (repo owner), 2026-11-08 - approved via the TeamProfile implementation session after AI domain review conditions were applied.",
|
|
13
|
+
"0.1.2 workflows wave (2026-11-10): added the credit-approval declarative workflow template (design section 2.4, copied field-for-field; step 1 additionally declares its reviewOpinion output so every downstream inputs[] key resolves). Roles, prompts, guardrails and glossary are unchanged from the signed 0.1.1."
|
|
13
14
|
],
|
|
14
15
|
"description": "Corporate credit line team (v1 scope: 对公信贷) covering intake, risk review, approval, AML analysis, credit compliance and post-loan management; every output is an internal working draft pending a human decision.",
|
|
15
16
|
"roles": [
|
|
@@ -167,6 +168,29 @@
|
|
|
167
168
|
"风险分类: 按行内金融资产风险分类框架输出「分类提示」(事实+考量+缺口清单),分类结果由人工认定。",
|
|
168
169
|
"法规版本截止声明: 法规修订频繁,助手记忆中的生效日期与修订状态不可作为依据;一律要求用户提供现行有效的权威文本,本词条表不携带文号。"
|
|
169
170
|
],
|
|
171
|
+
"workflows": [
|
|
172
|
+
{
|
|
173
|
+
"id": "credit-approval",
|
|
174
|
+
"name": "信贷审批流(对公)",
|
|
175
|
+
"steps": [
|
|
176
|
+
{ "id": 0, "role": "credit-officer", "title": "受理与尽调",
|
|
177
|
+
"conclusion": ["材料齐全", "需补充材料"],
|
|
178
|
+
"on": { "需补充材料": 0 },
|
|
179
|
+
"outputs": [{ "key": "dueDiligenceReport", "name": "尽调报告" }] },
|
|
180
|
+
{ "id": 1, "role": "risk-reviewer", "title": "风险审查",
|
|
181
|
+
"inputs": ["dueDiligenceReport"],
|
|
182
|
+
"conclusion": ["通过", "退回补充材料", "超权限上会"],
|
|
183
|
+
"on": { "退回补充材料": 0, "超权限上会": "committee", "通过": 2 },
|
|
184
|
+
"outputs": [{ "key": "reviewOpinion", "name": "风险审查意见" }] },
|
|
185
|
+
{ "id": 2, "role": "approver", "title": "审批决策",
|
|
186
|
+
"inputs": ["dueDiligenceReport", "reviewOpinion"],
|
|
187
|
+
"outputs": [{ "key": "approvalDecision", "name": "审批结论" }] },
|
|
188
|
+
{ "id": "committee", "role": "approver", "title": "贷审会(超权限)",
|
|
189
|
+
"inputs": ["dueDiligenceReport", "reviewOpinion"],
|
|
190
|
+
"outputs": [{ "key": "committeeMinutes", "name": "贷审会纪要式结论" }] }
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
],
|
|
170
194
|
"capabilities": {
|
|
171
195
|
"git": false,
|
|
172
196
|
"teamauto": false,
|
|
@@ -159,8 +159,88 @@
|
|
|
159
159
|
},
|
|
160
160
|
"workflows": {
|
|
161
161
|
"type": "array",
|
|
162
|
-
"items": {
|
|
163
|
-
|
|
162
|
+
"items": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"required": ["id", "name", "steps"],
|
|
165
|
+
"properties": {
|
|
166
|
+
"id": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"pattern": "^[a-z][a-z0-9-]*$",
|
|
169
|
+
"minLength": 1,
|
|
170
|
+
"description": "Workflow template slug (the start endpoint key), unique within the profile."
|
|
171
|
+
},
|
|
172
|
+
"name": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"minLength": 1,
|
|
175
|
+
"description": "Display name of the workflow (button label for the UI quick-actions group)."
|
|
176
|
+
},
|
|
177
|
+
"description": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"description": "Optional one-line summary of what the workflow covers."
|
|
180
|
+
},
|
|
181
|
+
"steps": {
|
|
182
|
+
"type": "array",
|
|
183
|
+
"minItems": 1,
|
|
184
|
+
"items": {
|
|
185
|
+
"type": "object",
|
|
186
|
+
"required": ["id", "role", "title"],
|
|
187
|
+
"properties": {
|
|
188
|
+
"id": {
|
|
189
|
+
"description": "Step identifier: an integer on the linear spine (0, 1, 2, ...) or a non-numeric string for branch-only steps (e.g. \"committee\"). Uniqueness and on-target resolution are enforced by loader cross-validation; the schema subset cannot express unions."
|
|
190
|
+
},
|
|
191
|
+
"role": {
|
|
192
|
+
"type": "string",
|
|
193
|
+
"minLength": 1,
|
|
194
|
+
"description": "RoleId of the step's executing role; must be a role of this profile (loader cross-validation red line)."
|
|
195
|
+
},
|
|
196
|
+
"title": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"minLength": 1,
|
|
199
|
+
"description": "Step title; becomes the created task's title."
|
|
200
|
+
},
|
|
201
|
+
"description": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"description": "Optional extra instructions folded into the step's task description."
|
|
204
|
+
},
|
|
205
|
+
"inputs": {
|
|
206
|
+
"type": "array",
|
|
207
|
+
"items": { "type": "string", "minLength": 1 },
|
|
208
|
+
"uniqueItems": true,
|
|
209
|
+
"description": "Output keys from upstream steps whose results are embedded into this step's task description (design 2.4 outputKey passing). Each key must be declared by some step's outputs (loader cross-validation)."
|
|
210
|
+
},
|
|
211
|
+
"conclusion": {
|
|
212
|
+
"type": "array",
|
|
213
|
+
"items": { "type": "string", "minLength": 1 },
|
|
214
|
+
"uniqueItems": true,
|
|
215
|
+
"description": "Conclusion phrases; the step's deliverable must end with exactly one of them, and the task-completion hook matches them against the result to route (design 2.4)."
|
|
216
|
+
},
|
|
217
|
+
"on": {
|
|
218
|
+
"type": "object",
|
|
219
|
+
"description": "Conclusion -> step id jumps. Every key must be in this step's conclusion enum; every value must be \"next\" or an existing step id (loader cross-validation). Conclusions without an explicit mapping default to the next numeric-spine step."
|
|
220
|
+
},
|
|
221
|
+
"outputs": {
|
|
222
|
+
"type": "array",
|
|
223
|
+
"items": {
|
|
224
|
+
"type": "object",
|
|
225
|
+
"required": ["key", "name"],
|
|
226
|
+
"properties": {
|
|
227
|
+
"key": { "type": "string", "pattern": "^[a-z][a-zA-Z0-9-]*$", "minLength": 1, "description": "Output key downstream steps reference via inputs." },
|
|
228
|
+
"name": { "type": "string", "minLength": 1, "description": "Display name of the output artifact." }
|
|
229
|
+
},
|
|
230
|
+
"additionalProperties": false
|
|
231
|
+
},
|
|
232
|
+
"uniqueItems": true,
|
|
233
|
+
"description": "Named outputs this step produces; keys must be unique across the whole workflow (loader cross-validation)."
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"additionalProperties": false
|
|
237
|
+
},
|
|
238
|
+
"description": "Ordered steps; numeric ids form the linear spine, string ids are branch-only targets."
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"additionalProperties": false
|
|
242
|
+
},
|
|
243
|
+
"description": "Industry workflow templates with conclusion branches (design section 2.4; consumed by POST /api/v1/workflows/{id}/start and the task-completion routing hook). Optional; software-rd ships none."
|
|
164
244
|
},
|
|
165
245
|
"capabilities": {
|
|
166
246
|
"type": "object",
|
|
@@ -5,8 +5,18 @@ import { buildTeamClawProjectAgentRelativePath } from "./openclaw-workspace.js";
|
|
|
5
5
|
// free leaf keeps a single source of truth without a module cycle. roles.ts
|
|
6
6
|
// asserts its ROLES registry agrees with the same list.
|
|
7
7
|
import { ROLE_IDS } from "./role-ids.js";
|
|
8
|
+
import { getActiveRoleIds } from "./profile-loader.js";
|
|
8
9
|
export const TEAMCLAW_ROLE_IDS = ROLE_IDS;
|
|
9
10
|
export const TEAMCLAW_ROLE_IDS_TEXT = TEAMCLAW_ROLE_IDS.join(", ");
|
|
11
|
+
// #251 (design 2.3): the four role-list prompt injections must reflect the
|
|
12
|
+
// ACTIVE team profile, not the software-11 constant - a banking team must
|
|
13
|
+
// not be told to collaborate using "architect"/"release-engineer" IDs.
|
|
14
|
+
// profile-loader is runtime dependency-free (fs + JSON only), so importing
|
|
15
|
+
// it here cannot create a module cycle. Under software-rd the active list
|
|
16
|
+
// IS the canonical software-11 list, so baseline prompts are byte-identical.
|
|
17
|
+
function activeRoleIdsText() {
|
|
18
|
+
return getActiveRoleIds().join(", ");
|
|
19
|
+
}
|
|
10
20
|
export function composePrompt(...sections) {
|
|
11
21
|
const lines = [];
|
|
12
22
|
for (const section of sections) {
|
|
@@ -29,8 +39,10 @@ export function composePrompt(...sections) {
|
|
|
29
39
|
* the option (software-rd baseline, roles.ts registry init) the output is
|
|
30
40
|
* byte-identical to the pre-Phase-2.4 value, which the Phase 1.7 prompt
|
|
31
41
|
* goldens lock. The option is injected by the prompt pipelines (controller
|
|
32
|
-
* and worker prompt-injector) rather than read from the loader here
|
|
33
|
-
*
|
|
42
|
+
* and worker prompt-injector) rather than read from the loader here.
|
|
43
|
+
* (#251 exception: the four role-LIST injections below now read
|
|
44
|
+
* getActiveRoleIds() directly - see activeRoleIdsText(). profile-loader is
|
|
45
|
+
* runtime dependency-free, so this still cannot cycle.)
|
|
34
46
|
*/
|
|
35
47
|
export function buildRoleOperatingRules(options) {
|
|
36
48
|
const domainInstructions = options.domainInstructions ?? [];
|
|
@@ -59,7 +71,7 @@ export function buildRoleOperatingRules(options) {
|
|
|
59
71
|
"- Treat other workers' OpenClaw sessions and session keys as unavailable; use the shared workspace, the current task context, and teammate messages instead of trying cross-session inspection.",
|
|
60
72
|
"- Do not mark a task completed or failed via progress updates. Finish by returning the deliverable or raising the blocking error so TeamClaw can close the task correctly.",
|
|
61
73
|
"- Do not infer ownership, license scope, or lack of user authorization from technical characteristics such as proprietary branding, bundled assets, binary files, minified code, or repository layout. Focus on technical feasibility and the user's explicit requirements.",
|
|
62
|
-
`- Use exact TeamClaw role IDs when collaborating: ${
|
|
74
|
+
`- Use exact TeamClaw role IDs when collaborating: ${activeRoleIdsText()}.`,
|
|
63
75
|
`- If a true follow-up is required after your deliverable, prefer these exact next roles: ${suggestedRoles}.`,
|
|
64
76
|
`- Default starter skills for this role: ${recommendedSkills}. If the task includes more specific recommended skills, prefer those.`,
|
|
65
77
|
];
|
|
@@ -91,7 +103,7 @@ export function buildWorkerSessionRules() {
|
|
|
91
103
|
"7. If another role must continue later, use review/handoff tools on the current task instead of spawning work.",
|
|
92
104
|
"8. Other workers' OpenClaw sessions are isolated from this worker. Do not attempt cross-session inspection; use task context, the shared workspace, and queued team messages instead.",
|
|
93
105
|
"9. Do not mark the task completed or failed via progress updates. Return the final deliverable and let TeamClaw close the task.",
|
|
94
|
-
`10. Valid TeamClaw role IDs: ${
|
|
106
|
+
`10. Valid TeamClaw role IDs: ${activeRoleIdsText()}.`,
|
|
95
107
|
"11. Treat file paths from documents, plans, and teammate messages as hints, not guarantees. Verify the real path exists in the current workspace before reading or editing it; if it does not exist, search for the closest real file and note the drift instead of repeatedly calling missing paths.",
|
|
96
108
|
"12. The workspace may be backed by a TeamClaw-managed git repository. Treat the current checkout as canonical project state; do not delete `.git` or replace the repo with ad-hoc archives.",
|
|
97
109
|
"13. If the assigned task includes recommended skills, use those exact skill slugs first. Missing skills should be searched/installed before execution when supported by the runtime.",
|
|
@@ -125,7 +137,7 @@ export function buildTaskExecutionRules(rateLimitWaitingSentinel) {
|
|
|
125
137
|
`- Do NOT use sessions_yield or end your turn while background work, coding agents, or process sessions are still running; if the task is not complete yet, reply with exactly ${rateLimitWaitingSentinel}.`,
|
|
126
138
|
"- Never return 'running in background' as the final result for a TeamClaw task. If you spawn a helper session, keep monitoring it and only return after you have the actual deliverable.",
|
|
127
139
|
"- Use structured fields on progress, review, handoff, and messaging tools whenever coordination is needed.",
|
|
128
|
-
`- When naming a role, use exact TeamClaw role IDs: ${
|
|
140
|
+
`- When naming a role, use exact TeamClaw role IDs: ${activeRoleIdsText()}.`,
|
|
129
141
|
];
|
|
130
142
|
}
|
|
131
143
|
export function buildVerificationPolicy() {
|
|
@@ -369,7 +381,7 @@ export function buildControllerDisciplineRules(options) {
|
|
|
369
381
|
? "- If no workers are currently registered but on-demand provisioning is enabled, you may still create execution-ready tasks so the required roles can be provisioned."
|
|
370
382
|
: "- If no workers are registered, you may mention which roles would be needed, but stop there and report the worker-capacity block to the human.",
|
|
371
383
|
"- Use the controller itself for requirement analysis; use the PM role only for PM-owned deliverables after intake is clear.",
|
|
372
|
-
`- Use exact TeamClaw role IDs only: ${
|
|
384
|
+
`- Use exact TeamClaw role IDs only: ${activeRoleIdsText()}.`,
|
|
373
385
|
"- Never guess or summarize a worker's unfinished output as if it were a completed result. While work is still in flight, report only current status plus the next concrete step.",
|
|
374
386
|
"- Never fabricate downstream readiness from intent alone. Downstream creation requires evidence: completed task state, a structured result contract, concrete deliverables, or an explicit handoff.",
|
|
375
387
|
"- Never ask the human to manually run an obvious machine step such as rebuild/retest/repro/verification (for example git pull, go build, npm test, rerun and report whether it still crashes) when TeamClaw can create an execution task and do that work itself.",
|
package/dist/src/protocol.js
CHANGED
|
@@ -1,13 +1,62 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
1
2
|
export const MDNS_TYPE = "_teamclaw._tcp";
|
|
2
3
|
export const DEFAULT_PORT = 9527;
|
|
3
4
|
export const HEARTBEAT_MS = 10000;
|
|
4
5
|
export const WORKER_TIMEOUT_MS = 30000;
|
|
5
6
|
export const API_PREFIX = "/api/v1";
|
|
7
|
+
// Issue #255 P0-1: id fragments used to come from the V8 Math PRNG
|
|
8
|
+
// (xorshift128+ - the internal state is recoverable from a handful of
|
|
9
|
+
// observed outputs, so past fragments leak future ones). Fragments now
|
|
10
|
+
// derive from the CSPRNG. The output shape (timestamp + 6 base36 chars) is
|
|
11
|
+
// kept byte-compatible so no generateId consumer sees a format change.
|
|
12
|
+
const ID_FRAGMENT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
13
|
+
function randomIdFragment(length = 6) {
|
|
14
|
+
let fragment = "";
|
|
15
|
+
while (fragment.length < length) {
|
|
16
|
+
for (const byte of randomBytes(length * 2)) {
|
|
17
|
+
// 256 is not a multiple of 36: bytes >= 252 would bias the last four
|
|
18
|
+
// alphabet symbols - reject them and draw again.
|
|
19
|
+
if (byte >= 252) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
fragment += ID_FRAGMENT_ALPHABET[byte % 36];
|
|
23
|
+
if (fragment.length === length) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return fragment;
|
|
29
|
+
}
|
|
6
30
|
function generateId() {
|
|
7
31
|
const ts = Date.now().toString(36);
|
|
8
|
-
const rand =
|
|
32
|
+
const rand = randomIdFragment();
|
|
9
33
|
return `${ts}-${rand}`;
|
|
10
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Issue #255 P0-1: bearer token a provisioned worker must present at
|
|
37
|
+
* registration (and that the controller echoes on task dispatch). 256 bits
|
|
38
|
+
* from the CSPRNG, hex-encoded. This is an internal value with no external
|
|
39
|
+
* format contract - it travels controller -> worker through the
|
|
40
|
+
* TEAMCLAW_LAUNCH_TOKEN env var and is only ever equality-checked - so the
|
|
41
|
+
* old `${generateId()}-${generateId()}` shape (two ~31-bit xorshift128+
|
|
42
|
+
* fragments) is replaced outright. Tokens minted by older builds stay valid:
|
|
43
|
+
* the check is an equality either way (now constant-time), only generation
|
|
44
|
+
* changes.
|
|
45
|
+
*/
|
|
46
|
+
function generateLaunchToken() {
|
|
47
|
+
return randomBytes(32).toString("hex");
|
|
48
|
+
}
|
|
49
|
+
/** Constant-time string equality for secrets (length guard: token length is
|
|
50
|
+
* a public format detail, not secret content).
|
|
51
|
+
* #259 follow-up: canonical home is this leaf module so controller leaves
|
|
52
|
+
* (worker-provisioning) can compare secrets without importing
|
|
53
|
+
* controller/security.ts, which would close a module cycle
|
|
54
|
+
* (http-server <-> route-table <-> security <-> worker-provisioning). */
|
|
55
|
+
export function secretsEqual(a, b) {
|
|
56
|
+
const left = Buffer.from(a, "utf8");
|
|
57
|
+
const right = Buffer.from(b, "utf8");
|
|
58
|
+
return left.length === right.length && timingSafeEqual(left, right);
|
|
59
|
+
}
|
|
11
60
|
async function parseJsonBody(req) {
|
|
12
61
|
const raw = await readRequestBody(req);
|
|
13
62
|
if (!raw.length) {
|
|
@@ -30,12 +79,26 @@ async function readRequestBody(req) {
|
|
|
30
79
|
req.on("error", reject);
|
|
31
80
|
});
|
|
32
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Issue #23: the Access-Control-Allow-Origin value a response should carry.
|
|
84
|
+
* A header the security gate PINNED before dispatch (device protection on:
|
|
85
|
+
* same-origin echo, or an explicit empty value for foreign origins) wins;
|
|
86
|
+
* with nothing pinned (protection off / non-browser requests) the value is
|
|
87
|
+
* the historical wildcard, byte for byte. Every response path that sets
|
|
88
|
+
* ACAO (sendJson here, the raw-file and repo-bundle octet-stream writers in
|
|
89
|
+
* the controller routes) must go through this helper so no route can widen
|
|
90
|
+
* a pinned response back to the L0 wildcard.
|
|
91
|
+
*/
|
|
92
|
+
function pinnedCorsAllowOrigin(res) {
|
|
93
|
+
const pinned = res.getHeader("Access-Control-Allow-Origin");
|
|
94
|
+
return typeof pinned === "string" ? pinned : "*";
|
|
95
|
+
}
|
|
33
96
|
function sendJson(res, status, data) {
|
|
34
97
|
const body = JSON.stringify(data);
|
|
35
98
|
res.writeHead(status, {
|
|
36
99
|
"Content-Type": "application/json",
|
|
37
100
|
"Content-Length": Buffer.byteLength(body),
|
|
38
|
-
"Access-Control-Allow-Origin":
|
|
101
|
+
"Access-Control-Allow-Origin": pinnedCorsAllowOrigin(res),
|
|
39
102
|
"Access-Control-Allow-Methods": "GET, POST, PATCH, DELETE, OPTIONS",
|
|
40
103
|
"Access-Control-Allow-Headers": "Content-Type",
|
|
41
104
|
});
|
|
@@ -55,4 +118,4 @@ function createHeartbeatPayload(workerId, status, currentTaskId) {
|
|
|
55
118
|
timestamp: Date.now(),
|
|
56
119
|
};
|
|
57
120
|
}
|
|
58
|
-
export { generateId, parseJsonBody, readRequestBody, sendJson, sendError, createRegistrationRequest, createHeartbeatPayload, };
|
|
121
|
+
export { generateId, generateLaunchToken, parseJsonBody, readRequestBody, sendJson, sendError, pinnedCorsAllowOrigin, createRegistrationRequest, createHeartbeatPayload, };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function normalizeOptionalManifestText(raw) {
|
|
2
|
+
if (typeof raw !== "string") {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
const normalized = raw.trim();
|
|
6
|
+
return normalized || undefined;
|
|
7
|
+
}
|
|
8
|
+
export function normalizeClarificationOptions(raw) {
|
|
9
|
+
if (!Array.isArray(raw)) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return raw
|
|
13
|
+
.filter((entry) => !!entry && typeof entry === "object")
|
|
14
|
+
.map((entry) => ({
|
|
15
|
+
value: typeof entry.value === "string" ? entry.value.trim() : "",
|
|
16
|
+
label: typeof entry.label === "string" ? entry.label.trim() : "",
|
|
17
|
+
hint: typeof entry.hint === "string" && entry.hint.trim() ? entry.hint.trim() : undefined,
|
|
18
|
+
}))
|
|
19
|
+
.filter((entry) => entry.value && entry.label);
|
|
20
|
+
}
|
|
21
|
+
export function normalizeClarificationQuestionSchema(raw) {
|
|
22
|
+
if (!raw || typeof raw !== "object") {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const input = raw;
|
|
26
|
+
const kind = typeof input.kind === "string" ? input.kind.trim() : "";
|
|
27
|
+
const title = typeof input.title === "string" ? input.title.trim() : "";
|
|
28
|
+
if (!title || !["single-select", "multi-select", "number", "text"].includes(kind)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const options = normalizeClarificationOptions(input.options);
|
|
32
|
+
const schema = {
|
|
33
|
+
kind: kind,
|
|
34
|
+
title,
|
|
35
|
+
description: normalizeOptionalManifestText(input.description),
|
|
36
|
+
required: input.required == null ? true : Boolean(input.required),
|
|
37
|
+
allowOther: Boolean(input.allowOther),
|
|
38
|
+
placeholder: normalizeOptionalManifestText(input.placeholder),
|
|
39
|
+
unit: normalizeOptionalManifestText(input.unit),
|
|
40
|
+
};
|
|
41
|
+
if (options.length > 0) {
|
|
42
|
+
schema.options = options;
|
|
43
|
+
}
|
|
44
|
+
if (typeof input.min === "number" && Number.isFinite(input.min)) {
|
|
45
|
+
schema.min = input.min;
|
|
46
|
+
}
|
|
47
|
+
if (typeof input.max === "number" && Number.isFinite(input.max)) {
|
|
48
|
+
schema.max = input.max;
|
|
49
|
+
}
|
|
50
|
+
if (typeof input.step === "number" && Number.isFinite(input.step)) {
|
|
51
|
+
schema.step = input.step;
|
|
52
|
+
}
|
|
53
|
+
if ((schema.kind === "single-select" || schema.kind === "multi-select") && (!schema.options || schema.options.length === 0)) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
return schema;
|
|
57
|
+
}
|
|
58
|
+
export function normalizeClarificationQuestionSchemas(raw) {
|
|
59
|
+
if (!Array.isArray(raw)) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
return raw
|
|
63
|
+
.map((entry) => normalizeClarificationQuestionSchema(entry))
|
|
64
|
+
.filter((entry) => Boolean(entry));
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Shared contracts layer (issue #226, W5): the GitHub auth manager TYPE
|
|
2
|
+
// contract. The teamauto subsystem consumes this type (github-client,
|
|
3
|
+
// scheduler, repo-sync all take a GithubAuthManager), so the cross-subsystem
|
|
4
|
+
// contract lives here — teamauto must not import the controller tree. Only
|
|
5
|
+
// types moved; the factory (createGithubAuthManager) and the singleton cache
|
|
6
|
+
// (getGithubAuthManager) stay in controller/github-auth.ts, which annotates
|
|
7
|
+
// the factory's return type with this contract so the compiler keeps the
|
|
8
|
+
// structural definition in lockstep with the implementation.
|
|
9
|
+
//
|
|
10
|
+
// GithubAuthManager was previously `ReturnType<typeof createGithubAuthManager>`;
|
|
11
|
+
// the explicit structural form below is signature-identical (each member
|
|
12
|
+
// mirrors one returned closure verbatim) and no longer requires importing the
|
|
13
|
+
// controller factory to name the type.
|
|
14
|
+
/** Default GitHub OAuth client id (moved from controller/github-auth, W3 residual edge). */
|
|
15
|
+
export const DEFAULT_GITHUB_CLIENT_ID = "Iv23liqWmzrS3swGiIvK";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveRole } from "../profile-loader.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build the kickoff assessment prompt sent to a worker.
|
|
4
|
+
* The worker should respond with structured JSON matching KickoffAssessment.
|
|
5
|
+
*/
|
|
6
|
+
export function buildKickoffAssessmentPrompt(role, requirement) {
|
|
7
|
+
const roleDef = getActiveRole(role);
|
|
8
|
+
const roleLabel = roleDef?.label ?? role;
|
|
9
|
+
return [
|
|
10
|
+
`You are the ${roleLabel} in a virtual software team.`,
|
|
11
|
+
`Your team is conducting a kickoff meeting for a new requirement.`,
|
|
12
|
+
``,
|
|
13
|
+
`## Requirement`,
|
|
14
|
+
requirement,
|
|
15
|
+
``,
|
|
16
|
+
`## Your Task`,
|
|
17
|
+
`Evaluate this requirement from your professional perspective as ${roleLabel}.`,
|
|
18
|
+
`Respond with a JSON object (and nothing else) with these fields:`,
|
|
19
|
+
``,
|
|
20
|
+
`{`,
|
|
21
|
+
` "needed": boolean, // Is your role needed for this project?`,
|
|
22
|
+
` "scope": string, // What would you contribute? (1-2 sentences)`,
|
|
23
|
+
` "suggestedTasks": string[], // Specific tasks you'd handle (2-5 items)`,
|
|
24
|
+
` "dependencies": string[], // What you need from other roles before or during your work`,
|
|
25
|
+
` "risks": string[], // Concerns or risks from your perspective`,
|
|
26
|
+
` "questions": string[] // Clarifications you'd want before starting`,
|
|
27
|
+
`}`,
|
|
28
|
+
``,
|
|
29
|
+
`Guidelines:`,
|
|
30
|
+
`- Be honest about whether your role is truly needed. Don't inflate your importance.`,
|
|
31
|
+
`- For "needed", consider: does the project actually require ${roleLabel}-level expertise?`,
|
|
32
|
+
`- A simple single-file script does NOT need an architect. A TODO app does NOT need a security engineer.`,
|
|
33
|
+
`- Keep suggestedTasks concrete and actionable, not vague.`,
|
|
34
|
+
`- Only list dependencies on roles that are actually relevant.`,
|
|
35
|
+
`- Return ONLY the JSON object, no markdown fencing, no explanation.`,
|
|
36
|
+
].join("\n");
|
|
37
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Shared generic utilities (issue #226 W6 dedup + W1 worker-provisioning
|
|
2
|
+
// split). Everything here is extracted VERBATIM from its former private
|
|
3
|
+
// copies - semantics are frozen, see the W6 notes per function:
|
|
4
|
+
// - pathExists strict: only ENOENT resolves false, other errors
|
|
5
|
+
// rethrow (former worker-provisioning.ts copy)
|
|
6
|
+
// - pathExistsTolerant swallowing: any access error resolves false (the
|
|
7
|
+
// former git-collaboration.ts / worker/skill-installer.ts
|
|
8
|
+
// / index.ts copies, kept as a distinct name so each
|
|
9
|
+
// call site keeps its exact original behavior)
|
|
10
|
+
// - sleep / cloneJson / sanitizePathSegment / sanitizeName: single shared
|
|
11
|
+
// copies of byte-identical former duplicates.
|
|
12
|
+
import fs from "node:fs/promises";
|
|
13
|
+
export function sleep(ms) {
|
|
14
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
+
}
|
|
16
|
+
export function cloneJson(value) {
|
|
17
|
+
return JSON.parse(JSON.stringify(value));
|
|
18
|
+
}
|
|
19
|
+
export async function pathExists(targetPath) {
|
|
20
|
+
try {
|
|
21
|
+
await fs.access(targetPath);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err.code === "ENOENT") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function pathExistsTolerant(targetPath) {
|
|
32
|
+
try {
|
|
33
|
+
await fs.access(targetPath);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function sanitizePathSegment(value) {
|
|
41
|
+
const normalized = value.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
42
|
+
return normalized || "worker";
|
|
43
|
+
}
|
|
44
|
+
export function sanitizeName(value, maxLength = 63) {
|
|
45
|
+
const normalized = sanitizePathSegment(value).slice(0, maxLength).replace(/^-+|-+$/g, "");
|
|
46
|
+
return normalized || "teamclaw";
|
|
47
|
+
}
|