@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
@@ -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">
@@ -87,7 +95,7 @@
87
95
  <aside class="planning-sessions">
88
96
  <div class="planning-sessions-header">Sessions</div>
89
97
  <div id="planning-session-list" class="planning-session-list">
90
- <div class="empty-state">No planning sessions yet</div>
98
+ <div class="empty-state" data-i18n="empty.noPlanningSessions">No planning sessions yet</div>
91
99
  </div>
92
100
  </aside>
93
101
  <div class="planning-main">
@@ -129,6 +137,13 @@
129
137
  <button class="filter-btn" data-filter="failed">Failed</button>
130
138
  <input id="task-keyword" class="task-keyword-input" type="search" placeholder="Filter by keyword..." spellcheck="false" autocomplete="off" />
131
139
  </div>
140
+ <!-- Workflow template button group (design 2.4 / PR #243 API
141
+ contract): buttons come from GET /api/v1/team/profile ->
142
+ profile.workflows[] (renderWorkflowLauncher in app.js).
143
+ hidden by default so profiles without workflows (software-rd)
144
+ never show it - purely data-driven, no per-profile branches.
145
+ Click posts /api/v1/workflows/{id}/start. -->
146
+ <div id="workflow-launcher" class="task-filters workflow-launcher" role="group" hidden></div>
132
147
  <div id="tasks-board" class="tasks-board">
133
148
  <div class="empty-state" data-i18n="empty.noTasks">No tasks yet</div>
134
149
  </div>
@@ -146,11 +161,11 @@
146
161
  <button id="workspace-tree-refresh" class="btn btn-small" type="button" data-i18n="action.refresh">Refresh</button>
147
162
  </div>
148
163
  <div class="workspace-current-path">
149
- <span class="workspace-current-path-label">Location</span>
164
+ <span class="workspace-current-path-label" data-i18n="workspace.location">Location</span>
150
165
  <code id="workspace-current-path-value">...</code>
151
166
  </div>
152
167
  <div id="workspace-tree" class="workspace-tree">
153
- <div class="empty-state">Workspace tree loading...</div>
168
+ <div class="empty-state" data-i18n="empty.workspaceLoading">Workspace tree loading…</div>
154
169
  </div>
155
170
  </aside>
156
171
 
@@ -288,22 +303,22 @@
288
303
  <div class="workspace-prompt-backdrop" data-workspace-prompt-close></div>
289
304
  <section class="workspace-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="workspace-prompt-title">
290
305
  <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>
306
+ <div class="workspace-prompt-kicker" data-i18n="ws.kicker">Workspace setup</div>
307
+ <h2 id="workspace-prompt-title" data-i18n="ctl.ws.title">Choose a workspace directory</h2>
293
308
  </header>
294
309
  <div class="workspace-prompt-body">
295
- <p class="workspace-prompt-current">Current workspace (default):</p>
310
+ <p class="workspace-prompt-current" data-i18n="ctl.ws.current">Current workspace (default):</p>
296
311
  <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>
312
+ <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
313
  <div class="workspace-prompt-controls">
299
314
  <input id="workspace-prompt-input" class="workspace-prompt-input" type="text" placeholder="/absolute/path/to/teamclaw_workspace" spellcheck="false" />
300
315
  <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>
316
+ <button id="workspace-prompt-browse" class="btn" type="button" data-i18n="ws.browse">Browse...</button>
317
+ <button id="workspace-prompt-apply" class="btn btn-primary" type="button" data-i18n="ctl.ws.apply">Apply</button>
318
+ <button id="workspace-prompt-dismiss" class="btn btn-small" type="button" data-workspace-prompt-close data-i18n="ws.keepDefault">Keep default</button>
304
319
  </div>
305
320
  </div>
306
- <p class="workspace-prompt-note">Applies after a gateway restart. Existing files are not moved automatically.</p>
321
+ <p class="workspace-prompt-note" data-i18n="ws.restartNote">Applies after a gateway restart. Existing files are not moved automatically.</p>
307
322
  </div>
