@teamclaws/teamclaw 2026.11.0 → 2026.11.2

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.
Files changed (128) hide show
  1. package/cli.mjs +368 -13
  2. package/dist/index.js +61 -32
  3. package/dist/src/config.js +24 -0
  4. package/dist/src/controller/auth-routes.js +129 -0
  5. package/dist/src/controller/clarification-routes.js +1 -1
  6. package/dist/src/controller/config-routes.js +138 -0
  7. package/dist/src/controller/controller-planning.js +1 -0
  8. package/dist/src/controller/controller-routes.js +195 -0
  9. package/dist/src/controller/controller-service.js +67 -10
  10. package/dist/src/controller/controller-tools.js +3 -1
  11. package/dist/src/controller/github-auth.js +2 -1
  12. package/dist/src/controller/http-server.js +51 -16
  13. package/dist/src/controller/kickoff-orchestrator.js +3 -39
  14. package/dist/src/controller/message-delivery.js +4 -1
  15. package/dist/src/controller/orchestration-manifest.js +5 -65
  16. package/dist/src/controller/preview-manager.js +51 -3
  17. package/dist/src/controller/profile-switch.js +42 -22
  18. package/dist/src/controller/provisioning/backend-contract.js +9 -0
  19. package/dist/src/controller/provisioning/container-shared.js +64 -0
  20. package/dist/src/controller/provisioning/docker.js +214 -0
  21. package/dist/src/controller/provisioning/kubernetes.js +244 -0
  22. package/dist/src/controller/provisioning/plugin-root.js +41 -0
  23. package/dist/src/controller/provisioning/process-supervisor.js +190 -0
  24. package/dist/src/controller/provisioning-config.js +239 -0
  25. package/dist/src/controller/repo-routes.js +70 -4
  26. package/dist/src/controller/report-routes.js +56 -0
  27. package/dist/src/controller/route-table.js +73 -1045
  28. package/dist/src/controller/security.js +775 -0
  29. package/dist/src/controller/status-routes.js +287 -0
  30. package/dist/src/controller/task-assignment.js +5 -2
  31. package/dist/src/controller/task-execution.js +31 -0
  32. package/dist/src/controller/task-results.js +10 -0
  33. package/dist/src/controller/tunnel-manager.js +41 -8
  34. package/dist/src/controller/tunnel-routes.js +225 -0
  35. package/dist/src/controller/websocket.js +6 -2
  36. package/dist/src/controller/webui-routes.js +49 -0
  37. package/dist/src/controller/worker-provisioning.js +39 -949
  38. package/dist/src/controller/workflow-routes.js +407 -0
  39. package/dist/src/controller/workspace-routes.js +200 -0
  40. package/dist/src/git-collaboration.js +4 -9
  41. package/dist/src/identity.js +12 -1
  42. package/dist/src/openclaw-workspace.js +36 -0
  43. package/dist/src/profile-loader.js +119 -1
  44. package/dist/src/profiles/banking.json +26 -2
  45. package/dist/src/profiles/schema.json +82 -2
  46. package/dist/src/prompt-policy.js +18 -6
  47. package/dist/src/protocol.js +66 -3
  48. package/dist/src/shared/clarification-schema.js +65 -0
  49. package/dist/src/shared/github-auth.js +15 -0
  50. package/dist/src/shared/kickoff-prompt.js +37 -0
  51. package/dist/src/shared/utils.js +47 -0
  52. package/dist/src/state.js +89 -3
  53. package/dist/src/teamauto/scanner.js +21 -2
  54. package/dist/src/teamauto/scheduler.js +9 -2
  55. package/dist/src/types.js +15 -1
  56. package/dist/src/ui/app.js +990 -73
  57. package/dist/src/ui/github-login.html +1 -0
  58. package/dist/src/ui/index.html +125 -36
  59. package/dist/src/worker/http-handler.js +59 -0
  60. package/dist/src/worker/skill-installer.js +3 -9
  61. package/dist/src/worker/tools.js +20 -10
  62. package/dist/src/worker/worker-service.js +17 -4
  63. package/index.ts +69 -32
  64. package/openclaw.plugin.json +23 -2
  65. package/package.json +1 -1
  66. package/src/config.ts +24 -0
  67. package/src/controller/auth-routes.ts +157 -0
  68. package/src/controller/clarification-routes.ts +1 -1
  69. package/src/controller/config-routes.ts +152 -0
  70. package/src/controller/controller-planning.ts +8 -0
  71. package/src/controller/controller-routes.ts +237 -0
  72. package/src/controller/controller-service.ts +128 -10
  73. package/src/controller/controller-tools.ts +5 -2
  74. package/src/controller/github-auth.ts +28 -63
  75. package/src/controller/http-server.ts +66 -17
  76. package/src/controller/kickoff-orchestrator.ts +3 -42
  77. package/src/controller/message-delivery.ts +4 -1
  78. package/src/controller/orchestration-manifest.ts +8 -71
  79. package/src/controller/preview-manager.ts +53 -3
  80. package/src/controller/profile-switch.ts +53 -23
  81. package/src/controller/provisioning/backend-contract.ts +51 -0
  82. package/src/controller/provisioning/container-shared.ts +84 -0
  83. package/src/controller/provisioning/docker.ts +260 -0
  84. package/src/controller/provisioning/kubernetes.ts +263 -0
  85. package/src/controller/provisioning/plugin-root.ts +42 -0
  86. package/src/controller/provisioning/process-supervisor.ts +214 -0
  87. package/src/controller/provisioning-config.ts +289 -0
  88. package/src/controller/repo-routes.ts +84 -12
  89. package/src/controller/report-routes.ts +64 -0
  90. package/src/controller/route-table.ts +139 -1152
  91. package/src/controller/security.ts +899 -0
  92. package/src/controller/status-routes.ts +354 -0
  93. package/src/controller/task-assignment.ts +5 -1
  94. package/src/controller/task-execution.ts +43 -0
  95. package/src/controller/task-results.ts +12 -0
  96. package/src/controller/tunnel-manager.ts +45 -8
  97. package/src/controller/tunnel-routes.ts +231 -0
  98. package/src/controller/websocket.ts +20 -3
  99. package/src/controller/webui-routes.ts +55 -0
  100. package/src/controller/worker-provisioning.ts +51 -1117
  101. package/src/controller/workflow-routes.ts +498 -0
  102. package/src/controller/workspace-routes.ts +222 -0
  103. package/src/git-collaboration.ts +4 -9
  104. package/src/identity.ts +13 -1
  105. package/src/openclaw-workspace.ts +47 -0
  106. package/src/profile-loader.ts +167 -1
  107. package/src/profiles/banking.json +26 -2
  108. package/src/profiles/schema.json +82 -2
  109. package/src/prompt-policy.ts +19 -6
  110. package/src/protocol.ts +72 -2
  111. package/src/shared/clarification-schema.ts +81 -0
  112. package/src/shared/github-auth.ts +92 -0
  113. package/src/shared/kickoff-prompt.ts +47 -0
  114. package/src/shared/utils.ts +51 -0
  115. package/src/state.ts +92 -3
  116. package/src/teamauto/github-client.ts +2 -1
  117. package/src/teamauto/repo-sync.ts +2 -1
  118. package/src/teamauto/scanner.ts +22 -3
  119. package/src/teamauto/scheduler.ts +11 -3
  120. package/src/teamauto/store.ts +5 -0
  121. package/src/types.ts +130 -1
  122. package/src/ui/app.js +990 -73
  123. package/src/ui/github-login.html +1 -0
  124. package/src/ui/index.html +125 -36
  125. package/src/worker/http-handler.ts +64 -1
  126. package/src/worker/skill-installer.ts +3 -9
  127. package/src/worker/tools.ts +21 -10
  128. package/src/worker/worker-service.ts +18 -4
