@teamclaws/teamclaw 2026.8.1 → 2026.11.0

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 (125) hide show
  1. package/cli.mjs +46 -15
  2. package/dist/src/config.js +33 -2
  3. package/dist/src/controller/clarification-routes.js +315 -0
  4. package/dist/src/controller/controller-intake.js +895 -0
  5. package/dist/src/controller/controller-planning.js +813 -0
  6. package/dist/src/controller/controller-runs.js +175 -0
  7. package/dist/src/controller/controller-service.js +271 -40
  8. package/dist/src/controller/controller-tools.js +11 -6
  9. package/dist/src/controller/http-server.js +256 -6004
  10. package/dist/src/controller/kickoff-orchestrator.js +32 -6
  11. package/dist/src/controller/message-delivery.js +28 -0
  12. package/dist/src/controller/message-routes.js +114 -0
  13. package/dist/src/controller/orchestration-manifest.js +6 -28
  14. package/dist/src/controller/preview-proxy.js +98 -0
  15. package/dist/src/controller/profile-switch.js +289 -0
  16. package/dist/src/controller/project-registry.js +294 -0
  17. package/dist/src/controller/prompt-injector.js +19 -9
  18. package/dist/src/controller/repo-routes.js +63 -0
  19. package/dist/src/controller/role-inference.js +231 -20
  20. package/dist/src/controller/route-table.js +1353 -0
  21. package/dist/src/controller/task-assignment.js +508 -0
  22. package/dist/src/controller/task-cleanup.js +258 -0
  23. package/dist/src/controller/task-execution.js +240 -0
  24. package/dist/src/controller/task-results.js +461 -0
  25. package/dist/src/controller/task-router.js +74 -4
  26. package/dist/src/controller/task-routes.js +703 -0
  27. package/dist/src/controller/teamauto-routes.js +124 -0
  28. package/dist/src/controller/ui-assets.js +68 -0
  29. package/dist/src/controller/worker-provisioning.js +30 -4
  30. package/dist/src/controller/worker-routes.js +188 -0
  31. package/dist/src/identity.js +3 -2
  32. package/dist/src/interaction-contracts.js +7 -7
  33. package/dist/src/openclaw-workspace.js +40 -18
  34. package/dist/src/profile-loader.js +486 -0
  35. package/dist/src/profiles/banking.json +178 -0
  36. package/dist/src/profiles/crossborder-ecom.json +253 -0
  37. package/dist/src/profiles/insurance.json +157 -0
  38. package/dist/src/profiles/knowledge/hs-structure.md +97 -0
  39. package/dist/src/profiles/knowledge/incoterms-2020.md +188 -0
  40. package/dist/src/profiles/knowledge/vat-principles.md +85 -0
  41. package/dist/src/profiles/schema.json +201 -0
  42. package/dist/src/profiles/securities.json +137 -0
  43. package/dist/src/profiles/software-rd.json +264 -0
  44. package/dist/src/profiles/trading-co.json +200 -0
  45. package/dist/src/prompt-policy.js +26 -13
  46. package/dist/src/role-ids.js +29 -0
  47. package/dist/src/roles.js +54 -13
  48. package/dist/src/session-roles.js +14 -0
  49. package/dist/src/state.js +188 -10
  50. package/dist/src/task-executor.js +7 -17
  51. package/dist/src/teamauto/github-client.js +18 -0
  52. package/dist/src/teamauto/repo-sync.js +228 -6
  53. package/dist/src/teamauto/scanner.js +40 -12
  54. package/dist/src/teamauto/scheduler.js +231 -12
  55. package/dist/src/types.js +62 -15
  56. package/dist/src/ui/app.js +592 -24
  57. package/dist/src/ui/index.html +44 -11
  58. package/dist/src/ui/style.css +194 -0
  59. package/dist/src/worker/prompt-injector.js +44 -8
  60. package/dist/src/worker/skill-installer.js +3 -1
  61. package/dist/src/worker/worker-service.js +76 -3
  62. package/openclaw.plugin.json +28 -1
  63. package/package.json +3 -2
  64. package/src/config.ts +33 -2
  65. package/src/controller/clarification-routes.ts +404 -0
  66. package/src/controller/controller-intake.ts +1113 -0
  67. package/src/controller/controller-planning.ts +1029 -0
  68. package/src/controller/controller-runs.ts +239 -0
  69. package/src/controller/controller-service.ts +295 -41
  70. package/src/controller/controller-tools.ts +11 -7
  71. package/src/controller/http-server.ts +294 -6971
  72. package/src/controller/kickoff-orchestrator.ts +70 -7
  73. package/src/controller/message-delivery.ts +49 -0
  74. package/src/controller/message-routes.ts +137 -0
  75. package/src/controller/orchestration-manifest.ts +6 -29
  76. package/src/controller/preview-proxy.ts +127 -0
  77. package/src/controller/profile-switch.ts +366 -0
  78. package/src/controller/project-registry.ts +361 -0
  79. package/src/controller/prompt-injector.ts +23 -8
  80. package/src/controller/repo-routes.ts +91 -0
  81. package/src/controller/role-inference.ts +260 -22
  82. package/src/controller/route-table.ts +1616 -0
  83. package/src/controller/task-assignment.ts +618 -0
  84. package/src/controller/task-cleanup.ts +344 -0
  85. package/src/controller/task-execution.ts +356 -0
  86. package/src/controller/task-results.ts +544 -0
  87. package/src/controller/task-router.ts +98 -6
  88. package/src/controller/task-routes.ts +812 -0
  89. package/src/controller/teamauto-routes.ts +121 -0
  90. package/src/controller/ui-assets.ts +70 -0
  91. package/src/controller/websocket.ts +13 -1
  92. package/src/controller/worker-provisioning.ts +32 -4
  93. package/src/controller/worker-routes.ts +241 -0
  94. package/src/identity.ts +3 -2
  95. package/src/interaction-contracts.ts +7 -7
  96. package/src/openclaw-workspace.ts +44 -18
  97. package/src/profile-loader.ts +650 -0
  98. package/src/profiles/banking.json +178 -0
  99. package/src/profiles/crossborder-ecom.json +253 -0
  100. package/src/profiles/insurance.json +157 -0
  101. package/src/profiles/knowledge/hs-structure.md +97 -0
  102. package/src/profiles/knowledge/incoterms-2020.md +188 -0
  103. package/src/profiles/knowledge/vat-principles.md +85 -0
  104. package/src/profiles/schema.json +201 -0
  105. package/src/profiles/securities.json +137 -0
  106. package/src/profiles/software-rd.json +264 -0
  107. package/src/profiles/trading-co.json +200 -0
  108. package/src/prompt-policy.ts +27 -13
  109. package/src/role-ids.ts +31 -0
  110. package/src/roles.ts +60 -14
  111. package/src/session-roles.ts +14 -0
  112. package/src/state.ts +236 -9
  113. package/src/task-executor.ts +7 -18
  114. package/src/teamauto/github-client.ts +21 -0
  115. package/src/teamauto/repo-sync.ts +246 -6
  116. package/src/teamauto/scanner.ts +47 -13
  117. package/src/teamauto/scheduler.ts +259 -16
  118. package/src/teamauto/store.ts +12 -0
  119. package/src/types.ts +133 -16
  120. package/src/ui/app.js +592 -24
  121. package/src/ui/index.html +44 -11
  122. package/src/ui/style.css +194 -0
  123. package/src/worker/prompt-injector.ts +48 -8
  124. package/src/worker/skill-installer.ts +3 -1
  125. package/src/worker/worker-service.ts +83 -3
