@teamclaws/teamclaw 2026.11.6 → 2026.11.7
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/README.md +17 -11
- package/dist/src/config.js +3 -3
- package/dist/src/controller/http-server.js +2 -2
- package/dist/src/controller/managed-gateway-process.js +17 -1
- package/dist/src/controller/provisioning/process-supervisor.js +11 -0
- package/dist/src/controller/route-table.js +2 -2
- package/dist/src/controller/security.js +30 -15
- package/dist/src/controller/task-assignment.js +62 -1
- package/dist/src/controller/task-routes.js +39 -2
- package/dist/src/controller/tunnel-manager.js +11 -0
- package/dist/src/controller/tunnel-routes.js +11 -0
- package/dist/src/controller/workspace-routes.js +16 -2
- package/dist/src/teamauto/github-client.js +19 -0
- package/dist/src/teamauto/repo-sync.js +96 -22
- package/dist/src/teamauto/scheduler.js +458 -36
- package/dist/src/teamauto/store.js +125 -3
- package/dist/src/types.js +5 -3
- package/dist/src/ui/app.js +2 -2
- package/dist/src/worker/worker-service.js +13 -1
- package/dist/src/workspace-browser.js +14 -0
- package/openclaw.plugin.json +5 -5
- package/package.json +4 -2
- package/src/config.ts +3 -3
- package/src/controller/http-server.ts +2 -2
- package/src/controller/managed-gateway-process.ts +17 -1
- package/src/controller/provisioning/process-supervisor.ts +11 -0
- package/src/controller/route-table.ts +2 -2
- package/src/controller/security.ts +30 -15
- package/src/controller/task-assignment.ts +58 -1
- package/src/controller/task-routes.ts +39 -1
- package/src/controller/tunnel-manager.ts +12 -1
- package/src/controller/tunnel-routes.ts +11 -0
- package/src/controller/workspace-routes.ts +17 -2
- package/src/teamauto/github-client.ts +21 -1
- package/src/teamauto/repo-sync.ts +85 -21
- package/src/teamauto/scheduler.ts +434 -33
- package/src/teamauto/store.ts +133 -3
- package/src/types.ts +9 -7
- package/src/ui/app.js +2 -2
- package/src/worker/worker-service.ts +15 -1
- package/src/workspace-browser.ts +15 -0
|
@@ -47,6 +47,8 @@ function emptyStore() {
|
|
|
47
47
|
failedClaimRecovery: {},
|
|
48
48
|
orphanResultAlarms: {},
|
|
49
49
|
deliveredResults: {},
|
|
50
|
+
prDeliveries: {},
|
|
51
|
+
undeliveredPrAlarms: {},
|
|
50
52
|
fullReviewUmbrellas: {},
|
|
51
53
|
budget: {
|
|
52
54
|
maxTasksPerDay: 150,
|
|
@@ -86,8 +88,10 @@ export function resolveTeamAutoPaths() {
|
|
|
86
88
|
const writeQueue = [];
|
|
87
89
|
export async function loadTeamAutoStore() {
|
|
88
90
|
const { storeFile } = resolveTeamAutoPaths();
|
|
91
|
+
let baseFingerprint = "";
|
|
89
92
|
try {
|
|
90
93
|
const raw = await fs.readFile(storeFile, "utf8");
|
|
94
|
+
baseFingerprint = staleWriteFingerprint(raw);
|
|
91
95
|
const parsed = JSON.parse(raw);
|
|
92
96
|
const store = emptyStore();
|
|
93
97
|
if (Array.isArray(parsed.repos)) {
|
|
@@ -130,13 +134,107 @@ export async function loadTeamAutoStore() {
|
|
|
130
134
|
if (typeof parsed.deliveredResultsInit === "boolean") {
|
|
131
135
|
store.deliveredResultsInit = parsed.deliveredResultsInit;
|
|
132
136
|
}
|
|
137
|
+
// #5785: same loader-copy discipline as the #5736 chain above - a field
|
|
138
|
+
// missing from this list is dropped on EVERY 20s settle reload even
|
|
139
|
+
// though saveTeamAutoStore writes it to disk (dropped prDeliveries =>
|
|
140
|
+
// healthy pruned tasks re-probe GitHub; dropped undeliveredPrAlarms =>
|
|
141
|
+
// the once-per-task gate resets and one incident re-alarms every pass).
|
|
142
|
+
if (parsed.prDeliveries && typeof parsed.prDeliveries === "object") {
|
|
143
|
+
store.prDeliveries = parsed.prDeliveries;
|
|
144
|
+
}
|
|
145
|
+
if (parsed.undeliveredPrAlarms && typeof parsed.undeliveredPrAlarms === "object") {
|
|
146
|
+
store.undeliveredPrAlarms = parsed.undeliveredPrAlarms;
|
|
147
|
+
}
|
|
133
148
|
store.budget = { ...store.budget, ...(parsed.budget ?? {}) };
|
|
149
|
+
store.__baseFp = baseFingerprint;
|
|
134
150
|
return store;
|
|
135
151
|
}
|
|
136
152
|
catch {
|
|
137
153
|
return emptyStore();
|
|
138
154
|
}
|
|
139
155
|
}
|
|
156
|
+
/** #5810/#5730 short-path guard helpers (cross-process stale-write protection). */
|
|
157
|
+
function staleWriteFingerprint(raw) {
|
|
158
|
+
let h = 5381;
|
|
159
|
+
for (let i = 0; i < raw.length; i++)
|
|
160
|
+
h = ((h * 33) ^ raw.charCodeAt(i)) >>> 0;
|
|
161
|
+
return `${raw.length}:${h.toString(36)}`;
|
|
162
|
+
}
|
|
163
|
+
function mergeStoresOnConflict(disk, saver) {
|
|
164
|
+
const maxKey = (a, b) => {
|
|
165
|
+
const out = { ...(a ?? {}) };
|
|
166
|
+
for (const [k, v] of Object.entries(b ?? {}))
|
|
167
|
+
out[k] = Math.max(out[k] ?? 0, v);
|
|
168
|
+
return out;
|
|
169
|
+
};
|
|
170
|
+
const unionBy = (a, b, key, cap = 600) => {
|
|
171
|
+
const seen = new Set();
|
|
172
|
+
const out = [];
|
|
173
|
+
for (const x of [...(a ?? []), ...(b ?? [])]) {
|
|
174
|
+
const k = key(x);
|
|
175
|
+
if (seen.has(k))
|
|
176
|
+
continue;
|
|
177
|
+
seen.add(k);
|
|
178
|
+
out.push(x);
|
|
179
|
+
}
|
|
180
|
+
return out.slice(-cap);
|
|
181
|
+
};
|
|
182
|
+
const merged = { ...saver };
|
|
183
|
+
const dayOf = (s) => s?.dayStamp ?? "";
|
|
184
|
+
const diskToday = disk.budget?.tasksToday ?? 0;
|
|
185
|
+
const saverToday = saver.budget?.tasksToday ?? 0;
|
|
186
|
+
merged.budget = {
|
|
187
|
+
...(disk.budget ?? saver.budget),
|
|
188
|
+
dayStamp: dayOf(disk.budget) !== dayOf(saver.budget) && diskToday > saverToday ? dayOf(disk.budget) : (dayOf(saver.budget) || dayOf(disk.budget)),
|
|
189
|
+
tasksToday: dayOf(disk.budget) === dayOf(saver.budget) ? Math.max(diskToday, saverToday) : saverToday,
|
|
190
|
+
maxTasksPerDay: disk.budget?.maxTasksPerDay ?? saver.budget?.maxTasksPerDay ?? 150,
|
|
191
|
+
};
|
|
192
|
+
merged.deliveredResults = maxKey(disk.deliveredResults, saver.deliveredResults);
|
|
193
|
+
merged.orphanResultAlarms = maxKey(disk.orphanResultAlarms, saver.orphanResultAlarms);
|
|
194
|
+
merged.undeliveredPrAlarms = maxKey(disk.undeliveredPrAlarms, saver.undeliveredPrAlarms);
|
|
195
|
+
// #5785: PR-face records are durable facts - either side's stamp is
|
|
196
|
+
// evidence of delivery, so union with disk winning key collisions.
|
|
197
|
+
merged.prDeliveries = { ...(saver.prDeliveries ?? {}), ...(disk.prDeliveries ?? {}) };
|
|
198
|
+
merged.failedClaimRecovery = maxKey(disk.failedClaimRecovery, saver.failedClaimRecovery);
|
|
199
|
+
merged.fullReviewUmbrellas = maxKey(disk.fullReviewUmbrellas, saver.fullReviewUmbrellas);
|
|
200
|
+
merged.activity = unionBy(disk.activity, saver.activity, (x) => `${x.at}:${String(x.text).slice(0, 60)}`);
|
|
201
|
+
merged.writebacks = unionBy(disk.writebacks, saver.writebacks, (w) => w.taskId, 600).map((w) => {
|
|
202
|
+
const d = (disk.writebacks ?? []).find((x) => x.taskId === w.taskId);
|
|
203
|
+
if (!d)
|
|
204
|
+
return w;
|
|
205
|
+
return { ...w, doneAt: w.doneAt ?? d.doneAt, failedAt: w.failedAt ?? d.failedAt, attempts: Math.max(w.attempts ?? 0, d.attempts ?? 0), targetId: w.targetId ?? d.targetId };
|
|
206
|
+
});
|
|
207
|
+
const repoMap = new Map();
|
|
208
|
+
for (const r of [...(disk.repos ?? []), ...(saver.repos ?? [])]) {
|
|
209
|
+
const prev = repoMap.get(r.id);
|
|
210
|
+
if (!prev) {
|
|
211
|
+
repoMap.set(r.id, r);
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const diskSide = disk.repos?.includes(prev) ? prev : r;
|
|
215
|
+
const otherSide = diskSide === prev ? r : prev;
|
|
216
|
+
repoMap.set(r.id, {
|
|
217
|
+
...diskSide,
|
|
218
|
+
lastSweepAt: Math.max(prev.lastSweepAt ?? 0, r.lastSweepAt ?? 0),
|
|
219
|
+
lastAttemptAt: Math.max(prev.lastAttemptAt ?? 0, r.lastAttemptAt ?? 0),
|
|
220
|
+
lastSweepErrorAt: Math.max(prev.lastSweepErrorAt ?? 0, r.lastSweepErrorAt ?? 0),
|
|
221
|
+
sweepFailures: Math.max(prev.sweepFailures ?? 0, r.sweepFailures ?? 0),
|
|
222
|
+
failedTasksSinceLastSweep: Math.max(prev.failedTasksSinceLastSweep ?? 0, r.failedTasksSinceLastSweep ?? 0),
|
|
223
|
+
lastSweepSummary: (prev.lastSweepAt ?? 0) >= (r.lastSweepAt ?? 0) ? prev.lastSweepSummary : r.lastSweepSummary,
|
|
224
|
+
sweeps: unionBy(prev.sweeps, r.sweeps, (x) => `${x.at}:${String(x.summary).slice(0, 40)}`, 40),
|
|
225
|
+
cursors: {
|
|
226
|
+
...diskSide.cursors,
|
|
227
|
+
seen: maxKey(prev.cursors?.seen, otherSide.cursors?.seen),
|
|
228
|
+
etags: { ...(otherSide.cursors?.etags ?? {}), ...(diskSide.cursors?.etags ?? {}) },
|
|
229
|
+
lastIssueSince: Math.max(prev.cursors?.lastIssueSince ?? 0, r.cursors?.lastIssueSince ?? 0),
|
|
230
|
+
lastPrSince: Math.max(prev.cursors?.lastPrSince ?? 0, r.cursors?.lastPrSince ?? 0),
|
|
231
|
+
lastCommitSha: prev.cursors?.lastCommitSha ?? r.cursors?.lastCommitSha,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
merged.repos = [...repoMap.values()];
|
|
236
|
+
return merged;
|
|
237
|
+
}
|
|
140
238
|
/** #5677 (ggcode, 2026-11-15): store-level async mutex. The 20s write-back
|
|
141
239
|
* reconcile re-reads the store from disk and saves the whole object; the
|
|
142
240
|
* sweep transaction (registerWriteback + summary) does the same. Without
|
|
@@ -161,11 +259,35 @@ export async function withStoreLock(section) {
|
|
|
161
259
|
export async function saveTeamAutoStore(store) {
|
|
162
260
|
const { storeFile } = resolveTeamAutoPaths();
|
|
163
261
|
await fs.mkdir(path.dirname(storeFile), { recursive: true });
|
|
164
|
-
const tmp = `${storeFile}.tmp-${process.pid}-${Date.now()}`;
|
|
165
262
|
const next = writeQueue.length ? writeQueue[writeQueue.length - 1].catch(() => { }) : Promise.resolve();
|
|
166
263
|
const job = next.then(async () => {
|
|
167
|
-
|
|
168
|
-
|
|
264
|
+
let toWrite = store;
|
|
265
|
+
const guardDir = `${storeFile}.guard-lock`;
|
|
266
|
+
let tookLock = false;
|
|
267
|
+
try {
|
|
268
|
+
await fs.mkdir(guardDir, { recursive: true }).then(() => { tookLock = true; }, () => { });
|
|
269
|
+
if (tookLock) {
|
|
270
|
+
const diskRaw = await fs.readFile(storeFile, "utf8").catch(() => null);
|
|
271
|
+
const baseFp = store.__baseFp;
|
|
272
|
+
if (diskRaw !== null && baseFp && staleWriteFingerprint(diskRaw) !== baseFp) {
|
|
273
|
+
const diskParsed = JSON.parse(diskRaw);
|
|
274
|
+
const diskStore = { ...emptyStore(), ...diskParsed };
|
|
275
|
+
toWrite = mergeStoresOnConflict(diskStore, store);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch { /* guard degraded - plain write */ }
|
|
280
|
+
try {
|
|
281
|
+
const tmp = `${storeFile}.tmp-${process.pid}-${Date.now()}`;
|
|
282
|
+
const raw = JSON.stringify(toWrite, (k, v) => (k === "__baseFp" ? undefined : v), 2) + "\n";
|
|
283
|
+
await fs.writeFile(tmp, raw, { encoding: "utf8", mode: 0o600 });
|
|
284
|
+
await fs.rename(tmp, storeFile);
|
|
285
|
+
store.__baseFp = staleWriteFingerprint(raw);
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
if (tookLock)
|
|
289
|
+
await fs.rm(guardDir, { recursive: true, force: true }).catch(() => { });
|
|
290
|
+
}
|
|
169
291
|
});
|
|
170
292
|
writeQueue.push(job);
|
|
171
293
|
writeQueue.splice(0, Math.max(0, writeQueue.length - 20));
|
package/dist/src/types.js
CHANGED
|
@@ -105,14 +105,16 @@ export function parsePluginConfig(raw = {}) {
|
|
|
105
105
|
const agentIsolationMode = typeof raw.agentIsolationMode === "string" && (raw.agentIsolationMode === "independent" || raw.agentIsolationMode === "main")
|
|
106
106
|
? raw.agentIsolationMode
|
|
107
107
|
: "independent";
|
|
108
|
-
// Issue #23: security.autoPair
|
|
109
|
-
// pairing)
|
|
108
|
+
// Issue #23: security.autoPair defaulted to true (L1 zero-input LAN
|
|
109
|
+
// pairing). ClawHub security review 2026.11.6 (finding 2) flipped the
|
|
110
|
+
// default to false: a LAN peer must now present a pairing code unless
|
|
111
|
+
// the owner opts into zero-input pairing explicitly.
|
|
110
112
|
const rawSecurity = raw.security;
|
|
111
113
|
const rawAutoPair = rawSecurity && typeof rawSecurity === "object" && !Array.isArray(rawSecurity)
|
|
112
114
|
? rawSecurity.autoPair
|
|
113
115
|
: undefined;
|
|
114
116
|
const security = {
|
|
115
|
-
autoPair: typeof rawAutoPair === "boolean" ? rawAutoPair :
|
|
117
|
+
autoPair: typeof rawAutoPair === "boolean" ? rawAutoPair : false,
|
|
116
118
|
};
|
|
117
119
|
// Issue #23 (client wave): the paired device token, if this instance
|
|
118
120
|
// paired with a protected controller. Empty/absent keeps L0 behavior.
|
package/dist/src/ui/app.js
CHANGED
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
"tunnel.selfHostedLabel": "Self-hosted tunnel (your own Cloudflare account/domain):",
|
|
330
330
|
"tunnel.tokenPlaceholder": "Cloudflare connector token",
|
|
331
331
|
"tunnel.setupHelp": "How to get a token & set up the tunnel",
|
|
332
|
-
"tunnel.setupHelpBody": "Cloudflare Zero Trust → Networks → Tunnels → your tunnel → copy token. Point its public hostname at this machine’s URL (Service: HTTP + the controller port shown in the docs).
|
|
332
|
+
"tunnel.setupHelpBody": "Cloudflare Zero Trust → Networks → Tunnels → your tunnel → copy token. Point its public hostname at this machine’s URL (Service: HTTP + the controller port shown in the docs). Self-hosted domains skip the TeamClaw gate, so device pairing must be enabled before the tunnel can start, and Cloudflare Access is still recommended.",
|
|
333
333
|
"tunnel.or": "— or —",
|
|
334
334
|
"tunnel.requiresGithub": "requires GitHub login",
|
|
335
335
|
"tunnel.startQuick": "Anonymous one-off tunnel (trycloudflare.com)",
|
|
@@ -627,7 +627,7 @@
|
|
|
627
627
|
"tunnel.selfHostedLabel": "自托管隧道(你自己的 Cloudflare 账号/域名):",
|
|
628
628
|
"tunnel.tokenPlaceholder": "Cloudflare 连接器令牌",
|
|
629
629
|
"tunnel.setupHelp": "如何获取令牌并配置隧道",
|
|
630
|
-
"tunnel.setupHelpBody": "Cloudflare Zero Trust → 网络(Networks)→ Tunnels → 你的隧道 → 复制令牌。将其公共域名指向本机 URL(Service:HTTP +
|
|
630
|
+
"tunnel.setupHelpBody": "Cloudflare Zero Trust → 网络(Networks)→ Tunnels → 你的隧道 → 复制令牌。将其公共域名指向本机 URL(Service:HTTP + 文档中所示的控制器端口)。自托管域名不走 TeamClaw 门禁,因此必须先启用设备配对才能启动隧道;仍建议用 Cloudflare Access 保护。",
|
|
631
631
|
"tunnel.or": "— 或 —",
|
|
632
632
|
"tunnel.requiresGithub": "需要 GitHub 登录",
|
|
633
633
|
"tunnel.startQuick": "匿名一次性隧道(trycloudflare.com)",
|
|
@@ -3,7 +3,7 @@ import http from "node:http";
|
|
|
3
3
|
import { createHeartbeatPayload } from "../protocol.js";
|
|
4
4
|
import { IdentityManager } from "../identity.js";
|
|
5
5
|
import { MessageQueue } from "./message-queue.js";
|
|
6
|
-
import { createWorkerHttpHandler } from "./http-handler.js";
|
|
6
|
+
import { createWorkerHttpHandler, resolveWorkerInboundTokens } from "./http-handler.js";
|
|
7
7
|
import { buildTeamClawAgentSessionKey, ensureOpenClawWorkspaceMemoryDir } from "../openclaw-workspace.js";
|
|
8
8
|
/**
|
|
9
9
|
* Issue #27: container detection mirrors the controller's resolve step in
|
|
@@ -204,6 +204,18 @@ export function createWorkerService(deps) {
|
|
|
204
204
|
}
|
|
205
205
|
server = http.createServer(handler);
|
|
206
206
|
const listenHost = resolveWorkerListenHost(config);
|
|
207
|
+
// ClawHub security review 2026.11.6 (finding 1): the HTTP handler's auth
|
|
208
|
+
// gate is conditional ("while this worker holds an expected token"), so a
|
|
209
|
+
// worker bound to a non-loopback address with NO token would expose task
|
|
210
|
+
// assignment / cancel / install to everyone who can reach the port. Fail
|
|
211
|
+
// closed: refuse to listen unless loopback OR a token is present. Loopback
|
|
212
|
+
// stays the zero-config L0 path (provisioned workers always carry
|
|
213
|
+
// TEAMCLAW_LAUNCH_TOKEN, so containers on 0.0.0.0 are unaffected).
|
|
214
|
+
if (!isLoopbackHost(listenHost) && resolveWorkerInboundTokens(config).length === 0) {
|
|
215
|
+
server = null;
|
|
216
|
+
throw new Error(`Worker: refusing to listen on ${listenHost}:${config.port} without an inbound token - the task/message/install API would be unauthenticated on the network. ` +
|
|
217
|
+
`Keep the loopback default, or set the securityToken plugin config (or launch via the controller, which injects TEAMCLAW_LAUNCH_TOKEN).`);
|
|
218
|
+
}
|
|
207
219
|
await new Promise((resolve, reject) => {
|
|
208
220
|
server.listen(config.port, listenHost, () => {
|
|
209
221
|
logger.info(`Worker: HTTP server listening on ${listenHost}:${config.port}`);
|
|
@@ -134,6 +134,20 @@ async function resolveWorkspacePath(relativePath) {
|
|
|
134
134
|
if (!relativeFromWorkspace || relativeFromWorkspace.startsWith("..") || path.isAbsolute(relativeFromWorkspace)) {
|
|
135
135
|
throw new Error("workspace path must stay inside the workspace");
|
|
136
136
|
}
|
|
137
|
+
// ClawHub security review 2026.11.6 (finding 5): the lexical check above
|
|
138
|
+
// does not follow symlinks, but every fs.* call below does - a link
|
|
139
|
+
// inside the workspace pointing at ~/.ssh would pass containment and be
|
|
140
|
+
// read straight through /api/v1/workspace/raw/. Resolve BOTH sides for
|
|
141
|
+
// real and re-check containment on the resolved paths. A dangling link
|
|
142
|
+
// surfaces ENOENT here (mapped to 404 by the routes, same as before).
|
|
143
|
+
// Residual: the realpath->open window is a check-to-use race; the
|
|
144
|
+
// controller trusts its own workspace tree against concurrent local
|
|
145
|
+
// tampering (an attacker who can plant links there already has the host).
|
|
146
|
+
const [realWorkspaceDir, realTarget] = await Promise.all([fs.realpath(workspaceDir), fs.realpath(absolutePath)]);
|
|
147
|
+
const relativeReal = path.relative(realWorkspaceDir, realTarget).replace(/\\/g, "/");
|
|
148
|
+
if (!relativeReal || relativeReal.startsWith("..") || path.isAbsolute(relativeReal)) {
|
|
149
|
+
throw new Error("workspace path must stay inside the workspace");
|
|
150
|
+
}
|
|
137
151
|
return {
|
|
138
152
|
workspaceDir,
|
|
139
153
|
normalizedPath: relativeFromWorkspace,
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "teamclaw",
|
|
3
3
|
"name": "TeamClaw",
|
|
4
4
|
"description": "Virtual team collaboration - multiple OpenClaw instances form a virtual software company with role-based task routing.",
|
|
5
|
-
"version": "2026.11.
|
|
5
|
+
"version": "2026.11.7",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true
|
|
8
8
|
},
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"maxConcurrentTasks": {
|
|
76
76
|
"label": "Max Concurrent Tasks",
|
|
77
77
|
"hint": "number",
|
|
78
|
-
"help": "Maximum number of tasks that can be in 'in_progress' status at the same time (1
|
|
78
|
+
"help": "Maximum number of tasks that can be in 'in_progress' status at the same time (1\u201350)"
|
|
79
79
|
},
|
|
80
80
|
"gitEnabled": {
|
|
81
81
|
"label": "Git Collaboration",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
},
|
|
109
109
|
"security": {
|
|
110
110
|
"label": "Device Pairing Security",
|
|
111
|
-
"help": "Controller device-pairing options; autoPair allows LAN devices to pair with zero input (POST /api/v1/security/pair-auto)
|
|
111
|
+
"help": "Controller device-pairing options; autoPair (off by default) allows LAN devices to pair with zero input (POST /api/v1/security/pair-auto) - enable only on a trusted private network"
|
|
112
112
|
},
|
|
113
113
|
"agentIsolationMode": {
|
|
114
114
|
"label": "Agent Isolation Mode",
|
|
@@ -313,8 +313,8 @@
|
|
|
313
313
|
"properties": {
|
|
314
314
|
"autoPair": {
|
|
315
315
|
"type": "boolean",
|
|
316
|
-
"default":
|
|
317
|
-
"description": "Allow zero-input pairing from LAN peers (POST /api/v1/security/pair-auto);
|
|
316
|
+
"default": false,
|
|
317
|
+
"description": "Allow zero-input pairing from LAN peers (POST /api/v1/security/pair-auto); off by default so every new device needs a pairing code - enable only on a trusted private network"
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamclaws/teamclaw",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.7",
|
|
4
4
|
"description": "OpenClaw virtual software team orchestration plugin - controller, role-based workers, Web UI with internet tunnel sharing",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -79,9 +79,11 @@
|
|
|
79
79
|
},
|
|
80
80
|
"compat": {
|
|
81
81
|
"pluginApi": ">=2026.3.24",
|
|
82
|
-
"builtWithOpenClawVersion": "2026.3.24",
|
|
83
82
|
"minGatewayVersion": ">=2026.3.24"
|
|
84
83
|
},
|
|
84
|
+
"build": {
|
|
85
|
+
"openclawVersion": "2026.11.6"
|
|
86
|
+
},
|
|
85
87
|
"release": {
|
|
86
88
|
"publishToNpm": true
|
|
87
89
|
}
|
package/src/config.ts
CHANGED
|
@@ -112,8 +112,8 @@ function buildConfigSchema() {
|
|
|
112
112
|
properties: {
|
|
113
113
|
autoPair: {
|
|
114
114
|
type: "boolean" as const,
|
|
115
|
-
default:
|
|
116
|
-
description: "Allow zero-input pairing from LAN peers (POST /api/v1/security/pair-auto);
|
|
115
|
+
default: false,
|
|
116
|
+
description: "Allow zero-input pairing from LAN peers (POST /api/v1/security/pair-auto); off by default so every new device needs a pairing code - enable only on a trusted private network",
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
119
|
},
|
|
@@ -331,7 +331,7 @@ function buildConfigSchema() {
|
|
|
331
331
|
},
|
|
332
332
|
security: {
|
|
333
333
|
label: "Device Pairing Security",
|
|
334
|
-
help: "Controller device-pairing options; autoPair allows LAN devices to pair with zero input (POST /api/v1/security/pair-auto)
|
|
334
|
+
help: "Controller device-pairing options; autoPair (off by default) allows LAN devices to pair with zero input (POST /api/v1/security/pair-auto) - enable only on a trusted private network",
|
|
335
335
|
},
|
|
336
336
|
agentIsolationMode: {
|
|
337
337
|
label: "Agent Isolation Mode",
|
|
@@ -231,7 +231,7 @@ export function createControllerHttpServer(deps: ControllerHttpDeps): http.Serve
|
|
|
231
231
|
// structure below is unchanged from the pre-PR-D if/else chain.
|
|
232
232
|
let tunnelManager = tunnelManagerSingleton;
|
|
233
233
|
if (!tunnelManager) {
|
|
234
|
-
tunnelManager = tunnelManagerSingleton = createTunnelManager({ logger, localPort: deps.config.port });
|
|
234
|
+
tunnelManager = tunnelManagerSingleton = createTunnelManager({ logger, localPort: deps.config.port, isProtectionOn: () => isProtectionOn(deps.getTeamState()) });
|
|
235
235
|
}
|
|
236
236
|
if (!tunnelRoutesSingleton) {
|
|
237
237
|
tunnelRoutesSingleton = {
|
|
@@ -299,7 +299,7 @@ export function createControllerHttpServer(deps: ControllerHttpDeps): http.Serve
|
|
|
299
299
|
// Boot reconciliation: reconnect a share persisted by a previous run
|
|
300
300
|
// (gateway restart or kill -9) so the tunnel id and gate token survive.
|
|
301
301
|
if (!tunnelManagerSingleton) {
|
|
302
|
-
tunnelManagerSingleton = createTunnelManager({ logger, localPort: deps.config.port });
|
|
302
|
+
tunnelManagerSingleton = createTunnelManager({ logger, localPort: deps.config.port, isProtectionOn: () => isProtectionOn(deps.getTeamState()) });
|
|
303
303
|
}
|
|
304
304
|
void tunnelManagerSingleton.recover().catch((err) => {
|
|
305
305
|
logger.warn(`TeamClaw tunnel: boot recovery failed: ${String(err)}`);
|
|
@@ -34,6 +34,18 @@ export function spawnManagedGatewayProcess(options: ManagedGatewaySpawnOptions):
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function spawnManagedCommandProcess(options: ManagedCommandSpawnOptions): ChildProcess {
|
|
37
|
+
// #terminal-activation guard: previewCommand is worker-influenced input
|
|
38
|
+
// (#237 W1) executed through the core sh -c wrapper. A prompt-injected
|
|
39
|
+
// `open`/osascript command hijacks LaunchServices and activates
|
|
40
|
+
// Terminal.app from the headless launchd context (reported live: default
|
|
41
|
+
// Terminal windows intermittently activating). Reject loudly - never
|
|
42
|
+
// silently - so the attempt is visible in logs.
|
|
43
|
+
const cmd = options.command.trim();
|
|
44
|
+
if (/^(open|osascript)\b/i.test(cmd) || /(^|[\s;&|])osascript\b/i.test(cmd) || /(^|\s)-a\s+Terminal\b/.test(cmd)) {
|
|
45
|
+
const reason = `blocked Terminal-activation command (preview contract violation): ${cmd.slice(0, 120)}`;
|
|
46
|
+
console.error(`[teamclaw] ${reason}`);
|
|
47
|
+
throw new Error(`[teamclaw] ${reason}`);
|
|
48
|
+
}
|
|
37
49
|
const cwd = options.cwd ?? process.cwd();
|
|
38
50
|
const child = spawn(process.execPath, buildManagedCommandWrapperArgs(options.command), {
|
|
39
51
|
...buildManagedProcessSpawnOptions({
|
|
@@ -251,9 +263,13 @@ const shutdownSignals = process.platform === "win32"
|
|
|
251
263
|
? ["SIGTERM", "SIGINT", "SIGBREAK"]
|
|
252
264
|
: ["SIGTERM", "SIGINT", "SIGHUP", "SIGQUIT"];
|
|
253
265
|
const shell = process.platform === "win32" ? "cmd.exe" : "sh";
|
|
266
|
+
// -c, NOT -lc: a LOGIN shell sources the user's profiles in a headless
|
|
267
|
+
// launchd context. Profile init scripts are interactive-session side-effect
|
|
268
|
+
// machines (open/LaunchServices hooks, TTY-needing helpers) and are the
|
|
269
|
+
// plausible amplifier behind intermittent Terminal.app activations.
|
|
254
270
|
const shellArgs = process.platform === "win32"
|
|
255
271
|
? ["/d", "/s", "/c", command]
|
|
256
|
-
: ["-
|
|
272
|
+
: ["-c", command];
|
|
257
273
|
|
|
258
274
|
let shuttingDown = false;
|
|
259
275
|
let parentMonitor = null;
|
|
@@ -145,6 +145,17 @@ export class ProcessProvisioner implements WorkerProvisionerBackend {
|
|
|
145
145
|
OPENCLAW_STATE_DIR: stateDir,
|
|
146
146
|
OPENCLAW_CONFIG_PATH: configPath,
|
|
147
147
|
OPENCLAW_SKIP_CANVAS_HOST: "1",
|
|
148
|
+
// #disk-hygiene (screenshot report 2026-11-19): worker go builds can
|
|
149
|
+
// accumulate gigabytes of go-build/go-link dirs in the HOME tmp when
|
|
150
|
+
// deployments want them on a scratch volume. Opt-in ONLY - hardcoded
|
|
151
|
+
// paths would break any deployment without that volume. When the
|
|
152
|
+
// operator sets TEAMCLAW_GOCACHE / TEAMCLAW_GOTMPDIR, they are
|
|
153
|
+
// forwarded as GOCACHE / GOTMPDIR (an externally-set GOCACHE already
|
|
154
|
+
// flows through ...process.env untouched and is never overridden);
|
|
155
|
+
// unset -> Go defaults apply exactly as before. Kept ABOVE the
|
|
156
|
+
// workspaceDir spread so the contract test's env-tail shape holds.
|
|
157
|
+
...(process.env.TEAMCLAW_GOCACHE && !process.env.GOCACHE ? { GOCACHE: process.env.TEAMCLAW_GOCACHE } : {}),
|
|
158
|
+
...(process.env.TEAMCLAW_GOTMPDIR && !process.env.GOTMPDIR ? { GOTMPDIR: process.env.TEAMCLAW_GOTMPDIR } : {}),
|
|
148
159
|
TEAMCLAW_WORKER_ID: spec.workerId,
|
|
149
160
|
TEAMCLAW_LAUNCH_TOKEN: spec.launchToken,
|
|
150
161
|
...(spec.workspaceDir ? { TEAMCLAW_WORKSPACE_DIR: spec.workspaceDir } : {}),
|
|
@@ -575,8 +575,8 @@ export const controllerRouteTable: readonly RouteDef[] = [
|
|
|
575
575
|
// pair/start- authenticated device or loopback (mints a fresh code,
|
|
576
576
|
// invalidating the previous one)
|
|
577
577
|
// pair - one-shot 60s code exchange -> {token, deviceId}
|
|
578
|
-
// pair-auto - LAN peer + config.security.autoPair + protection on
|
|
579
|
-
// reset -
|
|
578
|
+
// pair-auto - LAN peer + config.security.autoPair (opt-in) + protection on
|
|
579
|
+
// reset - loopback only (anti-lockout hatch; controller host action)
|
|
580
580
|
// GET /security and DELETE /security/devices/:id are NOT exempt: the
|
|
581
581
|
// middleware itself guarantees the caller holds a valid device token.
|
|
582
582
|
{ method: "POST", path: "/api/v1/security/enable", handler: handleSecurityEnableRequest },
|
|
@@ -524,6 +524,20 @@ export function createWebSocketUpgradeGuard(deps: WebSocketUpgradeGuardDeps): (r
|
|
|
524
524
|
const viaTunnel = deps.isTunnelHost(typeof req.headers.host === "string" ? req.headers.host : undefined);
|
|
525
525
|
const peer = classifySecurityPeer(req.socket.remoteAddress, viaTunnel);
|
|
526
526
|
const state = deps.getTeamState();
|
|
527
|
+
// ClawHub security review 2026.11.6 (finding 3): the tunnel gate must
|
|
528
|
+
// run BEFORE the protection-off allowance. The HTTP path enforces
|
|
529
|
+
// gateAllows for every tunnel request regardless of device protection
|
|
530
|
+
// (http-server.ts), so a protection-off controller still gates its HTTP
|
|
531
|
+
// surface - but this guard used to return true first, which left /ws as
|
|
532
|
+
// the one tunnel surface a gate-cookie-less visitor could subscribe to
|
|
533
|
+
// (task/message/clarification event stream). Same layering as HTTP now.
|
|
534
|
+
if (peer.viaTunnel) {
|
|
535
|
+
if (!deps.gateAllows || !deps.gateAllows(req)) {
|
|
536
|
+
deps.logger.warn(`Controller: rejected WebSocket upgrade from ${peer.ip} (via tunnel, no gate cookie)`);
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
return true;
|
|
540
|
+
}
|
|
527
541
|
if (!isProtectionOn(state)) {
|
|
528
542
|
recordNonLanPeerSignal(deps, state, peer, "/ws");
|
|
529
543
|
return true;
|
|
@@ -536,13 +550,8 @@ export function createWebSocketUpgradeGuard(deps: WebSocketUpgradeGuardDeps): (r
|
|
|
536
550
|
if (peer.loopback) {
|
|
537
551
|
return true;
|
|
538
552
|
}
|
|
539
|
-
// Tunnel-origin upgrades (
|
|
540
|
-
//
|
|
541
|
-
// as the HTTP gate (a device token here would be an unanswerable
|
|
542
|
-
// wall, 8b03ed6). Verify the gate cookie instead.
|
|
543
|
-
if (peer.viaTunnel && deps.gateAllows && deps.gateAllows(req)) {
|
|
544
|
-
return true;
|
|
545
|
-
}
|
|
553
|
+
// Tunnel-origin upgrades were handled above (gate cookie, never a pairing
|
|
554
|
+
// token - a device token here would be an unanswerable wall, 8b03ed6).
|
|
546
555
|
let token = extractDeviceToken(req);
|
|
547
556
|
if (!token) {
|
|
548
557
|
const url = new URL(req.url ?? "/ws", `http://${req.headers.host ?? "localhost"}`);
|
|
@@ -792,10 +801,10 @@ export async function handleSecurityPairAutoRequest(ctx: RouteContext): Promise<
|
|
|
792
801
|
});
|
|
793
802
|
return;
|
|
794
803
|
}
|
|
795
|
-
if ((deps.config.security?.autoPair ??
|
|
804
|
+
if ((deps.config.security?.autoPair ?? false) !== true) {
|
|
796
805
|
sendJson(res, 403, {
|
|
797
806
|
error: "auto-pairing is disabled on this controller",
|
|
798
|
-
hint: "
|
|
807
|
+
hint: "Zero-input LAN pairing is off by default (ClawHub security review); ask for a pairing code and POST /api/v1/security/pair {\"code\",\"kind\",\"name\"}.",
|
|
799
808
|
});
|
|
800
809
|
return;
|
|
801
810
|
}
|
|
@@ -828,7 +837,7 @@ export async function handleSecurityGetRequest(ctx: RouteContext): Promise<void>
|
|
|
828
837
|
protection: isProtectionOn(state),
|
|
829
838
|
devices: (security?.devices ?? []).map(serializeDevice),
|
|
830
839
|
...(active ? { pairingCode: { expiresAt: active.expiresAt, purpose: active.purpose } } : {}),
|
|
831
|
-
autoPair: deps.config.security?.autoPair ??
|
|
840
|
+
autoPair: deps.config.security?.autoPair ?? false,
|
|
832
841
|
});
|
|
833
842
|
}
|
|
834
843
|
|
|
@@ -857,15 +866,21 @@ export async function handleSecurityDeviceDeleteRequest(ctx: RouteContext): Prom
|
|
|
857
866
|
sendJson(res, 200, { ok: true, revoked: deviceId, revokedSelf, protection });
|
|
858
867
|
}
|
|
859
868
|
|
|
860
|
-
// POST /api/v1/security/reset -
|
|
861
|
-
//
|
|
862
|
-
//
|
|
869
|
+
// POST /api/v1/security/reset - LOOPBACK ONLY (anti-lockout hatch), plus
|
|
870
|
+
// an explicit confirm token (#255 P1-8). ClawHub security review 2026.11.6
|
|
871
|
+
// (finding 2): a paired device token used to be enough to drop protection
|
|
872
|
+
// for EVERYONE - any LAN device that self-paired via auto-pair could reset
|
|
873
|
+
// the controller to L0. Reset is now a controller-host action only; remote
|
|
874
|
+
// owners revoke devices individually or re-enable from the host.
|
|
863
875
|
export async function handleSecurityResetRequest(ctx: RouteContext): Promise<void> {
|
|
864
876
|
const { req, res, deps, peer } = ctx;
|
|
865
877
|
const state = deps.getTeamState();
|
|
866
878
|
const auth = authenticateDeviceToken(state, extractDeviceToken(req));
|
|
867
|
-
if (!
|
|
868
|
-
|
|
879
|
+
if (!(peer?.loopback ?? false)) {
|
|
880
|
+
sendJson(res, 403, {
|
|
881
|
+
error: "forbidden",
|
|
882
|
+
hint: "Security reset is a controller-host action (loopback only); remote devices cannot drop protection for everyone. Revoke devices individually or run the reset from the controller host.",
|
|
883
|
+
});
|
|
869
884
|
return;
|
|
870
885
|
}
|
|
871
886
|
const body = await parseJsonBody(req);
|
|
@@ -656,7 +656,37 @@ export async function runAutoAssignRound(
|
|
|
656
656
|
// bypassing the gate). Write-phase claim failures still continue
|
|
657
657
|
// unclaimed per the original 2026-11-15 semantics.
|
|
658
658
|
deps.getTeamAutoScheduler?.()?.claimTaskAtDequeue(updatedTask).then((claim) => {
|
|
659
|
-
if (claim?.
|
|
659
|
+
if (claim?.reason === "issue closed") {
|
|
660
|
+
// #5818: the claim check VERDICTED against the task - the issue was
|
|
661
|
+
// closed between enqueue and dequeue. That is terminal (no retry
|
|
662
|
+
// helps); running the leg anyway burned a full 8-minute worker on
|
|
663
|
+
// a closed issue (live: 952e7471). Cancel the dispatched execution
|
|
664
|
+
// and terminalize the task as cancelled - NOT back to pending (a
|
|
665
|
+
// pending task would redispatch; the sweep will not re-candidate a
|
|
666
|
+
// closed issue, but the queue entry would keep firing).
|
|
667
|
+
logger.warn(`Controller: issue closed before dispatch for ${updatedTask.id} - cancelling task`);
|
|
668
|
+
void (async () => {
|
|
669
|
+
await cancelTaskExecution(updatedTask.id, nextAssignment.worker.id, "target issue closed (#5818)", deps);
|
|
670
|
+
deps.updateTeamState((s) => {
|
|
671
|
+
const t = s.tasks[updatedTask.id];
|
|
672
|
+
if (!t) return;
|
|
673
|
+
t.status = "failed";
|
|
674
|
+
t.error = "Cancelled: target issue was closed before dispatch (#5818) - no work performed.";
|
|
675
|
+
t.updatedAt = Date.now();
|
|
676
|
+
// #5825: cancelTaskExecution never resets the worker record,
|
|
677
|
+
// and cancelling also suppresses the worker-side completion
|
|
678
|
+
// report - so nothing ever flipped the seat idle. Release here
|
|
679
|
+
// (same shape as the normal completion path) or the worker
|
|
680
|
+
// stays orphan-busy forever (live: 2 busy, 1 in_progress).
|
|
681
|
+
const w = s.workers[nextAssignment.worker.id];
|
|
682
|
+
if (w && w.currentTaskId === updatedTask.id) {
|
|
683
|
+
w.status = "idle";
|
|
684
|
+
w.currentTaskId = undefined;
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
wsServer.broadcastUpdate({ type: "task:updated", data: serializeTask(deps.getTeamState()?.tasks[updatedTask.id] ?? updatedTask) });
|
|
688
|
+
})().catch(() => {});
|
|
689
|
+
} else if (claim?.retryEligibility) {
|
|
660
690
|
logger.warn(`Controller: claim eligibility check failed for ${updatedTask.id} - reverting assignment to retry`);
|
|
661
691
|
// Unlike the #191 dispatch-failure path, the dispatch SUCCEEDED
|
|
662
692
|
// here: cancel the already-dispatched execution before reverting
|
|
@@ -670,6 +700,33 @@ export async function runAutoAssignRound(
|
|
|
670
700
|
holdMs: claimEligibilityHoldMs(failures),
|
|
671
701
|
});
|
|
672
702
|
})().catch(() => {});
|
|
703
|
+
} else if (claim?.reason === "external activity" || claim?.reason === "assignees present") {
|
|
704
|
+
// #5823: stand-down verdicts are TERMINAL like issue-closed (the
|
|
705
|
+
// seat/owner is not going away; retrying cannot help) - the old
|
|
706
|
+
// else-branch only cleared the hold and the leg ran to completion
|
|
707
|
+
// on an issue another seat owns (live: the #5819 self-fix leg
|
|
708
|
+
// stood down at 21:24 yet kept executing at 21:38). Same treatment
|
|
709
|
+
// as #5818: cancel the dispatched execution, terminalize with the
|
|
710
|
+
// stand-down reason, no dead-letter count.
|
|
711
|
+
logger.warn(`Controller: claim stood down (${claim.reason}) for ${updatedTask.id} - cancelling task`);
|
|
712
|
+
void (async () => {
|
|
713
|
+
await cancelTaskExecution(updatedTask.id, nextAssignment.worker.id, `claim stand-down: ${claim.reason} (#5823)`, deps);
|
|
714
|
+
deps.updateTeamState((s) => {
|
|
715
|
+
const t = s.tasks[updatedTask.id];
|
|
716
|
+
if (!t) return;
|
|
717
|
+
t.status = "failed";
|
|
718
|
+
t.error = `Cancelled: claim stood down (${claim.reason}) - another seat/owner owns the issue (#5823). No work performed.`;
|
|
719
|
+
t.updatedAt = Date.now();
|
|
720
|
+
// #5825: same orphan-busy release as the #5818 branch above.
|
|
721
|
+
const w = s.workers[nextAssignment.worker.id];
|
|
722
|
+
if (w && w.currentTaskId === updatedTask.id) {
|
|
723
|
+
w.status = "idle";
|
|
724
|
+
w.currentTaskId = undefined;
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
clearAssignmentHold(updatedTask.id, deps);
|
|
728
|
+
wsServer.broadcastUpdate({ type: "task:updated", data: serializeTask(deps.getTeamState()?.tasks[updatedTask.id] ?? updatedTask) });
|
|
729
|
+
})().catch(() => {});
|
|
673
730
|
} else {
|
|
674
731
|
// Claim attempt concluded definitively (claimed / stood down /
|
|
675
732
|
// WRITE failure continuing unclaimed): end the retry cycle.
|