@mrclrchtr/supi-review 7.3.1 → 8.0.0
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/README.md +4 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/README.md +11 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/package.json +7 -3
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/api.ts +37 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/lifecycle-trace.ts +5 -2
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/run.ts +237 -35
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry-types.ts +95 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry.ts +372 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/transcript-format.ts +184 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/transcript-store.ts +284 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/types.ts +30 -4
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-command.ts +206 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay-data.ts +100 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay-render.ts +167 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay.ts +398 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-list.ts +95 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-switcher.ts +29 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-input.ts +69 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-render.ts +246 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer.ts +400 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewport.ts +112 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-steering-input.ts +50 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-context.ts +56 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-pane.ts +386 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-payload.ts +66 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript.ts +380 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/README.md +6 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/README.md +29 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/api.ts +25 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +5 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +39 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +82 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +28 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +606 -30
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +69 -8
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +196 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +15 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +9 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +31 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +72 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +9 -43
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +102 -50
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +49 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +78 -18
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +46 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +30 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/capability/capability-warnings.ts +64 -25
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/health/server-status.ts +23 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/health/signals.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/ast-scan.ts +42 -8
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/pattern.ts +4 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/config.ts +64 -34
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/extension.ts +29 -10
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/headless.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/find-types.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/find-workflow.ts +5 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/health-types.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/health-workflow.ts +10 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/session.ts +34 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/lifecycle.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/recovery.ts +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/settings.ts +191 -108
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/workspace-provider-host.ts +50 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/markdown.ts +12 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/render.ts +20 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/result.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_health/markdown.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_health/result.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/result/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/status-command.ts +54 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/status-overlay.ts +5 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/package.json +4 -4
- package/src/review.ts +5 -2
- package/src/tool/review_run/child-session.ts +29 -7
- package/src/tool/review_run/execute.ts +6 -1
- package/src/tool/review_run/execution.ts +6 -0
- package/src/tool/review_run/register.ts +3 -1
- package/src/tool/review_run/runner.ts +40 -0
- package/src/tool/review_run/spec.ts +2 -0
- package/src/tool/review_run/workflow.ts +7 -1
- package/src/tui/review-command.ts +74 -3
- package/src/types.ts +5 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +0 -22
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
Text,
|
|
4
|
+
type TuiMouseEvent,
|
|
5
|
+
type TuiMouseEventResult,
|
|
6
|
+
truncateToWidth,
|
|
7
|
+
} from "@earendil-works/pi-tui";
|
|
8
|
+
import type {
|
|
9
|
+
AgentRunTranscriptDocument,
|
|
10
|
+
AgentRunTranscriptSource,
|
|
11
|
+
} from "../session/transcript-store.ts";
|
|
12
|
+
import type { AgentsOverlayRun } from "./agents-overlay-data.ts";
|
|
13
|
+
import { type AgentRunBlock, AgentRunViewport } from "./agents-run-viewport.ts";
|
|
14
|
+
import {
|
|
15
|
+
type AgentTranscriptInteractiveTarget,
|
|
16
|
+
type AgentTranscriptRenderResult,
|
|
17
|
+
layoutAgentRunTranscript,
|
|
18
|
+
renderAgentRunTranscript,
|
|
19
|
+
} from "./agents-transcript.ts";
|
|
20
|
+
|
|
21
|
+
type TranscriptView = "conversation" | "details";
|
|
22
|
+
|
|
23
|
+
/** The transcript viewport and loader for one selected Agent Run. */
|
|
24
|
+
export class AgentsTranscriptPane {
|
|
25
|
+
#conversationViewport = new AgentRunViewport();
|
|
26
|
+
#detailsViewport = new AgentRunViewport();
|
|
27
|
+
#detailsStarted = false;
|
|
28
|
+
#source: AgentRunTranscriptSource | undefined;
|
|
29
|
+
#document: AgentRunTranscriptDocument | undefined;
|
|
30
|
+
#revision = -1;
|
|
31
|
+
#status: string | undefined;
|
|
32
|
+
#loading = false;
|
|
33
|
+
#failed = false;
|
|
34
|
+
#loadToken = 0;
|
|
35
|
+
#rendered: AgentTranscriptRenderResult | undefined;
|
|
36
|
+
#renderedDocument: AgentRunTranscriptDocument | undefined;
|
|
37
|
+
#renderedView: TranscriptView | undefined;
|
|
38
|
+
#targets: readonly AgentTranscriptInteractiveTarget[] = [];
|
|
39
|
+
#bounds = { top: 0, height: 0, left: 0, width: 0 };
|
|
40
|
+
#toolDetailsExpanded = false;
|
|
41
|
+
#thinkingHidden = false;
|
|
42
|
+
#view: "conversation" | "details" = "conversation";
|
|
43
|
+
#selectedKey: string | undefined;
|
|
44
|
+
|
|
45
|
+
get #viewport(): AgentRunViewport {
|
|
46
|
+
return this.#view === "details" ? this.#detailsViewport : this.#conversationViewport;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
constructor(
|
|
50
|
+
private readonly theme: Theme,
|
|
51
|
+
private readonly onChange: () => void,
|
|
52
|
+
) {}
|
|
53
|
+
|
|
54
|
+
get status(): string {
|
|
55
|
+
return this.#viewport.status;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get scrollOffset(): number {
|
|
59
|
+
return this.#viewport.scrollOffset;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get isLoading(): boolean {
|
|
63
|
+
return this.#loading;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get isIncomplete(): boolean {
|
|
67
|
+
return this.#source?.getStatus().status === "incomplete";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
select(run: AgentsOverlayRun | undefined): void {
|
|
71
|
+
if (run?.key !== this.#selectedKey) {
|
|
72
|
+
this.#selectedKey = run?.key;
|
|
73
|
+
this.#conversationViewport.reset();
|
|
74
|
+
this.#detailsViewport.reset();
|
|
75
|
+
this.#detailsStarted = false;
|
|
76
|
+
if (this.#view === "details") {
|
|
77
|
+
this.#detailsViewport.navigate("start");
|
|
78
|
+
this.#detailsStarted = true;
|
|
79
|
+
}
|
|
80
|
+
this.#clearRendered();
|
|
81
|
+
this.#targets = [];
|
|
82
|
+
}
|
|
83
|
+
this.#request(run);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
update(run: AgentsOverlayRun | undefined): void {
|
|
87
|
+
this.#request(run);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setBounds(bounds: { top: number; height: number; left: number; width: number }): void {
|
|
91
|
+
this.#bounds = bounds;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
render(run: AgentsOverlayRun | undefined, width: number, height: number): string[] {
|
|
95
|
+
if (!run) {
|
|
96
|
+
this.#targets = [];
|
|
97
|
+
return height > 0 ? [this.#line("Select an Agent Run.", width)] : [];
|
|
98
|
+
}
|
|
99
|
+
if (this.#document && run.transcriptSource === this.#source) {
|
|
100
|
+
return this.#renderDocument(run, this.#document, width, height);
|
|
101
|
+
}
|
|
102
|
+
this.#targets = [];
|
|
103
|
+
if (this.#loading) {
|
|
104
|
+
return height > 0 ? [this.#line("Loading the full Agent Run transcript…", width)] : [];
|
|
105
|
+
}
|
|
106
|
+
return this.#renderFallback(run, width, height);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#renderDocument(
|
|
110
|
+
run: AgentsOverlayRun,
|
|
111
|
+
document: AgentRunTranscriptDocument,
|
|
112
|
+
width: number,
|
|
113
|
+
height: number,
|
|
114
|
+
): string[] {
|
|
115
|
+
if (
|
|
116
|
+
!this.#rendered ||
|
|
117
|
+
this.#renderedDocument !== document ||
|
|
118
|
+
this.#renderedView !== this.#view
|
|
119
|
+
) {
|
|
120
|
+
this.#rendered = renderAgentRunTranscript({
|
|
121
|
+
document,
|
|
122
|
+
toolRenderers: this.#source?.toolRenderers ?? [],
|
|
123
|
+
theme: this.theme,
|
|
124
|
+
tui: { requestRender: () => this.onChange() },
|
|
125
|
+
expanded: this.#toolDetailsExpanded,
|
|
126
|
+
thinkingHidden: this.#thinkingHidden,
|
|
127
|
+
view: this.#view,
|
|
128
|
+
previous: this.#rendered,
|
|
129
|
+
});
|
|
130
|
+
this.#renderedDocument = document;
|
|
131
|
+
this.#renderedView = this.#view;
|
|
132
|
+
}
|
|
133
|
+
const rendered = this.#rendered;
|
|
134
|
+
if (!rendered) throw new Error("Transcript render was not created.");
|
|
135
|
+
const layout = layoutAgentRunTranscript(rendered, width);
|
|
136
|
+
const registryMetadata =
|
|
137
|
+
this.#view === "details" ? this.#registryMetadataBlocks(run, width) : [];
|
|
138
|
+
const registryRows = registryMetadata.reduce((count, block) => count + block.lines.length, 0);
|
|
139
|
+
this.#targets = layout.targets.map((target) => ({
|
|
140
|
+
...target,
|
|
141
|
+
start: target.start + registryRows,
|
|
142
|
+
}));
|
|
143
|
+
const fallback =
|
|
144
|
+
document.status === "incomplete"
|
|
145
|
+
? this.#fallbackBlocks(run, width, rendered.items.length, {
|
|
146
|
+
warning: "Transcript capture is incomplete. Showing the retained Agent Run view.",
|
|
147
|
+
showTechnicalDetails: this.#view === "details",
|
|
148
|
+
})
|
|
149
|
+
: [];
|
|
150
|
+
return this.#viewport.render([...registryMetadata, ...layout.blocks, ...fallback], height);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
154
|
+
if (
|
|
155
|
+
event.type !== "click" ||
|
|
156
|
+
event.button !== "left" ||
|
|
157
|
+
event.y < this.#bounds.top ||
|
|
158
|
+
event.y >= this.#bounds.top + this.#bounds.height ||
|
|
159
|
+
event.x < this.#bounds.left ||
|
|
160
|
+
event.x >= this.#bounds.left + this.#bounds.width
|
|
161
|
+
) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const transcriptRow = this.#viewport.scrollOffset + event.y - this.#bounds.top;
|
|
165
|
+
const target = this.#targets.find(
|
|
166
|
+
(entry) => transcriptRow >= entry.start && transcriptRow < entry.start + entry.height,
|
|
167
|
+
);
|
|
168
|
+
if (!target) return undefined;
|
|
169
|
+
const result = target.component.handleMouse?.({
|
|
170
|
+
...event,
|
|
171
|
+
x: event.x - this.#bounds.left,
|
|
172
|
+
y: transcriptRow - target.start,
|
|
173
|
+
width: this.#bounds.width,
|
|
174
|
+
height: target.height,
|
|
175
|
+
});
|
|
176
|
+
if (result?.handled || result?.capture || result?.focus) {
|
|
177
|
+
this.onChange();
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
scrollBy(lines: number): void {
|
|
184
|
+
this.#viewport.scrollBy(lines);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
navigate(action: "page-up" | "page-down" | "start" | "end" | "toggle"): void {
|
|
188
|
+
this.#viewport.navigate(action);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
setDetails(details: boolean): void {
|
|
192
|
+
const view = details ? "details" : "conversation";
|
|
193
|
+
if (this.#view === view) return;
|
|
194
|
+
this.#view = view;
|
|
195
|
+
if (details && !this.#detailsStarted) {
|
|
196
|
+
this.#detailsViewport.navigate("start");
|
|
197
|
+
this.#detailsStarted = true;
|
|
198
|
+
}
|
|
199
|
+
this.onChange();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
toggleToolDetails(): void {
|
|
203
|
+
const anyExpanded =
|
|
204
|
+
this.#rendered?.rawPayloads.some((payload) => payload.isExpanded) ??
|
|
205
|
+
this.#toolDetailsExpanded;
|
|
206
|
+
this.#toolDetailsExpanded = !anyExpanded;
|
|
207
|
+
this.#applyToolExpansion();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
toggleThinking(): void {
|
|
211
|
+
this.#thinkingHidden = !this.#thinkingHidden;
|
|
212
|
+
for (const message of this.#rendered?.assistantMessages ?? []) {
|
|
213
|
+
message.setHideThinkingBlock(this.#thinkingHidden);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
invalidate(): void {
|
|
218
|
+
for (const item of this.#rendered?.items ?? []) item.component.invalidate();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
dispose(): void {
|
|
222
|
+
this.#loadToken++;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
#request(run: AgentsOverlayRun | undefined): void {
|
|
226
|
+
const source = run?.transcriptSource;
|
|
227
|
+
if (!source) {
|
|
228
|
+
this.#loadToken++;
|
|
229
|
+
this.#source = undefined;
|
|
230
|
+
this.#document = undefined;
|
|
231
|
+
this.#revision = -1;
|
|
232
|
+
this.#status = undefined;
|
|
233
|
+
this.#loading = false;
|
|
234
|
+
this.#failed = false;
|
|
235
|
+
this.#clearRendered();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const status = source.getStatus();
|
|
239
|
+
if (
|
|
240
|
+
source === this.#source &&
|
|
241
|
+
status.revision === this.#revision &&
|
|
242
|
+
status.status === this.#status
|
|
243
|
+
) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const sameSource = source === this.#source;
|
|
247
|
+
this.#source = source;
|
|
248
|
+
this.#revision = status.revision;
|
|
249
|
+
this.#status = status.status;
|
|
250
|
+
this.#loading = true;
|
|
251
|
+
this.#failed = false;
|
|
252
|
+
if (!sameSource) {
|
|
253
|
+
this.#document = undefined;
|
|
254
|
+
this.#clearRendered();
|
|
255
|
+
}
|
|
256
|
+
const token = ++this.#loadToken;
|
|
257
|
+
const selectedKey = run?.key;
|
|
258
|
+
void source
|
|
259
|
+
.load()
|
|
260
|
+
.then((document) => {
|
|
261
|
+
if (token !== this.#loadToken || this.#selectedKey !== selectedKey) return;
|
|
262
|
+
this.#document = document;
|
|
263
|
+
this.#loading = false;
|
|
264
|
+
this.#failed = document.status === "incomplete" && status.status === "complete";
|
|
265
|
+
this.onChange();
|
|
266
|
+
})
|
|
267
|
+
.catch(() => {
|
|
268
|
+
if (token !== this.#loadToken || this.#selectedKey !== selectedKey) return;
|
|
269
|
+
this.#loading = false;
|
|
270
|
+
this.#failed = true;
|
|
271
|
+
this.#document = undefined;
|
|
272
|
+
this.onChange();
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
#applyToolExpansion(): void {
|
|
277
|
+
for (const tool of this.#rendered?.toolCalls ?? []) {
|
|
278
|
+
tool.setExpanded(this.#toolDetailsExpanded);
|
|
279
|
+
}
|
|
280
|
+
for (const raw of this.#rendered?.rawPayloads ?? []) {
|
|
281
|
+
raw.setExpanded(this.#toolDetailsExpanded);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
#clearRendered(): void {
|
|
286
|
+
this.#rendered = undefined;
|
|
287
|
+
this.#renderedDocument = undefined;
|
|
288
|
+
this.#renderedView = undefined;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#renderFallback(run: AgentsOverlayRun, width: number, height: number): string[] {
|
|
292
|
+
return this.#viewport.render(
|
|
293
|
+
this.#fallbackBlocks(run, width, 0, {
|
|
294
|
+
...(this.#failed
|
|
295
|
+
? { warning: "Transcript storage is unavailable. Showing the retained Agent Run view." }
|
|
296
|
+
: {}),
|
|
297
|
+
showTechnicalDetails: this.#view === "details",
|
|
298
|
+
}),
|
|
299
|
+
height,
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
#registryMetadataBlocks(run: AgentsOverlayRun, width: number): AgentRunBlock[] {
|
|
304
|
+
if (this.#view !== "details") return [];
|
|
305
|
+
const status = run.result?.failureCode
|
|
306
|
+
? `${run.status} (${run.result.failureCode})`
|
|
307
|
+
: run.status;
|
|
308
|
+
const details = [
|
|
309
|
+
`Registry status: ${status}`,
|
|
310
|
+
`Runtime totals: ${run.turns} turns · ${run.toolUses} tool uses${
|
|
311
|
+
run.usage ? ` · ${run.usage.totalTokens.toLocaleString("en-US")} tokens` : ""
|
|
312
|
+
}`,
|
|
313
|
+
];
|
|
314
|
+
return details.map((text, index) => ({
|
|
315
|
+
key: index - details.length,
|
|
316
|
+
lines: new Text(text, 0, 0).render(width),
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
#fallbackBlocks(
|
|
321
|
+
run: AgentsOverlayRun,
|
|
322
|
+
width: number,
|
|
323
|
+
keyOffset: number,
|
|
324
|
+
options: { warning?: string; showTechnicalDetails?: boolean } = {},
|
|
325
|
+
): AgentRunBlock[] {
|
|
326
|
+
const metadata = options.showTechnicalDetails ? fallbackMetadata(run) : [];
|
|
327
|
+
const blocks = [...(options.warning ? [options.warning] : []), ...metadata].map(
|
|
328
|
+
(line, index) => ({
|
|
329
|
+
key: keyOffset + index,
|
|
330
|
+
lines: new Text(line, 0, 0).render(width),
|
|
331
|
+
}),
|
|
332
|
+
);
|
|
333
|
+
for (const entry of run.conversation?.entries ?? []) {
|
|
334
|
+
const line =
|
|
335
|
+
entry.kind === "assistant" || entry.kind === "steering"
|
|
336
|
+
? entry.text
|
|
337
|
+
: `${entry.toolName}: ${entry.summary ?? entry.status}`;
|
|
338
|
+
blocks.push({
|
|
339
|
+
key: keyOffset + blocks.length,
|
|
340
|
+
lines: new Text(line, 1, 0).render(width),
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
if (blocks.length === 0) {
|
|
344
|
+
blocks.push({
|
|
345
|
+
key: keyOffset,
|
|
346
|
+
lines: new Text("Full transcript is unavailable.", 0, 0).render(width),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return blocks;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
#line(text: string, width: number): string {
|
|
353
|
+
return truncateToWidth(` ${text}`, width);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function fallbackMetadata(run: AgentsOverlayRun): string[] {
|
|
358
|
+
const metadata = [
|
|
359
|
+
`${run.taskId} · ${run.kind}: ${run.label} · ${run.result?.failureCode ? `${run.status} (${run.result.failureCode})` : run.status}`,
|
|
360
|
+
`Model: ${run.modelId} · thinking ${run.thinkingLevel}`,
|
|
361
|
+
`${run.turns} turns · ${run.toolUses} tool uses${run.usage ? ` · ${run.usage.totalTokens.toLocaleString("en-US")} tokens` : ""}`,
|
|
362
|
+
...(run.result?.humanTruncated ? ["Human output truncated."] : []),
|
|
363
|
+
...(run.conversation?.omittedEntryCount
|
|
364
|
+
? [`Retention: ${run.conversation.omittedEntryCount} conversation entries omitted.`]
|
|
365
|
+
: []),
|
|
366
|
+
...(run.taskDescription ? [`Task: ${run.taskDescription}`] : []),
|
|
367
|
+
...(run.sharedContext ? [`Shared context: ${run.sharedContext}`] : []),
|
|
368
|
+
];
|
|
369
|
+
if (run.result?.finalText?.trim()) {
|
|
370
|
+
const bounded = boundFallbackResult(run.result.finalText);
|
|
371
|
+
metadata.push("Result", bounded.text);
|
|
372
|
+
if (bounded.truncated) metadata.push("Result shortened for overlay.");
|
|
373
|
+
}
|
|
374
|
+
metadata.push("Conversation");
|
|
375
|
+
return metadata;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function boundFallbackResult(text: string): { text: string; truncated: boolean } {
|
|
379
|
+
const characterBound = text.length > 4_000;
|
|
380
|
+
const safeText = text.slice(0, 4_000).replace(/\r\n?/g, "\n").trimEnd();
|
|
381
|
+
const lines = safeText ? safeText.split("\n") : [];
|
|
382
|
+
return {
|
|
383
|
+
text: lines.slice(0, 8).join("\n"),
|
|
384
|
+
truncated: characterBound || lines.length > 8,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
type Component,
|
|
4
|
+
Container,
|
|
5
|
+
Text,
|
|
6
|
+
type TuiMouseEvent,
|
|
7
|
+
type TuiMouseEventResult,
|
|
8
|
+
} from "@earendil-works/pi-tui";
|
|
9
|
+
|
|
10
|
+
/** Format a transcript value without failing the viewer on cyclic data. */
|
|
11
|
+
export function formatTranscriptValue(value: unknown): string {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.stringify(value, null, 2) ?? "(empty)";
|
|
14
|
+
} catch {
|
|
15
|
+
return "(message could not be rendered)";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Hide raw tool input and output until the user opens the disclosure. */
|
|
20
|
+
export class RawToolPayload implements Component {
|
|
21
|
+
#expanded = false;
|
|
22
|
+
#lines: string;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
payload: { input?: unknown; result?: unknown },
|
|
26
|
+
private readonly theme: Theme,
|
|
27
|
+
) {
|
|
28
|
+
this.#lines = formatTranscriptValue(payload);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
invalidate(): void {}
|
|
32
|
+
|
|
33
|
+
update(payload: { input?: unknown; result?: unknown }): void {
|
|
34
|
+
this.#lines = formatTranscriptValue(payload);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get isExpanded(): boolean {
|
|
38
|
+
return this.#expanded;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setExpanded(expanded: boolean): void {
|
|
42
|
+
this.#expanded = expanded;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
toggle(): void {
|
|
46
|
+
this.#expanded = !this.#expanded;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
render(width: number): string[] {
|
|
50
|
+
if (!this.#expanded) {
|
|
51
|
+
return [
|
|
52
|
+
this.theme.fg("dim", " Raw tool input/result hidden · use the tool details control"),
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
const container = new Container();
|
|
56
|
+
container.addChild(new Text(this.theme.fg("muted", " Raw tool input/result"), 0, 0));
|
|
57
|
+
container.addChild(new Text(this.#lines, 1, 0));
|
|
58
|
+
return container.render(width);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
62
|
+
if (event.type !== "click" || event.button !== "left") return undefined;
|
|
63
|
+
this.toggle();
|
|
64
|
+
return { handled: true };
|
|
65
|
+
}
|
|
66
|
+
}
|