@d86e/hive-panel 1.0.1 → 1.0.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.
- package/package.json +1 -1
- package/public/panel.css +17 -0
- package/public/panel.js +198 -11
package/package.json
CHANGED
package/public/panel.css
CHANGED
|
@@ -1131,3 +1131,20 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
|
|
|
1131
1131
|
.hive-agent-count { font: inherit; cursor: pointer; }
|
|
1132
1132
|
.hive-agent-count:disabled { cursor: default; }
|
|
1133
1133
|
|
|
1134
|
+
/* Agents dialog */
|
|
1135
|
+
.hive-agents-dialog { width: min(560px, 92vw); max-height: 80vh; }
|
|
1136
|
+
.hive-agents-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
|
|
1137
|
+
.hive-agents-empty-note { padding: 10px 0; color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; }
|
|
1138
|
+
.hive-agent-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
|
|
1139
|
+
.hive-agent-row-main { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
|
|
1140
|
+
.hive-agent-row-name { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
|
|
1141
|
+
.hive-agent-row-task { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
1142
|
+
.hive-agent-row-meta { color: var(--hive-fg-faint); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
1143
|
+
.hive-agents-workers-title { padding-top: 4px; color: var(--hive-fg); font-size: 14px; font-weight: 700; line-height: 1.5; }
|
|
1144
|
+
.hive-agent-worker-row { padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
|
|
1145
|
+
.hive-agent-worker-task { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
|
|
1146
|
+
.hive-agent-worker-meta { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
1147
|
+
.hive-agents-technical { border-top: 1px solid var(--hive-line-2); padding-top: 8px; }
|
|
1148
|
+
.hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
|
|
1149
|
+
.hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
|
|
1150
|
+
|
package/public/panel.js
CHANGED
|
@@ -2017,6 +2017,22 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
|
|
|
2017
2017
|
}
|
|
2018
2018
|
.hive-agent-count { font: inherit; cursor: pointer; }
|
|
2019
2019
|
.hive-agent-count:disabled { cursor: default; }
|
|
2020
|
+
/* Agents dialog */
|
|
2021
|
+
.hive-agents-dialog { width: min(560px, 92vw); max-height: 80vh; }
|
|
2022
|
+
.hive-agents-body { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
|
|
2023
|
+
.hive-agents-empty-note { padding: 10px 0; color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; }
|
|
2024
|
+
.hive-agent-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
|
|
2025
|
+
.hive-agent-row-main { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
|
|
2026
|
+
.hive-agent-row-name { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
|
|
2027
|
+
.hive-agent-row-task { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
2028
|
+
.hive-agent-row-meta { color: var(--hive-fg-faint); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
2029
|
+
.hive-agents-workers-title { padding-top: 4px; color: var(--hive-fg); font-size: 14px; font-weight: 700; line-height: 1.5; }
|
|
2030
|
+
.hive-agent-worker-row { padding: 8px 0; border-bottom: 1px solid var(--hive-line-2); }
|
|
2031
|
+
.hive-agent-worker-task { color: var(--hive-fg); font-size: 14px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
|
|
2032
|
+
.hive-agent-worker-meta { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
2033
|
+
.hive-agents-technical { border-top: 1px solid var(--hive-line-2); padding-top: 8px; }
|
|
2034
|
+
.hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
|
|
2035
|
+
.hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
|
|
2020
2036
|
`;
|
|
2021
2037
|
|
|
2022
2038
|
const LANE_LABEL_KEYS = Object.freeze({
|
|
@@ -2075,6 +2091,14 @@ export const messages = Object.freeze({
|
|
|
2075
2091
|
"status.actionFailed": "action failed",
|
|
2076
2092
|
"status.disconnected": "disconnected",
|
|
2077
2093
|
"agents.openAria": "Open agent",
|
|
2094
|
+
"agents.runningTooltip": "Running {running} / board identities {identities}",
|
|
2095
|
+
"agents.fallbackTooltip": "Board identities {identities} (supervisor disconnected or repository not registered)",
|
|
2096
|
+
"agents.modalEmpty": "No agents.",
|
|
2097
|
+
"agents.fileCount": "{count} files",
|
|
2098
|
+
"agents.workersTitle": "Active work units",
|
|
2099
|
+
"agents.workerStarted": "Started {time}",
|
|
2100
|
+
"agents.workerElapsed": "Running for {duration}",
|
|
2101
|
+
"agents.technical": "Technical details",
|
|
2078
2102
|
"agent.idle": "idle",
|
|
2079
2103
|
"agent.task": "task",
|
|
2080
2104
|
"agent.unknown": "unknown",
|
|
@@ -2316,6 +2340,14 @@ export const messages = Object.freeze({
|
|
|
2316
2340
|
"status.actionFailed": "操作失败",
|
|
2317
2341
|
"status.disconnected": "连接断开",
|
|
2318
2342
|
"agents.openAria": "打开智能体",
|
|
2343
|
+
"agents.runningTooltip": "运行中 {running} / 公告板身份 {identities}",
|
|
2344
|
+
"agents.fallbackTooltip": "公告板身份 {identities}(监督器未连接或未注册该仓库)",
|
|
2345
|
+
"agents.modalEmpty": "暂无智能体。",
|
|
2346
|
+
"agents.fileCount": "{count} 个文件",
|
|
2347
|
+
"agents.workersTitle": "运行中的工作单元",
|
|
2348
|
+
"agents.workerStarted": "开始于 {time}",
|
|
2349
|
+
"agents.workerElapsed": "已运行 {duration}",
|
|
2350
|
+
"agents.technical": "技术详情",
|
|
2319
2351
|
"agent.idle": "空闲",
|
|
2320
2352
|
"agent.task": "任务",
|
|
2321
2353
|
"agent.unknown": "未知",
|
|
@@ -2889,7 +2921,7 @@ function normalizeSupervisorRoles(source) {
|
|
|
2889
2921
|
const ensure = (role) => {
|
|
2890
2922
|
const name = asString(role).trim();
|
|
2891
2923
|
if (!name) return null;
|
|
2892
|
-
if (!rows.has(name)) rows.set(name, { role: name, limit: null, inFlight: null, queued: null });
|
|
2924
|
+
if (!rows.has(name)) rows.set(name, { role: name, limit: null, live: null, inFlight: null, queued: null });
|
|
2893
2925
|
return rows.get(name);
|
|
2894
2926
|
};
|
|
2895
2927
|
const setLimit = (role, value) => {
|
|
@@ -2923,6 +2955,12 @@ function normalizeSupervisorRoles(source) {
|
|
|
2923
2955
|
break;
|
|
2924
2956
|
}
|
|
2925
2957
|
}
|
|
2958
|
+
for (const field of ["live", "liveCount", "live_count", "workers", "workerCount"]) {
|
|
2959
|
+
if (supervisorNumber(raw[field]) !== null) {
|
|
2960
|
+
row.live = supervisorNumber(raw[field]);
|
|
2961
|
+
break;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2926
2964
|
for (const field of ["queued", "queue", "queued_count", "pending", "pending_count", "waiting", "waiting_count", "backlog"]) {
|
|
2927
2965
|
if (supervisorNumber(raw[field]) !== null) {
|
|
2928
2966
|
row.queued = supervisorNumber(raw[field]);
|
|
@@ -3009,6 +3047,26 @@ function supervisorEntriesFrom(payload, depth = 0) {
|
|
|
3009
3047
|
}
|
|
3010
3048
|
|
|
3011
3049
|
/** Normalize the supervisor status endpoint into per-repository rows. */
|
|
3050
|
+
function normalizeSupervisorWorkers(source) {
|
|
3051
|
+
const raw = source && Array.isArray(source.workers) ? source.workers : [];
|
|
3052
|
+
const rows = [];
|
|
3053
|
+
for (const entry of raw) {
|
|
3054
|
+
if (!isRecord(entry)) continue;
|
|
3055
|
+
const cardId = asString(entry.cardId || entry.card || entry.task || entry.id);
|
|
3056
|
+
if (!cardId) continue;
|
|
3057
|
+
rows.push({
|
|
3058
|
+
cardId,
|
|
3059
|
+
role: asString(entry.role),
|
|
3060
|
+
agent: asString(entry.agent || entry.adapter),
|
|
3061
|
+
agentName: asString(entry.agentName || entry.agent_name || entry.name),
|
|
3062
|
+
sessionId: asString(entry.sessionId || entry.session_id),
|
|
3063
|
+
startedAt: asString(entry.startedAt || entry.started_at),
|
|
3064
|
+
lastOutputAt: asString(entry.lastOutputAt || entry.last_output_at),
|
|
3065
|
+
});
|
|
3066
|
+
}
|
|
3067
|
+
return rows;
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3012
3070
|
function normalizeSupervisorStatus(payload) {
|
|
3013
3071
|
const rows = new Map();
|
|
3014
3072
|
for (const raw of supervisorEntriesFrom(payload)) {
|
|
@@ -3031,11 +3089,30 @@ function normalizeSupervisorStatus(payload) {
|
|
|
3031
3089
|
else if (/run|active|busy|working/.test(rawState)) state = "running";
|
|
3032
3090
|
else if (/idle|ready|free/.test(rawState)) state = "idle";
|
|
3033
3091
|
else if (running !== null && running > 0) state = "running";
|
|
3034
|
-
rows.set(repo, { repo, state, running, roles: normalizeSupervisorRoles(source) });
|
|
3092
|
+
rows.set(repo, { repo, state, running, roles: normalizeSupervisorRoles(source), workers: normalizeSupervisorWorkers(source) });
|
|
3035
3093
|
}
|
|
3036
3094
|
return [...rows.values()].sort((left, right) => left.repo.localeCompare(right.repo));
|
|
3037
3095
|
}
|
|
3038
3096
|
|
|
3097
|
+
function supervisorWorkerCount(row) {
|
|
3098
|
+
if (!row) return null;
|
|
3099
|
+
if (Array.isArray(row.workers) && row.workers.length > 0) return row.workers.length;
|
|
3100
|
+
const direct = supervisorNumber(row.running);
|
|
3101
|
+
if (direct !== null) return direct;
|
|
3102
|
+
let total = 0;
|
|
3103
|
+
let found = false;
|
|
3104
|
+
for (const role of Array.isArray(row.roles) ? row.roles : []) {
|
|
3105
|
+
if (!isRecord(role)) continue;
|
|
3106
|
+
const live = supervisorNumber(role.live);
|
|
3107
|
+
const inFlight = live !== null ? live : supervisorNumber(role.inFlight);
|
|
3108
|
+
if (inFlight !== null) {
|
|
3109
|
+
total += inFlight;
|
|
3110
|
+
found = true;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
return found ? total : null;
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3039
3116
|
function element(doc, tag, className, text) {
|
|
3040
3117
|
const node = doc.createElement(tag);
|
|
3041
3118
|
if (className) node.className = className;
|
|
@@ -3563,7 +3640,7 @@ export function mount(root, options = {}) {
|
|
|
3563
3640
|
const agentsCount = element(doc, "button", "hive-stat hive-agent-count");
|
|
3564
3641
|
setAttr(agentsCount, "type", "button");
|
|
3565
3642
|
agentsCount.addEventListener("click", () => {
|
|
3566
|
-
|
|
3643
|
+
openAgentsDialog();
|
|
3567
3644
|
});
|
|
3568
3645
|
bar.appendChild(agentsCount);
|
|
3569
3646
|
|
|
@@ -5155,6 +5232,101 @@ export function mount(root, options = {}) {
|
|
|
5155
5232
|
return body;
|
|
5156
5233
|
}
|
|
5157
5234
|
|
|
5235
|
+
function taskTitleForId(id) {
|
|
5236
|
+
const wanted = asString(id);
|
|
5237
|
+
if (!wanted || !lastModel) return "";
|
|
5238
|
+
for (const lane of LANE_ORDER) {
|
|
5239
|
+
for (const card of lastModel.lanes[lane] || []) {
|
|
5240
|
+
if (asString(card.id) === wanted) return card.title || wanted;
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5243
|
+
return wanted;
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5246
|
+
function openAgentsDialog() {
|
|
5247
|
+
closeHelp(false);
|
|
5248
|
+
closePlanDialog(false);
|
|
5249
|
+
closeAddDialog(false);
|
|
5250
|
+
closeDrawer(false);
|
|
5251
|
+
closeLimitsDialog(false);
|
|
5252
|
+
|
|
5253
|
+
const dialog = element(doc, "dialog", "hive-dialog hive-agents-dialog");
|
|
5254
|
+
setAttr(dialog, "role", "dialog");
|
|
5255
|
+
setAttr(dialog, "aria-modal", "true");
|
|
5256
|
+
setAttr(dialog, "aria-label", translate("pane.agents"));
|
|
5257
|
+
bindDialogDismiss(dialog, () => {
|
|
5258
|
+
closeModalDialog(dialog);
|
|
5259
|
+
if (!destroyed) focusNode(agentsCount);
|
|
5260
|
+
});
|
|
5261
|
+
|
|
5262
|
+
const head = element(doc, "div", "hive-dialog-head");
|
|
5263
|
+
const titleBox = element(doc, "div", "hive-dialog-head-title");
|
|
5264
|
+
titleBox.appendChild(element(doc, "h2", "hive-dialog-title", translate("pane.agents")));
|
|
5265
|
+
head.appendChild(titleBox);
|
|
5266
|
+
const closeButton = dialogCloseButton(() => {
|
|
5267
|
+
closeModalDialog(dialog);
|
|
5268
|
+
if (!destroyed) focusNode(agentsCount);
|
|
5269
|
+
});
|
|
5270
|
+
head.appendChild(closeButton);
|
|
5271
|
+
dialog.appendChild(head);
|
|
5272
|
+
|
|
5273
|
+
const body = element(doc, "div", "hive-dialog-body hive-agents-body");
|
|
5274
|
+
const agents = lastModel && Array.isArray(lastModel.agents) ? lastModel.agents : [];
|
|
5275
|
+
if (agents.length === 0) {
|
|
5276
|
+
body.appendChild(element(doc, "div", "hive-agents-empty-note", translate("agents.modalEmpty")));
|
|
5277
|
+
}
|
|
5278
|
+
for (const agent of agents) {
|
|
5279
|
+
const row = element(doc, "div", "hive-agent-row");
|
|
5280
|
+
const dot = element(doc, "span", "hive-dot is-" + safeClassToken(agent.state));
|
|
5281
|
+
setAttr(dot, "title", agent.state || translate("agent.idle"));
|
|
5282
|
+
row.appendChild(dot);
|
|
5283
|
+
const content = element(doc, "div", "hive-agent-row-main");
|
|
5284
|
+
content.appendChild(element(doc, "div", "hive-agent-row-name", agent.agent || translate("agent.unknown")));
|
|
5285
|
+
const task = taskTitleForId(agent.task);
|
|
5286
|
+
content.appendChild(
|
|
5287
|
+
element(doc, "div", "hive-agent-row-task", task || translate("agent.idle")),
|
|
5288
|
+
);
|
|
5289
|
+
const meta = [translate("agents.fileCount").replace("{count}", String((agent.files || []).length))];
|
|
5290
|
+
const activity = elapsedLabel(agent.updatedAt);
|
|
5291
|
+
if (activity) meta.push(activity);
|
|
5292
|
+
const metaNode = element(doc, "div", "hive-agent-row-meta", meta.join(" · "));
|
|
5293
|
+
if (agent.updatedAt) setAttr(metaNode, "title", agent.updatedAt);
|
|
5294
|
+
content.appendChild(metaNode);
|
|
5295
|
+
row.appendChild(content);
|
|
5296
|
+
body.appendChild(row);
|
|
5297
|
+
}
|
|
5298
|
+
|
|
5299
|
+
const supervisor = currentSupervisorRow();
|
|
5300
|
+
const workers = supervisor && Array.isArray(supervisor.workers) ? supervisor.workers : [];
|
|
5301
|
+
if (workers.length > 0) {
|
|
5302
|
+
body.appendChild(element(doc, "div", "hive-agents-workers-title", translate("agents.workersTitle")));
|
|
5303
|
+
for (const worker of workers) {
|
|
5304
|
+
const row = element(doc, "div", "hive-agent-worker-row");
|
|
5305
|
+
row.appendChild(
|
|
5306
|
+
element(doc, "div", "hive-agent-worker-task", taskTitleForId(worker.cardId) || worker.cardId),
|
|
5307
|
+
);
|
|
5308
|
+
const meta = [];
|
|
5309
|
+
if (worker.role) meta.push(worker.role);
|
|
5310
|
+
if (worker.startedAt) meta.push(translate("agents.workerStarted").replace("{time}", formatRunStamp(worker.startedAt)));
|
|
5311
|
+
const elapsed = elapsedLabel(worker.startedAt);
|
|
5312
|
+
if (elapsed) meta.push(translate("agents.workerElapsed").replace("{duration}", elapsed));
|
|
5313
|
+
row.appendChild(element(doc, "div", "hive-agent-worker-meta", meta.join(" · ") || worker.agentName || worker.agent || ""));
|
|
5314
|
+
body.appendChild(row);
|
|
5315
|
+
}
|
|
5316
|
+
}
|
|
5317
|
+
|
|
5318
|
+
const technical = element(doc, "details", "hive-agents-technical");
|
|
5319
|
+
technical.appendChild(element(doc, "summary", "hive-agents-technical-summary", translate("agents.technical")));
|
|
5320
|
+
technical.appendChild(
|
|
5321
|
+
element(doc, "pre", "hive-json hive-agents-technical-json", JSON.stringify({ agents, workers }, null, 2)),
|
|
5322
|
+
);
|
|
5323
|
+
body.appendChild(technical);
|
|
5324
|
+
dialog.appendChild(body);
|
|
5325
|
+
|
|
5326
|
+
showModalDialog(dialog);
|
|
5327
|
+
focusNode(closeButton);
|
|
5328
|
+
}
|
|
5329
|
+
|
|
5158
5330
|
function openAgentDrawer(agent) {
|
|
5159
5331
|
const raw = findRawAgent(agent) || { ...agent };
|
|
5160
5332
|
const title = agent.agent || translate("agent.unknown");
|
|
@@ -5490,6 +5662,14 @@ export function mount(root, options = {}) {
|
|
|
5490
5662
|
return;
|
|
5491
5663
|
}
|
|
5492
5664
|
|
|
5665
|
+
// The init action succeeded, so the repository IS initialised. Switch the
|
|
5666
|
+
// open panel out of the init card on this render instead of waiting for the
|
|
5667
|
+
// next poll (a freshly initialised repo may have no refs for a while, and a
|
|
5668
|
+
// failed/racy snapshot fetch must not leave the stale init card up).
|
|
5669
|
+
if (lastSnapshot && typeof lastSnapshot === "object") {
|
|
5670
|
+
setSnapshot({ ...lastSnapshot, initialised: true });
|
|
5671
|
+
}
|
|
5672
|
+
|
|
5493
5673
|
queenNotice = true;
|
|
5494
5674
|
initErrorMessage = "";
|
|
5495
5675
|
if (lastModel) {
|
|
@@ -5751,6 +5931,7 @@ export function mount(root, options = {}) {
|
|
|
5751
5931
|
function setSupervisorData(rows) {
|
|
5752
5932
|
supervisorData = Array.isArray(rows) ? rows : [];
|
|
5753
5933
|
renderSupervisor();
|
|
5934
|
+
if (lastModel) renderAgents(lastModel);
|
|
5754
5935
|
}
|
|
5755
5936
|
|
|
5756
5937
|
async function refreshSupervisor(force = false) {
|
|
@@ -5912,16 +6093,22 @@ export function mount(root, options = {}) {
|
|
|
5912
6093
|
agentsCount.disabled = true;
|
|
5913
6094
|
return;
|
|
5914
6095
|
}
|
|
5915
|
-
const
|
|
6096
|
+
const identities = model.agents.length;
|
|
6097
|
+
const row = currentSupervisorRow();
|
|
6098
|
+
const workers = supervisorWorkerCount(row);
|
|
6099
|
+
const running = workers !== null ? workers : identities;
|
|
5916
6100
|
agentsCount.className = "hive-stat hive-agent-count";
|
|
5917
|
-
agentsCount.textContent = translate("pane.agents") + " " + String(
|
|
5918
|
-
const first =
|
|
6101
|
+
agentsCount.textContent = translate("pane.agents") + " " + String(running);
|
|
6102
|
+
const first = identities > 0 ? model.agents[0] : null;
|
|
5919
6103
|
agentsCount._agent = first;
|
|
5920
|
-
agentsCount.disabled =
|
|
5921
|
-
const message =
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
6104
|
+
agentsCount.disabled = false;
|
|
6105
|
+
const message =
|
|
6106
|
+
workers !== null
|
|
6107
|
+
? translate("agents.runningTooltip")
|
|
6108
|
+
.replace("{running}", String(running))
|
|
6109
|
+
.replace("{identities}", String(identities))
|
|
6110
|
+
: translate("agents.fallbackTooltip").replace("{identities}", String(identities));
|
|
6111
|
+
const label = model.boardError ? message + " · " + model.boardError : message;
|
|
5925
6112
|
setAttr(agentsCount, "title", label);
|
|
5926
6113
|
setAttr(agentsCount, "aria-label", label);
|
|
5927
6114
|
}
|