@mrclrchtr/supi-review 7.3.0 → 7.4.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 +10 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -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/run.ts +151 -21
- 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 +22 -0
- 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 +78 -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 +400 -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/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- 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-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-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +25 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +22 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +7 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlayHint.d.ts +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineCompletion.d.ts +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.d.ts +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -2
- 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-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-core/package.json +1 -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-core/package.json +1 -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/workflow.ts +7 -1
- package/src/tui/review-command.ts +74 -3
- package/src/types.ts +5 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
2
|
+
import {
|
|
3
|
+
AssistantMessageComponent,
|
|
4
|
+
getMarkdownTheme,
|
|
5
|
+
type Theme,
|
|
6
|
+
ToolExecutionComponent,
|
|
7
|
+
UserMessageComponent,
|
|
8
|
+
} from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import { type Component, Image, Text } from "@earendil-works/pi-tui";
|
|
10
|
+
import type { AgentRunMessage, AgentRunToolRenderer } from "@mrclrchtr/supi-agent-runtime/api";
|
|
11
|
+
import type { AgentRunTranscriptDocument } from "../session/transcript-store.ts";
|
|
12
|
+
import type { AgentRunBlock } from "./agents-run-viewport.ts";
|
|
13
|
+
import { renderSystemPrompt, renderTranscriptMetadata } from "./agents-transcript-context.ts";
|
|
14
|
+
import { formatTranscriptValue, RawToolPayload } from "./agents-transcript-payload.ts";
|
|
15
|
+
|
|
16
|
+
export interface AgentTranscriptInteractiveTarget {
|
|
17
|
+
readonly start: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
readonly component: Component;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AgentTranscriptRenderItem {
|
|
23
|
+
readonly key: number;
|
|
24
|
+
readonly component: Component;
|
|
25
|
+
readonly interactive: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface AgentTranscriptRenderResult {
|
|
29
|
+
readonly items: readonly AgentTranscriptRenderItem[];
|
|
30
|
+
readonly assistantMessages: readonly AssistantMessageComponent[];
|
|
31
|
+
readonly toolCalls: readonly ToolExecutionComponent[];
|
|
32
|
+
readonly rawPayloads: readonly RawToolPayload[];
|
|
33
|
+
readonly assistantByIndex: ReadonlyMap<number, AssistantMessageComponent>;
|
|
34
|
+
readonly toolCallsById: ReadonlyMap<string, ToolExecutionComponent>;
|
|
35
|
+
readonly rawPayloadsById: ReadonlyMap<string, RawToolPayload>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Options for one full Agent Run transcript render. */
|
|
39
|
+
export interface RenderAgentRunTranscriptOptions {
|
|
40
|
+
readonly document: AgentRunTranscriptDocument;
|
|
41
|
+
readonly toolRenderers: readonly AgentRunToolRenderer[];
|
|
42
|
+
readonly theme: Theme;
|
|
43
|
+
readonly tui: { requestRender: () => void };
|
|
44
|
+
readonly expanded: boolean;
|
|
45
|
+
readonly thinkingHidden: boolean;
|
|
46
|
+
readonly view: "conversation" | "details";
|
|
47
|
+
readonly previous?: AgentTranscriptRenderResult;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface TranscriptRenderContext extends RenderAgentRunTranscriptOptions {
|
|
51
|
+
readonly items: AgentTranscriptRenderItem[];
|
|
52
|
+
readonly assistantMessages: AssistantMessageComponent[];
|
|
53
|
+
readonly toolCalls: ToolExecutionComponent[];
|
|
54
|
+
readonly rawPayloads: RawToolPayload[];
|
|
55
|
+
readonly assistantByIndex: Map<number, AssistantMessageComponent>;
|
|
56
|
+
readonly toolCallsById: Map<string, ToolExecutionComponent>;
|
|
57
|
+
readonly rawPayloadsById: Map<string, RawToolPayload>;
|
|
58
|
+
readonly renderers: Map<string, AgentRunToolRenderer>;
|
|
59
|
+
readonly results: Map<string, AgentRunMessage>;
|
|
60
|
+
readonly renderedResults: Set<string>;
|
|
61
|
+
nextKey: number;
|
|
62
|
+
messageIndex: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Render a full human transcript with Pi's message and tool components. */
|
|
66
|
+
export function renderAgentRunTranscript(
|
|
67
|
+
options: RenderAgentRunTranscriptOptions,
|
|
68
|
+
): AgentTranscriptRenderResult {
|
|
69
|
+
const context = createRenderContext(options);
|
|
70
|
+
if (options.view === "details") {
|
|
71
|
+
addItem(context, renderTranscriptMetadata(options.document, options.theme));
|
|
72
|
+
for (const prompt of options.document.systemPromptHistory) {
|
|
73
|
+
addItem(context, renderSystemPrompt(prompt, options.theme));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const message of options.document.messages) {
|
|
77
|
+
appendMessage(context, message, context.messageIndex++, options.view === "details");
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
items: context.items,
|
|
81
|
+
assistantMessages: context.assistantMessages,
|
|
82
|
+
toolCalls: context.toolCalls,
|
|
83
|
+
rawPayloads: context.rawPayloads,
|
|
84
|
+
assistantByIndex: context.assistantByIndex,
|
|
85
|
+
toolCallsById: context.toolCallsById,
|
|
86
|
+
rawPayloadsById: context.rawPayloadsById,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function layoutAgentRunTranscript(
|
|
91
|
+
transcript: AgentTranscriptRenderResult,
|
|
92
|
+
width: number,
|
|
93
|
+
): { blocks: readonly AgentRunBlock[]; targets: readonly AgentTranscriptInteractiveTarget[] } {
|
|
94
|
+
const blocks: AgentRunBlock[] = [];
|
|
95
|
+
const targets: AgentTranscriptInteractiveTarget[] = [];
|
|
96
|
+
let nextRow = 0;
|
|
97
|
+
for (const item of transcript.items) {
|
|
98
|
+
const lines = item.component.render(width);
|
|
99
|
+
blocks.push({ key: item.key, lines });
|
|
100
|
+
if (item.interactive && lines.length > 0) {
|
|
101
|
+
targets.push({ start: nextRow, height: lines.length, component: item.component });
|
|
102
|
+
}
|
|
103
|
+
nextRow += lines.length;
|
|
104
|
+
}
|
|
105
|
+
return { blocks, targets };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function createRenderContext(options: RenderAgentRunTranscriptOptions): TranscriptRenderContext {
|
|
109
|
+
const results = new Map<string, AgentRunMessage>();
|
|
110
|
+
for (const message of options.document.messages) {
|
|
111
|
+
if (message.role === "toolResult" && typeof message.toolCallId === "string") {
|
|
112
|
+
results.set(message.toolCallId, message);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
...options,
|
|
117
|
+
items: [],
|
|
118
|
+
assistantMessages: [],
|
|
119
|
+
toolCalls: [],
|
|
120
|
+
rawPayloads: [],
|
|
121
|
+
assistantByIndex: new Map(),
|
|
122
|
+
toolCallsById: new Map(),
|
|
123
|
+
rawPayloadsById: new Map(),
|
|
124
|
+
renderers: new Map(options.toolRenderers.map((renderer) => [renderer.name, renderer])),
|
|
125
|
+
results,
|
|
126
|
+
renderedResults: new Set(),
|
|
127
|
+
nextKey: 0,
|
|
128
|
+
messageIndex: 0,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function appendMessage(
|
|
133
|
+
context: TranscriptRenderContext,
|
|
134
|
+
message: AgentRunMessage,
|
|
135
|
+
messageIndex: number,
|
|
136
|
+
showTechnicalDetails: boolean,
|
|
137
|
+
): void {
|
|
138
|
+
const pairedToolResult =
|
|
139
|
+
message.role === "toolResult" &&
|
|
140
|
+
typeof message.toolCallId === "string" &&
|
|
141
|
+
context.renderedResults.has(message.toolCallId);
|
|
142
|
+
if (showTechnicalDetails && !pairedToolResult) addMessageHeader(context, message);
|
|
143
|
+
if (message.role === "assistant") {
|
|
144
|
+
appendAssistantMessage(context, message, messageIndex, showTechnicalDetails);
|
|
145
|
+
} else if (message.role === "user") {
|
|
146
|
+
appendUserMessage(context, message);
|
|
147
|
+
} else if (message.role === "toolResult") {
|
|
148
|
+
appendToolResult(context, message, showTechnicalDetails);
|
|
149
|
+
} else {
|
|
150
|
+
addItem(context, new Text(formatMessage(message), 1, 0));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function addMessageHeader(context: TranscriptRenderContext, message: AgentRunMessage): void {
|
|
155
|
+
const timestamp =
|
|
156
|
+
typeof message.timestamp === "number" && Number.isFinite(message.timestamp)
|
|
157
|
+
? ` · ${new Date(message.timestamp).toLocaleTimeString()}`
|
|
158
|
+
: "";
|
|
159
|
+
addItem(context, new Text(context.theme.fg("dim", `${message.role}${timestamp}`), 0, 0));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function appendAssistantMessage(
|
|
163
|
+
context: TranscriptRenderContext,
|
|
164
|
+
message: AgentRunMessage,
|
|
165
|
+
messageIndex: number,
|
|
166
|
+
showTechnicalDetails: boolean,
|
|
167
|
+
): void {
|
|
168
|
+
if (!Array.isArray(message.content)) {
|
|
169
|
+
addItem(context, new Text(formatMessage(message), 1, 0));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const existing = context.previous?.assistantByIndex.get(messageIndex);
|
|
173
|
+
const assistant =
|
|
174
|
+
existing ??
|
|
175
|
+
new AssistantMessageComponent(
|
|
176
|
+
message as unknown as AssistantMessage,
|
|
177
|
+
context.thinkingHidden,
|
|
178
|
+
getMarkdownTheme(),
|
|
179
|
+
"Thinking is hidden · press i to show",
|
|
180
|
+
1,
|
|
181
|
+
);
|
|
182
|
+
if (existing) assistant.updateContent(message as unknown as AssistantMessage, false);
|
|
183
|
+
context.assistantByIndex.set(messageIndex, assistant);
|
|
184
|
+
context.assistantMessages.push(assistant);
|
|
185
|
+
addItem(context, assistant, true);
|
|
186
|
+
for (const part of message.content) {
|
|
187
|
+
if (isToolCall(part)) appendToolCall(context, part, showTechnicalDetails);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function appendToolCall(
|
|
192
|
+
context: TranscriptRenderContext,
|
|
193
|
+
part: { type: "toolCall"; id: string; name: string; arguments: unknown },
|
|
194
|
+
showTechnicalDetails: boolean,
|
|
195
|
+
): void {
|
|
196
|
+
const result = context.results.get(part.id);
|
|
197
|
+
if (result) context.renderedResults.add(part.id);
|
|
198
|
+
if (showTechnicalDetails && result) addMessageHeader(context, result);
|
|
199
|
+
const existing = context.previous?.toolCallsById.get(part.id);
|
|
200
|
+
const tool =
|
|
201
|
+
existing ??
|
|
202
|
+
createToolComponent({
|
|
203
|
+
name: part.name,
|
|
204
|
+
id: part.id,
|
|
205
|
+
args: part.arguments,
|
|
206
|
+
result,
|
|
207
|
+
renderer: context.renderers.get(part.name),
|
|
208
|
+
tui: context.tui,
|
|
209
|
+
cwd: context.document.metadata.cwd,
|
|
210
|
+
expanded: context.expanded,
|
|
211
|
+
});
|
|
212
|
+
if (existing && result) tool.updateResult(toolResultPayload(result), false);
|
|
213
|
+
context.toolCallsById.set(part.id, tool);
|
|
214
|
+
context.toolCalls.push(tool);
|
|
215
|
+
addItem(context, tool, true);
|
|
216
|
+
const rawKey = `tool:${part.id}`;
|
|
217
|
+
const raw = context.previous?.rawPayloadsById.get(rawKey);
|
|
218
|
+
if (raw) {
|
|
219
|
+
raw.update({ input: part.arguments, result });
|
|
220
|
+
context.rawPayloadsById.set(rawKey, raw);
|
|
221
|
+
} else {
|
|
222
|
+
const payload = new RawToolPayload({ input: part.arguments, result }, context.theme);
|
|
223
|
+
payload.setExpanded(context.expanded);
|
|
224
|
+
context.rawPayloadsById.set(rawKey, payload);
|
|
225
|
+
}
|
|
226
|
+
const activeRaw = context.rawPayloadsById.get(rawKey);
|
|
227
|
+
if (!activeRaw) throw new Error("Raw tool payload was not created.");
|
|
228
|
+
context.rawPayloads.push(activeRaw);
|
|
229
|
+
if (showTechnicalDetails) addItem(context, activeRaw, true);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function appendUserMessage(context: TranscriptRenderContext, message: AgentRunMessage): void {
|
|
233
|
+
addItem(context, new UserMessageComponent(textContent(message.content), getMarkdownTheme(), 1));
|
|
234
|
+
for (const image of imageContent(message.content)) {
|
|
235
|
+
addItem(
|
|
236
|
+
context,
|
|
237
|
+
new Image(
|
|
238
|
+
image.data,
|
|
239
|
+
image.mimeType,
|
|
240
|
+
{ fallbackColor: (text) => context.theme.fg("muted", text) },
|
|
241
|
+
{ maxWidthCells: 80, maxHeightCells: 24 },
|
|
242
|
+
),
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function appendToolResult(
|
|
248
|
+
context: TranscriptRenderContext,
|
|
249
|
+
message: AgentRunMessage,
|
|
250
|
+
showTechnicalDetails: boolean,
|
|
251
|
+
): void {
|
|
252
|
+
if (typeof message.toolCallId !== "string" || context.renderedResults.has(message.toolCallId)) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const name = typeof message.toolName === "string" ? message.toolName : "tool";
|
|
256
|
+
const existing = context.previous?.toolCallsById.get(message.toolCallId);
|
|
257
|
+
const tool =
|
|
258
|
+
existing ??
|
|
259
|
+
createToolComponent({
|
|
260
|
+
name,
|
|
261
|
+
id: message.toolCallId,
|
|
262
|
+
result: message,
|
|
263
|
+
renderer: context.renderers.get(name),
|
|
264
|
+
tui: context.tui,
|
|
265
|
+
cwd: context.document.metadata.cwd,
|
|
266
|
+
expanded: context.expanded,
|
|
267
|
+
});
|
|
268
|
+
if (existing) tool.updateResult(toolResultPayload(message), false);
|
|
269
|
+
context.toolCallsById.set(message.toolCallId, tool);
|
|
270
|
+
context.toolCalls.push(tool);
|
|
271
|
+
addItem(context, tool, true);
|
|
272
|
+
const rawKey = `result:${message.toolCallId}`;
|
|
273
|
+
const raw = context.previous?.rawPayloadsById.get(rawKey);
|
|
274
|
+
if (raw) {
|
|
275
|
+
raw.update({ result: message });
|
|
276
|
+
context.rawPayloadsById.set(rawKey, raw);
|
|
277
|
+
} else {
|
|
278
|
+
const payload = new RawToolPayload({ result: message }, context.theme);
|
|
279
|
+
payload.setExpanded(context.expanded);
|
|
280
|
+
context.rawPayloadsById.set(rawKey, payload);
|
|
281
|
+
}
|
|
282
|
+
const activeRaw = context.rawPayloadsById.get(rawKey);
|
|
283
|
+
if (!activeRaw) throw new Error("Raw tool payload was not created.");
|
|
284
|
+
context.rawPayloads.push(activeRaw);
|
|
285
|
+
if (showTechnicalDetails) addItem(context, activeRaw, true);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function addItem(
|
|
289
|
+
context: TranscriptRenderContext,
|
|
290
|
+
component: Component,
|
|
291
|
+
interactive = false,
|
|
292
|
+
): void {
|
|
293
|
+
context.items.push({ key: context.nextKey++, component, interactive });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface ToolComponentOptions {
|
|
297
|
+
readonly name: string;
|
|
298
|
+
readonly id: string;
|
|
299
|
+
readonly args?: unknown;
|
|
300
|
+
readonly result?: AgentRunMessage;
|
|
301
|
+
readonly renderer?: AgentRunToolRenderer;
|
|
302
|
+
readonly tui: { requestRender: () => void };
|
|
303
|
+
readonly cwd: string;
|
|
304
|
+
readonly expanded: boolean;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function toolResultPayload(message: AgentRunMessage): {
|
|
308
|
+
content: never[];
|
|
309
|
+
details: unknown;
|
|
310
|
+
isError: boolean;
|
|
311
|
+
} {
|
|
312
|
+
return {
|
|
313
|
+
content: Array.isArray(message.content) ? (message.content as never[]) : [],
|
|
314
|
+
details: message.details,
|
|
315
|
+
isError: message.isError === true,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function createToolComponent(options: ToolComponentOptions): ToolExecutionComponent {
|
|
320
|
+
const component = new ToolExecutionComponent(
|
|
321
|
+
options.name,
|
|
322
|
+
options.id,
|
|
323
|
+
options.args,
|
|
324
|
+
{ showImages: true },
|
|
325
|
+
options.renderer,
|
|
326
|
+
options.tui as never,
|
|
327
|
+
options.cwd,
|
|
328
|
+
);
|
|
329
|
+
component.setArgsComplete();
|
|
330
|
+
component.markExecutionStarted();
|
|
331
|
+
if (options.result) {
|
|
332
|
+
component.updateResult(toolResultPayload(options.result), false);
|
|
333
|
+
}
|
|
334
|
+
component.setExpanded(options.expanded);
|
|
335
|
+
return component;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function isToolCall(
|
|
339
|
+
value: unknown,
|
|
340
|
+
): value is { type: "toolCall"; id: string; name: string; arguments: unknown } {
|
|
341
|
+
if (!value || typeof value !== "object") return false;
|
|
342
|
+
const candidate = value as Record<string, unknown>;
|
|
343
|
+
return (
|
|
344
|
+
candidate.type === "toolCall" &&
|
|
345
|
+
typeof candidate.id === "string" &&
|
|
346
|
+
typeof candidate.name === "string"
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function textContent(content: unknown): string {
|
|
351
|
+
if (typeof content === "string") return content;
|
|
352
|
+
if (!Array.isArray(content)) return formatTranscriptValue(content);
|
|
353
|
+
return content
|
|
354
|
+
.map((part) => {
|
|
355
|
+
if (!part || typeof part !== "object") return "";
|
|
356
|
+
const item = part as Record<string, unknown>;
|
|
357
|
+
if (item.type === "text" && typeof item.text === "string") return item.text;
|
|
358
|
+
return item.type === "image" ? "" : formatTranscriptValue(item);
|
|
359
|
+
})
|
|
360
|
+
.filter(Boolean)
|
|
361
|
+
.join("\n");
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function imageContent(content: unknown): Array<{ data: string; mimeType: string }> {
|
|
365
|
+
if (!Array.isArray(content)) return [];
|
|
366
|
+
return content.flatMap((part) => {
|
|
367
|
+
if (!part || typeof part !== "object") return [];
|
|
368
|
+
const item = part as Record<string, unknown>;
|
|
369
|
+
return item.type === "image" &&
|
|
370
|
+
typeof item.data === "string" &&
|
|
371
|
+
typeof item.mimeType === "string"
|
|
372
|
+
? [{ data: item.data, mimeType: item.mimeType }]
|
|
373
|
+
: [];
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function formatMessage(message: AgentRunMessage): string {
|
|
378
|
+
const content = message.content;
|
|
379
|
+
return typeof content === "string" ? content : formatTranscriptValue(message);
|
|
380
|
+
}
|
|
@@ -727,6 +727,20 @@ const WILDCARD = '[^\\/]*'
|
|
|
727
727
|
// The source is read one token at a time -- a wildcard, a single-character
|
|
728
728
|
// piece (a literal, an escape, a class), or a parenthesised group or anchor
|
|
729
729
|
// that ends the run -- so only a genuine wildcard is touched.
|
|
730
|
+
|
|
731
|
+
// The fixed pieces between the wildcard at `at` and the next wildcard of the
|
|
732
|
+
// run, joined as they appear in the source. A run never holds two wildcards
|
|
733
|
+
// in a row, so there is always at least one piece.
|
|
734
|
+
const separatorAfter = (run, at) => {
|
|
735
|
+
let separator = EMPTY
|
|
736
|
+
|
|
737
|
+
for (let index = at + 1; index < run.length && !run[index].wildcard; index ++) {
|
|
738
|
+
separator += run[index].single
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return separator
|
|
742
|
+
}
|
|
743
|
+
|
|
730
744
|
const pinWildcards = source => {
|
|
731
745
|
if (source.indexOf(WILDCARD) < 0) {
|
|
732
746
|
return source
|
|
@@ -814,14 +828,19 @@ const pinWildcards = source => {
|
|
|
814
828
|
return
|
|
815
829
|
}
|
|
816
830
|
|
|
817
|
-
// A wildcard that is not the last in the run is
|
|
818
|
-
//
|
|
819
|
-
//
|
|
820
|
-
//
|
|
821
|
-
// the
|
|
831
|
+
// A wildcard that is not the last in the run is pinned to the whole
|
|
832
|
+
// fixed piece that separates it from the next wildcard, not just to
|
|
833
|
+
// that piece's first character: stopping at the first character alone
|
|
834
|
+
// would let the wildcard hand over at a place where the rest of the
|
|
835
|
+
// separator cannot follow, and the pin leaves no way back, so
|
|
836
|
+
// `f*o/*/*` would miss `foo/b/c` -- the first `o` of `foo` is not the
|
|
837
|
+
// one the `o/` after it needs. Every piece matches exactly one
|
|
838
|
+
// character, so pinning to the first place the whole separator fits
|
|
839
|
+
// is the leftmost place it can sit, and the wildcards that follow
|
|
840
|
+
// take up whatever is left.
|
|
822
841
|
out += at === lastWildcard
|
|
823
842
|
? WILDCARD
|
|
824
|
-
: `(?:(?!${run
|
|
843
|
+
: `(?:(?!${separatorAfter(run, at)})[^\\/])*`
|
|
825
844
|
})
|
|
826
845
|
|
|
827
846
|
run = []
|
|
@@ -632,6 +632,17 @@ var WILDCARD = '[^\\/]*';
|
|
|
632
632
|
// The source is read one token at a time -- a wildcard, a single-character
|
|
633
633
|
// piece (a literal, an escape, a class), or a parenthesised group or anchor
|
|
634
634
|
// that ends the run -- so only a genuine wildcard is touched.
|
|
635
|
+
|
|
636
|
+
// The fixed pieces between the wildcard at `at` and the next wildcard of the
|
|
637
|
+
// run, joined as they appear in the source. A run never holds two wildcards
|
|
638
|
+
// in a row, so there is always at least one piece.
|
|
639
|
+
var separatorAfter = function separatorAfter(run, at) {
|
|
640
|
+
var separator = EMPTY;
|
|
641
|
+
for (var index = at + 1; index < run.length && !run[index].wildcard; index++) {
|
|
642
|
+
separator += run[index].single;
|
|
643
|
+
}
|
|
644
|
+
return separator;
|
|
645
|
+
};
|
|
635
646
|
var pinWildcards = function pinWildcards(source) {
|
|
636
647
|
if (source.indexOf(WILDCARD) < 0) {
|
|
637
648
|
return source;
|
|
@@ -714,12 +725,17 @@ var pinWildcards = function pinWildcards(source) {
|
|
|
714
725
|
return;
|
|
715
726
|
}
|
|
716
727
|
|
|
717
|
-
// A wildcard that is not the last in the run is
|
|
718
|
-
//
|
|
719
|
-
//
|
|
720
|
-
//
|
|
721
|
-
// the
|
|
722
|
-
|
|
728
|
+
// A wildcard that is not the last in the run is pinned to the whole
|
|
729
|
+
// fixed piece that separates it from the next wildcard, not just to
|
|
730
|
+
// that piece's first character: stopping at the first character alone
|
|
731
|
+
// would let the wildcard hand over at a place where the rest of the
|
|
732
|
+
// separator cannot follow, and the pin leaves no way back, so
|
|
733
|
+
// `f*o/*/*` would miss `foo/b/c` -- the first `o` of `foo` is not the
|
|
734
|
+
// one the `o/` after it needs. Every piece matches exactly one
|
|
735
|
+
// character, so pinning to the first place the whole separator fits
|
|
736
|
+
// is the leftmost place it can sit, and the wildcards that follow
|
|
737
|
+
// take up whatever is left.
|
|
738
|
+
out += at === lastWildcard ? WILDCARD : "(?:(?!".concat(separatorAfter(run, at), ")[^\\/])*");
|
|
723
739
|
});
|
|
724
740
|
run = [];
|
|
725
741
|
};
|
|
@@ -781,7 +781,8 @@ function createMessageConnection(messageReader, messageWriter, _logger, options)
|
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
|
-
|
|
784
|
+
const error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
|
|
785
|
+
tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms.${error}`, data);
|
|
785
786
|
}
|
|
786
787
|
else {
|
|
787
788
|
logLSPMessage('send-response', message);
|
|
@@ -1145,7 +1146,6 @@ function createMessageConnection(messageReader, messageWriter, _logger, options)
|
|
|
1145
1146
|
responsePromises.delete(id);
|
|
1146
1147
|
responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, error.message ? error.message : 'Unknown reason'));
|
|
1147
1148
|
logger.error(`Sending request failed.`);
|
|
1148
|
-
throw error;
|
|
1149
1149
|
}
|
|
1150
1150
|
});
|
|
1151
1151
|
},
|
|
@@ -50,6 +50,7 @@ export interface PipeTransport {
|
|
|
50
50
|
export declare function createClientPipeTransport(pipeName: string, encoding?: RAL.MessageBufferEncoding): Promise<PipeTransport>;
|
|
51
51
|
export declare function createServerPipeTransport(pipeName: string, encoding?: RAL.MessageBufferEncoding): [MessageReader, MessageWriter];
|
|
52
52
|
export interface SocketTransport {
|
|
53
|
+
port(): number;
|
|
53
54
|
onConnected(): Promise<[MessageReader, MessageWriter]>;
|
|
54
55
|
}
|
|
55
56
|
export declare function createClientSocketTransport(port: number, encoding?: RAL.MessageBufferEncoding): Promise<SocketTransport>;
|
|
@@ -255,7 +255,14 @@ function createClientSocketTransport(port, encoding = 'utf-8') {
|
|
|
255
255
|
server.on('error', reject);
|
|
256
256
|
server.listen(port, '127.0.0.1', () => {
|
|
257
257
|
server.removeListener('error', reject);
|
|
258
|
+
const address = server.address();
|
|
259
|
+
if (address === null || typeof address === 'string') {
|
|
260
|
+
reject(new Error(`Unexpected server address: ${address}`));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const boundPort = address.port;
|
|
258
264
|
resolve({
|
|
265
|
+
port: () => boundPort,
|
|
259
266
|
onConnected: () => { return connected; }
|
|
260
267
|
});
|
|
261
268
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-jsonrpc",
|
|
3
3
|
"description": "A json rpc implementation over streams",
|
|
4
|
-
"version": "9.0.
|
|
4
|
+
"version": "9.0.3",
|
|
5
5
|
"author": "Microsoft Corporation",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"msgpack-lite": "^0.1.26"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"prepublishOnly": "
|
|
37
|
+
"prepublishOnly": "npm run all:publish",
|
|
38
38
|
"prepack": "npm run all:publish",
|
|
39
39
|
"preversion": "npm test",
|
|
40
40
|
"compile": "tsc -b ./tsconfig.json",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestHandler, RequestHandler0 } from 'vscode-jsonrpc';
|
|
2
2
|
import { Range, TextDocumentIdentifier, InlayHint } from 'vscode-languageserver-types';
|
|
3
3
|
import { CM, MessageDirection, ProtocolRequestType, ProtocolRequestType0 } from './messages';
|
|
4
|
-
import { type StaticRegistrationOptions, type TextDocumentRegistrationOptions, type WorkDoneProgressOptions, type WorkDoneProgressParams } from './protocol';
|
|
4
|
+
import { type PartialResultParams, type StaticRegistrationOptions, type TextDocumentRegistrationOptions, type WorkDoneProgressOptions, type WorkDoneProgressParams } from './protocol';
|
|
5
5
|
/**
|
|
6
6
|
* @since 3.18.0
|
|
7
7
|
*/
|
|
@@ -67,7 +67,7 @@ export type InlayHintRegistrationOptions = InlayHintOptions & TextDocumentRegist
|
|
|
67
67
|
*
|
|
68
68
|
* @since 3.17.0
|
|
69
69
|
*/
|
|
70
|
-
export type InlayHintParams = WorkDoneProgressParams & {
|
|
70
|
+
export type InlayHintParams = WorkDoneProgressParams & PartialResultParams & {
|
|
71
71
|
/**
|
|
72
72
|
* The text document.
|
|
73
73
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InlineCompletionItem, InlineCompletionContext, InlineCompletionList } from 'vscode-languageserver-types';
|
|
2
2
|
import { RequestHandler } from 'vscode-jsonrpc';
|
|
3
3
|
import { CM, MessageDirection, ProtocolRequestType } from './messages';
|
|
4
|
-
import { type TextDocumentRegistrationOptions, type WorkDoneProgressOptions, type StaticRegistrationOptions, type WorkDoneProgressParams, type TextDocumentPositionParams } from './protocol';
|
|
4
|
+
import { type TextDocumentRegistrationOptions, type WorkDoneProgressOptions, type StaticRegistrationOptions, type WorkDoneProgressParams, type TextDocumentPositionParams, type PartialResultParams } from './protocol';
|
|
5
5
|
/**
|
|
6
6
|
* Client capabilities specific to inline completions.
|
|
7
7
|
*
|
|
@@ -30,7 +30,7 @@ export type InlineCompletionRegistrationOptions = InlineCompletionOptions & Text
|
|
|
30
30
|
*
|
|
31
31
|
* @since 3.18.0
|
|
32
32
|
*/
|
|
33
|
-
export type InlineCompletionParams = WorkDoneProgressParams & TextDocumentPositionParams & {
|
|
33
|
+
export type InlineCompletionParams = WorkDoneProgressParams & TextDocumentPositionParams & PartialResultParams & {
|
|
34
34
|
/**
|
|
35
35
|
* Additional information about the context in which inline completions were
|
|
36
36
|
* requested.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextDocumentIdentifier, Range, InlineValue, InlineValueContext } from 'vscode-languageserver-types';
|
|
2
2
|
import { RequestHandler, RequestHandler0 } from 'vscode-jsonrpc';
|
|
3
3
|
import { CM, MessageDirection, ProtocolRequestType, ProtocolRequestType0 } from './messages';
|
|
4
|
-
import { type TextDocumentRegistrationOptions, type WorkDoneProgressOptions, type StaticRegistrationOptions, type WorkDoneProgressParams } from './protocol';
|
|
4
|
+
import { type TextDocumentRegistrationOptions, type WorkDoneProgressOptions, type StaticRegistrationOptions, type WorkDoneProgressParams, type PartialResultParams } from './protocol';
|
|
5
5
|
/**
|
|
6
6
|
* Client capabilities specific to inline values.
|
|
7
7
|
*
|
|
@@ -47,7 +47,7 @@ export type InlineValueRegistrationOptions = InlineValueOptions & TextDocumentRe
|
|
|
47
47
|
*
|
|
48
48
|
* @since 3.17.0
|
|
49
49
|
*/
|
|
50
|
-
export type InlineValueParams = WorkDoneProgressParams & {
|
|
50
|
+
export type InlineValueParams = WorkDoneProgressParams & PartialResultParams & {
|
|
51
51
|
/**
|
|
52
52
|
* The text document.
|
|
53
53
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-languageserver-protocol",
|
|
3
3
|
"description": "VSCode Language Server Protocol implementation",
|
|
4
|
-
"version": "3.18.
|
|
4
|
+
"version": "3.18.4",
|
|
5
5
|
"author": "Microsoft Corporation",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"vscode-jsonrpc": "9.0.
|
|
31
|
-
"vscode-languageserver-types": "3.18.
|
|
30
|
+
"vscode-jsonrpc": "9.0.3",
|
|
31
|
+
"vscode-languageserver-types": "3.18.4"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"prepublishOnly": "
|
|
34
|
+
"prepublishOnly": "npm run all:publish",
|
|
35
35
|
"prepack": "npm run all:publish",
|
|
36
36
|
"postpublish": "node ../build/npm/post-publish.js",
|
|
37
37
|
"preversion": "npm test",
|