indusagi-coding-agent 0.1.24 → 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.
Files changed (101) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/cli/file-processor.js +1 -1
  3. package/dist/cli/file-processor.js.map +1 -1
  4. package/dist/core/agent-session.d.ts +1 -1
  5. package/dist/core/agent-session.d.ts.map +1 -1
  6. package/dist/core/agent-session.js +1 -1
  7. package/dist/core/agent-session.js.map +1 -1
  8. package/dist/core/bash-executor.d.ts +1 -1
  9. package/dist/core/bash-executor.d.ts.map +1 -1
  10. package/dist/core/bash-executor.js +1 -1
  11. package/dist/core/bash-executor.js.map +1 -1
  12. package/dist/core/discover-packages.d.ts +6 -0
  13. package/dist/core/discover-packages.d.ts.map +1 -0
  14. package/dist/core/discover-packages.js +62 -0
  15. package/dist/core/discover-packages.js.map +1 -0
  16. package/dist/core/extensions/types.d.ts +1 -3
  17. package/dist/core/extensions/types.d.ts.map +1 -1
  18. package/dist/core/sdk.d.ts.map +1 -1
  19. package/dist/core/sdk.js +2 -0
  20. package/dist/core/sdk.js.map +1 -1
  21. package/dist/core/settings-manager.js +1 -1
  22. package/dist/core/settings-manager.js.map +1 -1
  23. package/dist/core/task-session-manager.d.ts.map +1 -1
  24. package/dist/core/task-session-manager.js +1 -7
  25. package/dist/core/task-session-manager.js.map +1 -1
  26. package/dist/core/tools/bg-process.d.ts +49 -0
  27. package/dist/core/tools/bg-process.d.ts.map +1 -0
  28. package/dist/core/tools/bg-process.js +69 -0
  29. package/dist/core/tools/bg-process.js.map +1 -0
  30. package/dist/core/tools/index.d.ts +68 -16
  31. package/dist/core/tools/index.d.ts.map +1 -1
  32. package/dist/core/tools/index.js +100 -17
  33. package/dist/core/tools/index.js.map +1 -1
  34. package/dist/core/tools/registry.d.ts +17 -0
  35. package/dist/core/tools/registry.d.ts.map +1 -0
  36. package/dist/core/tools/registry.js +108 -0
  37. package/dist/core/tools/registry.js.map +1 -0
  38. package/dist/core/tools/todo.d.ts +4 -4
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/main.d.ts.map +1 -1
  43. package/dist/main.js +12 -1
  44. package/dist/main.js.map +1 -1
  45. package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
  46. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  47. package/dist/modes/interactive/components/bash-execution.js +1 -1
  48. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  49. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  50. package/dist/modes/interactive/components/tool-execution.js +2 -2
  51. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  52. package/docs/COMPREHENSIVE-CLI-SUMMARY.md +900 -0
  53. package/package.json +7 -3
  54. package/dist/core/tools/bash.d.ts +0 -428
  55. package/dist/core/tools/bash.d.ts.map +0 -1
  56. package/dist/core/tools/bash.js +0 -498
  57. package/dist/core/tools/bash.js.map +0 -1
  58. package/dist/core/tools/edit-diff.d.ts +0 -63
  59. package/dist/core/tools/edit-diff.d.ts.map +0 -1
  60. package/dist/core/tools/edit-diff.js +0 -243
  61. package/dist/core/tools/edit-diff.js.map +0 -1
  62. package/dist/core/tools/edit.d.ts +0 -315
  63. package/dist/core/tools/edit.d.ts.map +0 -1
  64. package/dist/core/tools/edit.js +0 -384
  65. package/dist/core/tools/edit.js.map +0 -1
  66. package/dist/core/tools/find.d.ts +0 -201
  67. package/dist/core/tools/find.d.ts.map +0 -1
  68. package/dist/core/tools/find.js +0 -342
  69. package/dist/core/tools/find.js.map +0 -1
  70. package/dist/core/tools/grep.d.ts +0 -323
  71. package/dist/core/tools/grep.d.ts.map +0 -1
  72. package/dist/core/tools/grep.js +0 -486
  73. package/dist/core/tools/grep.js.map +0 -1
  74. package/dist/core/tools/ls.d.ts +0 -44
  75. package/dist/core/tools/ls.d.ts.map +0 -1
  76. package/dist/core/tools/ls.js +0 -124
  77. package/dist/core/tools/ls.js.map +0 -1
  78. package/dist/core/tools/path-utils.d.ts +0 -8
  79. package/dist/core/tools/path-utils.d.ts.map +0 -1
  80. package/dist/core/tools/path-utils.js +0 -53
  81. package/dist/core/tools/path-utils.js.map +0 -1
  82. package/dist/core/tools/read.d.ts +0 -338
  83. package/dist/core/tools/read.d.ts.map +0 -1
  84. package/dist/core/tools/read.js +0 -397
  85. package/dist/core/tools/read.js.map +0 -1
  86. package/dist/core/tools/truncate.d.ts +0 -70
  87. package/dist/core/tools/truncate.d.ts.map +0 -1
  88. package/dist/core/tools/truncate.js +0 -205
  89. package/dist/core/tools/truncate.js.map +0 -1
  90. package/dist/core/tools/webfetch.d.ts +0 -174
  91. package/dist/core/tools/webfetch.d.ts.map +0 -1
  92. package/dist/core/tools/webfetch.js +0 -380
  93. package/dist/core/tools/webfetch.js.map +0 -1
  94. package/dist/core/tools/websearch.d.ts +0 -190
  95. package/dist/core/tools/websearch.d.ts.map +0 -1
  96. package/dist/core/tools/websearch.js +0 -267
  97. package/dist/core/tools/websearch.js.map +0 -1
  98. package/dist/core/tools/write.d.ts +0 -273
  99. package/dist/core/tools/write.d.ts.map +0 -1
  100. package/dist/core/tools/write.js +0 -288
  101. package/dist/core/tools/write.js.map +0 -1
