@teamclaws/teamclaw 2026.11.0 → 2026.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/cli.mjs +272 -2
  2. package/dist/index.js +54 -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/controller-planning.js +1 -0
  7. package/dist/src/controller/controller-routes.js +195 -0
  8. package/dist/src/controller/controller-service.js +67 -10
  9. package/dist/src/controller/controller-tools.js +3 -1
  10. package/dist/src/controller/github-auth.js +2 -1
  11. package/dist/src/controller/http-server.js +51 -16
  12. package/dist/src/controller/kickoff-orchestrator.js +3 -39
  13. package/dist/src/controller/message-delivery.js +4 -1
  14. package/dist/src/controller/orchestration-manifest.js +5 -65
  15. package/dist/src/controller/preview-manager.js +51 -3
  16. package/dist/src/controller/profile-switch.js +42 -22
  17. package/dist/src/controller/provisioning/backend-contract.js +9 -0
  18. package/dist/src/controller/provisioning/container-shared.js +64 -0
  19. package/dist/src/controller/provisioning/docker.js +214 -0
  20. package/dist/src/controller/provisioning/kubernetes.js +244 -0
  21. package/dist/src/controller/provisioning/plugin-root.js +41 -0
  22. package/dist/src/controller/provisioning/process-supervisor.js +190 -0
  23. package/dist/src/controller/provisioning-config.js +239 -0
  24. package/dist/src/controller/repo-routes.js +70 -4
  25. package/dist/src/controller/report-routes.js +56 -0
  26. package/dist/src/controller/route-table.js +67 -1045
  27. package/dist/src/controller/security.js +775 -0
  28. package/dist/src/controller/status-routes.js +287 -0
  29. package/dist/src/controller/task-assignment.js +5 -2
  30. package/dist/src/controller/task-execution.js +31 -0
  31. package/dist/src/controller/task-results.js +10 -0
  32. package/dist/src/controller/tunnel-manager.js +41 -8
  33. package/dist/src/controller/tunnel-routes.js +225 -0
  34. package/dist/src/controller/websocket.js +6 -2
  35. package/dist/src/controller/webui-routes.js +49 -0
  36. package/dist/src/controller/worker-provisioning.js +39 -949
  37. package/dist/src/controller/workflow-routes.js +407 -0
  38. package/dist/src/controller/workspace-routes.js +200 -0
  39. package/dist/src/git-collaboration.js +4 -9
  40. package/dist/src/identity.js +12 -1
  41. package/dist/src/profile-loader.js +119 -1
  42. package/dist/src/profiles/banking.json +26 -2
  43. package/dist/src/profiles/schema.json +82 -2
  44. package/dist/src/prompt-policy.js +18 -6
  45. package/dist/src/protocol.js +66 -3
  46. package/dist/src/shared/clarification-schema.js +65 -0
  47. package/dist/src/shared/github-auth.js +15 -0
  48. package/dist/src/shared/kickoff-prompt.js +37 -0
  49. package/dist/src/shared/utils.js +47 -0
  50. package/dist/src/state.js +89 -3
  51. package/dist/src/types.js +15 -1
  52. package/dist/src/ui/app.js +846 -62
  53. package/dist/src/ui/github-login.html +1 -0
  54. package/dist/src/ui/index.html +102 -36
  55. package/dist/src/worker/http-handler.js +59 -0
  56. package/dist/src/worker/skill-installer.js +3 -9
  57. package/dist/src/worker/tools.js +20 -10
  58. package/dist/src/worker/worker-service.js +17 -4
  59. package/index.ts +61 -32
  60. package/openclaw.plugin.json +23 -2
  61. package/package.json +1 -1
  62. package/src/config.ts +24 -0
  63. package/src/controller/auth-routes.ts +157 -0
  64. package/src/controller/clarification-routes.ts +1 -1
  65. package/src/controller/controller-planning.ts +8 -0
  66. package/src/controller/controller-routes.ts +237 -0
  67. package/src/controller/controller-service.ts +128 -10
  68. package/src/controller/controller-tools.ts +5 -2
  69. package/src/controller/github-auth.ts +28 -63
  70. package/src/controller/http-server.ts +66 -17
  71. package/src/controller/kickoff-orchestrator.ts +3 -42
  72. package/src/controller/message-delivery.ts +4 -1
  73. package/src/controller/orchestration-manifest.ts +8 -71
  74. package/src/controller/preview-manager.ts +53 -3
  75. package/src/controller/profile-switch.ts +53 -23
  76. package/src/controller/provisioning/backend-contract.ts +51 -0
  77. package/src/controller/provisioning/container-shared.ts +84 -0
  78. package/src/controller/provisioning/docker.ts +260 -0
  79. package/src/controller/provisioning/kubernetes.ts +263 -0
  80. package/src/controller/provisioning/plugin-root.ts +42 -0
  81. package/src/controller/provisioning/process-supervisor.ts +214 -0
  82. package/src/controller/provisioning-config.ts +289 -0
  83. package/src/controller/repo-routes.ts +84 -12
  84. package/src/controller/report-routes.ts +64 -0
  85. package/src/controller/route-table.ts +133 -1152
  86. package/src/controller/security.ts +899 -0
  87. package/src/controller/status-routes.ts +354 -0
  88. package/src/controller/task-assignment.ts +5 -1
  89. package/src/controller/task-execution.ts +43 -0
  90. package/src/controller/task-results.ts +12 -0
  91. package/src/controller/tunnel-manager.ts +45 -8
  92. package/src/controller/tunnel-routes.ts +231 -0
  93. package/src/controller/websocket.ts +19 -3
  94. package/src/controller/webui-routes.ts +55 -0
  95. package/src/controller/worker-provisioning.ts +51 -1117
  96. package/src/controller/workflow-routes.ts +498 -0
  97. package/src/controller/workspace-routes.ts +222 -0
  98. package/src/git-collaboration.ts +4 -9
  99. package/src/identity.ts +13 -1
  100. package/src/profile-loader.ts +167 -1
  101. package/src/profiles/banking.json +26 -2
  102. package/src/profiles/schema.json +82 -2
  103. package/src/prompt-policy.ts +19 -6
  104. package/src/protocol.ts +72 -2
  105. package/src/shared/clarification-schema.ts +81 -0
  106. package/src/shared/github-auth.ts +92 -0
  107. package/src/shared/kickoff-prompt.ts +47 -0
  108. package/src/shared/utils.ts +51 -0
  109. package/src/state.ts +92 -3
  110. package/src/teamauto/github-client.ts +2 -1
  111. package/src/teamauto/repo-sync.ts +2 -1
  112. package/src/teamauto/scheduler.ts +2 -1
  113. package/src/types.ts +130 -1
  114. package/src/ui/app.js +846 -62
  115. package/src/ui/github-login.html +1 -0
  116. package/src/ui/index.html +102 -36
  117. package/src/worker/http-handler.ts +64 -1
  118. package/src/worker/skill-installer.ts +3 -9
  119. package/src/worker/tools.ts +21 -10
  120. package/src/worker/worker-service.ts +18 -4
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(),
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,