@d86e/hive-panel 1.0.5 → 1.0.7
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 +5 -0
- package/public/panel.js +198 -25
package/package.json
CHANGED
package/public/panel.css
CHANGED
|
@@ -1148,3 +1148,8 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
|
|
|
1148
1148
|
.hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
|
|
1149
1149
|
.hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
|
|
1150
1150
|
|
|
1151
|
+
.hive-supervisor-inline-sep { color: var(--hive-fg-faint); }
|
|
1152
|
+
.hive-supervisor-inline-state.is-normal::before { background: var(--hive-ok); }
|
|
1153
|
+
.hive-supervisor-inline-state.is-paused::before { background: var(--hive-warn); }
|
|
1154
|
+
.hive-supervisor-inline-state.is-unresponsive::before { background: var(--hive-fg-faint); }
|
|
1155
|
+
|
package/public/panel.js
CHANGED
|
@@ -2033,6 +2033,10 @@ dialog.hive-dialog .hive-dialog-body { flex: 1 1 auto; min-height: 0; overflow:
|
|
|
2033
2033
|
.hive-agents-technical { border-top: 1px solid var(--hive-line-2); padding-top: 8px; }
|
|
2034
2034
|
.hive-agents-technical-summary { color: var(--hive-fg-soft); font-size: 12px; line-height: 1.5; cursor: pointer; }
|
|
2035
2035
|
.hive-agents-technical-json { max-height: 220px; margin-top: 8px; }
|
|
2036
|
+
.hive-supervisor-inline-sep { color: var(--hive-fg-faint); }
|
|
2037
|
+
.hive-supervisor-inline-state.is-normal::before { background: var(--hive-ok); }
|
|
2038
|
+
.hive-supervisor-inline-state.is-paused::before { background: var(--hive-warn); }
|
|
2039
|
+
.hive-supervisor-inline-state.is-unresponsive::before { background: var(--hive-fg-faint); }
|
|
2036
2040
|
`;
|
|
2037
2041
|
|
|
2038
2042
|
const LANE_LABEL_KEYS = Object.freeze({
|
|
@@ -2134,7 +2138,17 @@ export const messages = Object.freeze({
|
|
|
2134
2138
|
"supervisor.runningCount": "running {count}",
|
|
2135
2139
|
"supervisor.idle": "idle",
|
|
2136
2140
|
"supervisor.backoff": "backoff",
|
|
2137
|
-
"supervisor.paused": "
|
|
2141
|
+
"supervisor.paused": "Paused",
|
|
2142
|
+
"supervisor.normal": "Normal",
|
|
2143
|
+
"supervisor.unresponsive": "Unresponsive",
|
|
2144
|
+
"supervisor.noData": "No supervisor data",
|
|
2145
|
+
"supervisor.lastCheck": "Last check {seconds}s ago",
|
|
2146
|
+
"supervisor.lastTick": "Last tick {seconds}s ago",
|
|
2147
|
+
"supervisor.tooltipRunning": "Running {count}",
|
|
2148
|
+
"supervisor.tooltipQueued": "Queued {count}",
|
|
2149
|
+
"supervisor.tooltipError": "Last error: {error}",
|
|
2150
|
+
"supervisor.scopeBlockedTitle": "Cross-repository call blocked",
|
|
2151
|
+
"supervisor.scopeBlocked": "{tool} asked for repository {repo}, but this Session only controls {cwd}. The call was rejected.",
|
|
2138
2152
|
"supervisor.resume": "resume",
|
|
2139
2153
|
"supervisor.resumeAria": "Resume the supervisor for {repo}",
|
|
2140
2154
|
"supervisor.resumeFailed": "Could not resume the supervisor",
|
|
@@ -2389,6 +2403,16 @@ export const messages = Object.freeze({
|
|
|
2389
2403
|
"supervisor.idle": "空闲",
|
|
2390
2404
|
"supervisor.backoff": "退避",
|
|
2391
2405
|
"supervisor.paused": "已暂停",
|
|
2406
|
+
"supervisor.normal": "正常",
|
|
2407
|
+
"supervisor.unresponsive": "未响应",
|
|
2408
|
+
"supervisor.noData": "无监督器数据",
|
|
2409
|
+
"supervisor.lastCheck": "最近一次检查 {seconds} 秒前",
|
|
2410
|
+
"supervisor.lastTick": "最后 tick {seconds} 秒前",
|
|
2411
|
+
"supervisor.tooltipRunning": "运行中 {count} 个",
|
|
2412
|
+
"supervisor.tooltipQueued": "待办 {count} 个",
|
|
2413
|
+
"supervisor.tooltipError": "最近错误:{error}",
|
|
2414
|
+
"supervisor.scopeBlockedTitle": "跨仓库调用被拒绝",
|
|
2415
|
+
"supervisor.scopeBlocked": "{tool} 发起跨仓库请求:仓库 {repo},但本会话只允许操作 {cwd};该调用已被拒绝。",
|
|
2392
2416
|
"supervisor.resume": "恢复",
|
|
2393
2417
|
"supervisor.resumeAria": "恢复 {repo} 的 supervisor",
|
|
2394
2418
|
"supervisor.resumeFailed": "恢复 supervisor 失败",
|
|
@@ -3077,6 +3101,32 @@ function normalizeSupervisorWorkers(source) {
|
|
|
3077
3101
|
return rows;
|
|
3078
3102
|
}
|
|
3079
3103
|
|
|
3104
|
+
function supervisorTopTick(payload) {
|
|
3105
|
+
const candidates = [payload];
|
|
3106
|
+
for (const key of ["data", "result", "status", "supervisor"]) {
|
|
3107
|
+
if (isRecord(payload) && isRecord(payload[key])) candidates.push(payload[key]);
|
|
3108
|
+
}
|
|
3109
|
+
for (const source of candidates) {
|
|
3110
|
+
if (!isRecord(source)) continue;
|
|
3111
|
+
const tick = asString(source.lastTickAt || source.last_tick_at);
|
|
3112
|
+
if (tick) return tick;
|
|
3113
|
+
}
|
|
3114
|
+
return "";
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
function supervisorHeartbeatAt(rows) {
|
|
3118
|
+
if (!Array.isArray(rows)) return null;
|
|
3119
|
+
const top = parseDate(rows.lastTickAt);
|
|
3120
|
+
if (top) return top;
|
|
3121
|
+
let latest = null;
|
|
3122
|
+
for (const row of rows) {
|
|
3123
|
+
if (!isRecord(row)) continue;
|
|
3124
|
+
const check = parseDate(row.lastCheckAt);
|
|
3125
|
+
if (check && (latest === null || check.getTime() > latest.getTime())) latest = check;
|
|
3126
|
+
}
|
|
3127
|
+
return latest;
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3080
3130
|
function normalizeSupervisorStatus(payload) {
|
|
3081
3131
|
const rows = new Map();
|
|
3082
3132
|
for (const raw of supervisorEntriesFrom(payload)) {
|
|
@@ -3093,15 +3143,86 @@ function normalizeSupervisorStatus(payload) {
|
|
|
3093
3143
|
supervisorCount(source.agents) ??
|
|
3094
3144
|
supervisorCount(source.inflight) ??
|
|
3095
3145
|
supervisorCount(source.count);
|
|
3146
|
+
const roleRows = normalizeSupervisorRoles(source);
|
|
3147
|
+
let queued = isRecord(source.backlog) ? supervisorCount(source.backlog.queued) : null;
|
|
3148
|
+
if (queued === null) {
|
|
3149
|
+
let total = 0;
|
|
3150
|
+
let found = false;
|
|
3151
|
+
for (const role of roleRows) {
|
|
3152
|
+
if (supervisorNumber(role.queued) !== null) {
|
|
3153
|
+
total += supervisorNumber(role.queued);
|
|
3154
|
+
found = true;
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
queued = found ? total : null;
|
|
3158
|
+
}
|
|
3159
|
+
const lastError = asString(
|
|
3160
|
+
source.lastError || source.environmentError || source.limitsError,
|
|
3161
|
+
);
|
|
3162
|
+
const lastCheckAt = asString(source.lastCheckAt || source.last_check_at);
|
|
3096
3163
|
let state = "idle";
|
|
3097
3164
|
if (paused) state = "paused";
|
|
3098
3165
|
else if (source.backoff === true || /backoff|back-off|retry|delay|wait/.test(rawState)) state = "backoff";
|
|
3099
3166
|
else if (/run|active|busy|working/.test(rawState)) state = "running";
|
|
3100
3167
|
else if (/idle|ready|free/.test(rawState)) state = "idle";
|
|
3101
3168
|
else if (running !== null && running > 0) state = "running";
|
|
3102
|
-
rows.set(repo, {
|
|
3169
|
+
rows.set(repo, {
|
|
3170
|
+
repo,
|
|
3171
|
+
state,
|
|
3172
|
+
paused,
|
|
3173
|
+
running,
|
|
3174
|
+
queued,
|
|
3175
|
+
lastCheckAt,
|
|
3176
|
+
lastError,
|
|
3177
|
+
roles: roleRows,
|
|
3178
|
+
workers: normalizeSupervisorWorkers(source),
|
|
3179
|
+
});
|
|
3103
3180
|
}
|
|
3104
|
-
|
|
3181
|
+
const result = [...rows.values()].sort((left, right) => left.repo.localeCompare(right.repo));
|
|
3182
|
+
result.lastTickAt = supervisorTopTick(payload);
|
|
3183
|
+
return result;
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
/**
|
|
3187
|
+
* Normalize the supervisor's queen cross-repository rejection observability:
|
|
3188
|
+
* \`crossRepoBlocked\` count + \`lastCrossRepoBlocked { tool, repo, cwd, at }\`.
|
|
3189
|
+
* Older/newer supervisors may nest it under queen-prefixed or repoScope names.
|
|
3190
|
+
* @param {unknown} payload - /api/hive-runner?op=status payload.
|
|
3191
|
+
* @returns {{ count: number, last: { tool: string, repo: string, cwd: string, at: string } | null }}
|
|
3192
|
+
*/
|
|
3193
|
+
export function normalizeSupervisorMeta(payload) {
|
|
3194
|
+
const source = isRecord(payload) ? payload : {};
|
|
3195
|
+
const nested = isRecord(source.repoScopeBlocked) ? source.repoScopeBlocked : {};
|
|
3196
|
+
const rawCount = supervisorNumber(source.crossRepoBlocked)
|
|
3197
|
+
?? supervisorNumber(source.queenCrossRepoBlocked)
|
|
3198
|
+
?? supervisorNumber(nested.count)
|
|
3199
|
+
?? 0;
|
|
3200
|
+
const rawLast = source.lastCrossRepoBlocked || source.lastQueenCrossRepoBlocked || nested.last || null;
|
|
3201
|
+
const last = isRecord(rawLast)
|
|
3202
|
+
? {
|
|
3203
|
+
tool: asString(rawLast.tool),
|
|
3204
|
+
repo: asString(rawLast.repo),
|
|
3205
|
+
cwd: asString(rawLast.cwd),
|
|
3206
|
+
at: asString(rawLast.at),
|
|
3207
|
+
}
|
|
3208
|
+
: null;
|
|
3209
|
+
return { count: rawCount > 0 ? rawCount : 0, last };
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
/**
|
|
3213
|
+
* Render the human-readable reason for a blocked cross-repository call.
|
|
3214
|
+
* @param {{ count: number, last: object|null }} meta - normalized supervisor meta.
|
|
3215
|
+
* @param {(key: string) => string} translate - dictionary lookup.
|
|
3216
|
+
* @returns {string} localized reason, or '' when there is no rejection.
|
|
3217
|
+
*/
|
|
3218
|
+
export function formatScopeBlocked(meta, translate) {
|
|
3219
|
+
const last = meta && meta.last;
|
|
3220
|
+
if (!last) return "";
|
|
3221
|
+
const t = typeof translate === "function" ? translate : (key) => key;
|
|
3222
|
+
return t("supervisor.scopeBlocked")
|
|
3223
|
+
.replace("{tool}", last.tool || "?")
|
|
3224
|
+
.replace("{repo}", last.repo || "?")
|
|
3225
|
+
.replace("{cwd}", last.cwd || "?");
|
|
3105
3226
|
}
|
|
3106
3227
|
|
|
3107
3228
|
function supervisorWorkerCount(row) {
|
|
@@ -3603,6 +3724,8 @@ export function mount(root, options = {}) {
|
|
|
3603
3724
|
let queenBusy = false;
|
|
3604
3725
|
const queenDismissedFallback = new Set();
|
|
3605
3726
|
let supervisorData = [];
|
|
3727
|
+
let supervisorMeta = { count: 0, last: null };
|
|
3728
|
+
let supervisorScopeSignature = null;
|
|
3606
3729
|
let supervisorRequest = null;
|
|
3607
3730
|
let supervisorInlineRow = null;
|
|
3608
3731
|
let limitsOverlay = null;
|
|
@@ -3635,6 +3758,7 @@ export function mount(root, options = {}) {
|
|
|
3635
3758
|
const supervisorInline = element(doc, "span", "hive-supervisor-inline is-hidden");
|
|
3636
3759
|
setAttr(supervisorInline, "aria-label", translate("supervisor.aria"));
|
|
3637
3760
|
const supervisorInlineLabel = element(doc, "span", "hive-supervisor-inline-label", translate("supervisor.label"));
|
|
3761
|
+
const supervisorInlineSep = element(doc, "span", "hive-supervisor-inline-sep", "·");
|
|
3638
3762
|
const supervisorInlineState = element(doc, "span", "hive-supervisor-inline-state", "");
|
|
3639
3763
|
const supervisorInlineResume = element(doc, "button", "hive-btn hive-supervisor-inline-resume is-hidden", translate("supervisor.resume"));
|
|
3640
3764
|
setAttr(supervisorInlineResume, "type", "button");
|
|
@@ -3642,6 +3766,7 @@ export function mount(root, options = {}) {
|
|
|
3642
3766
|
if (supervisorInlineRow) void resumeSupervisor(supervisorInlineRow, supervisorInlineResume);
|
|
3643
3767
|
});
|
|
3644
3768
|
supervisorInline.appendChild(supervisorInlineLabel);
|
|
3769
|
+
supervisorInline.appendChild(supervisorInlineSep);
|
|
3645
3770
|
supervisorInline.appendChild(supervisorInlineState);
|
|
3646
3771
|
supervisorInline.appendChild(supervisorInlineResume);
|
|
3647
3772
|
bar.appendChild(supervisorInline);
|
|
@@ -5963,42 +6088,87 @@ export function mount(root, options = {}) {
|
|
|
5963
6088
|
supervisorInlineState.className = "hive-supervisor-inline-state";
|
|
5964
6089
|
supervisorInlineState.textContent = "";
|
|
5965
6090
|
supervisorInlineResume.className = "hive-btn hive-supervisor-inline-resume is-hidden";
|
|
5966
|
-
setAttr(supervisorInline, "aria-label", translate("supervisor.aria"));
|
|
5967
6091
|
supervisorInlineLabel.textContent = translate("supervisor.label");
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
6092
|
+
supervisorInlineSep.textContent = "·";
|
|
6093
|
+
if (!lastModel) return;
|
|
6094
|
+
|
|
6095
|
+
const row = Array.isArray(supervisorData)
|
|
6096
|
+
? supervisorData.find((entry) => entry.repo === lastModel.repo)
|
|
6097
|
+
: null;
|
|
6098
|
+
const now = Date.now();
|
|
6099
|
+
const heartbeat = supervisorHeartbeatAt(supervisorData);
|
|
6100
|
+
const fresh = heartbeat !== null && now - heartbeat.getTime() <= 90_000;
|
|
6101
|
+
const paused = Boolean(row && (row.paused === true || row.state === "paused"));
|
|
6102
|
+
const status = paused ? "paused" : !row ? "unresponsive" : fresh ? "normal" : "unresponsive";
|
|
6103
|
+
const label =
|
|
6104
|
+
status === "normal"
|
|
6105
|
+
? translate("supervisor.normal")
|
|
6106
|
+
: status === "paused"
|
|
6107
|
+
? translate("supervisor.paused")
|
|
6108
|
+
: translate("supervisor.unresponsive");
|
|
5971
6109
|
|
|
5972
|
-
supervisorInlineRow = row;
|
|
5973
6110
|
supervisorInline.className = "hive-supervisor-inline";
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
6111
|
+
supervisorInlineRow = row || null;
|
|
6112
|
+
supervisorInlineState.className = "hive-supervisor-inline-state is-" + status;
|
|
6113
|
+
supervisorInlineState.textContent = label;
|
|
6114
|
+
|
|
6115
|
+
const details = [];
|
|
6116
|
+
if (heartbeat) {
|
|
6117
|
+
const hasTopTick = Boolean(supervisorData && parseDate(supervisorData.lastTickAt));
|
|
6118
|
+
details.push(
|
|
6119
|
+
translate(hasTopTick ? "supervisor.lastTick" : "supervisor.lastCheck").replace(
|
|
6120
|
+
"{seconds}",
|
|
6121
|
+
String(Math.max(0, Math.floor((now - heartbeat.getTime()) / 1000))),
|
|
6122
|
+
),
|
|
6123
|
+
);
|
|
6124
|
+
} else {
|
|
6125
|
+
details.push(translate("supervisor.noData"));
|
|
6126
|
+
}
|
|
6127
|
+
const running = row ? supervisorWorkerCount(row) : null;
|
|
6128
|
+
details.push(translate("supervisor.tooltipRunning").replace("{count}", String(running === null ? 0 : running)));
|
|
6129
|
+
details.push(translate("supervisor.tooltipQueued").replace("{count}", String(row && row.queued !== null && row.queued !== undefined ? row.queued : 0)));
|
|
6130
|
+
if (row && row.lastError) {
|
|
6131
|
+
details.push(translate("supervisor.tooltipError").replace("{error}", asString(row.lastError)));
|
|
6132
|
+
}
|
|
6133
|
+
if (supervisorMeta.last && supervisorMeta.last.cwd !== "") {
|
|
6134
|
+
details.push(translate("supervisor.scopeBlockedTitle") + ": " + formatScopeBlocked(supervisorMeta, translate));
|
|
6135
|
+
}
|
|
6136
|
+
const tooltip = details.join(" · ");
|
|
6137
|
+
setAttr(supervisorInline, "title", tooltip);
|
|
6138
|
+
setAttr(supervisorInline, "aria-label", tooltip);
|
|
6139
|
+
|
|
6140
|
+
if (paused && row) {
|
|
5989
6141
|
const aria = translate("supervisor.resumeAria").replace("{repo}", row.repo);
|
|
5990
6142
|
supervisorInlineResume.className = "hive-btn hive-supervisor-inline-resume";
|
|
5991
6143
|
setAttr(supervisorInlineResume, "title", aria);
|
|
5992
6144
|
setAttr(supervisorInlineResume, "aria-label", aria);
|
|
5993
6145
|
}
|
|
5994
6146
|
}
|
|
5995
|
-
|
|
5996
6147
|
function setSupervisorData(rows) {
|
|
5997
6148
|
supervisorData = Array.isArray(rows) ? rows : [];
|
|
5998
6149
|
renderSupervisor();
|
|
5999
6150
|
if (lastModel) renderAgents(lastModel);
|
|
6000
6151
|
}
|
|
6001
6152
|
|
|
6153
|
+
|
|
6154
|
+
/**
|
|
6155
|
+
* Surface the supervisor's queen cross-repository rejections in the panel UI:
|
|
6156
|
+
* a toast with the concrete tool/repo/allowed-cwd reason for every new rejection,
|
|
6157
|
+
* plus the same reason in the supervisor strip tooltip. The backend already
|
|
6158
|
+
* refused the tool call; this makes the refusal visible to the human too.
|
|
6159
|
+
*/
|
|
6160
|
+
function applySupervisorMeta(payload) {
|
|
6161
|
+
const meta = normalizeSupervisorMeta(payload);
|
|
6162
|
+
supervisorMeta = meta;
|
|
6163
|
+
if (!meta.last) return;
|
|
6164
|
+
const signature = [meta.count, meta.last.at, meta.last.tool, meta.last.repo, meta.last.cwd].join("|");
|
|
6165
|
+
if (signature !== supervisorScopeSignature) {
|
|
6166
|
+
supervisorScopeSignature = signature;
|
|
6167
|
+
showToast("error", translate("supervisor.scopeBlockedTitle"), formatScopeBlocked(meta, translate));
|
|
6168
|
+
}
|
|
6169
|
+
renderSupervisor();
|
|
6170
|
+
}
|
|
6171
|
+
|
|
6002
6172
|
async function refreshSupervisor(force = false) {
|
|
6003
6173
|
if (destroyed) return;
|
|
6004
6174
|
if (!fetchImpl) {
|
|
@@ -6027,7 +6197,10 @@ export function mount(root, options = {}) {
|
|
|
6027
6197
|
} catch {
|
|
6028
6198
|
payload = null;
|
|
6029
6199
|
}
|
|
6030
|
-
if (!destroyed)
|
|
6200
|
+
if (!destroyed) {
|
|
6201
|
+
setSupervisorData(normalizeSupervisorStatus(payload));
|
|
6202
|
+
applySupervisorMeta(payload);
|
|
6203
|
+
}
|
|
6031
6204
|
} catch {
|
|
6032
6205
|
// The supervisor service is optional; hide the strip without reporting.
|
|
6033
6206
|
if (!destroyed) setSupervisorData([]);
|