indusagi-coding-agent 0.1.25 → 0.1.26
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 +60 -0
- package/dist/cli/file-processor.js +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -3
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/task-session-manager.d.ts.map +1 -1
- package/dist/core/task-session-manager.js +1 -7
- package/dist/core/task-session-manager.js.map +1 -1
- package/dist/core/tools/bg-process.d.ts +1 -1
- package/dist/core/tools/index.d.ts +57 -50
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +89 -21
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/todo.d.ts +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -2
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/package.json +3 -3
- package/dist/core/tools/bash.d.ts +0 -428
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js +0 -498
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit-diff.d.ts +0 -63
- package/dist/core/tools/edit-diff.d.ts.map +0 -1
- package/dist/core/tools/edit-diff.js +0 -243
- package/dist/core/tools/edit-diff.js.map +0 -1
- package/dist/core/tools/edit.d.ts +0 -315
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js +0 -384
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/find.d.ts +0 -201
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js +0 -342
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts +0 -323
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js +0 -486
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/ls.d.ts +0 -44
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/ls.js +0 -124
- package/dist/core/tools/ls.js.map +0 -1
- package/dist/core/tools/path-utils.d.ts +0 -8
- package/dist/core/tools/path-utils.d.ts.map +0 -1
- package/dist/core/tools/path-utils.js +0 -53
- package/dist/core/tools/path-utils.js.map +0 -1
- package/dist/core/tools/read.d.ts +0 -338
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js +0 -397
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/truncate.d.ts +0 -70
- package/dist/core/tools/truncate.d.ts.map +0 -1
- package/dist/core/tools/truncate.js +0 -205
- package/dist/core/tools/truncate.js.map +0 -1
- package/dist/core/tools/webfetch.d.ts +0 -174
- package/dist/core/tools/webfetch.d.ts.map +0 -1
- package/dist/core/tools/webfetch.js +0 -380
- package/dist/core/tools/webfetch.js.map +0 -1
- package/dist/core/tools/websearch.d.ts +0 -190
- package/dist/core/tools/websearch.d.ts.map +0 -1
- package/dist/core/tools/websearch.js +0 -267
- package/dist/core/tools/websearch.js.map +0 -1
- package/dist/core/tools/write.d.ts +0 -273
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/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OAAO,CAAC,CAAC;wBAC9C,MAAM,CAAC,CAAC,CAAC,CAAC;oBACX,CAAC;gBACF,CAAC,CAAC,EAAE,CAAC;YACN,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function expandPath(filePath: string): string;
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a path relative to the given cwd.
|
|
4
|
-
* Handles ~ expansion and absolute paths.
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveToCwd(filePath: string, cwd: string): string;
|
|
7
|
-
export declare function resolveReadPath(filePath: string, cwd: string): string;
|
|
8
|
-
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../../src/core/tools/path-utils.ts"],"names":[],"mappings":"AAuBA,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASnD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAMlE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAarE"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { accessSync, constants } from "node:fs";
|
|
2
|
-
import * as os from "node:os";
|
|
3
|
-
import { isAbsolute, resolve as resolvePath } from "node:path";
|
|
4
|
-
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
|
|
5
|
-
const NARROW_NO_BREAK_SPACE = "\u202F";
|
|
6
|
-
function normalizeUnicodeSpaces(str) {
|
|
7
|
-
return str.replace(UNICODE_SPACES, " ");
|
|
8
|
-
}
|
|
9
|
-
function tryMacOSScreenshotPath(filePath) {
|
|
10
|
-
return filePath.replace(/ (AM|PM)\./g, `${NARROW_NO_BREAK_SPACE}$1.`);
|
|
11
|
-
}
|
|
12
|
-
function fileExists(filePath) {
|
|
13
|
-
try {
|
|
14
|
-
accessSync(filePath, constants.F_OK);
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function expandPath(filePath) {
|
|
22
|
-
const normalized = normalizeUnicodeSpaces(filePath);
|
|
23
|
-
if (normalized === "~") {
|
|
24
|
-
return os.homedir();
|
|
25
|
-
}
|
|
26
|
-
if (normalized.startsWith("~/")) {
|
|
27
|
-
return os.homedir() + normalized.slice(1);
|
|
28
|
-
}
|
|
29
|
-
return normalized;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Resolve a path relative to the given cwd.
|
|
33
|
-
* Handles ~ expansion and absolute paths.
|
|
34
|
-
*/
|
|
35
|
-
export function resolveToCwd(filePath, cwd) {
|
|
36
|
-
const expanded = expandPath(filePath);
|
|
37
|
-
if (isAbsolute(expanded)) {
|
|
38
|
-
return expanded;
|
|
39
|
-
}
|
|
40
|
-
return resolvePath(cwd, expanded);
|
|
41
|
-
}
|
|
42
|
-
export function resolveReadPath(filePath, cwd) {
|
|
43
|
-
const resolved = resolveToCwd(filePath, cwd);
|
|
44
|
-
if (fileExists(resolved)) {
|
|
45
|
-
return resolved;
|
|
46
|
-
}
|
|
47
|
-
const macOSVariant = tryMacOSScreenshotPath(resolved);
|
|
48
|
-
if (macOSVariant !== resolved && fileExists(macOSVariant)) {
|
|
49
|
-
return macOSVariant;
|
|
50
|
-
}
|
|
51
|
-
return resolved;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=path-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../../src/core/tools/path-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AI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,OAAO,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,GAAW;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE7C,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,MAAM,YAAY,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,YAAY,KAAK,QAAQ,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3D,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Read Tool - Read file contents with automatic image handling
|
|
3
|
-
*
|
|
4
|
-
* @module core/tools/read
|
|
5
|
-
* @description
|
|
6
|
-
* Implements the read tool for the agent. Reads file contents with:
|
|
7
|
-
* - Support for line-based offset/limit
|
|
8
|
-
* - Automatic image detection and resizing
|
|
9
|
-
* - Large file truncation handling
|
|
10
|
-
* - Remote execution support (SSH, containers)
|
|
11
|
-
*
|
|
12
|
-
* Based on file reading tools from Anthropic's Claude API and common Unix utilities.
|
|
13
|
-
* Refactored for agent multimodal content handling.
|
|
14
|
-
* - Proper path resolution and validation
|
|
15
|
-
*
|
|
16
|
-
* ## Tool Interface
|
|
17
|
-
*
|
|
18
|
-
* **Input Parameters:**
|
|
19
|
-
* - `path` (required): File path to read (relative or absolute)
|
|
20
|
-
* - `offset` (optional): Starting line number (1-indexed)
|
|
21
|
-
* - `limit` (optional): Maximum number of lines to read
|
|
22
|
-
*
|
|
23
|
-
* **Output:**
|
|
24
|
-
* - Text files: Line content as text
|
|
25
|
-
* - Image files: Image data with metadata
|
|
26
|
-
* - Large files: Truncated with temp file path
|
|
27
|
-
*
|
|
28
|
-
* **Error Behavior:**
|
|
29
|
-
* - File not found → Tool error "ENOENT: no such file"
|
|
30
|
-
* - Permission denied → Tool error "EACCES: permission denied"
|
|
31
|
-
* - Invalid path → Tool error "Path outside working directory"
|
|
32
|
-
* - Large file not truncable → Tool error "File too large"
|
|
33
|
-
*
|
|
34
|
-
* ## Usage in Agent
|
|
35
|
-
*
|
|
36
|
-
* The agent uses this tool to:
|
|
37
|
-
* - Read source code files for analysis
|
|
38
|
-
* - Check configuration files
|
|
39
|
-
* - Read documentation and READMEs
|
|
40
|
-
* - View images and diagrams
|
|
41
|
-
* - Inspect logs and build output
|
|
42
|
-
*
|
|
43
|
-
* ## Features
|
|
44
|
-
*
|
|
45
|
-
* **Line-based Access:**
|
|
46
|
-
* - offset: Start reading from line N (1-indexed)
|
|
47
|
-
* - limit: Read at most N lines
|
|
48
|
-
* - Useful for large files
|
|
49
|
-
*
|
|
50
|
-
* **Image Handling:**
|
|
51
|
-
* - Auto-detect image MIME type
|
|
52
|
-
* - Resize large images (configurable)
|
|
53
|
-
* - Include dimension information
|
|
54
|
-
* - Provide helpful notes for vision models
|
|
55
|
-
*
|
|
56
|
-
* **Truncation:**
|
|
57
|
-
* - Truncate large files at front (keeps last N bytes)
|
|
58
|
-
* - Write full content to temp file if needed
|
|
59
|
-
* - Return truncation info for reference
|
|
60
|
-
*
|
|
61
|
-
* **Path Safety:**
|
|
62
|
-
* - Resolve relative paths relative to cwd
|
|
63
|
-
* - Prevent path traversal attacks (no ../../../etc/passwd)
|
|
64
|
-
* - Validate paths are accessible
|
|
65
|
-
*
|
|
66
|
-
* ## Security
|
|
67
|
-
*
|
|
68
|
-
* **Path validation:**
|
|
69
|
-
* - All paths resolved relative to cwd
|
|
70
|
-
* - No symlink following by default
|
|
71
|
-
* - Directory traversal prevented
|
|
72
|
-
*
|
|
73
|
-
* **Permission checks:**
|
|
74
|
-
* - File must be readable
|
|
75
|
-
* - Working directory must exist
|
|
76
|
-
* - Errors returned for permission denied
|
|
77
|
-
*
|
|
78
|
-
* **Data safety:**
|
|
79
|
-
* - Large files truncated (not read into memory)
|
|
80
|
-
* - Binary files handled gracefully
|
|
81
|
-
* - No automatic execution of file contents
|
|
82
|
-
*
|
|
83
|
-
* ## Customization
|
|
84
|
-
*
|
|
85
|
-
* **Image Resizing:**
|
|
86
|
-
* ```typescript
|
|
87
|
-
* const tool = createReadTool(cwd, {
|
|
88
|
-
* autoResizeImages: true,
|
|
89
|
-
* imageMaxBytes: 500 * 1024, // 500KB limit
|
|
90
|
-
* });
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* **Remote Execution (SSH):**
|
|
94
|
-
* ```typescript
|
|
95
|
-
* const sshTool = createReadTool(cwd, {
|
|
96
|
-
* operations: {
|
|
97
|
-
* readFile: (path) => sshExec(`cat ${path}`),
|
|
98
|
-
* access: (path) => sshExec(`test -r ${path}`),
|
|
99
|
-
* },
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*
|
|
103
|
-
* ## Examples
|
|
104
|
-
*
|
|
105
|
-
* ### Read a source file
|
|
106
|
-
* ```typescript
|
|
107
|
-
* // Agent calls: read {path: "src/main.ts"}
|
|
108
|
-
* // Returns: Full file content or truncated with temp file path
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* ### Read specific lines
|
|
112
|
-
* ```typescript
|
|
113
|
-
* // Agent calls: read {path: "test.txt", offset: 10, limit: 5}
|
|
114
|
-
* // Returns: Lines 10-14
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* ### Auto-resized image
|
|
118
|
-
* ```typescript
|
|
119
|
-
* // Agent calls: read {path: "diagram.png"}
|
|
120
|
-
* // Returns: Image content, resized if > 2MB, with dimensions
|
|
121
|
-
* ```
|
|
122
|
-
*
|
|
123
|
-
* ## Attribution
|
|
124
|
-
*
|
|
125
|
-
* Based on: indusagi-agent read tool
|
|
126
|
-
* Modifications:
|
|
127
|
-
* - Added image auto-detection and resizing
|
|
128
|
-
* - Added line-based offset/limit support
|
|
129
|
-
* - Added custom operations interface
|
|
130
|
-
* - Improved truncation handling
|
|
131
|
-
*/
|
|
132
|
-
import type { AgentTool } from "indusagi/agent";
|
|
133
|
-
import { type TruncationResult } from "./truncate.js";
|
|
134
|
-
/**
|
|
135
|
-
* JSON Schema for read tool parameters
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
declare const readSchema: import("@sinclair/typebox").TObject<{
|
|
139
|
-
path: import("@sinclair/typebox").TString;
|
|
140
|
-
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
141
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
142
|
-
}>;
|
|
143
|
-
/**
|
|
144
|
-
* Tool-specific details returned with read results
|
|
145
|
-
*/
|
|
146
|
-
export interface ReadToolDetails {
|
|
147
|
-
/** Truncation information if file was too large */
|
|
148
|
-
truncation?: TruncationResult;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Pluggable interface for file reading operations
|
|
152
|
-
*
|
|
153
|
-
* Allows custom implementations for:
|
|
154
|
-
* - Remote file systems (SSH, cloud storage)
|
|
155
|
-
* - Virtual file systems (in-memory, testing)
|
|
156
|
-
* - Custom permission models
|
|
157
|
-
* - Monitoring and logging
|
|
158
|
-
*
|
|
159
|
-
* Implementations must respect working directory boundaries.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* const sshOps: ReadOperations = {
|
|
164
|
-
* readFile: (path) => sshExec(`cat ${path}`),
|
|
165
|
-
* access: (path) => sshExec(`test -r ${path}`),
|
|
166
|
-
* detectImageMimeType: (path) => sshExec(`file -b --mime-type ${path}`),
|
|
167
|
-
* };
|
|
168
|
-
*
|
|
169
|
-
* const tool = createReadTool(cwd, { operations: sshOps });
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
export interface ReadOperations {
|
|
173
|
-
/**
|
|
174
|
-
* Read file contents as a Buffer
|
|
175
|
-
*
|
|
176
|
-
* @param absolutePath - Full path to file (already validated)
|
|
177
|
-
* @returns Buffer with file contents
|
|
178
|
-
* @throws ENOENT if file not found
|
|
179
|
-
* @throws EACCES if not readable
|
|
180
|
-
*/
|
|
181
|
-
readFile: (absolutePath: string) => Promise<Buffer>;
|
|
182
|
-
/**
|
|
183
|
-
* Check if file is readable
|
|
184
|
-
*
|
|
185
|
-
* @param absolutePath - Full path to file (already validated)
|
|
186
|
-
* @throws Error if not readable or doesn't exist
|
|
187
|
-
*/
|
|
188
|
-
access: (absolutePath: string) => Promise<void>;
|
|
189
|
-
/**
|
|
190
|
-
* Detect if file is an image and return MIME type
|
|
191
|
-
*
|
|
192
|
-
* @param absolutePath - Full path to file
|
|
193
|
-
* @returns MIME type like "image/png", or null/undefined if not an image
|
|
194
|
-
*/
|
|
195
|
-
detectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Configuration options for the read tool
|
|
199
|
-
*
|
|
200
|
-
* Allows customization of image handling and file reading backend.
|
|
201
|
-
*/
|
|
202
|
-
export interface ReadToolOptions {
|
|
203
|
-
/**
|
|
204
|
-
* Whether to auto-resize images to 2000x2000 max
|
|
205
|
-
*
|
|
206
|
-
* When enabled, images larger than the max will be:
|
|
207
|
-
* - Resized to fit within 2000x2000 pixels
|
|
208
|
-
* - Preserved as JPEG for smaller file size
|
|
209
|
-
* - Included with dimension notes in output
|
|
210
|
-
*
|
|
211
|
-
* Default: true (auto-resize enabled)
|
|
212
|
-
*
|
|
213
|
-
* Set to false if:
|
|
214
|
-
* - Vision model needs full resolution
|
|
215
|
-
* - Bandwidth/latency is not a concern
|
|
216
|
-
* - Custom resizing is handled elsewhere
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* ```typescript
|
|
220
|
-
* const tool = createReadTool(cwd, {
|
|
221
|
-
* autoResizeImages: false, // Keep full resolution
|
|
222
|
-
* });
|
|
223
|
-
* ```
|
|
224
|
-
*/
|
|
225
|
-
autoResizeImages?: boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Custom operations for file reading
|
|
228
|
-
*
|
|
229
|
-
* Default: Local filesystem operations
|
|
230
|
-
* Custom: SSH, cloud storage, testing mocks
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```typescript
|
|
234
|
-
* const tool = createReadTool(cwd, {
|
|
235
|
-
* operations: {
|
|
236
|
-
* readFile: (path) => sshExec(`cat ${path}`),
|
|
237
|
-
* access: (path) => sshExec(`test -r ${path}`),
|
|
238
|
-
* },
|
|
239
|
-
* });
|
|
240
|
-
* ```
|
|
241
|
-
*/
|
|
242
|
-
operations?: ReadOperations;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Create a read tool with custom configuration
|
|
246
|
-
*
|
|
247
|
-
* Creates an AgentTool that can read files with:
|
|
248
|
-
* - Line-based offset and limit
|
|
249
|
-
* - Automatic image detection and resizing
|
|
250
|
-
* - Large file truncation
|
|
251
|
-
* - Remote execution support
|
|
252
|
-
* - Proper path resolution
|
|
253
|
-
*
|
|
254
|
-
* **Tool Behavior:**
|
|
255
|
-
* - Resolves paths relative to working directory
|
|
256
|
-
* - Prevents path traversal (no ../../../etc/passwd)
|
|
257
|
-
* - Detects images and handles specially
|
|
258
|
-
* - Truncates large files at head (keeps tail)
|
|
259
|
-
* - Returns truncation info for reference
|
|
260
|
-
*
|
|
261
|
-
* **Tool Parameters:**
|
|
262
|
-
* - `path` (required): File to read
|
|
263
|
-
* - `offset` (optional): Starting line (1-indexed)
|
|
264
|
-
* - `limit` (optional): Maximum lines to read
|
|
265
|
-
*
|
|
266
|
-
* **Tool Output:**
|
|
267
|
-
* - Text files: File content (possibly truncated)
|
|
268
|
-
* - Image files: Image data with metadata
|
|
269
|
-
* - Details: Truncation info if file was too large
|
|
270
|
-
*
|
|
271
|
-
* **Error Handling:**
|
|
272
|
-
* - File not found: Tool error "ENOENT: no such file"
|
|
273
|
-
* - Permission denied: Tool error "EACCES: permission denied"
|
|
274
|
-
* - Invalid path: Tool error "Path outside working directory"
|
|
275
|
-
* - Other errors: Tool error with message
|
|
276
|
-
*
|
|
277
|
-
* @param cwd - Working directory for relative path resolution
|
|
278
|
-
* - All relative paths resolved from this directory
|
|
279
|
-
* - Prevents directory traversal attacks
|
|
280
|
-
* - Can be overridden per execution
|
|
281
|
-
*
|
|
282
|
-
* @param options - Optional configuration
|
|
283
|
-
* - autoResizeImages: Enable/disable image resizing (default: true)
|
|
284
|
-
* - operations: Custom file reading backend (default: filesystem)
|
|
285
|
-
*
|
|
286
|
-
* @returns AgentTool instance ready to use
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* ```typescript
|
|
290
|
-
* // Basic tool
|
|
291
|
-
* const tool = createReadTool(process.cwd());
|
|
292
|
-
*
|
|
293
|
-
* // With image resizing disabled
|
|
294
|
-
* const noResizeTool = createReadTool(cwd, {
|
|
295
|
-
* autoResizeImages: false,
|
|
296
|
-
* });
|
|
297
|
-
*
|
|
298
|
-
* // With remote backend (SSH)
|
|
299
|
-
* const remoteTool = createReadTool(cwd, {
|
|
300
|
-
* operations: sshOperations,
|
|
301
|
-
* });
|
|
302
|
-
* ```
|
|
303
|
-
*
|
|
304
|
-
* @see ReadToolOptions for detailed configuration
|
|
305
|
-
* @see ReadOperations for custom backend interface
|
|
306
|
-
*/
|
|
307
|
-
export declare function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema>;
|
|
308
|
-
/** Default read tool using process.cwd() - for backwards compatibility */
|
|
309
|
-
/**
|
|
310
|
-
* Default read tool instance
|
|
311
|
-
*
|
|
312
|
-
* Pre-created read tool using current process working directory.
|
|
313
|
-
* Supports line-based reading, image resizing, and truncation.
|
|
314
|
-
*
|
|
315
|
-
* Equivalent to:
|
|
316
|
-
* ```typescript
|
|
317
|
-
* const readTool = createReadTool(process.cwd(), {
|
|
318
|
-
* autoResizeImages: true,
|
|
319
|
-
* });
|
|
320
|
-
* ```
|
|
321
|
-
*
|
|
322
|
-
* For custom configuration or remote backends, use createReadTool() directly.
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* ```typescript
|
|
326
|
-
* import { readTool } from "./tools/read.js";
|
|
327
|
-
* const agent = new Agent({ tools: [readTool] });
|
|
328
|
-
* ```
|
|
329
|
-
*
|
|
330
|
-
* @see createReadTool for custom configuration
|
|
331
|
-
*/
|
|
332
|
-
export declare const readTool: AgentTool<import("@sinclair/typebox").TObject<{
|
|
333
|
-
path: import("@sinclair/typebox").TString;
|
|
334
|
-
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
335
|
-
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
336
|
-
}>, any>;
|
|
337
|
-
export {};
|
|
338
|
-
//# sourceMappingURL=read.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQhD,OAAO,EAAoD,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAMtH;;;GAGG;AACH,QAAA,MAAM,UAAU;;;;EAId,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,mDAAmD;IACnD,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,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