@cydm/pie 4.15.2 → 4.15.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.
|
@@ -144,7 +144,7 @@ function formatIpcInputHeader(rawUserText) {
|
|
|
144
144
|
const doneMatch = /^\[ipc-done\]\s+requestId=\S+(?:\s+outcome=(\S+))?[^\n]*(?:\n([\s\S]*))?$/.exec(body);
|
|
145
145
|
if (doneMatch) {
|
|
146
146
|
const outcome = doneMatch[1];
|
|
147
|
-
tag = outcome && outcome !== "done" ? `IPC
|
|
147
|
+
tag = outcome && outcome !== "done" ? `IPC Done (${outcome}) \xB7 ${fromPeer}` : `IPC Done \xB7 ${fromPeer}`;
|
|
148
148
|
body = (doneMatch[2] ?? "").trim();
|
|
149
149
|
}
|
|
150
150
|
if (!body) return `> [${tag}]`;
|
|
@@ -1136,10 +1136,11 @@ var COLOR_TEMPLATE = {
|
|
|
1136
1136
|
red: "red",
|
|
1137
1137
|
violet: "violet"
|
|
1138
1138
|
};
|
|
1139
|
-
function buildButton(action, size) {
|
|
1139
|
+
function buildButton(action, size, fill) {
|
|
1140
1140
|
return {
|
|
1141
1141
|
tag: "button",
|
|
1142
1142
|
...size ? { size } : {},
|
|
1143
|
+
...fill ? { width: "fill" } : {},
|
|
1143
1144
|
text: { tag: "plain_text", content: action.label },
|
|
1144
1145
|
type: action.style ?? "default",
|
|
1145
1146
|
behaviors: [{
|
|
@@ -1224,18 +1225,38 @@ function compileCard(spec) {
|
|
|
1224
1225
|
elements.push({ tag: "markdown", content: spec.footer, text_size: "notation" });
|
|
1225
1226
|
}
|
|
1226
1227
|
const perRow = spec.columnsPerRow ?? 3;
|
|
1228
|
+
const totalRows = Math.ceil(spec.actions.length / perRow);
|
|
1227
1229
|
for (let i = 0; i < spec.actions.length; i += perRow) {
|
|
1228
1230
|
const row = spec.actions.slice(i, i + perRow);
|
|
1229
|
-
|
|
1230
|
-
tag: "
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1231
|
+
const makeCol = (action) => ({
|
|
1232
|
+
tag: "column",
|
|
1233
|
+
width: "weighted",
|
|
1234
|
+
weight: 1,
|
|
1235
|
+
elements: [buildButton(action, void 0, true)]
|
|
1236
|
+
});
|
|
1237
|
+
let columns;
|
|
1238
|
+
if (totalRows > 1 && row.length < perRow) {
|
|
1239
|
+
const startActions = row.filter((a) => a.align !== "end");
|
|
1240
|
+
const endActions = row.filter((a) => a.align === "end");
|
|
1241
|
+
const spacers = Array.from({ length: perRow - row.length }, () => ({
|
|
1234
1242
|
tag: "column",
|
|
1235
1243
|
width: "weighted",
|
|
1236
1244
|
weight: 1,
|
|
1237
|
-
elements: [
|
|
1238
|
-
}))
|
|
1245
|
+
elements: []
|
|
1246
|
+
}));
|
|
1247
|
+
columns = [
|
|
1248
|
+
...startActions.map(makeCol),
|
|
1249
|
+
...spacers,
|
|
1250
|
+
...endActions.map(makeCol)
|
|
1251
|
+
];
|
|
1252
|
+
} else {
|
|
1253
|
+
columns = row.map(makeCol);
|
|
1254
|
+
}
|
|
1255
|
+
elements.push({
|
|
1256
|
+
tag: "column_set",
|
|
1257
|
+
flex_mode: "none",
|
|
1258
|
+
horizontal_spacing: "medium",
|
|
1259
|
+
columns
|
|
1239
1260
|
});
|
|
1240
1261
|
}
|
|
1241
1262
|
const doc = {
|
|
@@ -3253,10 +3274,10 @@ Malformed verified Peek response.`;
|
|
|
3253
3274
|
if (turnEntries.length > 0) {
|
|
3254
3275
|
const meta = parsePeekMeta(receipt);
|
|
3255
3276
|
const modelTag = typeof report.model === "string" && report.model ? ` \xB7 \`${cleanCodeSpan(report.model, 56)}\`` : "";
|
|
3256
|
-
const pageTag = meta.totalPages > 1 ? ` \xB7
|
|
3277
|
+
const pageTag = meta.totalPages > 1 ? ` \xB7 Page ${meta.page}/${meta.totalPages}` : "";
|
|
3257
3278
|
const header = `**Live status:** ${report.active ? "working" : "idle"}${modelTag} \xB7 snapshot ${age(report.generatedAt)}${report.active && report.startedAt ? ` \xB7 active ${age(report.startedAt)}` : ""}${pageTag}`;
|
|
3258
3279
|
const blocks = turnEntries.map((e) => {
|
|
3259
|
-
const roleLabel = e.role === "user" ? e.tag === "ipc-done" ? "\u{1F4E8} Worker
|
|
3280
|
+
const roleLabel = e.role === "user" ? e.tag === "ipc-done" ? "\u{1F4E8} Worker Report" : e.tag === "ipc-check" ? "\u23F1 Progress Check" : "\u{1F464} User" : e.tag === "error" ? "\u26A0\uFE0F Assistant (error)" : e.tag === "aborted" ? "\u23F9 Assistant (aborted)" : "\u{1F916} Assistant";
|
|
3260
3281
|
const when = typeof e.at === "number" ? ` \xB7 ${age(e.at)}` : "";
|
|
3261
3282
|
return `**${roleLabel}${when}**
|
|
3262
3283
|
${e.text}`;
|
|
@@ -3264,17 +3285,17 @@ ${e.text}`;
|
|
|
3264
3285
|
const sections = [header, ...blocks];
|
|
3265
3286
|
if (report.active && meta.page === 1 && items.length > 0) {
|
|
3266
3287
|
const lastTurnAssistant = [...turnEntries].reverse().find((e) => e.role === "assistant")?.text;
|
|
3267
|
-
const liveLines = items.filter((i) => !(i.kind === "assistant" && i.text === lastTurnAssistant)).map((i) => i.kind === "tool" ? `- \u{1F527} ${age(i.at)} \xB7 ${i.text}` : `**\u26A1
|
|
3288
|
+
const liveLines = items.filter((i) => !(i.kind === "assistant" && i.text === lastTurnAssistant)).map((i) => i.kind === "tool" ? `- \u{1F527} ${age(i.at)} \xB7 ${i.text}` : `**\u26A1 Live Output \xB7 ${age(i.at)}**
|
|
3268
3289
|
${i.text}`);
|
|
3269
3290
|
if (liveLines.length > 0) {
|
|
3270
3291
|
sections.push(`---
|
|
3271
|
-
**\u26A1
|
|
3292
|
+
**\u26A1 Running Now**
|
|
3272
3293
|
${liveLines.join("\n\n")}`);
|
|
3273
3294
|
}
|
|
3274
3295
|
}
|
|
3275
3296
|
const budget = typeof report.turns?.charBudget === "number" ? report.turns.charBudget : 1e3;
|
|
3276
3297
|
const total = typeof report.turns?.totalEntries === "number" ? report.turns.totalEntries : turnEntries.length;
|
|
3277
|
-
sections.push(`_Calm
|
|
3298
|
+
sections.push(`_Calm text snapshot (~${budget} chars/page, ${total} entries) \xB7 thinking & tool details omitted_`);
|
|
3278
3299
|
return sections.join("\n\n");
|
|
3279
3300
|
}
|
|
3280
3301
|
const live = items.map((i) => i.kind === "tool" ? `- \u{1F527} ${age(i.at)} \xB7 ${i.text}` : `**Assistant activity \xB7 ${age(i.at)}**
|
|
@@ -5480,13 +5501,13 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5480
5501
|
if (!info || !info.allowed) {
|
|
5481
5502
|
if (!hasLivePeer(sessionId)) {
|
|
5482
5503
|
cooldownUntil.set(sessionId, nowFn() + cooldownMs);
|
|
5483
|
-
const reason = sanitizeLiteralMarkdown(info?.reason ?? "
|
|
5504
|
+
const reason = sanitizeLiteralMarkdown(info?.reason ?? "no resumable session history found");
|
|
5484
5505
|
ctx.log(`im-forward: auto-wake refused for ${sessionId}: ${reason}`);
|
|
5485
5506
|
await sendNotice(
|
|
5486
5507
|
sessionId,
|
|
5487
5508
|
first.event,
|
|
5488
5509
|
first.meta,
|
|
5489
|
-
`\u{1F4A4}
|
|
5510
|
+
`\u{1F4A4} The worker for this thread is offline and cannot auto-wake: ${reason}`,
|
|
5490
5511
|
"unresumable"
|
|
5491
5512
|
);
|
|
5492
5513
|
return;
|
|
@@ -5503,7 +5524,7 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5503
5524
|
sessionId,
|
|
5504
5525
|
first.event,
|
|
5505
5526
|
first.meta,
|
|
5506
|
-
`\u26A0\uFE0F
|
|
5527
|
+
`\u26A0\uFE0F Failed to auto-wake worker: ${sanitizeLiteralMarkdown(res.detail)}`,
|
|
5507
5528
|
"spawn-failed"
|
|
5508
5529
|
);
|
|
5509
5530
|
return;
|
|
@@ -5536,7 +5557,7 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5536
5557
|
sessionId,
|
|
5537
5558
|
next.event,
|
|
5538
5559
|
next.meta,
|
|
5539
|
-
"\u23F1\uFE0F Worker
|
|
5560
|
+
"\u23F1\uFE0F Worker auto-wake timed out. Resend your message shortly or check status in `/panel`.",
|
|
5540
5561
|
"timeout"
|
|
5541
5562
|
);
|
|
5542
5563
|
}
|
|
@@ -5552,7 +5573,7 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5552
5573
|
sessionId,
|
|
5553
5574
|
first.event,
|
|
5554
5575
|
first.meta,
|
|
5555
|
-
`\u26A0\uFE0F
|
|
5576
|
+
`\u26A0\uFE0F Worker auto-wake error: ${sanitizeLiteralMarkdown(error instanceof Error ? error.message : String(error))}`,
|
|
5556
5577
|
"error"
|
|
5557
5578
|
);
|
|
5558
5579
|
} finally {
|
|
@@ -5570,7 +5591,7 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5570
5591
|
sessionId,
|
|
5571
5592
|
event,
|
|
5572
5593
|
meta,
|
|
5573
|
-
"\u26D4\uFE0F
|
|
5594
|
+
"\u26D4\uFE0F The worker for this thread is offline and you lack permission to auto-wake it (restricted by panelAccess=allowUsers).",
|
|
5574
5595
|
"denied"
|
|
5575
5596
|
);
|
|
5576
5597
|
}
|
|
@@ -5585,7 +5606,7 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5585
5606
|
sessionId,
|
|
5586
5607
|
event,
|
|
5587
5608
|
meta,
|
|
5588
|
-
"\u23F3 Worker
|
|
5609
|
+
"\u23F3 Worker is waking up and the pending queue is full. Wait a few seconds and retry.",
|
|
5589
5610
|
"queue-full"
|
|
5590
5611
|
);
|
|
5591
5612
|
return;
|
|
@@ -5613,7 +5634,7 @@ function createAutoWakeCoordinator(ctx) {
|
|
|
5613
5634
|
sessionId,
|
|
5614
5635
|
event,
|
|
5615
5636
|
meta,
|
|
5616
|
-
"\u23F3
|
|
5637
|
+
"\u23F3 Too many workers are waking up concurrently. Retry in a few seconds.",
|
|
5617
5638
|
"busy-cap"
|
|
5618
5639
|
);
|
|
5619
5640
|
return;
|
|
@@ -6506,7 +6527,7 @@ async function acquireLock(actionId, triggerName, timeoutMs = DEFAULT_TIMEOUT_MS
|
|
|
6506
6527
|
holder: {
|
|
6507
6528
|
triggerName: existing.triggerName,
|
|
6508
6529
|
startedAt: existing.startedAt,
|
|
6509
|
-
note:
|
|
6530
|
+
note: `Previous run's process identity could not be verified (argv may have changed via exec wrapper). Not auto-releasing for safety. Confirm the old process stopped, then delete ${dir} to recover.`
|
|
6510
6531
|
}
|
|
6511
6532
|
};
|
|
6512
6533
|
}
|
|
@@ -6670,13 +6691,12 @@ function composeWorkerCard(peer, opts = {}) {
|
|
|
6670
6691
|
{ id: `panel.worker.models.${peer.instanceId}`, label: "\u{1F39A} Model" },
|
|
6671
6692
|
...peer.sessionControls ? [
|
|
6672
6693
|
{ id: `panel.context.${peer.instanceId}`, label: "\u{1F4CA} Context", payload: fromWorker },
|
|
6673
|
-
{ id: `panel.compact.${peer.instanceId}`, label: "\u{1F9F9} Compact", payload: fromWorker },
|
|
6674
6694
|
{ id: `panel.tree.${peer.instanceId}`, label: "\u{1F333} Tree", payload: fromWorker }
|
|
6675
6695
|
] : [],
|
|
6676
6696
|
{ id: `panel.worker.cron.${peer.instanceId}`, label: workerCron > 0 ? `\u23F0 Cron (${workerCron})` : "\u23F0 Cron" },
|
|
6697
|
+
...peer.workerPeek && peer.sessionId ? [{ id: `panel.peek.${peer.instanceId}`, label: "\u{1F440} Peek", payload: peekCtx }] : [],
|
|
6677
6698
|
{ id: `panel.stop.${peer.instanceId}`, label: "\u23F9 Stop", payload: fromWorker },
|
|
6678
|
-
...canQuit ? [{ id: `panel.quit.${peer.instanceId}`, label: "\u{1F6AA} Quit", style: "danger" }] : []
|
|
6679
|
-
...peer.workerPeek && peer.sessionId ? [{ id: `panel.peek.${peer.instanceId}`, label: "\u{1F440} Peek", payload: peekCtx }] : []
|
|
6699
|
+
...canQuit ? [{ id: `panel.quit.${peer.instanceId}`, label: "\u{1F6AA} Quit", style: "danger" }] : []
|
|
6680
6700
|
];
|
|
6681
6701
|
const title = workerDisplayTitle(peer);
|
|
6682
6702
|
const modelDisplay = formatPeerModel(peer);
|
|
@@ -6686,21 +6706,21 @@ function composeWorkerCard(peer, opts = {}) {
|
|
|
6686
6706
|
const visibleActions = wActions.slice(0, maxCustom);
|
|
6687
6707
|
const items = visibleActions.map((a) => ({
|
|
6688
6708
|
text: `**${cleanInline(a.label, 36)}**
|
|
6689
|
-
${a.runs}
|
|
6709
|
+
${a.runs} run(s) \xB7 last ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
6690
6710
|
actions: [{
|
|
6691
6711
|
id: `panel.action.${a.id}`,
|
|
6692
|
-
label: "\u25B6\uFE0F
|
|
6712
|
+
label: "\u25B6\uFE0F Run",
|
|
6693
6713
|
payload: workerCtx
|
|
6694
6714
|
}]
|
|
6695
6715
|
}));
|
|
6696
|
-
const footer = wActions.length > maxCustom ?
|
|
6716
|
+
const footer = wActions.length > maxCustom ? `More actions (copy to run): ${wActions.slice(maxCustom).map((a) => `\`/card panel.action.${cleanCodeSpan(a.id, 32)} ${cleanCodeSpan(JSON.stringify({ worker: { ref: peer.instanceId } }), 80)}\``).join(" \xB7 ")}` : wActions.length === 0 ? "No custom worker actions yet (actions with scope=worker appear here)." : "Inline buttons run in this worker's context (zero LLM).";
|
|
6697
6717
|
const threadUrl = resolveSessionThreadUrl(peer.sessionId);
|
|
6698
6718
|
const infoLines = [
|
|
6699
|
-
`- **name
|
|
6700
|
-
`- **model
|
|
6701
|
-
`- **host
|
|
6702
|
-
...peer.cwd ? [`- **cwd
|
|
6703
|
-
...threadUrl ? [`- **thread
|
|
6719
|
+
`- **name**: ${cleanInline(peer.name, 48)} \xB7 **state**: ${cleanInline(state, 48)}`,
|
|
6720
|
+
`- **model**: \`${cleanCodeSpan(modelDisplay, 56)}\``,
|
|
6721
|
+
`- **host**: ${cleanInline(managedLabel, 48)} \xB7 **version**: ${cleanInline(peer.version ?? "\u2014", 24)}`,
|
|
6722
|
+
...peer.cwd ? [`- **cwd**: \`${cleanCodeSpan(peer.cwd, 96)}\``] : [],
|
|
6723
|
+
...threadUrl ? [`- **thread**: [\u{1F4AC} Open Thread \u2197](${threadUrl})`] : []
|
|
6704
6724
|
];
|
|
6705
6725
|
return {
|
|
6706
6726
|
title: `\u{1F527} ${title}`,
|
|
@@ -6712,14 +6732,14 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
|
6712
6732
|
footer,
|
|
6713
6733
|
actions: [
|
|
6714
6734
|
...fixedActions,
|
|
6715
|
-
...hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB}
|
|
6735
|
+
...hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB} Home", align: "end" }]
|
|
6716
6736
|
]
|
|
6717
6737
|
};
|
|
6718
6738
|
}
|
|
6719
6739
|
function composeTargetModelsCard(peer, catalog, opts) {
|
|
6720
6740
|
const isManager = opts.scope === "manager";
|
|
6721
6741
|
const navCmd = isManager ? "panel.models" : `panel.worker.models.${peer.instanceId}`;
|
|
6722
|
-
const backAction = isManager ? { id: "panel.home", label: "\u21A9\uFE0F
|
|
6742
|
+
const backAction = isManager ? { id: "panel.home", label: "\u21A9\uFE0F Home" } : { id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F Worker" };
|
|
6723
6743
|
const controlMeta = { from: opts.scope, peer: peer.instanceId };
|
|
6724
6744
|
const displayTitle = isManager ? "Manager" : workerDisplayTitle(peer);
|
|
6725
6745
|
const safeDisplayTitle = cleanInline(displayTitle, 36);
|
|
@@ -6745,15 +6765,15 @@ ${cleanInline(m.name, 48)}` : "";
|
|
|
6745
6765
|
text: `${isCur ? "\u2605 " : ""}\`${cleanCodeSpan(m.id, 44)}\`${subtitleLine}`,
|
|
6746
6766
|
actions: [{
|
|
6747
6767
|
id: `panel.model.${peer.instanceId}.${m.ref}`,
|
|
6748
|
-
label: isCur ? "\u2713
|
|
6768
|
+
label: isCur ? "\u2713 Active" : "Select",
|
|
6749
6769
|
...isCur ? { style: "primary" } : {},
|
|
6750
6770
|
payload: { ...controlMeta, provider: selectedGroup.provider, page: page2 }
|
|
6751
6771
|
}]
|
|
6752
6772
|
};
|
|
6753
6773
|
});
|
|
6754
6774
|
const navButtons2 = [];
|
|
6755
|
-
if (page2 > 1) navButtons2.push({ id: navCmd, label: `\u25C0\uFE0F
|
|
6756
|
-
if (page2 < totalPages2) navButtons2.push({ id: navCmd, label:
|
|
6775
|
+
if (page2 > 1) navButtons2.push({ id: navCmd, label: `\u25C0\uFE0F Page ${page2 - 1}`, payload: { provider: selectedGroup.provider, page: page2 - 1 } });
|
|
6776
|
+
if (page2 < totalPages2) navButtons2.push({ id: navCmd, label: `Page ${page2 + 1} \u25B6\uFE0F`, payload: { provider: selectedGroup.provider, page: page2 + 1 } });
|
|
6757
6777
|
return {
|
|
6758
6778
|
title: `\u{1F39A} ${selectedGroup.provider} \xB7 ${displayTitle}`,
|
|
6759
6779
|
subtitle: `${selectedGroup.models.length} model(s)${totalPages2 > 1 ? ` \xB7 p${page2}/${totalPages2}` : ""} \xB7 Current: ${currentSummary}`,
|
|
@@ -6761,10 +6781,10 @@ ${cleanInline(m.name, 48)}` : "";
|
|
|
6761
6781
|
columnsPerRow: cols,
|
|
6762
6782
|
body: headerInfo,
|
|
6763
6783
|
items: items2,
|
|
6764
|
-
footer: "
|
|
6784
|
+
footer: "Tap a button to switch immediately; applies on the next turn (zero LLM).",
|
|
6765
6785
|
actions: [
|
|
6766
6786
|
...navButtons2,
|
|
6767
|
-
{ id: navCmd, label: "\u21A9\uFE0F
|
|
6787
|
+
{ id: navCmd, label: "\u21A9\uFE0F All Providers", payload: {} },
|
|
6768
6788
|
backAction
|
|
6769
6789
|
].slice(0, 6)
|
|
6770
6790
|
};
|
|
@@ -6772,7 +6792,7 @@ ${cleanInline(m.name, 48)}` : "";
|
|
|
6772
6792
|
const advertisedThinkingLevels = peer.supportedThinkingLevels;
|
|
6773
6793
|
const dynamicThinkingLevels = Array.isArray(advertisedThinkingLevels) ? advertisedThinkingLevels.length === 0 || advertisedThinkingLevels.length === 1 && advertisedThinkingLevels[0] === "off" ? [] : advertisedThinkingLevels.slice(0, 7) : THINKING_LEVELS;
|
|
6774
6794
|
const activeThinkingDisplay = peer.effectiveThinkingLevel ?? peer.thinkingLevel;
|
|
6775
|
-
const thinkingHint = Array.isArray(advertisedThinkingLevels) && dynamicThinkingLevels.length === 0 ? advertisedThinkingLevels.length === 0 ? "\
|
|
6795
|
+
const thinkingHint = Array.isArray(advertisedThinkingLevels) && dynamicThinkingLevels.length === 0 ? advertisedThinkingLevels.length === 0 ? "\n_Current model uses fixed built-in reasoning (thinking levels cannot be switched)._" : "\n_Current model does not support thinking levels._" : "";
|
|
6776
6796
|
const makeThinkingButtons = (overviewPage) => dynamicThinkingLevels.map((level) => {
|
|
6777
6797
|
const isCur = activeThinkingDisplay === level;
|
|
6778
6798
|
return {
|
|
@@ -6792,7 +6812,7 @@ ${cleanInline(m.name, 48)}` : "";
|
|
|
6792
6812
|
text: `${isCur ? "\u2605 " : ""}\`${cleanCodeSpan(m.ref, 48)}\`${subtitleLine}`,
|
|
6793
6813
|
actions: [{
|
|
6794
6814
|
id: `panel.model.${peer.instanceId}.${m.ref}`,
|
|
6795
|
-
label: isCur ? "\u2713
|
|
6815
|
+
label: isCur ? "\u2713 Active" : "Select",
|
|
6796
6816
|
...isCur ? { style: "primary" } : {},
|
|
6797
6817
|
payload: controlMeta
|
|
6798
6818
|
}]
|
|
@@ -6805,9 +6825,9 @@ ${cleanInline(m.name, 48)}` : "";
|
|
|
6805
6825
|
columnsPerRow: cols,
|
|
6806
6826
|
body: allModels.length > 0 ? `${headerInfo}${thinkingHint}` : `${headerInfo}${thinkingHint}
|
|
6807
6827
|
|
|
6808
|
-
|
|
6828
|
+
_No available models found in models.json._`,
|
|
6809
6829
|
...items2.length > 0 ? { items: items2 } : {},
|
|
6810
|
-
footer: "
|
|
6830
|
+
footer: "Use inline buttons for Model and \u{1F9E0} buttons below for Thinking; applies next turn (zero LLM).",
|
|
6811
6831
|
actions: [
|
|
6812
6832
|
...makeThinkingButtons(),
|
|
6813
6833
|
backAction
|
|
@@ -6827,12 +6847,12 @@ _models.json \u4E2D\u672A\u627E\u5230\u53EF\u7528\u6A21\u578B_`,
|
|
|
6827
6847
|
const preview = overflow > 0 ? `${sample.join(", ")} (+${overflow} more)` : sample.join(", ");
|
|
6828
6848
|
const action = g.models.length === 1 ? {
|
|
6829
6849
|
id: `panel.model.${peer.instanceId}.${g.models[0].ref}`,
|
|
6830
|
-
label: currentModel === g.models[0].ref ? "\u2713
|
|
6850
|
+
label: currentModel === g.models[0].ref ? "\u2713 Active" : "Select",
|
|
6831
6851
|
...currentModel === g.models[0].ref ? { style: "primary" } : {},
|
|
6832
6852
|
payload: { ...controlMeta, page }
|
|
6833
6853
|
} : {
|
|
6834
6854
|
id: navCmd,
|
|
6835
|
-
label: hasCur ? "\u2605
|
|
6855
|
+
label: hasCur ? "\u2605 Expand" : "Expand",
|
|
6836
6856
|
...hasCur ? { style: "primary" } : {},
|
|
6837
6857
|
payload: { provider: g.provider, page: 1 }
|
|
6838
6858
|
};
|
|
@@ -6843,8 +6863,8 @@ _models.json \u4E2D\u672A\u627E\u5230\u53EF\u7528\u6A21\u578B_`,
|
|
|
6843
6863
|
};
|
|
6844
6864
|
});
|
|
6845
6865
|
const navButtons = [];
|
|
6846
|
-
if (page > 1) navButtons.push({ id: navCmd, label: `\u25C0\uFE0F
|
|
6847
|
-
if (page < totalPages) navButtons.push({ id: navCmd, label:
|
|
6866
|
+
if (page > 1) navButtons.push({ id: navCmd, label: `\u25C0\uFE0F Page ${page - 1}`, payload: { page: page - 1 } });
|
|
6867
|
+
if (page < totalPages) navButtons.push({ id: navCmd, label: `Page ${page + 1} \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
6848
6868
|
return {
|
|
6849
6869
|
title: `\u{1F39A} Model & Thinking \xB7 ${displayTitle}`,
|
|
6850
6870
|
subtitle: `Current: ${currentSummary} \xB7 ${catalog.length} providers / ${totalModels} models${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""}`,
|
|
@@ -6852,7 +6872,7 @@ _models.json \u4E2D\u672A\u627E\u5230\u53EF\u7528\u6A21\u578B_`,
|
|
|
6852
6872
|
columnsPerRow: cols,
|
|
6853
6873
|
body: `${headerInfo}${thinkingHint}`,
|
|
6854
6874
|
items,
|
|
6855
|
-
footer: "
|
|
6875
|
+
footer: "Single-model providers switch in one tap; multi-model providers expand. Use \u{1F9E0} buttons below for Thinking (zero LLM).",
|
|
6856
6876
|
actions: [
|
|
6857
6877
|
...navButtons,
|
|
6858
6878
|
...makeThinkingButtons(page),
|
|
@@ -6869,34 +6889,34 @@ function composeWorkerQuitConfirmCard(peer, opts = {}) {
|
|
|
6869
6889
|
const canQuit = canRemotelyQuitPeer(peer);
|
|
6870
6890
|
if (!canQuit) {
|
|
6871
6891
|
return {
|
|
6872
|
-
title: "\u26D4\uFE0F
|
|
6892
|
+
title: "\u26D4\uFE0F Remote Quit Unavailable",
|
|
6873
6893
|
color: "red",
|
|
6874
6894
|
columnsPerRow: opts.inThread ? 2 : 3,
|
|
6875
|
-
body: `${peer.isManager ? "
|
|
6895
|
+
body: `${peer.isManager ? "The manager host" : "Interactive TUI sessions"} cannot be quit remotely from IM (you can still use Stop / Model / Context / Tree).`,
|
|
6876
6896
|
actions: [
|
|
6877
6897
|
{ id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F Back" },
|
|
6878
|
-
...hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB}
|
|
6898
|
+
...hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB} Home" }]
|
|
6879
6899
|
]
|
|
6880
6900
|
};
|
|
6881
6901
|
}
|
|
6882
6902
|
const state = peer.state === "working" && peer.currentTool ? `working\xB7${peer.currentTool}` : peer.state;
|
|
6883
6903
|
const quitPayload = { quit: { ref: peer.instanceId, session: peer.sessionId, ...managed?.generation ? { generation: managed.generation } : {} } };
|
|
6884
6904
|
return {
|
|
6885
|
-
title: `\u{1F6AA}
|
|
6905
|
+
title: `\u{1F6AA} Confirm Quit \xB7 ${workerDisplayTitle(peer)}`,
|
|
6886
6906
|
subtitle: `${peer.name} \xB7 ${state}`,
|
|
6887
6907
|
color: "red",
|
|
6888
6908
|
columnsPerRow: opts.inThread ? 2 : 3,
|
|
6889
6909
|
body: [
|
|
6890
|
-
`- **name
|
|
6891
|
-
`- **session
|
|
6892
|
-
...peer.cwd ? [`- **cwd
|
|
6910
|
+
`- **name**: ${cleanInline(peer.name, 48)} \xB7 **state**: ${cleanInline(state, 48)}`,
|
|
6911
|
+
`- **session**: \`${cleanCodeSpan(peer.sessionId, 64)}\``,
|
|
6912
|
+
...peer.cwd ? [`- **cwd**: \`${cleanCodeSpan(peer.cwd, 96)}\``] : [],
|
|
6893
6913
|
``,
|
|
6894
|
-
peer.state === "working" ? "\u26A0\uFE0F
|
|
6914
|
+
peer.state === "working" ? "\u26A0\uFE0F This worker is currently running a turn. Graceful quit will abort the turn, flush state, and release locks." : "Graceful quit tells this worker to flush state, release IPC locks, and exit cleanly (session history is preserved for Resume)."
|
|
6895
6915
|
].join("\n"),
|
|
6896
6916
|
actions: [
|
|
6897
|
-
{ id: `panel.quit.confirm.${peer.instanceId}`, label: "\u2705
|
|
6898
|
-
...managed ? [{ id: `panel.quit.force.${peer.instanceId}`, label: "\u{1F480}
|
|
6899
|
-
{ id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F
|
|
6917
|
+
{ id: `panel.quit.confirm.${peer.instanceId}`, label: "\u2705 Graceful Quit", style: "danger", payload: quitPayload },
|
|
6918
|
+
...managed ? [{ id: `panel.quit.force.${peer.instanceId}`, label: "\u{1F480} Force Kill", style: "danger", payload: quitPayload }] : [],
|
|
6919
|
+
{ id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F Cancel" }
|
|
6900
6920
|
]
|
|
6901
6921
|
};
|
|
6902
6922
|
}
|
|
@@ -6905,14 +6925,14 @@ function composeOfflineWorkerCard(sessionId, opts = {}) {
|
|
|
6905
6925
|
const bridge = currentWorkerLifecycleBridge();
|
|
6906
6926
|
const resumable = sessionId ? bridge?.inspectResumable(sessionId) : void 0;
|
|
6907
6927
|
const lines = [
|
|
6908
|
-
sessionId ?
|
|
6928
|
+
sessionId ? `Worker session \`${cleanCodeSpan(sessionId, 64)}\` for this thread is offline (it may have exited or expired via TTL).` : "This session is currently offline (it may have exited or expired via TTL)."
|
|
6909
6929
|
];
|
|
6910
6930
|
if (resumable) {
|
|
6911
6931
|
lines.push(
|
|
6912
6932
|
"",
|
|
6913
|
-
`- **name
|
|
6914
|
-
`- **cwd
|
|
6915
|
-
`- **resume
|
|
6933
|
+
`- **name**: ${cleanInline(resumable.name, 48)}`,
|
|
6934
|
+
`- **cwd**: \`${cleanCodeSpan(resumable.cwd, 96)}\``,
|
|
6935
|
+
`- **resume**: ${resumable.allowed ? "ready" : `unavailable (${cleanInline(resumable.reason ?? "blocked", 64)})`}`
|
|
6916
6936
|
);
|
|
6917
6937
|
}
|
|
6918
6938
|
const actions = [];
|
|
@@ -6927,10 +6947,10 @@ function composeOfflineWorkerCard(sessionId, opts = {}) {
|
|
|
6927
6947
|
actions.push({ id: `panel.worker.${opts.peerId}`, label: "\u{1F504} Refresh" });
|
|
6928
6948
|
}
|
|
6929
6949
|
if (!hideHome) {
|
|
6930
|
-
actions.push({ id: "panel.home", label: "\u{1F4CB}
|
|
6950
|
+
actions.push({ id: "panel.home", label: "\u{1F4CB} Home" });
|
|
6931
6951
|
}
|
|
6932
6952
|
return {
|
|
6933
|
-
title: "\u{1F4A4} Worker
|
|
6953
|
+
title: "\u{1F4A4} Worker Offline",
|
|
6934
6954
|
subtitle: resumable ? `${resumable.name} \xB7 offline` : "offline",
|
|
6935
6955
|
color: "grey",
|
|
6936
6956
|
columnsPerRow: opts.inThread ? 2 : 3,
|
|
@@ -7067,61 +7087,60 @@ function composePanel(opts = {}) {
|
|
|
7067
7087
|
const label = formatPeerSessionLabel(p);
|
|
7068
7088
|
const verDrift = p.version && currentVer !== "unknown" && p.version !== currentVer ? ` \xB7 v${p.version}` : "";
|
|
7069
7089
|
const threadUrl = resolveSessionThreadUrl(p.sessionId);
|
|
7070
|
-
const threadLink = threadUrl ? ` \xB7 [\u{1F4AC}
|
|
7090
|
+
const threadLink = threadUrl ? ` \xB7 [\u{1F4AC} Thread](${threadUrl})` : "";
|
|
7071
7091
|
const meta = `\`${cleanCodeSpan(formatPeerModel(p), 44)}\` \xB7 ${formatPeerState(p.state, p.currentTool, verDrift)}${threadLink}`;
|
|
7072
7092
|
const rowActions = p === managerPeer ? [
|
|
7073
7093
|
{ id: "panel.models", label: "\u{1F39A} Model" },
|
|
7074
7094
|
...p.sessionControls ? [{ id: `panel.tree.${p.instanceId}`, label: "\u{1F333} Tree", payload: { from: "home" } }] : [],
|
|
7075
7095
|
...p.workerPeek && p.sessionId ? [{ id: `panel.peek.${p.instanceId}`, label: "\u{1F440} Peek", payload: { peek: { ref: p.instanceId, session: p.sessionId, isManager: true } } }] : []
|
|
7076
|
-
] : [{ id: `panel.worker.${p.instanceId}`, label: "\u{1F527}
|
|
7096
|
+
] : [{ id: `panel.worker.${p.instanceId}`, label: "\u{1F527} Manage" }];
|
|
7077
7097
|
return { text: `${label}
|
|
7078
7098
|
${meta}`, actions: rowActions };
|
|
7079
7099
|
});
|
|
7080
7100
|
const nav = [];
|
|
7081
|
-
if (page > 1) nav.push({ id: "panel.home", label: `\u25C0\uFE0F
|
|
7082
|
-
if (page < totalPages) nav.push({ id: "panel.home", label:
|
|
7101
|
+
if (page > 1) nav.push({ id: "panel.home", label: `\u25C0\uFE0F Page ${page - 1}`, payload: { page: page - 1 } });
|
|
7102
|
+
if (page < totalPages) nav.push({ id: "panel.home", label: `Page ${page + 1} \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
7083
7103
|
const upgradeLine = upgradeSummaryLine();
|
|
7084
7104
|
const footerParts = [];
|
|
7085
|
-
if (totalPages > 1) footerParts.push(
|
|
7105
|
+
if (totalPages > 1) footerParts.push(`Page ${page}/${totalPages}`);
|
|
7086
7106
|
footerParts.push(`${upgradeLine} \xB7 ${peers.length} session(s) \xB7 ${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-GB", { hour12: false })}`);
|
|
7087
7107
|
const activeCron = cronActiveCount();
|
|
7088
7108
|
const blockedCron = cronBlockedSummary();
|
|
7089
7109
|
if (blockedCron.memoryBlocked) {
|
|
7090
7110
|
const errNote = blockedCron.memoryError ? ` (${cleanCodeSpan(blockedCron.memoryError).slice(0, 60)})` : "";
|
|
7091
|
-
footerParts.unshift(`\u26A0\uFE0F Memory
|
|
7111
|
+
footerParts.unshift(`\u26A0\uFE0F Memory distillation cron is blocked${errNote} \u2014 open Cron to inspect or resume`);
|
|
7092
7112
|
} else if (blockedCron.blockedCount > 0) {
|
|
7093
|
-
footerParts.unshift(`\u26A0\uFE0F ${blockedCron.blockedCount}
|
|
7113
|
+
footerParts.unshift(`\u26A0\uFE0F ${blockedCron.blockedCount} cron job(s) blocked`);
|
|
7094
7114
|
}
|
|
7095
|
-
const cronLabel = blockedCron.blockedCount > 0 ? `\u26A0\uFE0F Cron (${blockedCron.blockedCount}
|
|
7115
|
+
const cronLabel = blockedCron.blockedCount > 0 ? `\u26A0\uFE0F Cron (${blockedCron.blockedCount}!)` : activeCron > 0 ? `\u23F0 Cron (${activeCron})` : "\u23F0 Cron";
|
|
7096
7116
|
const fixed = [
|
|
7097
7117
|
{ id: "panel.refresh", label: "\u{1F504} Refresh", ...totalPages > 1 ? { payload: { page } } : {} },
|
|
7098
|
-
{ id: "panel.
|
|
7099
|
-
{ id: "panel.archive", label: "\u{1F4DA} \u5F52\u6863" },
|
|
7118
|
+
{ id: "panel.archive", label: "\u{1F4DA} Archive" },
|
|
7100
7119
|
...!managerPeer ? [{ id: "panel.models", label: "\u{1F39A} Model" }] : [],
|
|
7101
7120
|
{ id: "panel.context", label: "\u{1F4CA} Context" },
|
|
7102
7121
|
{ id: "panel.memory", label: "\u{1F9E0} Memory" },
|
|
7103
7122
|
{ id: "panel.cron", label: cronLabel },
|
|
7104
|
-
{ id: "panel.upgrade", label: "\u2B06\uFE0F Upgrade" }
|
|
7105
|
-
{ id: "panel.help", label: "\u2753 Help" }
|
|
7123
|
+
{ id: "panel.upgrade", label: "\u2B06\uFE0F Upgrade" }
|
|
7106
7124
|
];
|
|
7125
|
+
const helpAction = { id: "panel.help", label: "\u2753 Help", align: "end" };
|
|
7107
7126
|
const CARD_ACTION_BUDGET = 18;
|
|
7108
7127
|
const inlineCount = items.reduce((sum, item) => sum + (item.actions?.length ?? 0), 0);
|
|
7109
7128
|
const custom = managerActions();
|
|
7110
|
-
const slots = Math.max(0, CARD_ACTION_BUDGET - inlineCount - fixed.length - nav.length);
|
|
7129
|
+
const slots = Math.max(0, CARD_ACTION_BUDGET - inlineCount - fixed.length - 1 - nav.length);
|
|
7111
7130
|
const inline = custom.length <= slots ? custom : custom.slice(0, Math.max(0, slots - 1));
|
|
7112
7131
|
const customButtons = inline.map((a) => ({ id: `panel.action.${a.id}`, label: a.label.slice(0, 20) }));
|
|
7113
|
-
if (custom.length > inline.length && slots > 0) customButtons.push({ id: "panel.actions", label: `\u26A1
|
|
7132
|
+
if (custom.length > inline.length && slots > 0) customButtons.push({ id: "panel.actions", label: `\u26A1 All Actions (${custom.length})` });
|
|
7114
7133
|
return {
|
|
7115
7134
|
title: "Pie Panel",
|
|
7116
7135
|
subtitle: `${os6.hostname()} \xB7 ${peers.length} session(s)${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7 pie ${pieVersion()}`,
|
|
7117
7136
|
color: "blue",
|
|
7118
7137
|
columnsPerRow: opts.inThread ? 2 : 3,
|
|
7119
|
-
body: peers.length === 0 ? "
|
|
7138
|
+
body: peers.length === 0 ? "_No online Pie sessions._" : "",
|
|
7120
7139
|
...items.length > 0 ? { items } : {},
|
|
7121
7140
|
footer: footerParts.join(" \xB7 "),
|
|
7122
7141
|
// r1-P2: only REGISTERED commands get buttons — unmapped ids would fall
|
|
7123
7142
|
// through to an LLM turn (a button press must never spend a model turn).
|
|
7124
|
-
actions: [...nav, ...fixed, ...customButtons]
|
|
7143
|
+
actions: [...nav, ...fixed, ...customButtons, helpAction]
|
|
7125
7144
|
};
|
|
7126
7145
|
}
|
|
7127
7146
|
function pieVersion() {
|
|
@@ -7183,7 +7202,7 @@ function executePanelCommand(input) {
|
|
|
7183
7202
|
color: "violet",
|
|
7184
7203
|
columnsPerRow: cols,
|
|
7185
7204
|
body: "_No live manager session found._",
|
|
7186
|
-
actions: [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
7205
|
+
actions: [{ id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
7187
7206
|
},
|
|
7188
7207
|
patchOrigin: patchInPlace
|
|
7189
7208
|
};
|
|
@@ -7205,22 +7224,22 @@ function executePanelCommand(input) {
|
|
|
7205
7224
|
text: `${formatPeerSessionLabel(p)}
|
|
7206
7225
|
\`${cleanCodeSpan(formatPeerModel(p), 44)}\` \xB7 ${formatPeerState(p.state, p.currentTool)}`,
|
|
7207
7226
|
actions: isCompactOnly ? [{ id: `panel.compact.${p.instanceId}`, label: "\u{1F9F9} Compact" }] : [
|
|
7208
|
-
{ id: `panel.context.${p.instanceId}`, label: "\u{1F4CA}
|
|
7209
|
-
{ id: `panel.compact.${p.instanceId}`, label: "\u{1F9F9}
|
|
7227
|
+
{ id: `panel.context.${p.instanceId}`, label: "\u{1F4CA} Inspect" },
|
|
7228
|
+
{ id: `panel.compact.${p.instanceId}`, label: "\u{1F9F9} Compact" }
|
|
7210
7229
|
]
|
|
7211
7230
|
}));
|
|
7212
7231
|
const nav = [];
|
|
7213
|
-
if (page > 1) nav.push({ id: input.cmd, label: `\u25C0\uFE0F
|
|
7214
|
-
if (page < totalPages) nav.push({ id: input.cmd, label:
|
|
7232
|
+
if (page > 1) nav.push({ id: input.cmd, label: `\u25C0\uFE0F Page ${page - 1}`, payload: { page: page - 1 } });
|
|
7233
|
+
if (page < totalPages) nav.push({ id: input.cmd, label: `Page ${page + 1} \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
7215
7234
|
return { spec: {
|
|
7216
7235
|
title: isCompactOnly ? "Compact Context" : "Context & Compact",
|
|
7217
|
-
subtitle: `${peers.length} session(s)${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7 ${isCompactOnly ? "
|
|
7236
|
+
subtitle: `${peers.length} session(s)${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7 ${isCompactOnly ? "Manually compact context history" : "Inspect context usage or compact history"}`,
|
|
7218
7237
|
color: "violet",
|
|
7219
7238
|
columnsPerRow: cols,
|
|
7220
|
-
body: peers.length === 0 ? "_
|
|
7239
|
+
body: peers.length === 0 ? "_No online sessions currently support this control._" : "",
|
|
7221
7240
|
...items.length > 0 ? { items } : {},
|
|
7222
|
-
footer: isCompactOnly ? "
|
|
7223
|
-
actions: [...nav, { id: "panel.home", label: "\u21A9\uFE0F
|
|
7241
|
+
footer: isCompactOnly ? "Compaction summarizes older history into a checkpoint while keeping recent turns (same as /sessions/compact). Refused while busy; retry when idle." : "Inspect checks live context usage (zero LLM). Compact summarizes older history while keeping recent turns (available when idle).",
|
|
7242
|
+
actions: [...nav, { id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
7224
7243
|
}, patchOrigin: patchInPlace };
|
|
7225
7244
|
}
|
|
7226
7245
|
if (input.cmd === "panel.actions") {
|
|
@@ -7231,21 +7250,21 @@ function executePanelCommand(input) {
|
|
|
7231
7250
|
const slice = all.slice((page - 1) * PAGE_SIZE2, page * PAGE_SIZE2);
|
|
7232
7251
|
const items = slice.map((a) => ({
|
|
7233
7252
|
text: `**${cleanInline2(a.label, 36)}**
|
|
7234
|
-
${a.runs}
|
|
7235
|
-
actions: [{ id: `panel.action.${a.id}`, label: "\u25B6\uFE0F
|
|
7253
|
+
${a.runs} run(s) \xB7 last ${cleanInline2(a.lastRunBy ?? "\u2014", 20)} \xB7 by ${cleanInline2(a.creator?.name ?? "\u2014", 20)}`,
|
|
7254
|
+
actions: [{ id: `panel.action.${a.id}`, label: "\u25B6\uFE0F Run" }]
|
|
7236
7255
|
}));
|
|
7237
7256
|
const nav = [];
|
|
7238
|
-
if (page > 1) nav.push({ id: "panel.actions", label: `\u25C0\uFE0F
|
|
7239
|
-
if (page < totalPages) nav.push({ id: "panel.actions", label:
|
|
7257
|
+
if (page > 1) nav.push({ id: "panel.actions", label: `\u25C0\uFE0F Page ${page - 1}`, payload: { page: page - 1 } });
|
|
7258
|
+
if (page < totalPages) nav.push({ id: "panel.actions", label: `Page ${page + 1} \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
7240
7259
|
return { spec: {
|
|
7241
|
-
title: "
|
|
7242
|
-
subtitle: `${all.length} registered${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7
|
|
7260
|
+
title: "All Actions",
|
|
7261
|
+
subtitle: `${all.length} registered${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7 tap inline buttons to run (zero LLM)`,
|
|
7243
7262
|
color: "violet",
|
|
7244
7263
|
columnsPerRow: cols,
|
|
7245
|
-
body: all.length === 0 ? "
|
|
7264
|
+
body: all.length === 0 ? "_No custom actions yet \u2014 ask Manager in chat to create one._" : "",
|
|
7246
7265
|
...items.length > 0 ? { items } : {},
|
|
7247
|
-
footer: "
|
|
7248
|
-
actions: [...nav, { id: "panel.home", label: "\u21A9\uFE0F
|
|
7266
|
+
footer: "Each run records the caller and audit log (zero LLM, runs script directly).",
|
|
7267
|
+
actions: [...nav, { id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
7249
7268
|
}, patchOrigin: patchInPlace };
|
|
7250
7269
|
}
|
|
7251
7270
|
if (input.cmd === "panel.worker.offline") {
|
|
@@ -7306,7 +7325,7 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline2(a.lastRunBy ?? "\u2014", 20)}
|
|
|
7306
7325
|
].join("\n"),
|
|
7307
7326
|
actions: [
|
|
7308
7327
|
{ id: "panel.upgrade.confirm", label: "\u2B06\uFE0F Install latest + restart", style: "primary", requireAllowUsers: true },
|
|
7309
|
-
{ id: "panel.home", label: "\u21A9\uFE0F
|
|
7328
|
+
{ id: "panel.home", label: "\u21A9\uFE0F Home" }
|
|
7310
7329
|
]
|
|
7311
7330
|
}, patchOrigin: patchInPlace };
|
|
7312
7331
|
}
|
|
@@ -7314,8 +7333,8 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline2(a.lastRunBy ?? "\u2014", 20)}
|
|
|
7314
7333
|
return { spec: {
|
|
7315
7334
|
title: "Panel Commands",
|
|
7316
7335
|
columnsPerRow: cols,
|
|
7317
|
-
body: "`/panel` summons the status panel (inside a worker thread, opens that worker's dedicated panel in-thread). Controls: \u{1F504} Refresh, \u{1F4DA}
|
|
7318
|
-
actions: [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
7336
|
+
body: "`/panel` summons the status panel (inside a worker thread, opens that worker's dedicated panel in-thread). Controls: \u{1F504} Refresh, \u{1F4DA} Archive (browse recent historical sessions across directories, inspect offline summaries, and one-click Resume workers), \u{1F39A} Model & Thinking, \u{1F4CA} Context (inspect context usage & one-tap Compact), \u{1F333} Tree (inspect session tree & lossless rewind/branch switch; also via `/panel.tree`), \u{1F9E0} Memory (Wiki status, curated page preview, distill/GC triggers, and logs), \u23F0 Cron (list / pause / resume / stop scheduled jobs; create new jobs in chat), \u23F9 Stop (abort current turn), \u{1F6AA} Quit (resident workers: graceful shutdown / force kill), \u267B\uFE0F Resume (when offline), \u{1F440} Peek (live snapshot). Navigation updates the card in place.",
|
|
7337
|
+
actions: [{ id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
7319
7338
|
}, patchOrigin: patchInPlace };
|
|
7320
7339
|
}
|
|
7321
7340
|
const homePage = input.cmd === "panel.home" || input.cmd === "panel.refresh" ? parsePage(input.payload) : 1;
|
|
@@ -7350,10 +7369,10 @@ function formatRelativeTime(timestamp) {
|
|
|
7350
7369
|
const mins = Math.floor(diffMs / 6e4);
|
|
7351
7370
|
const hours = Math.floor(diffMs / 36e5);
|
|
7352
7371
|
const days = Math.floor(diffMs / 864e5);
|
|
7353
|
-
if (mins < 1) return "
|
|
7354
|
-
if (mins < 60) return `${mins}m
|
|
7355
|
-
if (hours < 24) return `${hours}h
|
|
7356
|
-
if (days < 7) return `${days}d
|
|
7372
|
+
if (mins < 1) return "just now";
|
|
7373
|
+
if (mins < 60) return `${mins}m ago`;
|
|
7374
|
+
if (hours < 24) return `${hours}h ago`;
|
|
7375
|
+
if (days < 7) return `${days}d ago`;
|
|
7357
7376
|
const d = new Date(timestamp);
|
|
7358
7377
|
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
7359
7378
|
const dd = String(d.getDate()).padStart(2, "0");
|
|
@@ -7404,11 +7423,11 @@ function composeArchiveListCard(opts = {}) {
|
|
|
7404
7423
|
const bridge = currentWorkerLifecycleBridge();
|
|
7405
7424
|
if (!bridge?.listRecentSessions) {
|
|
7406
7425
|
return {
|
|
7407
|
-
title: "\u{1F4DA}
|
|
7426
|
+
title: "\u{1F4DA} Session Archive",
|
|
7408
7427
|
color: "grey",
|
|
7409
7428
|
columnsPerRow: cols,
|
|
7410
|
-
body: "
|
|
7411
|
-
actions: [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
7429
|
+
body: "`pie-proc` archive index is not attached on this host; historical sessions cannot be listed.",
|
|
7430
|
+
actions: [{ id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
7412
7431
|
};
|
|
7413
7432
|
}
|
|
7414
7433
|
const livePeers = scanPeers();
|
|
@@ -7434,18 +7453,18 @@ function composeArchiveListCard(opts = {}) {
|
|
|
7434
7453
|
const items = listed.sessions.map((s) => {
|
|
7435
7454
|
const livePeer = liveBySession.get(s.sessionId);
|
|
7436
7455
|
const threadUrl = resolveSessionThreadUrl(s.sessionId);
|
|
7437
|
-
const statusBadge = livePeer ? livePeer.state === "working" ? "\u{1F7E1}
|
|
7456
|
+
const statusBadge = livePeer ? livePeer.state === "working" ? "\u{1F7E1} Working" : "\u{1F7E2} Online" : s.livePid ? `\u{1F7E1} Busy (pid ${s.livePid})` : s.resumable ? "\u{1F4A4} Resumable" : "\u{1F512} Read-only";
|
|
7438
7457
|
const metaParts = [
|
|
7439
7458
|
statusBadge,
|
|
7440
7459
|
formatRelativeTime(s.updatedAt),
|
|
7441
7460
|
`${s.messageCount} msgs`,
|
|
7442
|
-
...threadUrl ? [`[\u{1F4AC}
|
|
7461
|
+
...threadUrl ? [`[\u{1F4AC} Thread](${threadUrl})`] : []
|
|
7443
7462
|
];
|
|
7444
7463
|
const rowActions = [
|
|
7445
|
-
{ id: `panel.archive.view.${s.sessionId}`, label: "\u{1F440}
|
|
7464
|
+
{ id: `panel.archive.view.${s.sessionId}`, label: "\u{1F440} Summary", payload: { page, scope } }
|
|
7446
7465
|
];
|
|
7447
7466
|
if (livePeer && !livePeer.isManager) {
|
|
7448
|
-
rowActions.push({ id: `panel.worker.${livePeer.instanceId}`, label: "\u{1F527}
|
|
7467
|
+
rowActions.push({ id: `panel.worker.${livePeer.instanceId}`, label: "\u{1F527} Manage" });
|
|
7449
7468
|
} else if (!livePeer && s.resumable) {
|
|
7450
7469
|
rowActions.push({
|
|
7451
7470
|
id: `panel.resume.${s.sessionId}`,
|
|
@@ -7460,30 +7479,30 @@ ${metaParts.join(" \xB7 ")}`,
|
|
|
7460
7479
|
};
|
|
7461
7480
|
});
|
|
7462
7481
|
const nav = [];
|
|
7463
|
-
if (page > 1) nav.push({ id: "panel.archive", label: `\u25C0\uFE0F
|
|
7464
|
-
if (page < totalPages) nav.push({ id: "panel.archive", label:
|
|
7465
|
-
const toggleAction = scope === "all" ? { id: "panel.archive", label: "\u{1F4AC}
|
|
7466
|
-
const scopeLabel = scope === "im" ? "
|
|
7467
|
-
const emptyText = scope === "im" ?
|
|
7482
|
+
if (page > 1) nav.push({ id: "panel.archive", label: `\u25C0\uFE0F Page ${page - 1}`, payload: { page: page - 1, scope } });
|
|
7483
|
+
if (page < totalPages) nav.push({ id: "panel.archive", label: `Page ${page + 1} \u25B6\uFE0F`, payload: { page: page + 1, scope } });
|
|
7484
|
+
const toggleAction = scope === "all" ? { id: "panel.archive", label: "\u{1F4AC} IM Threads", payload: { page: 1, scope: "im" } } : { id: "panel.archive", label: "\u{1F310} All Dirs", payload: { page: 1, scope: "all" } };
|
|
7485
|
+
const scopeLabel = scope === "im" ? "IM Threads" : "All Dirs";
|
|
7486
|
+
const emptyText = scope === "im" ? '_No archived sessions with IM threads yet \u2014 switch to "\u{1F310} All Dirs" to browse all project sessions._' : "_No archived sessions available._";
|
|
7468
7487
|
return {
|
|
7469
|
-
title: "\u{1F4DA}
|
|
7470
|
-
subtitle: `${scopeLabel} \xB7 ${listed.total}
|
|
7488
|
+
title: "\u{1F4DA} Session Archive",
|
|
7489
|
+
subtitle: `${scopeLabel} \xB7 ${listed.total}${listed.truncated ? "+" : ""} session(s)${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""}`,
|
|
7471
7490
|
color: "violet",
|
|
7472
7491
|
columnsPerRow: cols,
|
|
7473
7492
|
body: items.length === 0 ? emptyText : "",
|
|
7474
7493
|
...items.length > 0 ? { items } : {},
|
|
7475
|
-
footer: "
|
|
7494
|
+
footer: "Tap \u{1F440} Summary to read recent turns offline (zero LLM), or \u267B\uFE0F Resume to wake the worker (auto-opens a thread if needed).",
|
|
7476
7495
|
actions: [
|
|
7477
7496
|
...nav,
|
|
7478
7497
|
toggleAction,
|
|
7479
7498
|
{ id: "panel.archive", label: "\u{1F504} Refresh", payload: { page, scope } },
|
|
7480
|
-
{ id: "panel.home", label: "\u21A9\uFE0F
|
|
7499
|
+
{ id: "panel.home", label: "\u21A9\uFE0F Home" }
|
|
7481
7500
|
]
|
|
7482
7501
|
};
|
|
7483
7502
|
}
|
|
7484
7503
|
function renderRecentTurnsMarkdown(turns) {
|
|
7485
7504
|
if (turns.length === 0) {
|
|
7486
|
-
return "_
|
|
7505
|
+
return "_No readable text turns found recently (may contain only tool calls or compacted entries)._";
|
|
7487
7506
|
}
|
|
7488
7507
|
const blocks = [];
|
|
7489
7508
|
let used = 0;
|
|
@@ -7504,25 +7523,25 @@ function composeArchiveDetailCard(sessionId, opts = {}) {
|
|
|
7504
7523
|
const cols = opts.inThread ? 2 : 3;
|
|
7505
7524
|
const page = Math.max(1, Math.floor(opts.page ?? 1));
|
|
7506
7525
|
const scope = opts.scope === "im" ? "im" : "all";
|
|
7507
|
-
const backAction = { id: "panel.archive", label: "\u21A9\uFE0F
|
|
7508
|
-
const homeAction = { id: "panel.home", label: "\u{1F4CB}
|
|
7526
|
+
const backAction = { id: "panel.archive", label: "\u21A9\uFE0F Archive", payload: { page, scope } };
|
|
7527
|
+
const homeAction = { id: "panel.home", label: "\u{1F4CB} Home" };
|
|
7509
7528
|
const bridge = currentWorkerLifecycleBridge();
|
|
7510
7529
|
if (!bridge?.readSessionRecentTurns) {
|
|
7511
7530
|
return {
|
|
7512
|
-
title: "\u{1F4C4}
|
|
7531
|
+
title: "\u{1F4C4} Summary Unavailable",
|
|
7513
7532
|
color: "grey",
|
|
7514
7533
|
columnsPerRow: cols,
|
|
7515
|
-
body: "
|
|
7534
|
+
body: "`pie-proc` archive reader is not attached on this host.",
|
|
7516
7535
|
actions: [backAction, homeAction]
|
|
7517
7536
|
};
|
|
7518
7537
|
}
|
|
7519
7538
|
const res = bridge.readSessionRecentTurns(sessionId, { maxTurns: 6, maxCharsPerTurn: 300 });
|
|
7520
7539
|
if (!res.ok || !res.session) {
|
|
7521
7540
|
return {
|
|
7522
|
-
title: "\u26A0\uFE0F
|
|
7541
|
+
title: "\u26A0\uFE0F Cannot Read Session",
|
|
7523
7542
|
color: "red",
|
|
7524
7543
|
columnsPerRow: cols,
|
|
7525
|
-
body: sanitizeLiteralMarkdown(res.error ??
|
|
7544
|
+
body: sanitizeLiteralMarkdown(res.error ?? `Session ${sessionId} not found`),
|
|
7526
7545
|
actions: [backAction, homeAction]
|
|
7527
7546
|
};
|
|
7528
7547
|
}
|
|
@@ -7530,19 +7549,19 @@ function composeArchiveDetailCard(sessionId, opts = {}) {
|
|
|
7530
7549
|
const livePeer = findPeerBySessionId(s.sessionId);
|
|
7531
7550
|
const threadUrl = resolveSessionThreadUrl(s.sessionId);
|
|
7532
7551
|
const shortCwd = formatShortCwd(s.cwd);
|
|
7533
|
-
const statusText = livePeer ? livePeer.state === "working" ? "\u{1F7E1}
|
|
7552
|
+
const statusText = livePeer ? livePeer.state === "working" ? "\u{1F7E1} Working (online)" : "\u{1F7E2} Online" : s.livePid ? `\u{1F7E1} Busy (pid ${s.livePid})` : s.resumable ? "\u{1F4A4} Offline \xB7 Resumable" : `\u{1F512} Not resumable (${cleanInline3(s.resumeReason ?? "blocked by allowCwd", 48)})`;
|
|
7534
7553
|
const infoLines = [
|
|
7535
|
-
`- **title
|
|
7536
|
-
`- **session
|
|
7537
|
-
...shortCwd ? [`- **cwd
|
|
7538
|
-
...s.model ? [`- **model
|
|
7539
|
-
`- **updated
|
|
7540
|
-
`- **status
|
|
7541
|
-
...threadUrl ? [`- **thread
|
|
7554
|
+
`- **title**: ${cleanInline3(cleanArchiveTitle(s.name), 72)}`,
|
|
7555
|
+
`- **session**: \`${cleanCodeSpan(s.sessionId, 64)}\`${s.workerName ? ` \xB7 **worker**: ${cleanInline3(s.workerName, 48)}` : ""}`,
|
|
7556
|
+
...shortCwd ? [`- **cwd**: \`${cleanCodeSpan(shortCwd, 88)}\``] : [],
|
|
7557
|
+
...s.model ? [`- **model**: \`${cleanCodeSpan(s.model + (s.thinkingLevel ? ` (${s.thinkingLevel})` : ""), 56)}\``] : [],
|
|
7558
|
+
`- **updated**: ${formatClock(s.updatedAt)} (${formatRelativeTime(s.updatedAt)}) \xB7 ${s.messageCount} msgs`,
|
|
7559
|
+
`- **status**: ${statusText}`,
|
|
7560
|
+
...threadUrl ? [`- **thread**: [\u{1F4AC} Open Thread \u2197](${threadUrl})`] : []
|
|
7542
7561
|
];
|
|
7543
7562
|
const actions = [];
|
|
7544
7563
|
if (livePeer && !livePeer.isManager) {
|
|
7545
|
-
actions.push({ id: `panel.worker.${livePeer.instanceId}`, label: "\u{1F527}
|
|
7564
|
+
actions.push({ id: `panel.worker.${livePeer.instanceId}`, label: "\u{1F527} Manage Worker", style: "primary" });
|
|
7546
7565
|
} else if (!livePeer && s.resumable) {
|
|
7547
7566
|
actions.push({
|
|
7548
7567
|
id: `panel.resume.${s.sessionId}`,
|
|
@@ -7565,7 +7584,7 @@ function composeArchiveDetailCard(sessionId, opts = {}) {
|
|
|
7565
7584
|
body: `${infoLines.join("\n")}
|
|
7566
7585
|
|
|
7567
7586
|
---
|
|
7568
|
-
|
|
7587
|
+
**Recent Conversation Summary** (offline read, zero LLM)
|
|
7569
7588
|
|
|
7570
7589
|
${renderRecentTurnsMarkdown(res.turns)}`,
|
|
7571
7590
|
actions
|
|
@@ -7581,11 +7600,11 @@ function runArchivePanelCommand(panelCmd, opts) {
|
|
|
7581
7600
|
handled: true,
|
|
7582
7601
|
keyPrefix: "panel-archive-denied",
|
|
7583
7602
|
spec: {
|
|
7584
|
-
title: "\u{1F4DA}
|
|
7603
|
+
title: "\u{1F4DA} Archive Unavailable",
|
|
7585
7604
|
color: "red",
|
|
7586
7605
|
columnsPerRow: cols,
|
|
7587
|
-
body: "\u26D4\uFE0F
|
|
7588
|
-
actions: [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
7606
|
+
body: "\u26D4\uFE0F Session archive is restricted to authorized DMs or the bound group chat.",
|
|
7607
|
+
actions: [{ id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
7589
7608
|
}
|
|
7590
7609
|
};
|
|
7591
7610
|
}
|
|
@@ -7603,11 +7622,11 @@ function runArchivePanelCommand(panelCmd, opts) {
|
|
|
7603
7622
|
handled: true,
|
|
7604
7623
|
keyPrefix: "panel-archive-invalid",
|
|
7605
7624
|
spec: {
|
|
7606
|
-
title: "\u26A0\uFE0F
|
|
7625
|
+
title: "\u26A0\uFE0F Invalid Session ID",
|
|
7607
7626
|
color: "red",
|
|
7608
7627
|
columnsPerRow: cols,
|
|
7609
|
-
body: "
|
|
7610
|
-
actions: [{ id: "panel.archive", label: "\u21A9\uFE0F
|
|
7628
|
+
body: "Invalid session identifier.",
|
|
7629
|
+
actions: [{ id: "panel.archive", label: "\u21A9\uFE0F Archive", payload: nav }]
|
|
7611
7630
|
}
|
|
7612
7631
|
};
|
|
7613
7632
|
}
|
|
@@ -7629,8 +7648,8 @@ async function ensureResumedSessionTopic(opts) {
|
|
|
7629
7648
|
}
|
|
7630
7649
|
const dirName = formatProjectName(opts.cwd);
|
|
7631
7650
|
const displayName = opts.workerName?.trim() || opts.sessionId.slice(0, 12);
|
|
7632
|
-
const readyText = `\u267B\uFE0F
|
|
7633
|
-
|
|
7651
|
+
const readyText = `\u267B\uFE0F Resumed archived session **${cleanInline3(displayName, 40)}**${dirName ? ` (\`${cleanCodeSpan(dirName, 32)}\`)` : ""}
|
|
7652
|
+
Reply in this thread to continue.`;
|
|
7634
7653
|
const baseKey = `panel-resume-topic-${opts.eventId}-${opts.sessionId}`;
|
|
7635
7654
|
try {
|
|
7636
7655
|
let anchorMessageId;
|
|
@@ -7644,7 +7663,7 @@ async function ensureResumedSessionTopic(opts) {
|
|
|
7644
7663
|
} else {
|
|
7645
7664
|
const sent = await opts.connection.send(opts.recipient, readyText, baseKey);
|
|
7646
7665
|
if (!sent?.messageId) {
|
|
7647
|
-
return { opened: false, note: "
|
|
7666
|
+
return { opened: false, note: "Failed to auto-open a thread (no messageId returned). Open it from Home or address it with `name: message`." };
|
|
7648
7667
|
}
|
|
7649
7668
|
anchorMessageId = sent.messageId;
|
|
7650
7669
|
threadId = sent.threadId ?? null;
|
|
@@ -7688,7 +7707,7 @@ async function ensureResumedSessionTopic(opts) {
|
|
|
7688
7707
|
};
|
|
7689
7708
|
} catch (error) {
|
|
7690
7709
|
opts.log(`im-forward: auto-open topic for resumed session ${opts.sessionId} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
7691
|
-
return { opened: false, note: "
|
|
7710
|
+
return { opened: false, note: "Failed to auto-open a thread. Open this worker from Home or address it with `name: message`." };
|
|
7692
7711
|
}
|
|
7693
7712
|
}
|
|
7694
7713
|
|
|
@@ -7924,23 +7943,23 @@ function composeUpdatedModelsCard(opts) {
|
|
|
7924
7943
|
banner: opts.banner
|
|
7925
7944
|
});
|
|
7926
7945
|
}
|
|
7927
|
-
const homeOpt = opts.hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB}
|
|
7946
|
+
const homeOpt = opts.hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB} Home" }];
|
|
7928
7947
|
return {
|
|
7929
|
-
title: opts.receipt.ok ? "\u2705
|
|
7948
|
+
title: opts.receipt.ok ? "\u2705 Settings Updated" : "\u26A0\uFE0F Update Failed",
|
|
7930
7949
|
color: opts.receipt.ok ? "green" : "red",
|
|
7931
7950
|
columnsPerRow: cols,
|
|
7932
7951
|
body: `${opts.banner}
|
|
7933
7952
|
|
|
7934
7953
|
${sanitizeLiteralMarkdown(opts.receipt.detail)}`,
|
|
7935
|
-
actions: effectiveScope === "manager" ? [{ id: "panel.models", label: "\u{1F39A} Model & Thinking" }, { id: "panel.home", label: "\u{1F4CB}
|
|
7954
|
+
actions: effectiveScope === "manager" ? [{ id: "panel.models", label: "\u{1F39A} Model & Thinking" }, { id: "panel.home", label: "\u{1F4CB} Home" }] : opts.hideHome ? panelHomeAction(true, opts.threadWorkerSessionId, opts.peerRef) : [{ id: `panel.worker.${opts.peerRef}`, label: "\u21A9\uFE0F Worker" }, ...homeOpt]
|
|
7936
7955
|
};
|
|
7937
7956
|
}
|
|
7938
7957
|
function panelHomeAction(inThread, threadWorkerSessionId, peerRef) {
|
|
7939
|
-
if (!inThread) return [{ id: "panel.home", label: "\u{1F4CB}
|
|
7958
|
+
if (!inThread) return [{ id: "panel.home", label: "\u{1F4CB} Home" }];
|
|
7940
7959
|
if (peerRef) return [{ id: `panel.worker.${peerRef}`, label: "\u21A9\uFE0F Worker" }];
|
|
7941
7960
|
if (threadWorkerSessionId) {
|
|
7942
7961
|
const live = findPeerBySessionId(threadWorkerSessionId);
|
|
7943
|
-
return live ? [{ id: `panel.worker.${live.instanceId}`, label: "\u21A9\uFE0F Worker" }] : [{ id: "panel.worker.offline", label: "\u{1F504} Worker
|
|
7962
|
+
return live ? [{ id: `panel.worker.${live.instanceId}`, label: "\u21A9\uFE0F Worker" }] : [{ id: "panel.worker.offline", label: "\u{1F504} Worker Panel", payload: { sessionId: threadWorkerSessionId } }];
|
|
7944
7963
|
}
|
|
7945
7964
|
return [];
|
|
7946
7965
|
}
|
|
@@ -7971,7 +7990,7 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
7971
7990
|
const deny = (reason) => ({
|
|
7972
7991
|
blocked: true,
|
|
7973
7992
|
spec: {
|
|
7974
|
-
title: "\u26D4\uFE0F
|
|
7993
|
+
title: "\u26D4\uFE0F Worker Panel Only",
|
|
7975
7994
|
color: "red",
|
|
7976
7995
|
columnsPerRow: cols,
|
|
7977
7996
|
body: reason,
|
|
@@ -7979,24 +7998,24 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
7979
7998
|
}
|
|
7980
7999
|
});
|
|
7981
8000
|
if (THREAD_FORBIDDEN_GLOBAL_CMDS.has(panelCmd.cmd) || panelCmd.cmd.startsWith("panel.archive.view.")) {
|
|
7982
|
-
return deny("
|
|
8001
|
+
return deny("In-thread worker panels cannot access Home, Archive, or Manager. Use `/panel` in the main chat or DM.");
|
|
7983
8002
|
}
|
|
7984
8003
|
if (panelCmd.cmd === "panel.worker.offline" || panelCmd.cmd === "panel.worker.cron.offline") {
|
|
7985
8004
|
const rawSid = panelCmd.payload && typeof panelCmd.payload === "object" && !Array.isArray(panelCmd.payload) ? panelCmd.payload.sessionId : void 0;
|
|
7986
8005
|
if (typeof rawSid === "string" && rawSid.trim() && rawSid.trim() !== pinnedWorkerSessionId) {
|
|
7987
|
-
return deny("
|
|
8006
|
+
return deny("In-thread worker panels cannot access other worker sessions.");
|
|
7988
8007
|
}
|
|
7989
8008
|
return { blocked: false };
|
|
7990
8009
|
}
|
|
7991
8010
|
const resumeMatch = /^panel\.resume\.([A-Za-z0-9][A-Za-z0-9-_]{5,63})$/.exec(panelCmd.cmd);
|
|
7992
8011
|
if (resumeMatch && resumeMatch[1] !== pinnedWorkerSessionId) {
|
|
7993
|
-
return deny("
|
|
8012
|
+
return deny("In-thread worker panels can only resume the worker belonging to this thread.");
|
|
7994
8013
|
}
|
|
7995
8014
|
const actionMatch = /^panel\.action\.([a-z0-9][a-z0-9-]{0,31})$/.exec(panelCmd.cmd);
|
|
7996
8015
|
if (actionMatch) {
|
|
7997
8016
|
const action = findAction(actionMatch[1]);
|
|
7998
8017
|
if (action?.scope === "manager") {
|
|
7999
|
-
return deny("
|
|
8018
|
+
return deny("In-thread worker panels cannot run manager-scoped actions.");
|
|
8000
8019
|
}
|
|
8001
8020
|
return { blocked: false };
|
|
8002
8021
|
}
|
|
@@ -8004,21 +8023,21 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
8004
8023
|
if (viewPeerMatch) {
|
|
8005
8024
|
const peer = scanPeers().find((p) => p.instanceId === viewPeerMatch[1]);
|
|
8006
8025
|
if (peer && (peer.isManager || peer.sessionId !== pinnedWorkerSessionId)) {
|
|
8007
|
-
return deny("
|
|
8026
|
+
return deny("In-thread worker panels can only inspect or control the current worker.");
|
|
8008
8027
|
}
|
|
8009
8028
|
return { blocked: false };
|
|
8010
8029
|
}
|
|
8011
8030
|
const cronJobMatch = /^panel\.cron\.(?:pause|resume|stop(?:\.confirm)?)\.([A-Za-z0-9-]{8,64})$/.exec(panelCmd.cmd);
|
|
8012
8031
|
if (cronJobMatch) {
|
|
8013
8032
|
if (panelCmd.cmd.startsWith("panel.cron.stop.confirm.") && verifiedCronStopSessionId && verifiedCronStopSessionId !== pinnedWorkerSessionId) {
|
|
8014
|
-
return deny("
|
|
8033
|
+
return deny("In-thread worker panels can only manage this worker's scheduled jobs.");
|
|
8015
8034
|
}
|
|
8016
8035
|
const bridge = currentCronPanelBridge();
|
|
8017
8036
|
if (bridge) {
|
|
8018
8037
|
const jobId = cronJobMatch[1];
|
|
8019
8038
|
const allMatches = bridge.listJobs().jobs.filter((j) => j.id === jobId);
|
|
8020
8039
|
if (allMatches.length > 0 && !allMatches.some((j) => j.sessionId === pinnedWorkerSessionId)) {
|
|
8021
|
-
return deny("
|
|
8040
|
+
return deny("In-thread worker panels can only manage this worker's scheduled jobs, not manager, system, or other workers' jobs.");
|
|
8022
8041
|
}
|
|
8023
8042
|
}
|
|
8024
8043
|
return { blocked: false };
|
|
@@ -8027,10 +8046,10 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
8027
8046
|
if (quitExecMatch) {
|
|
8028
8047
|
const peer = scanPeers().find((p) => p.instanceId === quitExecMatch[1]);
|
|
8029
8048
|
if (peer && (peer.isManager || peer.sessionId !== pinnedWorkerSessionId)) {
|
|
8030
|
-
return deny("
|
|
8049
|
+
return deny("In-thread worker panels cannot quit Manager or other workers.");
|
|
8031
8050
|
}
|
|
8032
8051
|
if (verifiedQuitSessionId && verifiedQuitSessionId !== pinnedWorkerSessionId) {
|
|
8033
|
-
return deny("
|
|
8052
|
+
return deny("In-thread worker panels cannot quit other workers.");
|
|
8034
8053
|
}
|
|
8035
8054
|
return { blocked: false };
|
|
8036
8055
|
}
|
|
@@ -8039,10 +8058,10 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
8039
8058
|
const peer = scanPeers().find((p) => p.instanceId === treePeerMatch[1]);
|
|
8040
8059
|
if (peer) {
|
|
8041
8060
|
if (peer.isManager || peer.sessionId !== pinnedWorkerSessionId) {
|
|
8042
|
-
return deny("
|
|
8061
|
+
return deny("In-thread worker panels can only view or control this worker's session tree.");
|
|
8043
8062
|
}
|
|
8044
8063
|
if (panelCmd.cmd.startsWith("panel.tree.branch.confirm.") && verifiedTreeBranchSessionId && verifiedTreeBranchSessionId !== pinnedWorkerSessionId) {
|
|
8045
|
-
return deny("
|
|
8064
|
+
return deny("In-thread worker panels can only switch this worker's session branch.");
|
|
8046
8065
|
}
|
|
8047
8066
|
return { blocked: false };
|
|
8048
8067
|
}
|
|
@@ -8053,7 +8072,7 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
8053
8072
|
const peer = scanPeers().find((p) => p.instanceId === ctrlPeerMatch[1]);
|
|
8054
8073
|
if (peer) {
|
|
8055
8074
|
if (peer.isManager || peer.sessionId !== pinnedWorkerSessionId) {
|
|
8056
|
-
return deny("
|
|
8075
|
+
return deny("In-thread worker panels can only control the current worker, not Manager or other workers.");
|
|
8057
8076
|
}
|
|
8058
8077
|
return { blocked: false };
|
|
8059
8078
|
}
|
|
@@ -8066,7 +8085,7 @@ function isMutatingWorkerLifecycleCommand(cmd) {
|
|
|
8066
8085
|
}
|
|
8067
8086
|
async function runWorkerLifecycleCommand(panelCmd, inThread, verifiedQuit, threadWorkerSessionId, hideHome = inThread, onResumed) {
|
|
8068
8087
|
const cols = inThread ? 2 : 3;
|
|
8069
|
-
const homeOpt = hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB}
|
|
8088
|
+
const homeOpt = hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB} Home" }];
|
|
8070
8089
|
const homeOrWorker = (peerRef) => panelHomeAction(hideHome, threadWorkerSessionId, peerRef);
|
|
8071
8090
|
const thinkingAction = /^panel\.thinking\.([A-Za-z0-9-]+)\.(off|minimal|low|medium|high|xhigh|max)$/.exec(panelCmd.cmd);
|
|
8072
8091
|
if (thinkingAction) {
|
|
@@ -8076,7 +8095,7 @@ async function runWorkerLifecycleCommand(panelCmd, inThread, verifiedQuit, threa
|
|
|
8076
8095
|
const rec = panelCmd.payload && typeof panelCmd.payload === "object" && !Array.isArray(panelCmd.payload) ? panelCmd.payload : void 0;
|
|
8077
8096
|
const fromManager = !hideHome && rec?.from === "manager";
|
|
8078
8097
|
const page = typeof rec?.page === "number" && Number.isFinite(rec.page) ? Math.floor(rec.page) : void 0;
|
|
8079
|
-
const banner = receipt.ok ? `\u2705
|
|
8098
|
+
const banner = receipt.ok ? `\u2705 Switched to \`thinking=${level}\` (applies next turn)` : `\u26A0\uFE0F Failed to switch \`thinking=${level}\`: ${sanitizeLiteralMarkdown(receipt.detail)}`;
|
|
8080
8099
|
return {
|
|
8081
8100
|
handled: true,
|
|
8082
8101
|
keyPrefix: "panel-thinking",
|
|
@@ -8123,10 +8142,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8123
8142
|
handled: true,
|
|
8124
8143
|
keyPrefix: "panel-quit-unverified",
|
|
8125
8144
|
spec: {
|
|
8126
|
-
title: "\u26D4\uFE0F
|
|
8145
|
+
title: "\u26D4\uFE0F Quit Confirmation Expired",
|
|
8127
8146
|
color: "red",
|
|
8128
8147
|
columnsPerRow: cols,
|
|
8129
|
-
body: "
|
|
8148
|
+
body: "Missing or expired quit confirmation binding. Re-open the target worker from `/panel` and try again.",
|
|
8130
8149
|
actions: homeOrWorker()
|
|
8131
8150
|
}
|
|
8132
8151
|
};
|
|
@@ -8147,10 +8166,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8147
8166
|
handled: true,
|
|
8148
8167
|
keyPrefix: "panel-quit-stale",
|
|
8149
8168
|
spec: {
|
|
8150
|
-
title: "\u26A0\uFE0F Worker
|
|
8169
|
+
title: "\u26A0\uFE0F Worker Session Changed",
|
|
8151
8170
|
color: "red",
|
|
8152
8171
|
columnsPerRow: cols,
|
|
8153
|
-
body: "
|
|
8172
|
+
body: "This card's target binding expired. Refresh the panel and try again.",
|
|
8154
8173
|
actions: [
|
|
8155
8174
|
{ id: `panel.worker.${peerRef}`, label: "\u{1F504} Refresh" },
|
|
8156
8175
|
...homeOpt
|
|
@@ -8163,10 +8182,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8163
8182
|
handled: true,
|
|
8164
8183
|
keyPrefix: "panel-quit-refused",
|
|
8165
8184
|
spec: {
|
|
8166
|
-
title: "\u26D4\uFE0F
|
|
8185
|
+
title: "\u26D4\uFE0F Remote Quit Unavailable",
|
|
8167
8186
|
color: "red",
|
|
8168
8187
|
columnsPerRow: cols,
|
|
8169
|
-
body: `${peer.isManager ? "
|
|
8188
|
+
body: `${peer.isManager ? "The manager host" : "Interactive TUI sessions"} cannot be quit remotely from IM.`,
|
|
8170
8189
|
actions: [
|
|
8171
8190
|
{ id: `panel.worker.${peerRef}`, label: "\u21A9\uFE0F Back" },
|
|
8172
8191
|
...homeOpt
|
|
@@ -8194,7 +8213,7 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8194
8213
|
actions2.push({ id: `panel.resume.${peer.sessionId}`, label: "\u267B\uFE0F Resume Worker", style: "primary" });
|
|
8195
8214
|
}
|
|
8196
8215
|
if (!exited && managed) {
|
|
8197
|
-
actions2.push({ id: `panel.quit.force.${peer.instanceId}`, label: "\u{1F480}
|
|
8216
|
+
actions2.push({ id: `panel.quit.force.${peer.instanceId}`, label: "\u{1F480} Force Kill", style: "danger", payload: { quit: { ref: peer.instanceId, session: peer.sessionId, generation: managed.generation } } });
|
|
8198
8217
|
}
|
|
8199
8218
|
actions2.push({ id: "panel.worker.offline", label: "\u{1F504} Refresh", payload: { sessionId: peer.sessionId } });
|
|
8200
8219
|
actions2.push(...homeOpt);
|
|
@@ -8202,17 +8221,17 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8202
8221
|
handled: true,
|
|
8203
8222
|
keyPrefix: "panel-quit-ok",
|
|
8204
8223
|
spec: {
|
|
8205
|
-
title: exited ? `\u2705 Worker
|
|
8224
|
+
title: exited ? `\u2705 Worker Exited \xB7 ${peer.name}` : `\u23F3 Graceful Quit Sent \xB7 ${peer.name}`,
|
|
8206
8225
|
color: exited ? "green" : "blue",
|
|
8207
8226
|
columnsPerRow: cols,
|
|
8208
|
-
body: exited ? resumable?.allowed ?
|
|
8227
|
+
body: exited ? resumable?.allowed ? `Gracefully exited \`${cleanCodeSpan(peer.name, 48)}\` (session \`${cleanCodeSpan(peer.sessionId, 64)}\` saved; ready to Resume anytime).` : `Gracefully exited \`${cleanCodeSpan(peer.name, 48)}\` (session \`${cleanCodeSpan(peer.sessionId, 64)}\` ${resumable?.reason ? `cannot be resumed yet: ${sanitizeLiteralMarkdown(resumable.reason)}` : "has no persisted resumable history yet"}).` : `Sent graceful quit to \`${cleanCodeSpan(peer.name, 48)}\`; flushing state. Tap \u{1F504} Refresh shortly to verify${managed ? ", or tap \u{1F480} Force Kill if unresponsive" : ""}.`,
|
|
8209
8228
|
actions: actions2
|
|
8210
8229
|
}
|
|
8211
8230
|
};
|
|
8212
8231
|
}
|
|
8213
8232
|
const actions = [];
|
|
8214
8233
|
if (managed) {
|
|
8215
|
-
actions.push({ id: `panel.quit.force.${peer.instanceId}`, label: "\u{1F480}
|
|
8234
|
+
actions.push({ id: `panel.quit.force.${peer.instanceId}`, label: "\u{1F480} Force Kill", style: "danger", payload: { quit: { ref: peer.instanceId, session: peer.sessionId, generation: managed.generation } } });
|
|
8216
8235
|
}
|
|
8217
8236
|
actions.push({ id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F Back" });
|
|
8218
8237
|
actions.push(...homeOpt);
|
|
@@ -8220,10 +8239,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8220
8239
|
handled: true,
|
|
8221
8240
|
keyPrefix: "panel-quit-fail",
|
|
8222
8241
|
spec: {
|
|
8223
|
-
title: `\u26A0\uFE0F
|
|
8242
|
+
title: `\u26A0\uFE0F Graceful Quit Unresponsive \xB7 ${peer.name}`,
|
|
8224
8243
|
color: "red",
|
|
8225
8244
|
columnsPerRow: cols,
|
|
8226
|
-
body: `${sanitizeLiteralMarkdown(receipt.detail)}${managed ? "\n\
|
|
8245
|
+
body: `${sanitizeLiteralMarkdown(receipt.detail)}${managed ? "\n\nThis worker is supervised by `pie-proc`; tap **\u{1F480} Force Kill** below to terminate its process group (verified by launchToken)." : ""}`,
|
|
8227
8246
|
actions
|
|
8228
8247
|
}
|
|
8229
8248
|
};
|
|
@@ -8236,10 +8255,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8236
8255
|
handled: true,
|
|
8237
8256
|
keyPrefix: "panel-quit-force-unverified",
|
|
8238
8257
|
spec: {
|
|
8239
|
-
title: "\u26D4\uFE0F
|
|
8258
|
+
title: "\u26D4\uFE0F Force Kill Binding Expired",
|
|
8240
8259
|
color: "red",
|
|
8241
8260
|
columnsPerRow: cols,
|
|
8242
|
-
body: "
|
|
8261
|
+
body: "Missing or expired force-kill card binding. Re-open the target worker from `/panel` and try again.",
|
|
8243
8262
|
actions: homeOrWorker()
|
|
8244
8263
|
}
|
|
8245
8264
|
};
|
|
@@ -8251,10 +8270,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8251
8270
|
handled: true,
|
|
8252
8271
|
keyPrefix: "panel-quit-force-refused",
|
|
8253
8272
|
spec: {
|
|
8254
|
-
title: "\u26D4\uFE0F
|
|
8273
|
+
title: "\u26D4\uFE0F Force Kill Unavailable",
|
|
8255
8274
|
color: "red",
|
|
8256
8275
|
columnsPerRow: cols,
|
|
8257
|
-
body: "Manager
|
|
8276
|
+
body: "Manager and interactive TUI sessions do not support remote force kill.",
|
|
8258
8277
|
actions: homeOrWorker(peerRef)
|
|
8259
8278
|
}
|
|
8260
8279
|
};
|
|
@@ -8264,10 +8283,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8264
8283
|
handled: true,
|
|
8265
8284
|
keyPrefix: "panel-quit-force-stale",
|
|
8266
8285
|
spec: {
|
|
8267
|
-
title: "\u26A0\uFE0F Worker
|
|
8286
|
+
title: "\u26A0\uFE0F Worker Session Changed",
|
|
8268
8287
|
color: "red",
|
|
8269
8288
|
columnsPerRow: cols,
|
|
8270
|
-
body: "
|
|
8289
|
+
body: "This card's target binding expired. Refresh the panel and try again.",
|
|
8271
8290
|
actions: homeOrWorker()
|
|
8272
8291
|
}
|
|
8273
8292
|
};
|
|
@@ -8280,10 +8299,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8280
8299
|
handled: true,
|
|
8281
8300
|
keyPrefix: "panel-quit-force-unmanaged",
|
|
8282
8301
|
spec: {
|
|
8283
|
-
title: "\u26A0\uFE0F
|
|
8302
|
+
title: "\u26A0\uFE0F Cannot Force Kill",
|
|
8284
8303
|
color: "red",
|
|
8285
8304
|
columnsPerRow: cols,
|
|
8286
|
-
body: "
|
|
8305
|
+
body: "Managed worker not found in this manager's `pie-proc` registry (it may have exited or was not spawned by this manager).",
|
|
8287
8306
|
actions: [
|
|
8288
8307
|
{ id: "panel.worker.offline", label: "\u{1F504} Refresh", payload: { sessionId: targetSession } },
|
|
8289
8308
|
...homeOpt
|
|
@@ -8296,10 +8315,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8296
8315
|
handled: true,
|
|
8297
8316
|
keyPrefix: "panel-quit-force-incarnation",
|
|
8298
8317
|
spec: {
|
|
8299
|
-
title: "\u26D4\uFE0F Worker
|
|
8318
|
+
title: "\u26D4\uFE0F Worker Generation Changed",
|
|
8300
8319
|
color: "red",
|
|
8301
8320
|
columnsPerRow: cols,
|
|
8302
|
-
body: "
|
|
8321
|
+
body: "This force-kill card was issued for an earlier worker generation (the worker may have restarted or resumed). Refused to kill the new process; refresh and retry.",
|
|
8303
8322
|
actions: [
|
|
8304
8323
|
{ id: "panel.worker.offline", label: "\u{1F504} Refresh", payload: { sessionId: targetSession } },
|
|
8305
8324
|
...homeOpt
|
|
@@ -8313,7 +8332,7 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8313
8332
|
handled: true,
|
|
8314
8333
|
keyPrefix: "panel-quit-force-result",
|
|
8315
8334
|
spec: {
|
|
8316
|
-
title: res.ok ? `\u2705
|
|
8335
|
+
title: res.ok ? `\u2705 Force Killed \xB7 ${managed.name}` : `\u26A0\uFE0F Force Kill Unconfirmed \xB7 ${managed.name}`,
|
|
8317
8336
|
color: res.ok ? "green" : "red",
|
|
8318
8337
|
columnsPerRow: cols,
|
|
8319
8338
|
body: sanitizeLiteralMarkdown(res.detail),
|
|
@@ -8331,7 +8350,7 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8331
8350
|
const rec = isRecord(panelCmd.payload) ? panelCmd.payload : void 0;
|
|
8332
8351
|
const archiveBack = !hideHome && rec?.from === "archive" ? [{
|
|
8333
8352
|
id: "panel.archive",
|
|
8334
|
-
label: "\u21A9\uFE0F
|
|
8353
|
+
label: "\u21A9\uFE0F Archive",
|
|
8335
8354
|
payload: {
|
|
8336
8355
|
page: typeof rec.page === "number" && Number.isFinite(rec.page) && rec.page >= 1 ? Math.floor(rec.page) : 1,
|
|
8337
8356
|
scope: rec.scope === "im" ? "im" : "all"
|
|
@@ -8344,14 +8363,14 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8344
8363
|
handled: true,
|
|
8345
8364
|
keyPrefix: "panel-resume-live",
|
|
8346
8365
|
spec: {
|
|
8347
|
-
title: `\u{1F7E2} Worker
|
|
8366
|
+
title: `\u{1F7E2} Worker Already Online \xB7 ${sanitizeLiteralMarkdown(alreadyLive.name)}`,
|
|
8348
8367
|
color: "green",
|
|
8349
8368
|
columnsPerRow: cols,
|
|
8350
|
-
body:
|
|
8369
|
+
body: `Session \`${cleanCodeSpan(sessionId, 64)}\` is already online (state: ${sanitizeLiteralMarkdown(alreadyLive.state)}).${liveThread ? `
|
|
8351
8370
|
|
|
8352
|
-
[\u{1F4AC}
|
|
8371
|
+
[\u{1F4AC} Open Thread \u2197](${liveThread})` : ""}`,
|
|
8353
8372
|
actions: [
|
|
8354
|
-
{ id: `panel.worker.${alreadyLive.instanceId}`, label: "\u{1F527}
|
|
8373
|
+
{ id: `panel.worker.${alreadyLive.instanceId}`, label: "\u{1F527} Open Worker Panel", style: "primary" },
|
|
8355
8374
|
...archiveBack,
|
|
8356
8375
|
...homeOpt
|
|
8357
8376
|
]
|
|
@@ -8364,10 +8383,10 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8364
8383
|
handled: true,
|
|
8365
8384
|
keyPrefix: "panel-resume-unavailable",
|
|
8366
8385
|
spec: {
|
|
8367
|
-
title: "\u26A0\uFE0F Resume
|
|
8386
|
+
title: "\u26A0\uFE0F Resume Unavailable",
|
|
8368
8387
|
color: "red",
|
|
8369
8388
|
columnsPerRow: cols,
|
|
8370
|
-
body: "
|
|
8389
|
+
body: "`pie-proc` lifecycle manager is not attached on this host; cannot resume workers remotely.",
|
|
8371
8390
|
actions: [...archiveBack, ...homeOrWorker()]
|
|
8372
8391
|
}
|
|
8373
8392
|
};
|
|
@@ -8380,11 +8399,11 @@ ${sanitizeLiteralMarkdown(receipt.detail)}`,
|
|
|
8380
8399
|
if (topic.threadUrl) {
|
|
8381
8400
|
topicLine = topic.opened ? `
|
|
8382
8401
|
|
|
8383
|
-
\u{1F195}
|
|
8402
|
+
\u{1F195} Opened a new thread: [\u{1F4AC} Open Thread \u2197](${topic.threadUrl})` : `
|
|
8384
8403
|
|
|
8385
|
-
\u{1F4AC}
|
|
8404
|
+
\u{1F4AC} Linked existing thread: [\u{1F4AC} Open Thread \u2197](${topic.threadUrl})`;
|
|
8386
8405
|
} else if (topic.opened) {
|
|
8387
|
-
topicLine = "\n\n\u{1F195} \
|
|
8406
|
+
topicLine = "\n\n\u{1F195} Sent a ready message and opened a new thread \u2014 reply there to continue.";
|
|
8388
8407
|
} else if (topic.note) {
|
|
8389
8408
|
topicLine = `
|
|
8390
8409
|
|
|
@@ -8395,14 +8414,14 @@ _${sanitizeLiteralMarkdown(topic.note)}_`;
|
|
|
8395
8414
|
handled: true,
|
|
8396
8415
|
keyPrefix: "panel-resume-result",
|
|
8397
8416
|
spec: {
|
|
8398
|
-
title: res.ok ? `\u267B\uFE0F Worker
|
|
8417
|
+
title: res.ok ? `\u267B\uFE0F Worker Resumed${res.name ? ` \xB7 ${res.name}` : ""}` : "\u26A0\uFE0F Resume Failed",
|
|
8399
8418
|
color: res.ok ? "green" : "red",
|
|
8400
8419
|
columnsPerRow: cols,
|
|
8401
8420
|
body: res.ok ? `${sanitizeLiteralMarkdown(res.detail)}${topicLine}
|
|
8402
8421
|
|
|
8403
|
-
|
|
8422
|
+
Wait 1\u20132s for the worker to connect, then tap **\u{1F504} Open Worker Panel** below or continue in its thread.` : sanitizeLiteralMarkdown(res.detail),
|
|
8404
8423
|
actions: [
|
|
8405
|
-
{ id: "panel.worker.offline", label: "\u{1F504}
|
|
8424
|
+
{ id: "panel.worker.offline", label: "\u{1F504} Open Worker Panel", payload: { sessionId } },
|
|
8406
8425
|
...archiveBack,
|
|
8407
8426
|
...homeOpt
|
|
8408
8427
|
]
|
|
@@ -8428,21 +8447,21 @@ function buildPeekCardSpec(targetRef, targetSession, isManagerTarget, cols, rece
|
|
|
8428
8447
|
const actions = [
|
|
8429
8448
|
{
|
|
8430
8449
|
id: `panel.peek.refresh.${targetRef}`,
|
|
8431
|
-
label: meta.page > 1 ? "\u23ED
|
|
8450
|
+
label: meta.page > 1 ? "\u23ED Latest" : "\u{1F504} Refresh",
|
|
8432
8451
|
payload: { peek: { ref: targetRef, session: targetSession, page: 1 } }
|
|
8433
8452
|
}
|
|
8434
8453
|
];
|
|
8435
8454
|
if (meta.page < meta.totalPages) {
|
|
8436
8455
|
actions.push({
|
|
8437
8456
|
id: `panel.peek.refresh.${targetRef}`,
|
|
8438
|
-
label: "\u25C0\uFE0F
|
|
8457
|
+
label: "\u25C0\uFE0F Older",
|
|
8439
8458
|
payload: { peek: { ref: targetRef, session: targetSession, page: meta.page + 1 } }
|
|
8440
8459
|
});
|
|
8441
8460
|
}
|
|
8442
8461
|
if (meta.page > 2) {
|
|
8443
8462
|
actions.push({
|
|
8444
8463
|
id: `panel.peek.refresh.${targetRef}`,
|
|
8445
|
-
label: "
|
|
8464
|
+
label: "Newer \u25B6\uFE0F",
|
|
8446
8465
|
payload: { peek: { ref: targetRef, session: targetSession, page: meta.page - 1 } }
|
|
8447
8466
|
});
|
|
8448
8467
|
}
|
|
@@ -8450,7 +8469,7 @@ function buildPeekCardSpec(targetRef, targetSession, isManagerTarget, cols, rece
|
|
|
8450
8469
|
actions.push({ id: `panel.worker.${targetRef}`, label: "\u21A9\uFE0F Worker" });
|
|
8451
8470
|
}
|
|
8452
8471
|
if (!inThread) {
|
|
8453
|
-
actions.push({ id: "panel.home", label: "\u{1F4CB}
|
|
8472
|
+
actions.push({ id: "panel.home", label: "\u{1F4CB} Home" });
|
|
8454
8473
|
}
|
|
8455
8474
|
return {
|
|
8456
8475
|
title: isManagerTarget ? "\u{1F440} Manager Peek" : "\u{1F440} Worker Peek",
|
|
@@ -8515,13 +8534,13 @@ function formatNextTime(next, enabled, state) {
|
|
|
8515
8534
|
}
|
|
8516
8535
|
function formatJobState(job) {
|
|
8517
8536
|
if (job.state === "running") {
|
|
8518
|
-
if (job.pendingAction === "remove") return "\u23F3
|
|
8519
|
-
if (job.pendingAction === "pause") return "\u23F3
|
|
8537
|
+
if (job.pendingAction === "remove") return "\u23F3 stopping";
|
|
8538
|
+
if (job.pendingAction === "pause") return "\u23F3 pausing";
|
|
8520
8539
|
return "\u{1F7E1} running";
|
|
8521
8540
|
}
|
|
8522
8541
|
if (job.state === "blocked") return "\u{1F534} blocked";
|
|
8523
8542
|
if (!job.enabled) {
|
|
8524
|
-
if (job.remaining !== void 0 && job.remaining <= 0) return "\u2705
|
|
8543
|
+
if (job.remaining !== void 0 && job.remaining <= 0) return "\u2705 done";
|
|
8525
8544
|
return "\u23F8 paused";
|
|
8526
8545
|
}
|
|
8527
8546
|
return "\u{1F7E2} ready";
|
|
@@ -8547,15 +8566,15 @@ function composeCronListCard(opts) {
|
|
|
8547
8566
|
const baseMeta = isWorker ? { from: "worker", ...opts.peer ? { peer: opts.peer.instanceId } : {}, ...targetSessionId ? { sessionId: targetSessionId } : {} } : { from: "global" };
|
|
8548
8567
|
const backActions = isWorker ? [
|
|
8549
8568
|
...opts.peer ? [{ id: `panel.worker.${opts.peer.instanceId}`, label: "\u21A9\uFE0F Worker" }] : targetSessionId ? [{ id: "panel.worker.offline", label: "\u21A9\uFE0F Worker", payload: { sessionId: targetSessionId } }] : [],
|
|
8550
|
-
...hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB}
|
|
8551
|
-
] : [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
8569
|
+
...hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB} Home" }]
|
|
8570
|
+
] : [{ id: "panel.home", label: "\u21A9\uFE0F Home" }];
|
|
8552
8571
|
const bridge = currentCronPanelBridge();
|
|
8553
8572
|
if (!bridge) {
|
|
8554
8573
|
return {
|
|
8555
8574
|
title: `\u23F0 Cron${titleSuffix}`,
|
|
8556
8575
|
color: "grey",
|
|
8557
8576
|
columnsPerRow: cols,
|
|
8558
|
-
body: "
|
|
8577
|
+
body: "The `cron` extension is not enabled on this host; scheduled jobs cannot be listed.",
|
|
8559
8578
|
actions: backActions
|
|
8560
8579
|
};
|
|
8561
8580
|
}
|
|
@@ -8580,35 +8599,35 @@ function composeCronListCard(opts) {
|
|
|
8580
8599
|
const rowActions = [];
|
|
8581
8600
|
if (job.state === "running") {
|
|
8582
8601
|
if (job.pendingAction !== "pause" && job.pendingAction !== "remove") {
|
|
8583
|
-
rowActions.push({ id: `panel.cron.pause.${job.id}`, label: "\u23F8
|
|
8602
|
+
rowActions.push({ id: `panel.cron.pause.${job.id}`, label: "\u23F8 Pause", payload: actionPayload });
|
|
8584
8603
|
}
|
|
8585
8604
|
if (job.pendingAction !== "remove") {
|
|
8586
|
-
rowActions.push({ id: `panel.cron.stop.${job.id}`, label: "\u23F9
|
|
8605
|
+
rowActions.push({ id: `panel.cron.stop.${job.id}`, label: "\u23F9 Stop", style: "danger", payload: actionPayload });
|
|
8587
8606
|
}
|
|
8588
8607
|
} else if (job.enabled && job.state !== "blocked") {
|
|
8589
|
-
rowActions.push({ id: `panel.cron.pause.${job.id}`, label: "\u23F8
|
|
8590
|
-
rowActions.push({ id: `panel.cron.stop.${job.id}`, label: "\u23F9
|
|
8608
|
+
rowActions.push({ id: `panel.cron.pause.${job.id}`, label: "\u23F8 Pause", payload: actionPayload });
|
|
8609
|
+
rowActions.push({ id: `panel.cron.stop.${job.id}`, label: "\u23F9 Stop", style: "danger", payload: actionPayload });
|
|
8591
8610
|
} else {
|
|
8592
8611
|
if (canResumeJob(job)) {
|
|
8593
|
-
rowActions.push({ id: `panel.cron.resume.${job.id}`, label: "\u25B6\uFE0F
|
|
8612
|
+
rowActions.push({ id: `panel.cron.resume.${job.id}`, label: "\u25B6\uFE0F Resume", style: "primary", payload: actionPayload });
|
|
8594
8613
|
}
|
|
8595
|
-
rowActions.push({ id: `panel.cron.stop.${job.id}`, label: "\u23F9
|
|
8614
|
+
rowActions.push({ id: `panel.cron.stop.${job.id}`, label: "\u23F9 Stop", style: "danger", payload: actionPayload });
|
|
8596
8615
|
}
|
|
8597
8616
|
return { text: lines.join("\n"), actions: rowActions };
|
|
8598
8617
|
});
|
|
8599
8618
|
const bodyParts = [];
|
|
8600
8619
|
if (opts.banner) bodyParts.push(opts.banner);
|
|
8601
8620
|
if (jobs.length === 0) {
|
|
8602
|
-
bodyParts.push(isWorker ? "
|
|
8621
|
+
bodyParts.push(isWorker ? "_No scheduled jobs for this worker._" : "_No scheduled jobs._");
|
|
8603
8622
|
}
|
|
8604
8623
|
const footerParts = [];
|
|
8605
8624
|
if (listed.warnings && listed.warnings.length > 0) {
|
|
8606
8625
|
footerParts.push(`\u26A0\uFE0F _${cleanInlineText(listed.warnings.join(" \xB7 "), 160)}_`);
|
|
8607
8626
|
}
|
|
8608
|
-
footerParts.push("
|
|
8627
|
+
footerParts.push("Create new scheduled jobs in chat; inline buttons pause, resume, or stop jobs directly (zero LLM).");
|
|
8609
8628
|
const navButtons = [];
|
|
8610
|
-
if (page > 1) navButtons.push({ id: navCmd, label: `\u25C0\uFE0F
|
|
8611
|
-
if (page < totalPages) navButtons.push({ id: navCmd, label:
|
|
8629
|
+
if (page > 1) navButtons.push({ id: navCmd, label: `\u25C0\uFE0F Page ${page - 1}`, payload: { ...baseMeta, page: page - 1 } });
|
|
8630
|
+
if (page < totalPages) navButtons.push({ id: navCmd, label: `Page ${page + 1} \u25B6\uFE0F`, payload: { ...baseMeta, page: page + 1 } });
|
|
8612
8631
|
navButtons.push({ id: navCmd, label: "\u{1F504} Refresh", payload: { ...baseMeta, page } });
|
|
8613
8632
|
return {
|
|
8614
8633
|
title: `\u23F0 Cron${titleSuffix}`,
|
|
@@ -8633,20 +8652,20 @@ function composeCronStopConfirmCard(job, opts) {
|
|
|
8633
8652
|
cronStop: { jobId: job.id, sessionId: job.sessionId, storeKey: job.storeKey }
|
|
8634
8653
|
};
|
|
8635
8654
|
return {
|
|
8636
|
-
title: "\u23F9
|
|
8655
|
+
title: "\u23F9 Confirm Stop Cron Job",
|
|
8637
8656
|
subtitle: `${cleanCell(job.schedule.text, 48)} \xB7 ${formatJobState(job)}`,
|
|
8638
8657
|
color: "red",
|
|
8639
8658
|
columnsPerRow: cols,
|
|
8640
8659
|
body: [
|
|
8641
|
-
`- **task
|
|
8642
|
-
`- **schedule
|
|
8643
|
-
...job.ownerLabel ? [`- **owner
|
|
8660
|
+
`- **task**: ${cleanCell(job.summary, 64)}`,
|
|
8661
|
+
`- **schedule**: ${formatScheduleCell(job)} \xB7 **state**: ${formatJobState(job)}`,
|
|
8662
|
+
...job.ownerLabel ? [`- **owner**: ${cleanCell(job.ownerLabel, 32)}`] : [],
|
|
8644
8663
|
``,
|
|
8645
|
-
job.state === "running" ? "\u26A0\uFE0F
|
|
8664
|
+
job.state === "running" ? "\u26A0\uFE0F This job is currently running. Confirming will queue removal as soon as this turn finishes." : job.managedBy ? `Stopping removes managed job \`${cleanCodeSpan(job.managedBy, 64)}\` and remembers the opt-out (it will not auto-recreate on restart).` : "Stopping permanently removes this scheduled job (you can recreate it in chat anytime)."
|
|
8646
8665
|
].join("\n"),
|
|
8647
8666
|
actions: [
|
|
8648
|
-
{ id: `panel.cron.stop.confirm.${job.id}`, label: "\u2705
|
|
8649
|
-
{ id: backListCmd, label: "\u21A9\uFE0F
|
|
8667
|
+
{ id: `panel.cron.stop.confirm.${job.id}`, label: "\u2705 Confirm Stop", style: "danger", payload: stopPayload },
|
|
8668
|
+
{ id: backListCmd, label: "\u21A9\uFE0F Cancel", payload: baseMeta }
|
|
8650
8669
|
]
|
|
8651
8670
|
};
|
|
8652
8671
|
}
|
|
@@ -8715,10 +8734,10 @@ function runCronPanelCommand(panelCmd, opts) {
|
|
|
8715
8734
|
handled: true,
|
|
8716
8735
|
keyPrefix: "panel-worker-cron-offline",
|
|
8717
8736
|
spec: {
|
|
8718
|
-
title: "\u23F0 Cron \xB7 Worker
|
|
8737
|
+
title: "\u23F0 Cron \xB7 Worker Offline",
|
|
8719
8738
|
color: "grey",
|
|
8720
8739
|
columnsPerRow: cols,
|
|
8721
|
-
body: "
|
|
8740
|
+
body: "Worker session not found. Please refresh and try again.",
|
|
8722
8741
|
actions: panelHomeAction(opts.hideHome, opts.pinnedWorkerSessionId)
|
|
8723
8742
|
}
|
|
8724
8743
|
};
|
|
@@ -8762,7 +8781,7 @@ function runCronPanelCommand(panelCmd, opts) {
|
|
|
8762
8781
|
inThread: opts.inThread,
|
|
8763
8782
|
hideHome: opts.hideHome,
|
|
8764
8783
|
page: meta.page,
|
|
8765
|
-
banner: "\u26A0\uFE0F
|
|
8784
|
+
banner: "\u26A0\uFE0F Scheduled job not found (it may have already stopped or completed)."
|
|
8766
8785
|
})
|
|
8767
8786
|
};
|
|
8768
8787
|
}
|
|
@@ -8803,7 +8822,7 @@ function runCronPanelCommand(panelCmd, opts) {
|
|
|
8803
8822
|
inThread: opts.inThread,
|
|
8804
8823
|
hideHome: opts.hideHome,
|
|
8805
8824
|
page: meta.page,
|
|
8806
|
-
banner: "\u26D4\uFE0F
|
|
8825
|
+
banner: "\u26D4\uFE0F Stop confirmation expired or invalid. Please tap \u23F9 Stop again."
|
|
8807
8826
|
})
|
|
8808
8827
|
};
|
|
8809
8828
|
}
|
|
@@ -8824,8 +8843,9 @@ function runCronPanelCommand(panelCmd, opts) {
|
|
|
8824
8843
|
...opts.senderId ? { senderId: opts.senderId } : {},
|
|
8825
8844
|
...storeKey ? { storeKey } : {}
|
|
8826
8845
|
});
|
|
8827
|
-
const verb = action === "pause" ? "
|
|
8828
|
-
const
|
|
8846
|
+
const verb = action === "pause" ? "pause" : action === "resume" ? "resume" : "stop";
|
|
8847
|
+
const pastVerb = action === "pause" ? "Paused" : action === "resume" ? "Resumed" : "Stopped";
|
|
8848
|
+
const banner = res.ok ? res.outcome === "deferred" ? `\u23F3 Queued ${verb} (job is running; takes effect after this turn)` : `\u2705 ${pastVerb} cron job${res.job ? `: ${cleanInlineText(res.job.summary, 40)}` : ""}` : `\u26A0\uFE0F Failed to ${verb}: ${cleanInlineText(res.detail, 120)}`;
|
|
8829
8849
|
return {
|
|
8830
8850
|
handled: true,
|
|
8831
8851
|
keyPrefix: `panel-cron-${action}`,
|
|
@@ -8882,17 +8902,17 @@ function formatNodeClock(timestamp) {
|
|
|
8882
8902
|
function kindBadge(kind) {
|
|
8883
8903
|
switch (kind) {
|
|
8884
8904
|
case "user":
|
|
8885
|
-
return "\u{1F464}
|
|
8905
|
+
return "\u{1F464} User";
|
|
8886
8906
|
case "assistant":
|
|
8887
|
-
return "\u{1F916}
|
|
8907
|
+
return "\u{1F916} Assistant";
|
|
8888
8908
|
case "tool":
|
|
8889
|
-
return "\u{1F527}
|
|
8909
|
+
return "\u{1F527} Tool";
|
|
8890
8910
|
case "compaction":
|
|
8891
|
-
return "\u{1F9F9}
|
|
8911
|
+
return "\u{1F9F9} Compact";
|
|
8892
8912
|
case "fork":
|
|
8893
|
-
return "\u{1F33F}
|
|
8913
|
+
return "\u{1F33F} Fork";
|
|
8894
8914
|
default:
|
|
8895
|
-
return "\u{1F4CC}
|
|
8915
|
+
return "\u{1F4CC} Entry";
|
|
8896
8916
|
}
|
|
8897
8917
|
}
|
|
8898
8918
|
function parseTreeMeta(payload) {
|
|
@@ -8990,17 +9010,17 @@ function backActionsFor(peer, opts) {
|
|
|
8990
9010
|
return [{ id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F Worker" }];
|
|
8991
9011
|
}
|
|
8992
9012
|
if (opts.from === "home" || peer.isManager) {
|
|
8993
|
-
return [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
9013
|
+
return [{ id: "panel.home", label: "\u21A9\uFE0F Home" }];
|
|
8994
9014
|
}
|
|
8995
9015
|
return [
|
|
8996
9016
|
{ id: `panel.worker.${peer.instanceId}`, label: "\u21A9\uFE0F Worker" },
|
|
8997
|
-
{ id: "panel.home", label: "\u{1F4CB}
|
|
9017
|
+
{ id: "panel.home", label: "\u{1F4CB} Home" }
|
|
8998
9018
|
];
|
|
8999
9019
|
}
|
|
9000
9020
|
function formatPeerErrorDetail(detail) {
|
|
9001
9021
|
const unwrapped = unwrapControlReceiptMessage(detail)?.message ?? detail;
|
|
9002
9022
|
if (/unknown control:\s*session\.(?:tree|branch)/i.test(unwrapped)) {
|
|
9003
|
-
return "
|
|
9023
|
+
return "This session is running an older version of Pie that does not support remote Tree (upgrade to enable).";
|
|
9004
9024
|
}
|
|
9005
9025
|
return sanitizeLiteralMarkdown(unwrapped);
|
|
9006
9026
|
}
|
|
@@ -9013,17 +9033,17 @@ function composeTreeListCard(peer, report, opts) {
|
|
|
9013
9033
|
const items = report.nodes.map((node) => {
|
|
9014
9034
|
const marker = node.isHead ? "\u2605" : node.onActivePath ? "\u25CF" : "\u{1F33F}";
|
|
9015
9035
|
const tags = [];
|
|
9016
|
-
if (node.isHead) tags.push("
|
|
9036
|
+
if (node.isHead) tags.push("current");
|
|
9017
9037
|
if (node.isBranchPoint) tags.push(`\u2442\xD7${node.childCount}`);
|
|
9018
|
-
if (node.isBranchTip) tags.push("
|
|
9038
|
+
if (node.isBranchTip) tags.push("branch tip");
|
|
9019
9039
|
if (node.label) tags.push(`\u{1F3F7}\uFE0F${cleanInline4(node.label, 20)}`);
|
|
9020
9040
|
const tagSuffix = tags.length > 0 ? ` \xB7 ${tags.join(" ")}` : "";
|
|
9021
|
-
const preview = cleanInline4(node.preview || "(
|
|
9041
|
+
const preview = cleanInline4(node.preview || "(empty)", 72);
|
|
9022
9042
|
const text = `${marker} **#${node.seq}** ${kindBadge(node.kind)} \xB7 ${formatNodeClock(node.timestamp)}${tagSuffix}
|
|
9023
9043
|
${preview}`;
|
|
9024
9044
|
const actions = node.isHead ? [] : [{
|
|
9025
9045
|
id: `panel.tree.branch.${peer.instanceId}`,
|
|
9026
|
-
label: node.onActivePath ? "\u23EA
|
|
9046
|
+
label: node.onActivePath ? "\u23EA Rewind" : "\u{1F33F} Switch",
|
|
9027
9047
|
payload: { entryId: node.id, page: report.page, filter: report.filter, from: fromVal }
|
|
9028
9048
|
}];
|
|
9029
9049
|
return { text, ...actions.length > 0 ? { actions } : {} };
|
|
@@ -9031,37 +9051,37 @@ ${preview}`;
|
|
|
9031
9051
|
const bodyLines = [];
|
|
9032
9052
|
if (opts.banner) bodyLines.push(opts.banner);
|
|
9033
9053
|
if (!report.isIdle || report.compactionRunning) {
|
|
9034
|
-
bodyLines.push("\u26A0\uFE0F
|
|
9054
|
+
bodyLines.push("\u26A0\uFE0F Session is currently busy (streaming or compacting). Stop the current turn before switching branches.");
|
|
9035
9055
|
}
|
|
9036
9056
|
if (report.truncated) {
|
|
9037
|
-
bodyLines.push("\u2139\uFE0F \
|
|
9057
|
+
bodyLines.push("\u2139\uFE0F Large session tree \u2014 scanning only the most recent window (filter still shows latest key entries).");
|
|
9038
9058
|
}
|
|
9039
9059
|
if (items.length === 0) {
|
|
9040
|
-
bodyLines.push(report.filter === "key" ? "
|
|
9060
|
+
bodyLines.push(report.filter === "key" ? '_No key entries yet \u2014 tap "\u{1F50D} Show All" below to view all entries._' : "_No tree entries in this session yet._");
|
|
9041
9061
|
}
|
|
9042
9062
|
const navButtons = [];
|
|
9043
9063
|
if (report.page > 1) {
|
|
9044
|
-
navButtons.push({ id: `panel.tree.${peer.instanceId}`, label: `\u25C0\uFE0F
|
|
9064
|
+
navButtons.push({ id: `panel.tree.${peer.instanceId}`, label: `\u25C0\uFE0F Page ${report.page - 1}`, payload: { ...navBase, page: report.page - 1 } });
|
|
9045
9065
|
}
|
|
9046
9066
|
if (report.page < report.totalPages) {
|
|
9047
|
-
navButtons.push({ id: `panel.tree.${peer.instanceId}`, label:
|
|
9067
|
+
navButtons.push({ id: `panel.tree.${peer.instanceId}`, label: `Page ${report.page + 1} \u25B6\uFE0F`, payload: { ...navBase, page: report.page + 1 } });
|
|
9048
9068
|
}
|
|
9049
|
-
const toggleFilter = report.filter === "key" ? { id: `panel.tree.${peer.instanceId}`, label: "\u{1F50D}
|
|
9069
|
+
const toggleFilter = report.filter === "key" ? { id: `panel.tree.${peer.instanceId}`, label: "\u{1F50D} Show All", payload: { filter: "all", page: 1, from: fromVal } } : { id: `panel.tree.${peer.instanceId}`, label: "\u2728 Key Only", payload: { filter: "key", page: 1, from: fromVal } };
|
|
9050
9070
|
const subtitleParts = [
|
|
9051
|
-
headSeq !== void 0 ?
|
|
9052
|
-
`${report.totalEntries}
|
|
9053
|
-
...report.branchPointCount > 0 ? [`${report.branchPointCount}
|
|
9054
|
-
...report.otherBranchTipCount > 0 ? [`${report.otherBranchTipCount}
|
|
9071
|
+
headSeq !== void 0 ? `HEAD #${headSeq}` : "no active entry",
|
|
9072
|
+
`${report.totalEntries} entries`,
|
|
9073
|
+
...report.branchPointCount > 0 ? [`${report.branchPointCount} forks`] : [],
|
|
9074
|
+
...report.otherBranchTipCount > 0 ? [`${report.otherBranchTipCount} other branches`] : [],
|
|
9055
9075
|
`p${report.page}/${report.totalPages}`
|
|
9056
9076
|
];
|
|
9057
9077
|
return {
|
|
9058
|
-
title: `\u{1F333}
|
|
9078
|
+
title: `\u{1F333} Session Tree \xB7 ${displayTitle}`,
|
|
9059
9079
|
subtitle: subtitleParts.join(" \xB7 "),
|
|
9060
9080
|
color: !report.isIdle || report.compactionRunning ? "violet" : "blue",
|
|
9061
9081
|
columnsPerRow: cols,
|
|
9062
9082
|
body: bodyLines.join("\n\n"),
|
|
9063
9083
|
...items.length > 0 ? { items } : {},
|
|
9064
|
-
footer: "\u2605
|
|
9084
|
+
footer: "\u2605 current \u25CF active path \u{1F33F} other branch \xB7 Rewind is lossless; old branches stay intact to switch back anytime (zero LLM).",
|
|
9065
9085
|
actions: [
|
|
9066
9086
|
...navButtons,
|
|
9067
9087
|
toggleFilter,
|
|
@@ -9076,62 +9096,62 @@ function composeTreeBranchConfirmCard(peer, detail, opts) {
|
|
|
9076
9096
|
const fromVal = opts.from ?? (peer.isManager ? "home" : "worker");
|
|
9077
9097
|
const cancelAction = {
|
|
9078
9098
|
id: `panel.tree.${peer.instanceId}`,
|
|
9079
|
-
label: "\u21A9\uFE0F
|
|
9099
|
+
label: "\u21A9\uFE0F Tree",
|
|
9080
9100
|
payload: { page: opts.page, filter: opts.filter, from: fromVal }
|
|
9081
9101
|
};
|
|
9082
9102
|
const entry = detail.entry;
|
|
9083
9103
|
if (!entry) {
|
|
9084
9104
|
return {
|
|
9085
|
-
title: "\u26A0\uFE0F
|
|
9105
|
+
title: "\u26A0\uFE0F Entry Not Found",
|
|
9086
9106
|
subtitle: displayTitle,
|
|
9087
9107
|
color: "grey",
|
|
9088
9108
|
columnsPerRow: cols,
|
|
9089
|
-
body: "
|
|
9109
|
+
body: "The target entry no longer exists in this session. Refresh the session tree and try again.",
|
|
9090
9110
|
actions: [cancelAction]
|
|
9091
9111
|
};
|
|
9092
9112
|
}
|
|
9093
9113
|
if (entry.isHead) {
|
|
9094
9114
|
return {
|
|
9095
|
-
title: `\u{1F333}
|
|
9115
|
+
title: `\u{1F333} Already at Entry #${entry.seq}`,
|
|
9096
9116
|
subtitle: displayTitle,
|
|
9097
9117
|
color: "green",
|
|
9098
9118
|
columnsPerRow: cols,
|
|
9099
|
-
body: "\
|
|
9119
|
+
body: "The session pointer is already on this entry \u2014 no switch needed.",
|
|
9100
9120
|
actions: [cancelAction]
|
|
9101
9121
|
};
|
|
9102
9122
|
}
|
|
9103
9123
|
if (!detail.isIdle || detail.compactionRunning) {
|
|
9104
9124
|
return {
|
|
9105
|
-
title: "\u26A0\uFE0F \
|
|
9106
|
-
subtitle: `${displayTitle} \xB7
|
|
9125
|
+
title: "\u26A0\uFE0F Session Busy \u2014 Cannot Switch Branch",
|
|
9126
|
+
subtitle: `${displayTitle} \xB7 target #${entry.seq}`,
|
|
9107
9127
|
color: "red",
|
|
9108
9128
|
columnsPerRow: cols,
|
|
9109
|
-
body: detail.compactionRunning ? "
|
|
9129
|
+
body: detail.compactionRunning ? "Context compaction is currently running. Wait for it to finish before switching branches." : "A turn is currently running or queued. Stop the current turn before rewinding.",
|
|
9110
9130
|
actions: [
|
|
9111
9131
|
...!detail.compactionRunning ? [{ id: `panel.stop.${peer.instanceId}`, label: "\u23F9 Stop", payload: { from: fromVal, peer: peer.instanceId } }] : [],
|
|
9112
9132
|
cancelAction
|
|
9113
9133
|
]
|
|
9114
9134
|
};
|
|
9115
9135
|
}
|
|
9116
|
-
const impactLine = entry.onActivePath ?
|
|
9136
|
+
const impactLine = entry.onActivePath ? `Rewinds the session pointer to **#${entry.seq}** (skipping **${entry.activePathAfterCount}** subsequent entry/entries on the current path).` : `Switches the session pointer to **#${entry.seq}** on another branch.`;
|
|
9117
9137
|
return {
|
|
9118
|
-
title: entry.onActivePath ? `\u23EA
|
|
9138
|
+
title: entry.onActivePath ? `\u23EA Confirm Rewind to #${entry.seq}` : `\u{1F33F} Confirm Switch to Branch #${entry.seq}`,
|
|
9119
9139
|
subtitle: `${displayTitle} \xB7 ${kindBadge(entry.kind)} \xB7 ${formatNodeClock(entry.timestamp)}`,
|
|
9120
9140
|
color: "red",
|
|
9121
9141
|
columnsPerRow: cols,
|
|
9122
9142
|
body: [
|
|
9123
|
-
`- **session
|
|
9124
|
-
`- **target
|
|
9125
|
-
`- **preview
|
|
9143
|
+
`- **session**: ${cleanInline4(displayTitle, 48)}`,
|
|
9144
|
+
`- **target**: #${entry.seq} (${kindBadge(entry.kind)} \xB7 ${formatNodeClock(entry.timestamp)})`,
|
|
9145
|
+
`- **preview**: ${cleanInline4(entry.preview || "(empty)", 72)}`,
|
|
9126
9146
|
"",
|
|
9127
9147
|
impactLine,
|
|
9128
|
-
"\u2705
|
|
9129
|
-
"\u2139\uFE0F \
|
|
9148
|
+
"\u2705 **Lossless**: the previous branch stays intact in the session tree and can be restored via Tree anytime.",
|
|
9149
|
+
"\u2139\uFE0F Switches only the agent's session context \u2014 previously sent chat messages are not recalled."
|
|
9130
9150
|
].join("\n"),
|
|
9131
9151
|
actions: [
|
|
9132
9152
|
{
|
|
9133
9153
|
id: `panel.tree.branch.confirm.${peer.instanceId}`,
|
|
9134
|
-
label: "\u2705
|
|
9154
|
+
label: "\u2705 Confirm Switch",
|
|
9135
9155
|
style: "danger",
|
|
9136
9156
|
payload: {
|
|
9137
9157
|
treeBranch: { ref: peer.instanceId, session: detail.sessionId, entryId: entry.id },
|
|
@@ -9142,7 +9162,7 @@ function composeTreeBranchConfirmCard(peer, detail, opts) {
|
|
|
9142
9162
|
},
|
|
9143
9163
|
{
|
|
9144
9164
|
id: `panel.tree.${peer.instanceId}`,
|
|
9145
|
-
label: "\u21A9\uFE0F
|
|
9165
|
+
label: "\u21A9\uFE0F Cancel",
|
|
9146
9166
|
payload: { page: opts.page, filter: opts.filter, from: fromVal }
|
|
9147
9167
|
}
|
|
9148
9168
|
]
|
|
@@ -9157,10 +9177,10 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9157
9177
|
handled: true,
|
|
9158
9178
|
keyPrefix: "panel-tree-denied",
|
|
9159
9179
|
spec: {
|
|
9160
|
-
title: "\u{1F333}
|
|
9180
|
+
title: "\u{1F333} Session Tree Unavailable",
|
|
9161
9181
|
color: "red",
|
|
9162
9182
|
columnsPerRow: cols,
|
|
9163
|
-
body: "\u26D4\uFE0F
|
|
9183
|
+
body: "\u26D4\uFE0F Session tree contains conversation previews and is restricted to authorized chats or DMs.",
|
|
9164
9184
|
actions: panelHomeAction(opts.hideHome, opts.pinnedWorkerSessionId)
|
|
9165
9185
|
}
|
|
9166
9186
|
};
|
|
@@ -9181,10 +9201,10 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9181
9201
|
return composeOfflineWorkerCard(opts.pinnedWorkerSessionId, { inThread: opts.inThread, hideHome: true });
|
|
9182
9202
|
}
|
|
9183
9203
|
return {
|
|
9184
|
-
title: "\u{1F333}
|
|
9204
|
+
title: "\u{1F333} Session Offline",
|
|
9185
9205
|
color: "grey",
|
|
9186
9206
|
columnsPerRow: cols,
|
|
9187
|
-
body: peerRef2 ?
|
|
9207
|
+
body: peerRef2 ? `Online session \`${cleanCodeSpan(peerRef2, 40)}\` was not found (it may have exited or be restarting).` : "No online manager session found. Refresh Home and try again.",
|
|
9188
9208
|
actions: panelHomeAction(opts.hideHome, opts.pinnedWorkerSessionId)
|
|
9189
9209
|
};
|
|
9190
9210
|
};
|
|
@@ -9206,11 +9226,11 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9206
9226
|
handled: true,
|
|
9207
9227
|
keyPrefix: "panel-tree-confirm-stale",
|
|
9208
9228
|
spec: {
|
|
9209
|
-
title: "\u26A0\uFE0F
|
|
9229
|
+
title: "\u26A0\uFE0F Confirmation Expired",
|
|
9210
9230
|
color: "grey",
|
|
9211
9231
|
columnsPerRow: cols,
|
|
9212
|
-
body: "
|
|
9213
|
-
actions: livePeer ? [{ id: `panel.tree.${livePeer.instanceId}`, label: "\u{1F333}
|
|
9232
|
+
body: "This branch switch confirmation expired, was already used, or the session changed. Open Session Tree again to pick a target.",
|
|
9233
|
+
actions: livePeer ? [{ id: `panel.tree.${livePeer.instanceId}`, label: "\u{1F333} Back to Tree", payload: { page: meta.page, filter: meta.filter, from: meta.from } }] : panelHomeAction(opts.hideHome, opts.pinnedWorkerSessionId)
|
|
9214
9234
|
}
|
|
9215
9235
|
};
|
|
9216
9236
|
}
|
|
@@ -9235,19 +9255,19 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9235
9255
|
keyPrefix: "panel-tree-branch-failed",
|
|
9236
9256
|
clearIssuedBranch: true,
|
|
9237
9257
|
spec: {
|
|
9238
|
-
title: receipt2.unknown ? "\u26A0\uFE0F
|
|
9258
|
+
title: receipt2.unknown ? "\u26A0\uFE0F Branch Switch Status Unknown" : "\u26A0\uFE0F Branch Switch Refused",
|
|
9239
9259
|
color: "red",
|
|
9240
9260
|
columnsPerRow: cols,
|
|
9241
|
-
body: `${formatPeerErrorDetail(receipt2.detail)}${receipt2.unknown ? "\n\
|
|
9261
|
+
body: `${formatPeerErrorDetail(receipt2.detail)}${receipt2.unknown ? "\n\nRefresh the session tree to check the current pointer before retrying." : ""}`,
|
|
9242
9262
|
actions: [
|
|
9243
|
-
{ id: `panel.tree.${peer2.instanceId}`, label: "\u{1F333}
|
|
9263
|
+
{ id: `panel.tree.${peer2.instanceId}`, label: "\u{1F333} Back to Tree", payload: { page: meta.page, filter: meta.filter, from: meta.from } },
|
|
9244
9264
|
...backActionsFor(peer2, { hideHome: opts.hideHome, from: meta.from, pinnedWorkerSessionId: opts.pinnedWorkerSessionId })
|
|
9245
9265
|
]
|
|
9246
9266
|
}
|
|
9247
9267
|
};
|
|
9248
9268
|
}
|
|
9249
9269
|
const switched = parseBranchSuccess(receipt2.detail, verified.sessionId, verified.entryId);
|
|
9250
|
-
const banner = switched ? switched.alreadyActive ? `\u2139\uFE0F
|
|
9270
|
+
const banner = switched ? switched.alreadyActive ? `\u2139\uFE0F Already at **#${switched.seq}**.` : `\u2705 Losslessly switched to **#${switched.seq}** (${switched.pathLength} entries on active path; previous branch preserved).` : "\u26A0\uFE0F Received an unexpected receipt; refreshed the session tree \u2014 please verify the current \u2605 pointer.";
|
|
9251
9271
|
const refreshReceipt = await applyPeerControl(
|
|
9252
9272
|
peer2.instanceId,
|
|
9253
9273
|
"session.tree",
|
|
@@ -9274,12 +9294,12 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9274
9294
|
keyPrefix: "panel-tree-switched",
|
|
9275
9295
|
clearIssuedBranch: true,
|
|
9276
9296
|
spec: {
|
|
9277
|
-
title: "\u{1F333}
|
|
9297
|
+
title: "\u{1F333} Branch Switched",
|
|
9278
9298
|
color: "green",
|
|
9279
9299
|
columnsPerRow: cols,
|
|
9280
9300
|
body: banner,
|
|
9281
9301
|
actions: [
|
|
9282
|
-
{ id: `panel.tree.${peer2.instanceId}`, label: "\u{1F333}
|
|
9302
|
+
{ id: `panel.tree.${peer2.instanceId}`, label: "\u{1F333} View Tree", payload: { page: 1, filter: meta.filter, from: meta.from } },
|
|
9283
9303
|
...backActionsFor(peer2, { hideHome: opts.hideHome, from: meta.from, pinnedWorkerSessionId: opts.pinnedWorkerSessionId })
|
|
9284
9304
|
]
|
|
9285
9305
|
}
|
|
@@ -9304,11 +9324,11 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9304
9324
|
handled: true,
|
|
9305
9325
|
keyPrefix: "panel-tree-invalid-entry",
|
|
9306
9326
|
spec: {
|
|
9307
|
-
title: "\u26A0\uFE0F
|
|
9327
|
+
title: "\u26A0\uFE0F Invalid Entry",
|
|
9308
9328
|
color: "red",
|
|
9309
9329
|
columnsPerRow: cols,
|
|
9310
|
-
body: "
|
|
9311
|
-
actions: [{ id: `panel.tree.${peer2.instanceId}`, label: "\u21A9\uFE0F
|
|
9330
|
+
body: "Missing valid target entry ID. Please pick an entry from the session tree.",
|
|
9331
|
+
actions: [{ id: `panel.tree.${peer2.instanceId}`, label: "\u21A9\uFE0F Tree", payload: { page: meta.page, filter: meta.filter, from: meta.from } }]
|
|
9312
9332
|
}
|
|
9313
9333
|
};
|
|
9314
9334
|
}
|
|
@@ -9324,11 +9344,11 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9324
9344
|
handled: true,
|
|
9325
9345
|
keyPrefix: "panel-tree-entry-error",
|
|
9326
9346
|
spec: {
|
|
9327
|
-
title: "\u26A0\uFE0F
|
|
9347
|
+
title: "\u26A0\uFE0F Cannot Read Target Entry",
|
|
9328
9348
|
color: "red",
|
|
9329
9349
|
columnsPerRow: cols,
|
|
9330
9350
|
body: formatPeerErrorDetail(receipt2.detail),
|
|
9331
|
-
actions: [{ id: `panel.tree.${peer2.instanceId}`, label: "\u21A9\uFE0F
|
|
9351
|
+
actions: [{ id: `panel.tree.${peer2.instanceId}`, label: "\u21A9\uFE0F Tree", payload: { page: meta.page, filter: meta.filter, from: meta.from } }]
|
|
9332
9352
|
}
|
|
9333
9353
|
};
|
|
9334
9354
|
}
|
|
@@ -9362,12 +9382,12 @@ async function runTreePanelCommand(panelCmd, opts) {
|
|
|
9362
9382
|
handled: true,
|
|
9363
9383
|
keyPrefix: "panel-tree-error",
|
|
9364
9384
|
spec: {
|
|
9365
|
-
title: `\u{1F333}
|
|
9385
|
+
title: `\u{1F333} Session Tree \xB7 ${peer.isManager ? "Manager" : workerDisplayTitle(peer)}`,
|
|
9366
9386
|
color: "red",
|
|
9367
9387
|
columnsPerRow: cols,
|
|
9368
9388
|
body: formatPeerErrorDetail(receipt.detail),
|
|
9369
9389
|
actions: [
|
|
9370
|
-
{ id: `panel.tree.${peer.instanceId}`, label: "\u{1F504}
|
|
9390
|
+
{ id: `panel.tree.${peer.instanceId}`, label: "\u{1F504} Retry", payload: { page: meta.page, filter: meta.filter, from: meta.from } },
|
|
9371
9391
|
...backActionsFor(peer, { hideHome: opts.hideHome, from: meta.from, pinnedWorkerSessionId: opts.pinnedWorkerSessionId })
|
|
9372
9392
|
]
|
|
9373
9393
|
}
|
|
@@ -9403,7 +9423,7 @@ function parsePage2(payload, field = "page") {
|
|
|
9403
9423
|
return Math.floor(raw);
|
|
9404
9424
|
}
|
|
9405
9425
|
function formatDateTime(ts) {
|
|
9406
|
-
if (typeof ts !== "number" || !Number.isFinite(ts) || ts <= 0) return "
|
|
9426
|
+
if (typeof ts !== "number" || !Number.isFinite(ts) || ts <= 0) return "never";
|
|
9407
9427
|
const d = new Date(ts);
|
|
9408
9428
|
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
9409
9429
|
const dd = String(d.getDate()).padStart(2, "0");
|
|
@@ -9445,7 +9465,7 @@ function enumerateCuratedPages(memoryRoot, wiki) {
|
|
|
9445
9465
|
if (userContent !== null) {
|
|
9446
9466
|
entries.push({
|
|
9447
9467
|
key: USER_PAGE_KEY,
|
|
9448
|
-
label: "\u{1F464} USER.md
|
|
9468
|
+
label: "\u{1F464} USER.md (Profile & Preferences)",
|
|
9449
9469
|
category: "user",
|
|
9450
9470
|
tokens: estimateWikiTokens(userContent)
|
|
9451
9471
|
});
|
|
@@ -9464,7 +9484,7 @@ function enumerateCuratedPages(memoryRoot, wiki) {
|
|
|
9464
9484
|
const content = wiki.readPage(rel) ?? "";
|
|
9465
9485
|
entries.push({
|
|
9466
9486
|
key: `wiki/${rel}`,
|
|
9467
|
-
label: `\u{1F4E6} wiki/${rel}
|
|
9487
|
+
label: `\u{1F4E6} wiki/${rel} (archived)`,
|
|
9468
9488
|
category: "archived",
|
|
9469
9489
|
tokens: estimateWikiTokens(content)
|
|
9470
9490
|
});
|
|
@@ -9482,22 +9502,22 @@ function readAllowlistedPage(memoryRoot, wiki, pageKey) {
|
|
|
9482
9502
|
function summarizeMemoryCron() {
|
|
9483
9503
|
try {
|
|
9484
9504
|
const bridge = currentCronPanelBridge();
|
|
9485
|
-
if (!bridge) return "
|
|
9505
|
+
if (!bridge) return "Cron bridge unavailable";
|
|
9486
9506
|
const job = bridge.listJobs().jobs.find((j) => j.isProcess && j.managedBy === "memory");
|
|
9487
|
-
if (!job) return "
|
|
9488
|
-
if (job.state === "running") return "\u{1F7E1}
|
|
9507
|
+
if (!job) return "Not enabled (run `pie memory schedule on`)";
|
|
9508
|
+
if (job.state === "running") return "\u{1F7E1} Running";
|
|
9489
9509
|
if (job.state === "blocked") {
|
|
9490
|
-
const detail = job.error ?
|
|
9491
|
-
return `\u{1F534}
|
|
9510
|
+
const detail = job.error ? ` (${cleanCodeSpan(job.error, 80)})` : "";
|
|
9511
|
+
return `\u{1F534} Blocked${detail}`;
|
|
9492
9512
|
}
|
|
9493
|
-
if (!job.enabled) return "\u23F8
|
|
9513
|
+
if (!job.enabled) return "\u23F8 Paused";
|
|
9494
9514
|
const nextText = job.next !== null ? formatDateTime(job.next) : "\u2014";
|
|
9495
9515
|
if (job.error && job.error.startsWith("degraded")) {
|
|
9496
|
-
return `\u{1F7E0}
|
|
9516
|
+
return `\u{1F7E0} Retrying \xB7 next ${nextText}`;
|
|
9497
9517
|
}
|
|
9498
|
-
return `\u{1F7E2}
|
|
9518
|
+
return `\u{1F7E2} Active (\`${cleanCodeSpan(job.schedule.text, 24)}\` \xB7 next ${nextText})`;
|
|
9499
9519
|
} catch {
|
|
9500
|
-
return "
|
|
9520
|
+
return "Unavailable";
|
|
9501
9521
|
}
|
|
9502
9522
|
}
|
|
9503
9523
|
function composeMemoryCard(opts) {
|
|
@@ -9516,26 +9536,26 @@ function composeMemoryCard(opts) {
|
|
|
9516
9536
|
const slice = allEntries.slice((page - 1) * MEMORY_PAGE_SIZE, page * MEMORY_PAGE_SIZE);
|
|
9517
9537
|
const items = slice.map((entry) => ({
|
|
9518
9538
|
text: `**${sanitizeLiteralMarkdown(entry.label)}**
|
|
9519
|
-
|
|
9539
|
+
~${entry.tokens} tokens`,
|
|
9520
9540
|
actions: [{
|
|
9521
9541
|
id: "panel.memory.view",
|
|
9522
|
-
label: "\u{1F4D6}
|
|
9542
|
+
label: "\u{1F4D6} View",
|
|
9523
9543
|
payload: { pageKey: entry.key, returnPage: page }
|
|
9524
9544
|
}]
|
|
9525
9545
|
}));
|
|
9526
|
-
const missingLine = missingDates.length === 0 ? "
|
|
9527
|
-
const lastFailLine = meta.lastDreamError ? `-
|
|
9546
|
+
const missingLine = missingDates.length === 0 ? "7-day coverage complete \u2705" : `missing ${missingDates.length} day(s) in last 7d (${missingDates.slice(-4).map((d) => d.slice(5)).join(", ")}${missingDates.length > 4 ? "\u2026" : ""})`;
|
|
9547
|
+
const lastFailLine = meta.lastDreamError ? `- **Last failure**: \`${cleanCodeSpan(meta.lastDreamError, 100)}\`${meta.lastDreamFailedDate ? ` (${meta.lastDreamFailedDate})` : ""}` : void 0;
|
|
9528
9548
|
const bodyLines = [
|
|
9529
9549
|
...opts.banner ? [opts.banner, ""] : [],
|
|
9530
|
-
`- **Wiki
|
|
9531
|
-
`- **Dream
|
|
9550
|
+
`- **Wiki**: ${exists ? `${activePages.length}/${DEFAULT_WIKI_LIMITS.maxActivePages} active \xB7 ${archivedPages.length} archived` : "Not initialized yet (created on first distill)"} \xB7 index ~${indexTokens}/${DEFAULT_WIKI_LIMITS.maxIndexTokens} tokens`,
|
|
9551
|
+
`- **Dream**: last ${formatDateTime(meta.lastDreamAt)} \xB7 ${missingLine}`,
|
|
9532
9552
|
...lastFailLine ? [lastFailLine] : [],
|
|
9533
|
-
`- **GC
|
|
9534
|
-
...allEntries.length === 0 ? ["", "_
|
|
9553
|
+
`- **GC**: last ${formatDateTime(meta.lastGcAt)} \xB7 **Schedule**: ${summarizeMemoryCron()}`,
|
|
9554
|
+
...allEntries.length === 0 ? ["", "_No memory pages available yet._"] : []
|
|
9535
9555
|
];
|
|
9536
9556
|
const nav = [];
|
|
9537
|
-
if (page > 1) nav.push({ id: "panel.memory", label: `\u25C0\uFE0F
|
|
9538
|
-
if (page < totalPages) nav.push({ id: "panel.memory", label:
|
|
9557
|
+
if (page > 1) nav.push({ id: "panel.memory", label: `\u25C0\uFE0F Page ${page - 1}`, payload: { page: page - 1 } });
|
|
9558
|
+
if (page < totalPages) nav.push({ id: "panel.memory", label: `Page ${page + 1} \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
9539
9559
|
const defaultColor = meta.lastDreamError ? "red" : "violet";
|
|
9540
9560
|
return {
|
|
9541
9561
|
title: "\u{1F9E0} Memory \xB7 Wiki & Dreaming",
|
|
@@ -9544,14 +9564,14 @@ function composeMemoryCard(opts) {
|
|
|
9544
9564
|
columnsPerRow: cols,
|
|
9545
9565
|
body: bodyLines.join("\n"),
|
|
9546
9566
|
...items.length > 0 ? { items } : {},
|
|
9547
|
-
footer: "\
|
|
9567
|
+
footer: "Tap \u{1F4D6} View to preview a page. \u{1F319} Dream Now and \u{1F9F9} Run GC run detached in the background.",
|
|
9548
9568
|
actions: [
|
|
9549
9569
|
...nav,
|
|
9550
|
-
{ id: "panel.memory.dream", label: "\u{1F319}
|
|
9551
|
-
{ id: "panel.memory.gc", label: "\u{1F9F9}
|
|
9552
|
-
{ id: "panel.memory.logs", label: "\u{1F4DC}
|
|
9570
|
+
{ id: "panel.memory.dream", label: "\u{1F319} Dream Now", style: "primary" },
|
|
9571
|
+
{ id: "panel.memory.gc", label: "\u{1F9F9} Run GC" },
|
|
9572
|
+
{ id: "panel.memory.logs", label: "\u{1F4DC} Logs" },
|
|
9553
9573
|
{ id: "panel.memory", label: "\u{1F504} Refresh", payload: { page } },
|
|
9554
|
-
{ id: "panel.home", label: "\u21A9\uFE0F
|
|
9574
|
+
{ id: "panel.home", label: "\u21A9\uFE0F Home" }
|
|
9555
9575
|
]
|
|
9556
9576
|
};
|
|
9557
9577
|
}
|
|
@@ -9563,28 +9583,28 @@ function composeMemoryPageCard(opts) {
|
|
|
9563
9583
|
const found = readAllowlistedPage(memoryRoot, wiki, opts.pageKey);
|
|
9564
9584
|
if (!found) {
|
|
9565
9585
|
return {
|
|
9566
|
-
title: "\u26A0\uFE0F
|
|
9586
|
+
title: "\u26A0\uFE0F Page Unavailable",
|
|
9567
9587
|
color: "grey",
|
|
9568
9588
|
columnsPerRow: cols,
|
|
9569
|
-
body:
|
|
9589
|
+
body: `Page \`${cleanCodeSpan(opts.pageKey, 80)}\` was not found or is not accessible. Return to Memory to select another page.`,
|
|
9570
9590
|
actions: [
|
|
9571
|
-
{ id: "panel.memory", label: "\u21A9\uFE0F
|
|
9572
|
-
{ id: "panel.home", label: "\u{1F4CB}
|
|
9591
|
+
{ id: "panel.memory", label: "\u21A9\uFE0F Memory", payload: { page: returnPage } },
|
|
9592
|
+
{ id: "panel.home", label: "\u{1F4CB} Home" }
|
|
9573
9593
|
]
|
|
9574
9594
|
};
|
|
9575
9595
|
}
|
|
9576
|
-
const preview = truncateMarkdown(found.content.trim() || "_(
|
|
9596
|
+
const preview = truncateMarkdown(found.content.trim() || "_(empty page)_", PAGE_PREVIEW_CHAR_BUDGET);
|
|
9577
9597
|
return {
|
|
9578
9598
|
title: `\u{1F4D6} ${cleanCodeSpan(found.entry.key, 48)}`,
|
|
9579
|
-
subtitle:
|
|
9599
|
+
subtitle: `~${found.entry.tokens} tokens \xB7 ${found.content.length} chars \xB7 read-only`,
|
|
9580
9600
|
color: "blue",
|
|
9581
9601
|
columnsPerRow: cols,
|
|
9582
9602
|
body: preview,
|
|
9583
|
-
footer: "
|
|
9603
|
+
footer: "To edit or delete memories, tell Manager directly in chat.",
|
|
9584
9604
|
actions: [
|
|
9585
9605
|
{ id: "panel.memory.view", label: "\u{1F504} Refresh", payload: { pageKey: found.entry.key, returnPage } },
|
|
9586
|
-
{ id: "panel.memory", label: "\u21A9\uFE0F
|
|
9587
|
-
{ id: "panel.home", label: "\u{1F4CB}
|
|
9606
|
+
{ id: "panel.memory", label: "\u21A9\uFE0F Memory", payload: { page: returnPage } },
|
|
9607
|
+
{ id: "panel.home", label: "\u{1F4CB} Home" }
|
|
9588
9608
|
]
|
|
9589
9609
|
};
|
|
9590
9610
|
}
|
|
@@ -9593,27 +9613,27 @@ function composeMemoryLogsCard(opts) {
|
|
|
9593
9613
|
const memoryRoot = resolveMemoryRoot(opts.memoryRoot);
|
|
9594
9614
|
const workerLines = (opts.hooks?.readWorkerLog ?? readDistillWorkerLog)(memoryRoot, LOG_LINE_LIMIT);
|
|
9595
9615
|
const gitLines = (opts.hooks?.readGitLog ?? readCuratedMemoryGitLog)(memoryRoot, GIT_LOG_LIMIT);
|
|
9596
|
-
const workerSection = workerLines.length > 0 ? `**distill-worker.log
|
|
9616
|
+
const workerSection = workerLines.length > 0 ? `**distill-worker.log (last ${workerLines.length} lines)**
|
|
9597
9617
|
\`\`\`
|
|
9598
9618
|
${sanitizeFenceContent(workerLines.join("\n"), 1500)}
|
|
9599
|
-
\`\`\`` : "**distill-worker.log
|
|
9600
|
-
const gitSection = gitLines.length > 0 ? `**Curated Git
|
|
9619
|
+
\`\`\`` : "**distill-worker.log**: _no entries yet_";
|
|
9620
|
+
const gitSection = gitLines.length > 0 ? `**Curated Git History (recent)**
|
|
9601
9621
|
\`\`\`
|
|
9602
9622
|
${sanitizeFenceContent(gitLines.join("\n"), 900)}
|
|
9603
|
-
\`\`\`` : "**Curated Git
|
|
9623
|
+
\`\`\`` : "**Curated Git History**: _no commits yet_";
|
|
9604
9624
|
return {
|
|
9605
|
-
title: "\u{1F4DC} Memory
|
|
9606
|
-
subtitle: "worker
|
|
9625
|
+
title: "\u{1F4DC} Memory Distillation Logs",
|
|
9626
|
+
subtitle: "worker log + curated git history \xB7 zero LLM",
|
|
9607
9627
|
color: "blue",
|
|
9608
9628
|
columnsPerRow: cols,
|
|
9609
9629
|
body: `${workerSection}
|
|
9610
9630
|
|
|
9611
9631
|
${gitSection}`,
|
|
9612
9632
|
actions: [
|
|
9613
|
-
{ id: "panel.memory.dream", label: "\u{1F319}
|
|
9633
|
+
{ id: "panel.memory.dream", label: "\u{1F319} Dream Now", style: "primary" },
|
|
9614
9634
|
{ id: "panel.memory.logs", label: "\u{1F504} Refresh" },
|
|
9615
|
-
{ id: "panel.memory", label: "\u21A9\uFE0F
|
|
9616
|
-
{ id: "panel.home", label: "\u{1F4CB}
|
|
9635
|
+
{ id: "panel.memory", label: "\u21A9\uFE0F Memory" },
|
|
9636
|
+
{ id: "panel.home", label: "\u{1F4CB} Home" }
|
|
9617
9637
|
]
|
|
9618
9638
|
};
|
|
9619
9639
|
}
|
|
@@ -9636,11 +9656,11 @@ function runMemoryPanelCommand(panelCmd, opts) {
|
|
|
9636
9656
|
handled: true,
|
|
9637
9657
|
keyPrefix: "panel-memory-denied",
|
|
9638
9658
|
spec: {
|
|
9639
|
-
title: "\u{1F9E0} Memory
|
|
9659
|
+
title: "\u{1F9E0} Memory Unavailable",
|
|
9640
9660
|
color: "red",
|
|
9641
9661
|
columnsPerRow: cols,
|
|
9642
|
-
body: "\u26D4\uFE0F Memory
|
|
9643
|
-
actions: [{ id: "panel.home", label: "\u21A9\uFE0F
|
|
9662
|
+
body: "\u26D4\uFE0F The Memory panel is restricted to authorized chats or admin DMs.",
|
|
9663
|
+
actions: [{ id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
9644
9664
|
}
|
|
9645
9665
|
};
|
|
9646
9666
|
}
|
|
@@ -9672,7 +9692,7 @@ function runMemoryPanelCommand(panelCmd, opts) {
|
|
|
9672
9692
|
if (!opts.canMutate) {
|
|
9673
9693
|
return {
|
|
9674
9694
|
handled: true,
|
|
9675
|
-
refusedText: "\u26D4\uFE0F
|
|
9695
|
+
refusedText: "\u26D4\uFE0F Triggering Memory distillation or GC requires admin rights (panelAccess=allowUsers)."
|
|
9676
9696
|
};
|
|
9677
9697
|
}
|
|
9678
9698
|
const probeLockFree = opts.hooks?.probeLockFree ?? defaultProbeLockFree;
|
|
@@ -9684,7 +9704,7 @@ function runMemoryPanelCommand(panelCmd, opts) {
|
|
|
9684
9704
|
memoryRoot,
|
|
9685
9705
|
inThread: opts.inThread,
|
|
9686
9706
|
page,
|
|
9687
|
-
banner:
|
|
9707
|
+
banner: '\u23F3 **A Memory background job is already running** (holding `distill.lock`). Tap "\u{1F4DC} Logs" shortly to check progress.',
|
|
9688
9708
|
bannerColor: "grey"
|
|
9689
9709
|
})
|
|
9690
9710
|
};
|
|
@@ -9700,7 +9720,7 @@ function runMemoryPanelCommand(panelCmd, opts) {
|
|
|
9700
9720
|
memoryRoot,
|
|
9701
9721
|
inThread: opts.inThread,
|
|
9702
9722
|
page,
|
|
9703
|
-
banner: ok2 ?
|
|
9723
|
+
banner: ok2 ? '\u{1F319} **Started background distillation (`--auto`)**. Wiki and Git will update automatically when done (tap "\u{1F4DC} Logs" to monitor).' : '\u274C **Failed to start background distillation worker**. Tap "\u{1F4DC} Logs" to inspect.',
|
|
9704
9724
|
bannerColor: ok2 ? "green" : "red"
|
|
9705
9725
|
})
|
|
9706
9726
|
};
|
|
@@ -9714,7 +9734,7 @@ function runMemoryPanelCommand(panelCmd, opts) {
|
|
|
9714
9734
|
memoryRoot,
|
|
9715
9735
|
inThread: opts.inThread,
|
|
9716
9736
|
page,
|
|
9717
|
-
banner: ok ?
|
|
9737
|
+
banner: ok ? '\u{1F9F9} **Started background Wiki GC** (archives stale projects, prunes expired anchors, compacts over-budget pages). Tap "\u{1F4DC} Logs" to monitor.' : '\u274C **Failed to start background Wiki GC**. Tap "\u{1F4DC} Logs" to inspect.',
|
|
9718
9738
|
bannerColor: ok ? "green" : "red"
|
|
9719
9739
|
})
|
|
9720
9740
|
};
|
|
@@ -10172,7 +10192,7 @@ function createPanelExecutor(ctx) {
|
|
|
10172
10192
|
return true;
|
|
10173
10193
|
};
|
|
10174
10194
|
const payloadFromWorker = isRecord(panelCmd.payload) && panelCmd.payload.from === "worker" && typeof panelCmd.payload.peer === "string" ? panelCmd.payload.peer : void 0;
|
|
10175
|
-
const homeOpt = hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB}
|
|
10195
|
+
const homeOpt = hideHome ? [] : [{ id: "panel.home", label: "\u{1F4CB} Home" }];
|
|
10176
10196
|
if (event.message_id && (panelCmd.cmd.startsWith("panel.cron.stop.confirm.") || panelCmd.cmd.startsWith("panel.tree.branch.confirm."))) {
|
|
10177
10197
|
await ctx.cards.enqueueCardPatch(event.message_id, async () => void 0);
|
|
10178
10198
|
if (!isCurrent()) return;
|
|
@@ -10221,7 +10241,7 @@ function createPanelExecutor(ctx) {
|
|
|
10221
10241
|
const modelProvider = isRecord(panelCmd.payload) && typeof panelCmd.payload.provider === "string" && panelCmd.payload.provider.trim() ? panelCmd.payload.provider.trim() : void 0;
|
|
10222
10242
|
const modelPage = isRecord(panelCmd.payload) && typeof panelCmd.payload.page === "number" && Number.isFinite(panelCmd.payload.page) ? Math.floor(panelCmd.payload.page) : void 0;
|
|
10223
10243
|
const scope = workerScoped || hideHome || payloadFromWorker ? "worker" : "manager";
|
|
10224
|
-
const banner = receipt.ok ? `\u2705
|
|
10244
|
+
const banner = receipt.ok ? `\u2705 Switched model to \`${cleanCodeSpan(model, 56)}\` (applies next turn)` : `\u26A0\uFE0F Failed to switch model \`${cleanCodeSpan(model, 56)}\`: ${sanitizeLiteralMarkdown(receipt.detail)}`;
|
|
10225
10245
|
const spec = composeUpdatedModelsCard({
|
|
10226
10246
|
peerRef,
|
|
10227
10247
|
scope,
|
|
@@ -10500,10 +10520,10 @@ function createPanelExecutor(ctx) {
|
|
|
10500
10520
|
actions: [
|
|
10501
10521
|
{
|
|
10502
10522
|
id: `panel.compact.${contextAction[1]}`,
|
|
10503
|
-
label: "\u{1F9F9}
|
|
10523
|
+
label: "\u{1F9F9} Compact",
|
|
10504
10524
|
...workerScoped || payloadFromWorker ? { payload: { from: "worker", peer: workerScoped ? contextAction[1] : payloadFromWorker } } : {}
|
|
10505
10525
|
},
|
|
10506
|
-
...workerScoped ? [{ id: `panel.worker.${contextAction[1]}`, label: "\u21A9\uFE0F Back to worker" }] : payloadFromWorker ? [{ id: `panel.worker.${payloadFromWorker}`, label: "\u21A9\uFE0F Back to worker" }, ...homeOpt] : hideHome ? panelHomeAction(true, threadWorkerSessionId, contextAction[1]) : [{ id: "panel.context", label: "\u21A9\uFE0F Back to context list" }, { id: "panel.home", label: "\u{1F4CB}
|
|
10526
|
+
...workerScoped ? [{ id: `panel.worker.${contextAction[1]}`, label: "\u21A9\uFE0F Back to worker" }] : payloadFromWorker ? [{ id: `panel.worker.${payloadFromWorker}`, label: "\u21A9\uFE0F Back to worker" }, ...homeOpt] : hideHome ? panelHomeAction(true, threadWorkerSessionId, contextAction[1]) : [{ id: "panel.context", label: "\u21A9\uFE0F Back to context list" }, { id: "panel.home", label: "\u{1F4CB} Home" }]
|
|
10507
10527
|
]
|
|
10508
10528
|
};
|
|
10509
10529
|
await deliverPanelSpec(spec, `panel-context-${event.event_id}`, true, navGen);
|
|
@@ -10574,11 +10594,11 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10574
10594
|
const action = findAction(actionId);
|
|
10575
10595
|
if (!action) {
|
|
10576
10596
|
await deliverPanelSpec({
|
|
10577
|
-
title: "\u26A0\uFE0F
|
|
10578
|
-
body: `\`${actionId}\`
|
|
10597
|
+
title: "\u26A0\uFE0F Action Removed",
|
|
10598
|
+
body: `\`${actionId}\` is not in the registry (it may have been removed).
|
|
10579
10599
|
|
|
10580
|
-
\
|
|
10581
|
-
actions: hideHome ? panelHomeAction(true, threadWorkerSessionId) : [{ id: "panel.actions", label: "\u26A1
|
|
10600
|
+
Open \u26A1 All Actions from /panel to see currently available actions.`,
|
|
10601
|
+
actions: hideHome ? panelHomeAction(true, threadWorkerSessionId) : [{ id: "panel.actions", label: "\u26A1 All Actions" }, { id: "panel.home", label: "\u21A9\uFE0F Home" }]
|
|
10582
10602
|
}, `panel-action-gone-${event.event_id}`, true);
|
|
10583
10603
|
return;
|
|
10584
10604
|
}
|
|
@@ -10604,7 +10624,7 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10604
10624
|
const ambName = cleanCodeSpan(action.scope.startsWith("worker:") ? action.scope.slice("worker:".length) : payloadWorker?.name ?? "", 64);
|
|
10605
10625
|
await deliverPanelSpec({
|
|
10606
10626
|
title: `\u26A0\uFE0F ${action.label}`,
|
|
10607
|
-
body:
|
|
10627
|
+
body: `Name \`${ambName}\` matched multiple online sessions \u2014 open the target worker card from /panel and run it there (cards carry an exact address).`,
|
|
10608
10628
|
actions: panelHomeAction(hideHome, threadWorkerSessionId)
|
|
10609
10629
|
}, `panel-action-ambiguous-${event.event_id}`, true);
|
|
10610
10630
|
return;
|
|
@@ -10614,13 +10634,13 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10614
10634
|
const generic = action.scope === "worker" && !payloadWorker?.name && !payloadWorker?.ref;
|
|
10615
10635
|
await deliverPanelSpec({
|
|
10616
10636
|
title: `\u26A0\uFE0F ${action.label}`,
|
|
10617
|
-
body: generic ? "
|
|
10637
|
+
body: generic ? "This is a generic worker action \u2014 open a specific worker card from /panel to run it with that worker's context." : `Worker \`${cleanCodeSpan(wanted, 64)}\` is offline (workers expire via TTL). Wait until it is online and trigger from its card.`,
|
|
10618
10638
|
actions: panelHomeAction(hideHome, threadWorkerSessionId)
|
|
10619
10639
|
}, `panel-action-offline-${event.event_id}`, true);
|
|
10620
10640
|
return;
|
|
10621
10641
|
}
|
|
10622
10642
|
if (workerScoped && pinnedThreadWorkerSession && peer.sessionId !== pinnedThreadWorkerSession) {
|
|
10623
|
-
await deliverPanelSpec({ title: "\u26D4\uFE0F
|
|
10643
|
+
await deliverPanelSpec({ title: "\u26D4\uFE0F Worker Panel Only", color: "red", body: "In-thread worker panels cannot run actions on other workers.", actions: panelHomeAction(true, pinnedThreadWorkerSession) }, `panel-action-scope-${event.event_id}`, true);
|
|
10624
10644
|
return;
|
|
10625
10645
|
}
|
|
10626
10646
|
workerCtx = { name: peer.name, ref: peer.instanceId, ...peer.cwd ? { dir: peer.cwd } : {} };
|
|
@@ -10632,7 +10652,7 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10632
10652
|
const since = lock.holder.startedAt > 0 ? new Date(lock.holder.startedAt).toLocaleTimeString("en-GB", { hour12: false }) : "?";
|
|
10633
10653
|
await deliverPanelSpec({
|
|
10634
10654
|
title: `\u23F3 ${action.label}`,
|
|
10635
|
-
body: lock.holder.note ? `\u26A0\uFE0F ${sanitizeLiteralMarkdown(lock.holder.note)}` :
|
|
10655
|
+
body: lock.holder.note ? `\u26A0\uFE0F ${sanitizeLiteralMarkdown(lock.holder.note)}` : `Already running (triggered by ${sanitizeLiteralMarkdown(lock.holder.triggerName)} at ${since}). Only one run of this action can execute at a time \u2014 wait for it to finish or time out.`,
|
|
10636
10656
|
actions: panelHomeAction(hideHome, threadWorkerSessionId, workerCtx?.ref)
|
|
10637
10657
|
}, `panel-action-busy-${event.event_id}`, true);
|
|
10638
10658
|
return;
|
|
@@ -10653,7 +10673,7 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10653
10673
|
title: `\u26A0\uFE0F ${action.label}`,
|
|
10654
10674
|
color: "red",
|
|
10655
10675
|
body,
|
|
10656
|
-
actions: [{ id: `panel.action.${actionId}`, label: "\u{1F501}
|
|
10676
|
+
actions: [{ id: `panel.action.${actionId}`, label: "\u{1F501} Retry", ...workerCtx ? { payload: { worker: { name: workerCtx.name, ...workerCtx.ref ? { ref: workerCtx.ref } : {} } } } : {} }, ...panelHomeAction(hideHome, threadWorkerSessionId, workerCtx?.ref)]
|
|
10657
10677
|
}, `panel-action-cancel-${event.event_id}`);
|
|
10658
10678
|
if (!runtimeAlive() || !isCurrent()) {
|
|
10659
10679
|
lock.release();
|
|
@@ -10667,9 +10687,9 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10667
10687
|
ackMessageId = await sendActionCard({
|
|
10668
10688
|
title: `\u{1F680} ${action.label}`,
|
|
10669
10689
|
color: "blue",
|
|
10670
|
-
body:
|
|
10690
|
+
body: `Triggered by ${sanitizeLiteralMarkdown(triggerQuick)} \xB7 running\u2026 (timeout ${timeoutS}s)
|
|
10671
10691
|
|
|
10672
|
-
|
|
10692
|
+
This card will update automatically when done.`,
|
|
10673
10693
|
actions: []
|
|
10674
10694
|
}, `panel-action-${event.event_id}`, isCurrent);
|
|
10675
10695
|
return true;
|
|
@@ -10678,13 +10698,13 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10678
10698
|
try {
|
|
10679
10699
|
if (!await initialAck) return;
|
|
10680
10700
|
if (actionAbort.signal.aborted) {
|
|
10681
|
-
if (ackMessageId) await publishCancellation("
|
|
10701
|
+
if (ackMessageId) await publishCancellation("Runtime exited before execution started; action was not run.");
|
|
10682
10702
|
else ctx.log(`im-forward: panel action ${actionId} retired with no initial card receipt; script not started`);
|
|
10683
10703
|
return;
|
|
10684
10704
|
}
|
|
10685
10705
|
actionAbort.signal.removeEventListener("abort", lock.release);
|
|
10686
10706
|
if (!lock.rearm(action.timeoutMs ?? DEFAULT_TIMEOUT_MS)) {
|
|
10687
|
-
await publishCancellation("
|
|
10707
|
+
await publishCancellation("Execution slot changed hands before launch; cancelled (not run). Please retry.");
|
|
10688
10708
|
return;
|
|
10689
10709
|
}
|
|
10690
10710
|
ctx.log(`im-forward: panel action ${actionId} triggered by ${triggerQuick} (${triggerOpenId ?? "no-openid"})${workerCtx ? ` as worker ${workerCtx.name}` : ""}`);
|
|
@@ -10710,7 +10730,7 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10710
10730
|
ok: false,
|
|
10711
10731
|
logFile: result2.logFile
|
|
10712
10732
|
});
|
|
10713
|
-
await publishCancellation(ctx.isTerminated() ? "
|
|
10733
|
+
await publishCancellation(ctx.isTerminated() ? "Runtime exited; action cancelled. Check for partial output before retrying." : "Execution slot changed hands at launch; script terminated (partial output may exist). Please retry.");
|
|
10714
10734
|
return;
|
|
10715
10735
|
}
|
|
10716
10736
|
const triggerName = ctx.isTerminated() ? triggerQuick : await resolveUserName(triggerOpenId, {
|
|
@@ -10733,16 +10753,16 @@ ${receipt.ok ? "Compaction runs on the target host (LLM summary \u2014 may take
|
|
|
10733
10753
|
});
|
|
10734
10754
|
if (!actionCanDeliver()) return;
|
|
10735
10755
|
const icon = result2.timedOut ? "\u23F1\uFE0F" : result2.ok ? "\u2705" : "\u274C";
|
|
10736
|
-
const statusLine = result2.timedOut ?
|
|
10756
|
+
const statusLine = result2.timedOut ? `timed out (>${timeoutS}s), terminated` : result2.ok ? `took ${(result2.durationMs / 1e3).toFixed(1)}s` : `exit ${result2.exitCode ?? "?"} \xB7 took ${(result2.durationMs / 1e3).toFixed(1)}s`;
|
|
10737
10757
|
const outBody = truncateMarkdown(result2.stdout.trim() || (result2.ok ? "_(no output)_" : ""));
|
|
10738
10758
|
const logNote = result2.logDegraded ? `
|
|
10739
|
-
_(
|
|
10740
|
-
_(
|
|
10759
|
+
_(log incomplete: over limit or write failed; partial log at ${result2.logFile})_` : result2.stdoutTruncated || result2.stderrTruncated ? `
|
|
10760
|
+
_(output truncated; full log at ${result2.logFile})_` : "";
|
|
10741
10761
|
const resultSpec = {
|
|
10742
10762
|
title: `${icon} ${action.label}`,
|
|
10743
10763
|
color: result2.ok ? "green" : "red",
|
|
10744
10764
|
body: [
|
|
10745
|
-
|
|
10765
|
+
`Triggered by ${sanitizeLiteralMarkdown(triggerName)} \xB7 ${statusLine}${workerCtx ? ` \xB7 as ${sanitizeLiteralMarkdown(workerCtx.name)}` : ""}`,
|
|
10746
10766
|
``,
|
|
10747
10767
|
outBody,
|
|
10748
10768
|
result2.stderrTail.trim() && !result2.ok ? `
|
|
@@ -10752,7 +10772,7 @@ ${result2.stderrTail.trim().slice(0, 1500).replace(/`/g, "'").replace(/</g, "\u2
|
|
|
10752
10772
|
\`\`\`` : "",
|
|
10753
10773
|
logNote
|
|
10754
10774
|
].filter((line) => line !== "").join("\n"),
|
|
10755
|
-
actions: [{ id: `panel.action.${actionId}`, label: "\u{1F501}
|
|
10775
|
+
actions: [{ id: `panel.action.${actionId}`, label: "\u{1F501} Run Again", ...workerCtx ? { payload: { worker: { name: workerCtx.name, ...workerCtx.ref ? { ref: workerCtx.ref } : {} } } } : {} }, ...panelHomeAction(hideHome, threadWorkerSessionId, workerCtx?.ref)]
|
|
10756
10776
|
};
|
|
10757
10777
|
await publishTerminal(resultSpec, `panel-action-result-${event.event_id}`);
|
|
10758
10778
|
} catch (error) {
|
|
@@ -10760,7 +10780,7 @@ ${result2.stderrTail.trim().slice(0, 1500).replace(/`/g, "'").replace(/</g, "\u2
|
|
|
10760
10780
|
await publishTerminal({
|
|
10761
10781
|
title: `\u274C ${action.label}`,
|
|
10762
10782
|
color: "red",
|
|
10763
|
-
body:
|
|
10783
|
+
body: `Runner error: ${sanitizeLiteralMarkdown(error instanceof Error ? error.message : String(error))}`,
|
|
10764
10784
|
actions: panelHomeAction(hideHome, threadWorkerSessionId, workerCtx?.ref)
|
|
10765
10785
|
}, `panel-action-error-${event.event_id}`);
|
|
10766
10786
|
} finally {
|
|
@@ -11807,9 +11827,9 @@ function initializeImForward(ctx, providers = implementedProviders, runtimeFacto
|
|
|
11807
11827
|
...typeof args.id === "string" && args.id.trim() ? { id: args.id.trim() } : {},
|
|
11808
11828
|
...args.creatorName || args.creatorOpenId ? { creator: { ...typeof args.creatorOpenId === "string" ? { openId: args.creatorOpenId } : {}, ...typeof args.creatorName === "string" ? { name: args.creatorName } : {} } } : {}
|
|
11809
11829
|
});
|
|
11810
|
-
return text(`\u2705
|
|
11830
|
+
return text(`\u2705 Registered button: [${created.label}] id=\`${created.id}\` scope=${created.scope}
|
|
11811
11831
|
|
|
11812
|
-
|
|
11832
|
+
Visible on the next /panel (inlined by usage frequency, or under \u26A1 All Actions). Runs script directly with zero LLM.`);
|
|
11813
11833
|
} catch (error) {
|
|
11814
11834
|
return text(`add failed: ${error instanceof Error ? error.message : String(error)}`, true);
|
|
11815
11835
|
}
|
|
@@ -11818,7 +11838,7 @@ function initializeImForward(ctx, providers = implementedProviders, runtimeFacto
|
|
|
11818
11838
|
const id = typeof args.id === "string" ? args.id.trim() : "";
|
|
11819
11839
|
if (!id) return text("remove requires id", true);
|
|
11820
11840
|
const removed = removeAction(id);
|
|
11821
|
-
return removed ? text(`\u{1F5D1}
|
|
11841
|
+
return removed ? text(`\u{1F5D1} Removed button [${removed.label}] (${id}) from the registry (script file stays on disk; button no longer shown).`) : text(`action id "${id}" not found`, true);
|
|
11822
11842
|
}
|
|
11823
11843
|
return text(`unknown action "${act}"`, true);
|
|
11824
11844
|
}
|