@teamclaws/teamclaw 2026.11.5 → 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/config-routes.js +7 -3
- package/dist/src/controller/controller-service.js +12 -1
- package/dist/src/controller/http-server.js +2 -2
- package/dist/src/controller/managed-gateway-process.js +17 -1
- package/dist/src/controller/provisioning/container-shared.js +6 -1
- package/dist/src/controller/provisioning/docker.js +1 -1
- package/dist/src/controller/provisioning/kubernetes.js +1 -1
- package/dist/src/controller/provisioning/process-supervisor.js +23 -1
- package/dist/src/controller/provisioning-config.js +8 -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 +126 -2
- package/dist/src/controller/task-results.js +34 -3
- package/dist/src/controller/task-routes.js +63 -3
- package/dist/src/controller/tunnel-manager.js +11 -0
- package/dist/src/controller/tunnel-routes.js +11 -0
- package/dist/src/controller/worker-provisioning.js +35 -0
- package/dist/src/controller/worker-routes.js +21 -6
- package/dist/src/controller/workspace-routes.js +16 -2
- package/dist/src/openclaw-workspace.js +39 -20
- package/dist/src/task-executor.js +44 -3
- package/dist/src/teamauto/github-client.js +107 -5
- package/dist/src/teamauto/repo-sync.js +172 -26
- package/dist/src/teamauto/scanner.js +22 -1
- package/dist/src/teamauto/scheduler.js +988 -190
- package/dist/src/teamauto/store.js +171 -3
- package/dist/src/teamauto/write-payload-guard.js +209 -0
- package/dist/src/types.js +11 -3
- package/dist/src/ui/app.js +2 -2
- package/dist/src/worker/tools.js +5 -0
- 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/config-routes.ts +7 -3
- package/src/controller/controller-service.ts +12 -1
- package/src/controller/http-server.ts +2 -2
- package/src/controller/managed-gateway-process.ts +17 -1
- package/src/controller/provisioning/backend-contract.ts +4 -0
- package/src/controller/provisioning/container-shared.ts +6 -1
- package/src/controller/provisioning/docker.ts +1 -1
- package/src/controller/provisioning/kubernetes.ts +1 -1
- package/src/controller/provisioning/process-supervisor.ts +23 -1
- package/src/controller/provisioning-config.ts +9 -0
- package/src/controller/route-table.ts +2 -2
- package/src/controller/security.ts +30 -15
- package/src/controller/task-assignment.ts +128 -1
- package/src/controller/task-results.ts +33 -3
- package/src/controller/task-routes.ts +64 -2
- package/src/controller/tunnel-manager.ts +12 -1
- package/src/controller/tunnel-routes.ts +11 -0
- package/src/controller/worker-provisioning.ts +35 -0
- package/src/controller/worker-routes.ts +21 -7
- package/src/controller/workspace-routes.ts +17 -2
- package/src/openclaw-workspace.ts +43 -23
- package/src/task-executor.ts +46 -3
- package/src/teamauto/github-client.ts +103 -5
- package/src/teamauto/repo-sync.ts +158 -23
- package/src/teamauto/scanner.ts +23 -2
- package/src/teamauto/scheduler.ts +883 -113
- package/src/teamauto/store.ts +205 -3
- package/src/teamauto/write-payload-guard.ts +222 -0
- package/src/types.ts +30 -7
- package/src/ui/app.js +2 -2
- package/src/worker/tools.ts +5 -0
- package/src/worker/worker-service.ts +15 -1
- package/src/workspace-browser.ts +15 -0
|
@@ -45,6 +45,11 @@ function emptyStore() {
|
|
|
45
45
|
writebacks: [],
|
|
46
46
|
activity: [],
|
|
47
47
|
failedClaimRecovery: {},
|
|
48
|
+
orphanResultAlarms: {},
|
|
49
|
+
deliveredResults: {},
|
|
50
|
+
prDeliveries: {},
|
|
51
|
+
undeliveredPrAlarms: {},
|
|
52
|
+
fullReviewUmbrellas: {},
|
|
48
53
|
budget: {
|
|
49
54
|
maxTasksPerDay: 150,
|
|
50
55
|
firstSweepDryRun: true,
|
|
@@ -83,8 +88,10 @@ export function resolveTeamAutoPaths() {
|
|
|
83
88
|
const writeQueue = [];
|
|
84
89
|
export async function loadTeamAutoStore() {
|
|
85
90
|
const { storeFile } = resolveTeamAutoPaths();
|
|
91
|
+
let baseFingerprint = "";
|
|
86
92
|
try {
|
|
87
93
|
const raw = await fs.readFile(storeFile, "utf8");
|
|
94
|
+
baseFingerprint = staleWriteFingerprint(raw);
|
|
88
95
|
const parsed = JSON.parse(raw);
|
|
89
96
|
const store = emptyStore();
|
|
90
97
|
if (Array.isArray(parsed.repos)) {
|
|
@@ -105,21 +112,182 @@ export async function loadTeamAutoStore() {
|
|
|
105
112
|
if (parsed.failedClaimRecovery && typeof parsed.failedClaimRecovery === "object") {
|
|
106
113
|
store.failedClaimRecovery = parsed.failedClaimRecovery;
|
|
107
114
|
}
|
|
115
|
+
if (parsed.fullReviewUmbrellas && typeof parsed.fullReviewUmbrellas === "object") {
|
|
116
|
+
store.fullReviewUmbrellas = parsed.fullReviewUmbrellas;
|
|
117
|
+
}
|
|
118
|
+
// #5736 (ggcode): the orphan-alarm chain (#5725 -> #5736 -> #5738) learned
|
|
119
|
+
// this the hard way three times over - loadTeamAutoStore rebuilds the store
|
|
120
|
+
// field-by-field, so a persistence field missing from this copy list is
|
|
121
|
+
// dropped on EVERY 20s settle reload even though saveTeamAutoStore writes
|
|
122
|
+
// it to disk. With all three alarm fields missing, the alarm silently
|
|
123
|
+
// disarmed: deliveredResultsInit dropped => the one-time migration re-ran
|
|
124
|
+
// each pass and pardoned every completed in-window task (genuine #5725
|
|
125
|
+
// registration loss could never alarm again); deliveredResults dropped =>
|
|
126
|
+
// prune-time delivery records evaporated; orphanResultAlarms dropped =>
|
|
127
|
+
// the once-per-task gate reset (99 alarm lines in 80s live).
|
|
128
|
+
if (parsed.orphanResultAlarms && typeof parsed.orphanResultAlarms === "object") {
|
|
129
|
+
store.orphanResultAlarms = parsed.orphanResultAlarms;
|
|
130
|
+
}
|
|
131
|
+
if (parsed.deliveredResults && typeof parsed.deliveredResults === "object") {
|
|
132
|
+
store.deliveredResults = parsed.deliveredResults;
|
|
133
|
+
}
|
|
134
|
+
if (typeof parsed.deliveredResultsInit === "boolean") {
|
|
135
|
+
store.deliveredResultsInit = parsed.deliveredResultsInit;
|
|
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
|
+
}
|
|
108
148
|
store.budget = { ...store.budget, ...(parsed.budget ?? {}) };
|
|
149
|
+
store.__baseFp = baseFingerprint;
|
|
109
150
|
return store;
|
|
110
151
|
}
|
|
111
152
|
catch {
|
|
112
153
|
return emptyStore();
|
|
113
154
|
}
|
|
114
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
|
+
}
|
|
238
|
+
/** #5677 (ggcode, 2026-11-15): store-level async mutex. The 20s write-back
|
|
239
|
+
* reconcile re-reads the store from disk and saves the whole object; the
|
|
240
|
+
* sweep transaction (registerWriteback + summary) does the same. Without
|
|
241
|
+
* serialization their read-modify-write cycles interleave: reconcile reads
|
|
242
|
+
* BEFORE the sweep's entry save, then its tail-save clobbers the entry the
|
|
243
|
+
* sweep just persisted (live: b3f688c6/#5676 write-back vanished; 3 earlier
|
|
244
|
+
* legs survived by timing luck). Every load→mutate→save section must hold
|
|
245
|
+
* this lock; it is process-local (single controller per state dir). */
|
|
246
|
+
const storeLock = { tail: Promise.resolve() };
|
|
247
|
+
export async function withStoreLock(section) {
|
|
248
|
+
const prev = storeLock.tail;
|
|
249
|
+
let release;
|
|
250
|
+
storeLock.tail = new Promise((r) => { release = r; });
|
|
251
|
+
await prev;
|
|
252
|
+
try {
|
|
253
|
+
return await section();
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
release();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
115
259
|
export async function saveTeamAutoStore(store) {
|
|
116
260
|
const { storeFile } = resolveTeamAutoPaths();
|
|
117
261
|
await fs.mkdir(path.dirname(storeFile), { recursive: true });
|
|
118
|
-
const tmp = `${storeFile}.tmp-${process.pid}-${Date.now()}`;
|
|
119
262
|
const next = writeQueue.length ? writeQueue[writeQueue.length - 1].catch(() => { }) : Promise.resolve();
|
|
120
263
|
const job = next.then(async () => {
|
|
121
|
-
|
|
122
|
-
|
|
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
|
+
}
|
|
123
291
|
});
|
|
124
292
|
writeQueue.push(job);
|
|
125
293
|
writeQueue.splice(0, Math.max(0, writeQueue.length - 20));
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #5704 (ggcode, 2026-11-16): LLM envelope/frame leakage into GitHub write
|
|
3
|
+
* surfaces. Three documented cases - a raw transport frame posted verbatim as
|
|
4
|
+
* an issue comment (#5699), a write timeout with nothing landed (#5687), and
|
|
5
|
+
* a PR body that was nothing but the frame JSON (#5703, PR<->issue linkage
|
|
6
|
+
* survived only via title). The frame shape:
|
|
7
|
+
*
|
|
8
|
+
* {"role":"assistant","content":[],"api":"openai-completions","provider":"zai",
|
|
9
|
+
* "model":"glm-5.3","usage":{...},"usageReport":{...},"contextUsage":{...}}
|
|
10
|
+
*
|
|
11
|
+
* reached GitHub because the reply-extraction fallback serialized the whole
|
|
12
|
+
* message object as prose (fixed at the extraction site in task-executor.ts),
|
|
13
|
+
* and nothing between task.result and the REST call ever asked "is this
|
|
14
|
+
* intended text?". This module is the write-channel half of the fix: every
|
|
15
|
+
* GitHub write body funnels through sanitizeGithubWriteBody - ordinary text
|
|
16
|
+
* passes through untouched, a frame with recoverable content is repaired to
|
|
17
|
+
* that content, a frame without recoverable content is rejected loudly
|
|
18
|
+
* (EnvelopeLeakError) so the write-back ladder fails terminally instead of
|
|
19
|
+
* retrying deterministic corruption or posting frame JSON.
|
|
20
|
+
*/
|
|
21
|
+
/** Error-message prefix the write-back ladder keys terminal classification on. */
|
|
22
|
+
export const ENVELOPE_LEAK_MARKER = "[envelope-leak]";
|
|
23
|
+
export class EnvelopeLeakError extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(ENVELOPE_LEAK_MARKER + " " + message);
|
|
26
|
+
this.name = "EnvelopeLeakError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** True when the message starts with a "{" and closes a top-level object. */
|
|
30
|
+
function leadingJsonObject(text) {
|
|
31
|
+
const trimmed = String(text ?? "").trimStart();
|
|
32
|
+
if (!trimmed.startsWith("{")) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
let depth = 0;
|
|
36
|
+
let inString = false;
|
|
37
|
+
let escaped = false;
|
|
38
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
39
|
+
const ch = trimmed[i];
|
|
40
|
+
if (inString) {
|
|
41
|
+
if (escaped) {
|
|
42
|
+
escaped = false;
|
|
43
|
+
}
|
|
44
|
+
else if (ch === "\\") {
|
|
45
|
+
escaped = true;
|
|
46
|
+
}
|
|
47
|
+
else if (ch === '"') {
|
|
48
|
+
inString = false;
|
|
49
|
+
}
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (ch === '"') {
|
|
53
|
+
inString = true;
|
|
54
|
+
}
|
|
55
|
+
else if (ch === "{") {
|
|
56
|
+
depth++;
|
|
57
|
+
}
|
|
58
|
+
else if (ch === "}") {
|
|
59
|
+
depth--;
|
|
60
|
+
if (depth === 0) {
|
|
61
|
+
try {
|
|
62
|
+
const parsed = JSON.parse(trimmed.slice(0, i + 1));
|
|
63
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
64
|
+
return parsed;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Frame signature: transport metadata keys that never appear in intended
|
|
78
|
+
* prose. role==="assistant" plus any one transport key is decisive (chat
|
|
79
|
+
* turns carry none of these); without the assistant role we require at
|
|
80
|
+
* least two transport keys AND a content field, so ordinary JSON bodies
|
|
81
|
+
* (result contracts, settings objects) never trip the guard.
|
|
82
|
+
*/
|
|
83
|
+
export function looksLikeLlmEnvelopeFrame(value) {
|
|
84
|
+
const transportKeys = ["api", "usage", "provider", "usageReport", "contextUsage"].filter((key) => key in value);
|
|
85
|
+
if (value.role === "assistant" && transportKeys.length >= 1) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return transportKeys.length >= 2 && "content" in value;
|
|
89
|
+
}
|
|
90
|
+
/** Recover intended text from a frame's content field (string or text blocks). */
|
|
91
|
+
export function envelopeFrameContentText(frame) {
|
|
92
|
+
const content = frame.content;
|
|
93
|
+
if (typeof content === "string") {
|
|
94
|
+
return content.trim() ? content : null;
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(content)) {
|
|
97
|
+
const text = content
|
|
98
|
+
.filter((block) => !!block && typeof block === "object" && block.type === "text")
|
|
99
|
+
.map((block) => (typeof block.text === "string" ? block.text : ""))
|
|
100
|
+
.filter(Boolean)
|
|
101
|
+
.join("\n")
|
|
102
|
+
.trim();
|
|
103
|
+
return text ? text : null;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Split a write payload into (frame?, recoverable text?).
|
|
109
|
+
* Returns false when the body is not a frame (ordinary text - pass through),
|
|
110
|
+
* null when it is a frame with no recoverable text (reject), and the
|
|
111
|
+
* recovered string when the frame carries content (repair). The scan reads
|
|
112
|
+
* only the LEADING object, so our own marker footer appended after the frame
|
|
113
|
+
* does not defeat detection, and prose that merely MENTIONS frame keys in
|
|
114
|
+
* backticks (audit reports like the #5704 watchdog sweep) passes untouched.
|
|
115
|
+
*/
|
|
116
|
+
export function splitLlmEnvelopeFrame(body) {
|
|
117
|
+
const frame = leadingJsonObject(body);
|
|
118
|
+
if (!frame || !looksLikeLlmEnvelopeFrame(frame)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return envelopeFrameContentText(frame);
|
|
122
|
+
}
|
|
123
|
+
/** A whole body line that is exactly one frame object (umbrella section
|
|
124
|
+
* bodies embed task.result as a block between the section header and the
|
|
125
|
+
* marker footer, so the leading-object scan alone cannot see them). */
|
|
126
|
+
function parseStandaloneFrameLine(line) {
|
|
127
|
+
const trimmed = line.trim();
|
|
128
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const parsed = JSON.parse(trimmed);
|
|
133
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
134
|
+
const frame = parsed;
|
|
135
|
+
return looksLikeLlmEnvelopeFrame(frame) ? frame : null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
/* not JSON - ordinary prose line */
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
/** Structural chrome around a deliverable: section headers, marker footers
|
|
144
|
+
* (the live footer shape is a bare "---" line followed by a
|
|
145
|
+
* "[teamclaw:<role>] autonomous via TeamClaw" line). */
|
|
146
|
+
function isNonSubstantiveLine(line) {
|
|
147
|
+
const trimmed = line.trim();
|
|
148
|
+
if (!trimmed) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (trimmed.startsWith("#")) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (trimmed === "---" || trimmed === "***") {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
if (/^\[teamclaw:/.test(trimmed)) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Write-channel validator (#5704). Apply to every body GitHub-bound write
|
|
164
|
+
* sends. Ordinary text (including JSON that is not a transport frame) is
|
|
165
|
+
* returned unchanged; frames are repaired or rejected.
|
|
166
|
+
*
|
|
167
|
+
* Two detection shapes:
|
|
168
|
+
* 1. the payload IS a frame (with our footer possibly appended) - repair to
|
|
169
|
+
* the recovered content text, or reject when none exists;
|
|
170
|
+
* 2. the payload EMBEDS standalone frame lines (umbrella section bodies) -
|
|
171
|
+
* each is replaced by its recovered text (dropped when textless), and the
|
|
172
|
+
* write is rejected when nothing substantive remains besides chrome.
|
|
173
|
+
*/
|
|
174
|
+
export function sanitizeGithubWriteBody(body, context) {
|
|
175
|
+
const outcome = splitLlmEnvelopeFrame(body);
|
|
176
|
+
if (typeof outcome === "string") {
|
|
177
|
+
return outcome;
|
|
178
|
+
}
|
|
179
|
+
if (outcome === null) {
|
|
180
|
+
throw new EnvelopeLeakError(context +
|
|
181
|
+
": payload is a raw LLM transport envelope frame with no recoverable content text - write rejected (#5704)");
|
|
182
|
+
}
|
|
183
|
+
const lines = String(body ?? "").split("\n");
|
|
184
|
+
const mapped = [];
|
|
185
|
+
let touched = false;
|
|
186
|
+
let recoveredAny = false;
|
|
187
|
+
for (const line of lines) {
|
|
188
|
+
const frame = parseStandaloneFrameLine(line);
|
|
189
|
+
if (frame) {
|
|
190
|
+
touched = true;
|
|
191
|
+
const recovered = envelopeFrameContentText(frame);
|
|
192
|
+
if (recovered) {
|
|
193
|
+
recoveredAny = true;
|
|
194
|
+
mapped.push(recovered);
|
|
195
|
+
}
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
mapped.push(line);
|
|
199
|
+
}
|
|
200
|
+
if (!touched) {
|
|
201
|
+
return body;
|
|
202
|
+
}
|
|
203
|
+
const substantive = mapped.filter((line) => !isNonSubstantiveLine(line));
|
|
204
|
+
if (!recoveredAny && substantive.length === 0) {
|
|
205
|
+
throw new EnvelopeLeakError(context +
|
|
206
|
+
": payload embeds only LLM transport envelope frame lines with no recoverable text - write rejected (#5704)");
|
|
207
|
+
}
|
|
208
|
+
return mapped.join("\n");
|
|
209
|
+
}
|
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.
|
|
@@ -140,6 +142,11 @@ export function parsePluginConfig(raw = {}) {
|
|
|
140
142
|
? Math.floor(raw.workerProvisioningMaxPerRole)
|
|
141
143
|
: 3;
|
|
142
144
|
const workerProvisioningMaxPerRole = Math.max(rawProvisioningMaxPerRole, workerProvisioningMinPerRole);
|
|
145
|
+
const workerRateLimitMaxRetries = typeof raw.workerRateLimitMaxRetries === "number" && raw.workerRateLimitMaxRetries >= 0
|
|
146
|
+
? Math.floor(raw.workerRateLimitMaxRetries)
|
|
147
|
+
: 999; // #retry-999: operators WANT persistent retries (999); the host-side
|
|
148
|
+
// hard ceiling that clamped everything to 9 is exempted for explicit
|
|
149
|
+
// budgets (see openclaw failover-retry-controller #retry-999).
|
|
143
150
|
const workerProvisioningIdleTtlMs = typeof raw.workerProvisioningIdleTtlMs === "number" && raw.workerProvisioningIdleTtlMs >= 1000
|
|
144
151
|
? raw.workerProvisioningIdleTtlMs
|
|
145
152
|
: 120_000;
|
|
@@ -232,6 +239,7 @@ export function parsePluginConfig(raw = {}) {
|
|
|
232
239
|
workerProvisioningMinPerRole,
|
|
233
240
|
workerProvisioningMaxPerRole,
|
|
234
241
|
workerProvisioningIdleTtlMs,
|
|
242
|
+
workerRateLimitMaxRetries,
|
|
235
243
|
workerProvisioningStartupTimeoutMs,
|
|
236
244
|
workerProvisioningImage,
|
|
237
245
|
workerProvisioningPassEnv,
|
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)",
|
package/dist/src/worker/tools.js
CHANGED
|
@@ -529,6 +529,11 @@ export function createWorkerTools(deps) {
|
|
|
529
529
|
if (status) {
|
|
530
530
|
patch.status = status;
|
|
531
531
|
}
|
|
532
|
+
// #5740 (ggcode): identify the reporting worker so the controller
|
|
533
|
+
// can apply the same stale-worker guard as the result routes.
|
|
534
|
+
if (typeof identity.workerId === "string" && identity.workerId) {
|
|
535
|
+
patch.workerId = identity.workerId;
|
|
536
|
+
}
|
|
532
537
|
if (progressContract) {
|
|
533
538
|
patch.progressContract = progressContract;
|
|
534
539
|
}
|
|
@@ -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",
|
|
@@ -51,7 +51,10 @@ function teamConfigGetRoute(ctx: RouteContext): void {
|
|
|
51
51
|
workerProvisioningMaxPerRole: c.workerProvisioningMaxPerRole,
|
|
52
52
|
workerProvisioningIdleTtlMs: c.workerProvisioningIdleTtlMs,
|
|
53
53
|
// k8s controllers run on ephemeral container FS: declare it up front.
|
|
54
|
-
|
|
54
|
+
// #hot-reload: persistence is PLUGIN-STATE (beside team-state.json), not
|
|
55
|
+
// host config - a host-config write made the host reload the whole
|
|
56
|
+
// plugin on every PATCH (see openclaw-workspace.ts #hot-reload note).
|
|
57
|
+
persistenceMode: "plugin-state",
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
|
|
@@ -105,8 +108,9 @@ async function teamConfigPatchRoute(ctx: RouteContext): Promise<void> {
|
|
|
105
108
|
applied.workerProvisioningMaxPerRole = minR;
|
|
106
109
|
}
|
|
107
110
|
|
|
108
|
-
// 2) Persist
|
|
109
|
-
//
|
|
111
|
+
// 2) Persist to PLUGIN STATE (never the host config - see
|
|
112
|
+
// openclaw-workspace.ts #hot-reload: host writes triggered full plugin
|
|
113
|
+
// reloads that killed in-flight work and usually failed to apply).
|
|
110
114
|
const memoryOnly = deps.config.workerProvisioningType === "kubernetes";
|
|
111
115
|
let persisted = false;
|
|
112
116
|
if (!memoryOnly) {
|