@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; }
@@ -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,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) {