@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,222 @@
|
|
|
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 {
|
|
12
|
+
teamClawWorkspaceIsDefault,
|
|
13
|
+
updateTeamClawWorkspaceDir,
|
|
14
|
+
getTeamClawModelCatalog,
|
|
15
|
+
updateTeamClawModelConfig,
|
|
16
|
+
resolveTeamClawWorkspaceDir,
|
|
17
|
+
} from "../openclaw-workspace.js";
|
|
18
|
+
import { resolveSafeProjectDirectory } from "./task-cleanup.js";
|
|
19
|
+
import type { RouteContext } from "./route-table.js";
|
|
20
|
+
|
|
21
|
+
function workspaceRequestErrorStatus(err: unknown): number {
|
|
22
|
+
if (err && typeof err === "object" && "code" in err && (err as { code?: unknown }).code === "ENOENT") {
|
|
23
|
+
return 404;
|
|
24
|
+
}
|
|
25
|
+
return 400;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function workspaceRequestErrorMessage(err: unknown): string {
|
|
29
|
+
return err instanceof Error ? err.message : "Workspace request failed";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function workspaceStatusRoute(ctx: RouteContext): void {
|
|
33
|
+
const { res } = ctx;
|
|
34
|
+
sendJson(res, 200, {
|
|
35
|
+
workspaceDir: resolveTeamClawWorkspaceDir(),
|
|
36
|
+
isDefault: teamClawWorkspaceIsDefault(),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function workspaceChangeDirRoute(ctx: RouteContext): Promise<void> {
|
|
41
|
+
const { req, res, deps } = ctx;
|
|
42
|
+
let body: unknown;
|
|
43
|
+
try {
|
|
44
|
+
body = await parseJsonBody(req);
|
|
45
|
+
} catch {
|
|
46
|
+
sendError(res, 400, "invalid JSON body");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const workspaceDir = typeof (body as { workspaceDir?: unknown })?.workspaceDir === "string"
|
|
50
|
+
? (body as { workspaceDir: string }).workspaceDir
|
|
51
|
+
: "";
|
|
52
|
+
if (!workspaceDir.trim()) {
|
|
53
|
+
sendError(res, 400, "workspaceDir is required");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const result = await updateTeamClawWorkspaceDir(workspaceDir, {
|
|
58
|
+
warn: (message: string) => deps.logger.info(message),
|
|
59
|
+
});
|
|
60
|
+
sendJson(res, 200, {
|
|
61
|
+
ok: true,
|
|
62
|
+
workspaceDir: result.agentEntryPath,
|
|
63
|
+
configPath: result.configPath,
|
|
64
|
+
restartRequired: true,
|
|
65
|
+
});
|
|
66
|
+
} catch (err) {
|
|
67
|
+
sendError(res, 400, err instanceof Error ? err.message : "failed to update workspace directory");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// GET /api/v1/models/config - model catalog + current selection for the UI settings dialog
|
|
72
|
+
async function modelsConfigGetRoute(ctx: RouteContext): Promise<void> {
|
|
73
|
+
const { res } = ctx;
|
|
74
|
+
try {
|
|
75
|
+
sendJson(res, 200, await getTeamClawModelCatalog());
|
|
76
|
+
} catch (err) {
|
|
77
|
+
sendError(res, 500, err instanceof Error ? err.message : "failed to read model configuration");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// PUT /api/v1/models/config - persist default and per-role model selection
|
|
82
|
+
async function modelsConfigPutRoute(ctx: RouteContext): Promise<void> {
|
|
83
|
+
const { req, res, deps } = ctx;
|
|
84
|
+
let body: { defaultModel?: unknown; roleModelOverrides?: unknown } | null = null;
|
|
85
|
+
try {
|
|
86
|
+
body = await parseJsonBody(req) as { defaultModel?: unknown; roleModelOverrides?: unknown };
|
|
87
|
+
} catch {
|
|
88
|
+
sendError(res, 400, "invalid JSON body");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const update: { defaultModel?: string; roleModelOverrides?: Record<string, string> } = {};
|
|
92
|
+
if (typeof body?.defaultModel === "string") {
|
|
93
|
+
update.defaultModel = body.defaultModel.trim();
|
|
94
|
+
}
|
|
95
|
+
if (body?.roleModelOverrides && typeof body.roleModelOverrides === "object" && !Array.isArray(body.roleModelOverrides)) {
|
|
96
|
+
const overrides: Record<string, string> = {};
|
|
97
|
+
for (const [role, value] of Object.entries(body.roleModelOverrides as Record<string, unknown>)) {
|
|
98
|
+
if (typeof value === "string" && value.trim()) {
|
|
99
|
+
overrides[role] = value.trim();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
update.roleModelOverrides = overrides;
|
|
103
|
+
}
|
|
104
|
+
if (update.defaultModel === undefined && update.roleModelOverrides === undefined) {
|
|
105
|
+
sendError(res, 400, "defaultModel or roleModelOverrides is required");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await updateTeamClawModelConfig(update, {
|
|
110
|
+
warn: (message: string) => deps.logger.info(message),
|
|
111
|
+
});
|
|
112
|
+
sendJson(res, 200, {
|
|
113
|
+
ok: true,
|
|
114
|
+
restartNote: "Config changes hot-reload; restart the gateway (openclaw gateway restart) if a change does not take effect.",
|
|
115
|
+
catalog: await getTeamClawModelCatalog(),
|
|
116
|
+
});
|
|
117
|
+
} catch (err) {
|
|
118
|
+
sendError(res, 400, err instanceof Error ? err.message : "failed to update model configuration");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function workspaceTreeRoute(ctx: RouteContext): Promise<void> {
|
|
123
|
+
const { res, requestUrl } = ctx;
|
|
124
|
+
try {
|
|
125
|
+
// depth=N limits tree expansion (default 1 for lazy loading)
|
|
126
|
+
const depthParam = requestUrl.searchParams.get("depth");
|
|
127
|
+
const maxDepth = depthParam !== null ? Math.max(0, Math.min(parseInt(depthParam, 10) || 1, 8)) : 1;
|
|
128
|
+
sendJson(res, 200, await listWorkspaceTree(maxDepth));
|
|
129
|
+
} catch (err) {
|
|
130
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function workspaceSubtreeRoute(ctx: RouteContext): Promise<void> {
|
|
135
|
+
const { res, requestUrl } = ctx;
|
|
136
|
+
const dirPath = requestUrl.searchParams.get("path") ?? "";
|
|
137
|
+
if (!dirPath) {
|
|
138
|
+
sendError(res, 400, "path is required");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
sendJson(res, 200, { entries: await listWorkspaceSubtree(dirPath) });
|
|
143
|
+
} catch (err) {
|
|
144
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function workspaceFileRoute(ctx: RouteContext): Promise<void> {
|
|
149
|
+
const { res, requestUrl } = ctx;
|
|
150
|
+
const relativePath = requestUrl.searchParams.get("path") ?? "";
|
|
151
|
+
if (!relativePath) {
|
|
152
|
+
sendError(res, 400, "path is required");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
sendJson(res, 200, { file: await readWorkspaceFile(relativePath) });
|
|
158
|
+
} catch (err) {
|
|
159
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function workspaceProjectPathRoute(ctx: RouteContext): Promise<void> {
|
|
164
|
+
const { res, requestUrl } = ctx;
|
|
165
|
+
const projectDir = requestUrl.searchParams.get("projectDir") ?? "";
|
|
166
|
+
if (!projectDir) {
|
|
167
|
+
sendError(res, 400, "projectDir is required");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const absolutePath = resolveSafeProjectDirectory(projectDir);
|
|
171
|
+
if (!absolutePath) {
|
|
172
|
+
sendError(res, 400, "Invalid projectDir");
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!fs.existsSync(absolutePath)) {
|
|
176
|
+
sendError(res, 404, "Project directory not found");
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
sendJson(res, 200, {
|
|
180
|
+
projectDir,
|
|
181
|
+
absolutePath,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function workspaceRawFileRoute(ctx: RouteContext): Promise<void> {
|
|
186
|
+
const { res, pathname } = ctx;
|
|
187
|
+
const rawPathname = pathname.slice("/api/v1/workspace/raw/".length);
|
|
188
|
+
if (!rawPathname) {
|
|
189
|
+
sendError(res, 400, "path is required");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
const relativePath = decodeURIComponent(rawPathname);
|
|
195
|
+
const file = await readWorkspaceRawFile(relativePath);
|
|
196
|
+
res.writeHead(200, {
|
|
197
|
+
"Content-Type": file.contentType,
|
|
198
|
+
"Cache-Control": "no-store",
|
|
199
|
+
// Issue #23 security review follow-up: honor a CORS origin the
|
|
200
|
+
// security gate pinned (device protection on) instead of hardcoding
|
|
201
|
+
// the wildcard, which silently widened it; unpinned keeps the
|
|
202
|
+
// historical "*" byte for byte (shared helper, see protocol.ts).
|
|
203
|
+
"Access-Control-Allow-Origin": pinnedCorsAllowOrigin(res),
|
|
204
|
+
"X-Content-Type-Options": "nosniff",
|
|
205
|
+
});
|
|
206
|
+
res.end(file.content);
|
|
207
|
+
} catch (err) {
|
|
208
|
+
sendError(res, workspaceRequestErrorStatus(err), workspaceRequestErrorMessage(err));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export {
|
|
213
|
+
workspaceStatusRoute,
|
|
214
|
+
workspaceChangeDirRoute,
|
|
215
|
+
modelsConfigGetRoute,
|
|
216
|
+
modelsConfigPutRoute,
|
|
217
|
+
workspaceTreeRoute,
|
|
218
|
+
workspaceSubtreeRoute,
|
|
219
|
+
workspaceFileRoute,
|
|
220
|
+
workspaceProjectPathRoute,
|
|
221
|
+
workspaceRawFileRoute,
|
|
222
|
+
};
|
package/src/git-collaboration.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { spawn } from "node:child_process";
|
|
|
5
5
|
import type { PluginLogger } from "../api.js";
|
|
6
6
|
import type { GitRepoState, PluginConfig, RepoSyncInfo } from "./types.js";
|
|
7
7
|
import { resolveTeamClawWorkspaceDir } from "./openclaw-workspace.js";
|
|
8
|
+
// W6 of issue #226: the local swallowing pathExists copy was removed; the
|
|
9
|
+
// alias keeps every call site byte-identical while the shared copy pins the
|
|
10
|
+
// exact original semantics (any fs.access error resolves false).
|
|
11
|
+
import { pathExistsTolerant as pathExists } from "./shared/utils.js";
|
|
8
12
|
|
|
9
13
|
const TEAMCLAW_IMPORT_REF_PREFIX = "refs/teamclaw/imports";
|
|
10
14
|
const BUNDLE_IMPORT_MAX_RETRIES = 3;
|
|
@@ -783,15 +787,6 @@ async function tryRebaseWorkerOntoController(
|
|
|
783
787
|
}
|
|
784
788
|
}
|
|
785
789
|
|
|
786
|
-
async function pathExists(filePath: string): Promise<boolean> {
|
|
787
|
-
try {
|
|
788
|
-
await fs.access(filePath);
|
|
789
|
-
return true;
|
|
790
|
-
} catch {
|
|
791
|
-
return false;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
|
|
795
790
|
async function runGit(args: string[], options: { cwd: string }): Promise<CommandResult> {
|
|
796
791
|
const result = await runCommand("git", args, options);
|
|
797
792
|
if (result.exitCode !== 0) {
|
package/src/identity.ts
CHANGED
|
@@ -2,10 +2,22 @@ import os from "node:os";
|
|
|
2
2
|
import type { PluginLogger } from "../api.js";
|
|
3
3
|
import type { PluginConfig, WorkerIdentity } from "./types.js";
|
|
4
4
|
import { generateId, createRegistrationRequest } from "./protocol.js";
|
|
5
|
-
|
|
5
|
+
// Phase 1.3: the worker role label/icon come from the active TeamProfile.
|
|
6
|
+
import { getActiveRole } from "./profile-loader.js";
|
|
6
7
|
import { loadWorkerIdentity, saveWorkerIdentity, clearWorkerIdentity } from "./state.js";
|
|
7
8
|
import { MDnsBrowser } from "./discovery.js";
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Issue #23 (client wave): headers for worker -> controller calls. While a
|
|
12
|
+
* paired device token is configured it rides the X-TeamClaw-Token header the
|
|
13
|
+
* controller's device gate accepts; without one the headers pass through
|
|
14
|
+
* unchanged (L0). The token value itself is never logged.
|
|
15
|
+
*/
|
|
16
|
+
function withDeviceToken(config: PluginConfig, headers: Record<string, string>): Record<string, string> {
|
|
17
|
+
const token = config.securityToken?.trim();
|
|
18
|
+
return token ? { ...headers, "X-TeamClaw-Token": token } : headers;
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
function getLocalIp(targetHost?: string): string {
|
|
10
22
|
if (!targetHost || targetHost === "localhost" || targetHost === "127.0.0.1") {
|
|
11
23
|
return "localhost";
|
|
@@ -87,7 +99,7 @@ export class IdentityManager {
|
|
|
87
99
|
return null;
|
|
88
100
|
}
|
|
89
101
|
|
|
90
|
-
const roleDef =
|
|
102
|
+
const roleDef = getActiveRole(this.config.role);
|
|
91
103
|
const workerId = requestedWorkerId ?? generateId();
|
|
92
104
|
const controllerHost = new URL(controllerUrl).hostname;
|
|
93
105
|
// Prefer explicit override (set by provisioner for Docker/K8s workers),
|
|
@@ -114,7 +126,7 @@ export class IdentityManager {
|
|
|
114
126
|
try {
|
|
115
127
|
const res = await fetch(`${controllerUrl}/api/v1/workers/register`, {
|
|
116
128
|
method: "POST",
|
|
117
|
-
headers: { "Content-Type": "application/json" },
|
|
129
|
+
headers: withDeviceToken(this.config, { "Content-Type": "application/json" }),
|
|
118
130
|
body: JSON.stringify(registration),
|
|
119
131
|
});
|
|
120
132
|
|
|
@@ -146,6 +158,7 @@ export class IdentityManager {
|
|
|
146
158
|
try {
|
|
147
159
|
await fetch(`${this.identity.controllerUrl}/api/v1/workers/${this.identity.workerId}`, {
|
|
148
160
|
method: "DELETE",
|
|
161
|
+
headers: withDeviceToken(this.config, {}),
|
|
149
162
|
});
|
|
150
163
|
} catch {
|
|
151
164
|
// ignore
|
|
@@ -1,4 +1,6 @@
|
|
|
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
|
import type {
|
|
3
5
|
RoleId,
|
|
4
6
|
TaskHandoffContract,
|
|
@@ -14,7 +16,6 @@ import type {
|
|
|
14
16
|
} from "./types.js";
|
|
15
17
|
|
|
16
18
|
const CONTRACT_VERSION = "1.0";
|
|
17
|
-
const ROLE_IDS = new Set<RoleId>(ROLES.map((role) => role.id));
|
|
18
19
|
const RESULT_DELIVERABLE_KINDS = new Set<WorkerTaskResultDeliverable["kind"]>([
|
|
19
20
|
"file",
|
|
20
21
|
"directory",
|
|
@@ -56,11 +57,10 @@ export function normalizeOptionalContractText(raw: unknown): string | undefined
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
export function normalizeContractRole(raw: unknown): RoleId | undefined {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return normalized && ROLE_IDS.has(normalized) ? normalized : undefined;
|
|
60
|
+
// Phase 0.3 introduced single-source role validation; Phase 1.3 moved the
|
|
61
|
+
// runtime check to the active TeamProfile (validateActiveRoleId). This
|
|
62
|
+
// exported name keeps the contract-level API stable.
|
|
63
|
+
return validateActiveRoleId(raw);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export function summarizeContractText(text: string, maxChars = 180): string {
|
|
@@ -9,6 +9,9 @@ import os from "node:os";
|
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import JSON5 from "json5";
|
|
11
11
|
import type { PluginLogger } from "../api.js";
|
|
12
|
+
// Dependency-free canonical role id list (Phase 1.2); see role-ids.ts for why
|
|
13
|
+
// this module cannot value-import roles.ts.
|
|
14
|
+
import { ROLE_IDS } from "./role-ids.js";
|
|
12
15
|
|
|
13
16
|
export const TEAMCLAW_AGENT_ID = "teamclaw";
|
|
14
17
|
export const TEAMCLAW_ISOLATION_MODE_INDEPENDENT = "independent";
|
|
@@ -297,10 +300,12 @@ export type TeamClawModelReadiness = {
|
|
|
297
300
|
|
|
298
301
|
/**
|
|
299
302
|
* OpenClaw 2026.10+ moved model-provider auth out of the legacy per-agent
|
|
300
|
-
* `auth-profiles.json` file and into the host config
|
|
301
|
-
* with apiKey/auth
|
|
302
|
-
*
|
|
303
|
-
*
|
|
303
|
+
* `auth-profiles.json` file and into the host config. Two host shapes exist:
|
|
304
|
+
* 2026.10 wrote `models.providers[*]` with apiKey/auth (optionally backed by
|
|
305
|
+
* the secrets store); 2026.11 onboard writes `auth.profiles[*]` entries
|
|
306
|
+
* (`provider` + `mode`, the secret itself in the secrets store) and models
|
|
307
|
+
* reference profiles via the `<model>@<profile>` suffix. Treat either shape
|
|
308
|
+
* as ready so the readiness gate does not false-negative on current hosts.
|
|
304
309
|
*/
|
|
305
310
|
function hostConfiguredProviderAuthExists(
|
|
306
311
|
env: NodeJS.ProcessEnv = process.env,
|
|
@@ -311,14 +316,22 @@ function hostConfiguredProviderAuthExists(
|
|
|
311
316
|
const parsed = JSON.parse(readFileSync(configPath, "utf8")) as {
|
|
312
317
|
models?: { providers?: Record<string, unknown> };
|
|
313
318
|
providers?: Record<string, unknown>;
|
|
319
|
+
auth?: { profiles?: Record<string, unknown> };
|
|
314
320
|
};
|
|
315
321
|
const providers = parsed.models?.providers ?? parsed.providers ?? {};
|
|
316
|
-
|
|
322
|
+
const inlineProviderAuth = Object.values(providers).some(
|
|
317
323
|
(value) =>
|
|
318
324
|
Boolean(value) &&
|
|
319
325
|
typeof value === "object" &&
|
|
320
326
|
("apiKey" in (value as object) || "auth" in (value as object)),
|
|
321
327
|
);
|
|
328
|
+
if (inlineProviderAuth) {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
const authProfiles = Object.values(parsed.auth?.profiles ?? {});
|
|
332
|
+
return authProfiles.some(
|
|
333
|
+
(value) => Boolean(value) && typeof value === "object",
|
|
334
|
+
);
|
|
322
335
|
} catch {
|
|
323
336
|
return false;
|
|
324
337
|
}
|
|
@@ -521,19 +534,32 @@ export async function updateTeamClawWorkspaceDir(
|
|
|
521
534
|
return { configPath, agentEntryPath: normalized };
|
|
522
535
|
}
|
|
523
536
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
+
// Phase 1.2: the catalog's id set and order derive from the canonical
|
|
538
|
+
// role-ids.ts list (openclaw-workspace.ts sits below roles.ts in the module
|
|
539
|
+
// graph, so it cannot value-import the registry itself). The labels are the
|
|
540
|
+
// compact names the model-settings dialog has always shown; they
|
|
541
|
+
// intentionally differ from the full registry labels in roles.ts (e.g.
|
|
542
|
+
// "Project Manager" vs "Product Manager"), so they stay explicit here.
|
|
543
|
+
// tests/test-role-single-source.mjs pins the derived output to the exact
|
|
544
|
+
// pre-Phase-1.2 value.
|
|
545
|
+
const TEAMCLAW_ROLE_CATALOG_LABELS: Record<string, string> = {
|
|
546
|
+
pm: "Project Manager",
|
|
547
|
+
architect: "Architect",
|
|
548
|
+
developer: "Developer",
|
|
549
|
+
qa: "QA Engineer",
|
|
550
|
+
"release-engineer": "Release Engineer",
|
|
551
|
+
"infra-engineer": "Infra Engineer",
|
|
552
|
+
devops: "DevOps Engineer",
|
|
553
|
+
"security-engineer": "Security Engineer",
|
|
554
|
+
designer: "Designer",
|
|
555
|
+
marketing: "Marketing",
|
|
556
|
+
"data-engineer": "Data Engineer",
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
export const TEAMCLAW_ROLE_CATALOG: ReadonlyArray<{ id: string; label: string }> = ROLE_IDS.map((id) => ({
|
|
560
|
+
id,
|
|
561
|
+
label: TEAMCLAW_ROLE_CATALOG_LABELS[id] ?? id,
|
|
562
|
+
}));
|
|
537
563
|
|
|
538
564
|
export type TeamClawModelCatalog = {
|
|
539
565
|
defaultModel: string;
|