@teamclaws/teamclaw 2026.11.1 → 2026.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,6 +76,15 @@
76
76
  "tab.planning": "Planning",
77
77
  "tab.tasks": "Tasks",
78
78
  "tab.workspace": "Workspace",
79
+ "common.showOlder": "Show older ({n})",
80
+ "tab.settings": "Settings",
81
+ "settings.models.title": "Model settings",
82
+ "settings.models.hint": "Default model and per-role overrides.",
83
+ "settings.workers.title": "Worker scaling (hot)",
84
+ "settings.workers.hint": "Applies immediately without restarting the gateway. Lowering a cap never kills busy workers.",
85
+ "settings.workers.max": "Max workers / role",
86
+ "settings.workers.min": "Min warm / role",
87
+ "settings.workers.ttl": "Idle TTL (ms)",
79
88
  "tab.teamauto": "TeamAuto",
80
89
  "tab.clarifications": "Clarifications",
81
90
  "tab.messages": "Messages",
@@ -362,6 +371,15 @@
362
371
  "tab.planning": "规划",
363
372
  "tab.tasks": "任务",
364
373
  "tab.workspace": "工作区",
374
+ "common.showOlder": "显示更早({n})",
375
+ "tab.settings": "设置",
376
+ "settings.models.title": "模型设置",
377
+ "settings.models.hint": "默认模型与按角色覆盖。",
378
+ "settings.workers.title": "Worker 弹性伸缩(热)",
379
+ "settings.workers.hint": "立即生效无需重启 gateway。下调上限不会终止忙碌 worker。",
380
+ "settings.workers.max": "每角色最大 worker",
381
+ "settings.workers.min": "每角色保活下限",
382
+ "settings.workers.ttl": "空闲回收 TTL(毫秒)",
365
383
  "tab.teamauto": "TeamAuto",
366
384
  "tab.clarifications": "澄清",
367
385
  "tab.messages": "消息",
@@ -1417,12 +1435,16 @@
1417
1435
  var selectedPlanningRunId = null;
1418
1436
 
1419
1437
  function renderPlanningTab(runs) {
1438
+ lastRenderedData.planning = runs || [];
1420
1439
  var sessionList = $("#planning-session-list");
1421
1440
  if (!sessionList) return;
1422
1441
 
1423
1442
  var planningRuns = (runs || [])
1424
1443
  .filter(function (r) { return r && r.manifest; })
1425
1444
  .sort(function (a, b) { return (b.updatedAt || 0) - (a.updatedAt || 0); });
1445
+ var planningWindow = splitByRecency(planningRuns, function (r) { return r.updatedAt || r.createdAt; }, "planning");
1446
+ planningRuns = planningWindow.shown;
1447
+ var planningOlderHtml = olderToggleHtml(planningWindow.olderCount, "planning");
1426
1448
 
1427
1449
  if (planningRuns.length === 0) {
1428
1450
  sessionList.innerHTML = '<div class="empty-state">' + escapeHtml(t("empty.noPlanningSessions")) + "</div>";
@@ -1452,7 +1474,7 @@
1452
1474
  ' <div class="planning-session-meta">' + escapeHtml(humanizeStatus(status)) + " · " + roles + " roles" + (assessments.length ? " · " + needed + " confirmed" : "") + " · " + escapeHtml(formatTime(run.updatedAt) || "") + "</div>" +
1453
1475
  "</button>"
1454
1476
  );
1455
- }).join("");
1477
+ }).join("") + planningOlderHtml;
1456
1478
 
1457
1479
  // Render selected run
1458
1480
  renderPlanningDetail(planningRuns.find(function (r) { return r.id === selectedPlanningRunId; }));
@@ -3078,7 +3100,38 @@
3078
3100
  return haystack.includes(keyword);
3079
3101
  }
3080
3102
 
