@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,200 @@
|
|
|
1
|
+
// Issue #226 W2 (route-table carve-up): the workspace browser + model-config
|
|
2
|
+
// route handlers (plus their private error-mapping helpers) moved verbatim
|
|
3
|
+
// from route-table.ts (PR-D had moved them verbatim from http-server.ts
|
|
4
|
+
// before that) - bodies byte-identical, only the module home changed.
|
|
5
|
+
// route-table.ts keeps the table entries that bind these handlers. Like
|
|
6
|
+
// security.ts, this module imports route-table.js as TYPE ONLY
|
|
7
|
+
// (RouteContext), so the module graph stays acyclic.
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import { parseJsonBody, sendJson, sendError, pinnedCorsAllowOrigin } from "../protocol.js";
|
|
10
|
+
import { listWorkspaceTree, listWorkspaceSubtree, readWorkspaceFile, readWorkspaceRawFile } from "../workspace-browser.js";
|
|
11
|
+
import { teamClawWorkspaceIsDefault, updateTeamClawWorkspaceDir, getTeamClawModelCatalog, updateTeamClawModelConfig, resolveTeamClawWorkspaceDir, } from "../openclaw-workspace.js";
|
|
12
|
+
import { resolveSafeProjectDirectory } from "./task-cleanup.js";
|
|
13
|
+
function workspaceRequestErrorStatus(err) {
|
|
14
|
+
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
15
|
+
return 404;
|
|
16
|
+
}
|
|
17
|
+
return 400;
|
|
18
|
+
}
|
|
19
|
+
function workspaceRequestErrorMessage(err) {
|
|
20
|
+
return err instanceof Error ? err.message : "Workspace request failed";
|
|
21
|
+
}
|
|
22
|
+
function workspaceStatusRoute(ctx) {
|
|
23
|
+
const { res } = ctx;
|
|
24
|
+
sendJson(res, 200, {
|
|
25
|
+
workspaceDir: resolveTeamClawWorkspaceDir(),
|
|
26
|
+
isDefault: teamClawWorkspaceIsDefault(),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function workspaceChangeDirRoute(ctx) {
|
|
30
|
+
const { req, res, deps } = ctx;
|
|
31
|
+
let body;
|
|
32
|
+
try {
|
|
33
|
+
body = await parseJsonBody(req);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
sendError(res, 400, "invalid JSON body");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const workspaceDir = typeof body?.workspaceDir === "string"
|
|
40
|
+
? body.workspaceDir
|
|
41
|
+
: "";
|
|
42
|
+
if (!workspaceDir.trim()) {
|
|
43
|
+
sendError(res, 400, "workspaceDir is required");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const result = await updateTeamClawWorkspaceDir(workspaceDir, {
|
|
48
|
+
warn: (message) => deps.logger.info(message),
|
|
49
|
+
});
|
|
50
|
+
sendJson(res, 200, {
|
|
51
|
+
ok: true,
|
|
52
|
+
workspaceDir: result.agentEntryPath,
|
|
53
|
+
configPath: result.configPath,
|
|
54
|
+
restartRequired: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
sendError(res, 400, err instanceof Error ? err.message : "failed to update workspace directory");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// GET /api/v1/models/config - model catalog + current selection for the UI settings dialog
|
|
62
|
+
async function modelsConfigGetRoute(ctx) {
|
|
63
|
+
const { res } = ctx;
|
|
64
|
+
try {
|
|
65
|
+
sendJson(res, 200, await getTeamClawModelCatalog());
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
sendError(res, 500, err instanceof Error ? err.message : "failed to read model configuration");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// PUT /api/v1/models/config - persist default and per-role model selection
|
|
72
|
+
async function modelsConfigPutRoute(ctx) {
|
|
73
|
+
const { req, res, deps } = ctx;
|
|
74
|
+
let body = null;
|
|
75
|
+
try {
|
|
76
|
+
body = await parseJsonBody(req);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
sendError(res, 400, "invalid JSON body");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const update = {};
|
|
83
|
+
if (typeof body?.defaultModel === "string") {
|
|
84
|
+
update.defaultModel = body.defaultModel.trim();
|
|
85
|
+
}
|
|
86
|
+
if (body?.roleModelOverrides && typeof body.roleModelOverrides === "object" && !Array.isArray(body.roleModelOverrides)) {
|
|
87
|
+
const overrides = {};
|
|
88
|
+
for (const [role, value] of Object.entries(body.roleModelOverrides)) {
|
|
89
|
+
if (typeof value === "string" && value.trim()) {
|
|
90
|
+
overrides[role] = value.trim();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
update.roleModelOverrides = overrides;
|
|
94
|
+
}
|
|
95
|
+
if (update.defaultModel === undefined && update.roleModelOverrides === undefined) {
|
|
96
|
+
sendError(res, 400, "defaultModel or roleModelOverrides is required");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
await updateTeamClawModelConfig(update, {
|
|
101
|
+
warn: (message) => deps.logger.info(message),
|
|
102
|
+
});
|
|
103
|
+
sendJson(res, 200, {
|
|
104
|
+
ok: true,
|
|
105
|
+
restartNote: "Config changes hot-reload; restart the gateway (openclaw gateway restart) if a change does not take effect.",
|
|
106
|
+
catalog: await getTeamClawModelCatalog(),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
sendError(res, 400, err instanceof Error ? err.message : "failed to update model configuration");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function workspaceTreeRoute(ctx) {
|
|
114
|
+
const { res, requestUrl } = ctx;
|
|
115
|
+
try {
|
|
116
|
+
// depth=N limits tree expansion (default 1 for lazy loading)
|
|
117
|
+
const depthParam = requestUrl.searchParams.get("depth");
|
|
118
|
+
const maxDepth = depthParam !== null ? Math.max(0, Math.min(parseInt(depthParam, 10) || 1, 8)) : 1;
|
|
119
|
+
sendJson(res, 200, await listWorkspaceTree(maxDepth));
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function workspaceSubtreeRoute(ctx) {
|
|
126
|
+
const { res, requestUrl } = ctx;
|
|
127
|
+
const dirPath = requestUrl.searchParams.get("path") ?? "";
|
|
128
|
+
if (!dirPath) {
|
|
129
|
+
sendError(res, 400, "path is required");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
sendJson(res, 200, { entries: await listWorkspaceSubtree(dirPath) });
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function workspaceFileRoute(ctx) {
|
|
140
|
+
const { res, requestUrl } = ctx;
|
|
141
|
+
const relativePath = requestUrl.searchParams.get("path") ?? "";
|
|
142
|
+
if (!relativePath) {
|
|
143
|
+
sendError(res, 400, "path is required");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
sendJson(res, 200, { file: await readWorkspaceFile(relativePath) });
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function workspaceProjectPathRoute(ctx) {
|
|
154
|
+
const { res, requestUrl } = ctx;
|
|
155
|
+
const projectDir = requestUrl.searchParams.get("projectDir") ?? "";
|
|
156
|
+
if (!projectDir) {
|
|
157
|
+
sendError(res, 400, "projectDir is required");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const absolutePath = resolveSafeProjectDirectory(projectDir);
|
|
161
|
+
if (!absolutePath) {
|
|
162
|
+
sendError(res, 400, "Invalid projectDir");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!fs.existsSync(absolutePath)) {
|
|
166
|
+
sendError(res, 404, "Project directory not found");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
sendJson(res, 200, {
|
|
170
|
+
projectDir,
|
|
171
|
+
absolutePath,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async function workspaceRawFileRoute(ctx) {
|
|
175
|
+
const { res, pathname } = ctx;
|
|
176
|
+
const rawPathname = pathname.slice("/api/v1/workspace/raw/".length);
|
|
177
|
+
if (!rawPathname) {
|
|
178
|
+
sendError(res, 400, "path is required");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
const relativePath = decodeURIComponent(rawPathname);
|
|
183
|
+
const file = await readWorkspaceRawFile(relativePath);
|
|
184
|
+
res.writeHead(200, {
|
|
185
|
+
"Content-Type": file.contentType,
|
|
186
|
+
"Cache-Control": "no-store",
|
|
187
|
+
// Issue #23 security review follow-up: honor a CORS origin the
|
|
188
|
+
// security gate pinned (device protection on) instead of hardcoding
|
|
189
|
+
// the wildcard, which silently widened it; unpinned keeps the
|
|
190
|
+
// historical "*" byte for byte (shared helper, see protocol.ts).
|
|
191
|
+
"Access-Control-Allow-Origin": pinnedCorsAllowOrigin(res),
|
|
192
|
+
"X-Content-Type-Options": "nosniff",
|
|
193
|
+
});
|
|
194
|
+
res.end(file.content);
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
export { workspaceStatusRoute, workspaceChangeDirRoute, modelsConfigGetRoute, modelsConfigPutRoute, workspaceTreeRoute, workspaceSubtreeRoute, workspaceFileRoute, workspaceProjectPathRoute, workspaceRawFileRoute, };
|
|
@@ -3,6 +3,10 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { resolveTeamClawWorkspaceDir } from "./openclaw-workspace.js";
|
|
6
|
+
// W6 of issue #226: the local swallowing pathExists copy was removed; the
|
|
7
|
+
// alias keeps every call site byte-identical while the shared copy pins the
|
|
8
|
+
// exact original semantics (any fs.access error resolves false).
|
|
9
|
+
import { pathExistsTolerant as pathExists } from "./shared/utils.js";
|
|
6
10
|
const TEAMCLAW_IMPORT_REF_PREFIX = "refs/teamclaw/imports";
|
|
7
11
|
const BUNDLE_IMPORT_MAX_RETRIES = 3;
|
|
8
12
|
const BUNDLE_IMPORT_RETRY_DELAY_MS = 2_000;
|
|
@@ -613,15 +617,6 @@ async function tryRebaseWorkerOntoController(workspaceDir, repoInfo, controllerU
|
|
|
613
617
|
logger.warn(`Worker: rebase onto controller failed: ${err instanceof Error ? err.message : String(err)}; will retry bundle as-is.`);
|
|
614
618
|
}
|
|
615
619
|
}
|
|
616
|
-
async function pathExists(filePath) {
|
|
617
|
-
try {
|
|
618
|
-
await fs.access(filePath);
|
|
619
|
-
return true;
|
|
620
|
-
}
|
|
621
|
-
catch {
|
|
622
|
-
return false;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
620
|
async function runGit(args, options) {
|
|
626
621
|
const result = await runCommand("git", args, options);
|
|
627
622
|
if (result.exitCode !== 0) {
|
package/dist/src/identity.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import { generateId, createRegistrationRequest } from "./protocol.js";
|
|
3
|
-
|
|
3
|
+
// Phase 1.3: the worker role label/icon come from the active TeamProfile.
|
|
4
|
+
import { getActiveRole } from "./profile-loader.js";
|
|
4
5
|
import { loadWorkerIdentity, saveWorkerIdentity, clearWorkerIdentity } from "./state.js";
|
|
5
6
|
import { MDnsBrowser } from "./discovery.js";
|
|
7
|
+
/**
|
|
8
|
+
* Issue #23 (client wave): headers for worker -> controller calls. While a
|
|
9
|
+
* paired device token is configured it rides the X-TeamClaw-Token header the
|
|
10
|
+
* controller's device gate accepts; without one the headers pass through
|
|
11
|
+
* unchanged (L0). The token value itself is never logged.
|
|
12
|
+
*/
|
|
13
|
+
function withDeviceToken(config, headers) {
|
|
14
|
+
const token = config.securityToken?.trim();
|
|
15
|
+
return token ? { ...headers, "X-TeamClaw-Token": token } : headers;
|
|
16
|
+
}
|
|
6
17
|
function getLocalIp(targetHost) {
|
|
7
18
|
if (!targetHost || targetHost === "localhost" || targetHost === "127.0.0.1") {
|
|
8
19
|
return "localhost";
|
|
@@ -72,7 +83,7 @@ export class IdentityManager {
|
|
|
72
83
|
this.logger.warn("Identity: no controller found via mDNS or manual URL");
|
|
73
84
|
return null;
|
|
74
85
|
}
|
|
75
|
-
const roleDef =
|
|
86
|
+
const roleDef = getActiveRole(this.config.role);
|
|
76
87
|
const workerId = requestedWorkerId ?? generateId();
|
|
77
88
|
const controllerHost = new URL(controllerUrl).hostname;
|
|
78
89
|
// Prefer explicit override (set by provisioner for Docker/K8s workers),
|
|
@@ -89,7 +100,7 @@ export class IdentityManager {
|
|
|
89
100
|
try {
|
|
90
101
|
const res = await fetch(`${controllerUrl}/api/v1/workers/register`, {
|
|
91
102
|
method: "POST",
|
|
92
|
-
headers: { "Content-Type": "application/json" },
|
|
103
|
+
headers: withDeviceToken(this.config, { "Content-Type": "application/json" }),
|
|
93
104
|
body: JSON.stringify(registration),
|
|
94
105
|
});
|
|
95
106
|
if (!res.ok) {
|
|
@@ -118,6 +129,7 @@ export class IdentityManager {
|
|
|
118
129
|
try {
|
|
119
130
|
await fetch(`${this.identity.controllerUrl}/api/v1/workers/${this.identity.workerId}`, {
|
|
120
131
|
method: "DELETE",
|
|
132
|
+
headers: withDeviceToken(this.config, {}),
|
|
121
133
|
});
|
|
122
134
|
}
|
|
123
135
|
catch {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Phase 1.3: runtime role legitimacy is checked against the active
|
|
2
|
+
// TeamProfile (software-rd baseline); roles.ts keeps the registry-layer guard.
|
|
3
|
+
import { validateActiveRoleId } from "./profile-loader.js";
|
|
2
4
|
const CONTRACT_VERSION = "1.0";
|
|
3
|
-
const ROLE_IDS = new Set(ROLES.map((role) => role.id));
|
|
4
5
|
const RESULT_DELIVERABLE_KINDS = new Set([
|
|
5
6
|
"file",
|
|
6
7
|
"directory",
|
|
@@ -39,11 +40,10 @@ export function normalizeOptionalContractText(raw) {
|
|
|
39
40
|
return normalized || undefined;
|
|
40
41
|
}
|
|
41
42
|
export function normalizeContractRole(raw) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return normalized && ROLE_IDS.has(normalized) ? normalized : undefined;
|
|
43
|
+
// Phase 0.3 introduced single-source role validation; Phase 1.3 moved the
|
|
44
|
+
// runtime check to the active TeamProfile (validateActiveRoleId). This
|
|
45
|
+
// exported name keeps the contract-level API stable.
|
|
46
|
+
return validateActiveRoleId(raw);
|
|
47
47
|
}
|
|
48
48
|
export function summarizeContractText(text, maxChars = 180) {
|
|
49
49
|
const normalized = text.replace(/\s+/g, " ").trim();
|
|
@@ -7,6 +7,9 @@ import fs from "node:fs/promises";
|
|
|
7
7
|
import os from "node:os";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import JSON5 from "json5";
|
|
10
|
+
// Dependency-free canonical role id list (Phase 1.2); see role-ids.ts for why
|
|
11
|
+
// this module cannot value-import roles.ts.
|
|
12
|
+
import { ROLE_IDS } from "./role-ids.js";
|
|
10
13
|
export const TEAMCLAW_AGENT_ID = "teamclaw";
|
|
11
14
|
export const TEAMCLAW_ISOLATION_MODE_INDEPENDENT = "independent";
|
|
12
15
|
export const TEAMCLAW_ISOLATION_MODE_MAIN = "main";
|
|
@@ -219,19 +222,26 @@ export function resolveTeamClawAgentDir(env = process.env, homedir = os.homedir)
|
|
|
219
222
|
}
|
|
220
223
|
/**
|
|
221
224
|
* OpenClaw 2026.10+ moved model-provider auth out of the legacy per-agent
|
|
222
|
-
* `auth-profiles.json` file and into the host config
|
|
223
|
-
* with apiKey/auth
|
|
224
|
-
*
|
|
225
|
-
*
|
|
225
|
+
* `auth-profiles.json` file and into the host config. Two host shapes exist:
|
|
226
|
+
* 2026.10 wrote `models.providers[*]` with apiKey/auth (optionally backed by
|
|
227
|
+
* the secrets store); 2026.11 onboard writes `auth.profiles[*]` entries
|
|
228
|
+
* (`provider` + `mode`, the secret itself in the secrets store) and models
|
|
229
|
+
* reference profiles via the `<model>@<profile>` suffix. Treat either shape
|
|
230
|
+
* as ready so the readiness gate does not false-negative on current hosts.
|
|
226
231
|
*/
|
|
227
232
|
function hostConfiguredProviderAuthExists(env = process.env, homedir = os.homedir) {
|
|
228
233
|
try {
|
|
229
234
|
const configPath = resolveDefaultOpenClawConfigPath(env, homedir);
|
|
230
235
|
const parsed = JSON.parse(readFileSync(configPath, "utf8"));
|
|
231
236
|
const providers = parsed.models?.providers ?? parsed.providers ?? {};
|
|
232
|
-
|
|
237
|
+
const inlineProviderAuth = Object.values(providers).some((value) => Boolean(value) &&
|
|
233
238
|
typeof value === "object" &&
|
|
234
239
|
("apiKey" in value || "auth" in value));
|
|
240
|
+
if (inlineProviderAuth) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
const authProfiles = Object.values(parsed.auth?.profiles ?? {});
|
|
244
|
+
return authProfiles.some((value) => Boolean(value) && typeof value === "object");
|
|
235
245
|
}
|
|
236
246
|
catch {
|
|
237
247
|
return false;
|
|
@@ -401,19 +411,31 @@ export async function updateTeamClawWorkspaceDir(workspaceDir, logger, env = pro
|
|
|
401
411
|
logger?.warn?.(`TeamClaw: workspace updated to ${normalized} (restart the gateway to apply)`);
|
|
402
412
|
return { configPath, agentEntryPath: normalized };
|
|
403
413
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
// Phase 1.2: the catalog's id set and order derive from the canonical
|
|
415
|
+
// role-ids.ts list (openclaw-workspace.ts sits below roles.ts in the module
|
|
416
|
+
// graph, so it cannot value-import the registry itself). The labels are the
|
|
417
|
+
// compact names the model-settings dialog has always shown; they
|
|
418
|
+
// intentionally differ from the full registry labels in roles.ts (e.g.
|
|
419
|
+
// "Project Manager" vs "Product Manager"), so they stay explicit here.
|
|
420
|
+
// tests/test-role-single-source.mjs pins the derived output to the exact
|
|
421
|
+
// pre-Phase-1.2 value.
|
|
422
|
+
const TEAMCLAW_ROLE_CATALOG_LABELS = {
|
|
423
|
+
pm: "Project Manager",
|
|
424
|
+
architect: "Architect",
|
|
425
|
+
developer: "Developer",
|
|
426
|
+
qa: "QA Engineer",
|
|
427
|
+
"release-engineer": "Release Engineer",
|
|
428
|
+
"infra-engineer": "Infra Engineer",
|
|
429
|
+
devops: "DevOps Engineer",
|
|
430
|
+
"security-engineer": "Security Engineer",
|
|
431
|
+
designer: "Designer",
|
|
432
|
+
marketing: "Marketing",
|
|
433
|
+
"data-engineer": "Data Engineer",
|
|
434
|
+
};
|
|
435
|
+
export const TEAMCLAW_ROLE_CATALOG = ROLE_IDS.map((id) => ({
|
|
436
|
+
id,
|
|
437
|
+
label: TEAMCLAW_ROLE_CATALOG_LABELS[id] ?? id,
|
|
438
|
+
}));
|
|
417
439
|
/**
|
|
418
440
|
* Model catalog for the UI settings dialog: provider/model ids from the host
|
|
419
441
|
* config (names only - never secrets), plus the current teamclaw default and
|