@oh-my-pi/pi-coding-agent 17.3.4 → 17.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/dist/{CHANGELOG-trcc215s.md → CHANGELOG-tt9k4jpr.md} +68 -0
- package/dist/cli.js +3146 -3153
- package/dist/docs-index.generated.txt +1 -1
- package/dist/types/config/model-discovery.d.ts +2 -0
- package/dist/types/config/model-registry.d.ts +6 -1
- package/dist/types/config/settings-schema.d.ts +10 -0
- package/dist/types/debug/report-bundle.d.ts +7 -2
- package/dist/types/extensibility/extensions/loader.d.ts +2 -0
- package/dist/types/extensibility/extensions/runner.d.ts +3 -3
- package/dist/types/extensibility/extensions/types.d.ts +2 -0
- package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +4 -0
- package/dist/types/launch/presence.d.ts +11 -0
- package/dist/types/lsp/client.d.ts +22 -0
- package/dist/types/lsp/workspace-diagnostics.d.ts +2 -0
- package/dist/types/mcp/config.d.ts +3 -1
- package/dist/types/modes/components/tool-execution.d.ts +3 -1
- package/dist/types/registry/agent-lifecycle.d.ts +11 -0
- package/dist/types/registry/agent-registry.d.ts +4 -0
- package/dist/types/session/agent-session-types.d.ts +0 -2
- package/dist/types/session/agent-session.d.ts +20 -0
- package/dist/types/session/date-cwd-reminder.d.ts +22 -0
- package/dist/types/session/irc-bridge.d.ts +2 -0
- package/dist/types/session/messages.d.ts +4 -0
- package/dist/types/session/session-loader.d.ts +18 -11
- package/dist/types/session/session-maintenance.d.ts +6 -2
- package/dist/types/session/session-manager.d.ts +19 -3
- package/dist/types/session/session-tools.d.ts +0 -1
- package/dist/types/session/turn-recovery.d.ts +7 -7
- package/dist/types/tools/browser/attach.d.ts +16 -0
- package/dist/types/tools/browser/launch.d.ts +2 -2
- package/dist/types/tools/browser.d.ts +1 -1
- package/dist/types/tools/builtin-names.d.ts +1 -1
- package/dist/types/tools/hub/jobs.d.ts +6 -0
- package/dist/types/tools/hub/types.d.ts +6 -0
- package/dist/types/vibe/runtime.d.ts +3 -3
- package/package.json +13 -13
- package/src/auto-thinking/classifier.ts +37 -23
- package/src/cli/models-cli.ts +1 -1
- package/src/commit/analysis/conventional.ts +15 -9
- package/src/commit/analysis/summary.ts +15 -9
- package/src/commit/changelog/generate.ts +15 -9
- package/src/commit/map-reduce/map-phase.ts +3 -19
- package/src/commit/map-reduce/reduce-phase.ts +15 -9
- package/src/config/model-discovery.ts +3 -3
- package/src/config/model-registry.ts +29 -16
- package/src/config/settings-schema.ts +13 -0
- package/src/debug/report-bundle.ts +25 -59
- package/src/discovery/claude-plugins.ts +2 -1
- package/src/discovery/claude.ts +4 -2
- package/src/discovery/helpers.ts +5 -0
- package/src/edit/renderer.ts +48 -19
- package/src/extensibility/extensions/loader.ts +9 -5
- package/src/extensibility/extensions/runner.ts +124 -21
- package/src/extensibility/extensions/types.ts +2 -0
- package/src/extensibility/extensions/wrapper.ts +16 -10
- package/src/extensibility/legacy-pi-ai-shim.ts +4 -0
- package/src/extensibility/plugins/marketplace/manager.ts +15 -18
- package/src/irc/bus.ts +1 -1
- package/src/launch/broker.ts +8 -1
- package/src/launch/presence.ts +77 -1
- package/src/lsp/client.ts +35 -3
- package/src/lsp/clients/biome-client.ts +47 -93
- package/src/lsp/servers.ts +17 -11
- package/src/lsp/tool.ts +2 -4
- package/src/lsp/workspace-diagnostics.ts +24 -2
- package/src/mcp/config.ts +50 -6
- package/src/memories/index.ts +29 -25
- package/src/mnemopi/backend.ts +13 -11
- package/src/modes/components/ask-dialog.ts +25 -5
- package/src/modes/components/tool-execution.ts +10 -6
- package/src/modes/components/welcome.ts +4 -1
- package/src/modes/controllers/extension-ui-controller.ts +52 -32
- package/src/modes/controllers/selector-controller.ts +6 -0
- package/src/modes/controllers/tan-command-controller.ts +1 -0
- package/src/modes/interactive-mode.ts +49 -10
- package/src/modes/theme/defaults/birch.json +2 -2
- package/src/prompts/system/checkpoint-active-notice.md +5 -0
- package/src/prompts/system/date-cwd-reminder.md +3 -0
- package/src/prompts/system/project-prompt.md +0 -1
- package/src/prompts/system/rewind-report.md +1 -3
- package/src/prompts/tools/browser.md +1 -0
- package/src/prompts/tools/rewind.md +1 -13
- package/src/registry/agent-lifecycle.ts +34 -0
- package/src/registry/agent-registry.ts +27 -2
- package/src/registry/persisted-agents.ts +40 -20
- package/src/sdk.ts +32 -2
- package/src/session/agent-session-types.ts +0 -2
- package/src/session/agent-session.ts +178 -46
- package/src/session/date-cwd-reminder.ts +77 -0
- package/src/session/irc-bridge.ts +5 -0
- package/src/session/messages.ts +5 -1
- package/src/session/session-loader.ts +106 -64
- package/src/session/session-maintenance.ts +189 -115
- package/src/session/session-manager.ts +142 -35
- package/src/session/session-persistence.ts +4 -4
- package/src/session/session-storage.ts +18 -5
- package/src/session/session-tools.ts +5 -10
- package/src/session/turn-recovery.ts +102 -20
- package/src/session/unexpected-stop-classifier.ts +33 -21
- package/src/system-prompt.ts +0 -5
- package/src/task/executor.ts +4 -15
- package/src/task/persisted-revive.ts +3 -6
- package/src/tools/ask.ts +10 -3
- package/src/tools/browser/attach.ts +80 -25
- package/src/tools/browser/launch.ts +44 -15
- package/src/tools/browser/relay/daemon.ts +3 -7
- package/src/tools/browser/render.ts +1 -1
- package/src/tools/browser/shared-daemon.ts +3 -7
- package/src/tools/browser.ts +5 -5
- package/src/tools/builtin-names.ts +7 -3
- package/src/tools/checkpoint.ts +1 -7
- package/src/tools/hub/index.ts +1 -1
- package/src/tools/hub/jobs.ts +20 -3
- package/src/tools/hub/types.ts +6 -0
- package/src/tools/render-utils.ts +53 -21
- package/src/tools/think.ts +15 -3
- package/src/tts/speech-enhancer.ts +19 -14
- package/src/utils/commit-message-generator.ts +14 -12
- package/src/utils/title-generator.ts +23 -19
- package/src/vibe/runtime.ts +32 -17
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
Markdown,
|
|
5
5
|
type MarkdownTheme,
|
|
6
6
|
matchesKey,
|
|
7
|
+
padding,
|
|
7
8
|
renderInlineMarkdown,
|
|
8
9
|
replaceTabs,
|
|
9
10
|
ScrollView,
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
Text,
|
|
13
14
|
type TUI,
|
|
14
15
|
truncateToWidth,
|
|
16
|
+
visibleWidth,
|
|
15
17
|
wrapTextWithAnsi,
|
|
16
18
|
} from "@oh-my-pi/pi-tui";
|
|
17
19
|
import type {
|
|
@@ -315,8 +317,18 @@ function renderRowLabel(
|
|
|
315
317
|
const cursor = selected ? theme.fg("accent", `${theme.nav.cursor} `) : " ";
|
|
316
318
|
const label = renderInlineMarkdown(rowItem.label, mdTheme, t => theme.fg(color, t));
|
|
317
319
|
const noteMarker = state.note && state.noteRowKey === rowItem.key ? theme.fg("success", " ✎ note") : "";
|
|
318
|
-
|
|
319
|
-
|
|
320
|
+
// `width` is already the inner content width consumed by row(); when a
|
|
321
|
+
// scrollbar is needed, renderRows() calls this again with one less column.
|
|
322
|
+
// Keep the cursor, option marker, first wrapped label line, and optional
|
|
323
|
+
// note marker within that budget so the outer fit() never truncates them.
|
|
324
|
+
const noteWidth = noteMarker ? visibleWidth(noteMarker) : 0;
|
|
325
|
+
const labelWidth = Math.max(1, width - visibleWidth(cursor) - visibleWidth(marker) - noteWidth);
|
|
326
|
+
const wrappedLabel = wrapTextWithAnsi(label, labelWidth);
|
|
327
|
+
const indent = padding(visibleWidth(cursor) + visibleWidth(marker));
|
|
328
|
+
const lines = [`${cursor}${marker}${wrappedLabel[0] ?? ""}${noteMarker}`];
|
|
329
|
+
for (let i = 1; i < wrappedLabel.length; i++) {
|
|
330
|
+
lines.push(`${indent}${wrappedLabel[i] ?? ""}`);
|
|
331
|
+
}
|
|
320
332
|
if (rowItem.kind === "option") {
|
|
321
333
|
const option = question.options[rowItem.optionIndex ?? -1];
|
|
322
334
|
if (option?.description?.trim()) {
|
|
@@ -602,7 +614,9 @@ export class AskDialogComponent implements Component {
|
|
|
602
614
|
return `Enter submit · ↑/↓ scroll ·${scroll} ${cancel}`;
|
|
603
615
|
}
|
|
604
616
|
const question = this.#questions[this.#currentQuestionIndex()];
|
|
605
|
-
|
|
617
|
+
// Enter advances in multi-question dialogs and submits single-question ones.
|
|
618
|
+
const enterAction = this.#questions.length > 1 ? "next" : "submit";
|
|
619
|
+
const action = question?.multi ? `Space toggle · Enter ${enterAction}` : "Enter select · n note";
|
|
606
620
|
const tabs = this.#hasSubmitTab() ? " · Tab/←/→" : "";
|
|
607
621
|
if (this.#questionCanPage && indicator) {
|
|
608
622
|
return `${action} · ↑/↓${tabs} · ${cancel} · ${pageKeysLabel()} ${indicator}`;
|
|
@@ -680,8 +694,14 @@ export class AskDialogComponent implements Component {
|
|
|
680
694
|
const option = question.options[rowItem.optionIndex ?? -1];
|
|
681
695
|
if (!option) return;
|
|
682
696
|
if (question.multi) {
|
|
683
|
-
|
|
684
|
-
|
|
697
|
+
if (isEnter) {
|
|
698
|
+
// Enter confirms the current selection without toggling the
|
|
699
|
+
// focused option; Space toggles. Advances to the next question
|
|
700
|
+
// (submitting only for a single-question dialog), matching
|
|
701
|
+
// single-select Enter (#8252).
|
|
702
|
+
this.#advanceAfterQuestion();
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
685
705
|
if (state.selectedOptions.has(option.label)) {
|
|
686
706
|
state.selectedOptions.delete(option.label);
|
|
687
707
|
clearNoteIfRow(state, rowItem.key);
|
|
@@ -734,10 +734,11 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
|
|
|
734
734
|
* region (a later block streams below it), or — while it is still the
|
|
735
735
|
* live tail — its head rows were committed because the frame outgrew the
|
|
736
736
|
* viewport. Committed rows are immutable, so from that point every further
|
|
737
|
-
* partial snapshot is dropped.
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
737
|
+
* partial snapshot is dropped. A hidden, wholly uncommitted block keeps
|
|
738
|
+
* accepting snapshots so revealing it starts from current progress. Rows
|
|
739
|
+
* restyle static gray only when nothing is committed yet; otherwise the
|
|
740
|
+
* bytes stay exactly as painted. One-way — blocks never re-enter the live
|
|
741
|
+
* region. Returns whether the block is frozen.
|
|
741
742
|
*/
|
|
742
743
|
#maybeFreezeBackgroundTask(): boolean {
|
|
743
744
|
if (this.#backgroundTaskFrozen) return true;
|
|
@@ -745,7 +746,7 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
|
|
|
745
746
|
const asyncState = (this.#result?.details as { async?: { state?: string } } | undefined)?.async?.state;
|
|
746
747
|
if (asyncState !== "running") return false;
|
|
747
748
|
const uncommitted = this.#liveRegion.isBlockUncommitted?.(this) ?? true;
|
|
748
|
-
if (uncommitted && this.#liveRegion.isBlockInLiveRegion(this)) return false;
|
|
749
|
+
if (uncommitted && (!this.#toolActivityVisible || this.#liveRegion.isBlockInLiveRegion(this))) return false;
|
|
749
750
|
this.#backgroundTaskFrozen = true;
|
|
750
751
|
this.#updateSpinnerAnimation();
|
|
751
752
|
if (uncommitted) {
|
|
@@ -825,10 +826,13 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
|
|
|
825
826
|
* Reports `false` while it can still visually change so the
|
|
826
827
|
* {@link TranscriptContainer} keeps it inside the repaintable live region:
|
|
827
828
|
* a foreground tool awaiting its result, or one streaming partial output.
|
|
829
|
+
* Hidden blocks render no rows, so they cannot gate later streaming content.
|
|
830
|
+
* Visibility toggles reset and replay the transcript before revealing them.
|
|
828
831
|
* A final (non-partial) result, a background-async tool the agent has moved
|
|
829
|
-
* past, or an explicit {@link seal} flips it to `true`.
|
|
832
|
+
* past, or an explicit {@link seal} also flips it to `true`.
|
|
830
833
|
*/
|
|
831
834
|
isTranscriptBlockFinalized(): boolean {
|
|
835
|
+
if (!this.#toolActivityVisible) return true;
|
|
832
836
|
if (this.#sealed) return true;
|
|
833
837
|
if (this.#result === undefined) return false;
|
|
834
838
|
// A displaceable snapshot stays live: its rows are kept out of native
|
|
@@ -248,7 +248,10 @@ export class WelcomeComponent implements Component {
|
|
|
248
248
|
visibleWidth(this.modelName),
|
|
249
249
|
visibleWidth(this.providerName),
|
|
250
250
|
);
|
|
251
|
-
const desiredLeftCol = Math.
|
|
251
|
+
const desiredLeftCol = Math.max(
|
|
252
|
+
Math.min(preferredLeftCol, Math.max(minLeftCol, Math.floor(dualContentWidth * 0.35))),
|
|
253
|
+
leftMinContentWidth,
|
|
254
|
+
);
|
|
252
255
|
const dualLeftCol =
|
|
253
256
|
dualContentWidth >= minRightCol + 1
|
|
254
257
|
? Math.min(desiredLeftCol, dualContentWidth - minRightCol)
|
|
@@ -1053,53 +1053,73 @@ export class ExtensionUiController {
|
|
|
1053
1053
|
const savedText = this.ctx.editor.getText();
|
|
1054
1054
|
const keybindings = KeybindingsManager.inMemory();
|
|
1055
1055
|
|
|
1056
|
-
const { promise, resolve } = Promise.withResolvers<T>();
|
|
1056
|
+
const { promise, resolve, reject } = Promise.withResolvers<T>();
|
|
1057
1057
|
let component: (Component & { dispose?(): void }) | undefined;
|
|
1058
1058
|
let overlayHandle: OverlayHandle | undefined;
|
|
1059
1059
|
let closed = false;
|
|
1060
|
+
let editorReplaced = false;
|
|
1060
1061
|
|
|
1061
|
-
const
|
|
1062
|
-
if (closed) return;
|
|
1063
|
-
closed = true;
|
|
1062
|
+
const cleanup = () => {
|
|
1064
1063
|
component?.dispose?.();
|
|
1065
1064
|
overlayHandle?.hide();
|
|
1066
1065
|
overlayHandle = undefined;
|
|
1067
|
-
if (
|
|
1066
|
+
if (editorReplaced) {
|
|
1068
1067
|
this.ctx.editorContainer.clear();
|
|
1069
1068
|
this.ctx.editorContainer.addChild(this.ctx.editor);
|
|
1070
1069
|
this.ctx.editor.setText(savedText);
|
|
1071
1070
|
}
|
|
1072
1071
|
this.ctx.ui.setFocus(this.ctx.editor);
|
|
1073
1072
|
this.ctx.ui.requestRender();
|
|
1074
|
-
resolve(result);
|
|
1075
1073
|
};
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
const overlayOptions =
|
|
1085
|
-
typeof options.overlayOptions === "function" ? options.overlayOptions() : options.overlayOptions;
|
|
1086
|
-
overlayHandle = this.ctx.ui.showOverlay(
|
|
1087
|
-
component,
|
|
1088
|
-
overlayOptions ?? {
|
|
1089
|
-
anchor: "bottom-center",
|
|
1090
|
-
width: "100%",
|
|
1091
|
-
maxHeight: "100%",
|
|
1092
|
-
margin: 0,
|
|
1093
|
-
},
|
|
1094
|
-
);
|
|
1095
|
-
options.onHandle?.(overlayHandle);
|
|
1096
|
-
return;
|
|
1074
|
+
const finish = (settle: () => void) => {
|
|
1075
|
+
if (closed) return;
|
|
1076
|
+
closed = true;
|
|
1077
|
+
options?.signal?.removeEventListener("abort", onAbort);
|
|
1078
|
+
try {
|
|
1079
|
+
cleanup();
|
|
1080
|
+
} finally {
|
|
1081
|
+
settle();
|
|
1097
1082
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1083
|
+
};
|
|
1084
|
+
const fail = (error: unknown) => finish(() => reject(error));
|
|
1085
|
+
const onAbort = () => fail(options?.signal?.reason ?? new DOMException("Dialog aborted", "AbortError"));
|
|
1086
|
+
const close = (result: T) => finish(() => resolve(result));
|
|
1087
|
+
|
|
1088
|
+
if (options?.signal?.aborted) {
|
|
1089
|
+
fail(options.signal.reason ?? new DOMException("Dialog aborted", "AbortError"));
|
|
1090
|
+
return promise;
|
|
1091
|
+
}
|
|
1092
|
+
options?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1093
|
+
|
|
1094
|
+
Promise.try(() => factory(this.ctx.ui, theme, keybindings, close))
|
|
1095
|
+
.then(c => {
|
|
1096
|
+
if (closed) {
|
|
1097
|
+
c.dispose?.();
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
component = c;
|
|
1101
|
+
if (options?.overlay) {
|
|
1102
|
+
const overlayOptions =
|
|
1103
|
+
typeof options.overlayOptions === "function" ? options.overlayOptions() : options.overlayOptions;
|
|
1104
|
+
overlayHandle = this.ctx.ui.showOverlay(
|
|
1105
|
+
component,
|
|
1106
|
+
overlayOptions ?? {
|
|
1107
|
+
anchor: "bottom-center",
|
|
1108
|
+
width: "100%",
|
|
1109
|
+
maxHeight: "100%",
|
|
1110
|
+
margin: 0,
|
|
1111
|
+
},
|
|
1112
|
+
);
|
|
1113
|
+
options.onHandle?.(overlayHandle);
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
editorReplaced = true;
|
|
1117
|
+
this.ctx.editorContainer.clear();
|
|
1118
|
+
this.ctx.editorContainer.addChild(component);
|
|
1119
|
+
this.ctx.ui.setFocus(component);
|
|
1120
|
+
this.ctx.ui.requestRender();
|
|
1121
|
+
})
|
|
1122
|
+
.catch(fail);
|
|
1103
1123
|
return promise;
|
|
1104
1124
|
}
|
|
1105
1125
|
|
|
@@ -562,6 +562,12 @@ export class SelectorController {
|
|
|
562
562
|
this.ctx.rebuildChatFromMessages();
|
|
563
563
|
this.ctx.ui.resetDisplay();
|
|
564
564
|
break;
|
|
565
|
+
case "display.showTokenUsage":
|
|
566
|
+
// Rebuild reruns usage-row detection under the new setting; resetDisplay
|
|
567
|
+
// retires rows already committed to native scrollback.
|
|
568
|
+
this.ctx.rebuildChatFromMessages();
|
|
569
|
+
this.ctx.ui.resetDisplay();
|
|
570
|
+
break;
|
|
565
571
|
case "tui.tight":
|
|
566
572
|
setTuiTight(value as boolean);
|
|
567
573
|
this.ctx.ui.invalidate();
|
|
@@ -111,6 +111,7 @@ export class TanCommandController {
|
|
|
111
111
|
let jobId = "";
|
|
112
112
|
try {
|
|
113
113
|
const cloneManager = await SessionManager.forkFrom(parentFile, cwd, sessionDir, undefined, {
|
|
114
|
+
copyArtifacts: false,
|
|
114
115
|
suppressBreadcrumb: true,
|
|
115
116
|
sessionFile: cloneFile,
|
|
116
117
|
});
|
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
logger,
|
|
51
51
|
postmortem,
|
|
52
52
|
prompt,
|
|
53
|
+
sanitizeText,
|
|
53
54
|
setProjectDir,
|
|
54
55
|
} from "@oh-my-pi/pi-utils";
|
|
55
56
|
import chalk from "@oh-my-pi/pi-utils/chalk";
|
|
@@ -390,16 +391,20 @@ export interface InteractiveModeOptions {
|
|
|
390
391
|
/**
|
|
391
392
|
* Anchored live-region container for the HUD/status rows between the transcript
|
|
392
393
|
* and the editor (working loader, todo + subagent HUDs, transient notification
|
|
393
|
-
* panels). While it has content every row is live: it reports a seam at 0
|
|
394
|
-
* engine never commits these anchored,
|
|
395
|
-
* scrollback — otherwise stale duplicates pile
|
|
396
|
-
* terminals once the loader sits below a tall HUD. The transcript's own seam,
|
|
394
|
+
* panels). While it has content every row is live: it reports a seam at 0 and
|
|
395
|
+
* pins that live region so the engine never commits these anchored,
|
|
396
|
+
* rebuilt-in-place rows to native scrollback — otherwise stale duplicates pile
|
|
397
|
+
* up above the live copy on short terminals once the loader sits below a tall HUD. The transcript's own seam,
|
|
397
398
|
* when present, sits higher and wins (topmost-seam merge in TUI.render).
|
|
398
399
|
*/
|
|
399
400
|
class AnchoredLiveContainer extends Container implements NativeScrollbackLiveRegion {
|
|
400
401
|
getNativeScrollbackLiveRegionStart(): number | undefined {
|
|
401
402
|
return this.children.length > 0 ? 0 : undefined;
|
|
402
403
|
}
|
|
404
|
+
|
|
405
|
+
isNativeScrollbackLiveRegionPinned(): boolean {
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
403
408
|
}
|
|
404
409
|
|
|
405
410
|
/**
|
|
@@ -814,7 +819,7 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
814
819
|
this.editor.onAutocompleteUpdate = () => {
|
|
815
820
|
this.ui.requestRender();
|
|
816
821
|
};
|
|
817
|
-
this.editor.setShimmerRepaintHandler(() => this.ui.
|
|
822
|
+
this.editor.setShimmerRepaintHandler(() => this.ui.requestDirectWrite(this.editor));
|
|
818
823
|
this.#syncEditorMaxHeight();
|
|
819
824
|
this.#resizeHandler = () => {
|
|
820
825
|
this.#syncEditorMaxHeight();
|
|
@@ -1108,6 +1113,15 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1108
1113
|
// before initHooksAndCustomTools/#reconcileModeFromSession/#enterPlanMode —
|
|
1109
1114
|
// all of which can reach setSessionName during init.
|
|
1110
1115
|
this.#eventBusUnsubscribers.push(
|
|
1116
|
+
this.sessionManager.onPersistenceError(error => {
|
|
1117
|
+
const detail = truncateToWidth(
|
|
1118
|
+
replaceTabs(sanitizeText(error.message)).replace(/[\r\n]+/g, " "),
|
|
1119
|
+
TRUNCATE_LENGTHS.LINE,
|
|
1120
|
+
);
|
|
1121
|
+
this.showWarning(
|
|
1122
|
+
`Session persistence failed: ${detail}. Unsaved entries remain in memory; persistence will retry on the next entry.`,
|
|
1123
|
+
);
|
|
1124
|
+
}),
|
|
1111
1125
|
this.sessionManager.onSessionNameChanged(() => {
|
|
1112
1126
|
setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
|
|
1113
1127
|
this.#handleSessionAccentInputsChanged();
|
|
@@ -1177,6 +1191,9 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1177
1191
|
|
|
1178
1192
|
this.#eventBusUnsubscribers.push(
|
|
1179
1193
|
this.session.subscribe(event => {
|
|
1194
|
+
if (event.type === "model_changed") {
|
|
1195
|
+
this.#updateWelcomeModel();
|
|
1196
|
+
}
|
|
1180
1197
|
void this.#handleGoalSessionEvent(event);
|
|
1181
1198
|
}),
|
|
1182
1199
|
onStatusLineSessionAccentChanged(() => {
|
|
@@ -1184,6 +1201,11 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
1184
1201
|
this.#handleSessionAccentInputsChanged();
|
|
1185
1202
|
}),
|
|
1186
1203
|
);
|
|
1204
|
+
// Resync the welcome banner to the live model: init-time reconciliations
|
|
1205
|
+
// (#reconcileModeFromSession, #enterPlanMode for plan.defaultOnStartup)
|
|
1206
|
+
// can change the model before this subscription exists, so the
|
|
1207
|
+
// model_changed events they emit are never observed by the handler above.
|
|
1208
|
+
this.#updateWelcomeModel();
|
|
1187
1209
|
this.#eventBusUnsubscribers.push(
|
|
1188
1210
|
onModelRolesChanged(() => {
|
|
1189
1211
|
void this.#reapplyPlanModeModelOnRoleChange();
|
|
@@ -3509,10 +3531,18 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
3509
3531
|
if (!this.vibeModeEnabled) {
|
|
3510
3532
|
return;
|
|
3511
3533
|
}
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3534
|
+
// Tear down with the queued-message drain suppressed: aborting the active
|
|
3535
|
+
// turn would otherwise let a queued user steer/follow-up restart on the
|
|
3536
|
+
// still-live Vibe tools before this teardown removes them (issue #8326).
|
|
3537
|
+
let killed = 0;
|
|
3538
|
+
await this.session.runModeExitTeardown(async () => {
|
|
3539
|
+
if (this.session.isStreaming) {
|
|
3540
|
+
await this.session.abort();
|
|
3541
|
+
}
|
|
3542
|
+
killed = await VibeSessionRegistry.global().killAll(this.#vibeParentSession(), this.#vibeModeOwnerScope);
|
|
3543
|
+
await this.session.deactivateVibeTools(this.#vibeModePreviousTools ?? []);
|
|
3544
|
+
this.session.setVibeModeState(undefined);
|
|
3545
|
+
});
|
|
3516
3546
|
this.vibeModeEnabled = false;
|
|
3517
3547
|
this.#vibeModePreviousTools = undefined;
|
|
3518
3548
|
this.#vibeModeOwnerScope = undefined;
|
|
@@ -4252,7 +4282,7 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
4252
4282
|
nextEditor.onAutocompleteUpdate = () => {
|
|
4253
4283
|
this.ui.requestRender();
|
|
4254
4284
|
};
|
|
4255
|
-
nextEditor.setShimmerRepaintHandler(() => this.ui.
|
|
4285
|
+
nextEditor.setShimmerRepaintHandler(() => this.ui.requestDirectWrite(nextEditor));
|
|
4256
4286
|
nextEditor.setTopBorderProvider(availableWidth => this.statusLine.getTopBorder(availableWidth));
|
|
4257
4287
|
nextEditor.setMaxHeight(this.#computeEditorMaxHeight());
|
|
4258
4288
|
if (this.historyStorage) {
|
|
@@ -4430,6 +4460,15 @@ export class InteractiveMode implements InteractiveModeContext {
|
|
|
4430
4460
|
);
|
|
4431
4461
|
}
|
|
4432
4462
|
|
|
4463
|
+
#updateWelcomeModel(): void {
|
|
4464
|
+
if (!this.#welcomeComponent) {
|
|
4465
|
+
return;
|
|
4466
|
+
}
|
|
4467
|
+
|
|
4468
|
+
this.#welcomeComponent.setModel(this.session.model?.name ?? "Unknown", this.session.model?.provider ?? "Unknown");
|
|
4469
|
+
this.ui.requestRender();
|
|
4470
|
+
}
|
|
4471
|
+
|
|
4433
4472
|
#updateWelcomeLspServers(): void {
|
|
4434
4473
|
if (!this.#welcomeComponent) {
|
|
4435
4474
|
return;
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"thinkingText": "warmGray",
|
|
34
34
|
"selectedBg": "selectedBg",
|
|
35
35
|
"userMessageBg": "userMsgBg",
|
|
36
|
-
"userMessageText": "",
|
|
36
|
+
"userMessageText": "forestFloor",
|
|
37
37
|
"customMessageBg": "customMsgBg",
|
|
38
|
-
"customMessageText": "",
|
|
38
|
+
"customMessageText": "forestFloor",
|
|
39
39
|
"customMessageLabel": "#5a7a52",
|
|
40
40
|
"toolPendingBg": "toolPendingBg",
|
|
41
41
|
"toolSuccessBg": "toolSuccessBg",
|
|
@@ -47,7 +47,6 @@ Additional workspace directories. This CURRENT workspace state supersedes worksp
|
|
|
47
47
|
{{/each}}
|
|
48
48
|
</workspace-roots>
|
|
49
49
|
{{/if}}
|
|
50
|
-
Today: {{date}}; current working directory: '{{cwd}}'.
|
|
51
50
|
|
|
52
51
|
<critical>
|
|
53
52
|
- Each response MUST advance the task; completion only stopping condition.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
Checkpoint
|
|
2
|
-
Context: branch summary and retained report below.
|
|
3
|
-
NEVER call `rewind` again for this checkpoint; continue from retained report.
|
|
1
|
+
Checkpoint called and rewound. Report retained below. Need explore again → new `checkpoint`.
|
|
4
2
|
|
|
5
3
|
Report:
|
|
6
4
|
{{report}}
|
|
@@ -21,6 +21,7 @@ Drives real Chromium tab; full puppeteer access via JS.
|
|
|
21
21
|
|
|
22
22
|
- `app.path` → NEVER tamper with a real desktop app (no stealth patches).
|
|
23
23
|
- `app.relay: true` → drive the user's own Chrome tabs via the omp browser relay (auto-started; needs the OMP Browser Relay extension installed). `app.target` picks a tab by URL/title substring; without it the visible tab is adopted without stealing focus.
|
|
24
|
+
- `close` releases the named tool session. It closes tool-owned headless pages and owned cmux surfaces, but NEVER closes pages in CDP-connected or relay browsers. Spawned-browser pages remain open unless `kill: true` terminates their process.
|
|
24
25
|
- Selectors: CSS + puppeteer `aria/…`, `text/…`, `xpath/…`, `pierce/…`. Playwright-only pseudos (`:has-text()`, `:visible`) are REJECTED.
|
|
25
26
|
</instruction>
|
|
26
27
|
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
End active checkpoint; rewind context to it, replacing intermediate exploration with your report.
|
|
2
|
-
|
|
3
|
-
Call immediately after investigative work started by `checkpoint`.
|
|
4
|
-
|
|
5
|
-
Requirements:
|
|
6
|
-
- `report` MUST be concise, factual, actionable; include key findings, decisions, unresolved risks.
|
|
7
|
-
- AVOID raw scratch logs unless essential.
|
|
8
|
-
- MUST call before yielding if checkpoint active.
|
|
9
|
-
|
|
10
|
-
Behavior:
|
|
11
|
-
- No active checkpoint → error. Checkpoint already rewound → continue from retained report; NEVER retry.
|
|
12
|
-
- Success → session rewinds, retains your report as context, closes checkpoint.
|
|
13
|
-
- Successful rewind final for that checkpoint; repeat calls error.
|
|
1
|
+
End the active checkpoint; rewind context to it, replacing intermediate exploration with your report.
|
|
@@ -174,6 +174,40 @@ export class AgentLifecycleManager {
|
|
|
174
174
|
);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Reclaim a provably-dead parked corpse so a fresh spawn can reuse its id.
|
|
179
|
+
* Refuses live, adopted, in-flight, or cold-revivable refs. For a parked ref
|
|
180
|
+
* restored from disk, the persisted factory is consulted before removal
|
|
181
|
+
* because cold revivers are created lazily by {@link ensureLive}.
|
|
182
|
+
*
|
|
183
|
+
* Only refs in the registry this manager owns are touched; the transcript
|
|
184
|
+
* stays readable at `history://<id>`. Returns true when the corpse was
|
|
185
|
+
* unregistered.
|
|
186
|
+
*/
|
|
187
|
+
async reclaimDeadCorpse(id: string, expected: AgentRef): Promise<boolean> {
|
|
188
|
+
const ref = this.#registry.get(id);
|
|
189
|
+
if (ref !== expected || ref.status !== "parked" || ref.session) return false;
|
|
190
|
+
if (this.#adopted.has(id) || this.#parks.has(id) || this.#revivals.has(id)) return false;
|
|
191
|
+
|
|
192
|
+
const persistedFactory = ref.sessionFile ? this.#persistedReviverFactory : undefined;
|
|
193
|
+
if (persistedFactory) {
|
|
194
|
+
try {
|
|
195
|
+
if (await persistedFactory(ref)) return false;
|
|
196
|
+
} catch (error) {
|
|
197
|
+
logger.warn("AgentLifecycleManager.reclaimDeadCorpse: persisted reviver probe failed", {
|
|
198
|
+
id,
|
|
199
|
+
error: error instanceof Error ? error.message : String(error),
|
|
200
|
+
});
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
// The factory awaited I/O; another lifecycle operation may now own or
|
|
204
|
+
// have replaced this ref. Revalidate every reclaim invariant.
|
|
205
|
+
if (this.#registry.get(id) !== ref || ref.status !== "parked" || ref.session) return false;
|
|
206
|
+
if (this.#adopted.has(id) || this.#parks.has(id) || this.#revivals.has(id)) return false;
|
|
207
|
+
}
|
|
208
|
+
return this.#registry.unregister(id, ref);
|
|
209
|
+
}
|
|
210
|
+
|
|
177
211
|
/**
|
|
178
212
|
* True when this manager owns `registry` — i.e. its adopt/park/revive state
|
|
179
213
|
* describes that registry's refs. Lets a caller holding a specific registry
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* revival) and are only removed on explicit release/teardown.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { logger } from "@oh-my-pi/pi-utils";
|
|
12
13
|
import type { AgentSession } from "../session/agent-session";
|
|
13
14
|
import { oneLineLabel } from "../task/types";
|
|
14
15
|
|
|
@@ -135,6 +136,11 @@ export class AgentRegistry {
|
|
|
135
136
|
return expected === undefined || ref === expected || ref.session === expected;
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
#rejectStatusUpdate(id: string, status: AgentStatus, reason: string): false {
|
|
140
|
+
logger.debug("Agent registry status update rejected", { id, status, reason });
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
138
144
|
register(input: RegisterInput): AgentRef {
|
|
139
145
|
const now = Date.now();
|
|
140
146
|
const ref: AgentRef = {
|
|
@@ -181,10 +187,15 @@ export class AgentRegistry {
|
|
|
181
187
|
|
|
182
188
|
setStatus(id: string, status: AgentStatus, expected?: AgentRefExpectation): boolean {
|
|
183
189
|
const ref = this.#refs.get(id);
|
|
184
|
-
if (!ref
|
|
190
|
+
if (!ref) return this.#rejectStatusUpdate(id, status, "missing-ref");
|
|
191
|
+
if (!this.#matchesExpected(ref, expected)) {
|
|
192
|
+
return this.#rejectStatusUpdate(id, status, "session-ownership-changed");
|
|
193
|
+
}
|
|
185
194
|
// `aborted` is terminal: delayed progress/revival work from the killed
|
|
186
195
|
// generation must never transition the tombstone back to a live status.
|
|
187
|
-
if (ref.status === "aborted")
|
|
196
|
+
if (ref.status === "aborted") {
|
|
197
|
+
return status === "aborted" || this.#rejectStatusUpdate(id, status, "aborted-is-terminal");
|
|
198
|
+
}
|
|
188
199
|
if (ref.status === status) return true;
|
|
189
200
|
ref.status = status;
|
|
190
201
|
// Activity describes current work; it is meaningless once the agent
|
|
@@ -270,6 +281,20 @@ export class AgentRegistry {
|
|
|
270
281
|
);
|
|
271
282
|
}
|
|
272
283
|
|
|
284
|
+
/** Whether a ref's claimed running state is corroborated by its attached live session. */
|
|
285
|
+
isRunning(ref: AgentRef): boolean {
|
|
286
|
+
if (ref.status !== "running") return false;
|
|
287
|
+
return ref.session?.isStreaming === true;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Mirror a session's authoritative run-state notifications into its owned registry ref. */
|
|
291
|
+
syncSessionStatus(id: string, session: AgentSession): () => void {
|
|
292
|
+
const unsubscribe = session.subscribeRunState(status => {
|
|
293
|
+
this.setStatus(id, status, session);
|
|
294
|
+
});
|
|
295
|
+
return unsubscribe;
|
|
296
|
+
}
|
|
297
|
+
|
|
273
298
|
onChange(listener: RegistryListener): () => void {
|
|
274
299
|
this.#listeners.add(listener);
|
|
275
300
|
return () => this.#listeners.delete(listener);
|
|
@@ -25,6 +25,8 @@ interface PersistedAgentMetadata {
|
|
|
25
25
|
createdAt?: number;
|
|
26
26
|
lastActivity?: number;
|
|
27
27
|
history?: AgentHistorySummary;
|
|
28
|
+
/** True when the file is only a SessionManager header (no session_init, no messages). */
|
|
29
|
+
incomplete?: boolean;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
interface PersistedTranscript {
|
|
@@ -244,6 +246,8 @@ async function readPersistedAgentMetadata(sessionFile: string): Promise<Persiste
|
|
|
244
246
|
let createdAt: number | undefined;
|
|
245
247
|
let activity: string | undefined;
|
|
246
248
|
let history: AgentHistorySummary = {};
|
|
249
|
+
let hasSessionInit = false;
|
|
250
|
+
let hasConversation = false;
|
|
247
251
|
try {
|
|
248
252
|
await visitEntriesFromFileStream(
|
|
249
253
|
sessionFile,
|
|
@@ -264,7 +268,12 @@ async function readPersistedAgentMetadata(sessionFile: string): Promise<Persiste
|
|
|
264
268
|
}
|
|
265
269
|
return;
|
|
266
270
|
}
|
|
271
|
+
if (record.type === "message" || record.type === "custom_message") {
|
|
272
|
+
hasConversation = true;
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
267
275
|
if (record.type !== "session_init") return;
|
|
276
|
+
hasSessionInit = true;
|
|
268
277
|
createdAt ??= timestampOf(record.timestamp);
|
|
269
278
|
if (typeof record.task === "string") activity = summarizePersistedTask(record.task);
|
|
270
279
|
const inferred = typeof record.systemPrompt === "string" ? inferBundledAgent(record.systemPrompt) : {};
|
|
@@ -290,6 +299,7 @@ async function readPersistedAgentMetadata(sessionFile: string): Promise<Persiste
|
|
|
290
299
|
activity,
|
|
291
300
|
createdAt: createdAt ?? file?.birthtimeMs,
|
|
292
301
|
lastActivity: file?.mtimeMs,
|
|
302
|
+
incomplete: !hasSessionInit && !hasConversation,
|
|
293
303
|
history: {
|
|
294
304
|
...history,
|
|
295
305
|
...(hasOutput ? { outputPath } : {}),
|
|
@@ -425,26 +435,36 @@ async function registerPersistedSubagentsFromDir(
|
|
|
425
435
|
if (!registry.get(id)) {
|
|
426
436
|
const metadata = await readPersistedAgentMetadata(sessionFile);
|
|
427
437
|
if (!shouldContinue()) return;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
438
|
+
// Metadata reads yield. A spawn may claim the id while this scan is
|
|
439
|
+
// inspecting the file; never replace that live generation with a
|
|
440
|
+
// transcript-derived parked ref.
|
|
441
|
+
const unclaimed = !registry.get(id);
|
|
442
|
+
// SessionManager.open writes title+session before createAgentSession
|
|
443
|
+
// claims the id. Parking that stub makes the spawn's expectedAgentRef:null
|
|
444
|
+
// CAS fail with "already owned by another session generation".
|
|
445
|
+
if (unclaimed && metadata.incomplete && !tombstoned) continue;
|
|
446
|
+
if (unclaimed) {
|
|
447
|
+
registry.register({
|
|
448
|
+
id,
|
|
449
|
+
displayName: id,
|
|
450
|
+
kind: "sub",
|
|
451
|
+
parentId: parentId ?? MAIN_AGENT_ID,
|
|
452
|
+
session: null,
|
|
453
|
+
sessionFile,
|
|
454
|
+
activity: metadata.activity,
|
|
455
|
+
createdAt: metadata.createdAt,
|
|
456
|
+
lastActivity: metadata.lastActivity,
|
|
457
|
+
history: metadata.history,
|
|
458
|
+
status: tombstoned ? "aborted" : "parked",
|
|
459
|
+
});
|
|
460
|
+
const ref = registry.get(id);
|
|
461
|
+
transcripts.push({
|
|
462
|
+
id,
|
|
463
|
+
sessionFile,
|
|
464
|
+
createdAt: ref?.createdAt,
|
|
465
|
+
lastActivity: ref?.lastActivity,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
448
468
|
}
|
|
449
469
|
await registerPersistedSubagentsFromDir(
|
|
450
470
|
registry,
|