3103
+ // ---- 24h recency window + lazy "show older" (#recent-window) ----
3104
+ // Planning / Tasks / Clarifications / Messages only list items from the
3105
+ // last 24h by default; older items appear after an explicit click.
3106
+ const TWENTY_FOUR_H_MS = 24 * 60 * 60 * 1000;
3107
+ const showOlderSections = { tasks: false, planning: false, clarifications: false, messages: false };
3108
+ const lastRenderedData = { tasks: [], planning: [], clarifications: [], messages: [] };
3109
+ function splitByRecency(items, tsOf, section) {
3110
+ const cutoff = Date.now() - TWENTY_FOUR_H_MS;
3111
+ const recent = [];
3112
+ const older = [];
3113
+ for (const item of items || []) {
3114
+ ((tsOf(item) || 0) >= cutoff ? recent : older).push(item);
3115
+ }
3116
+ return showOlderSections[section] ? { shown: recent.concat(older), olderCount: 0 } : { shown: recent, olderCount: older.length };
3117
+ }
3118
+ function olderToggleHtml(count, section) {
3119
+ if (!count) return "";
3120
+ return '<div style="text-align:center;padding:8px"><button type="button" class="btn btn-small" data-show-older="' + section + '">' +
3121
+ escapeHtml(t("common.showOlder", { n: count })) + "</button></div>";
3122
+ }
3123
+ document.addEventListener("click", function (event) {
3124
+ const btn = event.target instanceof Element && event.target.closest("[data-show-older]");
3125
+ if (!btn || btn.tagName !== "BUTTON") return;
3126
+ showOlderSections[btn.getAttribute("data-show-older")] = true;
3127
+ renderTasks(lastRenderedData.tasks);
3128
+ renderPlanningTab(lastRenderedData.planning);
3129
+ renderClarifications(lastRenderedData.clarifications);
3130
+ renderMessages(lastRenderedData.messages);
3131
+ });
3132
+
3081
3133
  function renderTasks(tasks) {
3134
+ lastRenderedData.tasks = tasks || [];
3082
3135
  const container = $("#tasks-board");
3083
3136
  if (!container) return;
3084
3137
 
@@ -3099,10 +3152,13 @@
3099
3152
  }
3100
3153
 
3101
3154
  const sorted = filtered.slice().sort(taskComparator);
3155
+ // #recent-window: 24h recency first, older tasks behind the lazy toggle
3156
+ // (applied before the terminal chunking, so both windows stay fast).
3157
+ const recency = splitByRecency(sorted, function (task) { return task.updatedAt || task.createdAt; }, "tasks");
3102
3158
  // Active tasks render in full; terminal ones chunk so long-lived installs
3103
3159
  // with hundreds of completed tasks stay fast and meaningful.
3104
- const activeTasks = sorted.filter(function (task) { return !TERMINAL_STATUSES[task.status]; });
3105
- const terminalTasks = sorted.filter(function (task) { return TERMINAL_STATUSES[task.status]; });
3160
+ const activeTasks = recency.shown.filter(function (task) { return !TERMINAL_STATUSES[task.status]; });
3161
+ const terminalTasks = recency.shown.filter(function (task) { return TERMINAL_STATUSES[task.status]; });
3106
3162
  const visibleTerminal = terminalTasks.slice(0, terminalTasksVisible);
3107
3163
  const hiddenTerminal = terminalTasks.length - visibleTerminal.length;
3108
3164
  const visibleList = activeTasks.concat(visibleTerminal);
@@ -3154,7 +3210,7 @@
3154
3210
  " </div>" +
3155
3211
  "</div>"
3156
3212
  );
3157
- }).join("") + showMoreHtml;
3213
+ }).join("") + showMoreHtml + olderToggleHtml(recency.olderCount, "tasks");
3158
3214
 
3159
3215
  const showMoreBtn = $("#tasks-show-more");
3160
3216
  if (showMoreBtn) {
@@ -3808,6 +3864,7 @@
3808
3864
  }
3809
3865
 
3810
3866
  function renderClarifications(clarifications) {
3867
+ lastRenderedData.clarifications = clarifications || [];
3811
3868
  const container = $("#clarifications-list");
3812
3869
  if (!container) return;
3813
3870
 
@@ -3816,14 +3873,21 @@
3816
3873
  return;
3817
3874
  }
3818
3875
 
3819
- container.innerHTML = renderClarificationCards(sortClarifications(clarifications), { linkToTask: true });
3876
+ const clWindow = splitByRecency(sortClarifications(clarifications), function (c) { return c.createdAt || c.updatedAt; }, "clarifications");
3877
+ if (clWindow.shown.length === 0) {
3878
+ container.innerHTML = olderToggleHtml(clWindow.olderCount, "clarifications");
3879
+ return;
3880
+ }
3881
+ container.innerHTML = renderClarificationCards(clWindow.shown, { linkToTask: true }) +
3882
+ olderToggleHtml(clWindow.olderCount, "clarifications");
3820
3883
  }
3821
3884
 