@@ -29,6 +29,9 @@
29
29
  <button id="language-toggle" class="header-mini-btn" type="button">中文</button>
30
30
  <button id="toast-settings-toggle" class="header-mini-btn" type="button" title="Toast notifications">Toasts</button>
31
31
  <button id="worker-install-toggle" class="header-mini-btn" type="button" hidden>Add worker</button>
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>
32
35
  <span id="team-name">Team</span>
33
36
  <button id="github-corner-login" class="header-mini-btn" type="button">Login</button>
34
37
  <span id="github-corner-user" class="github-corner-user hidden" role="button" tabindex="0" title="GitHub: click to sign out">
@@ -200,6 +203,11 @@
200
203
  <!-- TeamAuto Tab -->
201
204
  <div id="tab-teamauto" class="tab-panel">
202
205
  <div class="teamauto-wrap">
206
+ <div class="ta-subtabs" role="tablist">
207
+ <button type="button" class="ta-subtab active" data-ta-pane="config" data-i18n="teamauto.tabConfig">Config</button>
208
+ <button type="button" class="ta-subtab" data-ta-pane="activity" data-i18n="teamauto.activity">Activity</button>
209
+ </div>
210
+ <div class="ta-pane" data-ta-pane-body="config">
203
211
  <div class="teamauto-bind card">
204
212
  <div class="teamauto-bind-row">
205
213
  <select id="teamauto-repo-select" class="teamauto-select"></select>
@@ -224,8 +232,11 @@
224
232
  <p class="teamauto-hint" data-i18n="teamauto.hint">Pick one of your GitHub repositories. TeamClaw sweeps it on its own schedule, reviews issues/PRs, takes ownership of unassigned issues, and posts results with teamclaw markers.</p>
225
233
  </div>
226
234
  <div id="teamauto-repos" class="teamauto-repos"></div>
235
+ </div>
236
+ <div class="ta-pane is-hidden" data-ta-pane-body="activity">
227
237
  <h3 class="teamauto-section-title" data-i18n="teamauto.activity">Activity</h3>
