@d86e/hive-panel 1.0.6 → 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.js +112 -8
package/package.json
CHANGED
package/public/panel.js
CHANGED
|
@@ -2143,9 +2143,12 @@ export const messages = Object.freeze({
|
|
|
2143
2143
|
"supervisor.unresponsive": "Unresponsive",
|
|
2144
2144
|
"supervisor.noData": "No supervisor data",
|
|
2145
2145
|
"supervisor.lastCheck": "Last check {seconds}s ago",
|
|
2146
|
+
"supervisor.lastTick": "Last tick {seconds}s ago",
|
|
2146
2147
|
"supervisor.tooltipRunning": "Running {count}",
|
|
2147
2148
|
"supervisor.tooltipQueued": "Queued {count}",
|
|
2148
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.",
|
|
2149
2152
|
"supervisor.resume": "resume",
|
|
2150
2153
|
"supervisor.resumeAria": "Resume the supervisor for {repo}",
|
|
2151
2154
|
"supervisor.resumeFailed": "Could not resume the supervisor",
|
|
@@ -2404,9 +2407,12 @@ export const messages = Object.freeze({
|
|
|
2404
2407
|
"supervisor.unresponsive": "未响应",
|
|
2405
2408
|
"supervisor.noData": "无监督器数据",
|
|
2406
2409
|
"supervisor.lastCheck": "最近一次检查 {seconds} 秒前",
|
|
2410
|
+
"supervisor.lastTick": "最后 tick {seconds} 秒前",
|
|
2407
2411
|
"supervisor.tooltipRunning": "运行中 {count} 个",
|
|
2408
2412
|
"supervisor.tooltipQueued": "待办 {count} 个",
|
|
2409
2413
|
"supervisor.tooltipError": "最近错误:{error}",
|
|
2414
|
+
"supervisor.scopeBlockedTitle": "跨仓库调用被拒绝",
|
|
2415
|
+
"supervisor.scopeBlocked": "{tool} 发起跨仓库请求:仓库 {repo},但本会话只允许操作 {cwd};该调用已被拒绝。",
|
|
2410
2416
|
"supervisor.resume": "恢复",
|
|
2411
2417
|
"supervisor.resumeAria": "恢复 {repo} 的 supervisor",
|
|
2412
2418
|
"supervisor.resumeFailed": "恢复 supervisor 失败",
|
|
@@ -3095,6 +3101,32 @@ function normalizeSupervisorWorkers(source) {
|
|
|
3095
3101
|
return rows;
|
|
3096
3102
|
}
|
|
3097
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
|
+
|
|
3098
3130
|
function normalizeSupervisorStatus(payload) {
|
|
3099
3131
|
const rows = new Map();
|
|
3100
3132
|
for (const raw of supervisorEntriesFrom(payload)) {
|
|
@@ -3146,7 +3178,51 @@ function normalizeSupervisorStatus(payload) {
|
|
|
3146
3178
|
workers: normalizeSupervisorWorkers(source),
|
|
3147
3179
|
});
|
|
3148
3180
|
}
|
|
3149
|
-
|
|
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 || "?");
|
|
3150
3226
|
}
|
|
3151
3227
|
|
|
3152
3228
|
function supervisorWorkerCount(row) {
|
|
@@ -3648,6 +3724,8 @@ export function mount(root, options = {}) {
|
|
|
3648
3724
|
let queenBusy = false;
|
|
3649
3725
|
const queenDismissedFallback = new Set();
|
|
3650
3726
|
let supervisorData = [];
|
|
3727
|
+
let supervisorMeta = { count: 0, last: null };
|
|
3728
|
+
let supervisorScopeSignature = null;
|
|
3651
3729
|
let supervisorRequest = null;
|
|
3652
3730
|
let supervisorInlineRow = null;
|
|
3653
3731
|
let limitsOverlay = null;
|
|
@@ -6018,10 +6096,10 @@ export function mount(root, options = {}) {
|
|
|
6018
6096
|
? supervisorData.find((entry) => entry.repo === lastModel.repo)
|
|
6019
6097
|
: null;
|
|
6020
6098
|
const now = Date.now();
|
|
6021
|
-
const
|
|
6022
|
-
const fresh =
|
|
6099
|
+
const heartbeat = supervisorHeartbeatAt(supervisorData);
|
|
6100
|
+
const fresh = heartbeat !== null && now - heartbeat.getTime() <= 90_000;
|
|
6023
6101
|
const paused = Boolean(row && (row.paused === true || row.state === "paused"));
|
|
6024
|
-
const status = paused ? "paused" : fresh ? "normal" : "unresponsive";
|
|
6102
|
+
const status = paused ? "paused" : !row ? "unresponsive" : fresh ? "normal" : "unresponsive";
|
|
6025
6103
|
const label =
|
|
6026
6104
|
status === "normal"
|
|
6027
6105
|
? translate("supervisor.normal")
|
|
@@ -6035,11 +6113,12 @@ export function mount(root, options = {}) {
|
|
|
6035
6113
|
supervisorInlineState.textContent = label;
|
|
6036
6114
|
|
|
6037
6115
|
const details = [];
|
|
6038
|
-
if (
|
|
6116
|
+
if (heartbeat) {
|
|
6117
|
+
const hasTopTick = Boolean(supervisorData && parseDate(supervisorData.lastTickAt));
|
|
6039
6118
|
details.push(
|
|
6040
|
-
translate("supervisor.lastCheck").replace(
|
|
6119
|
+
translate(hasTopTick ? "supervisor.lastTick" : "supervisor.lastCheck").replace(
|
|
6041
6120
|
"{seconds}",
|
|
6042
|
-
String(Math.max(0, Math.floor((now -
|
|
6121
|
+
String(Math.max(0, Math.floor((now - heartbeat.getTime()) / 1000))),
|
|
6043
6122
|
),
|
|
6044
6123
|
);
|
|
6045
6124
|
} else {
|
|
@@ -6051,6 +6130,9 @@ export function mount(root, options = {}) {
|
|
|
6051
6130
|
if (row && row.lastError) {
|
|
6052
6131
|
details.push(translate("supervisor.tooltipError").replace("{error}", asString(row.lastError)));
|
|
6053
6132
|
}
|
|
6133
|
+
if (supervisorMeta.last && supervisorMeta.last.cwd !== "") {
|
|
6134
|
+
details.push(translate("supervisor.scopeBlockedTitle") + ": " + formatScopeBlocked(supervisorMeta, translate));
|
|
6135
|
+
}
|
|
6054
6136
|
const tooltip = details.join(" · ");
|
|
6055
6137
|
setAttr(supervisorInline, "title", tooltip);
|
|
6056
6138
|
setAttr(supervisorInline, "aria-label", tooltip);
|
|
@@ -6068,6 +6150,25 @@ export function mount(root, options = {}) {
|
|
|
6068
6150
|
if (lastModel) renderAgents(lastModel);
|
|
6069
6151
|
}
|
|
6070
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
|
+
|
|
6071
6172
|
async function refreshSupervisor(force = false) {
|
|
6072
6173
|
if (destroyed) return;
|
|
6073
6174
|
if (!fetchImpl) {
|
|
@@ -6096,7 +6197,10 @@ export function mount(root, options = {}) {
|
|
|
6096
6197
|
} catch {
|
|
6097
6198
|
payload = null;
|
|
6098
6199
|
}
|
|
6099
|
-
if (!destroyed)
|
|
6200
|
+
if (!destroyed) {
|
|
6201
|
+
setSupervisorData(normalizeSupervisorStatus(payload));
|
|
6202
|
+
applySupervisorMeta(payload);
|
|
6203
|
+
}
|
|
6100
6204
|
} catch {
|
|
6101
6205
|
// The supervisor service is optional; hide the strip without reporting.
|
|
6102
6206
|
if (!destroyed) setSupervisorData([]);
|