@@ -0,0 +1,47 @@
1
+ // Shared generic utilities (issue #226 W6 dedup + W1 worker-provisioning
2
+ // split). Everything here is extracted VERBATIM from its former private
3
+ // copies - semantics are frozen, see the W6 notes per function:
4
+ // - pathExists strict: only ENOENT resolves false, other errors
5
+ // rethrow (former worker-provisioning.ts copy)
6
+ // - pathExistsTolerant swallowing: any access error resolves false (the
7
+ // former git-collaboration.ts / worker/skill-installer.ts
8
+ // / index.ts copies, kept as a distinct name so each
9
+ // call site keeps its exact original behavior)
10
+ // - sleep / cloneJson / sanitizePathSegment / sanitizeName: single shared
11
+ // copies of byte-identical former duplicates.
12
+ import fs from "node:fs/promises";
13
+ export function sleep(ms) {
14
+ return new Promise((resolve) => setTimeout(resolve, ms));
15
+ }
16
+ export function cloneJson(value) {
17
+ return JSON.parse(JSON.stringify(value));
18
+ }
19
+ export async function pathExists(targetPath) {
20
+ try {
21
+ await fs.access(targetPath);
22
+ return true;
23
+ }
24
+ catch (err) {
25
+ if (err.code === "ENOENT") {
26
+ return false;
27
+ }
28
+ throw err;
29
+ }
30
+ }
31
+ export async function pathExistsTolerant(targetPath) {
32
+ try {
33
+ await fs.access(targetPath);
34
+ return true;
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ }
40
+ export function sanitizePathSegment(value) {
41
+ const normalized = value.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "");
42
+ return normalized || "worker";
43
+ }
44
+ export function sanitizeName(value, maxLength = 63) {
45
+ const normalized = sanitizePathSegment(value).slice(0, maxLength).replace(/^-+|-+$/g, "");
46
+ return normalized || "teamclaw";
47
+ }
package/dist/src/state.js CHANGED
@@ -72,8 +72,61 @@ function migrateState(raw) {
72
72
  delete state.transition;
73
73
  }
