pi-agent-ide 0.7.0 → 0.7.1
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 +7 -0
- package/dist/chunk-2TRHFMCZ.js +11 -0
- package/dist/{chunk-FXNKMNSJ.js → chunk-4GCWGE2C.js} +1 -1
- package/dist/chunk-4XMY4H4V.js +1 -0
- package/dist/{chunk-3HYXQ4YA.js → chunk-76ZK5ODR.js} +2 -2
- package/dist/{chunk-6CZO43OH.js → chunk-BU7IZLKB.js} +1 -1
- package/dist/chunk-CWD4O5PM.js +3 -0
- package/dist/chunk-D3WTDA6V.js +2 -0
- package/dist/chunk-GXEGY7GV.js +1 -0
- package/dist/{chunk-GBLKIB6O.js → chunk-HZEY4GT4.js} +1 -1
- package/dist/{chunk-S5LXX32D.js → chunk-LEEQIQ7D.js} +6 -6
- package/dist/chunk-NRZO5KJT.js +9 -0
- package/dist/chunk-OMVRLWMX.js +5 -0
- package/dist/{chunk-KR36BT5E.js → chunk-PGIVHICI.js} +1 -1
- package/dist/{chunk-YRF7OATP.js → chunk-PKKDDIWW.js} +1 -1
- package/dist/{chunk-EDURPQAV.js → chunk-QRJLIV6P.js} +6 -6
- package/dist/{chunk-OBNING2A.js → chunk-S5PL5DFQ.js} +1 -1
- package/dist/chunk-VMTR74FF.js +2 -0
- package/dist/{chunk-PYPPV2F5.js → chunk-WMO6RNE2.js} +1 -1
- package/dist/{chunk-3JO7QFIL.js → chunk-WU6ZK6YD.js} +1 -1
- package/dist/{chunk-F5YZG77W.js → chunk-XH5WN5XA.js} +1 -1
- package/dist/{chunk-AJRIASPQ.js → chunk-YP46DVVP.js} +1 -1
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +2 -2
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +2 -2
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +13 -12
- package/dist/entry-33.js +1 -1
- package/dist/entry-37.js +6 -6
- package/dist/entry-41.js +1 -1
- package/dist/entry-43.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +13 -14
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +2 -2
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-57.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +33 -34
- package/dist/entry-78.js +1 -1
- package/dist/entry-79.js +1 -1
- package/dist/entry-80.js +1 -1
- package/dist/entry-82.js +2 -2
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +14 -9
- package/docs/agent-guides/editing.md +35 -46
- package/docs/agent-guides/read-resources.md +5 -9
- package/docs/agent-guides/search-code.md +12 -17
- package/docs/agent-guides/select-code.md +61 -140
- package/docs/structured-results.md +27 -62
- package/docs/tools.md +6 -10
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/index.ts +7 -6
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/index.ts +4 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +7 -4
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +35 -6
- package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +18 -1
- package/node_modules/pi-agent-ide-changes/index.ts +4 -3
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/index.ts +3 -3
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/node_modules/pi-agent-read/src/api/tools/read.ts +7 -1
- package/node_modules/pi-agent-read/src/core/extension.ts +7 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +50 -35
- package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +9 -2
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/result-targets.ts +183 -9
- package/node_modules/pi-agent-resource/src/tool-result.ts +13 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +1 -1
- package/node_modules/pi-agent-search-text/index.ts +1 -1
- package/node_modules/pi-agent-search-text/package.json +7 -7
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/index.ts +65 -4
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/node_modules/pi-agent-text-anchor-line-hash/index.ts +4 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/node_modules/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/node_modules/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +43 -209
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
- package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-call-interception/src/index.ts +3 -0
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/index.ts +4 -3
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/composite/text-results.ts +221 -0
- package/src/documentation/extension.ts +11 -9
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +7 -6
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +4 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/plugin-protocol.ts +1 -1
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +38 -1
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +7 -1
- package/src/extensions/pi-agent-read/src/core/extension.ts +7 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +50 -35
- package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +3 -3
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +9 -2
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +1 -1
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/index.ts +65 -4
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +12 -2
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +4 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +3 -1
- package/src/extensions/pi-agent-text-editor/src/core/extension.ts +10 -3
- package/src/extensions/pi-agent-text-editor/src/core/file-operations.ts +3 -13
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +18 -11
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +43 -209
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +37 -31
- package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/coordinator.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +2 -7
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +1 -1
- package/src/pi-agent-ide.ts +4 -1
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +7 -4
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +35 -6
- package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +1 -1
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +18 -1
- package/src/plugins/pi-agent-ide-changes/index.ts +4 -3
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-debugger/index.ts +5 -3
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +5 -3
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/index.ts +3 -3
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +5 -1
- package/src/plugins/pi-agent-ide-terminal/src/resources.ts +8 -6
- package/src/plugins/pi-agent-ide-vision/index.ts +12 -4
- package/dist/chunk-4NIFBFFR.js +0 -11
- package/dist/chunk-7LZKOHH2.js +0 -1
- package/dist/chunk-FK42RSF4.js +0 -1
- package/dist/chunk-KBP3QUDT.js +0 -2
- package/dist/chunk-OE7QVAI2.js +0 -5
- package/dist/chunk-SILJ3OL4.js +0 -9
- package/dist/chunk-SQKAXYIR.js +0 -2
- package/dist/chunk-VCGNVTXQ.js +0 -1
|
@@ -109,6 +109,7 @@ export function createAstSearchResolver(
|
|
|
109
109
|
);
|
|
110
110
|
const data = selectionData(selected.matches, selected.complete, session.id, session);
|
|
111
111
|
const captures: Record<string, ReturnType<typeof selectionData>["matches"]>[] = [];
|
|
112
|
+
const captureGroups: Record<string, { target: string; nodes: number }>[] = [];
|
|
112
113
|
for (const raw of selected.raw.slice(0, data.matches.length)) {
|
|
113
114
|
const groups = Object.entries({
|
|
114
115
|
...Object.fromEntries(
|
|
@@ -117,6 +118,7 @@ export function createAstSearchResolver(
|
|
|
117
118
|
...raw.metaVariables?.multi,
|
|
118
119
|
});
|
|
119
120
|
const projected = [];
|
|
121
|
+
const groupsForMatch: Record<string, { target: string; nodes: number }> = {};
|
|
120
122
|
for (const [name, nodes] of groups) {
|
|
121
123
|
for (const node of nodes) {
|
|
122
124
|
if (
|
|
@@ -130,6 +132,23 @@ export function createAstSearchResolver(
|
|
|
130
132
|
context.cwd,
|
|
131
133
|
context.signal,
|
|
132
134
|
);
|
|
135
|
+
const group = await registerSelection(
|
|
136
|
+
{
|
|
137
|
+
request,
|
|
138
|
+
matches,
|
|
139
|
+
complete: selected.complete,
|
|
140
|
+
refresh: async () => {
|
|
141
|
+
throw new Error("Capture snapshots cannot refresh; repeat the AST search.");
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
context,
|
|
145
|
+
);
|
|
146
|
+
groupsForMatch[name] = {
|
|
147
|
+
target: requiredValue(
|
|
148
|
+
selectionData(matches, selected.complete, undefined, group).target,
|
|
149
|
+
),
|
|
150
|
+
nodes: matches.length,
|
|
151
|
+
};
|
|
133
152
|
const nodesData: ReturnType<typeof selectionData>["matches"] = [];
|
|
134
153
|
// Shared Search previews hold 100 nodes. Register every capture chunk without dropping nodes.
|
|
135
154
|
for (let offset = 0; offset < matches.length; offset += 100) {
|
|
@@ -150,6 +169,7 @@ export function createAstSearchResolver(
|
|
|
150
169
|
projected.push([name, nodesData] as const);
|
|
151
170
|
}
|
|
152
171
|
captures.push(Object.fromEntries(projected));
|
|
172
|
+
captureGroups.push(groupsForMatch);
|
|
153
173
|
}
|
|
154
174
|
if (context.scope !== undefined) await verifyResultTargets(context.scope, context.signal);
|
|
155
175
|
return {
|
|
@@ -159,6 +179,7 @@ export function createAstSearchResolver(
|
|
|
159
179
|
...data,
|
|
160
180
|
matches: data.matches.map((match, index) => ({ ...match, captures: captures[index] })),
|
|
161
181
|
},
|
|
182
|
+
captureGroups,
|
|
162
183
|
pattern,
|
|
163
184
|
matches: selected.raw.map((match, index) => ({
|
|
164
185
|
...match,
|
|
@@ -181,7 +202,11 @@ export function createAstSearchResolver(
|
|
|
181
202
|
},
|
|
182
203
|
format(payload) {
|
|
183
204
|
const result = payload as {
|
|
205
|
+
readonly data: {
|
|
206
|
+
matches: { captures?: Record<string, ReturnType<typeof selectionData>["matches"]> }[];
|
|
207
|
+
};
|
|
184
208
|
readonly pattern: string;
|
|
209
|
+
readonly captureGroups: Record<string, { target: string; nodes: number }>[];
|
|
185
210
|
readonly sessionId: string;
|
|
186
211
|
readonly matches: readonly AstGrepMatch[];
|
|
187
212
|
readonly complete: boolean;
|
|
@@ -195,12 +220,16 @@ export function createAstSearchResolver(
|
|
|
195
220
|
};
|
|
196
221
|
}
|
|
197
222
|
|
|
198
|
-
const lines = result.matches.flatMap((match, index) =>
|
|
199
|
-
|
|
200
|
-
match.range.start.column + 1
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
223
|
+
const lines = result.matches.flatMap((match, index) => {
|
|
224
|
+
const rows = [
|
|
225
|
+
`SEARCH#${result.sessionId}:${index + 1}:match ${match.file}:${match.range.start.line + 1}:${match.range.start.column + 1} ${match.language}`,
|
|
226
|
+
` ${match.lines.trim()}`,
|
|
227
|
+
];
|
|
228
|
+
for (const [name, group] of Object.entries(result.captureGroups[index] ?? {})) {
|
|
229
|
+
rows.push(` capture ${name}: ${group.target} ${group.nodes} node(s)`);
|
|
230
|
+
}
|
|
231
|
+
return rows;
|
|
232
|
+
});
|
|
204
233
|
|
|
205
234
|
if (result.complete)
|
|
206
235
|
lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact AST matches.`);
|
|
@@ -120,7 +120,7 @@ function scopedOperation<const Kind extends "within" | "intersection" | "differe
|
|
|
120
120
|
scopes: {
|
|
121
121
|
...resultInputSchema,
|
|
122
122
|
description:
|
|
123
|
-
"Comparison scopes:
|
|
123
|
+
"Comparison scopes: unchanged results, issued UUIDs or item references, arrays of those strings, or a readable source path. Match sets by source, not array position.",
|
|
124
124
|
},
|
|
125
125
|
},
|
|
126
126
|
{ additionalProperties: false, description },
|
|
@@ -287,7 +287,7 @@ export const selectSchema = Type.Object(
|
|
|
287
287
|
path: {
|
|
288
288
|
...resultInputSchema,
|
|
289
289
|
description:
|
|
290
|
-
"
|
|
290
|
+
"File path, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Pass the whole result; do not rebuild it from preview text.",
|
|
291
291
|
},
|
|
292
292
|
operation: Type.Union([
|
|
293
293
|
structuralOperationSchema,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
withToolCallInterceptionRendering,
|
|
10
10
|
} from "pi-agent-tool-call-interception";
|
|
11
11
|
import { selectPresentation } from "./select-presentation.js";
|
|
12
|
+
|
|
12
13
|
import { selectStructuralRegions } from "./ast/selection.js";
|
|
13
14
|
import { publicRange } from "./selection-region.js";
|
|
14
15
|
import { selectTextRegions } from "./text-selection.js";
|
|
@@ -21,6 +22,22 @@ import {
|
|
|
21
22
|
type SelectParameters,
|
|
22
23
|
type GeometrySelectOperation,
|
|
23
24
|
} from "./select-schema.js";
|
|
25
|
+
/** Show selected text and opaque item references, never the internal selection record. */
|
|
26
|
+
function selectionText(data: SelectionData): string {
|
|
27
|
+
const rows = [`${data.totalItems} selection(s)${data.complete ? "" : " · incomplete input"}`];
|
|
28
|
+
if (data.missingInputs) rows.push(`${data.missingInputs} input(s) without a selection`);
|
|
29
|
+
for (const item of data.items) {
|
|
30
|
+
const range = item.range;
|
|
31
|
+
rows.push(
|
|
32
|
+
`${item.target} ${item.source}:${range.startLine}:${range.startColumn}–${range.endLine}:${range.endColumn}${item.syntax ? ` ${item.syntax.object}${item.syntax.part ? `/${item.syntax.part}` : ""}` : ""}`,
|
|
33
|
+
item.preview,
|
|
34
|
+
);
|
|
35
|
+
if (item.textTruncated)
|
|
36
|
+
rows.push("… preview shortened; reference retains the complete selection");
|
|
37
|
+
}
|
|
38
|
+
if (data.truncated) rows.push("… more selections retained in the whole result");
|
|
39
|
+
return rows.join("\n");
|
|
40
|
+
}
|
|
24
41
|
|
|
25
42
|
function operationLabel(operation: SelectParameters["operation"]): string {
|
|
26
43
|
switch (operation.kind) {
|
|
@@ -219,7 +236,7 @@ export async function registerSelect(pi: ExtensionAPI, read: ReadPluginApi): Pro
|
|
|
219
236
|
};
|
|
220
237
|
return withStructuredResult(
|
|
221
238
|
{
|
|
222
|
-
content: [{ type: "text", text:
|
|
239
|
+
content: [{ type: "text", text: selectionText(data) }],
|
|
223
240
|
details: selectPresentation(
|
|
224
241
|
selected.regions,
|
|
225
242
|
verified.complete,
|
|
@@ -42,9 +42,10 @@ export default async function registerGitChanges(pi: ExtensionAPI): Promise<void
|
|
|
42
42
|
id: "current-git-changes",
|
|
43
43
|
setup(api) {
|
|
44
44
|
api.addView({ view: "changes", presenter });
|
|
45
|
-
api.describe(
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
api.describe({
|
|
46
|
+
views:
|
|
47
|
+
"changes — uncommitted edits in tracked files, staged/unstaged state, and CHANGE# anchors for stage, unstage and undo.",
|
|
48
|
+
});
|
|
48
49
|
},
|
|
49
50
|
} satisfies ReadPlugin;
|
|
50
51
|
const editorPlugin = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-changes",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"diff": "^9.0.0",
|
|
16
|
-
"pi-agent-doctor": "0.7.
|
|
17
|
-
"pi-agent-documentation": "0.7.
|
|
18
|
-
"pi-agent-invariant": "0.7.
|
|
19
|
-
"pi-agent-read": "0.7.
|
|
20
|
-
"pi-agent-resource": "0.7.
|
|
21
|
-
"pi-agent-text": "0.7.
|
|
22
|
-
"pi-agent-text-editor": "0.7.
|
|
16
|
+
"pi-agent-doctor": "0.7.1",
|
|
17
|
+
"pi-agent-documentation": "0.7.1",
|
|
18
|
+
"pi-agent-invariant": "0.7.1",
|
|
19
|
+
"pi-agent-read": "0.7.1",
|
|
20
|
+
"pi-agent-resource": "0.7.1",
|
|
21
|
+
"pi-agent-text": "0.7.1",
|
|
22
|
+
"pi-agent-text-editor": "0.7.1"
|
|
23
23
|
},
|
|
24
24
|
"pi": {
|
|
25
25
|
"extensions": [
|
|
@@ -216,9 +216,11 @@ export default async function registerDebugger(pi: ExtensionAPI): Promise<void>
|
|
|
216
216
|
},
|
|
217
217
|
});
|
|
218
218
|
api.addView({ view: "breakpoints", presenter: breakpointPresenter });
|
|
219
|
-
api.describe(
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
api.describe({
|
|
220
|
+
path: "debug:<session> — debugger state.",
|
|
221
|
+
views:
|
|
222
|
+
"breakpoints — current debugger breakpoints beside source lines. Normal files include every current session; debug sources are session-scoped.",
|
|
223
|
+
});
|
|
222
224
|
},
|
|
223
225
|
} satisfies ReadPlugin;
|
|
224
226
|
const editorPlugin = {
|
|
@@ -135,9 +135,11 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
|
|
|
135
135
|
};
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
|
-
api.describe(
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
api.describe({
|
|
139
|
+
path: "diagnostics:<path> — lint and language-server diagnostics with reporting tool and readiness. Pending results and snapshots are not completed checks.",
|
|
140
|
+
views:
|
|
141
|
+
"diagnostics — diagnostics alongside source text, with reporting tool and readiness. Pending results and snapshots are not completed checks.",
|
|
142
|
+
});
|
|
141
143
|
},
|
|
142
144
|
} satisfies ReadPlugin;
|
|
143
145
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-formatter",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.7.
|
|
6
|
+
"pi-agent-doctor": "0.7.1"
|
|
7
7
|
},
|
|
8
8
|
"pi": {
|
|
9
9
|
"extensions": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@earendil-works/pi-coding-agent": "*",
|
|
15
|
-
"pi-agent-ide": "0.7.
|
|
15
|
+
"pi-agent-ide": "0.7.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"pi-agent-ide": {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lint",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.7.
|
|
7
|
-
"pi-agent-invariant": "0.7.
|
|
8
|
-
"pi-agent-read": "0.7.
|
|
9
|
-
"pi-agent-resource": "0.7.
|
|
10
|
-
"pi-agent-text": "0.7.
|
|
6
|
+
"pi-agent-doctor": "0.7.1",
|
|
7
|
+
"pi-agent-invariant": "0.7.1",
|
|
8
|
+
"pi-agent-read": "0.7.1",
|
|
9
|
+
"pi-agent-resource": "0.7.1",
|
|
10
|
+
"pi-agent-text": "0.7.1"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@earendil-works/pi-coding-agent": "*",
|
|
19
|
-
"pi-agent-ide": "0.7.
|
|
19
|
+
"pi-agent-ide": "0.7.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"pi-agent-ide": {
|
|
@@ -112,9 +112,9 @@ export default async function registerLsp(pi: ExtensionAPI): Promise<void> {
|
|
|
112
112
|
when: { resolvedBy: "any", contentKind: "text" },
|
|
113
113
|
handler: createSourceMappedTextReadHandler(),
|
|
114
114
|
});
|
|
115
|
-
api.describe(
|
|
116
|
-
"symbol:<file>#<selector> — declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> — top-level declarations, references and calls; members include selectors. graph:<file>#<selector> — references and incoming/outgoing calls for that declaration or member.",
|
|
117
|
-
);
|
|
115
|
+
api.describe({
|
|
116
|
+
path: "symbol:<file>#<selector> — declaration source, e.g. symbol:src/catalog.ts#Catalog/find. graph:<file> — top-level declarations, references and calls; members include selectors. graph:<file>#<selector> — references and incoming/outgoing calls for that declaration or member.",
|
|
117
|
+
});
|
|
118
118
|
},
|
|
119
119
|
} satisfies ReadPlugin;
|
|
120
120
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lsp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"cross-spawn": "^7.0.6",
|
|
7
|
-
"pi-agent-doctor": "0.7.
|
|
8
|
-
"pi-agent-invariant": "0.7.
|
|
9
|
-
"pi-agent-read": "0.7.
|
|
10
|
-
"pi-agent-resource": "0.7.
|
|
11
|
-
"pi-agent-search": "0.7.
|
|
12
|
-
"pi-agent-text": "0.7.
|
|
13
|
-
"pi-agent-text-editor": "0.7.
|
|
7
|
+
"pi-agent-doctor": "0.7.1",
|
|
8
|
+
"pi-agent-invariant": "0.7.1",
|
|
9
|
+
"pi-agent-read": "0.7.1",
|
|
10
|
+
"pi-agent-resource": "0.7.1",
|
|
11
|
+
"pi-agent-search": "0.7.1",
|
|
12
|
+
"pi-agent-text": "0.7.1",
|
|
13
|
+
"pi-agent-text-editor": "0.7.1",
|
|
14
14
|
"vscode-jsonrpc": "^9.0.0",
|
|
15
15
|
"vscode-uri": "^3.1.0"
|
|
16
16
|
},
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@earendil-works/pi-coding-agent": "*",
|
|
24
|
-
"pi-agent-ide": "0.7.
|
|
24
|
+
"pi-agent-ide": "0.7.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependenciesMeta": {
|
|
27
27
|
"pi-agent-ide": {
|
|
@@ -52,6 +52,7 @@ export function createLspSearchResolver(
|
|
|
52
52
|
payload: {
|
|
53
53
|
query,
|
|
54
54
|
hits: found.hits,
|
|
55
|
+
sessionId: session.id,
|
|
55
56
|
complete: found.complete,
|
|
56
57
|
navigation: request.navigation,
|
|
57
58
|
data: {
|
|
@@ -87,6 +88,7 @@ export function createLspSearchResolver(
|
|
|
87
88
|
format(payload, context) {
|
|
88
89
|
const result = payload as {
|
|
89
90
|
readonly query: string;
|
|
91
|
+
readonly sessionId: string;
|
|
90
92
|
readonly hits: readonly SymbolHit[];
|
|
91
93
|
readonly complete: boolean;
|
|
92
94
|
readonly navigation?: "references";
|
|
@@ -102,8 +104,10 @@ export function createLspSearchResolver(
|
|
|
102
104
|
.slice(0, 100)
|
|
103
105
|
.map(
|
|
104
106
|
(hit, index) =>
|
|
105
|
-
|
|
107
|
+
`SEARCH#${result.sessionId}:${index + 1}:match ${path.relative(context.cwd, hit.source)}:${hit.lineNumber}:${hit.startColumn + 1} ${hit.role} ${hit.symbol.name} · declared at ${path.relative(context.cwd, hit.symbol.source)}:${hit.symbol.range.startLine}:${hit.symbol.range.startColumn + 1}`,
|
|
106
108
|
);
|
|
109
|
+
if (result.complete && result.hits.length)
|
|
110
|
+
lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact symbol matches.`);
|
|
107
111
|
if (!result.complete) lines.push("Incomplete results; not a complete edit scope.");
|
|
108
112
|
if (result.hits.length > 100) lines.push("Preview shortened; full source targets retained.");
|
|
109
113
|
return {
|
|
@@ -185,9 +185,11 @@ export async function registerTerminalResources(
|
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
});
|
|
188
|
-
api.describe(
|
|
189
|
-
"shell:<session> — terminal status and a bounded output tail with a full-log path when truncated.
|
|
190
|
-
|
|
188
|
+
api.describe({
|
|
189
|
+
path: "shell:<session> — terminal status and a bounded output tail with a full-log path when truncated.",
|
|
190
|
+
views:
|
|
191
|
+
"On shell:<session>, image[:scale=S] returns the virtual terminal screen; sequence[:duration=D,interval=I,scale=S] returns ordered PNG frames. Defaults: D=2 seconds, I=0.5 seconds, S=1. Scale satisfies 0 < S <= 1; sequences require 0 < D <= 10, I > 0, and at most 20 frames (floor(D/I)+1). Terminal captures do not support region or image grid selection; offset/limit do not crop their frames.",
|
|
192
|
+
});
|
|
191
193
|
},
|
|
192
194
|
} satisfies ReadPlugin;
|
|
193
195
|
|
|
@@ -268,7 +270,7 @@ export async function registerTerminalResources(
|
|
|
268
270
|
content: [{ type: "text", text: message }],
|
|
269
271
|
details: event.details,
|
|
270
272
|
},
|
|
271
|
-
mutationDataSchema,
|
|
273
|
+
mutationDataSchema(event.toolName),
|
|
272
274
|
{
|
|
273
275
|
status: "error",
|
|
274
276
|
errors: [resultError(message, "UNSUPPORTED_OPERATION", requestedSource)],
|
|
@@ -302,7 +304,7 @@ export async function registerTerminalResources(
|
|
|
302
304
|
changedLines: [],
|
|
303
305
|
} satisfies TerminalActionDetails,
|
|
304
306
|
},
|
|
305
|
-
mutationDataSchema,
|
|
307
|
+
mutationDataSchema(event.toolName),
|
|
306
308
|
{
|
|
307
309
|
status: "success",
|
|
308
310
|
errors: [],
|
|
@@ -321,7 +323,7 @@ export async function registerTerminalResources(
|
|
|
321
323
|
],
|
|
322
324
|
details: { source: requestedSource, deleted: false },
|
|
323
325
|
},
|
|
324
|
-
mutationDataSchema,
|
|
326
|
+
mutationDataSchema(event.toolName),
|
|
325
327
|
{
|
|
326
328
|
status: "error",
|
|
327
329
|
errors: [resultError(error, "TERMINAL_DELETE_FAILED", requestedSource)],
|
|
@@ -127,10 +127,18 @@ export default async function registerVision(
|
|
|
127
127
|
return { kind: "continue", context };
|
|
128
128
|
},
|
|
129
129
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
api.describe({
|
|
131
|
+
path: () =>
|
|
132
|
+
`process:PID — process metadata. window:PID — capture a window of an IDE-owned or allowlisted process${pi.getFlag("pi-agent-ide-vision-arbitrary-windows") === true ? "; arbitrary windows are enabled" : "; other processes require --pi-agent-ide-vision-arbitrary-windows"}. display: or display:#N — display capture with a zero-based index; ${pi.getFlag("pi-agent-ide-vision-displays") === true ? "enabled" : "requires --pi-agent-ide-vision-displays"}. HTTP(S) URLs accept image or sequence screenshots.`,
|
|
133
|
+
views: () => {
|
|
134
|
+
const defaults = getVisionDefaults();
|
|
135
|
+
return `image or image:scale=S,region=X,Y,W,H — one screenshot. sequence or sequence:duration=D,interval=I,scale=S,region=X,Y,W,H — timed frames. Only one image/sequence view per request. duration and interval are seconds and only valid for sequence: 0 < D <= 10, I > 0, at most 20 frames (floor(D/I)+1). Scale satisfies 0 < S <= 1. Region uses normalized x,y,width,height: x,y >= 0, width,height > 0, and the rectangle must fit in 0..1; crop runs before scaling. Settings are optional; defaults: duration=${defaults.durationSeconds}, interval=${defaults.intervalSeconds}, scale=${defaults.scale}.`;
|
|
136
|
+
},
|
|
137
|
+
offset:
|
|
138
|
+
"For window:, display: and HTTP(S) image/sequence captures, a non-negative integer zero-based row-major grid cell index in the transformed image. Requires limit; omit to select cell 0 when limit is set.",
|
|
139
|
+
limit:
|
|
140
|
+
"For window:, display: and HTTP(S) image/sequence captures, a positive integer square grid cell size in output pixels. Omit both offset and limit for the bounded transformed image.",
|
|
141
|
+
});
|
|
134
142
|
},
|
|
135
143
|
}),
|
|
136
144
|
connectSearchPlugin(pi, {
|
package/dist/chunk-4NIFBFFR.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{d as B,h as M}from"./chunk-F5YZG77W.js";import{a as N}from"./chunk-VCGNVTXQ.js";import{h as w,i as P}from"./chunk-SQKAXYIR.js";import{a as y}from"./chunk-EI7MMDWY.js";import{Allow as $}from"partial-json";import{Guard as f}from"typebox-guard/guard";import{Allow as F,parse as H}from"partial-json";function _(o,e=F.ALL){if(!(!o||o.trim().length===0))try{let t=H(o,e);return t==null||typeof t!="object"||Array.isArray(t)?void 0:t}catch{return}}y(_,"resolvePartial");var R=class{static{y(this,"PartialToolRecoveryRegistry")}registrations=new Map;states=new Map;register(e){this.registrations.set(e.recoveryKey??e.toolName,e)}unregister(e){for(let[t,n]of this.registrations)(n.toolName===e||t===e)&&this.registrations.delete(t)}recoveryKeyFor(e){for(let[t,n]of this.registrations)if(n.toolName===e||n.toolNames?.includes(e)||t===e)return t}async recover(e){let t=this.states.get(e.contentIndex);if(t?.status==="done")return t.result;if(t?.status==="running")return t.promise;let n=this.registrations.get(e.recoveryKey??e.toolName);if(!n)return;let r=this.run(n,e);this.states.set(e.contentIndex,{status:"running",promise:r});let a=await r;return this.states.set(e.contentIndex,{status:"done",result:a}),a}cancel(e){this.states.delete(e)}cleanup(e){this.states.delete(e)}cleanupAll(){this.states.clear()}async run(e,t){let n=[],r=new Set(t.completedEntryIndexes),a=new Set(t.blockedEntryIndexes),i=e.extractEntries(t).filter(c=>{if(r.has(c.index))return n.push({index:c.index,reason:"entry already completed before recovery"}),!1;if(a.has(c.index))return n.push({index:c.index,reason:"entry was blocked by a guard"}),!1;let g=e.isCompleteEntry?.(c,t)??c.complete;return g||n.push({index:c.index,reason:t.recoverCompleteBatch?"entry was incomplete in the recovered batch":"entry was incomplete before the stale entry"}),!t.recoverCompleteBatch&&t.staleEntryIndex!==void 0&&c.index>=t.staleEntryIndex?!1:g}),s=e.filterEntries?.(i,t)??i,d=new Set(s.map(c=>c.index));for(let c of i)d.has(c.index)||n.push({index:c.index,reason:"entry was excluded by recovery filtering"});let u=[];for(let c of s)try{e.validateEntry?.(c,t),u.push(c)}catch(g){n.push({index:c.index,reason:g instanceof Error?g.message:String(g)})}let m={toolName:t.toolName,contentIndex:t.contentIndex,...t.staleEntryIndex!==void 0&&{staleEntryIndex:t.staleEntryIndex},staleDetails:t.staleDetails};if(u.length===0)return{...m,status:"skipped",appliedEntries:[],skippedEntries:n};try{let c=e.buildParams(u,t),g=await e.execute(c,{contentIndex:t.contentIndex,toolCallId:t.toolCallId,toolName:t.toolName,cwd:t.cwd,ctx:t.ctx,signal:new AbortController().signal});return{...m,status:"recovered",appliedEntries:e.getAppliedEntries?.(g,u,t)??u.map(b=>b.index),skippedEntries:n,normalResult:g}}catch(c){return{...m,status:"failed",appliedEntries:[],skippedEntries:n,error:c instanceof Error?c.message:String(c)}}}};import{createAssistantMessageEventStream as W}from"@earendil-works/pi-ai";var O=Symbol.for("pi-agent-text-editor.tool-call-interceptor.streaming-provider.state");function K(o,e,t,n){let r=new Map,a={context:void 0,processStreamEvent:e,markStreamEventProcessed:t,finalizeStreamInterception:n},l=y((i,s)=>{if(!i)return;let d=s.modelRegistry.getProvider(i.provider);if(!d)return;let u=r.get(i.provider);if(u){if(u.subscribers.add(a),u.api===i.api&&d.streamSimple===u.wrapper)return;u.api=i.api;let p=s.modelRegistry.getRegisteredProviderConfig(i.provider);o.registerProvider(i.provider,{...p,api:i.api,streamSimple:u.wrapper});return}let m=d.streamSimple[O];if(m){if(m.subscribers.add(a),r.set(i.provider,m),m.api===i.api)return;m.api=i.api;let p=s.modelRegistry.getRegisteredProviderConfig(i.provider);o.registerProvider(i.provider,{...p,api:i.api,streamSimple:m.wrapper});return}let c=d.streamSimple.bind(d),g=new Set([a]),b=y((p,v,C)=>U(c,p,v,C,g),"wrapper"),E={api:i.api,delegate:c,wrapper:b,subscribers:g};b[O]=E;let h=s.modelRegistry.getRegisteredProviderConfig(i.provider);o.registerProvider(i.provider,{...h,api:i.api,streamSimple:b}),r.set(i.provider,E)},"install");o.on("before_provider_request",(i,s)=>{a.context=s,l(s.model,s)}),o.on("turn_start",(i,s)=>{a.context=s,l(s.model,s)}),o.on("agent_start",(i,s)=>{a.context=s,l(s.model,s)}),o.on("session_start",(i,s)=>{a.context=s,l(s.model,s)}),o.on("model_select",(i,s)=>{a.context=s,l(i.model,s)}),o.on("session_shutdown",()=>{for(let[i,s]of r)s.subscribers.delete(a),s.subscribers.size===0&&o.unregisterProvider(i);r.clear(),a.context=void 0})}y(K,"registerStreamingInterceptorProvider");function U(o,e,t,n,r){let a=W(),l=new AbortController,i=n?.signal,s=!1,d=Y(e),u=new Set,m=new Set,c=new Set,g=new Set,b=y(h=>{for(let p of r)p.markStreamEventProcessed(h)},"markStreamEventProcessed"),E=y(()=>{l.abort()},"abortFromParent");return i&&(i.aborted?l.abort():i.addEventListener("abort",E,{once:!0})),(async()=>{try{let h=o(e,t,{...n,signal:l.signal});for await(let p of h){if(s)continue;p.type==="done"?d=structuredClone(p.message):p.type==="error"?d=structuredClone(p.error):d=structuredClone(p.partial),Q(p,u);let v;for(let C of r){let I=C.context;if(I){let T=await C.processStreamEvent(p,I);v??=T}}if(b(p),q(p,m,c,g),a.push(structuredClone(p)),v){if(p.type==="toolcall_delta"||p.type==="toolcall_end")for(let x of r)x.finalizeStreamInterception(p.contentIndex);s=!0,l.abort();let C=p.type==="toolcall_delta"||p.type==="toolcall_end"?p.contentIndex:void 0,I={...d,content:d.content.filter((x,A)=>u.has(A)&&(C===void 0||A<=C||g.has(A))).map(x=>x.type==="toolCall"&&x.id===v.toolCallId?{...x,arguments:structuredClone(v.arguments)}:x)};V(a,b,I,u,m,c,g);let{errorMessage:T,...L}=I;a.push({type:"done",reason:"toolUse",message:{...L,stopReason:"toolUse"}}),a.end();continue}if(p.type==="done"||p.type==="error"){a.end();return}}}catch(h){if(s)return;let p=d,v=i?.aborted===!0?"aborted":"error",C={...p,stopReason:v,errorMessage:h instanceof Error?h.message:String(h)};a.push({type:"error",reason:v,error:C}),a.end()}finally{i?.removeEventListener("abort",E)}})(),a}y(U,"wrapStream");function Q(o,e){(o.type==="text_start"||o.type==="thinking_start"||o.type==="toolcall_start")&&e.add(o.contentIndex)}y(Q,"rememberStartEvent");function q(o,e,t,n){switch(o.type){case"text_end":{e.add(o.contentIndex);break}case"thinking_end":{t.add(o.contentIndex);break}case"toolcall_end":{n.add(o.contentIndex);break}}}y(q,"rememberEndEvent");function V(o,e,t,n,r,a,l){for(let[i,s]of t.content.entries())if(n.has(i)){if(s.type==="text"&&!r.has(i)){let d={type:"text_end",contentIndex:i,content:s.text,partial:t};e(d),o.push(d)}else if(s.type==="thinking"&&!a.has(i)){let d={type:"thinking_end",contentIndex:i,content:s.thinking,partial:t};e(d),o.push(d)}else if(s.type==="toolCall"&&!l.has(i)){let d={type:"toolcall_end",contentIndex:i,toolCall:s,partial:t};e(d),o.push(d)}}}y(V,"emitMissingEndEvents");function Y(o){return{role:"assistant",content:[],api:o.api,provider:o.provider,model:o.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"toolUse",timestamp:Date.now()}}y(Y,"emptyAssistantMessage");var Z="agentic-ide-partial-tool-recovery",G="pi-agent-text-editor/tool-call-annotation",S=new WeakMap,k=class{constructor(e){this.pi=e;e.on("tool_call",t=>{let n=this.toolCallRecords.get(t.toolCallId),r=n?.blockExecution?n.guardResult:void 0;return r?{block:!0,reason:r.content.filter(l=>l.type==="text").map(l=>l.text).join(`
|
|
2
|
-
`)||`Tool call ${t.toolName} was blocked by a streaming interceptor.`}:void 0}),e.on("tool_result",t=>{let n=this.toolCallBatchEntryIndexes.get(t.toolCallId);n!==void 0&&this.completedBatchEntryIndexes.add(n);let r=this.toolCallRecords.get(t.toolCallId)?.guardResult;if(this.toolCallRecords.delete(t.toolCallId),r){let a=r.details,l=typeof a=="object"&&a!==null&&"effect"in a&&(a.effect==="not-applied"||a.effect==="applied")?a.effect:"unknown",i=r.content.flatMap(s=>s.type==="text"?[s.text]:[]).join(`
|
|
3
|
-
`);return P({content:r.content,details:a},N,{status:"error",errors:[w(i,"INTERCEPTED")],data:{operation:t.toolName,operationId:t.toolCallId,effect:l,files:[]}})}}),e.on("message_update",async(t,n)=>{let r=t.assistantMessageEvent;this.consumeProcessedStreamEvent(r)||await this.processStreamEvent(r,n)}),e.on("message_end",async t=>{if(await this.finalizeRecovery(),this.annotateIncompleteCalls(),t.message.role!=="assistant")return;let n=this.pendingAbortReason;if(this.pendingAbortReason=void 0,!(n===void 0||t.message.stopReason!=="aborted"))return{message:{...t.message,errorMessage:n}}}),e.on("agent_end",async()=>{await this.finalizeRecovery(),this.annotateIncompleteCalls(),this.cleanupAll()})}static{y(this,"InterceptorImpl")}handlers=new Map;recoveryRegistry=new R;pendingRecoveryBlocks=[];pendingAbortReason;recoveryAppliedBatchIndexes=new Set;partialBuffers=new Map;completeArgumentContentIndices=new Set;streamedBatchEntries=new Map;batchEntryIndexes=new Map;toolCallBatchEntryIndexes=new Map;completedBatchEntryIndexes=new Set;nextBatchEntryIndex=0;contentNames=new Map;contentToolCallIds=new Map;pendingToolCallAnnotations=new Map;emittedToolCallAnnotationKinds=new Map;abortedContentIndices=new Set;dispatchQueues=new Map;abortCleanups=new Map;processedStreamEvents=new WeakSet;processedStreamEventKeys=new Map;toolCallRecords=new Map;blockedCallSink;processStreamEvent(e,t){if(e.type==="toolcall_start"){let n=e.partial.content[e.contentIndex];if(n?.type==="toolCall"){let r=this.getOrCreateBatchEntryIndex(e.contentIndex);this.contentNames.set(e.contentIndex,n.name),typeof n.id=="string"&&this.bindToolCallId(e.contentIndex,n.id),this.partialBuffers.set(e.contentIndex,""),this.streamedBatchEntries.set(e.contentIndex,{index:r,toolName:n.name,args:{},complete:!1}),this.installAbortCleanup(e.contentIndex,t.signal)}return Promise.resolve(void 0)}return e.type==="toolcall_delta"?this.enqueue(e.contentIndex,async()=>{let n=this.contentNames.get(e.contentIndex),r=this.contentToolCallIds.get(e.contentIndex);if(!n)return;let a=(this.partialBuffers.get(e.contentIndex)??"")+e.delta;this.partialBuffers.set(e.contentIndex,a),this.installAbortCleanup(e.contentIndex,t.signal);let l=_(a,$.OBJ|$.ARR)??{},i=ee(a),s=this.getOrCreateBatchEntryIndex(e.contentIndex);this.streamedBatchEntries.set(e.contentIndex,{index:s,toolName:n,args:l,complete:i!==void 0});let d=this.handlers.get(n);if(!r||!d||d.length===0||!i&&Object.keys(l).length===0)return;let u=i!==void 0;if(u&&this.completeArgumentContentIndices.has(e.contentIndex))return;u&&this.completeArgumentContentIndices.add(e.contentIndex);let m=i??l,c=await this.dispatchHandlers(d,{toolCall:{id:r,name:n,arguments:m},args:m,...!u&&{partialArgs:l},batchEntryIndex:s,batchEntries:this.getBatchEntries(s),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t});return c&&this.rememberOriginalArguments(c.toolCallId,c.arguments),c}):e.type==="toolcall_end"?this.enqueue(e.contentIndex,async()=>{let n=e.toolCall.name,r=this.handlers.get(n),a=this.getOrCreateBatchEntryIndex(e.contentIndex);this.bindToolCallId(e.contentIndex,e.toolCall.id);let l=this.toolCallRecords.get(e.toolCall.id);this.toolCallRecords.set(e.toolCall.id,{originalArguments:structuredClone(e.toolCall.arguments),...l?.guardResult&&{guardResult:l.guardResult},...l?.blockExecution&&{blockExecution:!0}}),this.streamedBatchEntries.set(e.contentIndex,{index:a,toolName:n,args:e.toolCall.arguments,complete:!1});let i=!this.completeArgumentContentIndices.has(e.contentIndex),s;i&&(this.completeArgumentContentIndices.add(e.contentIndex),s=r&&r.length>0?await this.dispatchHandlers(r,{toolCall:e.toolCall,args:e.toolCall.arguments,batchEntryIndex:a,batchEntries:this.getBatchEntries(a),contentIndex:e.contentIndex,cwd:t.cwd,signal:t.signal,ctx:t}):void 0);let d=this.streamedBatchEntries.get(e.contentIndex);return d&&this.streamedBatchEntries.set(e.contentIndex,{...d,complete:!0}),this.cleanupContent(e.contentIndex,n),s}):Promise.resolve(void 0)}markStreamEventProcessed(e){this.processedStreamEvents.add(e);let t=j(e);t!==void 0&&this.processedStreamEventKeys.set(t,(this.processedStreamEventKeys.get(t)??0)+1)}consumeProcessedStreamEvent(e){let t=this.processedStreamEvents.delete(e),n=j(e);if(n===void 0)return t;let r=this.processedStreamEventKeys.get(n)??0;return r===0?t:(r===1?this.processedStreamEventKeys.delete(n):this.processedStreamEventKeys.set(n,r-1),!0)}finalizeStreamInterception(e){this.cleanupTransientContent(e,void 0,!0)}getToolCallRecord(e){return this.toolCallRecords.get(e)}rememberOriginalArguments(e,t){let n=this.toolCallRecords.get(e);n&&this.toolCallRecords.set(e,{originalArguments:structuredClone(t),...n.guardResult&&{guardResult:n.guardResult},...n.blockExecution&&{blockExecution:!0}})}async dispatchHandlers(e,t){for(let n of e){let r=await n.intercept(t);if(r!==void 0){this.pendingRecoveryBlocks.push({blocked:r,ctx:t});let a={content:[{type:"text",text:r.message.content}],details:r.message.details??null};return this.blockedCallSink?.({callId:t.toolCall.id,toolName:t.toolCall.name,arguments:structuredClone(t.args),...t.contentIndex!==void 0&&{contentIndex:t.contentIndex},...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},...r.message.details!==void 0&&{details:r.message.details},result:a,nativeExecutionBlocked:n.blockExecution===!0}),{toolCallId:t.toolCall.id,arguments:structuredClone(t.args),result:this.abortToolCall(r,t,n.name,n.blockExecution===!0)}}}}annotateIncompleteCalls(){for(let[e,t]of this.streamedBatchEntries)!t.complete&&this.contentNames.has(e)&&!this.recoveryAppliedBatchIndexes.has(t.index)&&!this.emittedToolCallAnnotationKinds.get(e)?.has("stale-anchor")&&this.annotateContent(e,{kind:"aborted"})}bindToolCallId(e,t){this.contentToolCallIds.set(e,t);let n=this.batchEntryIndexes.get(e);n!==void 0&&this.toolCallBatchEntryIndexes.set(t,n);let r=this.pendingToolCallAnnotations.get(e);if(r){for(let a of r)this.emitToolCallAnnotation(t,a);this.pendingToolCallAnnotations.delete(e)}}annotateContent(e,t){let n=this.emittedToolCallAnnotationKinds.get(e)??new Set;if(n.has(t.kind))return;n.add(t.kind),this.emittedToolCallAnnotationKinds.set(e,n);let r=this.contentToolCallIds.get(e);if(r){this.emitToolCallAnnotation(r,t);return}let a=this.pendingToolCallAnnotations.get(e)??[];a.push(t),this.pendingToolCallAnnotations.set(e,a)}emitToolCallAnnotation(e,t){let n={toolCallId:e,annotation:t};this.pi.events.emit(G,n)}getOrCreateBatchEntryIndex(e){let t=this.batchEntryIndexes.get(e);if(t!==void 0)return t;let n=this.nextBatchEntryIndex;return this.nextBatchEntryIndex+=1,this.batchEntryIndexes.set(e,n),n}getBatchEntries(e){return[...this.streamedBatchEntries.values()].filter(t=>t.index<=e).sort((t,n)=>t.index-n.index)}getAllBatchEntries(){return[...this.streamedBatchEntries.values()].sort((e,t)=>e.index-t.index)}abortToolCall(e,t,n,r){let a=X(e,n),l=e.annotation?e.annotation.kind==="aborted"&&e.annotation.label===void 0?{...e.annotation,label:a}:e.annotation:e.message.customType==="text-editor-stale-anchor-block"?{kind:"stale-anchor",label:a}:{kind:"aborted",label:a,color:"error"};t.contentIndex!==void 0&&(this.abortedContentIndices.add(t.contentIndex),this.annotateContent(t.contentIndex,l));let i={content:[{type:"text",text:e.message.content}],details:B(e.message.details,l,a)};return this.toolCallRecords.set(t.toolCall.id,{originalArguments:structuredClone(t.args),guardResult:i,...r&&{blockExecution:!0}}),i}async finalizeRecovery(){let e=this.pendingRecoveryBlocks.splice(0);if(e.length===0)return;let t=new Map;for(let n of e){let r=this.recoveryRegistry.recoveryKeyFor(n.ctx.toolCall.name);if(r===void 0)continue;let a=t.get(r)??[];a.push(n),t.set(r,a)}for(let n of t.values()){let r=n[0];if(!r)continue;let a=await this.recoverIfNeeded(r.blocked,r.ctx,this.getAllBatchEntries(),n);if(a===r.blocked)continue;let l=a.message.details,s=(f.IsObjectNotArray(l)&&f.IsObjectNotArray(l.recovery)?l.recovery:void 0)?.appliedEntries;if(Array.isArray(s))for(let d of s)typeof d=="number"&&this.recoveryAppliedBatchIndexes.add(d)}}async recoverIfNeeded(e,t,n,r){if(t.contentIndex===void 0)return e;let a=e.message.details,l=f.IsObjectNotArray(a)&&typeof a.entryIndex=="number"?a.entryIndex:void 0,i=[...new Set(r.map(g=>g.ctx.batchEntryIndex).filter(g=>g!==void 0))],s=[...new Set(r.map(g=>g.ctx.toolCall.id))],d=r.map(g=>g.blocked.message.details),u=r[0],m=u?this.recoveryRegistry.recoveryKeyFor(u.ctx.toolCall.name):void 0;if(!m)return e;let c=await this.recoveryRegistry.recover({contentIndex:t.contentIndex,toolCallId:t.toolCall.id,toolName:t.toolCall.name,...l!==void 0&&{staleEntryIndex:l},staleDetails:a,...t.partialArgs&&{partialArgs:t.partialArgs},args:t.args,batchEntries:n,...t.batchEntryIndex!==void 0&&{batchEntryIndex:t.batchEntryIndex},recoverCompleteBatch:!0,completedEntryIndexes:[...this.completedBatchEntryIndexes],blockedEntryIndexes:i,blockedToolCallIds:s,blockedDetails:d,recoveryKey:m,cwd:t.cwd,ctx:t.ctx});return c&&(c.appliedEntries.length>0||c.skippedEntries.length>0)?re(e,c):e}async enqueue(e,t){let r=(this.dispatchQueues.get(e)??Promise.resolve()).catch(()=>{}).then(t);this.dispatchQueues.set(e,r);try{return await r}finally{this.dispatchQueues.get(e)===r&&this.dispatchQueues.delete(e)}}installAbortCleanup(e,t){if(!t||this.abortCleanups.has(e))return;let n=y(()=>{let r=this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let l of a??[])l.onAbort?.(e)},"listener");t.addEventListener("abort",n,{once:!0}),this.abortCleanups.set(e,()=>{t.removeEventListener("abort",n)})}cleanupContent(e,t){this.cleanupTransientContent(e,t),this.recoveryRegistry.cleanup(e)}cleanupTransientContent(e,t,n=!1){let r=t??this.contentNames.get(e),a=r?this.handlers.get(r):void 0;for(let l of a??[])n&&l.onAbort?.(e),l.onContentEnd?.(e);this.abortCleanups.get(e)?.(),this.abortCleanups.delete(e),this.contentNames.delete(e),this.contentToolCallIds.delete(e),this.pendingToolCallAnnotations.delete(e),this.emittedToolCallAnnotationKinds.delete(e),this.completeArgumentContentIndices.delete(e),this.partialBuffers.delete(e),this.abortedContentIndices.delete(e)}cleanupAll(){for(let e of this.handlers.values())for(let t of e)t.onAgentEnd?.();for(let e of this.abortCleanups.values())e();this.abortCleanups.clear(),this.contentNames.clear(),this.contentToolCallIds.clear(),this.pendingToolCallAnnotations.clear(),this.completeArgumentContentIndices.clear(),this.emittedToolCallAnnotationKinds.clear(),this.partialBuffers.clear(),this.streamedBatchEntries.clear(),this.batchEntryIndexes.clear(),this.toolCallBatchEntryIndexes.clear(),this.toolCallRecords.clear(),this.completedBatchEntryIndexes.clear(),this.nextBatchEntryIndex=0,this.abortedContentIndices.clear(),this.pendingAbortReason=void 0,this.dispatchQueues.clear(),this.processedStreamEventKeys.clear(),this.recoveryRegistry.cleanupAll(),this.pendingRecoveryBlocks.length=0,this.recoveryAppliedBatchIndexes.clear()}registerRecovery(e){this.recoveryRegistry.register(e)}unregisterRecovery(e){this.recoveryRegistry.unregister(e)}registerBlockedCallSink(e){this.blockedCallSink=e}register(e){let t=new Set(e.toolNames);for(let[n,r]of this.handlers){let a=r.findIndex(l=>l.name===e.name);a!==-1&&(t.has(n)?(r[a]=e,t.delete(n)):r.splice(a,1))}for(let n of t){let r=this.handlers.get(n)??[];r.push(e),this.handlers.set(n,r)}}unregister(e){for(let[t,n]of this.handlers)this.handlers.set(t,n.filter(r=>r.name!==e))}};function j(o){if(o.type==="toolcall_end")return`${o.type}\0${o.contentIndex}\0${o.toolCall.id}`;if(o.type!=="toolcall_start"&&o.type!=="toolcall_delta")return;let e=o.partial.content[o.contentIndex],t=e?.type==="toolCall"?e.id:"",n=o.type==="toolcall_delta"?o.delta:"";return`${o.type}\0${o.contentIndex}\0${t}\0${n}`}y(j,"toolStreamEventKey");function X(o,e){return o.annotation?.reason?o.annotation.reason:o.annotation?.label?o.annotation.label:o.message.customType==="text-editor-stale-anchor-block"?"Stale Anchor":e.replace(/[-_]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())||"Blocked"}y(X,"abortReason");function ee(o){try{let e=JSON.parse(o);return f.IsObjectNotArray(e)?e:void 0}catch{return}}y(ee,"parseCompleteArguments");function te(o){let e=o.normalResult;if(!f.IsObjectNotArray(e)||!f.IsObjectNotArray(e.details))return[];let t=e.details.results;if(!Array.isArray(t))return[];let n=f.IsObjectNotArray(o.staleDetails)&&typeof o.staleDetails.path=="string"?o.staleDetails.path:void 0,r=t.filter(f.IsObjectNotArray).map(s=>f.IsObjectNotArray(s.data)?s.data:s),a=n===void 0?r:r.filter(s=>s.path===n),i=(a.length>0?a:r).flatMap(s=>{let d=s.freshAnchors;return Array.isArray(d)?d.filter(u=>typeof u=="string"):[]});return[...new Set(i)]}y(te,"freshAnchorsAfterRecovery");function ne(o,e){let n=o.indexOf(`
|
|
4
|
-
|
|
5
|
-
Current nearby anchors:`);return`${n===-1?o:o.slice(0,n)}
|
|
6
|
-
|
|
7
|
-
Current nearby anchors:
|
|
8
|
-
${e.map(a=>` ${a}`).join(`
|
|
9
|
-
`)}`}y(ne,"replaceCurrentAnchors");function re(o,e){let t=e.appliedEntries.length,n=t>0?`${t} (indices: ${e.appliedEntries.join(", ")})`:"0",r=e.skippedEntries.length>0?e.skippedEntries.map(u=>`${u.index} (${u.reason})`).join(", "):"none",a=e.error?`Recovery execution failed: ${e.error}.`:"Recovery execution completed.",l=te(e),i=l.length>0&&f.IsObjectNotArray(o.message.details)?{...o.message.details,freshAnchors:l}:o.message.details,s=l.length>0?ne(o.message.content,l):o.message.content,d=l.length>0&&f.IsObjectNotArray(e.staleDetails)?{...e,staleDetails:{...e.staleDetails,freshAnchors:l}}:e;return{message:{customType:Z,content:`${s}
|
|
10
|
-
|
|
11
|
-
[RECOVERY] Status: ${e.status}. Applied entries: ${n}. Skipped entries: ${r}. ${a}`,display:!1,details:{blocked:i,recovery:d}}}}y(re,"makeRecoveryResult");var D=new WeakMap;function z(o){let e=D.get(o);if(e)return e;let t=new k(o);return D.set(o,t),K(o,(n,r)=>t.processStreamEvent(n,r),n=>{t.markStreamEventProcessed(n)},n=>{t.finalizeStreamInterception(n)}),t}y(z,"coordinatorFor");function oe(o,e){z(o).register(e)}y(oe,"registerToolCallInterceptor");function ae(o,e){if(S.get(o)?.(),S.delete(o),e===void 0)return;let t=o.events.on(G,n=>{!f.IsObjectNotArray(n)||typeof n.toolCallId!="string"||!M(n.annotation)||e(n.toolCallId,n.annotation)});S.set(o,t)}y(ae,"registerToolCallAnnotationSink");function Ee(o,e){z(o).registerBlockedCallSink(e)}y(Ee,"registerBlockedToolCallSink");export{oe as a,ae as b,Ee as c};
|
package/dist/chunk-7LZKOHH2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as f,i as p,m}from"./chunk-SQKAXYIR.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Type as r}from"typebox";import{Value as u}from"typebox/value";import{Type as d}from"typebox";var T=d.Object({path:d.Optional(d.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:d.Optional(d.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:d.Optional(d.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:d.Optional(d.Array(d.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))});import{Type as t}from"typebox";var O=t.Object({value:t.String(),kind:t.String(),state:t.Optional(t.String())},{additionalProperties:!1}),L=t.Object({lineNumber:t.Integer(),content:t.String(),lineEnding:t.String(),anchors:t.Optional(t.Array(t.String()))},{additionalProperties:!1}),k=t.Object({path:t.String(),offset:t.Integer()},{additionalProperties:!1}),y={source:t.String(),truncated:t.Boolean(),continuation:t.Optional(k),fullResult:t.Optional(t.String())},x=t.Object({...y,kind:t.Literal("text"),target:t.Optional(t.String()),lines:t.Array(L),startLine:t.Integer(),endLine:t.Integer(),totalLines:t.Integer(),references:t.Optional(t.Array(O))},{additionalProperties:!1}),b=t.Object({...y,kind:t.Literal("bytes"),bytes:t.Array(t.Integer({minimum:0,maximum:255})),byteOffset:t.Integer(),byteLength:t.Integer(),totalBytes:t.Integer()},{additionalProperties:!1}),C=t.Union([t.Object({type:t.Literal("text"),text:t.String()},{additionalProperties:!1}),t.Object({type:t.Literal("image"),data:t.String(),mimeType:t.String()},{additionalProperties:!1})]),h=t.Object({...y,kind:t.Literal("native"),blocks:t.Array(C)},{additionalProperties:!1}),c=t.Union([t.Object({kind:t.Literal("recovery"),source:t.String(),candidates:t.Array(t.Object({path:t.String()},{additionalProperties:!1}))},{additionalProperties:!1}),x,b,h,t.Object({kind:t.Literal("resources"),source:t.Optional(t.String()),resources:t.Array(t.Union([x,b,h])),truncated:t.Boolean(),fullResult:t.Optional(t.String())},{additionalProperties:!1})]),P=f(c);function w(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}i(w,"publicLine");function S(e){if(e.kind==="resources"){let o=e.resources.map(s=>S(s));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:o,truncated:o.some(s=>typeof s=="object"&&s!==null&&"truncated"in s&&s.truncated===!0)}}if(e.kind==="bytes"){let o=e.bytes.slice(0,32768),s=e.truncated===!0||o.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:o,byteOffset:e.byteOffset,byteLength:o.length,totalBytes:e.totalBytes,truncated:s,...e.byteOffset+o.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+o.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(o=>{if(o.type==="text")return{type:o.type,text:o.text};if(o.type==="image")return{type:o.type,data:o.data,mimeType:o.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let n=[],a=0;for(let o of e.lines){let s=w(o);if(a+=Buffer.byteLength(JSON.stringify(s)),n.length>=2e3||a>512*1024)break;n.push(s)}if(n.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let R=n.length<e.lines.length,g=n.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,lines:n,startLine:n[0]?.lineNumber??0,endLine:n.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:R,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...R||g<e.totalLines?{continuation:{path:e.source,offset:g+1}}:{}}}i(S,"publicData");function E(e){let n=e.details.failure;if(e.isError||n!==void 0)return p(e,c,{status:"error",...n?.candidates?.length&&n.source!==void 0?{data:{kind:"recovery",source:n.source,candidates:n.candidates}}:{},errors:[{code:n?.code??"READ_FAILED",message:n?.message??"Read failed",...n?.source===void 0?{}:{source:n.source}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let a=S(e.script);return p(e,c,{status:"success",data:e.details.temporarySource!==void 0&&typeof a=="object"&&a!==null?{...a,fullResult:e.details.temporarySource}:a,errors:[]})}catch(a){return p(e,c,{status:"error",errors:[{code:a instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:a instanceof Error?a.message:String(a)}]})}}i(E,"structuredRead");var l=r.Function([],r.Unknown()),v=r.Object({resolver:r.Unknown(),matchesCall:r.Optional(l),renderCall:r.Optional(l),priority:r.Optional(r.Number()),renderResult:r.Optional(l),preserveTruncatedOutput:r.Optional(r.Boolean())}),D=r.Object({resolver:r.Unknown(),priority:r.Optional(r.Number())}),A=r.Object({id:r.String({pattern:"\\S"}),priority:r.Optional(r.Number()),resolve:l}),N=r.Object({view:r.String({pattern:"\\S"}),includes:r.Optional(r.Array(r.String({pattern:"\\S"}))),presenter:r.Object({id:r.String(),present:l}),priority:r.Optional(r.Number())}),F=r.Object({resolvedBy:r.String({pattern:"\\S"}),contentKind:r.Union([r.Literal("text"),r.Literal("any")])}),U=r.Union([r.Object({stage:r.Literal("pre-read"),handler:l}),r.Object({stage:r.Literal("read"),when:F,handler:l}),r.Object({stage:r.Literal("post-read"),handler:l})]);function W(e){if(!u.Check(D,e))return!1;let n=e,a=n.resolver;return typeof a.id=="string"&&a.id.length>0&&typeof a.tryResolve=="function"&&(!("priority"in n)||typeof n.priority=="number")}i(W,"isTextTargetResolverRegistration");function M(e){if(!u.Check(v,e))return!1;let n=e;return m(n.resolver)?n.resolver.id!=="any"&&(!("priority"in n)||typeof n.priority=="number")&&(!("matchesCall"in n)||typeof n.matchesCall=="function")&&(!("renderCall"in n)||typeof n.renderCall=="function")&&"matchesCall"in n=="renderCall"in n&&(!("renderResult"in n)||typeof n.renderResult=="function"):!1}i(M,"isResourceResolverRegistration");function Q(e){return u.Check(U,e)}i(Q,"isReadHandlerRegistration");function J(e){return u.Check(N,e)}i(J,"isReadViewRegistration");function Y(e){return u.Check(A,e)}i(Y,"isFragmentResolverRegistration");function X(e){return I(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}i(X,"isReadFragmentResolution");function I(e){return typeof e=="object"&&e!==null}i(I,"isRecord");export{T as a,c as b,P as c,E as d,W as e,M as f,Q as g,J as h,Y as i,X as j};
|
package/dist/chunk-FK42RSF4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as d,e as c}from"./chunk-SQKAXYIR.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var y=t.Object({query:t.String({minLength:1,description:"Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching."}),path:t.Optional({...d,description:"File, directory, URL, or a source-aware Read/Search/Select/mutation result with a live target, RESULT# reference, or array of returned targets. Result scopes search only their exact ranges unless symbols: navigation explicitly follows external references; plain preview text is not a source."}),navigation:t.Optional(t.Literal("references",{description:"Only for symbols: queries. Explicitly follow symbols represented inside path to their references outside that scope. Without navigation, all returned ranges stay inside path."})),include:t.Optional(t.String({description:"Optional include glob for local search"})),exclude:t.Optional(t.String({description:"Optional exclude glob for local search"})),caseSensitive:t.Optional(t.Boolean({description:"Match letter case"})),wholeWord:t.Optional(t.Boolean({description:"Match complete words"})),limit:t.Optional(t.Integer({minimum:1,maximum:1e3,description:"Maximum detailed results returned to the agent (default 50)"}))},{additionalProperties:!1});import{Type as e}from"typebox";var u=e.Object({startLine:e.Integer(),startColumn:e.Integer(),endLine:e.Integer(),endColumn:e.Integer()},{additionalProperties:!1}),m=e.Object({line:e.Optional(e.String()),match:e.Optional(e.String())},{additionalProperties:!1}),p={source:e.String(),target:e.Optional(e.String()),range:u,matchedText:e.Optional(e.String()),textTruncated:e.Optional(e.Boolean()),references:e.Optional(m)},f=e.Object({...p,captures:e.Optional(e.Record(e.String(),e.Array(e.Object(p,{additionalProperties:!1})))),role:e.Optional(e.Union([e.Literal("definition"),e.Literal("reference")])),symbol:e.Optional(e.Object({id:e.String(),name:e.String(),kind:e.String(),source:e.String(),range:u},{additionalProperties:!1}))},{additionalProperties:!1}),g={target:e.Optional(e.String()),kind:e.Literal("matches"),truncated:e.Optional(e.Boolean()),fullResult:e.Optional(e.String()),complete:e.Boolean(),matches:e.Array(f),all:e.Optional(m),notices:e.Optional(e.Array(e.String()))},h=e.Object({status:e.Union([e.Literal("ready"),e.Literal("skipped")]),message:e.Optional(e.String()),candidates:e.Array(e.Object({identifier:e.String(),kind:e.Union([e.Literal("normalized"),e.Literal("component"),e.Literal("typo")]),reason:e.String(),matchCount:e.Integer(),fileCount:e.Integer(),selection:e.Object(g,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),O=e.Union([e.Object({...g,fuzzy:e.Optional(h)},{additionalProperties:!1}),e.Object({kind:e.Literal("files"),complete:e.Boolean(),files:e.Array(e.String())},{additionalProperties:!1}),e.Object({kind:e.Literal("custom"),resolverId:e.String(),value:e.Unknown()},{additionalProperties:!1})]),T=c(O);function P(o,l,n,i){return{kind:"matches",...i?.target===void 0?{}:{target:i.target},truncated:o.length>100,complete:l,matches:o.slice(0,100).map((r,a)=>({source:r.source,...i?.matchTargets?.[a]===void 0?{}:{target:i.matchTargets[a]},range:{startLine:r.lineNumber,startColumn:r.startColumn,endLine:r.endLineNumber??r.lineNumber,endColumn:r.endColumn},...Buffer.byteLength(r.matchedText)<=4096?{matchedText:r.matchedText}:{textTruncated:!0},...n===void 0?{}:{references:{line:`SEARCH#${n}:${a+1}:line`,match:`SEARCH#${n}:${a+1}:match`}}})),...l&&n!==void 0?{all:{line:`SEARCH#${n}:all:line`,match:`SEARCH#${n}:all:match`}}:{}}}s(P,"selectionData");export{y as a,h as b,O as c,T as d,P as e};
|
package/dist/chunk-KBP3QUDT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{e as E,f as b}from"./chunk-T7I2VX3J.js";import{d as M}from"./chunk-KR36BT5E.js";import"./chunk-FXNKMNSJ.js";import"./chunk-NNCZYO4Q.js";import{d as q}from"./chunk-64M3SQPG.js";import{a as T}from"./chunk-6CZO43OH.js";import{a as N,b as O}from"./chunk-OBNING2A.js";import"./chunk-PS2B6THP.js";import"./chunk-SQKAXYIR.js";import{e as h,f as w,g as P,h as k,i as y,l as I}from"./chunk-KVHDMIZS.js";import"./chunk-ZPT5D4VP.js";import{a as A}from"./chunk-QDLTO5PH.js";import{a as v,b as C}from"./chunk-QIK2E64R.js";import"./chunk-KINKBPPX.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import H from"node:path";var S="diagnostics",L=q({kind:"code-view",label:"Diagnostics"});async function V(r){b(r,[await E({id:"diagnostics",description:"Diagnostic resources, readiness, and verification",triggers:[{tool:"read",resourcePrefixes:["diagnostics:"]}]})]);let n,t=l((c,f,e)=>{if(n===void 0)throw new Error("IDE diagnostics are not connected");return n(c,{cwd:f,...e})},"collect"),i={protocol:v,apiVersion:4,id:"diagnostics",setup(c){n=c.readDiagnostics}},o=new WeakMap,s=new WeakMap,a=new WeakMap,u=new WeakMap,W={protocol:N,apiVersion:O,id:"diagnostics",setup(c){c.addResolver({resolver:j(t,s),renderResult:L});let f=I();c.addView({view:"diagnostics",priority:100,presenter:B(t,u)}),c.addHandler({stage:"read",when:{resolvedBy:"any",contentKind:"text"},handler(e){if(e.state?.resolvedBy==="diagnostics"){let p=e.state.content[0],g=s.get(p);return g&&o.set(e.request,g),f(e)}return e.state?.contentKind==="text"&&e.request.views?.includes("diagnostics")&&a.set(e.request,e.state.text),{kind:"continue",context:e}}}),c.addHandler({stage:"post-read",handler(e){let p=o.get(e.request);if(p&&e.result)return{kind:"continue",context:e,transform:l(d=>({...d,details:{...d.details,diagnosticCheck:p}}),"transform")};let g=a.get(e.request),m=g&&u.get(g),D=e.result,_=D?.content[0];return!m||!D||_?.type!=="text"?{kind:"continue",context:e}:{kind:"continue",context:e,transform(d){let R=d.content[0];return R?.type!=="text"?d:{...d,content:[{...R,text:`${m}
|
|
2
|
-
${R.text}`},...d.content.slice(1)]}}}}}),c.describe('diagnostics:<path> \u2014 lint and language-server diagnostics. views: ["diagnostics"] \u2014 diagnostics alongside source text. Results identify their reporting tool and readiness; pending results and snapshots are not completed checks.')}};await Promise.all([A(r,i),T(r,W)])}l(V,"registerDiagnostics");function j(r,n){return{id:"diagnostics",tryResolve(t,i){return Promise.resolve(x(t,i.cwd,r,n,{signal:i.signal,...i.audience==="script"&&{mode:"complete"}}))}}}l(j,"createDiagnosticResolver");function x(r,n,t,i,o){let s;try{s=h(r,S,n)}catch(a){return{kind:"failed",error:a}}return s===void 0?{kind:"not-handled"}:{kind:"resolved",resource:{source:w(S,s),async read(){let a=await t(s,n,o),u=P(s,a.content,a.results);return i.set(u,u.diagnosticCheck),[u]}}}}l(x,"resolveDiagnosticSource");function B(r,n){return{id:"diagnostics",async present(t,i){if(i.purpose!=="read"||!H.isAbsolute(t.source))return t;let o=i.audience==="script"&&!i.requestedViews?.includes("diagnostics");if(o&&M(t.source))return t;let s=await r(t.source,i.cwd,{signal:i.signal,...i.audience==="script"&&{mode:o?"snapshot":"complete"}}).catch(a=>{if(i.signal?.throwIfAborted(),!o)throw a});if(s===void 0||o&&s.content!==t.content)return t;if(s.content!==t.content)throw new Error("File changed during diagnostic read; read it again for current source lines.");return n.set(t,y(s.results)),k(t,s.results)}}}l(B,"createDiagnosticPresenter");export{V as default};
|
package/dist/chunk-OE7QVAI2.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as z}from"./chunk-M5IVSCR2.js";import{e as V,f as q}from"./chunk-T7I2VX3J.js";import{a as O}from"./chunk-6CZO43OH.js";import{a as k,b as T}from"./chunk-OBNING2A.js";import{a as _}from"./chunk-ZTYWHL2F.js";import{a as L,b as W}from"./chunk-7UGNGK7Y.js";import{a as U}from"./chunk-PS2B6THP.js";import{a as c}from"./chunk-EI7MMDWY.js";import{execFile as te}from"node:child_process";import re from"node:os";import{promisify as oe}from"node:util";import{createCanvas as B,loadImage as se}from"@napi-rs/canvas";var w=oe(te),I=20*1024*1024,H={durationSeconds:2,intervalSeconds:.5,scale:.5},j=new Set;function G(e){let n=R({mode:"sequence",durationSeconds:Number(e.durationSeconds??2),intervalSeconds:Number(e.intervalSeconds??.5),scale:Number(e.scale??.5)});H={durationSeconds:n.durationSeconds,intervalSeconds:n.intervalSeconds,scale:n.scale},j=new Set((e.allowedExecutables??"").split(",").map(r=>r.trim().toLowerCase()).filter(Boolean))}c(G,"configureVision");function y(){return H}c(y,"getVisionDefaults");function J(e){let n=e.includes("\\")?e.slice(e.lastIndexOf("\\")+1):e,r=n.trim().split(/\s+/u)[0]??"",t=r.slice(r.lastIndexOf("/")+1);return j.has((e.includes("\\")?n:t).toLowerCase())}c(J,"isExecutableAllowed");function X(e,n){let r=e?.filter(s=>/^(?:image|sequence)(?::|$)/u.test(s))??[];if(r.length===0)return;if(r.length>1)throw new Error("Use only one image or sequence view");let t=r[0],i=t.indexOf(":"),a=t.slice(0,i<0?void 0:i),o={};if(i>=0&&ie(t.slice(i+1),o),a==="image"&&(o.duration!==void 0||o.interval!==void 0))throw new Error("duration and interval are supported only by the sequence view");return R({mode:a,durationSeconds:o.duration??n.durationSeconds,intervalSeconds:o.interval??n.intervalSeconds,scale:o.scale??n.scale,...o.region===void 0?{}:{region:o.region}})}c(X,"parseVisionView");function ie(e,n){if(e.length===0)throw new Error("View parameters cannot be empty");let r=e.split(",");for(let t=0;t<r.length;t+=1){let i=r[t],a=i.indexOf("=");if(a<=0)throw new Error(`Invalid view parameter ${i}`);let o=i.slice(0,a),s=i.slice(a+1);if(o==="region"){let u=[s,r[t+1],r[t+2],r[t+3]].map(Number);if(u.some(m=>!Number.isFinite(m)))throw new Error("region requires x,y,width,height values");n.region={x:u[0],y:u[1],width:u[2],height:u[3]},t+=3;continue}if(o!=="duration"&&o!=="interval"&&o!=="scale")throw new Error(`Unknown view parameter ${o}`);let d=Number(s);if(!Number.isFinite(d))throw new Error(`View parameter ${o} must be a number`);if(n[o]!==void 0)throw new Error(`Duplicate view parameter ${o}`);n[o]=d}}c(ie,"parseViewParameters");function Y(e){if(!e.startsWith("display:"))return;if(e==="display:")return 0;let n=/^display:#(\d+)$/u.exec(e);if(n===null)throw new Error("Display sources use display: or display:#N with a zero-based index");let r=Number(n[1]);if(!Number.isSafeInteger(r))throw new Error("Display sources use display: or display:#N with a zero-based index");return r}c(Y,"parseDisplaySource");async function E(e){let n=new Map(e.list().flatMap(i=>i.pid===void 0?[]:[[i.pid,i]]));if(process.platform!=="linux"&&process.platform!=="darwin")return[...n].map(([i,a])=>({pid:i,command:a.description,owned:!0,source:a.source,host:"local"}));let{stdout:r}=await w("ps",["-eo","pid=,ppid=,lstart=,args="],{maxBuffer:4*1024*1024}),t=r.split(`
|
|
2
|
-
`).flatMap(i=>{let a=/^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.*)$/u.exec(i);if(a===null)return[];let o=Number(a[1]),s=n.get(o);return[{pid:o,parentPid:Number(a[2]),started:a[3],command:a[4]??"",owned:s!==void 0,host:"local",...s===void 0?{}:{source:s.source}}]});return S()?[...t,...await ae()]:t}c(E,"listProcesses");async function ae(){try{let{stdout:e}=await w("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command","Get-Process | Select-Object Id,ProcessName,Path,StartTime | ConvertTo-Json -Compress"],{maxBuffer:4194304}),n=JSON.parse(e);return(Array.isArray(n)?n:[n]).flatMap(t=>{if(typeof t!="object"||t===null||!("Id"in t)||typeof t.Id!="number")return[];let i="ProcessName"in t&&typeof t.ProcessName=="string"?t.ProcessName:"Windows process",a="Path"in t&&typeof t.Path=="string"?t.Path:void 0,o="StartTime"in t&&typeof t.StartTime=="string"?t.StartTime:void 0;return[{pid:t.Id,command:a??i,owned:!1,host:"windows",...o===void 0?{}:{started:o}}]})}catch{return[]}}c(ae,"listWindowsProcesses");async function A(e,n){if(!Number.isSafeInteger(e)||e<=0)throw new Error("Process PID must be a positive integer");let r=(await E(n)).find(t=>t.pid===e);if(r===void 0)throw new Error(`Process ${e} is not running`);return r}c(A,"readProcess");function R(e){let n=e.scale??1;if(!(n>0&&n<=1))throw new Error("Image scale must be greater than 0 and at most 1");let r=e.durationSeconds??0,t=e.intervalSeconds??1;if(e.mode==="sequence"){if(!(r>0&&r<=10))throw new Error("Sequence duration must be greater than 0 and at most 10 seconds");if(!(t>0))throw new Error("Sequence interval must be greater than 0 seconds");if(Math.floor(r/t)+1>20)throw new Error("Sequence capture is limited to 20 frames")}if(e.region!==void 0){let{x:i,y:a,width:o,height:s}=e.region;if(i<0||a<0||o<=0||s<=0||i+o>1||a+s>1)throw new Error("Image region x,y,width,height must fit within normalized bounds 0..1")}if(e.cellIndex!==void 0&&e.cellSize===void 0)throw new Error("Image offset requires limit to set the square grid cell size");if(e.cellSize!==void 0&&(!Number.isSafeInteger(e.cellSize)||e.cellSize<=0))throw new Error("Image limit must be a positive integer pixel size");if(e.cellIndex!==void 0&&(!Number.isSafeInteger(e.cellIndex)||e.cellIndex<0))throw new Error("Image offset must be a zero-based cell index");return e}c(R,"validateVisionOptions");async function b(e,n,r){let t=R(n),i=t.mode==="image"?1:Math.floor(t.durationSeconds/t.intervalSeconds)+1,a=[],o=0;for(let s=0;s<i;s+=1){r?.throwIfAborted(),s>0&&await pe(t.intervalSeconds*1e3,r);let d=await e();if(o+=d.byteLength,o>I)throw new Error("Captured images exceed the 20MB aggregate limit");for(let u of await ce(d,t))a.push({type:"image",data:Buffer.from(u).toString("base64"),mimeType:"image/png"})}return a}c(b,"captureImages");async function ce(e,n){let r=await se(e),t=n.region??{x:0,y:0,width:1,height:1},i=Math.round(t.x*r.width),a=Math.round(t.y*r.height),o=Math.max(1,Math.round(t.width*r.width)),s=Math.max(1,Math.round(t.height*r.height)),d=n.scale??1,u=Math.max(1,Math.round(o*d)),m=Math.max(1,Math.round(s*d)),f=B(u,m);if(f.getContext("2d").drawImage(r,i,a,o,s,0,0,u,m),n.cellSize===void 0)return[await f.encode("png")];let l=Math.ceil(u/n.cellSize),p=Math.ceil(m/n.cellSize),h=n.cellIndex??0;if(h>=l*p)throw new Error(`Image cell offset ${h} exceeds the ${l}x${p} grid`);let ee=h%l,ne=Math.floor(h/l),C=ee*n.cellSize,M=ne*n.cellSize,P=Math.min(n.cellSize,u-C),x=Math.min(n.cellSize,m-M),$=B(P,x);return $.getContext("2d").drawImage(f,C,M,P,x,0,0,P,x),[await $.encode("png")]}c(ce,"selectImage");function de(e,n){return e&&n==="windows"}c(de,"usesWindowsHostWindowCapture");function K(){return{async captureWindow(e,n,r){if(r?.throwIfAborted(),de(S(),n))return ue(e,r);if(process.platform!=="linux"&&process.platform!=="darwin")throw new Error(`Window capture is unsupported on ${process.platform}`);let{Window:t}=await import("node-screenshots"),i;try{i=t.all()}catch(s){throw new Error(`Desktop window enumeration is unavailable: ${F(s)}`,{cause:s})}let a=i.find(s=>{try{return s.pid()===e}catch{return!1}});if(a===void 0)throw new Error(`No capturable desktop window belongs to PID ${e}`);let o=await a.captureImage();return r?.throwIfAborted(),new Uint8Array(await o.toPng())},async captureDisplay(e,n){if(n?.throwIfAborted(),S())return le(e,n);if(process.platform!=="linux"&&process.platform!=="darwin"&&process.platform!=="win32")throw new Error(`Display capture is unsupported on ${process.platform}`);let{Monitor:r}=await import("node-screenshots"),t;try{t=r.all()}catch(o){throw new Error(`Desktop display enumeration is unavailable: ${F(o)}`,{cause:o})}let i=t[e];if(i===void 0)throw new Error(`Display index ${e} is unavailable; found ${t.length} display(s)`);let a=await i.captureImage();return n?.throwIfAborted(),new Uint8Array(await a.toPng())},async captureUrl(e,n){if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Web screenshots require an HTTP(S) URL");let{chromium:r}=await import("playwright-core"),t=await me(),i=await r.launch({executablePath:t,headless:!0,chromiumSandbox:!1,timeout:3e4}),a=c(()=>{i.close()},"abort");n?.addEventListener("abort",a,{once:!0});try{let o=await i.newPage({viewport:{width:1280,height:720}});return await o.goto(e.href,{waitUntil:"domcontentloaded",timeout:3e4}),await o.waitForLoadState("networkidle",{timeout:1500}).catch(()=>{}),n?.throwIfAborted(),new Uint8Array(await o.screenshot({type:"png",fullPage:!0}))}finally{n?.removeEventListener("abort",a),await i.close().catch(()=>{})}}}}c(K,"createCaptureBackend");async function ue(e,n){let r=new URL("windows-window-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await w("wslpath",["-w",r.pathname],{signal:n}),{stdout:i}=await w("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-ProcessId",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(i)}c(ue,"captureWslWindow");async function le(e,n){let r=new URL("windows-display-capture.ps1",new URL("../src/plugins/pi-agent-ide-vision/src/vision.ts",import.meta.url).href);n?.throwIfAborted();let{stdout:t}=await w("wslpath",["-w",r.pathname],{signal:n}),{stdout:i}=await w("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-File",t.trim(),"-DisplayIndex",String(e)],{encoding:"buffer",maxBuffer:I,signal:n});return new Uint8Array(i)}c(le,"captureWslDisplay");function S(){return process.platform==="linux"&&(process.env.WSL_DISTRO_NAME!==void 0||re.release().toLowerCase().includes("microsoft"))}c(S,"isWsl");async function me(){let e=process.env.PI_AGENT_IDE_BROWSER_PATH;if(e!==void 0)return e;let{stdout:n}=await w("bash",["-lc","command -v google-chrome-stable || command -v google-chrome || command -v chromium || command -v chromium-browser"]),r=n.trim();if(r.length===0)throw new Error("No Chrome or Chromium executable was found; set PI_AGENT_IDE_BROWSER_PATH");return r}c(me,"resolveBrowser");function pe(e,n){return new Promise((r,t)=>{let i=setTimeout(r,e),a=c(()=>{clearTimeout(i),t(n?.reason??new Error("Capture aborted"))},"abort");n?.addEventListener("abort",a,{once:!0}),i.unref()})}c(pe,"delay");function F(e){return e instanceof Error?e.message:String(e)}c(F,"errorMessage");async function fe(e,n){q(e,[await V({id:"vision",description:"Window, display, image, and sequence capture",triggers:[{tool:"read",resourcePrefixes:["window:","display:"]}]})]);let r=n?.preferences??{};G({durationSeconds:r["vision.sequenceDurationSeconds"],intervalSeconds:r["vision.sequenceIntervalSeconds"],scale:r["vision.imageScale"],allowedExecutables:r["vision.allowedExecutables"]});let t=z(e),i=K();await Promise.all([O(e,{protocol:k,apiVersion:T,id:"vision",setup(a){for(let s of["image","sequence"])a.addView({view:s,presenter:{id:`vision-${s}`,present:c(d=>d,"present")}});a.addHandler({stage:"pre-read",async handler(s){let d=s.request.path;if(d===void 0)return{kind:"continue",context:s};let u=Y(d);if(u!==void 0){if(e.getFlag("pi-agent-ide-vision-displays")!==!0)return g(d,"Display capture is disabled. Enable --pi-agent-ide-vision-displays to allow it.");try{let l=await b(()=>i.captureDisplay(u,s.resolverContext.signal),D(s.request),s.resolverContext.signal);return v(d,l)}catch(l){return g(d,N(l))}}let m=Q(d,"process:");if(m!==void 0){let l=await A(m,t);return v(d,[{type:"text",text:Z(l)}])}let f=Q(d,"window:");if(f!==void 0){let l=await A(f,t);if(!l.owned&&!J(l.command)&&e.getFlag("pi-agent-ide-vision-arbitrary-windows")!==!0)return g(d,`Window capture for PID ${f} is denied because the process is neither Agent IDE-owned nor allowlisted by executable name. Enable --pi-agent-ide-vision-arbitrary-windows to allow it.`);try{let p=await b(()=>i.captureWindow(f,l.host,s.resolverContext.signal),D(s.request),s.resolverContext.signal);return v(d,p)}catch(p){return g(d,N(p))}}if(/^https?:\/\//iu.test(d)&&we(s.request)){let l=new URL(d);try{let p=await b(()=>i.captureUrl(l,s.resolverContext.signal),D(s.request),s.resolverContext.signal);return v(l.href,p)}catch(p){return g(l.href,N(p))}}return{kind:"continue",context:s}}});let o=y();a.describe(`Process metadata: process:PID. Visual capture: window:PID and display: or display:#N. HTTP(S) sources accept image and sequence screenshots. Use named view parameters such as sequence:duration=2,interval=0.5,scale=0.5 and image:scale=0.5,region=0.25,0.25,0.5,0.5. Duration is limited to 10 seconds and sequences to 20 frames. Defaults: duration=${o.durationSeconds}, interval=${o.intervalSeconds}, scale=${o.scale}. Region uses normalized x,y,width,height and runs before scaling. For captures, limit is a square grid cell size in output pixels and offset is one zero-based row-major cell index; limit without offset selects cell 0, while offset without limit is invalid. Omit both for the bounded transformed image.`)}}),_(e,{protocol:L,apiVersion:W,id:"vision-processes",setup(a){a.addResolver({priority:-100,resolver:{id:"processes",readResources:c(o=>/^process:/iu.test(o.query)?void 0:[],"readResources"),toScriptData(o){return{kind:"custom",resolverId:"processes",value:{processes:o.map(d=>({pid:d.pid,command:d.command}))}}},async tryResolve(o){let s=/^process:(.*)$/isu.exec(o.query);if(s===null)return{kind:"not-handled"};let d=(s[1]??"").trim().toLowerCase();return{kind:"resolved",payload:(await E(t)).filter(m=>d.length===0||String(m.pid)===d||m.command.toLowerCase().includes(d)).slice(0,Math.min(o.limit??50,100))}},renderResult(o,s,d){let u=o.details;return new U({summary:`${u.processes.length} processes shown`,rows:u.processes.length?u.processes.map(m=>({kind:"note",text:`${m.pid} ${m.command}`})):[{kind:"note",text:"No matching processes"}]},d,s.expanded)},format(o){let s=o;return{content:[{type:"text",text:s.length===0?"No matching processes.":s.map(Z).join(`
|
|
3
|
-
|
|
4
|
-
`)}],details:{count:s.length,processes:s}}}}}),a.describe("process:<query> finds running processes by PID or command for process:PID metadata reads and guarded window:PID capture.")}})])}c(fe,"registerVision");function Q(e,n){if(!e.startsWith(n))return;let r=e.slice(n.length);if(!/^\d+$/u.test(r))throw new Error(`${n} sources require a numeric PID`);return Number(r)}c(Q,"prefixedPid");function D(e){return{...X(e.views,y())??{mode:"image",...y()},...e.limit===void 0?{}:{cellSize:e.limit},...e.offset===void 0?{}:{cellIndex:e.offset}}}c(D,"options");function we(e){return e.views?.some(n=>/^(?:image|sequence)(?::|$)/u.test(n))===!0}c(we,"requestsScreenshot");function v(e,n){return{kind:"return",result:{content:n,script:{kind:"native",source:e,blocks:n},details:{source:e,resolvedBy:"vision"}}}}c(v,"returned");function g(e,n){return{kind:"return",result:{content:[{type:"text",text:n}],details:{source:e,resolvedBy:"vision",failure:{code:"READ_FAILED",source:e,resolverId:"vision",message:n}},isError:!0}}}c(g,"failed");function N(e){return e instanceof Error?e.message:String(e)}c(N,"errorMessage");function Z(e){return[`PID: ${e.pid}`,`Command: ${e.command}`,`Owned by Agent IDE: ${e.owned?"yes":"no"}`,...e.parentPid===void 0?[]:[`Parent PID: ${e.parentPid}`],...e.started===void 0?[]:[`Started: ${e.started}`],...e.source===void 0?[]:[`Agent IDE source: ${e.source}`]].join(`
|
|
5
|
-
`)}c(Z,"formatProcess");export{fe as default};
|