@teamclaws/teamclaw 2026.11.1 → 2026.11.3
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.
- package/cli.mjs +96 -11
- package/dist/index.js +7 -0
- package/dist/src/controller/config-routes.js +138 -0
- package/dist/src/controller/http-server.js +18 -0
- package/dist/src/controller/journal.js +68 -0
- package/dist/src/controller/provisioning/process-supervisor.js +58 -2
- package/dist/src/controller/provisioning-config.js +53 -0
- package/dist/src/controller/route-table.js +11 -0
- package/dist/src/controller/security.js +39 -0
- package/dist/src/controller/teamauto-routes.js +12 -0
- package/dist/src/controller/tunnel-manager.js +33 -1
- package/dist/src/controller/tunnel-routes.js +17 -1
- package/dist/src/controller/websocket.js +4 -0
- package/dist/src/controller/worker-provisioning.js +36 -0
- package/dist/src/openclaw-workspace.js +36 -0
- package/dist/src/state.js +77 -1
- package/dist/src/teamauto/github-client.js +33 -0
- package/dist/src/teamauto/scanner.js +30 -3
- package/dist/src/teamauto/scheduler.js +300 -18
- package/dist/src/teamauto/store.js +9 -0
- package/dist/src/ui/app.js +188 -11
- package/dist/src/ui/index.html +38 -0
- package/index.ts +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/controller/config-routes.ts +152 -0
- package/src/controller/http-server.ts +18 -0
- package/src/controller/journal.ts +89 -0
- package/src/controller/provisioning/process-supervisor.ts +56 -2
- package/src/controller/provisioning-config.ts +54 -0
- package/src/controller/route-table.ts +11 -0
- package/src/controller/security.ts +40 -0
- package/src/controller/teamauto-routes.ts +12 -0
- package/src/controller/tunnel-manager.ts +34 -1
- package/src/controller/tunnel-routes.ts +18 -1
- package/src/controller/websocket.ts +6 -0
- package/src/controller/worker-provisioning.ts +34 -0
- package/src/openclaw-workspace.ts +47 -0
- package/src/state.ts +73 -2
- package/src/teamauto/github-client.ts +36 -0
- package/src/teamauto/scanner.ts +31 -4
- package/src/teamauto/scheduler.ts +303 -18
- package/src/teamauto/store.ts +36 -1
- package/src/ui/app.js +188 -11
- package/src/ui/index.html +38 -0
package/dist/src/ui/app.js
CHANGED
|
@@ -76,6 +76,20 @@
|
|
|
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
|
+
"tab.activity": "Activity",
|
|
82
|
+
"activity.events.title": "Controller activity",
|
|
83
|
+
"activity.events.hint": "Live provisioning, sweeps, task routing and team events (ring buffer, last 400).",
|
|
84
|
+
"activity.log.title": "TeamClaw log tail",
|
|
85
|
+
"activity.log.all": "unfiltered",
|
|
86
|
+
"settings.models.title": "Model settings",
|
|
87
|
+
"settings.models.hint": "Default model and per-role overrides.",
|
|
88
|
+
"settings.workers.title": "Worker scaling (hot)",
|
|
89
|
+
"settings.workers.hint": "Applies immediately without restarting the gateway. Lowering a cap never kills busy workers.",
|
|
90
|
+
"settings.workers.max": "Max workers / role",
|
|
91
|
+
"settings.workers.min": "Min warm / role",
|
|
92
|
+
"settings.workers.ttl": "Idle TTL (ms)",
|
|
79
93
|
"tab.teamauto": "TeamAuto",
|
|
80
94
|
"tab.clarifications": "Clarifications",
|
|
81
95
|
"tab.messages": "Messages",
|
|
@@ -362,6 +376,20 @@
|
|
|
362
376
|
"tab.planning": "规划",
|
|
363
377
|
"tab.tasks": "任务",
|
|
364
378
|
"tab.workspace": "工作区",
|
|
379
|
+
"common.showOlder": "显示更早({n})",
|
|
380
|
+
"tab.settings": "设置",
|
|
381
|
+
"tab.activity": "活动",
|
|
382
|
+
"activity.events.title": "控制器活动",
|
|
383
|
+
"activity.events.hint": "实时的 worker 供给、sweep、任务分派与团队事件(环形缓冲,最近 400 条)。",
|
|
384
|
+
"activity.log.title": "TeamClaw 日志尾随",
|
|
385
|
+
"activity.log.all": "不过滤",
|
|
386
|
+
"settings.models.title": "模型设置",
|
|
387
|
+
"settings.models.hint": "默认模型与按角色覆盖。",
|
|
388
|
+
"settings.workers.title": "Worker 弹性伸缩(热)",
|
|
389
|
+
"settings.workers.hint": "立即生效无需重启 gateway。下调上限不会终止忙碌 worker。",
|
|
390
|
+
"settings.workers.max": "每角色最大 worker",
|
|
391
|
+
"settings.workers.min": "每角色保活下限",
|
|
392
|
+
"settings.workers.ttl": "空闲回收 TTL(毫秒)",
|
|
365
393
|
"tab.teamauto": "TeamAuto",
|
|
366
394
|
"tab.clarifications": "澄清",
|
|
367
395
|
"tab.messages": "消息",
|
|
@@ -1417,12 +1445,16 @@
|
|
|
1417
1445
|
var selectedPlanningRunId = null;
|
|
1418
1446
|
|
|
1419
1447
|
function renderPlanningTab(runs) {
|
|
1448
|
+
lastRenderedData.planning = runs || [];
|
|
1420
1449
|
var sessionList = $("#planning-session-list");
|
|
1421
1450
|
if (!sessionList) return;
|
|
1422
1451
|
|
|
1423
1452
|
var planningRuns = (runs || [])
|
|
1424
1453
|
.filter(function (r) { return r && r.manifest; })
|
|
1425
1454
|
.sort(function (a, b) { return (b.updatedAt || 0) - (a.updatedAt || 0); });
|
|
1455
|
+
var planningWindow = splitByRecency(planningRuns, function (r) { return r.updatedAt || r.createdAt; }, "planning");
|
|
1456
|
+
planningRuns = planningWindow.shown;
|
|
1457
|
+
var planningOlderHtml = olderToggleHtml(planningWindow.olderCount, "planning");
|
|
1426
1458
|
|
|
1427
1459
|
if (planningRuns.length === 0) {
|
|
1428
1460
|
sessionList.innerHTML = '<div class="empty-state">' + escapeHtml(t("empty.noPlanningSessions")) + "</div>";
|
|
@@ -1452,7 +1484,7 @@
|
|
|
1452
1484
|
' <div class="planning-session-meta">' + escapeHtml(humanizeStatus(status)) + " · " + roles + " roles" + (assessments.length ? " · " + needed + " confirmed" : "") + " · " + escapeHtml(formatTime(run.updatedAt) || "") + "</div>" +
|
|
1453
1485
|
"</button>"
|
|
1454
1486
|
);
|
|
1455
|
-
}).join("");
|
|
1487
|
+
}).join("") + planningOlderHtml;
|
|
1456
1488
|
|
|
1457
1489
|
// Render selected run
|
|
1458
1490
|
renderPlanningDetail(planningRuns.find(function (r) { return r.id === selectedPlanningRunId; }));
|
|
@@ -3078,7 +3110,38 @@
|
|
|
3078
3110
|
return haystack.includes(keyword);
|
|
3079
3111
|
}
|
|
3080
3112
|
|
|
3113
|
+
// ---- 24h recency window + lazy "show older" (#recent-window) ----
|
|
3114
|
+
// Planning / Tasks / Clarifications / Messages only list items from the
|
|
3115
|
+
// last 24h by default; older items appear after an explicit click.
|
|
3116
|
+
const TWENTY_FOUR_H_MS = 24 * 60 * 60 * 1000;
|
|
3117
|
+
const showOlderSections = { tasks: false, planning: false, clarifications: false, messages: false };
|
|
3118
|
+
const lastRenderedData = { tasks: [], planning: [], clarifications: [], messages: [] };
|
|
3119
|
+
function splitByRecency(items, tsOf, section) {
|
|
3120
|
+
const cutoff = Date.now() - TWENTY_FOUR_H_MS;
|
|
3121
|
+
const recent = [];
|
|
3122
|
+
const older = [];
|
|
3123
|
+
for (const item of items || []) {
|
|
3124
|
+
((tsOf(item) || 0) >= cutoff ? recent : older).push(item);
|
|
3125
|
+
}
|
|
3126
|
+
return showOlderSections[section] ? { shown: recent.concat(older), olderCount: 0 } : { shown: recent, olderCount: older.length };
|
|
3127
|
+
}
|
|
3128
|
+
function olderToggleHtml(count, section) {
|
|
3129
|
+
if (!count) return "";
|
|
3130
|
+
return '<div style="text-align:center;padding:8px"><button type="button" class="btn btn-small" data-show-older="' + section + '">' +
|
|
3131
|
+
escapeHtml(t("common.showOlder", { n: count })) + "</button></div>";
|
|
3132
|
+
}
|
|
3133
|
+
document.addEventListener("click", function (event) {
|
|
3134
|
+
const btn = event.target instanceof Element && event.target.closest("[data-show-older]");
|
|
3135
|
+
if (!btn || btn.tagName !== "BUTTON") return;
|
|
3136
|
+
showOlderSections[btn.getAttribute("data-show-older")] = true;
|
|
3137
|
+
renderTasks(lastRenderedData.tasks);
|
|
3138
|
+
renderPlanningTab(lastRenderedData.planning);
|
|
3139
|
+
renderClarifications(lastRenderedData.clarifications);
|
|
3140
|
+
renderMessages(lastRenderedData.messages);
|
|
3141
|
+
});
|
|
3142
|
+
|
|
3081
3143
|
function renderTasks(tasks) {
|
|
3144
|
+
lastRenderedData.tasks = tasks || [];
|
|
3082
3145
|
const container = $("#tasks-board");
|
|
3083
3146
|
if (!container) return;
|
|
3084
3147
|
|
|
@@ -3099,10 +3162,13 @@
|
|
|
3099
3162
|
}
|
|
3100
3163
|
|
|
3101
3164
|
const sorted = filtered.slice().sort(taskComparator);
|
|
3165
|
+
// #recent-window: 24h recency first, older tasks behind the lazy toggle
|
|
3166
|
+
// (applied before the terminal chunking, so both windows stay fast).
|
|
3167
|
+
const recency = splitByRecency(sorted, function (task) { return task.updatedAt || task.createdAt; }, "tasks");
|
|
3102
3168
|
// Active tasks render in full; terminal ones chunk so long-lived installs
|
|
3103
3169
|
// with hundreds of completed tasks stay fast and meaningful.
|
|
3104
|
-
const activeTasks =
|
|
3105
|
-
const terminalTasks =
|
|
3170
|
+
const activeTasks = recency.shown.filter(function (task) { return !TERMINAL_STATUSES[task.status]; });
|
|
3171
|
+
const terminalTasks = recency.shown.filter(function (task) { return TERMINAL_STATUSES[task.status]; });
|
|
3106
3172
|
const visibleTerminal = terminalTasks.slice(0, terminalTasksVisible);
|
|
3107
3173
|
const hiddenTerminal = terminalTasks.length - visibleTerminal.length;
|
|
3108
3174
|
const visibleList = activeTasks.concat(visibleTerminal);
|
|
@@ -3154,7 +3220,7 @@
|
|
|
3154
3220
|
" </div>" +
|
|
3155
3221
|
"</div>"
|
|
3156
3222
|
);
|
|
3157
|
-
}).join("") + showMoreHtml;
|
|
3223
|
+
}).join("") + showMoreHtml + olderToggleHtml(recency.olderCount, "tasks");
|
|
3158
3224
|
|
|
3159
3225
|
const showMoreBtn = $("#tasks-show-more");
|
|
3160
3226
|
if (showMoreBtn) {
|
|
@@ -3808,6 +3874,7 @@
|
|
|
3808
3874
|
}
|
|
3809
3875
|
|
|
3810
3876
|
function renderClarifications(clarifications) {
|
|
3877
|
+
lastRenderedData.clarifications = clarifications || [];
|
|
3811
3878
|
const container = $("#clarifications-list");
|
|
3812
3879
|
if (!container) return;
|
|
3813
3880
|
|
|
@@ -3816,14 +3883,21 @@
|
|
|
3816
3883
|
return;
|
|
3817
3884
|
}
|
|
3818
3885
|
|
|
3819
|
-
|
|
3886
|
+
const clWindow = splitByRecency(sortClarifications(clarifications), function (c) { return c.createdAt || c.updatedAt; }, "clarifications");
|
|
3887
|
+
if (clWindow.shown.length === 0) {
|
|
3888
|
+
container.innerHTML = olderToggleHtml(clWindow.olderCount, "clarifications");
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
container.innerHTML = renderClarificationCards(clWindow.shown, { linkToTask: true }) +
|
|
3892
|
+
olderToggleHtml(clWindow.olderCount, "clarifications");
|
|
3820
3893
|
}
|
|
3821
3894
|
|
|
3822
3895
|
function renderMessages(messages) {
|
|
3896
|
+
lastRenderedData.messages = messages || [];
|
|
3823
3897
|
const container = $("#messages-feed");
|
|
3824
3898
|
if (!container) return;
|
|
3825
3899
|
|
|
3826
|
-
|
|
3900
|
+
var recent = (messages || [])
|
|
3827
3901
|
.concat(controllerConversation || [])
|
|
3828
3902
|
.sort(function (left, right) {
|
|
3829
3903
|
return (right.createdAt || 0) - (left.createdAt || 0);
|
|
@@ -3834,7 +3908,13 @@
|
|
|
3834
3908
|
return;
|
|
3835
3909
|
}
|
|
3836
3910
|
|
|
3837
|
-
|
|
3911
|
+
const msgWindow = splitByRecency(recent, function (m) { return m.createdAt; }, "messages");
|
|
3912
|
+
if (msgWindow.shown.length === 0) {
|
|
3913
|
+
container.innerHTML = olderToggleHtml(msgWindow.olderCount, "messages");
|
|
3914
|
+
return;
|
|
3915
|
+
}
|
|
3916
|
+
container.innerHTML = renderMessageCards(msgWindow.shown) +
|
|
3917
|
+
olderToggleHtml(msgWindow.olderCount, "messages");
|
|
3838
3918
|
}
|
|
3839
3919
|
|
|
3840
3920
|
function renderRoles(roles) {
|
|
@@ -4058,6 +4138,12 @@
|
|
|
4058
4138
|
if (activeTab === "workspace") {
|
|
4059
4139
|
refreshWorkspaceTree(false);
|
|
4060
4140
|
}
|
|
4141
|
+
if (activeTab === "settings") {
|
|
4142
|
+
renderWorkerSettingsPanel();
|
|
4143
|
+
}
|
|
4144
|
+
if (activeTab === "activity") {
|
|
4145
|
+
renderActivityTab();
|
|
4146
|
+
}
|
|
4061
4147
|
if (activeTab === "teamauto") {
|
|
4062
4148
|
refreshTeamAutoTab();
|
|
4063
4149
|
}
|
|
@@ -5050,10 +5136,13 @@
|
|
|
5050
5136
|
opener.setAttribute("data-i18n", "ctl.tab.models");
|
|
5051
5137
|
opener.textContent = t("ctl.tab.models");
|
|
5052
5138
|
var refreshBtn = document.querySelector("#workspace-tree-refresh");
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5139
|
+
// Settings tab (#hot-config): the models opener now lives in the Settings
|
|
5140
|
+
// tab slot instead of the workspace header (its old home raised "why is
|
|
5141
|
+
// models inside workspace"). Workspace fallback only if the slot is absent.
|
|
5142
|
+
var settingsSlot = document.querySelector("#settings-models-slot");
|
|
5143
|
+
var mount = settingsSlot || (refreshBtn && refreshBtn.parentElement) || document.body;
|
|
5144
|
+
mount.appendChild(opener);
|
|
5145
|
+
opener.addEventListener("click", openModelSettings);
|
|
5057
5146
|
|
|
5058
5147
|
var modal = document.querySelector("#model-settings-modal");
|
|
5059
5148
|
if (!modal || modal.dataset.bound === "true") return;
|
|
@@ -5173,6 +5262,94 @@ function refreshGithubAuthStatus() {
|
|
|
5173
5262
|
});
|
|
5174
5263
|
}
|
|
5175
5264
|
|
|
5265
|
+
// Hot worker-provisioning config (#hot-config): renders into the Settings
|
|
5266
|
+
// tab's static form (#tab-settings). PATCH /team/config applies in-memory to
|
|
5267
|
+
// the running controller (no restart) and persists to the host openclaw.json
|
|
5268
|
+
// where the deployment shape allows it.
|
|
5269
|
+
var workerSettingsBound = false;
|
|
5270
|
+
function renderWorkerSettingsPanel() {
|
|
5271
|
+
var modal = document.getElementById("wk-save");
|
|
5272
|
+
if (!modal) return;
|
|
5273
|
+
apiRequest("/team/config").then(function (cfg) {
|
|
5274
|
+
if (cfg.workerProvisioningMaxPerRole != null) {
|
|
5275
|
+
var mx = document.getElementById("wk-max");
|
|
5276
|
+
if (mx) mx.value = cfg.workerProvisioningMaxPerRole;
|
|
5277
|
+
}
|
|
5278
|
+
if (cfg.workerProvisioningMinPerRole != null) {
|
|
5279
|
+
var mn = document.getElementById("wk-min");
|
|
5280
|
+
if (mn) mn.value = cfg.workerProvisioningMinPerRole;
|
|
5281
|
+
}
|
|
5282
|
+
if (cfg.workerProvisioningIdleTtlMs != null) {
|
|
5283
|
+
var ttl = document.getElementById("wk-ttl");
|
|
5284
|
+
if (ttl) ttl.value = cfg.workerProvisioningIdleTtlMs;
|
|
5285
|
+
}
|
|
5286
|
+
var mode = document.getElementById("wk-mode");
|
|
5287
|
+
if (mode) {
|
|
5288
|
+
mode.textContent = "provisioning: " + (cfg.workerProvisioningType || "process") +
|
|
5289
|
+
(cfg.persistenceMode === "memory-only" ? " | persistence: memory-only (restart reverts)" : " | persistence: host config");
|
|
5290
|
+
}
|
|
5291
|
+
}).catch(function (err) {
|
|
5292
|
+
var mode = document.getElementById("wk-mode");
|
|
5293
|
+
if (mode) mode.textContent = (err && err.message) || "load failed";
|
|
5294
|
+
});
|
|
5295
|
+
if (workerSettingsBound) return;
|
|
5296
|
+
workerSettingsBound = true;
|
|
5297
|
+
document.getElementById("wk-save").addEventListener("click", function () {
|
|
5298
|
+
var payload = {};
|
|
5299
|
+
var mxEl = document.getElementById("wk-max");
|
|
5300
|
+
var mnEl = document.getElementById("wk-min");
|
|
5301
|
+
var ttlEl = document.getElementById("wk-ttl");
|
|
5302
|
+
var mx = Number(mxEl && mxEl.value);
|
|
5303
|
+
var mn = Number(mnEl && mnEl.value);
|
|
5304
|
+
var ttl = Number(ttlEl && ttlEl.value);
|
|
5305
|
+
if (mxEl && mxEl.value !== "" && Number.isFinite(mx)) payload.workerProvisioningMaxPerRole = mx;
|
|
5306
|
+
if (mnEl && mnEl.value !== "" && Number.isFinite(mn)) payload.workerProvisioningMinPerRole = mn;
|
|
5307
|
+
if (ttlEl && ttlEl.value !== "" && Number.isFinite(ttl)) payload.workerProvisioningIdleTtlMs = ttl;
|
|
5308
|
+
if (!Object.keys(payload).length) return;
|
|
5309
|
+
var save = document.getElementById("wk-save");
|
|
5310
|
+
save.disabled = true;
|
|
5311
|
+
apiRequest("/team/config", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) })
|
|
5312
|
+
.then(function (out) {
|
|
5313
|
+
document.getElementById("wk-result").textContent = out && out.persisted === false ? "Applied (memory only)" : "Applied";
|
|
5314
|
+
})
|
|
5315
|
+
.catch(function (err) {
|
|
5316
|
+
document.getElementById("wk-result").textContent = (err && err.message) || "failed";
|
|
5317
|
+
})
|
|
5318
|
+
.finally(function () { save.disabled = false; });
|
|
5319
|
+
});
|
|
5320
|
+
}
|
|
5321
|
+
|
|
5322
|
+
// Controller Activity tab (#ui-blindness): journal event stream + gateway
|
|
5323
|
+
// log tail. Polls only while the tab is active (no background traffic).
|
|
5324
|
+
var activityTimer = null;
|
|
5325
|
+
function renderActivityTab() {
|
|
5326
|
+
var journalEl = document.getElementById("activity-journal");
|
|
5327
|
+
if (!journalEl) return;
|
|
5328
|
+
function fmtTime(at) {
|
|
5329
|
+
var d = new Date(at);
|
|
5330
|
+
return ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":" + ("0" + d.getSeconds()).slice(-2);
|
|
5331
|
+
}
|
|
5332
|
+
function load() {
|
|
5333
|
+
apiRequest("/controller/journal?limit=200").then(function (d) {
|
|
5334
|
+
var ev = d.events || [];
|
|
5335
|
+
journalEl.innerHTML = ev.length
|
|
5336
|
+
? ev.map(function (e) { return escapeHtml(fmtTime(e.at) + " [" + e.type + "] " + e.summary); }).join("\n")
|
|
5337
|
+
: "(no events yet)";
|
|
5338
|
+
}).catch(function (err) { journalEl.textContent = (err && err.message) || "load failed"; });
|
|
5339
|
+
var all = document.getElementById("activity-log-all");
|
|
5340
|
+
apiRequest("/controller/log-tail?lines=200" + (all && all.checked ? "&all=1" : "")).then(function (d) {
|
|
5341
|
+
var logEl = document.getElementById("activity-log");
|
|
5342
|
+
if (logEl) {
|
|
5343
|
+
logEl.textContent = ((d.path || "") + "\n" + (d.lines || []).join("\n")) || "(no log lines matched)";
|
|
5344
|
+
logEl.scrollTop = logEl.scrollHeight;
|
|
5345
|
+
}
|
|
5346
|
+
}).catch(function () { /* transient */ });
|
|
5347
|
+
}
|
|
5348
|
+
if (activityTimer) clearInterval(activityTimer);
|
|
5349
|
+
load();
|
|
5350
|
+
activityTimer = setInterval(load, 5000);
|
|
5351
|
+
}
|
|
5352
|
+
|
|
5176
5353
|
function openModelSettings() {
|
|
5177
5354
|
var modal = document.querySelector("#model-settings-modal");
|
|
5178
5355
|
if (!modal) return;
|
package/dist/src/ui/index.html
CHANGED
|
@@ -78,6 +78,8 @@
|
|
|
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>
|
|
82
|
+
<button class="tab" data-tab="activity"><span class="tab-label" data-i18n="tab.activity">Activity</span></button>
|
|
81
83
|
<button class="tab" data-tab="clarifications">
|
|
82
84
|
<span class="tab-label" data-i18n="tab.clarifications">Clarifications</span>
|
|
83
85
|
<span id="clarifications-tab-count" class="tab-badge">0</span>
|
|
@@ -150,6 +152,42 @@
|
|
|
150
152
|
</div>
|
|
151
153
|
|
|
152
154
|
<!-- Workspace Tab -->
|
|
155
|
+
<div id="tab-activity" class="tab-panel">
|
|
156
|
+
<div class="panel-note" style="padding:12px 14px">
|
|
157
|
+
<h3 data-i18n="activity.events.title" style="margin:0 0 6px">Controller activity</h3>
|
|
158
|
+
<p data-i18n="activity.events.hint" style="margin:0 0 8px;color:#666">Live provisioning, sweeps, task routing and team events (ring buffer, last 400).</p>
|
|
159
|
+
<div id="activity-journal" style="font:12px/1.6 ui-monospace,monospace;max-height:320px;overflow:auto;background:#f6f6f6;padding:8px;border-radius:6px;white-space:pre-wrap"></div>
|
|
160
|
+
</div>
|
|
161
|
+
<div class="panel-note" style="padding:12px 14px;margin-top:10px">
|
|
162
|
+
<h3 data-i18n="activity.log.title" style="margin:0 0 6px">TeamClaw log tail</h3>
|
|
163
|
+
<p style="margin:0 0 8px">
|
|
164
|
+
<label style="font-size:12px;color:#666"><input id="activity-log-all" type="checkbox" /> <span data-i18n="activity.log.all">unfiltered</span></label>
|
|
165
|
+
</p>
|
|
166
|
+
<div id="activity-log" style="font:12px/1.6 ui-monospace,monospace;max-height:420px;overflow:auto;background:#111;color:#9f9;padding:10px;border-radius:6px;white-space:pre-wrap"></div>
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
<div id="tab-settings" class="tab-panel">
|
|
170
|
+
<div class="panel-note" style="padding:12px 14px">
|
|
171
|
+
<h3 data-i18n="settings.models.title" style="margin:0 0 6px">Model settings</h3>
|
|
172
|
+
<p data-i18n="settings.models.hint" style="margin:0 0 8px;color:#666">Default model and per-role overrides.</p>
|
|
173
|
+
<div id="settings-models-slot"></div>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="panel-note" style="padding:12px 14px;margin-top:10px">
|
|
176
|
+
<h3 data-i18n="settings.workers.title" style="margin:0 0 6px">Worker scaling (hot)</h3>
|
|
177
|
+
<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>
|
|
178
|
+
<div style="display:flex;gap:10px;flex-wrap:wrap;align-items:end">
|
|
179
|
+
<label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.max">Max workers / role</span>
|
|
180
|
+
<input id="wk-max" type="number" min="1" max="50" style="width:90px" /></label>
|
|
181
|
+
<label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.min">Min warm / role</span>
|
|
182
|
+
<input id="wk-min" type="number" min="0" max="50" style="width:90px" /></label>
|
|
183
|
+
<label style="display:flex;flex-direction:column;gap:4px;font-size:12px"><span data-i18n="settings.workers.ttl">Idle TTL (ms)</span>
|
|
184
|
+
<input id="wk-ttl" type="number" min="1000" max="86400000" step="1000" style="width:120px" /></label>
|
|
185
|
+
<button id="wk-save" type="button" class="btn btn-small">Apply</button>
|
|
186
|
+
<span id="wk-result" style="margin-left:8px;color:#080"></span>
|
|
187
|
+
</div>
|
|
188
|
+
<p id="wk-mode" style="margin:8px 0 0;color:#666;font-size:12px"></p>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
153
191
|
<div id="tab-workspace" class="tab-panel">
|
|
154
192
|
<div class="workspace-browser">
|
|
155
193
|
<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",
|
package/openclaw.plugin.json
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "2026.11.3",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true
|
|
8
8
|
},
|
package/package.json
CHANGED
|
@@ -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 };
|
|
@@ -286,6 +286,7 @@ export function createControllerHttpServer(deps: ControllerHttpDeps): http.Serve
|
|
|
286
286
|
verifyUpgrade: createWebSocketUpgradeGuard({
|
|
287
287
|
...deps,
|
|
288
288
|
isTunnelHost: (host) => tunnelManagerSingleton?.isTunnelRequest(host) ?? false,
|
|
289
|
+
gateAllows: (req) => tunnelManagerSingleton?.gateAllows(req) ?? false,
|
|
289
290
|
}),
|
|
290
291
|
});
|
|
291
292
|
|
|
@@ -304,6 +305,23 @@ export function createControllerHttpServer(deps: ControllerHttpDeps): http.Serve
|
|
|
304
305
|
logger.warn(`TeamClaw tunnel: boot recovery failed: ${String(err)}`);
|
|
305
306
|
});
|
|
306
307
|
|
|
308
|
+
// Shutdown counterpart of the boot recover above: when the gateway process
|
|
309
|
+
// stops (SIGTERM/SIGINT - e.g. a config change restarting the plugin, or
|
|
310
|
+
// launchctl kickstart), detach() kills ONLY the local connector and keeps
|
|
311
|
+
// both tunnel-state.json and the remote relay tunnel alive, so the next
|
|
312
|
+
// boot's recover() reconnects the SAME tunnel. Without this, the
|
|
313
|
+
// connector's exit handler ran mid-shutdown, cleared the state file and
|
|
314
|
+
// DELETEd the relay tunnel - after which nothing could recover and the
|
|
315
|
+
// hostname served 530 (issue timeline: 2026-11-12, two consecutive
|
|
316
|
+
// restarts). Idempotent and safe to register repeatedly per http server.
|
|
317
|
+
for (const signal of ["SIGTERM", "SIGINT"] as const) {
|
|
318
|
+
process.on(signal, () => {
|
|
319
|
+
try {
|
|
320
|
+
tunnelManagerSingleton?.detach();
|
|
321
|
+
} catch { /* best effort during shutdown */ }
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
307
325
|
setTimeout(() => {
|
|
308
326
|
const state = deps.getTeamState();
|
|
309
327
|
const pendingCount = state
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Controller activity journal (#ui-blindness): an in-memory ring of recent
|
|
2
|
+
// controller-side events, plus a tail reader for the teamclaw-relevant slice
|
|
3
|
+
// of the host gateway log. The web UI's Activity tab polls the journal and
|
|
4
|
+
// follows the log tail so operators can SEE provisioning, sweeps, task
|
|
5
|
+
// routing and tunnel lifecycle without ssh-ing into logs.
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import os from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import type { ServerResponse } from "node:http";
|
|
10
|
+
import { sendJson } from "../protocol.js";
|
|
11
|
+
|
|
12
|
+
// Structural event shape (deliberately NOT importing the WsEvent type from
|
|
13
|
+
// websocket.js: journal <- websocket is fine, but websocket -> journal for
|
|
14
|
+
// the broadcast hook would make the pair a cycle under the arch gate. Keep
|
|
15
|
+
// this module leaf-level.)
|
|
16
|
+
type BroadcastLike = { type?: unknown; data?: unknown };
|
|
17
|
+
|
|
18
|
+
export type JournalEntry = {
|
|
19
|
+
at: number;
|
|
20
|
+
source: "ws" | "provisioner";
|
|
21
|
+
type: string;
|
|
22
|
+
summary: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const RING_LIMIT = 400;
|
|
26
|
+
const ring: JournalEntry[] = [];
|
|
27
|
+
|
|
28
|
+
/** Record a controller event into the ring (callers also broadcast it). */
|
|
29
|
+
export function journalRecord(source: JournalEntry["source"], type: string, summary: string): void {
|
|
30
|
+
ring.push({ at: Date.now(), source, type, summary: summary.slice(0, 240) });
|
|
31
|
+
if (ring.length > RING_LIMIT) ring.splice(0, ring.length - RING_LIMIT);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Summarize a broadcast WS event into the journal (best effort, never throws). */
|
|
35
|
+
export function journalFromWsEvent(event: BroadcastLike): void {
|
|
36
|
+
try {
|
|
37
|
+
const t = String(event.type ?? "unknown");
|
|
38
|
+
if (t === "task:created" || t === "task:completed" || t === "task:updated" || t === "worker:online" || t === "worker:offline" || t === "team:config_updated" || t === "controller:run") {
|
|
39
|
+
journalRecord("ws", t, JSON.stringify(event.data ?? {}).slice(0, 200));
|
|
40
|
+
}
|
|
41
|
+
} catch { /* journal must never break broadcasting */ }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function journalSnapshot(limit = 200): JournalEntry[] {
|
|
45
|
+
return ring.slice(-Math.min(limit, RING_LIMIT));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Host gateway log tail (read-only). The teamclaw plugin logs land in the
|
|
50
|
+
// openclaw gateway log; filter to the teamclaw-relevant lines.
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
const TEAMCLAW_LOG_FILTER = /TeamClaw|TeamAuto|Provisioner|ProvisionedWorker|TaskRouter|tunnel|Controller:/i;
|
|
54
|
+
|
|
55
|
+
function gatewayLogCandidates(): string[] {
|
|
56
|
+
const home = process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw");
|
|
57
|
+
return [
|
|
58
|
+
process.env.TEAMCLAW_GATEWAY_LOG,
|
|
59
|
+
path.join(home, "logs", "gateway.log"),
|
|
60
|
+
path.join(process.env.HOME ?? "", "Library", "Logs", "openclaw", "gateway.log"),
|
|
61
|
+
].filter((p): p is string => Boolean(p));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function readGatewayLogTail(lines = 200, filter = true): { path: string | null; lines: string[] } {
|
|
65
|
+
for (const candidate of gatewayLogCandidates()) {
|
|
66
|
+
try {
|
|
67
|
+
const raw = fs.readFileSync(candidate, "utf8");
|
|
68
|
+
const all = raw.split("\n").filter((l) => l.trim().length > 0);
|
|
69
|
+
const picked = filter ? all.filter((l) => TEAMCLAW_LOG_FILTER.test(l)) : all;
|
|
70
|
+
return { path: candidate, lines: picked.slice(-lines) };
|
|
71
|
+
} catch {
|
|
72
|
+
// try next candidate
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { path: null, lines: [] };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Route handlers (bound in route-table.ts, appended at the table tail on the
|
|
79
|
+
// append-only precedent; both read-only GETs).
|
|
80
|
+
export function controllerJournalRoute({ res, requestUrl }: { res: ServerResponse; requestUrl: URL }): void {
|
|
81
|
+
const limit = Math.min(Math.max(parseInt(requestUrl.searchParams.get("limit") ?? "200", 10) || 200, 1), 400);
|
|
82
|
+
sendJson(res, 200, { events: journalSnapshot(limit) });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function controllerLogTailRoute({ res, requestUrl }: { res: ServerResponse; requestUrl: URL }): void {
|
|
86
|
+
const lines = Math.min(Math.max(parseInt(requestUrl.searchParams.get("lines") ?? "200", 10) || 200, 1), 1000);
|
|
87
|
+
const unfiltered = requestUrl.searchParams.get("all") === "1";
|
|
88
|
+
sendJson(res, 200, readGatewayLogTail(lines, !unfiltered));
|
|
89
|
+
}
|