74
74
  }
75
+ // Issue #23: device-pairing security state (additive optional field). No
76
+ // `security` key = protection off (L0 zero-friction default). A malformed
77
+ // persisted shape is sanitized in place, mirroring the transition policy
78
+ // above: devices without a usable identity/tokenHash are dropped (such a
79
+ // device could never authenticate again anyway), and malformed pairing
80
+ // codes / observation records are discarded.
81
+ if (state.security !== undefined) {
82
+ const security = state.security;
83
+ if (!security || typeof security !== "object" || Array.isArray(security)) {
84
+ delete state.security;
85
+ }
86
+ else {
87
+ if (security.enabledAt !== undefined && typeof security.enabledAt !== "number") {
88
+ delete security.enabledAt;
89
+ }
90
+ security.devices = Array.isArray(security.devices)
91
+ ? security.devices.filter(isValidPersistedSecurityDevice)
92
+ : [];
93
+ if (security.pairingCode !== undefined) {
94
+ const pairingCode = security.pairingCode;
95
+ const codeOk = typeof pairingCode?.code === "string" && /^[A-Z2-7]{8}$/.test(pairingCode.code);
96
+ const expiresOk = typeof pairingCode?.expiresAt === "number";
97
+ const purposeOk = typeof pairingCode?.purpose === "string" && Boolean(pairingCode.purpose.trim());
98
+ const usedOk = pairingCode?.usedAt === undefined || typeof pairingCode.usedAt === "number";
99
+ if (!codeOk || !expiresOk || !purposeOk || !usedOk) {
100
+ delete security.pairingCode;
101
+ }
102
+ }
103
+ if (security.lastNonLanPeer !== undefined) {
104
+ const observation = security.lastNonLanPeer;
105
+ if (typeof observation?.ip !== "string" ||
106
+ typeof observation?.at !== "number" ||
107
+ typeof observation?.path !== "string") {
108
+ delete security.lastNonLanPeer;
109
+ }
110
+ }
111
+ }
112
+ }
75
113
  return state;
76
114
  }
