@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
@@ -4,6 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
6
  <title>TeamClaw - GitHub Login</title>
7
+ <!-- i18n: the inline bilingual STR map in this page is INTENTIONALLY independent (standalone auth document; the app.js dictionary lives inside its own IIFE scope and is not reachable from here). It does NOT participate in tests/test-i18n-parity.mjs — edit the page's STR map directly. Unification was considered and rejected (DECIDED 2026-11-10, i18n shared-package re-evaluation closure). -->
7
8
  <style>
8
9
  :root { color-scheme: dark; }
9
10
  * { box-sizing: border-box; }
@@ -24,17 +24,19 @@
24
24
  </div>
25
25
  <div class="header-status">
26
26
  <span id="connection-status" class="status-dot disconnected"></span>
27
- <a id="tunnel-live-pill" class="tunnel-live-pill" hidden target="_blank" rel="noopener" title="Managed tunnel is live - open in a new tab"></a>
28
- <button id="tunnel-settings-toggle" class="header-mini-btn" type="button" title="Internet tunnel settings">Tunnel</button>
27
+ <a id="tunnel-live-pill" class="tunnel-live-pill" hidden target="_blank" rel="noopener" data-i18n-title="header.tunnelLiveTitle"></a>
28
+ <button id="tunnel-settings-toggle" class="header-mini-btn" type="button" data-i18n-title="ctl.tunnel.title" data-i18n="ctl.tab.tunnel">Tunnel</button>
29
29
  <button id="language-toggle" class="header-mini-btn" type="button">中文</button>
30
- <button id="toast-settings-toggle" class="header-mini-btn" type="button" title="Toast notifications">Toasts</button>
31
- <button id="worker-install-toggle" class="header-mini-btn" type="button" hidden>Add worker</button>
30
+ <button id="toast-settings-toggle" class="header-mini-btn" type="button" data-i18n-title="toast.settingsTitle" data-i18n="header.toasts">Toasts</button>
31
+ <button id="worker-install-toggle" class="header-mini-btn" type="button" hidden data-i18n="worker.add">Add worker</button>
32
32
  <!-- Team profile indicator (Phase 5.1): shows the active profile's
33
- icon + localized name; click opens #team-profile-modal. -->
34
- <button id="team-profile-toggle" class="header-mini-btn team-profile-toggle" type="button" title="Team profile">Team</button>
35
- <span id="team-name">Team</span>
36
- <button id="github-corner-login" class="header-mini-btn" type="button">Login</button>
37
- <span id="github-corner-user" class="github-corner-user hidden" role="button" tabindex="0" title="GitHub: click to sign out">
33
+ icon + localized name; click opens #team-profile-modal. Static
34
+ fallback text/title only cover the pre-fetch paint; refreshAll
35
+ and renderTeamProfileHeaderButton overwrite both. -->
36
+ <button id="team-profile-toggle" class="header-mini-btn team-profile-toggle" type="button" data-i18n-title="teamProfile.kicker" data-i18n="header.teamFallback">Team</button>
37
+ <span id="team-name" data-i18n="header.teamFallback">Team</span>
38
+ <button id="github-corner-login" class="header-mini-btn" type="button" data-i18n="ctl.gh.login">Login</button>
39
+ <span id="github-corner-user" class="github-corner-user hidden" role="button" tabindex="0" data-i18n-title="header.githubUserTitle">
38
40
  <img id="github-corner-avatar" class="github-corner-avatar hidden" alt="">
39
41
  <span id="github-corner-name"></span>
40
42
  </span>
@@ -57,6 +59,12 @@
57
59
 
58
60
  <div class="content">
59
61
  <div id="runtime-alert" class="runtime-alert hidden"></div>