308
323
  </section>
309
324
  </div>
@@ -312,19 +327,19 @@
312
327
  <div class="workspace-prompt-backdrop" data-model-settings-close></div>
313
328
  <section class="workspace-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="model-settings-title">
314
329
  <header class="workspace-prompt-header">
315
- <div class="workspace-prompt-kicker">Model settings</div>
316
- <h2 id="model-settings-title">Team models</h2>
330
+ <div class="workspace-prompt-kicker" data-i18n="models.kicker">Model settings</div>
331
+ <h2 id="model-settings-title" data-i18n="ctl.models.title">Team models</h2>
317
332
  </header>
318
333
  <div class="workspace-prompt-body">
319
334
  <label class="model-settings-field">
320
- <span class="model-settings-label">Default model (controller &amp; all roles)</span>
335
+ <span class="model-settings-label" data-i18n="ctl.models.default">Default model (controller &amp; all roles)</span>
321
336
  <select id="model-settings-default"></select>
322
337
  </label>
323
338
  <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>
339
+ <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
340
  <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>
341
+ <button id="model-settings-save" class="btn btn-primary" type="button" data-i18n="ctl.models.save">Save</button>
342
+ <button id="model-settings-close" class="btn btn-small" type="button" data-model-settings-close data-i18n="action.cancel">Cancel</button>
328
343
  </div>
329
344
  </div>
330
345
  </section>
@@ -352,10 +367,61 @@
352
367
  </div>
353
368
  </div>
354
369
  <p id="team-profile-switch-status" class="team-profile-switch-status" hidden></p>
370
+ <!-- Role display (Phase 4 lightweight customization): per-browser
371
+ visibility + rename layer over GET /roles - localStorage only,
372
+ the profile JSON and the API stay untouched (full editing is
373
+ v2). Rows render in app.js from the /roles registry mirror. -->
374
+ <section class="team-profile-archived" id="role-display-section">
375
+ <h3 data-i18n="roleDisplay.title">Role display</h3>
376
+ <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>
377
+ <div id="role-display-list" class="team-profile-archives"></div>
378
+ <div class="workspace-prompt-actions">
379
+ <button id="role-display-save" class="btn btn-primary" type="button" data-i18n="roleDisplay.save">Save</button>
380
+ <button id="role-display-reset" class="btn btn-small" type="button" data-i18n="roleDisplay.reset">Reset to defaults</button>
381
+ </div>
382
+ </section>
355
383
  <section class="team-profile-archived">
356
384
  <h3 data-i18n="teamProfile.archivedTitle">Archived teams</h3>
357
385
  <div id="team-profile-archives" class="team-profile-archives"></div>
358
386
  </section>