115
+ /**
116
+ * Issue #23: persisted-device structural guard for the migration above. A
117
+ * device needs a non-empty id, a sha256-hex tokenHash (64 lowercase hex
118
+ * chars) and a creation timestamp; anything else is corrupt state and is
119
+ * dropped rather than half-loaded.
120
+ */
121
+ function isValidPersistedSecurityDevice(entry) {
122
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
123
+ return false;
124
+ }
125
+ const device = entry;
126
+ return (typeof device.id === "string" && Boolean(device.id.trim()) &&
127
+ typeof device.tokenHash === "string" && /^[0-9a-f]{64}$/.test(device.tokenHash) &&
128
+ typeof device.createdAt === "number");
129
+ }
77
130
  function resolvePluginStateDir() {
78
131
  const explicitStateDir = process.env.OPENCLAW_STATE_DIR?.trim();
79
132
  if (explicitStateDir) {
@@ -124,9 +177,37 @@ function normalizeStartupReadiness(value) {
124
177
  async function ensureDir(dir) {
125
178
  await fs.mkdir(dir, { recursive: true });
126
179
  }
180
+ /**
181
+ * Issue #255 P1-4: every file written through this helper is controller
182
+ * state that can carry plaintext secrets - team-state.json holds the device
183
+ * pairingCode and each provisioned worker's launchToken, the archived team
184
+ * envelopes and worker-identity.json ride the same path. Writes are now
185
+ * owner-only (0600), matching the github-auth.ts auth-store precedent:
186
+ * - the tmp file is created with mode 0600 and the rename carries that
187
+ * mode onto the final path, and
188
+ * - an existing file from an older build (created 0644 by this same
189
+ * helper before the mode existed) is pre-tightened before the rewrite
190
+ * (#242 process-supervisor pattern: chmod first, ENOENT tolerated for
191
+ * first writes).
192
+ */
127
193
  async function writeFileAtomically(filePath, contents) {
128
194
  const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}`;
129
- await fs.writeFile(tmpPath, contents, "utf8");
195
+ try {
196
+ await fs.chmod(filePath, 0o600);
197
+ }
198
+ catch (error) {
199
+ if (error?.code !== "ENOENT") {
200
+ throw error;
201
+ }
202
+ }
203
+ await fs.writeFile(tmpPath, contents, { encoding: "utf8", mode: 0o600 });
204
+ try {
205
+ await fs.chmod(tmpPath, 0o600);
206
+ }
207
+ catch {
208
+ // Best-effort: the write itself already requested mode 0600; some
209
+ // filesystems (e.g. network mounts) reject explicit chmod.
210
+ }
130
211
  await fs.rename(tmpPath, filePath);
131
212
  }
132
213
  function enqueueAtomicWrite(filePath, contents) {
@@ -237,7 +318,7 @@ async function saveTeamState(state) {
237
318
  // lists archive metadata; the full payload stays queryable offline.
238
319
  // ---------------------------------------------------------------------------
239
320
  const ARCHIVED_TEAMS_DIR_NAME = "archived";
240
- const ARCHIVE_FILE_RE = /^([a-z0-9-]+)-(\d+)\.json$/;
321
+ const ARCHIVE_FILE_RE = /^([a-z0-9-]+)-(\d+)(?:-([a-z0-9]+))?\.json$/;
241
322
  function archivedTeamsDirPath() {
242
323
  return path.join(STATE_DIR, ARCHIVED_TEAMS_DIR_NAME);
243
324
  }
@@ -257,7 +338,12 @@ function parseArchiveFileName(name) {
257
338
  async function archiveTeamState(state, profileSnapshot) {
258
339
  const dir = archivedTeamsDirPath();
259
340
  await ensureDir(dir);
260
- const fileName = `${state.profileId}-${Date.now()}.json`;
341
+ // #251: a short random suffix disambiguates same-millisecond archives
342
+ // (two switches inside one ms would otherwise silently overwrite each
343
+ // other). Capture groups 1/2 keep their original semantics; group 3 is
344
+ // the optional suffix, so pre-#251 archive names still parse.
345
+ const suffix = Math.random().toString(36).slice(2, 8).padEnd(6, "0");
346
+ const fileName = `${state.profileId}-${Date.now()}-${suffix}.json`;
261
347
  const filePath = path.join(dir, fileName);
262
348
  const envelope = {
263
349
  archivedAt: Date.now(),
@@ -65,6 +65,19 @@ export async function sweepRepo(repo, client, now = Date.now()) {
65
65
  const pulls = repo.policy.actions.prReview
66
66
  ? await client.listPulls(owner, name, repo.cursors.etags)
67
67
  : [];
68
+ // #265: the commits leg was dead code (listCommits had zero callers,
69
+ // lastCommitSha never advanced) - the designed third signal source never
70
+ // ran. Wire it as an observation-only feed: fetch, filter past the cursor,
71
+ // and surface the delta. Cursor advance happens in advanceCursors (with
72
+ // the other legs, so dry-run semantics stay intact); it produces no task
73
+ // candidates (issue/pull policies stay the sole candidate sources).
74
+ const commits = await client.listCommits(owner, name, repo.cursors.lastCommitSha);
75
+ // Newest-first feed: when the cursor is set, stop the delta at the first
76
+ // entry whose sha equals it (that commit and everything after is already
77
+ // known). An unset cursor means first sweep: observe only, report nothing.
78
+ const newCommits = repo.cursors.lastCommitSha
79
+ ? commits.slice(0, (() => { const i = commits.findIndex((c) => c.sha === repo.cursors.lastCommitSha); return i === -1 ? commits.length : i; })())
80
+ : [];
68
81
  const candidates = [];
69
82
  for (const issue of issues) {
70
83
  // Dedup: seen map survives sweeps; a closed-then-reopened issue updates.
@@ -173,16 +186,22 @@ export async function sweepRepo(repo, client, now = Date.now()) {
173
186
  }
174
187
  }
175
188
  }
176
- return { candidates: candidates.slice(0, repo.policy.maxTasksPerSweep * 2), issues, pulls };
189
+ return { candidates: candidates.slice(0, repo.policy.maxTasksPerSweep * 2), issues, pulls, newCommits, commits };
177
190
  }
178
191
  /** Advance cursors after tasks were enqueued (or observed on first sweep). */
179
- export function advanceCursors(repo, issues, pulls, now = Date.now()) {
192
+ export function advanceCursors(repo, issues, pulls, now = Date.now(), commits = []) {
180
193
  for (const issue of issues) {
181
194
  repo.cursors.seen[`${repo.id}#issue-${issue.number}`] = Date.parse(issue.updatedAt) || now;
182
195
  }
183
196
  for (const pull of pulls) {
184
197
  repo.cursors.seen[`${repo.id}#pr-${pull.number}`] = Date.parse(pull.updated_at) || now;
185
198
  }
199
+ // Commit cursor: the feed is newest-first, so when anything came back the
200
+ // HEAD entry IS the new cursor. Empty feed keeps the old cursor (nothing
201
+ // new to advance to).
202
+ if (commits.length > 0) {
203
+ repo.cursors.lastCommitSha = commits[0].sha;
204
+ }
186
205
  // Cap the seen map so it cannot grow unbounded.
187
206
  const entries = Object.entries(repo.cursors.seen);
188
207
  if (entries.length > 2000) {
@@ -337,7 +337,7 @@ export function createTeamAutoScheduler(deps) {
337
337
  }
338
338
  sweeping.add(repo.id);
339
339
  try {
340
- const { candidates, issues, pulls } = await sweepRepo(repo, client);
340
+ const { candidates, issues, pulls, newCommits, commits } = await sweepRepo(repo, client);
341
341
  const dryRun = !repo.dryRunDone && s.budget.firstSweepDryRun;
342
342
  if (dryRun) {
343
343
  // One observing pass, then act. Flip unconditionally - flipping only
@@ -350,7 +350,7 @@ export function createTeamAutoScheduler(deps) {
350
350
  // Advance only for acting sweeps: a dry-run must leave the cursors
351
351
  // untouched so the reported actions are actually performed next time
352
352
  // instead of being marked as already-seen.
353
- advanceCursors(repo, issues, pulls);
353
+ advanceCursors(repo, issues, pulls, Date.now(), commits);
354
354
  }
355
355
  // Joint full reviews bypass the per-sweep cap: they append AFTER issue/
356
356
  // pull candidates, so a busy repo would otherwise starve them forever
@@ -361,6 +361,11 @@ export function createTeamAutoScheduler(deps) {
361
361
  const capped = [...fullReviews, ...regular];
362
362
  let created = 0;
363
363
  const summary = [`found ${candidates.length} candidate(s)`];
364
+ // #265: surface the commits delta so the third signal source is
365
+ // observable in sweep summaries (was silently dead before).
366
+ if (newCommits.length > 0) {
367
+ summary.push(`${newCommits.length} new commit(s) (HEAD ${newCommits[0].sha.slice(0, 7)})`);
368
+ }
364
369
  if (capped.length && dryRun) {
365
370
  summary.push(...capped.map((c) => `DRY-RUN would ${c.kind}: ${c.title}`));
366
371
  repo.lastSweepSummary = `dry-run: ${summary.join("; ")}`;
@@ -401,6 +406,7 @@ export function createTeamAutoScheduler(deps) {
401
406
  recordActivity(s, { at: Date.now(), repoId: repo.id, kind: "sweep", text: "sweep recovered, auto-pause cleared" });
402
407
  }
403
408
  repo.sweepFailures = 0;
409
+ repo.lastAttemptAt = Date.now(); // #266: success is also an attempt
404
410
  recordActivity(s, { at: Date.now(), repoId: repo.id, kind: "sweep", text: repo.lastSweepSummary ?? "sweep complete" });
405
411
  await saveTeamAutoStore(s);
406
412
  if (created > 0) {
@@ -419,6 +425,7 @@ export function createTeamAutoScheduler(deps) {
419
425
  // backoff below, and a success clears the state in the block above.
420
426
  repo.sweepFailures = (repo.sweepFailures ?? 0) + 1;
421
427
  repo.lastSweepErrorAt = Date.now();
428
+ repo.lastAttemptAt = repo.lastSweepErrorAt; // #266: failures must be visible without inferring from lastSweepErrorAt
422
429
  repo.pausedReason = `sweep failed: ${message}`;
423
430
  recordActivity(s, { at: Date.now(), repoId: repo.id, kind: "sweep", text: `sweep failed (auto-retry in ~${sweepBackoffMinutes(repo.sweepFailures)}min): ${message}` });
424
431
  await saveTeamAutoStore(s).catch(() => { });
package/dist/src/types.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TEAMCLAW_PUBLISHED_RUNTIME_IMAGE } from "./install-defaults.js";
2
- import { DEFAULT_GITHUB_CLIENT_ID } from "./controller/github-auth.js";
2
+ import { DEFAULT_GITHUB_CLIENT_ID } from "./shared/github-auth.js";
3
3
  // Safe value import: roles.js only pulls prompt-policy.js -> openclaw-workspace.js
4
4
  // at runtime (its types.js import is type-only), so no module cycle is formed.
5
5
  import { DEFAULT_ROLE } from "./roles.js";
@@ -105,6 +105,18 @@ 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 defaults to true (L1 zero-input LAN
109
+ // pairing); only an explicit boolean false disables pair-auto.
110
+ const rawSecurity = raw.security;
111
+ const rawAutoPair = rawSecurity && typeof rawSecurity === "object" && !Array.isArray(rawSecurity)
112
+ ? rawSecurity.autoPair
113
+ : undefined;
114
+ const security = {
115
+ autoPair: typeof rawAutoPair === "boolean" ? rawAutoPair : true,
116
+ };
117
+ // Issue #23 (client wave): the paired device token, if this instance
118
+ // paired with a protected controller. Empty/absent keeps L0 behavior.
119
+ const securityToken = typeof raw.securityToken === "string" ? raw.securityToken.trim() : "";
108
120
  const rawWorkerProvisioningType = parseProvisioningType(raw.workerProvisioningType);
109
121
  const workerProvisioningDisabled = raw.workerProvisioningDisabled === true;
110
122
  // Legacy local installs often persisted workerProvisioningType="none" without
@@ -211,6 +223,8 @@ export function parsePluginConfig(raw = {}) {
211
223
  githubClientId,
212
224
  githubClientSecret,
213
225
  agentIsolationMode,
226
+ security,
227
+ securityToken,
214
228
  workerProvisioningType,
215
229
  workerProvisioningDisabled,
216
230
  workerProvisioningControllerUrl,