3822
3885
  function renderMessages(messages) {
3886
+ lastRenderedData.messages = messages || [];
3823
3887
  const container = $("#messages-feed");
3824
3888
  if (!container) return;
3825
3889
 
3826
- const recent = (messages || [])
3890
+ var recent = (messages || [])
3827
3891
  .concat(controllerConversation || [])
3828
3892
  .sort(function (left, right) {
3829
3893
  return (right.createdAt || 0) - (left.createdAt || 0);
@@ -3834,7 +3898,13 @@
3834
3898
  return;
3835
3899
  }
3836
3900
 
3837
- container.innerHTML = renderMessageCards(recent);
3901
+ const msgWindow = splitByRecency(recent, function (m) { return m.createdAt; }, "messages");
3902
+ if (msgWindow.shown.length === 0) {
3903
+ container.innerHTML = olderToggleHtml(msgWindow.olderCount, "messages");
3904
+ return;
3905
+ }
3906
+ container.innerHTML = renderMessageCards(msgWindow.shown) +
3907
+ olderToggleHtml(msgWindow.olderCount, "messages");
3838
3908
  }
3839
3909
 
3840
3910
  function renderRoles(roles) {
@@ -4058,6 +4128,9 @@
4058
4128
  if (activeTab === "workspace") {
4059
4129
  refreshWorkspaceTree(false);
4060
4130
  }
4131
+ if (activeTab === "settings") {
4132
+ renderWorkerSettingsPanel();
4133
+ }
4061
4134
  if (activeTab === "teamauto") {
4062
4135
  refreshTeamAutoTab();
4063
4136
  }
@@ -5050,10 +5123,13 @@
5050
5123
  opener.setAttribute("data-i18n", "ctl.tab.models");
5051
5124
  opener.textContent = t("ctl.tab.models");
5052
5125
  var refreshBtn = document.querySelector("#workspace-tree-refresh");
5053
- if (refreshBtn && refreshBtn.parentElement) {
5054
- refreshBtn.parentElement.appendChild(opener);
5055
- opener.addEventListener("click", openModelSettings);
5056
- }
5126
+ // Settings tab (#hot-config): the models opener now lives in the Settings
5127
+ // tab slot instead of the workspace header (its old home raised "why is
5128
+ // models inside workspace"). Workspace fallback only if the slot is absent.
5129
+ var settingsSlot = document.querySelector("#settings-models-slot");
5130
+ var mount = settingsSlot || (refreshBtn && refreshBtn.parentElement) || document.body;
5131
+ mount.appendChild(opener);
5132
+ opener.addEventListener("click", openModelSettings);
5057
5133
 
5058
5134
  var modal = document.querySelector("#model-settings-modal");
5059
5135
  if (!modal || modal.dataset.bound === "true") return;
@@ -5173,6 +5249,63 @@ function refreshGithubAuthStatus() {
5173
5249
  });
5174
5250
  }
5175
5251
 