387
+ <!-- Device-pairing security section (issue #23): status line always
388
+ reflects /team/status.security; the device list / revoke / reset
389
+ controls fetch GET /api/v1/security (paired browsers only). -->
390
+ <section class="team-profile-archived" id="security-devices-section">
391
+ <h3 data-i18n="security.devicesTitle">Device security</h3>
392
+ <div id="security-devices-status" style="font-size:12.5px;margin-bottom:8px"></div>
393
+ <div id="security-devices-list" class="team-profile-archives"></div>
394
+ <div id="security-devices-actions" class="workspace-prompt-actions"></div>
395
+ </section>
396
+ </div>
397
+ </section>
398
+ </div>
399
+
400
+ <!-- Device pairing modal (issue #23): opened right after POST
401
+ /api/v1/security/enable succeeds, or when the devices section issues a
402
+ new code. Shows the one-shot 60s pairing code, the countdown, and the
403
+ copyable CLI command for the next device. Closing needs no further
404
+ action: this browser was paired by the enable response's session
405
+ cookie, so it never logs in. -->
406
+ <div id="security-pair-modal" class="workspace-prompt-modal" aria-hidden="true">
407
+ <div class="workspace-prompt-backdrop" data-security-pair-close></div>
408
+ <section class="workspace-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="security-pair-title" style="max-width:560px">
409
+ <header class="workspace-prompt-header">
410
+ <div>
411
+ <div class="workspace-prompt-kicker" data-i18n="security.devicesTitle">Device security</div>
412
+ <h2 id="security-pair-title" data-i18n="security.pairTitle">Pair your devices</h2>
413
+ </div>
414
+ <button id="security-pair-close" class="btn btn-small" type="button" data-security-pair-close data-i18n="action.close">Close</button>
415
+ </header>
416
+ <div class="workspace-prompt-body">
417
+ <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>
418
+ <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>
419
+ <div id="security-pair-countdown" style="text-align:center;font-size:12.5px;opacity:.75;margin-bottom:10px"></div>
420
+ <pre id="security-pair-command" class="worker-install-command" style="margin:0 0 12px"><code></code></pre>
421
+ <div class="workspace-prompt-actions">
422
+ <button id="security-pair-copy" class="btn" type="button" data-i18n="action.copyCommand">Copy command</button>
423
+ <button id="security-pair-new" class="btn" type="button" data-i18n="security.pairNewCode">New pairing code</button>
424
+ </div>
359
425
  </div>
360
426
  </section>
361
427
  </div>
@@ -395,19 +461,19 @@
395
461
 
396
462
  <div class="task-detail-tabs">
397
463
  <button class="task-detail-tab active" type="button" data-task-detail-tab="details">
398
- <span>Task details</span>
464
+ <span data-i18n="task.details">Task details</span>
399
465
  <span class="task-detail-tab-count" data-task-detail-tab-count="details"></span>
400
466
  </button>
401
467
  <button class="task-detail-tab" type="button" data-task-detail-tab="timeline">
402
- <span>Timeline</span>
468
+ <span data-i18n="task.timeline">Timeline</span>
403
469
  <span class="task-detail-tab-count" data-task-detail-tab-count="timeline"></span>
404
470
  </button>
405
471
  <button class="task-detail-tab" type="button" data-task-detail-tab="clarifications">
406
- <span>Clarifications</span>
472
+ <span data-i18n="tab.clarifications">Clarifications</span>
407
473
  <span class="task-detail-tab-count" data-task-detail-tab-count="clarifications"></span>
408
474
  </button>
409
475
  <button class="task-detail-tab" type="button" data-task-detail-tab="messages">
410
- <span>Messages</span>
476
+ <span data-i18n="task.messages">Messages</span>
411
477
  <span class="task-detail-tab-count" data-task-detail-tab-count="messages"></span>
412
478
  </button>
413
479
  </div>
@@ -423,8 +489,8 @@
423
489
 
424
490
  <footer class="footer">
425
491
  <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>
492
+ <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">
493
+ <button id="command-send" class="btn btn-small" data-i18n="command.send">Send to Controller</button>
428
494
  </div>
429
495
  </footer>
430
496
 
@@ -433,12 +499,12 @@
433
499
  active). -->
434
500
  <div id="tunnel-popover" class="tunnel-popover" hidden>
435
501
  <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">
502
+ <div class="tunnel-popover-card" role="dialog" aria-modal="true" data-i18n-aria="ctl.tunnel.title">
437
503
  <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>
504
+ <h3 data-i18n="ctl.tunnel.title">Internet Tunnel</h3>
505
+ <button class="tunnel-popover-close" data-act="close" type="button" aria-label="Close" data-i18n-aria="action.close">×</button>
440
506
  </div>
441
- <div class="tunnel-state"><span class="tunnel-note">loading…</span></div>
507
+ <div class="tunnel-state"><span class="tunnel-note" data-i18n="ctl.tunnel.loading">loading…</span></div>
442
508
  </div>
443
509
  </div>
444
510
 
@@ -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