@@ -1,273 +0,0 @@
1
- /**
2
- * Write Tool - Create and overwrite files with automatic directory creation
3
- *
4
- * @module core/tools/write
5
- * @description
6
- * Implements the write tool for the agent. Creates or overwrites files with:
7
- * - Automatic parent directory creation
8
- * - Path validation and resolution
9
- * - Remote execution support (SSH, containers)
10
- * - UTF-8 encoding
11
- *
12
- * Based on file writing patterns from Anthropic's Claude API.
13
- * Refactored for agent file system safety.
14
- * - Atomic writes (file written as a whole unit)
15
- *
16
- * ## Tool Interface
17
- *
18
- * **Input Parameters:**
19
- * - `path` (required): File path (relative or absolute)
20
- * - `content` (required): File content as string
21
- *
22
- * **Output:**
23
- * - Success: "File written" message
24
- * - Errors: Path invalid, permission denied, disk full, etc.
25
- *
26
- * **Error Behavior:**
27
- * - Invalid path → Tool error "Path outside working directory"
28
- * - Permission denied → Tool error "EACCES: permission denied"
29
- * - Disk full → Tool error "ENOSPC: no space left on device"
30
- * - Other errors → Tool error with message
31
- *
32
- * ## Usage in Agent
33
- *
34
- * The agent uses this tool to:
35
- * - Create new files (code, config, docs)
36
- * - Overwrite existing files
37
- * - Write generated content
38
- * - Create boilerplate and scaffolding
39
- * - Generate test fixtures
40
- *
41
- * Overwrites existing files completely (no merge).
42
- *
43
- * ## Features
44
- *
45
- * **Directory Creation:**
46
- * - Automatically creates parent directories
47
- * - Recursively creates full path
48
- * - No errors if dirs already exist
49
- *
50
- * **Path Safety:**
51
- * - All paths resolved relative to cwd
52
- * - No path traversal (no ../../../etc/passwd)
53
- * - Validates accessible location
54
- *
55
- * **Writing:**
56
- * - UTF-8 encoding (standard for code)
57
- * - Atomic write (no partial files)
58
- * - Overwrites completely (not merge)
59
- *
60
- * **Permissions:**
61
- * - Respects system umask
62
- * - Files created with standard permissions
63
- * - Errors on permission issues
64
- *
65
- * ## Security
66
- *
67
- * **Path validation:**
68
- * - All paths resolved relative to cwd
69
- * - No absolute paths outside cwd
70
- * - Directory traversal prevented
71
- *
72
- * **Write safety:**
73
- * - Cannot execute written files
74
- * - Files written as text, not executable
75
- * - Permission issues caught and reported
76
- *
77
- * **Disk safety:**
78
- * - System handles disk full errors
79
- * - Inode limit errors caught
80
- * - No intentional DoS vectors
81
- *
82
- * ## Customization
83
- *
84
- * **Remote Execution (SSH):**
85
- * ```typescript
86
- * const sshTool = createWriteTool(cwd, {
87
- * operations: {
88
- * writeFile: (path, content) => sshExec(`cat > ${path} << 'EOF'\n${content}\nEOF`),
89
- * mkdir: (dir) => sshExec(`mkdir -p ${dir}`),
90
- * },
91
- * });
92
- * ```
93
- *
94
- * ## Examples
95
- *
96
- * ### Create new file
97
- * ```typescript
98
- * // Agent calls: write {path: "hello.txt", content: "Hello, world!"}
99
- * // Result: File created with content
100
- * ```
101
- *
102
- * ### Create in subdirectory
103
- * ```typescript
104
- * // Agent calls: write {path: "src/main.ts", content: "..."}
105
- * // Result: src/ and src/main.ts created automatically
106
- * ```
107
- *
108
- * ### Overwrite existing file
109
- * ```typescript
110
- * // Agent calls: write {path: "existing.js", content: "..."}
111
- * // Result: File completely replaced with new content
112
- * ```
113
- *
114
- * ## Attribution
115
- *
116
- * Based on: indusagi-agent write tool
117
- * Modifications:
118
- * - Added custom operations interface
119
- * - Improved error messages
120
- * - Added directory creation details
121
- */
122
- import type { AgentTool } from "indusagi/agent";
123
- /**
124
- * JSON Schema for write tool parameters
125
- * @internal
126
- */
127
- declare const writeSchema: import("@sinclair/typebox").TObject<{
128
- path: import("@sinclair/typebox").TString;
129
- content: import("@sinclair/typebox").TString;
130
- }>;
131
- /**
132
- * Pluggable interface for file writing operations
133
- *
134
- * Allows custom implementations for:
135
- * - Remote file systems (SSH, cloud storage)
136
- * - Virtual file systems (in-memory, testing)
137
- * - Custom permission models
138
- * - Monitoring and auditing
139
- *
140
- * Implementations must respect working directory boundaries.
141
- */
142
- export interface WriteOperations {
143
- /**
144
- * Write content to a file (overwrite if exists)
145
- *
146
- * Must handle:
147
- * - Creating file if not exists
148
- * - Overwriting if exists
149
- * - UTF-8 encoding
150
- *
151
- * @param absolutePath - Full path to file (already validated)
152
- * @param content - File content as string
153
- * @throws Error on write failures
154
- */
155
- writeFile: (absolutePath: string, content: string) => Promise<void>;
156
- /**
157
- * Create directory (recursively)
158
- *
159
- * Must handle:
160
- * - Creating directory if not exists
161
- * - Creating parent directories
162
- * - Not erroring if already exists
163
- *
164
- * @param dir - Directory path (already validated)
165
- * @throws Error on creation failures
166
- */
167
- mkdir: (dir: string) => Promise<void>;
168
- }
169
- /**
170
- * Configuration options for the write tool
171
- */
172
- export interface WriteToolOptions {
173
- /**
174
- * Custom operations for file writing
175
- *
176
- * Default: Local filesystem operations
177
- * Custom: SSH, cloud storage, testing mocks
178
- *
179
- * @example
180
- * ```typescript
181
- * const tool = createWriteTool(cwd, {
182
- * operations: {
183
- * writeFile: (path, content) => sshExec(`cat > ${path}`, content),
184
- * mkdir: (dir) => sshExec(`mkdir -p ${dir}`),
185
- * },
186
- * });
187
- * ```
188
- */
189
- operations?: WriteOperations;
190
- }
191
- /**
192
- * Create a write tool with custom configuration
193
- *
194
- * Creates an AgentTool that can write files with:
195
- * - Automatic parent directory creation
196
- * - Path validation and resolution
197
- * - Remote execution support
198
- * - Proper error handling
199
- *
200
- * **Tool Behavior:**
201
- * - Resolves paths relative to working directory
202
- * - Prevents path traversal (no ../../../etc/passwd)
203
- * - Creates parent directories automatically
204
- * - Overwrites files completely (not merge/append)
205
- * - Returns success message
206
- *
207
- * **Tool Parameters:**
208
- * - `path` (required): File to write (relative or absolute)
209
- * - `content` (required): File content as string
210
- *
211
- * **Tool Output:**
212
- * - Success: "File written to <path>"
213
- * - Errors: Tool error with message
214
- *
215
- * **Error Handling:**
216
- * - Invalid path: Tool error "Path outside working directory"
217
- * - Permission denied: Tool error "EACCES: permission denied"
218
- * - Disk full: Tool error "ENOSPC: no space left on device"
219
- * - Other errors: Tool error with message
220
- *
221
- * @param cwd - Working directory for relative path resolution
222
- * - All relative paths resolved from this directory
223
- * - Prevents directory traversal attacks
224
- * - Can be overridden per execution
225
- *
226
- * @param options - Optional configuration
227
- * - operations: Custom file writing backend (default: filesystem)
228
- *
229
- * @returns AgentTool instance ready to use
230
- *
231
- * @example
232
- * ```typescript
233
- * // Basic tool
234
- * const tool = createWriteTool(process.cwd());
235
- *
236
- * // With remote backend (SSH)
237
- * const remoteTool = createWriteTool(cwd, {
238
- * operations: sshOperations,
239
- * });
240
- * ```
241
- *
242
- * @see WriteToolOptions for detailed configuration
243
- * @see WriteOperations for custom backend interface
244
- */
245
- export declare function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema>;
246
- /** Default write tool using process.cwd() - for backwards compatibility */
247
- /**
248
- * Default write tool instance
249
- *
250
- * Pre-created write tool using current process working directory.
251
- * Supports automatic directory creation and file overwriting.
252
- *
253
- * Equivalent to:
254
- * ```typescript
255
- * const writeTool = createWriteTool(process.cwd());
256
- * ```
257
- *
258
- * For custom configuration or remote backends, use createWriteTool() directly.
259
- *
260
- * @example
261
- * ```typescript
262
- * import { writeTool } from "./tools/write.js";
263
- * const agent = new Agent({ tools: [writeTool] });
264
- * ```
265
- *
266
- * @see createWriteTool for custom configuration
267
- */
268
- export declare const writeTool: AgentTool<import("@sinclair/typebox").TObject<{
269
- path: import("@sinclair/typebox").TString;
270
- content: import("@sinclair/typebox").TString;
271
- }>, any>;
272
- export {};
273
- //# sourceMappingURL=write.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwHG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUhD;;;GAGG;AACH,QAAA,MAAM,WAAW;;;EAGf,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC/B;;;;;;;;;;;OAWG;IACH,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;;;;;;;OAUG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAWD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;CAC7B;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAgFtG;AAED,2EAA2E;AAC3E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,SAAS;;;QAAiC,CAAC"}
@@ -1,288 +0,0 @@
1
- /**
2
- * Write Tool - Create and overwrite files with automatic directory creation
3
- *
4
- * @module core/tools/write
5
- * @description
6
- * Implements the write tool for the agent. Creates or overwrites files with:
7
- * - Automatic parent directory creation
8
- * - Path validation and resolution
9
- * - Remote execution support (SSH, containers)
10
- * - UTF-8 encoding
11
- *
12
- * Based on file writing patterns from Anthropic's Claude API.
13
- * Refactored for agent file system safety.
14
- * - Atomic writes (file written as a whole unit)
15
- *
16
- * ## Tool Interface
17
- *
18
- * **Input Parameters:**
19
- * - `path` (required): File path (relative or absolute)
20
- * - `content` (required): File content as string
21
- *
22
- * **Output:**
23
- * - Success: "File written" message
24
- * - Errors: Path invalid, permission denied, disk full, etc.
25
- *
26
- * **Error Behavior:**
27
- * - Invalid path → Tool error "Path outside working directory"
28
- * - Permission denied → Tool error "EACCES: permission denied"
29
- * - Disk full → Tool error "ENOSPC: no space left on device"
30
- * - Other errors → Tool error with message
31
- *
32
- * ## Usage in Agent
33
- *
34
- * The agent uses this tool to:
35
- * - Create new files (code, config, docs)
36
- * - Overwrite existing files
37
- * - Write generated content
38
- * - Create boilerplate and scaffolding
39
- * - Generate test fixtures
40
- *
41
- * Overwrites existing files completely (no merge).
42
- *
43
- * ## Features
44
- *
45
- * **Directory Creation:**
46
- * - Automatically creates parent directories
47
- * - Recursively creates full path
48
- * - No errors if dirs already exist
49
- *
50
- * **Path Safety:**
51
- * - All paths resolved relative to cwd
52
- * - No path traversal (no ../../../etc/passwd)
53
- * - Validates accessible location
54
- *
55
- * **Writing:**
56
- * - UTF-8 encoding (standard for code)
57
- * - Atomic write (no partial files)
58
- * - Overwrites completely (not merge)
59
- *
60
- * **Permissions:**
61
- * - Respects system umask
62
- * - Files created with standard permissions
63
- * - Errors on permission issues
64
- *
65
- * ## Security
66
- *
67
- * **Path validation:**
68
- * - All paths resolved relative to cwd
69
- * - No absolute paths outside cwd
70
- * - Directory traversal prevented
71
- *
72
- * **Write safety:**
73
- * - Cannot execute written files
74
- * - Files written as text, not executable
75
- * - Permission issues caught and reported
76
- *
77
- * **Disk safety:**
78
- * - System handles disk full errors
79
- * - Inode limit errors caught
80
- * - No intentional DoS vectors
81
- *
82
- * ## Customization
83
- *
84
- * **Remote Execution (SSH):**
85
- * ```typescript
86
- * const sshTool = createWriteTool(cwd, {
87
- * operations: {
88
- * writeFile: (path, content) => sshExec(`cat > ${path} << 'EOF'\n${content}\nEOF`),
89
- * mkdir: (dir) => sshExec(`mkdir -p ${dir}`),
90
- * },
91
- * });
92
- * ```
93
- *
94
- * ## Examples
95
- *
96
- * ### Create new file
97
- * ```typescript
98
- * // Agent calls: write {path: "hello.txt", content: "Hello, world!"}
99
- * // Result: File created with content
100
- * ```
101
- *
102
- * ### Create in subdirectory
103
- * ```typescript
104
- * // Agent calls: write {path: "src/main.ts", content: "..."}
105
- * // Result: src/ and src/main.ts created automatically
106
- * ```
107
- *
108
- * ### Overwrite existing file
109
- * ```typescript
110
- * // Agent calls: write {path: "existing.js", content: "..."}
111
- * // Result: File completely replaced with new content
112
- * ```
113
- *
114
- * ## Attribution
115
- *
116
- * Based on: indusagi-agent write tool
117
- * Modifications:
118
- * - Added custom operations interface
119
- * - Improved error messages
120
- * - Added directory creation details
121
- */
122
- import { Type } from "@sinclair/typebox";
123
- import { mkdir as fsMkdir, writeFile as fsWriteFile } from "fs/promises";
124
- import { dirname } from "path";
125
- import { resolveToCwd } from "./path-utils.js";
126
- // ============================================================================
127
- // Schema & Types
128
- // ============================================================================
129
- /**
130
- * JSON Schema for write tool parameters
131
- * @internal
132
- */
133
- const writeSchema = Type.Object({
134
- path: Type.String({ description: "Path to the file to write (relative or absolute)" }),
135
- content: Type.String({ description: "Content to write to the file" }),
136
- });
137
- /**
138
- * Default write operations using local filesystem
139
- * @internal
140
- */
141
- const defaultWriteOperations = {
142
- writeFile: (path, content) => fsWriteFile(path, content, "utf-8"),
143
- mkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => { }),
144
- };
145
- // ============================================================================
146
- // Tool Factory & Exports
147
- // ============================================================================
148
- /**
149
- * Create a write tool with custom configuration
150
- *
151
- * Creates an AgentTool that can write files with:
152
- * - Automatic parent directory creation
153
- * - Path validation and resolution
154
- * - Remote execution support
155
- * - Proper error handling
156
- *
157
- * **Tool Behavior:**
158
- * - Resolves paths relative to working directory
159
- * - Prevents path traversal (no ../../../etc/passwd)
160
- * - Creates parent directories automatically
161
- * - Overwrites files completely (not merge/append)
162
- * - Returns success message
163
- *
164
- * **Tool Parameters:**
165
- * - `path` (required): File to write (relative or absolute)
166
- * - `content` (required): File content as string
167
- *
168
- * **Tool Output:**
169
- * - Success: "File written to <path>"
170
- * - Errors: Tool error with message
171
- *
172
- * **Error Handling:**
173
- * - Invalid path: Tool error "Path outside working directory"
174
- * - Permission denied: Tool error "EACCES: permission denied"
175
- * - Disk full: Tool error "ENOSPC: no space left on device"
176
- * - Other errors: Tool error with message
177
- *
178
- * @param cwd - Working directory for relative path resolution
179
- * - All relative paths resolved from this directory
180
- * - Prevents directory traversal attacks
181
- * - Can be overridden per execution
182
- *
183
- * @param options - Optional configuration
184
- * - operations: Custom file writing backend (default: filesystem)
185
- *
186
- * @returns AgentTool instance ready to use
187
- *
188
- * @example
189
- * ```typescript
190
- * // Basic tool
191
- * const tool = createWriteTool(process.cwd());
192
- *
193
- * // With remote backend (SSH)
194
- * const remoteTool = createWriteTool(cwd, {
195
- * operations: sshOperations,
196
- * });
197
- * ```
198
- *
199
- * @see WriteToolOptions for detailed configuration
200
- * @see WriteOperations for custom backend interface
201
- */
202
- export function createWriteTool(cwd, options) {
203
- const ops = options?.operations ?? defaultWriteOperations;
204
- return {
205
- name: "write",
206
- label: "write",
207
- description: "Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Automatically creates parent directories.",
208
- parameters: writeSchema,
209
- execute: async (_toolCallId, { path, content }, signal) => {
210
- const absolutePath = resolveToCwd(path, cwd);
211
- const dir = dirname(absolutePath);
212
- return new Promise((resolve, reject) => {
213
- // Check if already aborted
214
- if (signal?.aborted) {
215
- reject(new Error("Operation aborted"));
216
- return;
217
- }
218
- let aborted = false;
219
- // Set up abort handler
220
- const onAbort = () => {
221
- aborted = true;
222
- reject(new Error("Operation aborted"));
223
- };
224
- if (signal) {
225
- signal.addEventListener("abort", onAbort, { once: true });
226
- }
227
- // Perform the write operation
228
- (async () => {
229
- try {
230
- // Create parent directories if needed
231
- await ops.mkdir(dir);
232
- // Check if aborted before writing
233
- if (aborted) {
234
- return;
235
- }
236
- // Write the file
237
- await ops.writeFile(absolutePath, content);
238
- // Check if aborted after writing
239
- if (aborted) {
240
- return;
241
- }
242
- // Clean up abort handler
243
- if (signal) {
244
- signal.removeEventListener("abort", onAbort);
245
- }
246
- resolve({
247
- content: [{ type: "text", text: `Successfully wrote ${content.length} bytes to ${path}` }],
248
- details: undefined,
249
- });
250
- }
251
- catch (error) {
252
- // Clean up abort handler
253
- if (signal) {
254
- signal.removeEventListener("abort", onAbort);
255
- }
256
- if (!aborted) {
257
- reject(error);
258
- }
259
- }
260
- })();
261
- });
262
- },
263
- };
264
- }
265
- /** Default write tool using process.cwd() - for backwards compatibility */
266
- /**
267
- * Default write tool instance
268
- *
269
- * Pre-created write tool using current process working directory.
270
- * Supports automatic directory creation and file overwriting.
271
- *
272
- * Equivalent to:
273
- * ```typescript
274
- * const writeTool = createWriteTool(process.cwd());
275
- * ```
276
- *
277
- * For custom configuration or remote backends, use createWriteTool() directly.
278
- *
279
- * @example
280
- * ```typescript
281
- * import { writeTool } from "./tools/write.js";
282
- * const agent = new Agent({ tools: [writeTool] });
283
- * ```
284
- *
285
- * @see createWriteTool for custom configuration
286
- */
287
- export const writeTool = createWriteTool(process.cwd());
288
- //# sourceMappingURL=write.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwHG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;IACtF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;CACrE,CAAC,CAAC;AA0CH;;;GAGG;AACH,MAAM,sBAAsB,GAAoB;IAC/C,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;IACjE,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;CAChE,CAAC;AAyBF,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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