228
238
  <div id="teamauto-activity" class="teamauto-activity"></div>
239
+ </div>
229
240
  </div>
230
241
  </div>
231
242
 
@@ -258,19 +269,11 @@
258
269
  </div>
259
270
  <div class="form-group">
260
271
  <label for="task-role" data-i18n="manualTask.assignedRole">Assigned Role</label>
272
+ <!-- Role options are rendered by app.js from GET /api/v1/roles
273
+ (renderTaskRoleOptions) so profile-driven role sets need no
274
+ HTML change. Only the Auto-assign placeholder lives here. -->
261
275
  <select id="task-role">
262
276
  <option value="" data-i18n="manualTask.autoAssign">Auto-assign</option>
263
- <option value="pm">Product Manager</option>
264
- <option value="architect">Software Architect</option>
265
- <option value="developer">Developer</option>
266
- <option value="qa">QA Engineer</option>
267
- <option value="release-engineer">Release Engineer</option>
268
- <option value="infra-engineer">Infra Engineer</option>
269
- <option value="devops">DevOps Engineer</option>
270
- <option value="security-engineer">Security Engineer</option>
271
- <option value="designer">UI/UX Designer</option>
272
- <option value="marketing">Marketing Specialist</option>
273
- <option value="data-engineer">Data Engineer</option>
274
277
  </select>
275
278
  </div>
276
279
  </div>
@@ -327,6 +330,36 @@
327
330
  </section>
328
331
  </div>
329
332
 
333
+ <!-- Team profile switcher modal (Phase 5.1): step 1 lists
334
+ GET /api/v1/profiles cards, step 2 confirms the archive consequences
335
+ before POST /api/v1/team/profile; the archived-teams section lists
336
+ GET /api/v1/archived-teams metadata (read-only). -->
337
+ <div id="team-profile-modal" class="workspace-prompt-modal" aria-hidden="true">
338
+ <div class="workspace-prompt-backdrop" data-team-profile-close></div>
339
+ <section class="workspace-prompt-panel team-profile-panel" role="dialog" aria-modal="true" aria-labelledby="team-profile-title">
340
+ <header class="workspace-prompt-header">
341
+ <div class="workspace-prompt-kicker" data-i18n="teamProfile.kicker">Team profile</div>
342
+ <h2 id="team-profile-title" data-i18n="teamProfile.title">Switch team profile</h2>
343
+ </header>
344
+ <div class="workspace-prompt-body">
345
+ <div id="team-profile-transition" class="team-profile-transition" hidden></div>
346
+ <div id="team-profile-list" class="team-profile-list"></div>
347
+ <div id="team-profile-confirm" class="team-profile-confirm" hidden>
348
+ <div id="team-profile-confirm-body" class="team-profile-confirm-body"></div>
349
+ <div class="workspace-prompt-actions">
350
+ <button id="team-profile-confirm-btn" class="btn btn-primary" type="button" data-i18n="teamProfile.confirmButton">Switch team</button>
351
+ <button id="team-profile-confirm-back" class="btn btn-small" type="button" data-i18n="teamProfile.cancel">Back</button>
352
+ </div>
353
+ </div>
354
+ <p id="team-profile-switch-status" class="team-profile-switch-status" hidden></p>
355
+ <section class="team-profile-archived">
356
+ <h3 data-i18n="teamProfile.archivedTitle">Archived teams</h3>
357
+ <div id="team-profile-archives" class="team-profile-archives"></div>
358
+ </section>
359
+ </div>
360
+ </section>
361
+ </div>
362
+
330
363
  <div id="clarification-prompt-modal" class="clarification-prompt-modal" aria-hidden="true">
331
364
  <div class="clarification-prompt-backdrop" data-clarification-prompt-close></div>
332
365
  <section class="clarification-prompt-panel" role="dialog" aria-modal="true" aria-labelledby="clarification-prompt-title">
@@ -652,6 +652,28 @@ body {
652
652
  color: var(--text-secondary);
653
653
  }
654
654
 
