@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; }
package/src/ui/index.html CHANGED
@@ -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,3 +1,4 @@
1
+ import { timingSafeEqual } from "node:crypto";
1
2
  import type { IncomingMessage, ServerResponse } from "node:http";
2
3
  import type { PluginLogger } from "../../api.js";
3
4
  import type { TaskAssignmentPayload, TeamMessage } from "../types.js";
@@ -10,8 +11,57 @@ export type TaskCanceller = (taskId: string) => Promise<boolean> | boolean;
10
11
  export type TaskCancelChecker = (taskId: string) => boolean;
11
12
  export type KickoffAssessor = (requirement: string, role: string) => Promise<Record<string, unknown>>;
12
13
 
14
+ // ---------------------------------------------------------------------------
15
+ // Inbound API auth (issue #222, coordinated scope after #23/#227).
16
+ //
17
+ // The controller's device gate (#23) protects controller->world traffic; the
18
+ // REVERSE direction (controller dispatching tasks/messages INTO this worker)
19
+ // had no check at all, so any pod/host that can reach the worker port could
20
+ // submit tasks and poison results (review finding C2). Token model, chosen
21
+ // for minimal invasion with no NEW pairing surface:
22
+ //
23
+ // expected tokens = { config.securityToken, env TEAMCLAW_LAUNCH_TOKEN }
24
+ //
25
+ // - Provisioned workers: the provisioner already generates a per-worker
26
+ // launch token, delivers it via the TEAMCLAW_LAUNCH_TOKEN env, and the
27
+ // controller keeps it in the provisioning record - reuse it (it is
28
+ // already decoupled from the #23 device registry, so option (a)'s shape
29
+ // without a second token).
30
+ // - Manual/external workers: the operator syncs `securityToken` to the
31
+ // same value on the controller and the worker (documentation stance for
32
+ // self-managed fleets); provisioning-record tokens take precedence on
33
+ // the controller side.
34
+ // - BOTH are accepted (either match passes): pairing a provisioned worker
35
+ // later (`teamclaw pair` overwrites config.securityToken) must never
36
+ // lock the controller out of its own dispatch path.
37
+ // - Neither set => L0: zero checks, byte-identical historical behavior.
38
+ //
39
+ // /api/v1/health stays exempt: kubelet/docker probes (helm charts probe
40
+ // this path) cannot attach headers, mirroring the controller gate's health
41
+ // exemption. Comparison is constant-time on the raw token (a single shared
42
+ // secret per direction; hashing buys nothing here).
43
+ // ---------------------------------------------------------------------------
44
+
45
+ /** Constant-time string equality; length mismatch short-circuits (leaks only length, never content). */
46
+ function constantTimeEqual(a: string, b: string): boolean {
47
+ const left = Buffer.from(a, "utf8");
48
+ const right = Buffer.from(b, "utf8");
49
+ return left.length === right.length && timingSafeEqual(left, right);
50
+ }
51
+
52
+ /**
53
+ * The non-empty token values this worker accepts on inbound /api requests
54
+ * (config.securityToken and/or the provisioner's TEAMCLAW_LAUNCH_TOKEN).
55
+ * Empty result = L0 (no inbound auth).
56
+ */
57
+ export function resolveWorkerInboundTokens(config: { securityToken?: string }): string[] {
58
+ const configured = config.securityToken?.trim();
59
+ const launch = process.env.TEAMCLAW_LAUNCH_TOKEN?.trim();
60
+ return [configured, launch].filter((token): token is string => Boolean(token));
61
+ }
62
+
13
63
  export function createWorkerHttpHandler(
14
- config: { role: string; port: number },
64
+ config: { role: string; port: number; securityToken?: string },
15
65
  logger: PluginLogger,
16
66
  messageQueue: MessageQueue,
17
67
  workerId: string,
@@ -21,6 +71,7 @@ export function createWorkerHttpHandler(
21
71
  isTaskCancelled?: TaskCancelChecker,
22
72
  kickoffAssessor?: KickoffAssessor,
23
73
  ) {
74
+ const inboundTokens = resolveWorkerInboundTokens(config);
24
75
  return async (req: IncomingMessage, res: ServerResponse) => {
25
76
  // CORS preflight
26
77
  if (req.method === "OPTIONS") {
@@ -36,6 +87,18 @@ export function createWorkerHttpHandler(
36
87
  const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
37
88
  const pathname = url.pathname;
38
89
 
90
+ // Inbound device gate (issue #222): every /api route except the health
91
+ // probe requires X-TeamClaw-Token while this worker holds an expected
92
+ // token. No expected token configured => proceed (L0, zero change).
93
+ if (inboundTokens.length > 0 && pathname.startsWith("/api/") && pathname !== "/api/v1/health") {
94
+ const presented = typeof req.headers["x-teamclaw-token"] === "string" ? req.headers["x-teamclaw-token"].trim() : "";
95
+ if (!presented || !inboundTokens.some((expected) => constantTimeEqual(expected, presented))) {
96
+ logger.warn(`Worker: rejected unauthenticated ${req.method ?? "?"} ${pathname} from ${req.socket.remoteAddress ?? "unknown"}`);
97
+ 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)");
98
+ return;
99
+ }
100
+ }
101
+
39
102
  try {
40
103
  // GET /api/v1/health
41
104
  if (req.method === "GET" && pathname === "/api/v1/health") {
@@ -7,6 +7,9 @@ import type { PluginLogger } from "../../api.js";
7
7
  import { normalizeRecommendedSkills } from "../profile-loader.js";
8
8
  import { resolveTeamClawWorkspaceDir } from "../openclaw-workspace.js";
9
9
  import type { TaskAssignmentPayload, TaskExecutionEventInput } from "../types.js";
10
+ // W6 of issue #226: local swallowing pathExists copy replaced by the shared
11
+ // one (identical semantics; alias keeps the call sites byte-identical).
12
+ import { pathExistsTolerant as pathExists } from "../shared/utils.js";
10
13
 
11
14
  type SkillCli = "openclaw" | "clawhub";
12
15
  const ON_DEMAND_DISCOVERY_SKILLS = new Set(["find-skills"]);
@@ -44,15 +47,6 @@ function isSkillSlug(value: string): boolean {
44
47
  return /^[a-z0-9][a-z0-9._/-]*$/i.test(value) && !/\s/.test(value);
45
48
  }
46
49
 
47
- async function pathExists(filePath: string): Promise<boolean> {
48
- try {
49
- await fs.access(filePath);
50
- return true;
51
- } catch {
52
- return false;
53
- }
54
- }
55
-
56
50
  async function runCommand(
57
51
  command: string,
58
52
  args: string[],
@@ -12,7 +12,8 @@ import {
12
12
  } from "../interaction-contracts.js";
13
13
  import { loadWorkerIdentity } from "../state.js";
14
14
  import type { PluginConfig, WorkerIdentity } from "../types.js";
15
- import { normalizeClarificationQuestionSchema } from "../controller/orchestration-manifest.js";
15
+ // Issue #226 W3: shared contract — the worker must not import the controller tree.
16
+ import { normalizeClarificationQuestionSchema } from "../shared/clarification-schema.js";
16
17
 
17
18
  const ALLOWED_PROGRESS_STATUSES = new Set(["in_progress", "review"]);
18
19
 
@@ -44,6 +45,16 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
44
45
  return getIdentity() ?? await loadWorkerIdentity();
45
46
  }
46
47
 
48
+ /**
49
+ * Issue #23 (client wave): worker-tool calls into the controller carry the
50
+ * paired device token (config.securityToken) as X-TeamClaw-Token when one
51
+ * is configured; without it the headers are unchanged (L0). Never logged.
52
+ */
53
+ function withDeviceToken(headers: Record<string, string>): Record<string, string> {
54
+ const token = config.securityToken?.trim();
55
+ return token ? { ...headers, "X-TeamClaw-Token": token } : headers;
56
+ }
57
+
47
58
  return [
48
59
  {
49
60
  name: "teamclaw_ask_peer",
@@ -87,7 +98,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
87
98
  });
88
99
  const res = await fetch(`${identity.controllerUrl}/api/v1/messages/direct`, {
89
100
  method: "POST",
90
- headers: { "Content-Type": "application/json" },
101
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
91
102
  body: JSON.stringify({
92
103
  from: identity.workerId,
93
104
  fromRole: identity.role,
@@ -146,7 +157,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
146
157
  });
147
158
  const res = await fetch(`${identity.controllerUrl}/api/v1/messages/broadcast`, {
148
159
  method: "POST",
149
- headers: { "Content-Type": "application/json" },
160
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
150
161
  body: JSON.stringify({
151
162
  from: identity.workerId,
152
163
  fromRole: identity.role,
@@ -206,7 +217,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
206
217
  });
207
218
  const res = await fetch(`${identity.controllerUrl}/api/v1/messages/review-request`, {
208
219
  method: "POST",
209
- headers: { "Content-Type": "application/json" },
220
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
210
221
  body: JSON.stringify({
211
222
  from: identity.workerId,
212
223
  fromRole: identity.role,
@@ -263,7 +274,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
263
274
  });
264
275
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/handoff`, {
265
276
  method: "POST",
266
- headers: { "Content-Type": "application/json" },
277
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
267
278
  body: JSON.stringify({
268
279
  fromWorkerId: identity.workerId,
269
280
  targetRole,
@@ -348,7 +359,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
348
359
  try {
349
360
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/result-contract`, {
350
361
  method: "POST",
351
- headers: { "Content-Type": "application/json" },
362
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
352
363
  body: JSON.stringify({ contract, workerId: identity.workerId }),
353
364
  });
354
365
  if (!res.ok) {
@@ -402,7 +413,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
402
413
  try {
403
414
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}/parallel-help`, {
404
415
  method: "POST",
405
- headers: { "Content-Type": "application/json" },
416
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
406
417
  body: JSON.stringify({
407
418
  requestedBy: identity.workerId,
408
419
  requestedByRole: identity.role,
@@ -475,7 +486,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
475
486
  try {
476
487
  const res = await fetch(`${identity.controllerUrl}/api/v1/clarifications`, {
477
488
  method: "POST",
478
- headers: { "Content-Type": "application/json" },
489
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
479
490
  body: JSON.stringify({
480
491
  taskId,
481
492
  requestedBy: identity.workerId,
@@ -510,7 +521,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
510
521
  }
511
522
 
512
523
  try {
513
- const res = await fetch(`${identity.controllerUrl}/api/v1/team/status`);
524
+ const res = await fetch(`${identity.controllerUrl}/api/v1/team/status`, { headers: withDeviceToken({}) });
514
525
  if (!res.ok) {
515
526
  return { details: {}, content: [{ type: "text" as const, text: `Failed to get status: ${res.status}` }] };
516
527
  }
@@ -582,7 +593,7 @@ export function createWorkerTools(deps: WorkerToolsDeps) {
582
593
 
583
594
  const res = await fetch(`${identity.controllerUrl}/api/v1/tasks/${taskId}`, {
584
595
  method: "PATCH",
585
- headers: { "Content-Type": "application/json" },
596
+ headers: withDeviceToken({ "Content-Type": "application/json" }),
586
597
  body: JSON.stringify(patch),
587
598
  });
588
599
 
@@ -43,6 +43,17 @@ function isLoopbackHost(host: string): boolean {
43
43
  return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
44
44
  }
45
45
 
46
+ /**
47
+ * Issue #23 (client wave): worker -> controller requests carry the paired
48
+ * device token (config.securityToken) as X-TeamClaw-Token when one is
49
+ * configured; without a token the headers are unchanged (L0 behavior). The
50
+ * token value is never logged.
51
+ */
52
+ function withDeviceToken(config: PluginConfig, headers: Record<string, string>): Record<string, string> {
53
+ const token = config.securityToken?.trim();
54
+ return token ? { ...headers, "X-TeamClaw-Token": token } : headers;
55
+ }
56
+
46
57
  export type WorkerServiceDeps = {
47
58
  config: PluginConfig;
48
59
  logger: PluginLogger;
@@ -149,7 +160,7 @@ export function createWorkerService(deps: WorkerServiceDeps): OpenClawPluginServ
149
160
  }
150
161
  fetch(`${controllerUrl}/api/v1/tasks/${taskId}/result`, {
151
162
  method: "POST",
152
- headers: { "Content-Type": "application/json" },
163
+ headers: withDeviceToken(config, { "Content-Type": "application/json" }),
153
164
  body: JSON.stringify(body),
154
165
  }).catch((err) => {
155
166
  logger.error(`Worker: failed to report task result: ${String(err)}`);
@@ -179,7 +190,10 @@ export function createWorkerService(deps: WorkerServiceDeps): OpenClawPluginServ
179
190
  // Kickoff assessor — uses the worker's subagent runtime for lightweight assessment
180
191
  const kickoffAssessor = externalTaskExecutor
181
192
  ? async (requirement: string, role: string): Promise<Record<string, unknown>> => {
182
- const { buildKickoffAssessmentPrompt } = await import("../controller/kickoff-orchestrator.js");
193
+ // Issue #226 W3: the kickoff prompt contract lives in the shared
194
+ // layer now — this dynamic import must never point back at the
195
+ // controller tree (worker-mode deployments would drag it in).
196
+ const { buildKickoffAssessmentPrompt } = await import("../shared/kickoff-prompt.js");
183
197
  const prompt = buildKickoffAssessmentPrompt(role as import("../types.js").RoleId, requirement);
184
198
  const sessionKey = buildTeamClawAgentSessionKey(`teamclaw-kickoff-${role}-${Date.now()}`);
185
199
  const raw = await externalTaskExecutor(prompt, {
@@ -210,7 +224,7 @@ export function createWorkerService(deps: WorkerServiceDeps): OpenClawPluginServ
210
224
  : undefined;
211
225
 
212
226
  const handler = createWorkerHttpHandler(
213
- { role: config.role, port: config.port },
227
+ { role: config.role, port: config.port, securityToken: config.securityToken },
214
228
  logger,
215
229
  messageQueue,
216
230
  workerId ?? "",
@@ -299,7 +313,7 @@ export function createWorkerService(deps: WorkerServiceDeps): OpenClawPluginServ
299
313
  );
300
314
  const res = await fetch(`${controllerUrl}/api/v1/workers/${id.workerId}/heartbeat`, {
301
315
  method: "POST",
302
- headers: { "Content-Type": "application/json" },
316
+ headers: withDeviceToken(config, { "Content-Type": "application/json" }),
303
317
  body: JSON.stringify(heartbeat),
304
318
  });
305
319