62
+ <!-- Device-pairing security suggestion banner (issue #23): non-blocking,
63
+ rendered only while protection is off AND a non-LAN peer was
64
+ observed (the /team/status security.suggested signal). The Enable
65
+ call is loopback-only server side; remote browsers never get an
66
+ actionable enable path. -->
67
+ <div id="security-suggest-banner" class="runtime-alert" hidden></div>
60
68
  <section id="external-worker-install" class="worker-install-card hidden"></section>
61
69
  <div class="tabs">
62
70
  <button class="tab" data-tab="planning">
@@ -70,6 +78,7 @@
70
78
  <span id="tasks-tab-signal" class="tab-signal"></span>
71
79
  </button>
72
80
  <button class="tab" data-tab="workspace"><span class="tab-label" data-i18n="tab.workspace">Workspace</span></button>
81
+ <button class="tab" data-tab="settings"><span class="tab-label" data-i18n="tab.settings">Settings</span></button>
73
82
  <button class="tab" data-tab="clarifications">
74
83
  <span class="tab-label" data-i18n="tab.clarifications">Clarifications</span>
75
84
  <span id="clarifications-tab-count" class="tab-badge">0</span>
@@ -87,7 +96,7 @@
87
96
  <aside class="planning-sessions">
88
97
  <div class="planning-sessions-header">Sessions</div>
89
98
  <div id="planning-session-list" class="planning-session-list">
90
- <div class="empty-state">No planning sessions yet</div>
99
+ <div class="empty-state" data-i18n="empty.noPlanningSessions">No planning sessions yet</div>
91
100
  </div>
92
101
  </aside>
93
102
  <div class="planning-main">
@@ -129,12 +138,41 @@
129
138
  <button class="filter-btn" data-filter="failed">Failed</button>
130
139
  <input id="task-keyword" class="task-keyword-input" type="search" placeholder="Filter by keyword..." spellcheck="false" autocomplete="off" />
131
140
  </div>
141
+ <!-- Workflow template button group (design 2.4 / PR #243 API
142
+ contract): buttons come from GET /api/v1/team/profile ->
143
+ profile.workflows[] (renderWorkflowLauncher in app.js).
144
+ hidden by default so profiles without workflows (software-rd)
145
+ never show it - purely data-driven, no per-profile branches.
146
+ Click posts /api/v1/workflows/{id}/start. -->
147
+ <div id="workflow-launcher" class="task-filters workflow-launcher" role="group" hidden></div>
132
148
  <div id="tasks-board" class="tasks-board">
133
149
  <div class="empty-state" data-i18n="empty.noTasks">No tasks yet</div>
134
150
  </div>
135
151
  </div>
136
152
 
137
153
  <!-- Workspace Tab -->
154
+ <div id="tab-settings" class="tab-panel">
155
+ <div class="panel-note" style="padding:12px 14px">
156
+ <h3 data-i18n="settings.models.title" style="margin:0 0 6px">Model settings</h3>
157
+ <p data-i18n="settings.models.hint" style="margin:0 0 8px;color:#666">Default model and per-role overrides.</p>
158
+ <div id="settings-models-slot"></div>
159
+ </div>
160
+ <div class="panel-note" style="padding:12px 14px;margin-top:10px">
161
+ <h3 data-i18n="settings.workers.title" style="margin:0 0 6px">Worker scaling (hot)</h3>
162
+ <p data-i18n="settings.workers.hint" style="margin:0 0 8px;color:#666">Applies immediately without restarting the gateway. Lowering a cap never kills busy workers.</p>
163
+ <div style="display:flex;gap:10px;flex-wrap:wrap;align-items:end">
164
+ <label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.max">Max workers / role</span>
165
+ <input id="wk-max" type="number" min="1" max="50" style="width:90px" /></label>
166
+ <label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.min">Min warm / role</span>
167
+ <input id="wk-min" type="number" min="0" max="50" style="width:90px" /></label>
168
+ <label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.ttl">Idle TTL (ms)</span>
169
+ <input id="wk-ttl" type="number" min="1000" max="86400000" step="1000" style="width:120px" /></label>
170
+ <button id="wk-save" type="button" class="btn btn-small">Apply</button>
171
+ <span id="wk-result" style="margin-left:8px;color:#080"></span>
172
+ </div>
173
+ <p id="wk-mode" style="margin:8px 0 0;color:#666;font-size:12px"></p>
174
+ </div>
175
+ </div>
138
176
  <div id="tab-workspace" class="tab-panel">
139
177
  <div class="workspace-browser">
140
178
  <aside class="workspace-sidebar-panel">
@@ -146,11 +184,11 @@
146
184
  <button id="workspace-tree-refresh" class="btn btn-small" type="button" data-i18n="action.refresh">Refresh</button>
147
185
  </div>
148
186
  <div class="workspace-current-path">
149
- <span class="workspace-current-path-label">Location</span>
187
+ <span class="workspace-current-path-label" data-i18n="workspace.location">Location</span>
150
188
  <code id="workspace-current-path-value">...</code>
151
189
  </div>
152
190
  <div id="workspace-tree" class="workspace-tree">
153
- <div class="empty-state">Workspace tree loading...</div>
191
+ <div class="empty-state" data-i18n="empty.workspaceLoading">Workspace tree loading…</div>
154
192
  </div>
155
193
  </aside>
156
194
 
@@ -288,22 +326,22 @@
288
326
  <div class="workspace-prompt-backdrop" data-workspace-prompt-close></div>
289
327
  <section class="workspace-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="workspace-prompt-title">
290
328
  <header class="workspace-prompt-header">
291
- <div class="workspace-prompt-kicker">Workspace setup</div>
292
- <h2 id="workspace-prompt-title">Choose a workspace directory</h2>
329
+ <div class="workspace-prompt-kicker" data-i18n="ws.kicker">Workspace setup</div>
330
+ <h2 id="workspace-prompt-title" data-i18n="ctl.ws.title">Choose a workspace directory</h2>
293
331
  </header>
294
332
  <div class="workspace-prompt-body">
295
- <p class="workspace-prompt-current">Current workspace (default):</p>
333
+ <p class="workspace-prompt-current" data-i18n="ctl.ws.current">Current workspace (default):</p>
296
334
  <p><code id="workspace-prompt-path"></code></p>
297
- <p class="workspace-prompt-hint">TeamClaw is using the default workspace location. You can move it anywhere on this machine (for example a project parent directory) before creating tasks.</p>
335
+ <p class="workspace-prompt-hint" data-i18n="ctl.ws.hint">TeamClaw is using the default workspace location. You can move it anywhere on this machine (for example a project parent directory) before creating tasks.</p>
298
336
  <div class="workspace-prompt-controls">
299
337
  <input id="workspace-prompt-input" class="workspace-prompt-input" type="text" placeholder="/absolute/path/to/teamclaw_workspace" spellcheck="false" />
300
338
  <div class="workspace-prompt-actions">
301
- <button id="workspace-prompt-browse" class="btn" type="button">Browse...</button>
302
- <button id="workspace-prompt-apply" class="btn btn-primary" type="button">Apply</button>
303
- <button id="workspace-prompt-dismiss" class="btn btn-small" type="button" data-workspace-prompt-close>Keep default</button>
339
+ <button id="workspace-prompt-browse" class="btn" type="button" data-i18n="ws.browse">Browse...</button>
340
+ <button id="workspace-prompt-apply" class="btn btn-primary" type="button" data-i18n="ctl.ws.apply">Apply</button>
341
+ <button id="workspace-prompt-dismiss" class="btn btn-small" type="button" data-workspace-prompt-close data-i18n="ws.keepDefault">Keep default</button>
304
342
  </div>
305
343
  </div>
306
- <p class="workspace-prompt-note">Applies after a gateway restart. Existing files are not moved automatically.</p>
344
+ <p class="workspace-prompt-note" data-i18n="ws.restartNote">Applies after a gateway restart. Existing files are not moved automatically.</p>
307
345
  </div>
308
346
  </section>
309
347
  </div>
@@ -312,19 +350,19 @@
312
350
  <div class="workspace-prompt-backdrop" data-model-settings-close></div>
313
351
  <section class="workspace-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="model-settings-title">
314
352
  <header class="workspace-prompt-header">
315
- <div class="workspace-prompt-kicker">Model settings</div>
316
- <h2 id="model-settings-title">Team models</h2>
353
+ <div class="workspace-prompt-kicker" data-i18n="models.kicker">Model settings</div>
354
+ <h2 id="model-settings-title" data-i18n="ctl.models.title">Team models</h2>
317
355
  </header>
318
356
  <div class="workspace-prompt-body">
319
357
  <label class="model-settings-field">
320
- <span class="model-settings-label">Default model (controller &amp; all roles)</span>
358
+ <span class="model-settings-label" data-i18n="ctl.models.default">Default model (controller &amp; all roles)</span>
321
359
  <select id="model-settings-default"></select>
322
360
  </label>
323
361
  <div id="model-settings-roles" class="model-settings-roles"></div>
324
- <p class="workspace-prompt-note">Changes hot-reload when possible; restart the gateway (openclaw gateway restart) if a selection does not take effect. Per-role selections override the default for that role.</p>
362
+ <p class="workspace-prompt-note" data-i18n="ctl.models.hint">Changes hot-reload when possible; restart the gateway (openclaw gateway restart) if a selection does not take effect. Per-role selections override the default for that role.</p>
325
363
  <div class="workspace-prompt-actions">
326
- <button id="model-settings-save" class="btn btn-primary" type="button">Save</button>
327
- <button id="model-settings-close" class="btn btn-small" type="button" data-model-settings-close>Cancel</button>
364
+ <button id="model-settings-save" class="btn btn-primary" type="button" data-i18n="ctl.models.save">Save</button>
365
+ <button id="model-settings-close" class="btn btn-small" type="button" data-model-settings-close data-i18n="action.cancel">Cancel</button>
328
366
  </div>
329
367
  </div>
330
368
  </section>
@@ -352,10 +390,61 @@
352
390
  </div>
353
391
  </div>
354
392
  <p id="team-profile-switch-status" class="team-profile-switch-status" hidden></p>
393
+ <!-- Role display (Phase 4 lightweight customization): per-browser
394
+ visibility + rename layer over GET /roles - localStorage only,
395
+ the profile JSON and the API stay untouched (full editing is
396
+ v2). Rows render in app.js from the /roles registry mirror. -->
397
+ <section class="team-profile-archived" id="role-display-section">
398
+ <h3 data-i18n="roleDisplay.title">Role display</h3>
399
+ <p class="workspace-prompt-note" data-i18n="roleDisplay.hint">Hide roles this team does not use, or rename them for your team. Saved in this browser only (display layer) - the team profile itself is not modified.</p>
400
+ <div id="role-display-list" class="team-profile-archives"></div>
401
+ <div class="workspace-prompt-actions">
402
+ <button id="role-display-save" class="btn btn-primary" type="button" data-i18n="roleDisplay.save">Save</button>
403
+ <button id="role-display-reset" class="btn btn-small" type="button" data-i18n="roleDisplay.reset">Reset to defaults</button>
404
+ </div>
405
+ </section>
355
406
  <section class="team-profile-archived">
356
407
  <h3 data-i18n="teamProfile.archivedTitle">Archived teams</h3>
357
408
  <div id="team-profile-archives" class="team-profile-archives"></div>
358
409
  </section>
410
+ <!-- Device-pairing security section (issue #23): status line always
411
+ reflects /team/status.security; the device list / revoke / reset
412
+ controls fetch GET /api/v1/security (paired browsers only). -->
413
+ <section class="team-profile-archived" id="security-devices-section">
414
+ <h3 data-i18n="security.devicesTitle">Device security</h3>
415
+ <div id="security-devices-status" style="font-size:12.5px;margin-bottom:8px"></div>
416
+ <div id="security-devices-list" class="team-profile-archives"></div>
417
+ <div id="security-devices-actions" class="workspace-prompt-actions"></div>
418
+ </section>
419
+ </div>
420
+ </section>
421
+ </div>
422
+
423
+ <!-- Device pairing modal (issue #23): opened right after POST
424
+ /api/v1/security/enable succeeds, or when the devices section issues a
425
+ new code. Shows the one-shot 60s pairing code, the countdown, and the
426
+ copyable CLI command for the next device. Closing needs no further
427
+ action: this browser was paired by the enable response's session
428
+ cookie, so it never logs in. -->
429
+ <div id="security-pair-modal" class="workspace-prompt-modal" aria-hidden="true">
430
+ <div class="workspace-prompt-backdrop" data-security-pair-close></div>
431
+ <section class="workspace-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="security-pair-title" style="max-width:560px">
432
+ <header class="workspace-prompt-header">
433
+ <div>
434
+ <div class="workspace-prompt-kicker" data-i18n="security.devicesTitle">Device security</div>
435
+ <h2 id="security-pair-title" data-i18n="security.pairTitle">Pair your devices</h2>
436
+ </div>
437
+ <button id="security-pair-close" class="btn btn-small" type="button" data-security-pair-close data-i18n="action.close">Close</button>
438
+ </header>
439
+ <div class="workspace-prompt-body">
440
+ <p data-i18n="security.pairHint">This browser is paired automatically. To pair another device (worker, desktop or CLI), run this command within 60 seconds:</p>
441
+ <div id="security-pair-code" style="font-family:ui-monospace,Menlo,Consolas,monospace;font-size:32px;letter-spacing:6px;font-weight:700;text-align:center;margin:10px 0 4px"></div>
442
+ <div id="security-pair-countdown" style="text-align:center;font-size:12.5px;opacity:.75;margin-bottom:10px"></div>
443
+ <pre id="security-pair-command" class="worker-install-command" style="margin:0 0 12px"><code></code></pre>
444
+ <div class="workspace-prompt-actions">
445
+ <button id="security-pair-copy" class="btn" type="button" data-i18n="action.copyCommand">Copy command</button>
446
+ <button id="security-pair-new" class="btn" type="button" data-i18n="security.pairNewCode">New pairing code</button>
447
+ </div>
359
448
  </div>
360
449
  </section>
361
450
  </div>
@@ -395,19 +484,19 @@
395
484
 
396
485
  <div class="task-detail-tabs">
397
486
  <button class="task-detail-tab active" type="button" data-task-detail-tab="details">
398
- <span>Task details</span>
487
+ <span data-i18n="task.details">Task details</span>
399
488
  <span class="task-detail-tab-count" data-task-detail-tab-count="details"></span>
400
489
  </button>
401
490
  <button class="task-detail-tab" type="button" data-task-detail-tab="timeline">
402
- <span>Timeline</span>
491
+ <span data-i18n="task.timeline">Timeline</span>
403
492
  <span class="task-detail-tab-count" data-task-detail-tab-count="timeline"></span>
404
493
  </button>
405
494
  <button class="task-detail-tab" type="button" data-task-detail-tab="clarifications">
406
- <span>Clarifications</span>
495
+ <span data-i18n="tab.clarifications">Clarifications</span>
407
496
  <span class="task-detail-tab-count" data-task-detail-tab-count="clarifications"></span>
408
497
  </button>
409
498
  <button class="task-detail-tab" type="button" data-task-detail-tab="messages">
410
- <span>Messages</span>
499
+ <span data-i18n="task.messages">Messages</span>
411
500
  <span class="task-detail-tab-count" data-task-detail-tab-count="messages"></span>
412
501
  </button>
413
502
  </div>
@@ -423,8 +512,8 @@
423
512
 
424
513
  <footer class="footer">
425
514
  <div class="command-bar">
426
- <input type="text" id="command-input" placeholder="Send a controller message or slash command... (e.g., 继续工作, /status, /assign task-id developer)" autocomplete="off">
427
- <button id="command-send" class="btn btn-small">Send to Controller</button>
515
+ <input type="text" id="command-input" placeholder="Send a controller message or slash command... (e.g., 继续工作, /status, /assign task-id developer)" data-i18n-placeholder="command.placeholder" autocomplete="off">
516
+ <button id="command-send" class="btn btn-small" data-i18n="command.send">Send to Controller</button>
428
517
  </div>
429
518
  </footer>
430
519
 
@@ -433,12 +522,12 @@
433
522
  active). -->
434
523
  <div id="tunnel-popover" class="tunnel-popover" hidden>
435
524
  <div class="tunnel-popover-backdrop" data-act="close"></div>
436
- <div class="tunnel-popover-card" role="dialog" aria-modal="true" aria-label="Internet tunnel settings">
525
+ <div class="tunnel-popover-card" role="dialog" aria-modal="true" data-i18n-aria="ctl.tunnel.title">
437
526
  <div class="tunnel-popover-head">
438
- <h3>Internet Tunnel</h3>
439
- <button class="tunnel-popover-close" data-act="close" type="button" aria-label="Close">×</button>
527
+ <h3 data-i18n="ctl.tunnel.title">Internet Tunnel</h3>
528
+ <button class="tunnel-popover-close" data-act="close" type="button" aria-label="Close" data-i18n-aria="action.close">×</button>
440
529
  </div>
441
- <div class="tunnel-state"><span class="tunnel-note">loading…</span></div>
530
+ <div class="tunnel-state"><span class="tunnel-note" data-i18n="ctl.tunnel.loading">loading…</span></div>
442
531
  </div>
443
532
  </div>
444
533
 
@@ -1,5 +1,53 @@
1
+ import { timingSafeEqual } from "node:crypto";
1
2
  import { parseJsonBody, sendJson, sendError } from "../protocol.js";
3
+ // ---------------------------------------------------------------------------
4
+ // Inbound API auth (issue #222, coordinated scope after #23/#227).
5
+ //
6
+ // The controller's device gate (#23) protects controller->world traffic; the
7
+ // REVERSE direction (controller dispatching tasks/messages INTO this worker)
8
+ // had no check at all, so any pod/host that can reach the worker port could
9
+ // submit tasks and poison results (review finding C2). Token model, chosen
10
+ // for minimal invasion with no NEW pairing surface:
11
+ //
12
+ // expected tokens = { config.securityToken, env TEAMCLAW_LAUNCH_TOKEN }
13
+ //
14
+ // - Provisioned workers: the provisioner already generates a per-worker
15
+ // launch token, delivers it via the TEAMCLAW_LAUNCH_TOKEN env, and the
16
+ // controller keeps it in the provisioning record - reuse it (it is
17
+ // already decoupled from the #23 device registry, so option (a)'s shape
18
+ // without a second token).
19
+ // - Manual/external workers: the operator syncs `securityToken` to the
20
+ // same value on the controller and the worker (documentation stance for
21
+ // self-managed fleets); provisioning-record tokens take precedence on
22
+ // the controller side.
23
+ // - BOTH are accepted (either match passes): pairing a provisioned worker
24
+ // later (`teamclaw pair` overwrites config.securityToken) must never
25
+ // lock the controller out of its own dispatch path.
26
+ // - Neither set => L0: zero checks, byte-identical historical behavior.
27
+ //
28
+ // /api/v1/health stays exempt: kubelet/docker probes (helm charts probe
29
+ // this path) cannot attach headers, mirroring the controller gate's health
30
+ // exemption. Comparison is constant-time on the raw token (a single shared
31
+ // secret per direction; hashing buys nothing here).
32
+ // ---------------------------------------------------------------------------
33
+ /** Constant-time string equality; length mismatch short-circuits (leaks only length, never content). */
34
+ function constantTimeEqual(a, b) {
35
+ const left = Buffer.from(a, "utf8");
36
+ const right = Buffer.from(b, "utf8");
37
+ return left.length === right.length && timingSafeEqual(left, right);
38
+ }
39
+ /**
40
+ * The non-empty token values this worker accepts on inbound /api requests
41
+ * (config.securityToken and/or the provisioner's TEAMCLAW_LAUNCH_TOKEN).
42
+ * Empty result = L0 (no inbound auth).
43
+ */
44
+ export function resolveWorkerInboundTokens(config) {
45
+ const configured = config.securityToken?.trim();
46
+ const launch = process.env.TEAMCLAW_LAUNCH_TOKEN?.trim();
47
+ return [configured, launch].filter((token) => Boolean(token));
48
+ }
2
49
  export function createWorkerHttpHandler(config, logger, messageQueue, workerId, taskExecutor, resultReporter, cancelTaskExecution, isTaskCancelled, kickoffAssessor) {
50
+ const inboundTokens = resolveWorkerInboundTokens(config);
3
51
  return async (req, res) => {
4
52
  // CORS preflight
5
53
  if (req.method === "OPTIONS") {
@@ -13,6 +61,17 @@ export function createWorkerHttpHandler(config, logger, messageQueue, workerId,
13
61
  }
14
62
  const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
15
63
  const pathname = url.pathname;
64
+ // Inbound device gate (issue #222): every /api route except the health
65
+ // probe requires X-TeamClaw-Token while this worker holds an expected
66
+ // token. No expected token configured => proceed (L0, zero change).
67
+ if (inboundTokens.length > 0 && pathname.startsWith("/api/") && pathname !== "/api/v1/health") {
68
+ const presented = typeof req.headers["x-teamclaw-token"] === "string" ? req.headers["x-teamclaw-token"].trim() : "";
69
+ if (!presented || !inboundTokens.some((expected) => constantTimeEqual(expected, presented))) {
70
+ logger.warn(`Worker: rejected unauthenticated ${req.method ?? "?"} ${pathname} from ${req.socket.remoteAddress ?? "unknown"}`);
71
+ sendError(res, 401, "unauthorized: this worker requires the X-TeamClaw-Token header (the controller's dispatch token for this worker, or the value synced into securityToken)");
72
+ return;
73
+ }
74
+ }
16
75
  try {
17
76
  // GET /api/v1/health
18
77
  if (req.method === "GET" && pathname === "/api/v1/health") {
@@ -5,6 +5,9 @@ import path from "node:path";
5
5
  // face (same semantics as the registry helper).
6
6
  import { normalizeRecommendedSkills } from "../profile-loader.js";
7
7
  import { resolveTeamClawWorkspaceDir } from "../openclaw-workspace.js";
8
+ // W6 of issue #226: local swallowing pathExists copy replaced by the shared
9
+ // one (identical semantics; alias keeps the call sites byte-identical).
10
+ import { pathExistsTolerant as pathExists } from "../shared/utils.js";
8
11
  const ON_DEMAND_DISCOVERY_SKILLS = new Set(["find-skills"]);
9
12
  function truncateOutput(value, limit = 400) {
10
13
  const trimmed = value.trim();
@@ -22,15 +25,6 @@ function normalizeKey(value) {
22
25
  function isSkillSlug(value) {
23
26
  return /^[a-z0-9][a-z0-9._/-]*$/i.test(value) && !/\s/.test(value);
24
27
  }
25
- async function pathExists(filePath) {
26
- try {
27
- await fs.access(filePath);
28
- return true;
29
- }
30
- catch {
31
- return false;
32
- }
33
- }
34
28
  async function runCommand(command, args, cwd) {
35
29
  return await new Promise((resolve) => {
36
30
  const child = spawn(command, args, {
@@ -1,7 +1,8 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import { backfillWorkerProgressContract, ensureTeamMessageContract, normalizeContractRole, normalizeContractStringList, normalizeTaskHandoffContract, normalizeWorkerProgressContract, normalizeWorkerTaskResultContract, renderWorkerProgressText, } from "../interaction-contracts.js";
3
3
  import { loadWorkerIdentity } from "../state.js";
4
- import { normalizeClarificationQuestionSchema } from "../controller/orchestration-manifest.js";
4
+ // Issue #226 W3: shared contract — the worker must not import the controller tree.
5
+ import { normalizeClarificationQuestionSchema } from "../shared/clarification-schema.js";
5
6
  const ALLOWED_PROGRESS_STATUSES = new Set(["in_progress", "review"]);
6
7
  function normalizeProgressText(params) {
7
8
  if (typeof params.progress === "string" && params.progress.trim()) {
@@ -23,6 +24,15 @@ export function createWorkerTools(deps) {
23
24
  async function resolveIdentity() {
24
25
  return getIdentity() ?? await loadWorkerIdentity();
25
26
  }
27
+ /**
28
+ * Issue #23 (client wave): worker-tool calls into the controller carry the
29
+ * paired device token (config.securityToken) as X-TeamClaw-Token when one
30
+ * is configured; without it the headers are unchanged (L0). Never logged.
31
+ */
32
+ function withDeviceToken(headers) {
33
+ const token = config.securityToken?.trim();
34
+ return token ? { ...headers, "X-TeamClaw-Token": token } : headers;
35
+ }
26
36
  return [
27
37
  {
28
38
  name: "teamclaw_ask_peer",
@@ -63,7 +73,7 @@ export function createWorkerTools(deps) {
63
73
  });
64
74
  const res = await fetch(`${identity.controllerUrl}/api/v1/messages/direct`, {
65
75
  method: "POST",
66
- headers: { "Content-Type": "application/json" },
76
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
67
77
  body: JSON.stringify({
68
78
  from: identity.workerId,
69
79
  fromRole: identity.role,
@@ -119,7 +129,7 @@ export function createWorkerTools(deps) {
119
129
  });
120
130
  const res = await fetch(`${identity.controllerUrl}/api/v1/messages/broadcast`, {
121
131
  method: "POST",
122
- headers: { "Content-Type": "application/json" },
132
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
123
133
  body: JSON.stringify({
124
134
  from: identity.workerId,
125
135
  fromRole: identity.role,
@@ -175,7 +185,7 @@ export function createWorkerTools(deps) {
175
185
  });
176
186
  const res = await fetch(`${identity.controllerUrl}/api/v1/messages/review-request`, {
177
187
  method: "POST",
178
- headers: { "Content-Type": "application/json" },
188
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
179
189
  body: JSON.stringify({
180
190
  from: identity.workerId,
181
191
  fromRole: identity.role,
@@ -228,7 +238,7 @@ export function createWorkerTools(deps) {
228
238
  });
229
239
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/handoff`, {
230
240
  method: "POST",
231
- headers: { "Content-Type": "application/json" },
241
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
232
242
  body: JSON.stringify({
233
243
  fromWorkerId: identity.workerId,
234
244
  targetRole,
@@ -301,7 +311,7 @@ export function createWorkerTools(deps) {
301
311
  try {
302
312
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/result-contract`, {
303
313
  method: "POST",
304
- headers: { "Content-Type": "application/json" },
314
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
305
315
  body: JSON.stringify({ contract, workerId: identity.workerId }),
306
316
  });
307
317
  if (!res.ok) {
@@ -353,7 +363,7 @@ export function createWorkerTools(deps) {
353
363
  try {
354
364
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/parallel-help`, {
355
365
  method: "POST",
356
- headers: { "Content-Type": "application/json" },
366
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
357
367
  body: JSON.stringify({
358
368
  requestedBy: identity.workerId,
359
369
  requestedByRole: identity.role,
@@ -422,7 +432,7 @@ export function createWorkerTools(deps) {
422
432
  try {
423
433
  const res = await fetch(`${identity.controllerUrl}/api/v1/clarifications`, {
424
434
  method: "POST",
425
- headers: { "Content-Type": "application/json" },
435
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
426
436
  body: JSON.stringify({
427
437
  taskId,
428
438
  requestedBy: identity.workerId,
@@ -455,7 +465,7 @@ export function createWorkerTools(deps) {
455
465
  return { details: {}, content: [{ type: "text", text: "Not registered with a team." }] };
456
466
  }
457
467
  try {
458
- const res = await fetch(`${identity.controllerUrl}/api/v1/team/status`);
468
+ const res = await fetch(`${identity.controllerUrl}/api/v1/team/status`, { headers: withDeviceToken({}) });
459
469
  if (!res.ok) {
460
470
  return { details: {}, content: [{ type: "text", text: `Failed to get status: ${res.status}` }] };
461
471
  }
@@ -524,7 +534,7 @@ export function createWorkerTools(deps) {
524
534
  }
525
535
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}`, {
526
536
  method: "PATCH",
527
- headers: { "Content-Type": "application/json" },
537
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
528
538
  body: JSON.stringify(patch),
529
539
  });
530
540
  if (!res.ok) {
@@ -35,6 +35,16 @@ export function resolveWorkerListenHost(config) {
35
35
  function isLoopbackHost(host) {
36
36
  return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
37
37
  }
38
+ /**
39
+ * Issue #23 (client wave): worker -> controller requests carry the paired
40
+ * device token (config.securityToken) as X-TeamClaw-Token when one is
41
+ * configured; without a token the headers are unchanged (L0 behavior). The
42
+ * token value is never logged.
43
+ */
44
+ function withDeviceToken(config, headers) {
45
+ const token = config.securityToken?.trim();
46
+ return token ? { ...headers, "X-TeamClaw-Token": token } : headers;
47
+ }
38
48
  export function createWorkerService(deps) {
39
49
  const { config, logger, onIdentityEstablished, taskExecutor: externalTaskExecutor } = deps;
40
50
  let identityManager;
@@ -128,7 +138,7 @@ export function createWorkerService(deps) {
128
138
  }
129
139
  fetch(`${controllerUrl}/api/v1/tasks/${taskId}/result`, {
130
140
  method: "POST",
131
- headers: { "Content-Type": "application/json" },
141
+ headers: withDeviceToken(config, { "Content-Type": "application/json" }),
132
142
  body: JSON.stringify(body),
133
143
  }).catch((err) => {
134
144
  logger.error(`Worker: failed to report task result: ${String(err)}`);
@@ -155,7 +165,10 @@ export function createWorkerService(deps) {
155
165
  // Kickoff assessor — uses the worker's subagent runtime for lightweight assessment
156
166
  const kickoffAssessor = externalTaskExecutor
157
167
  ? async (requirement, role) => {
158
- const { buildKickoffAssessmentPrompt } = await import("../controller/kickoff-orchestrator.js");
168
+ // Issue #226 W3: the kickoff prompt contract lives in the shared
169
+ // layer now — this dynamic import must never point back at the
170
+ // controller tree (worker-mode deployments would drag it in).
171
+ const { buildKickoffAssessmentPrompt } = await import("../shared/kickoff-prompt.js");
159
172
  const prompt = buildKickoffAssessmentPrompt(role, requirement);
160
173
  const sessionKey = buildTeamClawAgentSessionKey(`teamclaw-kickoff-${role}-${Date.now()}`);
161
174
  const raw = await externalTaskExecutor(prompt, {
@@ -185,7 +198,7 @@ export function createWorkerService(deps) {
185
198
  }
186
199
  }
187
200
  : undefined;
188
- const handler = createWorkerHttpHandler({ role: config.role, port: config.port }, logger, messageQueue, workerId ?? "", taskExecutor, reportTaskResult, cancelAssignedTask, isTaskCancelled, kickoffAssessor);
201
+ const handler = createWorkerHttpHandler({ role: config.role, port: config.port, securityToken: config.securityToken }, logger, messageQueue, workerId ?? "", taskExecutor, reportTaskResult, cancelAssignedTask, isTaskCancelled, kickoffAssessor);
189
202
  if (server) {
190
203
  await new Promise((resolve) => server.close(() => resolve()));
191
204
  }
@@ -252,7 +265,7 @@ export function createWorkerService(deps) {
252
265
  const heartbeat = createHeartbeatPayload(id.workerId, activeTaskId ? "busy" : "idle", activeTaskId);
253
266
  const res = await fetch(`${controllerUrl}/api/v1/workers/${id.workerId}/heartbeat`, {
254
267
  method: "POST",
255
- headers: { "Content-Type": "application/json" },
268
+ headers: withDeviceToken(config, { "Content-Type": "application/json" }),
256
269
  body: JSON.stringify(heartbeat),
257
270
  });
258
271
  if (!res.ok) {