655
+ /* TeamAuto sub-tabs (Config / Activity) */
656
+ .ta-subtabs {
657
+ display: flex;
658
+ gap: 8px;
659
+ margin-bottom: 12px;
660
+ }
661
+ .ta-subtab {
662
+ border: 1px solid var(--border-color, rgba(255,255,255,0.15));
663
+ background: transparent;
664
+ color: var(--text-secondary);
665
+ border-radius: 8px;
666
+ padding: 4px 14px;
667
+ font-size: 12px;
668
+ cursor: pointer;
669
+ }
670
+ .ta-subtab.active {
671
+ background: var(--accent-soft, rgba(226,183,111,0.15));
672
+ color: var(--accent, #e2b76f);
673
+ border-color: var(--accent, #e2b76f);
674
+ }
675
+ .ta-pane.is-hidden { display: none; }
676
+
655
677
  .clarification-reason,
656
678
  .clarification-context,
657
679
  .clarification-answer {
@@ -660,6 +682,46 @@ body {
660
682
  line-height: 1.5;
661
683
  }
662
684
 
685
+ /* Markdown-rendered clarification context (worker-authored) */
686
+ .clarification-context-md h1,
687
+ .clarification-context-md h2,
688
+ .clarification-context-md h3,
689
+ .clarification-context-md h4 {
690
+ font-size: 13px;
691
+ font-weight: 600;
692
+ margin: 10px 0 4px;
693
+ color: var(--text-primary);
694
+ }
695
+ .clarification-context-md p { margin: 6px 0; }
696
+ .clarification-context-md ul,
697
+ .clarification-context-md ol { margin: 6px 0; padding-left: 18px; }
698
+ .clarification-context-md li { margin: 2px 0; }
699
+ .clarification-context-md code {
700
+ font-family: var(--font-mono, ui-monospace, monospace);
701
+ font-size: 12px;
702
+ background: var(--bg-tertiary, rgba(255,255,255,0.06));
703
+ padding: 1px 4px;
704
+ border-radius: 4px;
705
+ }
706
+ .clarification-context-md pre {
707
+ margin: 8px 0;
708
+ padding: 8px 10px;
709
+ overflow-x: auto;
710
+ background: var(--bg-tertiary, rgba(255,255,255,0.06));
711
+ border-radius: 6px;
712
+ }
713
+ .clarification-context-md pre code { background: none; padding: 0; }
714
+ .clarification-context-md blockquote {
715
+ margin: 6px 0;
716
+ padding: 2px 10px;
717
+ border-left: 3px solid var(--border-color, rgba(255,255,255,0.15));
718
+ color: var(--text-secondary);
719
+ }
720
+ .clarification-context-md table { border-collapse: collapse; margin: 8px 0; font-size: 12px; }
721
+ .clarification-context-md th,
722
+ .clarification-context-md td { border: 1px solid var(--border-color, rgba(255,255,255,0.15)); padding: 4px 8px; }
723
+ .clarification-context-md a { color: var(--accent, #e2b76f); }
724
+
663
725
  .clarification-answer-meta {
664
726
  color: var(--text-secondary);
665
727
  font-size: 12px;
@@ -2609,3 +2671,135 @@ body {
2609
2671
  .tunnel-popover-card .tunnel-on { word-break: break-all; }
2610
2672
  .tunnel-note { margin-left: 10px; color: var(--text-muted); font-size: 12px; }
2611
2673
  .tunnel-err { color: var(--danger); font-size: 12.5px; margin-top: 8px; }
2674
+
2675
+ /* ==================== Team profile switcher (Phase 5.1) ==================== */
2676
+ /* Capability gate (GET /team/profile capabilities.teamauto): the tab node is
2677
+ hidden, not removed, so the DOM keeps the full 7-tab contract. `.tab`
2678
+ sets display:inline-flex which would beat the UA [hidden] rule, so the
2679
+ hidden state needs an explicit rule. */
2680
+ .tab[hidden] { display: none; }
2681
+
2682
+ .team-profile-toggle {
2683
+ max-width: 220px;
2684
+ overflow: hidden;
2685
+ text-overflow: ellipsis;
2686
+ white-space: nowrap;
2687
+ }
2688
+
2689
+ .team-profile-panel { max-width: 640px; }
2690
+
2691
+ .team-profile-transition {
2692
+ margin: 0 0 10px;
2693
+ padding: 8px 12px;
2694
+ border-radius: 8px;
2695
+ font-size: 12.5px;
2696
+ background: rgba(230, 162, 60, 0.12);
2697
+ border: 1px solid rgba(230, 162, 60, 0.4);
2698
+ color: var(--warning, #e6a23c);
2699
+ }
2700
+
2701
+ .team-profile-list {
2702
+ display: flex;
2703
+ flex-direction: column;
2704
+ gap: 10px;
2705
+ margin: 6px 0 4px;
2706
+ }
2707
+
2708
+ .team-profile-card {
2709
+ display: flex;
2710
+ align-items: flex-start;
2711
+ gap: 12px;
2712
+ width: 100%;
2713
+ box-sizing: border-box;
2714
+ text-align: left;
2715
+ padding: 12px 14px;
2716
+ border-radius: 10px;
2717
+ border: 1px solid var(--border);
2718
+ background: var(--bg-tertiary);
2719
+ color: var(--text-primary);
2720
+ cursor: pointer;
2721
+ }
2722
+ .team-profile-card:hover { border-color: var(--accent); }
2723
+ .team-profile-card.active {
2724
+ border-color: var(--accent);
2725
+ background: rgba(217, 166, 100, 0.08);
2726
+ cursor: default;
2727
+ }
2728
+ .team-profile-card.is-locked { opacity: 0.6; }
2729
+
2730
+ .team-profile-card-icon { font-size: 20px; line-height: 1.3; }
2731
+ .team-profile-card-main {
2732
+ flex: 1;
2733
+ min-width: 0;
2734
+ display: flex;
2735
+ flex-direction: column;
2736
+ gap: 3px;
2737
+ }
2738
+ .team-profile-card-name { font-weight: 600; font-size: 13.5px; }
2739
+ .team-profile-card-name-alt { font-weight: 400; opacity: 0.65; font-size: 12.5px; }
2740
+ .team-profile-card-desc { font-size: 12.5px; opacity: 0.75; line-height: 1.45; }
2741
+ .team-profile-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
2742
+
2743
+ .team-profile-chip {
2744
+ display: inline-block;
2745
+ padding: 1px 8px;
2746
+ border-radius: 999px;
2747
+ font-size: 11px;
2748
+ border: 1px solid var(--border);
2749
+ opacity: 0.85;
2750
+ }
2751
+ .team-profile-chip.pending {
2752
+ border-color: rgba(230, 162, 60, 0.5);
2753
+ background: rgba(230, 162, 60, 0.14);
2754
+ color: var(--warning, #e6a23c);
2755
+ opacity: 1;
2756
+ }
2757
+ .team-profile-card-current {
2758
+ flex-shrink: 0;
2759
+ padding: 2px 10px;
2760
+ border-radius: 999px;
2761
+ font-size: 11px;
2762
+ border: 1px solid var(--accent);
2763
+ color: var(--accent);
2764
+ }
2765
+
2766
+ .team-profile-confirm-body h3 { margin: 2px 0 10px; font-size: 15px; }
2767
+ .team-profile-confirm-warning {
2768
+ margin: 6px 0;
2769
+ padding: 8px 12px;
2770
+ border-radius: 8px;
2771
+ font-size: 12.5px;
2772
+ background: rgba(230, 90, 90, 0.1);
2773
+ border: 1px solid rgba(230, 90, 90, 0.35);
2774
+ color: var(--danger, #ff7b7b);
2775
+ }
2776
+
2777
+ .team-profile-switch-status {
2778
+ margin: 8px 0 0;
2779
+ font-size: 12.5px;
2780
+ opacity: 0.75;
2781
+ }
2782
+
2783
+ .team-profile-archived {
2784
+ margin-top: 16px;
2785
+ padding-top: 10px;
2786
+ border-top: 1px solid rgba(255, 255, 255, 0.08);
2787
+ }
2788
+ .team-profile-archived h3 { margin: 0 0 8px; font-size: 13px; opacity: 0.8; }
2789
+ .team-profile-archives {
2790
+ max-height: 180px;
2791
+ overflow-y: auto;
2792
+ display: flex;
2793
+ flex-direction: column;
2794
+ gap: 6px;
2795
+ }
2796
+ .team-profile-archive-row {
2797
+ display: flex;
2798
+ flex-wrap: wrap;
2799
+ gap: 10px;
2800
+ align-items: baseline;
2801
+ font-size: 12.5px;
2802
+ }
2803
+ .team-profile-archive-team { font-weight: 600; }
2804
+ .team-profile-archive-profile { opacity: 0.7; }
2805
+ .team-profile-archive-meta { margin-left: auto; opacity: 0.6; font-size: 12px; }
@@ -1,23 +1,59 @@
1
- import { getRole } from "../roles.js";
2
- import { buildWorkerSessionRules, composePrompt } from "../prompt-policy.js";
3
- const TEAMCLAW_ROLE_IDS_TEXT = [
4
- "pm", "architect", "developer", "qa",
5
- "release-engineer", "infra-engineer", "devops", "security-engineer",
6
- "designer", "marketing", "data-engineer",
7
- ];
1
+ // Phase 1.3: the worker role prompt comes from the active TeamProfile.
2
+ import { getActiveDomainInstructions, getActiveKnowledgePacks, getActiveRole } from "../profile-loader.js";
3
+ import { buildRoleOperatingRules, buildWorkerSessionRules, composePrompt } from "../prompt-policy.js";
4
+ // Phase 1.2: the local TEAMCLAW_ROLE_IDS_TEXT copy that used to live here was
5
+ // dead code (no references) and duplicated the canonical role id list; the
6
+ // shared text is exported from prompt-policy.ts (TEAMCLAW_ROLE_IDS_TEXT).
7
+ // Phase 4 hard rule appended to every Reference Packs section (zero-cost
8
+ // exception, design 3 Phase 4): the packs ground stable concepts, and
9
+ // everything time-sensitive stays TBD + authoritative-source-driven.
10
+ const KNOWLEDGE_PACK_HARD_RULE = "When answering, prefer these pack definitions over memory; "
11
+ + "for anything time-sensitive (rates, thresholds, regulations), direct the user to current "
12
+ + "authoritative sources and mark TBD.";
13
+ function buildKnowledgePackSection(packs) {
14
+ const lines = ["", "## Reference Packs"];
15
+ for (const pack of packs) {
16
+ lines.push(`### ${pack.name}`);
17
+ lines.push(pack.content.trimEnd());
18
+ lines.push("");
19
+ }
20
+ lines.push(KNOWLEDGE_PACK_HARD_RULE);
21
+ return lines;
22
+ }
8
23
  export function createWorkerPromptInjector(config, getIdentity, messageQueue) {
9
24
  return () => {
10
25
  const identity = getIdentity();
11
26
  if (!identity) {
12
27
  return null;
13
28
  }
14
- const roleDef = getRole(identity.role);
29
+ const roleDef = getActiveRole(identity.role);
15
30
  if (!roleDef) {
16
31
  return null;
17
32
  }
33
+ // Phase 2.4 (design 2.4): when the active profile carries industry
34
+ // guardrails they REPLACE the software operating rules and are assembled
35
+ // right after the role systemPrompt. Profiles without domainInstructions
36
+ // (software-rd) inject nothing here - the operating contract is already
37
+ // pre-composed into their systemPrompt - so the worker prompt bytes are
38
+ // unchanged (Phase 1.7 golden).
39
+ const domainInstructions = getActiveDomainInstructions();
40
+ // Phase 4 static knowledge packs (design 2.1/2.2, 3 Phase 4 exception):
41
+ // appended right after the operating contract, only when the active
42
+ // profile declares them. software-rd carries none, so the section (and
43
+ // every byte around it) stays absent - the Phase 1.7 goldens keep the
44
+ // baseline worker prompt byte-identical.
45
+ const knowledgePacks = getActiveKnowledgePacks();
18
46
  const parts = [
19
47
  `## TeamClaw Role: ${roleDef.label} ${roleDef.icon}`,
20
48
  roleDef.systemPrompt,
49
+ ...(domainInstructions
50
+ ? buildRoleOperatingRules({
51
+ suggestedRoles: roleDef.suggestedNextRoles,
52
+ recommendedSkills: roleDef.recommendedSkills,
53
+ domainInstructions,
54
+ })
55
+ : []),
56
+ ...(knowledgePacks.length > 0 ? buildKnowledgePackSection(knowledgePacks) : []),
21
57
  ...buildWorkerSessionRules(),
22
58
  "Important: submit structured collaboration contracts for all handoffs, reviews, progress updates, and result deliveries so the controller can route work without parsing freeform prose.",
23
59
  "Do not use sessions_yield or end your turn while background work, coding agents, or process sessions are still running.",
@@ -1,7 +1,9 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { normalizeRecommendedSkills } from "../roles.js";
4
+ // Phase 1.3: recommended-skill normalization lives on the profile loader
5
+ // face (same semantics as the registry helper).
6
+ import { normalizeRecommendedSkills } from "../profile-loader.js";
5
7
  import { resolveTeamClawWorkspaceDir } from "../openclaw-workspace.js";
6
8
  const ON_DEMAND_DISCOVERY_SKILLS = new Set(["find-skills"]);
7
9
  function truncateOutput(value, limit = 400) {
@@ -1,9 +1,40 @@
1
+ import fs from "node:fs";
1
2
  import http from "node:http";
2
3
  import { createHeartbeatPayload } from "../protocol.js";
3
4
  import { IdentityManager } from "../identity.js";
4
5
  import { MessageQueue } from "./message-queue.js";
5
6
  import { createWorkerHttpHandler } from "./http-handler.js";
6
7
  import { buildTeamClawAgentSessionKey, ensureOpenClawWorkspaceMemoryDir } from "../openclaw-workspace.js";
8
+ /**
9
+ * Issue #27: container detection mirrors the controller's resolve step in
10
+ * controller-service.ts (/.dockerenv, /run/.containerenv, or the Kubernetes
11
+ * service env). Inside Docker/K8s the worker must bind all interfaces so
12
+ * port mapping, service networking, and the controller can reach it; on a
13
+ * host it stays loopback by default.
14
+ */
15
+ export function detectWorkerContainerEnvironment() {
16
+ return fs.existsSync("/.dockerenv") ||
17
+ fs.existsSync("/run/.containerenv") ||
18
+ process.env.KUBERNETES_SERVICE_HOST !== undefined;
19
+ }
20
+ /**
21
+ * Issue #27: worker HTTP bind address resolution. Precedence:
22
+ * 1. explicit `listenHost` config (overrides everything),
23
+ * 2. 0.0.0.0 inside containers (Docker/K8s),
24
+ * 3. 127.0.0.1 loopback default on hosts.
25
+ * Previously `listen(config.port)` bound `::` (all interfaces) everywhere,
26
+ * exposing the unauthenticated task/message endpoints to the whole network.
27
+ */
28
+ export function resolveWorkerListenHost(config) {
29
+ const explicit = config.listenHost?.trim();
30
+ if (explicit) {
31
+ return explicit;
32
+ }
33
+ return detectWorkerContainerEnvironment() ? "0.0.0.0" : "127.0.0.1";
34
+ }
35
+ function isLoopbackHost(host) {
36
+ return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
37
+ }
7
38
  export function createWorkerService(deps) {
8
39
  const { config, logger, onIdentityEstablished, taskExecutor: externalTaskExecutor } = deps;
9
40
  let identityManager;
@@ -16,6 +47,33 @@ export function createWorkerService(deps) {
16
47
  const activeTaskSessionKeys = new Map();
17
48
  const cancelledTaskIds = new Set();
18
49
  let consecutiveHeartbeatFailures = 0;
50
+ let warnedLoopbackReachability = false;
51
+ // Issue #27: with the loopback bind default, an external worker (controller
52
+ // on another host) still advertises its LAN IP (identity.ts getLocalIp),
53
+ // so the controller could never reach it. Surface that mismatch once
54
+ // instead of failing silently; `listenHost` is the escape hatch.
55
+ function warnIfLoopbackBindBlocksRemoteController(targetControllerUrl) {
56
+ if (warnedLoopbackReachability) {
57
+ return;
58
+ }
59
+ const listenHost = resolveWorkerListenHost(config);
60
+ if (!isLoopbackHost(listenHost)) {
61
+ return;
62
+ }
63
+ let controllerHost;
64
+ try {
65
+ controllerHost = new URL(targetControllerUrl).hostname;
66
+ }
67
+ catch {
68
+ return;
69
+ }
70
+ if (!controllerHost || isLoopbackHost(controllerHost)) {
71
+ return;
72
+ }
73
+ warnedLoopbackReachability = true;
74
+ logger.warn(`Worker: HTTP server is bound to loopback (${listenHost}) but the controller is at ${targetControllerUrl} (different host) - the controller cannot reach this worker. ` +
75
+ `Set the "listenHost" plugin config (e.g. "0.0.0.0" or this machine's LAN address) for external-worker deployments.`);
76
+ }
19
77
  const taskExecutor = externalTaskExecutor
20
78
  ? async (assignment) => {
21
79
  const taskId = assignment.taskId;
@@ -132,12 +190,25 @@ export function createWorkerService(deps) {
132
190
  await new Promise((resolve) => server.close(() => resolve()));
133
191
  }
134
192
  server = http.createServer(handler);
193
+ const listenHost = resolveWorkerListenHost(config);
135
194
  await new Promise((resolve, reject) => {
136
- server.listen(config.port, () => {
137
- logger.info(`Worker: HTTP server listening on port ${config.port}`);
195
+ server.listen(config.port, listenHost, () => {
196
+ logger.info(`Worker: HTTP server listening on ${listenHost}:${config.port}`);
138
197
  resolve();
139
198
  });
140
- server.on("error", reject);
199
+ server.on("error", (err) => {
200
+ if (err.code === "EADDRINUSE") {
201
+ // Issue #27: the worker default port is also the controller default,
202
+ // so same-host dual-process setups crash here with no pointer.
203
+ reject(new Error(`Worker: cannot listen on ${listenHost}:${config.port} - address already in use` +
204
+ (config.port === 9527
205
+ ? ". Port 9527 is also the controller default; when running a controller and this worker on the same host, point this worker's \`port\` config at another value"
206
+ : "") +
207
+ ". Adjust the `port` and `listenHost` plugin config keys to change the bind address."));
208
+ return;
209
+ }
210
+ reject(err);
211
+ });
141
212
  });
142
213
  }
143
214
  return {
@@ -157,6 +228,7 @@ export function createWorkerService(deps) {
157
228
  controllerUrl = identity.controllerUrl;
158
229
  workerId = identity.workerId;
159
230
  onIdentityEstablished(identity);
231
+ warnIfLoopbackBindBlocksRemoteController(controllerUrl);
160
232
  // Restart server with worker ID and task executor
161
233
  await startServer();
162
234
  }
@@ -168,6 +240,7 @@ export function createWorkerService(deps) {
168
240
  controllerUrl = newIdentity.controllerUrl;
169
241
  workerId = newIdentity.workerId;
170
242
  onIdentityEstablished(newIdentity);
243
+ warnIfLoopbackBindBlocksRemoteController(controllerUrl);
171
244
  await startServer();
172
245
  }
173
246
  return;
@@ -2,7 +2,7 @@
2
2
  "id": "teamclaw",
3
3
  "name": "TeamClaw",
4
4
  "description": "Virtual team collaboration - multiple OpenClaw instances form a virtual software company with role-based task routing.",
5
- "version": "2026.8.1",
5
+ "version": "2026.11.0",
6
6
  "activation": {
7
7
  "onStartup": true
8
8
  },
@@ -40,6 +40,10 @@
40
40
  "label": "Port",
41
41
  "help": "HTTP server port for this instance"
42
42
  },
43
+ "listenHost": {
44
+ "label": "Listen Host",
45
+ "help": "HTTP bind address override; empty defaults to 127.0.0.1 on hosts and 0.0.0.0 in containers. Use 0.0.0.0 when a remote controller must reach this worker"
46
+ },
43
47
  "role": {
44
48
  "label": "Role",
45
49
  "help": "Worker role (worker mode only)"
@@ -52,6 +56,10 @@
52
56
  "label": "Team Name",
53
57
  "help": "Team identifier for mDNS"
54
58
  },
59
+ "teamProfile": {
60
+ "label": "Team Profile",
61
+ "help": "Team profile package id; applies to the first team initialization only (Phase 2 adds profile switching)"
62
+ },
55
63
  "heartbeatIntervalMs": {
56
64
  "label": "Heartbeat Interval",
57
65
  "help": "In milliseconds, minimum 1000"
@@ -60,6 +68,10 @@
60
68
  "label": "Task Stall Threshold",
61
69
  "help": "In milliseconds, how long TeamClaw waits without visible progress before probing the task instead of failing it"
62
70
  },
71
+ "teamSwitchDrainTimeoutMs": {
72
+ "label": "Profile Switch Drain Timeout",
73
+ "help": "In milliseconds, how long a team profile switch waits for in-flight tasks to finish before force-collecting them"
74
+ },
63
75
  "maxConcurrentTasks": {
64
76
  "label": "Max Concurrent Tasks",
65
77
  "hint": "number",
@@ -208,6 +220,11 @@
208
220
  "default": 9527,
209
221
  "description": "HTTP server port for this instance"
210
222
  },
223
+ "listenHost": {
224
+ "type": "string",
225
+ "default": "",
226
+ "description": "HTTP listen host override (empty = 127.0.0.1 on hosts, 0.0.0.0 in containers); set 0.0.0.0 for external workers reachable by a remote controller"
227
+ },
211
228
  "role": {
212
229
  "type": "string",
213
230
  "default": "developer",
@@ -223,6 +240,11 @@
223
240
  "default": "TeamClaw",
224
241
  "description": "Team name for mDNS identification"
225
242
  },
243
+ "teamProfile": {
244
+ "type": "string",
245
+ "default": "software-rd",
246
+ "description": "Team profile package id (software-rd baseline); seeds first initialization only - the persisted team state profile is the runtime truth"
247
+ },
226
248
  "heartbeatIntervalMs": {
227
249
  "type": "number",
228
250
  "default": 10000,
@@ -233,6 +255,11 @@
233
255
  "default": 600000,
234
256
  "description": "Inactivity threshold in milliseconds before TeamClaw probes a stalled role task instead of failing it"
235
257
  },
258
+ "teamSwitchDrainTimeoutMs": {
259
+ "type": "number",
260
+ "default": 30000,
261
+ "description": "How long a team profile switch waits for in-flight tasks to finish before force-collecting them (design 2.3 graceful drain)"
262
+ },
236
263
  "maxConcurrentTasks": {
237
264
  "type": "integer",
238
265
  "default": 5,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamclaws/teamclaw",
3
- "version": "2026.8.1",
3
+ "version": "2026.11.0",
4
4
  "description": "OpenClaw virtual software team orchestration plugin - controller, role-based workers, Web UI with internet tunnel sharing",
5
5
  "private": false,
6
6
  "keywords": [
@@ -45,8 +45,9 @@
45
45
  "tsconfig.build.json"
46
46
  ],
47
47
  "scripts": {
48
- "build": "tsc -p tsconfig.build.json && node -e \"require('fs').cpSync('src/ui','dist/src/ui',{recursive:true})\"",
48
+ "build": "tsc -p tsconfig.build.json && node -e \"const fs=require('fs');fs.cpSync('src/ui','dist/src/ui',{recursive:true});fs.cpSync('src/profiles','dist/src/profiles',{recursive:true})\"",
49
49
  "manifest:sync": "cd .. && node scripts/sync-teamclaw-plugin-manifest.mjs src",
50
+ "profile:sync": "cd .. && node scripts/generate-software-rd-profile.mjs src",
50
51
  "pack:dry-run": "npm pack --dry-run --json --ignore-scripts",
51
52
  "release:check": "cd .. && node scripts/teamclaw-package-check.mjs src",
52
53
  "release:clawhub:dry-run": "cd .. && bash scripts/teamclaw-clawhub-release.sh --dry-run"