5252
+ // Hot worker-provisioning config (#hot-config): renders into the Settings
5253
+ // tab's static form (#tab-settings). PATCH /team/config applies in-memory to
5254
+ // the running controller (no restart) and persists to the host openclaw.json
5255
+ // where the deployment shape allows it.
5256
+ var workerSettingsBound = false;
5257
+ function renderWorkerSettingsPanel() {
5258
+ var modal = document.getElementById("wk-save");
5259
+ if (!modal) return;
5260
+ apiRequest("/team/config").then(function (cfg) {
5261
+ if (cfg.workerProvisioningMaxPerRole != null) {
5262
+ var mx = document.getElementById("wk-max");
5263
+ if (mx) mx.value = cfg.workerProvisioningMaxPerRole;
5264
+ }
5265
+ if (cfg.workerProvisioningMinPerRole != null) {
5266
+ var mn = document.getElementById("wk-min");
5267
+ if (mn) mn.value = cfg.workerProvisioningMinPerRole;
5268
+ }
5269
+ if (cfg.workerProvisioningIdleTtlMs != null) {
5270
+ var ttl = document.getElementById("wk-ttl");
5271
+ if (ttl) ttl.value = cfg.workerProvisioningIdleTtlMs;
5272
+ }
5273
+ var mode = document.getElementById("wk-mode");
5274
+ if (mode) {
5275
+ mode.textContent = "provisioning: " + (cfg.workerProvisioningType || "process") +
5276
+ (cfg.persistenceMode === "memory-only" ? " | persistence: memory-only (restart reverts)" : " | persistence: host config");
5277
+ }
5278
+ }).catch(function (err) {
5279
+ var mode = document.getElementById("wk-mode");
5280
+ if (mode) mode.textContent = (err && err.message) || "load failed";
5281
+ });
5282
+ if (workerSettingsBound) return;
5283
+ workerSettingsBound = true;
5284
+ document.getElementById("wk-save").addEventListener("click", function () {
5285
+ var payload = {};
5286
+ var mxEl = document.getElementById("wk-max");
5287
+ var mnEl = document.getElementById("wk-min");
5288
+ var ttlEl = document.getElementById("wk-ttl");
5289
+ var mx = Number(mxEl && mxEl.value);
5290
+ var mn = Number(mnEl && mnEl.value);
5291
+ var ttl = Number(ttlEl && ttlEl.value);
5292
+ if (mxEl && mxEl.value !== "" && Number.isFinite(mx)) payload.workerProvisioningMaxPerRole = mx;
5293
+ if (mnEl && mnEl.value !== "" && Number.isFinite(mn)) payload.workerProvisioningMinPerRole = mn;
5294
+ if (ttlEl && ttlEl.value !== "" && Number.isFinite(ttl)) payload.workerProvisioningIdleTtlMs = ttl;
5295
+ if (!Object.keys(payload).length) return;
5296
+ var save = document.getElementById("wk-save");
5297
+ save.disabled = true;
5298
+ apiRequest("/team/config", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) })
5299
+ .then(function (out) {
5300
+ document.getElementById("wk-result").textContent = out && out.persisted === false ? "Applied (memory only)" : "Applied";
5301
+ })
5302
+ .catch(function (err) {
5303
+ document.getElementById("wk-result").textContent = (err && err.message) || "failed";
5304
+ })
5305
+ .finally(function () { save.disabled = false; });
5306
+ });
5307
+ }
5308
+
5176
5309
  function openModelSettings() {
5177
5310
  var modal = document.querySelector("#model-settings-modal");
5178
5311
  if (!modal) return;
@@ -78,6 +78,7 @@
78
78
  <span id="tasks-tab-signal" class="tab-signal"></span>
79
79
  </button>
80
80
  <button class="tab" data-tab="workspace"><span class="tab-label" data-i18n="tab.workspace">Workspace</span></button>
81
+ <button class="tab" data-tab="settings"><span class="tab-label" data-i18n="tab.settings">Settings</span></button>
81
82
  <button class="tab" data-tab="clarifications">
82
83
  <span class="tab-label" data-i18n="tab.clarifications">Clarifications</span>
83
84
  <span id="clarifications-tab-count" class="tab-badge">0</span>
@@ -150,6 +151,28 @@
150
151
  </div>
151
152
 
152
153
  <!-- Workspace Tab -->
154
+ <div id="tab-settings" class="tab-panel">
155
+ <div class="panel-note" style="padding:12px 14px">
156
+ <h3 data-i18n="settings.models.title" style="margin:0 0 6px">Model settings</h3>
157
+ <p data-i18n="settings.models.hint" style="margin:0 0 8px;color:#666">Default model and per-role overrides.</p>
158
+ <div id="settings-models-slot"></div>
159
+ </div>
160
+ <div class="panel-note" style="padding:12px 14px;margin-top:10px">
161
+ <h3 data-i18n="settings.workers.title" style="margin:0 0 6px">Worker scaling (hot)</h3>
162
+ <p data-i18n="settings.workers.hint" style="margin:0 0 8px;color:#666">Applies immediately without restarting the gateway. Lowering a cap never kills busy workers.</p>
163
+ <div style="display:flex;gap:10px;flex-wrap:wrap;align-items:end">
164
+ <label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.max">Max workers / role</span>
165
+ <input id="wk-max" type="number" min="1" max="50" style="width:90px" /></label>
166
+ <label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.min">Min warm / role</span>
167
+ <input id="wk-min" type="number" min="0" max="50" style="width:90px" /></label>
168
+ <label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.ttl">Idle TTL (ms)</span>
169
+ <input id="wk-ttl" type="number" min="1000" max="86400000" step="1000" style="width:120px" /></label>
170
+ <button id="wk-save" type="button" class="btn btn-small">Apply</button>
171
+ <span id="wk-result" style="margin-left:8px;color:#080"></span>
172
+ </div>
173
+ <p id="wk-mode" style="margin:8px 0 0;color:#666;font-size:12px"></p>
174
+ </div>
175
+ </div>
153
176
  <div id="tab-workspace" class="tab-panel">
154
177
  <div class="workspace-browser">
155
178
  <aside class="workspace-sidebar-panel">
package/index.ts CHANGED
@@ -20,6 +20,14 @@ import { installRecommendedSkills } from "./src/worker/skill-installer.js";
20
20
  // one (identical semantics; alias keeps the call site byte-identical).
21
21
  import { pathExistsTolerant as pathExists } from "./src/shared/utils.js";
22
22
 
23
+ // #253: the image build compiles this plugin into a flat rolldown bundle
24
+ // (dist/extensions/teamclaw/index.js) with NO nested dist/src tree, while the
25
+ // npm tarball layout ships dist/src/roles.js and no top-level index.js. The
26
+ // installer CLI (cli.mjs) reads the role registry through whichever layout it
27
+ // lands in, so the registry must be reachable from this entry as a named
28
+ // export for the bundled layout to resolve it.
29
+ export { ROLES, DEFAULT_ROLE } from "./src/roles.js";
30
+
23
31
  export default definePluginEntry({
24
32
  id: "teamclaw",
25
33
  name: "TeamClaw",
@@ -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.11.1",
5
+ "version": "2026.11.2",
6
6
  "activation": {
7
7
  "onStartup": true
8
8
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamclaws/teamclaw",
3
- "version": "2026.11.1",
3
+ "version": "2026.11.2",
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": [
@@ -0,0 +1,152 @@
1
+ // Hot-reloadable worker-provisioning configuration routes (runtime scaling).
2
+ //
3
+ // GET /api/v1/team/config -> read-only snapshot of the hot-reloadable fields
4
+ // PATCH /api/v1/team/config -> whitelist-only update that
5
+ // 1. mutates deps.config IN MEMORY (the provisioner reads these fields on
6
+ // every computeRoleDemand pass, so the change applies on the next
7
+ // reconcile tick — no restart),
8
+ // 2. persists to the host openclaw.json plugins.entries.teamclaw.config
9
+ // (same read-modify-write pattern as updateTeamClawModelConfig), and
10
+ // 3. pokes the provisioner via requestReconcile + broadcasts a
11
+ // team:config_updated WS event so desktop/web UIs refresh.
12
+ //
13
+ // Deployment-shape behavior (issue context: all deployment forms):
14
+ // - process / managed-gateway / desktop-private / tunnel: memory + host-config
15
+ // persistence (resolveDefaultOpenClawConfigPath honors OPENCLAW_HOME /
16
+ // OPENCLAW_CONFIG_PATH, so sandboxed instances persist into their own home).
17
+ // - docker (controller on host): same as process — host config is writable.
18
+ // - docker/k8s (controller itself containerized): container FS is ephemeral,
19
+ // so persistence degrades to memory-only and the response carries
20
+ // persistenceMode: "memory-only" + a restart note (declared behavior, not
21
+ // a silent drop). k8s deployments should source config from ConfigMap and
22
+ // treat this API as runtime-only scaling.
23
+ // Scale-down semantics: lowering maxPerRole never kills active workers; idle
24
+ // workers drain via workerProvisioningIdleTtlMs and the cap stops refills.
25
+ import { parseJsonBody, sendJson, sendError } from "../protocol.js";
26
+ import { updateTeamClawProvisioningConfig } from "../openclaw-workspace.js";
27
+ import type { RouteContext } from "./route-table.js";
28
+
29
+ /** Fields a PATCH may touch. Everything else in PluginConfig is rejected. */
30
+ const HOT_CONFIG_FIELDS = [
31
+ "workerProvisioningMaxPerRole",
32
+ "workerProvisioningMinPerRole",
33
+ "workerProvisioningIdleTtlMs",
34
+ ] as const;
35
+ type HotConfigField = (typeof HOT_CONFIG_FIELDS)[number];
36
+
37
+ const BOUNDS: Record<HotConfigField, { min: number; max: number }> = {
38
+ workerProvisioningMaxPerRole: { min: 1, max: 50 },
39
+ workerProvisioningMinPerRole: { min: 0, max: 50 },
40
+ // 1s floor keeps the idle reaper from churn-looping; 24h ceiling is generous.
41
+ workerProvisioningIdleTtlMs: { min: 1_000, max: 86_400_000 },
42
+ };
43
+
44
+ function teamConfigGetRoute(ctx: RouteContext): void {
45
+ const { res, deps } = ctx;
46
+ const c = deps.config;
47
+ sendJson(res, 200, {
48
+ workerProvisioningType: c.workerProvisioningType,
49
+ workerProvisioningDisabled: c.workerProvisioningDisabled,
50
+ workerProvisioningMinPerRole: c.workerProvisioningMinPerRole,
51
+ workerProvisioningMaxPerRole: c.workerProvisioningMaxPerRole,
52
+ workerProvisioningIdleTtlMs: c.workerProvisioningIdleTtlMs,
53
+ // k8s controllers run on ephemeral container FS: declare it up front.
54
+ persistenceMode: c.workerProvisioningType === "kubernetes" ? "memory-only" : "host-config",
55
+ });
56
+ }
57
+
58
+ async function teamConfigPatchRoute(ctx: RouteContext): Promise<void> {
59
+ const { req, res, deps } = ctx;
60
+ let body: Record<string, unknown> | null = null;
61
+ try {
62
+ body = (await parseJsonBody(req)) as Record<string, unknown>;
63
+ } catch {
64
+ sendError(res, 400, "invalid JSON body");
65
+ return;
66
+ }
67
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
68
+ sendError(res, 400, "JSON object body required");
69
+ return;
70
+ }
71
+
72
+ const unknown = Object.keys(body).filter((k) => !(HOT_CONFIG_FIELDS as readonly string[]).includes(k));
73
+ if (unknown.length > 0) {
74
+ sendError(res, 400, `unknown or non-hot-reloadable field(s): ${unknown.join(", ")}`);
75
+ return;
76
+ }
77
+
78
+ const update: Partial<Record<HotConfigField, number>> = {};
79
+ for (const field of HOT_CONFIG_FIELDS) {
80
+ if (body[field] === undefined) continue;
81
+ const raw = body[field];
82
+ if (typeof raw !== "number" || !Number.isFinite(raw)) {
83
+ sendError(res, 400, `${field} must be a finite number`);
84
+ return;
85
+ }
86
+ const { min, max } = BOUNDS[field];
87
+ update[field] = Math.max(min, Math.min(max, Math.floor(raw)));
88
+ }
89
+ if (Object.keys(update).length === 0) {
90
+ sendError(res, 400, `at least one of ${HOT_CONFIG_FIELDS.join(", ")} is required`);
91
+ return;
92
+ }
93
+
94
+ // 1) In-memory hot apply (deps.config is a live reference the provisioner
95
+ // reads on every demand computation — no restart needed).
96
+ const applied: Record<string, number> = {};
97
+ for (const [field, value] of Object.entries(update) as [HotConfigField, number][]) {
98
+ (deps.config as unknown as Record<string, number>)[field] = value;
99
+ applied[field] = value;
100
+ }
101
+ // Keep the min<=max invariant types.ts enforces at parse time.
102
+ const minR = update.workerProvisioningMinPerRole ?? deps.config.workerProvisioningMinPerRole;
103
+ if (deps.config.workerProvisioningMaxPerRole < minR) {
104
+ deps.config.workerProvisioningMaxPerRole = minR;
105
+ applied.workerProvisioningMaxPerRole = minR;
106
+ }
107
+
108
+ // 2) Persist (host config) unless the controller itself runs on an
109
+ // ephemeral container FS.
110
+ const memoryOnly = deps.config.workerProvisioningType === "kubernetes";
111
+ let persisted = false;
112
+ if (!memoryOnly) {
113
+ try {
114
+ await updateTeamClawProvisioningConfig(applied, {
115
+ warn: (message: string) => deps.logger.info(message),
116
+ });
117
+ persisted = true;
118
+ } catch (err) {
119
+ // Memory already applied — report partial success honestly.
120
+ deps.logger.warn(
121
+ `TeamClaw: hot config applied in memory but host-config persist failed: ${err instanceof Error ? err.message : String(err)}`,
122
+ );
123
+ }
124
+ }
125
+
126
+ // 3) Poke the provisioner so the new caps apply immediately instead of
127
+ // waiting for the next periodic reconcile tick, then tell UIs.
128
+ try {
129
+ await deps.workerProvisioningManager?.requestReconcile("team-config-hot-update");
130
+ } catch (err) {
131
+ deps.logger.warn(
132
+ `TeamClaw: config hot-update reconcile poke failed: ${err instanceof Error ? err.message : String(err)}`,
133
+ );
134
+ }
135
+ deps.wsServer.broadcastUpdate({ type: "team:config_updated", data: { ...applied, persisted } });
136
+ deps.logger.info(`TeamClaw: worker provisioning config hot-updated: ${JSON.stringify(applied)} (persisted=${persisted})`);
137
+
138
+ sendJson(res, 200, {
139
+ ok: true,
140
+ applied,
141
+ persisted,
142
+ persistenceMode: persisted ? "host-config" : "memory-only",
143
+ ...(persisted
144
+ ? {}
145
+ : {
146
+ restartNote:
147
+ "Applied in memory only; this deployment shape does not persist to a durable host config — after a gateway restart the config reverts to its persisted source.",
148
+ }),
149
+ });
150
+ }
151
+
152
+ export { teamConfigGetRoute, teamConfigPatchRoute };
@@ -52,6 +52,7 @@ import {
52
52
  teamProfileSwitchRoute,
53
53
  archivedTeamsRoute,
54
54
  } from "./status-routes.js";
55
+ import { teamConfigGetRoute, teamConfigPatchRoute } from "./config-routes.js";
55
56
  import {
56
57
  reportsListRoute,
57
58
  reportsSessionRoute,
@@ -594,4 +595,9 @@ export const controllerRouteTable: readonly RouteDef[] = [
594
595
  // { context } (initial business context). The handler enforces the
595
596
  // transition-matrix 503 itself (see workflow-routes.ts).
596
597
  { method: "POST", path: /^\/api\/v1\/workflows\/[^/]+\/start$/, handler: workflowStartRoute },
598
+ // Hot worker-provisioning config (#hot-config): GET snapshot + PATCH
599
+ // hot-apply. Appended at the table tail on the same append-only precedent
600
+ // (no path overlap with any earlier route).
601
+ { method: "GET", path: "/api/v1/team/config", handler: teamConfigGetRoute },
602
+ { method: "PATCH", path: "/api/v1/team/config", handler: teamConfigPatchRoute },
597
603
  ];
@@ -20,6 +20,7 @@ export type WsEvent =
20
20
  | { type: "project:deleted"; data: unknown }
21
21
  | { type: "requirement:complete"; data: unknown }
22
22
  | { type: "report:ready"; data: unknown }
23
+ | { type: "team:config_updated"; data: unknown }
23
24
  | { type: "teamauto:activity"; data: unknown }
24
25
  // Phase 2.2 (design sections 2.3/4): team profile switch lifecycle. Event
25
26
  // names follow the design document verbatim (dot-separated) rather than the
@@ -807,6 +807,53 @@ export async function updateTeamClawModelConfig(
807
807
  return { configPath };
808
808
  }
809
809
 
810
+ /**
811
+ * Persist hot-reloadable worker-provisioning fields into the host
812
+ * openclaw.json plugins.entries.teamclaw.config (read-modify-write, same
813
+ * pattern as updateTeamClawModelConfig). Only whitelisted fields are
814
+ * touched; unknown keys in the existing plugin config are preserved.
815
+ */
816
+ export async function updateTeamClawProvisioningConfig(
817
+ update: {
818
+ workerProvisioningMinPerRole?: number;
819
+ workerProvisioningMaxPerRole?: number;
820
+ workerProvisioningIdleTtlMs?: number;
821
+ },
822
+ logger?: { warn?: (message: string) => void },
823
+ env: NodeJS.ProcessEnv = process.env,
824
+ homedir: () => string = os.homedir,
825
+ ): Promise<{ configPath: string }> {
826
+ const configPath = resolveDefaultOpenClawConfigPath(env, homedir);
827
+ let parsed: Record<string, unknown>;
828
+ try {
829
+ parsed = JSON5.parse(await fs.readFile(configPath, "utf8")) as Record<string, unknown>;
830
+ if (!isRecord(parsed)) {
831
+ throw new Error("host config is not an object");
832
+ }
833
+ } catch (err) {
834
+ throw new Error(`failed to read host config at ${configPath}: ${err instanceof Error ? err.message : String(err)}`);
835
+ }
836
+
837
+ const plugins = isRecord(parsed.plugins) ? parsed.plugins : {};
838
+ const pluginEntries = isRecord(plugins.entries) ? plugins.entries : {};
839
+ const teamclawPlugin = isRecord(pluginEntries[TEAMCLAW_AGENT_ID]) ? pluginEntries[TEAMCLAW_AGENT_ID] : { enabled: true };
840
+ const pluginConfig = isRecord((teamclawPlugin as { config?: unknown }).config)
841
+ ? { ...(teamclawPlugin as { config: Record<string, unknown> }).config }
842
+ : {};
843
+ for (const [key, value] of Object.entries(update)) {
844
+ if (typeof value === "number" && Number.isFinite(value)) {
845
+ pluginConfig[key] = value;
846
+ }
847
+ }
848
+ pluginEntries[TEAMCLAW_AGENT_ID] = { ...teamclawPlugin, config: pluginConfig };
849
+ plugins.entries = pluginEntries;
850
+ parsed.plugins = plugins;
851
+
852
+ await fs.writeFile(configPath, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
853
+ logger?.warn?.("TeamClaw: worker provisioning config persisted (hot-reload applies to the running controller)");
854
+ return { configPath };
855
+ }
856
+
810
857
  /**
811
858
  * Resolve the `projects/` root inside the TeamClaw workspace.
812
859
  * Each orchestration run or ad-hoc task gets its own subdirectory here.
@@ -102,12 +102,25 @@ export async function sweepRepo(
102
102
  repo: TeamAutoRepo,
103
103
  client: TeamAutoGithubClient,
104
104
  now = Date.now(),
105
- ): Promise<{ candidates: Candidate[]; issues: SweepableIssue[]; pulls: SweepablePull[] }> {
105
+ ): Promise<{ candidates: Candidate[]; issues: SweepableIssue[]; pulls: SweepablePull[]; newCommits: { sha: string; message: string }[]; commits: { sha: string; message: string }[] }> {
106
106
  const [owner, name] = repo.id.split("/");
107
107
  const issues = await client.listIssues(owner, name, repo.cursors.lastIssueSince, repo.cursors.etags);
108
108
  const pulls = repo.policy.actions.prReview
109
109
  ? await client.listPulls(owner, name, repo.cursors.etags)
110
110
  : [];
111
+ // #265: the commits leg was dead code (listCommits had zero callers,
112
+ // lastCommitSha never advanced) - the designed third signal source never
113
+ // ran. Wire it as an observation-only feed: fetch, filter past the cursor,
114
+ // and surface the delta. Cursor advance happens in advanceCursors (with
115
+ // the other legs, so dry-run semantics stay intact); it produces no task
116
+ // candidates (issue/pull policies stay the sole candidate sources).
117
+ const commits = await client.listCommits(owner, name, repo.cursors.lastCommitSha);
118
+ // Newest-first feed: when the cursor is set, stop the delta at the first
119
+ // entry whose sha equals it (that commit and everything after is already
120
+ // known). An unset cursor means first sweep: observe only, report nothing.
121
+ const newCommits = repo.cursors.lastCommitSha
122
+ ? commits.slice(0, (() => { const i = commits.findIndex((c) => c.sha === repo.cursors.lastCommitSha); return i === -1 ? commits.length : i; })())
123
+ : [];
111
124
  const candidates: Candidate[] = [];
112
125
 
113
126
  for (const issue of issues) {
@@ -220,17 +233,23 @@ export async function sweepRepo(
220
233
  }
221
234
  }
222
235
 
223
- return { candidates: candidates.slice(0, repo.policy.maxTasksPerSweep * 2), issues, pulls };
236
+ return { candidates: candidates.slice(0, repo.policy.maxTasksPerSweep * 2), issues, pulls, newCommits, commits };
224
237
  }
225
238
 
226
239
  /** Advance cursors after tasks were enqueued (or observed on first sweep). */
227
- export function advanceCursors(repo: TeamAutoRepo, issues: SweepableIssue[], pulls: SweepablePull[], now = Date.now()): void {
240
+ export function advanceCursors(repo: TeamAutoRepo, issues: SweepableIssue[], pulls: SweepablePull[], now = Date.now(), commits: { sha: string; message: string }[] = []): void {
228
241
  for (const issue of issues) {
229
242
  repo.cursors.seen[`${repo.id}#issue-${issue.number}`] = Date.parse(issue.updatedAt) || now;
230
243
  }
231
244
  for (const pull of pulls) {
232
245
  repo.cursors.seen[`${repo.id}#pr-${pull.number}`] = Date.parse(pull.updated_at) || now;
233
246
  }
247
+ // Commit cursor: the feed is newest-first, so when anything came back the
248
+ // HEAD entry IS the new cursor. Empty feed keeps the old cursor (nothing
249
+ // new to advance to).
250
+ if (commits.length > 0) {
251
+ repo.cursors.lastCommitSha = commits[0].sha;
252
+ }
234
253
  // Cap the seen map so it cannot grow unbounded.
235
254
  const entries = Object.entries(repo.cursors.seen);
236
255
  if (entries.length > 2000) {