@caupulican/pi-adaptative 0.80.22 → 0.80.25
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 +38 -1
- package/README.md +16 -2
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +14 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +28 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +4 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +22 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +32 -78
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +16 -7
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/exec.d.ts +20 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +52 -19
- package/dist/core/exec.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +6 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +33 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/message-retention.d.ts +26 -0
- package/dist/core/message-retention.d.ts.map +1 -0
- package/dist/core/message-retention.js +95 -0
- package/dist/core/message-retention.js.map +1 -0
- package/dist/core/package-manager.d.ts +3 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +72 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +3 -1
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +39 -11
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/resource-profile-blocks.d.ts +16 -0
- package/dist/core/resource-profile-blocks.d.ts.map +1 -0
- package/dist/core/resource-profile-blocks.js +120 -0
- package/dist/core/resource-profile-blocks.js.map +1 -0
- package/dist/core/sdk.d.ts +9 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +17 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +3 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +45 -9
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +45 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +218 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +15 -0
- package/dist/core/skills.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +9 -1
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +94 -8
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/read.d.ts +31 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +164 -33
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +37 -4
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +54 -18
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts +0 -7
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +17 -0
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/utils/safe-write-stream.d.ts +10 -0
- package/dist/utils/safe-write-stream.d.ts.map +1 -0
- package/dist/utils/safe-write-stream.js +16 -0
- package/dist/utils/safe-write-stream.js.map +1 -0
- package/dist/utils/sleep.d.ts +3 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js +10 -4
- package/dist/utils/sleep.js.map +1 -1
- package/docs/extensions.md +18 -1
- package/docs/prompt-templates.md +1 -0
- package/docs/settings.md +43 -1
- package/docs/skills.md +12 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/dist/core/tools/read.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from "node:path";
|
|
2
|
+
import { StringDecoder } from "node:string_decoder";
|
|
2
3
|
import { Text } from "@caupulican/pi-tui";
|
|
3
4
|
import { constants } from "fs";
|
|
4
|
-
import { access as fsAccess, readFile as fsReadFile } from "fs/promises";
|
|
5
|
+
import { access as fsAccess, open as fsOpen, readFile as fsReadFile, stat as fsStat } from "fs/promises";
|
|
5
6
|
import { Type } from "typebox";
|
|
6
7
|
import { getReadmePath } from "../../config.js";
|
|
7
8
|
import { keyHint, keyText } from "../../modes/interactive/components/keybinding-hints.js";
|
|
@@ -31,11 +32,78 @@ const COMPACT_RESOURCE_FILE_NAMES = new Set([
|
|
|
31
32
|
"GEMINI.md",
|
|
32
33
|
"GEMINI.MD",
|
|
33
34
|
]);
|
|
35
|
+
const SLICE_SCAN_CHUNK_BYTES = 1024 * 1024;
|
|
36
|
+
async function scanLines(absolutePath, onLine) {
|
|
37
|
+
const handle = await fsOpen(absolutePath, "r");
|
|
38
|
+
try {
|
|
39
|
+
const decoder = new StringDecoder("utf8");
|
|
40
|
+
const buffer = Buffer.allocUnsafe(SLICE_SCAN_CHUNK_BYTES);
|
|
41
|
+
let pending = "";
|
|
42
|
+
let index = 0;
|
|
43
|
+
while (true) {
|
|
44
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, null);
|
|
45
|
+
if (bytesRead === 0)
|
|
46
|
+
break;
|
|
47
|
+
pending += decoder.write(buffer.subarray(0, bytesRead));
|
|
48
|
+
let lineStart = 0;
|
|
49
|
+
let newlineIndex = pending.indexOf("\n", lineStart);
|
|
50
|
+
while (newlineIndex !== -1) {
|
|
51
|
+
if (!onLine(pending.slice(lineStart, newlineIndex), index++))
|
|
52
|
+
return;
|
|
53
|
+
lineStart = newlineIndex + 1;
|
|
54
|
+
newlineIndex = pending.indexOf("\n", lineStart);
|
|
55
|
+
}
|
|
56
|
+
pending = pending.slice(lineStart);
|
|
57
|
+
}
|
|
58
|
+
pending += decoder.end();
|
|
59
|
+
onLine(pending, index);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
await handle.close();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function readLocalLineSlice(absolutePath, options) {
|
|
66
|
+
const lines = [];
|
|
67
|
+
let collectedChars = 0;
|
|
68
|
+
let sawMore = false;
|
|
69
|
+
await scanLines(absolutePath, (text, index) => {
|
|
70
|
+
if (text === undefined)
|
|
71
|
+
return false;
|
|
72
|
+
if (index < options.startLine)
|
|
73
|
+
return true;
|
|
74
|
+
if (lines.length >= options.maxLines || collectedChars > options.maxChars) {
|
|
75
|
+
sawMore = true;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
lines.push({ text, originalIndex: index + 1 });
|
|
79
|
+
collectedChars += text.length;
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
return { lines, reachedEnd: !sawMore };
|
|
83
|
+
}
|
|
84
|
+
async function countLocalLines(absolutePath) {
|
|
85
|
+
let count = 0;
|
|
86
|
+
await scanLines(absolutePath, () => {
|
|
87
|
+
count++;
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
return count;
|
|
91
|
+
}
|
|
34
92
|
const defaultReadOperations = {
|
|
35
93
|
readFile: (path) => fsReadFile(path),
|
|
36
94
|
access: (path) => fsAccess(path, constants.R_OK),
|
|
37
95
|
detectImageMimeType: detectSupportedImageMimeTypeFromFile,
|
|
96
|
+
stat: async (path) => ({ size: (await fsStat(path)).size }),
|
|
97
|
+
readLineSlice: readLocalLineSlice,
|
|
98
|
+
countLines: countLocalLines,
|
|
38
99
|
};
|
|
100
|
+
// Loading a whole file before truncation lets a single giant file spike the heap
|
|
101
|
+
// to its full size. Beyond these budgets, text reads stream line slices (every
|
|
102
|
+
// region stays reachable in batches — lossless). The image budget is deliberately
|
|
103
|
+
// far above any real screenshot/photo so quality-degrading workarounds are never
|
|
104
|
+
// needed in practice; it only guards against pathological files.
|
|
105
|
+
const DEFAULT_MAX_TEXT_READ_BYTES = 16 * 1024 * 1024;
|
|
106
|
+
const DEFAULT_MAX_IMAGE_READ_BYTES = 128 * 1024 * 1024;
|
|
39
107
|
function formatReadLineRange(args, theme) {
|
|
40
108
|
if (args?.offset === undefined && args?.limit === undefined)
|
|
41
109
|
return "";
|
|
@@ -142,6 +210,8 @@ function formatReadResult(args, result, options, theme, showImages, _cwd, isErro
|
|
|
142
210
|
export function createReadToolDefinition(cwd, options) {
|
|
143
211
|
const autoResizeImages = options?.autoResizeImages ?? true;
|
|
144
212
|
const ops = options?.operations ?? defaultReadOperations;
|
|
213
|
+
const maxTextReadBytes = options?.maxTextReadBytes ?? DEFAULT_MAX_TEXT_READ_BYTES;
|
|
214
|
+
const maxImageReadBytes = options?.maxImageReadBytes ?? DEFAULT_MAX_IMAGE_READ_BYTES;
|
|
145
215
|
return {
|
|
146
216
|
name: "read",
|
|
147
217
|
label: "read",
|
|
@@ -174,7 +244,23 @@ export function createReadToolDefinition(cwd, options) {
|
|
|
174
244
|
let content;
|
|
175
245
|
let details;
|
|
176
246
|
const nonVisionImageNote = getNonVisionImageNote(ctx?.model);
|
|
247
|
+
const fileSize = ops.stat ? (await ops.stat(absolutePath)).size : undefined;
|
|
248
|
+
if (aborted)
|
|
249
|
+
return;
|
|
177
250
|
if (mimeType) {
|
|
251
|
+
if (fileSize !== undefined && fileSize > maxImageReadBytes) {
|
|
252
|
+
signal?.removeEventListener("abort", onAbort);
|
|
253
|
+
resolve({
|
|
254
|
+
content: [
|
|
255
|
+
{
|
|
256
|
+
type: "text",
|
|
257
|
+
text: `Image file is ${formatSize(fileSize)} (${formatSize(maxImageReadBytes)} inline decode limit). Downscale it first, e.g. with bash (ImageMagick: magick "${path}" -resize 2000x2000 /tmp/preview.png) and read the result.`,
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
details: undefined,
|
|
261
|
+
});
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
178
264
|
// Read image as binary.
|
|
179
265
|
const buffer = await ops.readFile(absolutePath);
|
|
180
266
|
if (autoResizeImages) {
|
|
@@ -210,33 +296,73 @@ export function createReadToolDefinition(cwd, options) {
|
|
|
210
296
|
}
|
|
211
297
|
}
|
|
212
298
|
else {
|
|
213
|
-
// Read text content.
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
const allLines = textContent.split("\n");
|
|
217
|
-
const totalFileLines = allLines.length;
|
|
218
|
-
// Apply offset/tail if specified. Convert from 1-indexed input to 0-indexed array access.
|
|
299
|
+
// Read text content. Oversized files are streamed as line slices so
|
|
300
|
+
// any region stays reachable in batches without loading the whole file.
|
|
301
|
+
const useSlicedRead = fileSize !== undefined && fileSize > maxTextReadBytes && ops.readLineSlice !== undefined;
|
|
219
302
|
let startLine = 0;
|
|
220
303
|
let userLimitedLines = limit;
|
|
221
|
-
|
|
222
|
-
|
|
304
|
+
let totalFileLines;
|
|
305
|
+
let moreContentRemains = false;
|
|
306
|
+
let textContentForJsonCheck;
|
|
307
|
+
let slicedLines;
|
|
308
|
+
if (useSlicedRead && ops.readLineSlice) {
|
|
309
|
+
if (offset !== undefined) {
|
|
310
|
+
startLine = Math.max(0, offset - 1);
|
|
311
|
+
}
|
|
312
|
+
else if (tail !== undefined) {
|
|
313
|
+
const counted = ops.countLines ? await ops.countLines(absolutePath) : undefined;
|
|
314
|
+
if (counted !== undefined) {
|
|
315
|
+
totalFileLines = counted;
|
|
316
|
+
startLine = Math.max(0, counted - tail);
|
|
317
|
+
}
|
|
318
|
+
if (limit === undefined) {
|
|
319
|
+
userLimitedLines = tail;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const slice = await ops.readLineSlice(absolutePath, {
|
|
323
|
+
startLine,
|
|
324
|
+
maxLines: userLimitedLines ?? DEFAULT_MAX_LINES,
|
|
325
|
+
maxChars: DEFAULT_MAX_BYTES * 4,
|
|
326
|
+
});
|
|
327
|
+
if (slice.lines.length === 0 && startLine > 0) {
|
|
328
|
+
throw new Error(`Offset ${startLine + 1} is beyond end of file`);
|
|
329
|
+
}
|
|
330
|
+
slicedLines = slice.lines;
|
|
331
|
+
moreContentRemains = !slice.reachedEnd;
|
|
223
332
|
}
|
|
224
|
-
else
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
333
|
+
else {
|
|
334
|
+
const buffer = await ops.readFile(absolutePath);
|
|
335
|
+
const textContent = buffer.toString("utf-8");
|
|
336
|
+
textContentForJsonCheck = textContent;
|
|
337
|
+
const allLines = textContent.split("\n");
|
|
338
|
+
totalFileLines = allLines.length;
|
|
339
|
+
// Apply offset/tail if specified. Convert from 1-indexed input to 0-indexed array access.
|
|
340
|
+
if (offset !== undefined) {
|
|
341
|
+
startLine = Math.max(0, offset - 1);
|
|
228
342
|
}
|
|
343
|
+
else if (tail !== undefined) {
|
|
344
|
+
startLine = Math.max(0, totalFileLines - tail);
|
|
345
|
+
if (limit === undefined) {
|
|
346
|
+
userLimitedLines = tail;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Check if offset is out of bounds.
|
|
350
|
+
if (startLine >= allLines.length && allLines.length > 0) {
|
|
351
|
+
throw new Error(`Offset ${startLine + 1} is beyond end of file (${allLines.length} lines total)`);
|
|
352
|
+
}
|
|
353
|
+
slicedLines =
|
|
354
|
+
userLimitedLines !== undefined
|
|
355
|
+
? allLines
|
|
356
|
+
.map((line, idx) => ({ text: line, originalIndex: idx + 1 }))
|
|
357
|
+
.slice(startLine, startLine + userLimitedLines)
|
|
358
|
+
: allLines
|
|
359
|
+
.map((line, idx) => ({ text: line, originalIndex: idx + 1 }))
|
|
360
|
+
.slice(startLine);
|
|
361
|
+
moreContentRemains =
|
|
362
|
+
userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length;
|
|
229
363
|
}
|
|
230
364
|
const startLineDisplay = startLine + 1;
|
|
231
|
-
|
|
232
|
-
if (startLine >= allLines.length && allLines.length > 0) {
|
|
233
|
-
throw new Error(`Offset ${startLine + 1} is beyond end of file (${allLines.length} lines total)`);
|
|
234
|
-
}
|
|
235
|
-
let slicedLines = userLimitedLines !== undefined
|
|
236
|
-
? allLines
|
|
237
|
-
.map((line, idx) => ({ text: line, originalIndex: idx + 1 }))
|
|
238
|
-
.slice(startLine, startLine + userLimitedLines)
|
|
239
|
-
: allLines.map((line, idx) => ({ text: line, originalIndex: idx + 1 })).slice(startLine);
|
|
365
|
+
const firstSelectedLineText = slicedLines[0]?.text ?? "";
|
|
240
366
|
// Safe text filtering
|
|
241
367
|
let canFilter = true;
|
|
242
368
|
if (mimeType) {
|
|
@@ -257,9 +383,9 @@ export function createReadToolDefinition(cwd, options) {
|
|
|
257
383
|
if (unsafeExtensions.some((ext) => fileNameLower.endsWith(ext))) {
|
|
258
384
|
canFilter = false;
|
|
259
385
|
}
|
|
260
|
-
else {
|
|
386
|
+
else if (textContentForJsonCheck !== undefined) {
|
|
261
387
|
try {
|
|
262
|
-
JSON.parse(
|
|
388
|
+
JSON.parse(textContentForJsonCheck);
|
|
263
389
|
canFilter = false;
|
|
264
390
|
}
|
|
265
391
|
catch { }
|
|
@@ -316,9 +442,12 @@ export function createReadToolDefinition(cwd, options) {
|
|
|
316
442
|
// Apply truncation, respecting both line and byte limits.
|
|
317
443
|
const truncation = truncateHead(selectedContent);
|
|
318
444
|
let outputText;
|
|
445
|
+
const totalDisplay = totalFileLines !== undefined
|
|
446
|
+
? String(totalFileLines)
|
|
447
|
+
: `a ${fileSize !== undefined ? formatSize(fileSize) : "large"} file`;
|
|
319
448
|
if (truncation.firstLineExceedsLimit) {
|
|
320
449
|
// First line alone exceeds the byte limit. Point the model at a bash fallback.
|
|
321
|
-
const firstLineSize = formatSize(Buffer.byteLength(
|
|
450
|
+
const firstLineSize = formatSize(Buffer.byteLength(firstSelectedLineText, "utf-8"));
|
|
322
451
|
outputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;
|
|
323
452
|
details = { truncation };
|
|
324
453
|
}
|
|
@@ -328,21 +457,23 @@ export function createReadToolDefinition(cwd, options) {
|
|
|
328
457
|
const nextOffset = endLineDisplay + 1;
|
|
329
458
|
outputText = truncation.content;
|
|
330
459
|
if (truncation.truncatedBy === "lines") {
|
|
331
|
-
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${
|
|
460
|
+
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalDisplay}. Use offset=${nextOffset} to continue.]`;
|
|
332
461
|
}
|
|
333
462
|
else {
|
|
334
|
-
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${
|
|
463
|
+
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalDisplay} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
|
|
335
464
|
}
|
|
336
465
|
details = { truncation };
|
|
337
466
|
}
|
|
338
|
-
else if (
|
|
339
|
-
//
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
467
|
+
else if (moreContentRemains) {
|
|
468
|
+
// More content exists beyond this slice; hand the model a continuation pointer.
|
|
469
|
+
const nextOffset = startLine + slicedLines.length + 1;
|
|
470
|
+
const remaining = totalFileLines !== undefined && userLimitedLines !== undefined
|
|
471
|
+
? `${totalFileLines - (startLine + userLimitedLines)} more lines in file`
|
|
472
|
+
: "More content remains";
|
|
473
|
+
outputText = `${truncation.content}\n\n[${remaining}. Use offset=${nextOffset} to continue.]`;
|
|
343
474
|
}
|
|
344
475
|
else {
|
|
345
|
-
// No truncation and no remaining
|
|
476
|
+
// No truncation and no remaining content.
|
|
346
477
|
outputText = truncation.content;
|
|
347
478
|
}
|
|
348
479
|
content = [{ type: "text", text: outputText }];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGjG,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,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AC;YAAA,CACL,CACD,CAAC;QAAA,CACF;QACD,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE;YAChC,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACvG,IAAI,CAAC,OAAO,CACX,cAAc;gBACb,CAAC,CAAC,qBAAqB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC;gBACpD,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAC3C,CAAC;YACF,OAAO,IAAI,CAAC;QAAA,CACZ;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAC7C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CACX,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CACxG,CAAC;YACF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB,EAAgC;IACpG,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@caupulican/pi-ai\";\nimport { Text } from \"@caupulican/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { formatDimensionNote, resizeImage } from \"../../utils/image-resize.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n\tlineNumbers: Type.Optional(Type.Boolean({ description: \"Include line numbers in the output\" })),\n\ttail: Type.Optional(Type.Number({ description: \"Number of lines to read from the end of the file\" })),\n\tfilter: Type.Optional(\n\t\tType.Union([Type.Literal(\"none\"), Type.Literal(\"minimal\"), Type.Literal(\"aggressive\")], {\n\t\t\tdescription: \"Safe text filtering level (none, minimal, aggressive)\",\n\t\t}),\n\t),\n});\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\n\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\n\t\"AGENTS.md\",\n\t\"AGENTS.MD\",\n\t\"CLAUDE.md\",\n\t\"CLAUDE.MD\",\n\t\"GEMINI.md\",\n\t\"GEMINI.MD\",\n]);\n\n/**\n * Pluggable operations for the read tool.\n * Override these to delegate file reading to remote systems (for example SSH).\n */\nexport interface ReadOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Check if file is readable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n\t/** Detect image MIME type, return null or undefined for non-images */\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n}\n\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\n\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Custom operations for file reading. Default: local filesystem */\n\toperations?: ReadOperations;\n}\n\ntype ReadRenderArgs = { path?: string; file_path?: string; offset?: number; limit?: number };\n\nfunction formatReadLineRange(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tif (args?.offset === undefined && args?.limit === undefined) return \"\";\n\tconst startLine = args.offset ?? 1;\n\tconst endLine = args.limit !== undefined ? startLine + args.limit - 1 : \"\";\n\treturn theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n}\n\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\tif (!model || model.input.includes(\"image\")) {\n\t\treturn undefined;\n\t}\n\treturn \"[Current model does not support images. The image will be omitted from this request.]\";\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\n\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tif (!rawPath) return undefined;\n\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\n\treturn undefined;\n}\n\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\n\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tif (!options.expanded && !isError) {\n\t\treturn \"\";\n\t}\n\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result, showImages);\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t}\n\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\n\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tpromptSnippet: \"Read file contents\",\n\t\tpromptGuidelines: [\"Use read to examine files instead of cat or sed.\"],\n\t\tparameters: readSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\toffset,\n\t\t\t\tlimit,\n\t\t\t\tlineNumbers,\n\t\t\t\ttail,\n\t\t\t\tfilter,\n\t\t\t}: {\n\t\t\t\tpath: string;\n\t\t\t\toffset?: number;\n\t\t\t\tlimit?: number;\n\t\t\t\tlineNumbers?: boolean;\n\t\t\t\ttail?: number;\n\t\t\t\tfilter?: \"none\" | \"minimal\" | \"aggressive\";\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(path, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t// Check if file exists and is readable.\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tif (autoResizeImages) {\n\t\t\t\t\t\t\t\t\t// Resize image if needed before sending it back to the model.\n\t\t\t\t\t\t\t\t\tconst resized = await resizeImage(buffer, mimeType);\n\t\t\t\t\t\t\t\t\tif (!resized) {\n\t\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n[Image omitted: could not be resized below the inline image size limit.]`;\n\t\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tconst dimensionNote = formatDimensionNote(resized);\n\t\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${resized.mimeType}]`;\n\t\t\t\t\t\t\t\t\t\tif (dimensionNote) textNote += `\\n${dimensionNote}`;\n\t\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: resized.data, mimeType: resized.mimeType },\n\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: buffer.toString(\"base64\"), mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Read text content.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tconst totalFileLines = allLines.length;\n\t\t\t\t\t\t\t\t// Apply offset/tail if specified. Convert from 1-indexed input to 0-indexed array access.\n\t\t\t\t\t\t\t\tlet startLine = 0;\n\t\t\t\t\t\t\t\tlet userLimitedLines = limit;\n\t\t\t\t\t\t\t\tif (offset !== undefined) {\n\t\t\t\t\t\t\t\t\tstartLine = Math.max(0, offset - 1);\n\t\t\t\t\t\t\t\t} else if (tail !== undefined) {\n\t\t\t\t\t\t\t\t\tstartLine = Math.max(0, totalFileLines - tail);\n\t\t\t\t\t\t\t\t\tif (limit === undefined) {\n\t\t\t\t\t\t\t\t\t\tuserLimitedLines = tail;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\t// Check if offset is out of bounds.\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length && allLines.length > 0) {\n\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t`Offset ${startLine + 1} is beyond end of file (${allLines.length} lines total)`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlet slicedLines =\n\t\t\t\t\t\t\t\t\tuserLimitedLines !== undefined\n\t\t\t\t\t\t\t\t\t\t? allLines\n\t\t\t\t\t\t\t\t\t\t\t\t.map((line, idx) => ({ text: line, originalIndex: idx + 1 }))\n\t\t\t\t\t\t\t\t\t\t\t\t.slice(startLine, startLine + userLimitedLines)\n\t\t\t\t\t\t\t\t\t\t: allLines.map((line, idx) => ({ text: line, originalIndex: idx + 1 })).slice(startLine);\n\n\t\t\t\t\t\t\t\t// Safe text filtering\n\t\t\t\t\t\t\t\tlet canFilter = true;\n\t\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t\tcanFilter = false;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst fileNameLower = path.toLowerCase();\n\t\t\t\t\t\t\t\t\tconst unsafeExtensions = [\n\t\t\t\t\t\t\t\t\t\t\".json\",\n\t\t\t\t\t\t\t\t\t\t\".jsonl\",\n\t\t\t\t\t\t\t\t\t\t\".yml\",\n\t\t\t\t\t\t\t\t\t\t\".yaml\",\n\t\t\t\t\t\t\t\t\t\t\".toml\",\n\t\t\t\t\t\t\t\t\t\t\".xml\",\n\t\t\t\t\t\t\t\t\t\t\".csv\",\n\t\t\t\t\t\t\t\t\t\t\".tsv\",\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\tif (unsafeExtensions.some((ext) => fileNameLower.endsWith(ext))) {\n\t\t\t\t\t\t\t\t\t\tcanFilter = false;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tJSON.parse(textContent);\n\t\t\t\t\t\t\t\t\t\t\tcanFilter = false;\n\t\t\t\t\t\t\t\t\t\t} catch {}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (canFilter && filter && filter !== \"none\") {\n\t\t\t\t\t\t\t\t\tconst filtered: typeof slicedLines = [];\n\t\t\t\t\t\t\t\t\tif (filter === \"minimal\") {\n\t\t\t\t\t\t\t\t\t\tlet consecutiveBlank = 0;\n\t\t\t\t\t\t\t\t\t\tfor (const item of slicedLines) {\n\t\t\t\t\t\t\t\t\t\t\tconst trimmed = item.text.trimEnd();\n\t\t\t\t\t\t\t\t\t\t\tif (trimmed === \"\") {\n\t\t\t\t\t\t\t\t\t\t\t\tconsecutiveBlank++;\n\t\t\t\t\t\t\t\t\t\t\t\tif (consecutiveBlank <= 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tfiltered.push({ text: \"\", originalIndex: item.originalIndex });\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\tconsecutiveBlank = 0;\n\t\t\t\t\t\t\t\t\t\t\t\tfiltered.push({ text: trimmed, originalIndex: item.originalIndex });\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\twhile (filtered.length > 0 && filtered[filtered.length - 1].text === \"\") {\n\t\t\t\t\t\t\t\t\t\t\tfiltered.pop();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else if (filter === \"aggressive\") {\n\t\t\t\t\t\t\t\t\t\tfor (const item of slicedLines) {\n\t\t\t\t\t\t\t\t\t\t\tconst trimmed = item.text.trimEnd();\n\t\t\t\t\t\t\t\t\t\t\tconst trimmedStart = trimmed.trimStart();\n\t\t\t\t\t\t\t\t\t\t\tif (trimmedStart === \"\") {\n\t\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\ttrimmedStart.startsWith(\"//\") ||\n\t\t\t\t\t\t\t\t\t\t\t\ttrimmedStart.startsWith(\"#\") ||\n\t\t\t\t\t\t\t\t\t\t\t\t(trimmedStart.startsWith(\"/*\") && trimmedStart.endsWith(\"*/\"))\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tfiltered.push({ text: trimmed, originalIndex: item.originalIndex });\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// If filtering would empty a non-empty list, keep original\n\t\t\t\t\t\t\t\t\tconst isOriginalNotEmpty = slicedLines.some((item) => item.text.trim().length > 0);\n\t\t\t\t\t\t\t\t\tconst isFilteredEmpty = filtered.every((item) => item.text.trim().length === 0);\n\t\t\t\t\t\t\t\t\tif (isOriginalNotEmpty && isFilteredEmpty) {\n\t\t\t\t\t\t\t\t\t\t// Fallback to slicedLines\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tslicedLines = filtered;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst finalLines = slicedLines.map((item) =>\n\t\t\t\t\t\t\t\t\tlineNumbers ? `${item.originalIndex}: ${item.text}` : item.text,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst selectedContent = finalLines.join(\"\\n\");\n\n\t\t\t\t\t\t\t\t// Apply truncation, respecting both line and byte limits.\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\tlet outputText: string;\n\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t// First line alone exceeds the byte limit. Point the model at a bash fallback.\n\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], \"utf-8\"));\n\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t// Truncation occurred. Build an actionable continuation notice.\n\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\t\t\t\t\t\t// User-specified limit stopped early, but the file still has more content.\n\t\t\t\t\t\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// No truncation and no remaining user-limited content.\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details });\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification\n\t\t\t\t\t? formatCompactReadCall(classification, args, theme)\n\t\t\t\t\t: formatReadCall(args, theme, context.cwd),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"read.js","sour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,CAAC,CAAC,CAAC;YAC/E,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACvG,IAAI,CAAC,OAAO,CACX,cAAc;gBACb,CAAC,CAAC,qBAAqB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC;gBACpD,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAC3C,CAAC;YACF,OAAO,IAAI,CAAC;QAAA,CACZ;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAC7C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CACX,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CACxG,CAAC;YACF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB,EAAgC;IACpG,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport { StringDecoder } from \"node:string_decoder\";\nimport type { AgentTool } from \"@caupulican/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@caupulican/pi-ai\";\nimport { Text } from \"@caupulican/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, open as fsOpen, readFile as fsReadFile, stat as fsStat } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { formatDimensionNote, resizeImage } from \"../../utils/image-resize.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n\tlineNumbers: Type.Optional(Type.Boolean({ description: \"Include line numbers in the output\" })),\n\ttail: Type.Optional(Type.Number({ description: \"Number of lines to read from the end of the file\" })),\n\tfilter: Type.Optional(\n\t\tType.Union([Type.Literal(\"none\"), Type.Literal(\"minimal\"), Type.Literal(\"aggressive\")], {\n\t\t\tdescription: \"Safe text filtering level (none, minimal, aggressive)\",\n\t\t}),\n\t),\n});\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\n\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\n\t\"AGENTS.md\",\n\t\"AGENTS.MD\",\n\t\"CLAUDE.md\",\n\t\"CLAUDE.MD\",\n\t\"GEMINI.md\",\n\t\"GEMINI.MD\",\n]);\n\n/**\n * Pluggable operations for the read tool.\n * Override these to delegate file reading to remote systems (for example SSH).\n */\nexport interface ReadOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Check if file is readable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n\t/** Detect image MIME type, return null or undefined for non-images */\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n\t/** File size in bytes, used to decide between whole-file and sliced reads. */\n\tstat?: (absolutePath: string) => Promise<{ size: number }>;\n\t/**\n\t * Stream a slice of lines out of the file with bounded memory. Any region of an\n\t * arbitrarily large file stays reachable in batches via offset continuation.\n\t */\n\treadLineSlice?: (absolutePath: string, options: LineSliceOptions) => Promise<LineSlice>;\n\t/** Count lines by streaming (bounded memory); used to resolve tail reads on oversized files. */\n\tcountLines?: (absolutePath: string) => Promise<number>;\n}\n\nexport interface LineSliceOptions {\n\t/** 0-based line to start collecting at. */\n\tstartLine: number;\n\t/** Maximum number of lines to collect. */\n\tmaxLines: number;\n\t/** Maximum total characters to collect across lines. */\n\tmaxChars: number;\n}\n\nexport interface LineSlice {\n\tlines: { text: string; originalIndex: number }[];\n\t/** True when the end of the file was reached while collecting. */\n\treachedEnd: boolean;\n}\n\nconst SLICE_SCAN_CHUNK_BYTES = 1024 * 1024;\n\nasync function scanLines(\n\tabsolutePath: string,\n\tonLine: (text: string | undefined, index: number) => boolean,\n): Promise<void> {\n\tconst handle = await fsOpen(absolutePath, \"r\");\n\ttry {\n\t\tconst decoder = new StringDecoder(\"utf8\");\n\t\tconst buffer = Buffer.allocUnsafe(SLICE_SCAN_CHUNK_BYTES);\n\t\tlet pending = \"\";\n\t\tlet index = 0;\n\t\twhile (true) {\n\t\t\tconst { bytesRead } = await handle.read(buffer, 0, buffer.length, null);\n\t\t\tif (bytesRead === 0) break;\n\t\t\tpending += decoder.write(buffer.subarray(0, bytesRead));\n\t\t\tlet lineStart = 0;\n\t\t\tlet newlineIndex = pending.indexOf(\"\\n\", lineStart);\n\t\t\twhile (newlineIndex !== -1) {\n\t\t\t\tif (!onLine(pending.slice(lineStart, newlineIndex), index++)) return;\n\t\t\t\tlineStart = newlineIndex + 1;\n\t\t\t\tnewlineIndex = pending.indexOf(\"\\n\", lineStart);\n\t\t\t}\n\t\t\tpending = pending.slice(lineStart);\n\t\t}\n\t\tpending += decoder.end();\n\t\tonLine(pending, index);\n\t} finally {\n\t\tawait handle.close();\n\t}\n}\n\nasync function readLocalLineSlice(absolutePath: string, options: LineSliceOptions): Promise<LineSlice> {\n\tconst lines: { text: string; originalIndex: number }[] = [];\n\tlet collectedChars = 0;\n\tlet sawMore = false;\n\tawait scanLines(absolutePath, (text, index) => {\n\t\tif (text === undefined) return false;\n\t\tif (index < options.startLine) return true;\n\t\tif (lines.length >= options.maxLines || collectedChars > options.maxChars) {\n\t\t\tsawMore = true;\n\t\t\treturn false;\n\t\t}\n\t\tlines.push({ text, originalIndex: index + 1 });\n\t\tcollectedChars += text.length;\n\t\treturn true;\n\t});\n\treturn { lines, reachedEnd: !sawMore };\n}\n\nasync function countLocalLines(absolutePath: string): Promise<number> {\n\tlet count = 0;\n\tawait scanLines(absolutePath, () => {\n\t\tcount++;\n\t\treturn true;\n\t});\n\treturn count;\n}\n\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n\tstat: async (path) => ({ size: (await fsStat(path)).size }),\n\treadLineSlice: readLocalLineSlice,\n\tcountLines: countLocalLines,\n};\n\n// Loading a whole file before truncation lets a single giant file spike the heap\n// to its full size. Beyond these budgets, text reads stream line slices (every\n// region stays reachable in batches — lossless). The image budget is deliberately\n// far above any real screenshot/photo so quality-degrading workarounds are never\n// needed in practice; it only guards against pathological files.\nconst DEFAULT_MAX_TEXT_READ_BYTES = 16 * 1024 * 1024;\nconst DEFAULT_MAX_IMAGE_READ_BYTES = 128 * 1024 * 1024;\n\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Custom operations for file reading. Default: local filesystem */\n\toperations?: ReadOperations;\n\t/** Whole-file load budget for text reads; larger files stream line slices instead. Default 16 MiB. */\n\tmaxTextReadBytes?: number;\n\t/** Pathology guard for image reads; larger images return downscale guidance. Default 128 MiB. */\n\tmaxImageReadBytes?: number;\n}\n\ntype ReadRenderArgs = { path?: string; file_path?: string; offset?: number; limit?: number };\n\nfunction formatReadLineRange(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tif (args?.offset === undefined && args?.limit === undefined) return \"\";\n\tconst startLine = args.offset ?? 1;\n\tconst endLine = args.limit !== undefined ? startLine + args.limit - 1 : \"\";\n\treturn theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n}\n\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\tif (!model || model.input.includes(\"image\")) {\n\t\treturn undefined;\n\t}\n\treturn \"[Current model does not support images. The image will be omitted from this request.]\";\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\n\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tif (!rawPath) return undefined;\n\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\n\treturn undefined;\n}\n\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\n\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tif (!options.expanded && !isError) {\n\t\treturn \"\";\n\t}\n\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result, showImages);\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")})`;\n\t}\n\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\n\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\tconst maxTextReadBytes = options?.maxTextReadBytes ?? DEFAULT_MAX_TEXT_READ_BYTES;\n\tconst maxImageReadBytes = options?.maxImageReadBytes ?? DEFAULT_MAX_IMAGE_READ_BYTES;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tpromptSnippet: \"Read file contents\",\n\t\tpromptGuidelines: [\"Use read to examine files instead of cat or sed.\"],\n\t\tparameters: readSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\toffset,\n\t\t\t\tlimit,\n\t\t\t\tlineNumbers,\n\t\t\t\ttail,\n\t\t\t\tfilter,\n\t\t\t}: {\n\t\t\t\tpath: string;\n\t\t\t\toffset?: number;\n\t\t\t\tlimit?: number;\n\t\t\t\tlineNumbers?: boolean;\n\t\t\t\ttail?: number;\n\t\t\t\tfilter?: \"none\" | \"minimal\" | \"aggressive\";\n\t\t\t},\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(path, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t// Check if file exists and is readable.\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tconst fileSize = ops.stat ? (await ops.stat(absolutePath)).size : undefined;\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\tif (fileSize !== undefined && fileSize > maxImageReadBytes) {\n\t\t\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\t\t\t\t\ttext: `Image file is ${formatSize(fileSize)} (${formatSize(maxImageReadBytes)} inline decode limit). Downscale it first, e.g. with bash (ImageMagick: magick \"${path}\" -resize 2000x2000 /tmp/preview.png) and read the result.`,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tif (autoResizeImages) {\n\t\t\t\t\t\t\t\t\t// Resize image if needed before sending it back to the model.\n\t\t\t\t\t\t\t\t\tconst resized = await resizeImage(buffer, mimeType);\n\t\t\t\t\t\t\t\t\tif (!resized) {\n\t\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n[Image omitted: could not be resized below the inline image size limit.]`;\n\t\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tconst dimensionNote = formatDimensionNote(resized);\n\t\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${resized.mimeType}]`;\n\t\t\t\t\t\t\t\t\t\tif (dimensionNote) textNote += `\\n${dimensionNote}`;\n\t\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: resized.data, mimeType: resized.mimeType },\n\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: buffer.toString(\"base64\"), mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Read text content. Oversized files are streamed as line slices so\n\t\t\t\t\t\t\t\t// any region stays reachable in batches without loading the whole file.\n\t\t\t\t\t\t\t\tconst useSlicedRead =\n\t\t\t\t\t\t\t\t\tfileSize !== undefined && fileSize > maxTextReadBytes && ops.readLineSlice !== undefined;\n\t\t\t\t\t\t\t\tlet startLine = 0;\n\t\t\t\t\t\t\t\tlet userLimitedLines = limit;\n\t\t\t\t\t\t\t\tlet totalFileLines: number | undefined;\n\t\t\t\t\t\t\t\tlet moreContentRemains = false;\n\t\t\t\t\t\t\t\tlet textContentForJsonCheck: string | undefined;\n\t\t\t\t\t\t\t\tlet slicedLines: { text: string; originalIndex: number }[];\n\t\t\t\t\t\t\t\tif (useSlicedRead && ops.readLineSlice) {\n\t\t\t\t\t\t\t\t\tif (offset !== undefined) {\n\t\t\t\t\t\t\t\t\t\tstartLine = Math.max(0, offset - 1);\n\t\t\t\t\t\t\t\t\t} else if (tail !== undefined) {\n\t\t\t\t\t\t\t\t\t\tconst counted = ops.countLines ? await ops.countLines(absolutePath) : undefined;\n\t\t\t\t\t\t\t\t\t\tif (counted !== undefined) {\n\t\t\t\t\t\t\t\t\t\t\ttotalFileLines = counted;\n\t\t\t\t\t\t\t\t\t\t\tstartLine = Math.max(0, counted - tail);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif (limit === undefined) {\n\t\t\t\t\t\t\t\t\t\t\tuserLimitedLines = tail;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tconst slice = await ops.readLineSlice(absolutePath, {\n\t\t\t\t\t\t\t\t\t\tstartLine,\n\t\t\t\t\t\t\t\t\t\tmaxLines: userLimitedLines ?? DEFAULT_MAX_LINES,\n\t\t\t\t\t\t\t\t\t\tmaxChars: DEFAULT_MAX_BYTES * 4,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (slice.lines.length === 0 && startLine > 0) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(`Offset ${startLine + 1} is beyond end of file`);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tslicedLines = slice.lines;\n\t\t\t\t\t\t\t\t\tmoreContentRemains = !slice.reachedEnd;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\t\tconst textContent = buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\t\ttextContentForJsonCheck = textContent;\n\t\t\t\t\t\t\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\t\ttotalFileLines = allLines.length;\n\t\t\t\t\t\t\t\t\t// Apply offset/tail if specified. Convert from 1-indexed input to 0-indexed array access.\n\t\t\t\t\t\t\t\t\tif (offset !== undefined) {\n\t\t\t\t\t\t\t\t\t\tstartLine = Math.max(0, offset - 1);\n\t\t\t\t\t\t\t\t\t} else if (tail !== undefined) {\n\t\t\t\t\t\t\t\t\t\tstartLine = Math.max(0, totalFileLines - tail);\n\t\t\t\t\t\t\t\t\t\tif (limit === undefined) {\n\t\t\t\t\t\t\t\t\t\t\tuserLimitedLines = tail;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Check if offset is out of bounds.\n\t\t\t\t\t\t\t\t\tif (startLine >= allLines.length && allLines.length > 0) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t`Offset ${startLine + 1} is beyond end of file (${allLines.length} lines total)`,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tslicedLines =\n\t\t\t\t\t\t\t\t\t\tuserLimitedLines !== undefined\n\t\t\t\t\t\t\t\t\t\t\t? allLines\n\t\t\t\t\t\t\t\t\t\t\t\t\t.map((line, idx) => ({ text: line, originalIndex: idx + 1 }))\n\t\t\t\t\t\t\t\t\t\t\t\t\t.slice(startLine, startLine + userLimitedLines)\n\t\t\t\t\t\t\t\t\t\t\t: allLines\n\t\t\t\t\t\t\t\t\t\t\t\t\t.map((line, idx) => ({ text: line, originalIndex: idx + 1 }))\n\t\t\t\t\t\t\t\t\t\t\t\t\t.slice(startLine);\n\t\t\t\t\t\t\t\t\tmoreContentRemains =\n\t\t\t\t\t\t\t\t\t\tuserLimitedLines !== undefined && startLine + userLimitedLines < allLines.length;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\tconst firstSelectedLineText = slicedLines[0]?.text ?? \"\";\n\n\t\t\t\t\t\t\t\t// Safe text filtering\n\t\t\t\t\t\t\t\tlet canFilter = true;\n\t\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t\tcanFilter = false;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tconst fileNameLower = path.toLowerCase();\n\t\t\t\t\t\t\t\t\tconst unsafeExtensions = [\n\t\t\t\t\t\t\t\t\t\t\".json\",\n\t\t\t\t\t\t\t\t\t\t\".jsonl\",\n\t\t\t\t\t\t\t\t\t\t\".yml\",\n\t\t\t\t\t\t\t\t\t\t\".yaml\",\n\t\t\t\t\t\t\t\t\t\t\".toml\",\n\t\t\t\t\t\t\t\t\t\t\".xml\",\n\t\t\t\t\t\t\t\t\t\t\".csv\",\n\t\t\t\t\t\t\t\t\t\t\".tsv\",\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\tif (unsafeExtensions.some((ext) => fileNameLower.endsWith(ext))) {\n\t\t\t\t\t\t\t\t\t\tcanFilter = false;\n\t\t\t\t\t\t\t\t\t} else if (textContentForJsonCheck !== undefined) {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tJSON.parse(textContentForJsonCheck);\n\t\t\t\t\t\t\t\t\t\t\tcanFilter = false;\n\t\t\t\t\t\t\t\t\t\t} catch {}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (canFilter && filter && filter !== \"none\") {\n\t\t\t\t\t\t\t\t\tconst filtered: typeof slicedLines = [];\n\t\t\t\t\t\t\t\t\tif (filter === \"minimal\") {\n\t\t\t\t\t\t\t\t\t\tlet consecutiveBlank = 0;\n\t\t\t\t\t\t\t\t\t\tfor (const item of slicedLines) {\n\t\t\t\t\t\t\t\t\t\t\tconst trimmed = item.text.trimEnd();\n\t\t\t\t\t\t\t\t\t\t\tif (trimmed === \"\") {\n\t\t\t\t\t\t\t\t\t\t\t\tconsecutiveBlank++;\n\t\t\t\t\t\t\t\t\t\t\t\tif (consecutiveBlank <= 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tfiltered.push({ text: \"\", originalIndex: item.originalIndex });\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\tconsecutiveBlank = 0;\n\t\t\t\t\t\t\t\t\t\t\t\tfiltered.push({ text: trimmed, originalIndex: item.originalIndex });\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\twhile (filtered.length > 0 && filtered[filtered.length - 1].text === \"\") {\n\t\t\t\t\t\t\t\t\t\t\tfiltered.pop();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else if (filter === \"aggressive\") {\n\t\t\t\t\t\t\t\t\t\tfor (const item of slicedLines) {\n\t\t\t\t\t\t\t\t\t\t\tconst trimmed = item.text.trimEnd();\n\t\t\t\t\t\t\t\t\t\t\tconst trimmedStart = trimmed.trimStart();\n\t\t\t\t\t\t\t\t\t\t\tif (trimmedStart === \"\") {\n\t\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\ttrimmedStart.startsWith(\"//\") ||\n\t\t\t\t\t\t\t\t\t\t\t\ttrimmedStart.startsWith(\"#\") ||\n\t\t\t\t\t\t\t\t\t\t\t\t(trimmedStart.startsWith(\"/*\") && trimmedStart.endsWith(\"*/\"))\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tfiltered.push({ text: trimmed, originalIndex: item.originalIndex });\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// If filtering would empty a non-empty list, keep original\n\t\t\t\t\t\t\t\t\tconst isOriginalNotEmpty = slicedLines.some((item) => item.text.trim().length > 0);\n\t\t\t\t\t\t\t\t\tconst isFilteredEmpty = filtered.every((item) => item.text.trim().length === 0);\n\t\t\t\t\t\t\t\t\tif (isOriginalNotEmpty && isFilteredEmpty) {\n\t\t\t\t\t\t\t\t\t\t// Fallback to slicedLines\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tslicedLines = filtered;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst finalLines = slicedLines.map((item) =>\n\t\t\t\t\t\t\t\t\tlineNumbers ? `${item.originalIndex}: ${item.text}` : item.text,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst selectedContent = finalLines.join(\"\\n\");\n\n\t\t\t\t\t\t\t\t// Apply truncation, respecting both line and byte limits.\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\tlet outputText: string;\n\t\t\t\t\t\t\t\tconst totalDisplay =\n\t\t\t\t\t\t\t\t\ttotalFileLines !== undefined\n\t\t\t\t\t\t\t\t\t\t? String(totalFileLines)\n\t\t\t\t\t\t\t\t\t\t: `a ${fileSize !== undefined ? formatSize(fileSize) : \"large\"} file`;\n\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t// First line alone exceeds the byte limit. Point the model at a bash fallback.\n\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(firstSelectedLineText, \"utf-8\"));\n\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t// Truncation occurred. Build an actionable continuation notice.\n\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalDisplay}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalDisplay} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (moreContentRemains) {\n\t\t\t\t\t\t\t\t\t// More content exists beyond this slice; hand the model a continuation pointer.\n\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + slicedLines.length + 1;\n\t\t\t\t\t\t\t\t\tconst remaining =\n\t\t\t\t\t\t\t\t\t\ttotalFileLines !== undefined && userLimitedLines !== undefined\n\t\t\t\t\t\t\t\t\t\t\t? `${totalFileLines - (startLine + userLimitedLines)} more lines in file`\n\t\t\t\t\t\t\t\t\t\t\t: \"More content remains\";\n\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// No truncation and no remaining content.\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details });\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification\n\t\t\t\t\t? formatCompactReadCall(classification, args, theme)\n\t\t\t\t\t: formatReadCall(args, theme, context.cwd),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ export { DefaultPackageManager } from "./core/package-manager.ts";
|
|
|
14
14
|
export { ACTIVE_TURN_TTL_MS, AUTO_RELOAD_COORDINATOR_TTL_MS, describeReloadSession, getPendingReloadBlockers, isReloadSessionProcessAlive, type PendingReloadBlockers, type ReloadBlockerOptions, type ReloadSessionRecord, } from "./core/reload-blockers.ts";
|
|
15
15
|
export type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from "./core/resource-loader.ts";
|
|
16
16
|
export { DefaultResourceLoader, loadProjectContextFiles } from "./core/resource-loader.ts";
|
|
17
|
+
export { mergeResourceProfileMap, mergeResourceProfileSettings, parseResourceProfileBlocks, parseResourceProfileInput, parseResourceProfileJson, stripResourceProfileBlocks, } from "./core/resource-profile-blocks.ts";
|
|
17
18
|
export { AgentSessionRuntime, type AgentSessionRuntimeDiagnostic, type AgentSessionServices, type CreateAgentSessionFromServicesOptions, type CreateAgentSessionOptions, type CreateAgentSessionResult, type CreateAgentSessionRuntimeFactory, type CreateAgentSessionRuntimeResult, type CreateAgentSessionServicesOptions, createAgentSession, createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, createBashTool, createCodingTools, createEditTool, createFindTool, createGrepTool, createLsTool, createReadOnlyTools, createReadTool, createWriteTool, type PromptTemplate, } from "./core/sdk.ts";
|
|
18
19
|
export { type BranchSummaryEntry, buildSessionContext, type CompactionEntry, CURRENT_SESSION_VERSION, type CustomEntry, type CustomMessageEntry, type FileEntry, getLatestCompactionEntry, type ModelChangeEntry, migrateSessionEntries, type NewSessionOptions, parseSessionEntries, type SessionContext, type SessionEntry, type SessionEntryBase, type SessionHeader, type SessionInfo, type SessionInfoEntry, SessionManager, type SessionMessageEntry, type ThinkingLevelChangeEntry, } from "./core/session-manager.ts";
|
|
19
|
-
export { type CompactionSettings, type ImageSettings, type PackageSource, type RetrySettings, SettingsManager, type SettingsManagerCreateOptions, } from "./core/settings-manager.ts";
|
|
20
|
+
export { type CompactionSettings, type DirectoryResourceProfileInfo, getDirectoryResourceProfileInfo, type ImageSettings, matchesResourceProfilePattern, type PackageSource, type ResourceProfileFilterSettings, type ResourceProfileKind, type ResourceProfileSettings, type RetrySettings, SettingsManager, type SettingsManagerCreateOptions, } from "./core/settings-manager.ts";
|
|
20
21
|
export { formatSkillsForPrompt, type LoadSkillsFromDirOptions, type LoadSkillsResult, loadSkills, loadSkillsFromDir, type Skill, type SkillFrontmatter, } from "./core/skills.ts";
|
|
21
22
|
export { createSyntheticSourceInfo } from "./core/source-info.ts";
|
|
22
23
|
export { type BashOperations, type BashSpawnContext, type BashSpawnHook, type BashToolDetails, type BashToolInput, type BashToolOptions, createBashToolDefinition, createEditToolDefinition, createFindToolDefinition, createGrepToolDefinition, createLocalBashOperations, createLsToolDefinition, createReadToolDefinition, createWriteToolDefinition, DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, type EditOperations, type EditToolDetails, type EditToolInput, type EditToolOptions, type FindOperations, type FindToolDetails, type FindToolInput, type FindToolOptions, formatSize, type GrepOperations, type GrepToolDetails, type GrepToolInput, type GrepToolOptions, type LsOperations, type LsToolDetails, type LsToolInput, type LsToolOptions, type ReadOperations, type ReadToolDetails, type ReadToolInput, type ReadToolOptions, type ToolsOptions, type TruncationOptions, type TruncationResult, truncateHead, truncateLine, truncateTail, type WriteOperations, type WriteToolInput, type WriteToolOptions, withFileMutationQueue, } from "./core/tools/index.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,eAAe,EACf,KAA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AE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype ImageSettings,\n\ttype PackageSource,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,YAAY,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,WAAW,EACX,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,eAAe,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACN,KAAK,iBAAiB,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EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["// Core session management\n\nexport { type Args, parseArgs } from \"./cli/args.ts\";\n\n// Config paths\nexport { getAgentDir, VERSION } from \"./config.ts\";\nexport {\n\tAgentSession,\n\ttype AgentSessionConfig,\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\ttype ModelCycleResult,\n\ttype ParsedSkillBlock,\n\ttype PromptOptions,\n\tparseSkillBlock,\n\ttype SessionStats,\n} from \"./core/agent-session.ts\";\n// Auth and model registry\nexport {\n\ttype ApiKeyCredential,\n\ttype AuthCredential,\n\ttype AuthStatus,\n\tAuthStorage,\n\ttype AuthStorageBackend,\n\tFileAuthStorageBackend,\n\tInMemoryAuthStorageBackend,\n\ttype OAuthCredential,\n} from \"./core/auth-storage.ts\";\n// Compaction\nexport {\n\ttype BranchPreparation,\n\ttype BranchSummaryResult,\n\ttype CollectEntriesResult,\n\ttype CompactionResult,\n\ttype CutPointResult,\n\tcalculateContextTokens,\n\tcollectEntriesForBranchSummary,\n\tcompact,\n\tDEFAULT_COMPACTION_SETTINGS,\n\testimateTokens,\n\ttype FileOperations,\n\tfindCutPoint,\n\tfindTurnStartIndex,\n\ttype GenerateBranchSummaryOptions,\n\tgenerateBranchSummary,\n\tgenerateSummary,\n\tgetLastAssistantUsage,\n\tprepareBranchEntries,\n\tserializeConversation,\n\tshouldCompact,\n} from \"./core/compaction/index.ts\";\nexport { createEventBus, type EventBus, type EventBusController } from \"./core/event-bus.ts\";\n// Extension system\nexport type {\n\tAgentEndEvent,\n\tAgentStartEvent,\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tAppKeybinding,\n\tAutocompleteProviderFactory,\n\tBashToolCallEvent,\n\tBeforeAgentStartEvent,\n\tBeforeAgentStartEventResult,\n\tBeforeProviderRequestEvent,\n\tBeforeProviderRequestEventResult,\n\tBuildSystemPromptOptions,\n\tCompactOptions,\n\tContextEvent,\n\tContextUsage,\n\tCustomToolCallEvent,\n\tEditToolCallEvent,\n\tExecOptions,\n\tExecResult,\n\tExtension,\n\tExtensionActions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionEvent,\n\tExtensionFactory,\n\tExtensionFlag,\n\tExtensionHandler,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tExtensionUIDialogOptions,\n\tExtensionWidgetOptions,\n\tFindToolCallEvent,\n\tGrepToolCallEvent,\n\tInputEvent,\n\tInputEventResult,\n\tInputSource,\n\tKeybindingsManager,\n\tLoadExtensionsResult,\n\tLsToolCallEvent,\n\tMessageRenderer,\n\tMessageRenderOptions,\n\tProviderConfig,\n\tProviderModelConfig,\n\tReadToolCallEvent,\n\tRegisteredCommand,\n\tRegisteredTool,\n\tResolvedCommand,\n\tSessionBeforeCompactEvent,\n\tSessionBeforeForkEvent,\n\tSessionBeforeSwitchEvent,\n\tSessionBeforeTreeEvent,\n\tSessionCompactEvent,\n\tSessionShutdownEvent,\n\tSessionStartEvent,\n\tSessionTreeEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tSourceInfo,\n\tTerminalInputHandler,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolDefinition,\n\tToolExecutionMode,\n\tToolInfo,\n\tToolRenderResultOptions,\n\tToolResultEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n\tUserBashEvent,\n\tUserBashEventResult,\n\tWidgetPlacement,\n\tWorkingIndicatorOptions,\n\tWriteToolCallEvent,\n} from \"./core/extensions/index.ts\";\nexport {\n\tcreateExtensionRuntime,\n\tdefineTool,\n\tdiscoverAndLoadExtensions,\n\tExtensionRunner,\n\tisBashToolResult,\n\tisEditToolResult,\n\tisFindToolResult,\n\tisGrepToolResult,\n\tisLsToolResult,\n\tisReadToolResult,\n\tisToolCallEventType,\n\tisWriteToolResult,\n\twrapRegisteredTool,\n\twrapRegisteredTools,\n} from \"./core/extensions/index.ts\";\n// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)\nexport type { ReadonlyFooterDataProvider } from \"./core/footer-data-provider.ts\";\nexport { convertToLlm } from \"./core/messages.ts\";\nexport { ModelRegistry } from \"./core/model-registry.ts\";\nexport type {\n\tPackageManager,\n\tPathMetadata,\n\tProgressCallback,\n\tProgressEvent,\n\tResolvedPaths,\n\tResolvedResource,\n} from \"./core/package-manager.ts\";\nexport { DefaultPackageManager } from \"./core/package-manager.ts\";\nexport {\n\tACTIVE_TURN_TTL_MS,\n\tAUTO_RELOAD_COORDINATOR_TTL_MS,\n\tdescribeReloadSession,\n\tgetPendingReloadBlockers,\n\tisReloadSessionProcessAlive,\n\ttype PendingReloadBlockers,\n\ttype ReloadBlockerOptions,\n\ttype ReloadSessionRecord,\n} from \"./core/reload-blockers.ts\";\nexport type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from \"./core/resource-loader.ts\";\nexport { DefaultResourceLoader, loadProjectContextFiles } from \"./core/resource-loader.ts\";\nexport {\n\tmergeResourceProfileMap,\n\tmergeResourceProfileSettings,\n\tparseResourceProfileBlocks,\n\tparseResourceProfileInput,\n\tparseResourceProfileJson,\n\tstripResourceProfileBlocks,\n} from \"./core/resource-profile-blocks.ts\";\n// SDK for programmatic usage\nexport {\n\tAgentSessionRuntime,\n\ttype AgentSessionRuntimeDiagnostic,\n\ttype AgentSessionServices,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionOptions,\n\ttype CreateAgentSessionResult,\n\ttype CreateAgentSessionRuntimeFactory,\n\ttype CreateAgentSessionRuntimeResult,\n\ttype CreateAgentSessionServicesOptions,\n\t// Factory\n\tcreateAgentSession,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateGrepTool,\n\tcreateLsTool,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateWriteTool,\n\ttype PromptTemplate,\n} from \"./core/sdk.ts\";\nexport {\n\ttype BranchSummaryEntry,\n\tbuildSessionContext,\n\ttype CompactionEntry,\n\tCURRENT_SESSION_VERSION,\n\ttype CustomEntry,\n\ttype CustomMessageEntry,\n\ttype FileEntry,\n\tgetLatestCompactionEntry,\n\ttype ModelChangeEntry,\n\tmigrateSessionEntries,\n\ttype NewSessionOptions,\n\tparseSessionEntries,\n\ttype SessionContext,\n\ttype SessionEntry,\n\ttype SessionEntryBase,\n\ttype SessionHeader,\n\ttype SessionInfo,\n\ttype SessionInfoEntry,\n\tSessionManager,\n\ttype SessionMessageEntry,\n\ttype ThinkingLevelChangeEntry,\n} from \"./core/session-manager.ts\";\nexport {\n\ttype CompactionSettings,\n\ttype DirectoryResourceProfileInfo,\n\tgetDirectoryResourceProfileInfo,\n\ttype ImageSettings,\n\tmatchesResourceProfilePattern,\n\ttype PackageSource,\n\ttype ResourceProfileFilterSettings,\n\ttype ResourceProfileKind,\n\ttype ResourceProfileSettings,\n\ttype RetrySettings,\n\tSettingsManager,\n\ttype SettingsManagerCreateOptions,\n} from \"./core/settings-manager.ts\";\n// Skills\nexport {\n\tformatSkillsForPrompt,\n\ttype LoadSkillsFromDirOptions,\n\ttype LoadSkillsResult,\n\tloadSkills,\n\tloadSkillsFromDir,\n\ttype Skill,\n\ttype SkillFrontmatter,\n} from \"./core/skills.ts\";\nexport { createSyntheticSourceInfo } from \"./core/source-info.ts\";\n// Tools\nexport {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashToolDefinition,\n\tcreateEditToolDefinition,\n\tcreateFindToolDefinition,\n\tcreateGrepToolDefinition,\n\tcreateLocalBashOperations,\n\tcreateLsToolDefinition,\n\tcreateReadToolDefinition,\n\tcreateWriteToolDefinition,\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n\tformatSize,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n\ttype ToolsOptions,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n\twithFileMutationQueue,\n} from \"./core/tools/index.ts\";\nexport { hasProjectTrustInputs, type ProjectTrustDecision, ProjectTrustStore } from \"./core/trust-manager.ts\";\n// Main entry point\nexport { type MainOptions, main } from \"./main.ts\";\n// Run modes for programmatic SDK usage\nexport {\n\tInteractiveMode,\n\ttype InteractiveModeOptions,\n\ttype ModelInfo,\n\ttype PrintModeOptions,\n\tRpcClient,\n\ttype RpcClientOptions,\n\ttype RpcCommand,\n\ttype RpcEventListener,\n\ttype RpcResponse,\n\ttype RpcSessionState,\n\trunPrintMode,\n\trunRpcMode,\n} from \"./modes/index.ts\";\n// UI components for extensions\nexport {\n\tArminComponent,\n\tAssistantMessageComponent,\n\tBashExecutionComponent,\n\tBorderedLoader,\n\tBranchSummaryMessageComponent,\n\tCompactionSummaryMessageComponent,\n\tCustomEditor,\n\tCustomMessageComponent,\n\tDynamicBorder,\n\tExtensionEditorComponent,\n\tExtensionInputComponent,\n\tExtensionSelectorComponent,\n\tFooterComponent,\n\tkeyHint,\n\tkeyText,\n\tLoginDialogComponent,\n\tModelSelectorComponent,\n\tOAuthSelectorComponent,\n\ttype RenderDiffOptions,\n\trawKeyHint,\n\trenderDiff,\n\trenderTitleBadge,\n\trenderToolTitle,\n\tSessionSelectorComponent,\n\ttype SettingsCallbacks,\n\ttype SettingsConfig,\n\tSettingsSelectorComponent,\n\tShowImagesSelectorComponent,\n\tSkillInvocationMessageComponent,\n\tThemeSelectorComponent,\n\tThinkingSelectorComponent,\n\tTitleBadgeComponent,\n\ttype TitleBadgeOptions,\n\ttype TitleBadgeSegment,\n\ttype TitleBadgeStatus,\n\tToolExecutionComponent,\n\ttype ToolExecutionOptions,\n\tToolTitleComponent,\n\ttype ToolTitleOptions,\n\ttype ToolTitleSegment,\n\ttype ToolTitleStatus,\n\tTreeSelectorComponent,\n\ttitleBadge,\n\ttoolTitle,\n\ttruncateToVisualLines,\n\tUserMessageComponent,\n\tUserMessageSelectorComponent,\n\ttype VisualTruncateResult,\n} from \"./modes/interactive/components/index.ts\";\n// Theme utilities for custom tools and extensions\nexport {\n\tgetLanguageFromPath,\n\tgetMarkdownTheme,\n\tgetSelectListTheme,\n\tgetSettingsListTheme,\n\thighlightCode,\n\tinitTheme,\n\tTheme,\n\ttype ThemeColor,\n} from \"./modes/interactive/theme/theme.ts\";\n// Clipboard utilities\nexport { copyToClipboard } from \"./utils/clipboard.ts\";\nexport { parseFrontmatter, stripFrontmatter } from \"./utils/frontmatter.ts\";\nexport { convertToPng } from \"./utils/image-convert.ts\";\nexport { formatDimensionNote, type ResizedImage, resizeImage } from \"./utils/image-resize.ts\";\n// Shell utilities\nexport { getShellConfig } from \"./utils/shell.ts\";\n"]}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { ModelRegistry } from "./core/model-registry.js";
|
|
|
14
14
|
export { DefaultPackageManager } from "./core/package-manager.js";
|
|
15
15
|
export { ACTIVE_TURN_TTL_MS, AUTO_RELOAD_COORDINATOR_TTL_MS, describeReloadSession, getPendingReloadBlockers, isReloadSessionProcessAlive, } from "./core/reload-blockers.js";
|
|
16
16
|
export { DefaultResourceLoader, loadProjectContextFiles } from "./core/resource-loader.js";
|
|
17
|
+
export { mergeResourceProfileMap, mergeResourceProfileSettings, parseResourceProfileBlocks, parseResourceProfileInput, parseResourceProfileJson, stripResourceProfileBlocks, } from "./core/resource-profile-blocks.js";
|
|
17
18
|
// SDK for programmatic usage
|
|
18
19
|
export { AgentSessionRuntime,
|
|
19
20
|
// Factory
|
|
@@ -21,7 +22,7 @@ createAgentSession, createAgentSessionFromServices, createAgentSessionRuntime, c
|
|
|
21
22
|
// Tool factories (for custom cwd)
|
|
22
23
|
createCodingTools, createEditTool, createFindTool, createGrepTool, createLsTool, createReadOnlyTools, createReadTool, createWriteTool, } from "./core/sdk.js";
|
|
23
24
|
export { buildSessionContext, CURRENT_SESSION_VERSION, getLatestCompactionEntry, migrateSessionEntries, parseSessionEntries, SessionManager, } from "./core/session-manager.js";
|
|
24
|
-
export { SettingsManager, } from "./core/settings-manager.js";
|
|
25
|
+
export { getDirectoryResourceProfileInfo, matchesResourceProfilePattern, SettingsManager, } from "./core/settings-manager.js";
|
|
25
26
|
// Skills
|
|
26
27
|
export { formatSkillsForPrompt, loadSkills, loadSkillsFromDir, } from "./core/skills.js";
|
|
27
28
|
export { createSyntheticSourceInfo } from "./core/source-info.js";
|