ai-code-agents 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1260 @@
1
+ import { FlexibleSchema, Tool } from '@ai-sdk/provider-utils';
2
+ import { ToolCallOptions, Experimental_AgentSettings, Experimental_Agent } from 'ai';
3
+ import * as z from 'zod';
4
+ import { z as z$1 } from 'zod';
5
+
6
+ declare const ReadFileResult: z.ZodObject<{
7
+ path: z.ZodString;
8
+ content: z.ZodString;
9
+ }, z.core.$strip>;
10
+ type ReadFileResult = z.infer<typeof ReadFileResult>;
11
+ declare const WriteFileResult: z.ZodObject<{
12
+ path: z.ZodString;
13
+ message: z.ZodString;
14
+ }, z.core.$strip>;
15
+ type WriteFileResult = z.infer<typeof WriteFileResult>;
16
+ declare const DeleteFileResult: z.ZodObject<{
17
+ path: z.ZodString;
18
+ message: z.ZodString;
19
+ }, z.core.$strip>;
20
+ type DeleteFileResult = z.infer<typeof DeleteFileResult>;
21
+ declare const MoveFileResult: z.ZodObject<{
22
+ sourcePath: z.ZodString;
23
+ destinationPath: z.ZodString;
24
+ message: z.ZodString;
25
+ }, z.core.$strip>;
26
+ type MoveFileResult = z.infer<typeof MoveFileResult>;
27
+ declare const CopyFileResult: z.ZodObject<{
28
+ sourcePath: z.ZodString;
29
+ destinationPath: z.ZodString;
30
+ message: z.ZodString;
31
+ }, z.core.$strip>;
32
+ type CopyFileResult = z.infer<typeof CopyFileResult>;
33
+ declare const RunCommandResult: z.ZodObject<{
34
+ command: z.ZodString;
35
+ exitCode: z.ZodNumber;
36
+ stdout: z.ZodString;
37
+ stderr: z.ZodString;
38
+ }, z.core.$strip>;
39
+ type RunCommandResult = z.infer<typeof RunCommandResult>;
40
+ interface FilesystemEnvironmentInterface {
41
+ get name(): string;
42
+ readFile(path: string): Promise<ReadFileResult>;
43
+ writeFile(path: string, content: string): Promise<WriteFileResult>;
44
+ deleteFile(path: string): Promise<DeleteFileResult>;
45
+ moveFile(sourcePath: string, destinationPath: string): Promise<MoveFileResult>;
46
+ copyFile(sourcePath: string, destinationPath: string): Promise<CopyFileResult>;
47
+ }
48
+ interface CommandLineEnvironmentInterface extends FilesystemEnvironmentInterface {
49
+ runCommand(command: string): Promise<RunCommandResult>;
50
+ }
51
+ type Environment = FilesystemEnvironmentInterface | CommandLineEnvironmentInterface;
52
+ type ModelTextResult = {
53
+ type: 'text';
54
+ value: string;
55
+ };
56
+ type ModelTextPart = {
57
+ type: 'text';
58
+ text: string;
59
+ };
60
+ type ModelMediaPart = {
61
+ type: 'media';
62
+ data: string;
63
+ mediaType: string;
64
+ };
65
+ type ModelFormattedToolResult = ModelTextResult | {
66
+ type: 'content';
67
+ value: Array<ModelTextPart | ModelMediaPart>;
68
+ };
69
+ type ToolExample<ToolInputType, ToolOutputType> = {
70
+ input: ToolInputType;
71
+ output: ToolOutputType | string;
72
+ };
73
+ interface ToolInterface<ToolInputType, ToolOutputType> {
74
+ get name(): string;
75
+ get description(): string;
76
+ get inputSchema(): FlexibleSchema<ToolInputType>;
77
+ get outputSchema(): FlexibleSchema<ToolOutputType>;
78
+ execute(input: ToolInputType, options: ToolCallOptions): Promise<ToolOutputType>;
79
+ toModelOutput(output: ToolOutputType): ModelFormattedToolResult;
80
+ get examples(): Array<ToolExample<ToolInputType, ToolOutputType>>;
81
+ get needsApproval(): boolean;
82
+ }
83
+ interface EnvironmentToolInterface<ToolInputType, ToolOutputType, EnvironmentType> extends ToolInterface<ToolInputType, ToolOutputType> {
84
+ get environment(): EnvironmentType;
85
+ }
86
+ type ToolConfig = {
87
+ name?: string;
88
+ description?: string;
89
+ needsApproval?: boolean;
90
+ };
91
+
92
+ /**
93
+ * Base class for a filesystem-based execution environment.
94
+ */
95
+ declare abstract class FilesystemEnvironmentBase<EnvironmentConfig> implements FilesystemEnvironmentInterface {
96
+ protected _envConfig: EnvironmentConfig;
97
+ /**
98
+ * Constructs a new environment instance.
99
+ *
100
+ * @param config - Environment configuration.
101
+ */
102
+ constructor(config: EnvironmentConfig);
103
+ /**
104
+ * Gets the environment name.
105
+ *
106
+ * @returns The environment name.
107
+ */
108
+ abstract get name(): string;
109
+ /**
110
+ * Reads the content of a file at the specified path.
111
+ *
112
+ * @param path - The path to the file to read, relative to the project directory.
113
+ * @returns A promise that resolves to a ReadFileResult.
114
+ */
115
+ readFile(path: string): Promise<ReadFileResult>;
116
+ /**
117
+ * Writes content to a file at the specified path.
118
+ *
119
+ * If a file is already present at the path, it will be overwritten.
120
+ *
121
+ * @param path - The path to the file to write, relative to the project directory.
122
+ * @param content - The content to write to the file.
123
+ * @returns A promise that resolves to a WriteFileResult.
124
+ */
125
+ writeFile(path: string, content: string): Promise<WriteFileResult>;
126
+ /**
127
+ * Deletes a file at the specified path.
128
+ *
129
+ * @param path - The path to the file to delete, relative to the project directory.
130
+ * @returns A promise that resolves to a DeleteFileResult.
131
+ */
132
+ deleteFile(path: string): Promise<DeleteFileResult>;
133
+ /**
134
+ * Moves a file from a source path to a destination path.
135
+ *
136
+ * If a file is already present at the destination path, it will be overwritten.
137
+ *
138
+ * @param sourcePath - The path to the file to move.
139
+ * @param destinationPath - The path to move the file to.
140
+ * @returns A promise that resolves to a MoveFileResult.
141
+ */
142
+ moveFile(sourcePath: string, destinationPath: string): Promise<MoveFileResult>;
143
+ /**
144
+ * Copies a file from a source path to a destination path.
145
+ *
146
+ * If a file is already present at the destination path, it will be overwritten.
147
+ *
148
+ * @param sourcePath - The path to the file to copy.
149
+ * @param destinationPath - The path to copy the file to.
150
+ * @returns A promise that resolves to a CopyFileResult.
151
+ */
152
+ copyFile(sourcePath: string, destinationPath: string): Promise<CopyFileResult>;
153
+ /**
154
+ * Checks whether a file exists at the specified path relative to the project directory.
155
+ *
156
+ * @param relativePath - The path to the file to check, relative to the project directory.
157
+ * @returns True if the file exists, false otherwise.
158
+ */
159
+ protected abstract fileExists(relativePath: string): Promise<boolean>;
160
+ /**
161
+ * Gets the content of a file at the specified path, relative to the project directory.
162
+ *
163
+ * When this method is called, it is guaranteed that the file exists.
164
+ *
165
+ * @param relativePath - The path to the file to read, relative to the project directory.
166
+ * @returns The content of the file.
167
+ */
168
+ protected abstract readFileContent(relativePath: string): Promise<string>;
169
+ /**
170
+ * Writes content to a file at the specified path, relative to the project directory.
171
+ *
172
+ * This method unconditionally writes the content, even if a file already exists at the path, or if the file is new.
173
+ *
174
+ * @param relativePath - The path to the file to write, relative to the project directory.
175
+ * @param content - The content to write to the file.
176
+ */
177
+ protected abstract writeFileContent(relativePath: string, content: string): Promise<void>;
178
+ /**
179
+ * Deletes a file at the specified path, relative to the project directory.
180
+ *
181
+ * When this method is called, it is guaranteed that the file exists.
182
+ *
183
+ * @param relativePath - The path to the file to delete, relative to the project directory.
184
+ */
185
+ protected abstract deleteFileContent(relativePath: string): Promise<void>;
186
+ /**
187
+ * Moves the content of a file from a source path to a destination path, relative to the project directory.
188
+ *
189
+ * When this method is called, it is guaranteed that the source file exists.
190
+ * This method unconditionally moves the content, even if a file already exists at the destination path.
191
+ *
192
+ * @param relativeSourcePath - The path to the file to move, relative to the project directory.
193
+ * @param relativeDestinationPath - The path to move the file to, relative to the project directory.
194
+ */
195
+ protected moveFileContent(relativeSourcePath: string, relativeDestinationPath: string): Promise<void>;
196
+ /**
197
+ * Copies the content of a file from a source path to a destination path, relative to the project directory.
198
+ *
199
+ * When this method is called, it is guaranteed that the source file exists.
200
+ * This method unconditionally copies the content, even if a file already exists at the destination path.
201
+ *
202
+ * @param relativeSourcePath - The path to the file to copy, relative to the project directory.
203
+ * @param relativeDestinationPath - The path to copy the file to, relative to the project directory.
204
+ */
205
+ protected copyFileContent(relativeSourcePath: string, relativeDestinationPath: string): Promise<void>;
206
+ }
207
+
208
+ /**
209
+ * Base class for a command-line based execution environment.
210
+ */
211
+ declare abstract class CommandLineEnvironmentBase<EnvironmentConfig> extends FilesystemEnvironmentBase<EnvironmentConfig> implements CommandLineEnvironmentInterface {
212
+ /**
213
+ * Runs a CLI command in environment.
214
+ *
215
+ * @param command - The command to run.
216
+ * @returns A promise that resolves to a RunCommandResult.
217
+ */
218
+ runCommand(command: string): Promise<RunCommandResult>;
219
+ /**
220
+ * Executes a command in the environment and returns the exit code, stdout, and stderr.
221
+ *
222
+ * @param command - The command to execute.
223
+ * @returns A promise that resolves to a tuple containing the exit code, stdout, and stderr.
224
+ */
225
+ protected abstract executeCommand(command: string): Promise<[number, string, string]>;
226
+ }
227
+
228
+ /**
229
+ * Base class for a Unix-like command line execution environment.
230
+ */
231
+ declare abstract class UnixEnvironmentBase<EnvironmentConfig> extends CommandLineEnvironmentBase<EnvironmentConfig> {
232
+ /**
233
+ * Checks whether a file exists at the specified path relative to the project directory.
234
+ *
235
+ * @param relativePath - The path to the file to check, relative to the project directory.
236
+ * @returns True if the file exists, false otherwise.
237
+ */
238
+ protected fileExists(relativePath: string): Promise<boolean>;
239
+ /**
240
+ * Gets the content of a file at the specified path, relative to the project directory.
241
+ *
242
+ * When this method is called, it is guaranteed that the file exists.
243
+ *
244
+ * @param relativePath - The path to the file to read, relative to the project directory.
245
+ * @returns The content of the file.
246
+ */
247
+ protected readFileContent(relativePath: string): Promise<string>;
248
+ /**
249
+ * Writes content to a file at the specified path, relative to the project directory.
250
+ *
251
+ * This method unconditionally writes the content, even if a file already exists at the path, or if the file is new.
252
+ *
253
+ * @param relativePath - The path to the file to write, relative to the project directory.
254
+ * @param content - The content to write to the file.
255
+ */
256
+ protected writeFileContent(relativePath: string, content: string): Promise<void>;
257
+ /**
258
+ * Deletes a file at the specified path, relative to the project directory.
259
+ *
260
+ * When this method is called, it is guaranteed that the file exists.
261
+ *
262
+ * @param relativePath - The path to the file to delete, relative to the project directory.
263
+ */
264
+ protected deleteFileContent(relativePath: string): Promise<void>;
265
+ /**
266
+ * Moves the content of a file from a source path to a destination path, relative to the project directory.
267
+ *
268
+ * When this method is called, it is guaranteed that the source file exists.
269
+ * This method unconditionally moves the content, even if a file already exists at the destination path.
270
+ *
271
+ * @param relativeSourcePath - The path to the file to move, relative to the project directory.
272
+ * @param relativeDestinationPath - The path to move the file to, relative to the project directory.
273
+ */
274
+ protected moveFileContent(relativeSourcePath: string, relativeDestinationPath: string): Promise<void>;
275
+ /**
276
+ * Copies the content of a file from a source path to a destination path, relative to the project directory.
277
+ *
278
+ * When this method is called, it is guaranteed that the source file exists.
279
+ * This method unconditionally copies the content, even if a file already exists at the destination path.
280
+ *
281
+ * @param relativeSourcePath - The path to the file to copy, relative to the project directory.
282
+ * @param relativeDestinationPath - The path to copy the file to, relative to the project directory.
283
+ */
284
+ protected copyFileContent(relativeSourcePath: string, relativeDestinationPath: string): Promise<void>;
285
+ }
286
+
287
+ type DockerEnvironmentConfig = {
288
+ containerId: string;
289
+ directoryPath?: string;
290
+ };
291
+ declare const DockerEnvironmentName = "docker";
292
+ /**
293
+ * A Docker-based execution environment that interacts with a specified Docker container.
294
+ */
295
+ declare class DockerEnvironment extends UnixEnvironmentBase<DockerEnvironmentConfig> {
296
+ protected readonly _commandPrefix: string;
297
+ /**
298
+ * Constructs a new environment instance.
299
+ *
300
+ * @param config - Environment configuration.
301
+ */
302
+ constructor(config: DockerEnvironmentConfig);
303
+ /**
304
+ * Gets the environment name.
305
+ *
306
+ * @returns The environment name.
307
+ */
308
+ get name(): string;
309
+ /**
310
+ * Executes a command in the environment and returns the exit code, stdout, and stderr.
311
+ *
312
+ * @param command - The command to execute.
313
+ * @returns A promise that resolves to a tuple containing the exit code, stdout, and stderr.
314
+ */
315
+ protected executeCommand(command: string): Promise<[number, string, string]>;
316
+ }
317
+
318
+ type MockFilesystemEnvironmentConfig = {
319
+ initialFiles?: Map<string, string>;
320
+ directoryPath?: string;
321
+ };
322
+ declare const MockFilesystemEnvironmentName = "mock-filesystem";
323
+ /**
324
+ * An in-memory execution environment that simulates a filesystem.
325
+ *
326
+ * This environment is useful for testing purposes where you want to control the
327
+ * filesystem state without interacting with the actual disk.
328
+ */
329
+ declare class MockFilesystemEnvironment extends FilesystemEnvironmentBase<MockFilesystemEnvironmentConfig> {
330
+ protected readonly files: Map<string, string>;
331
+ protected readonly _preparePath: (filePath: string) => string;
332
+ /**
333
+ * Constructs a new environment instance.
334
+ *
335
+ * @param config - Environment configuration.
336
+ */
337
+ constructor(config?: MockFilesystemEnvironmentConfig);
338
+ /**
339
+ * Gets the environment name.
340
+ *
341
+ * @returns The environment name.
342
+ */
343
+ get name(): string;
344
+ /**
345
+ * Checks whether a file exists at the specified path relative to the project directory.
346
+ *
347
+ * @param relativePath - The path to the file to check, relative to the project directory.
348
+ * @returns True if the file exists, false otherwise.
349
+ */
350
+ protected fileExists(relativePath: string): Promise<boolean>;
351
+ /**
352
+ * Gets the content of a file at the specified path, relative to the project directory.
353
+ *
354
+ * When this method is called, it is guaranteed that the file exists.
355
+ *
356
+ * @param relativePath - The path to the file to read, relative to the project directory.
357
+ * @returns The content of the file.
358
+ */
359
+ protected readFileContent(relativePath: string): Promise<string>;
360
+ /**
361
+ * Writes content to a file at the specified path, relative to the project directory.
362
+ *
363
+ * This method unconditionally writes the content, even if a file already exists at the path, or if the file is new.
364
+ *
365
+ * @param relativePath - The path to the file to write, relative to the project directory.
366
+ * @param content - The content to write to the file.
367
+ */
368
+ protected writeFileContent(relativePath: string, content: string): Promise<void>;
369
+ /**
370
+ * Deletes a file at the specified path, relative to the project directory.
371
+ *
372
+ * @param relativePath - The path to the file to delete, relative to the project directory.
373
+ */
374
+ protected deleteFileContent(relativePath: string): Promise<void>;
375
+ }
376
+
377
+ type NodeFilesystemEnvironmentConfig = {
378
+ directoryPath: string;
379
+ };
380
+ declare const NodeFilesystemEnvironmentName = "node-filesystem";
381
+ /**
382
+ * A Node.js filesystem-based execution environment.
383
+ *
384
+ * This environment uses Node.js fs/promises APIs to provide filesystem operations
385
+ * within a specified directory path. All relative file paths are resolved relative
386
+ * to the configured directoryPath.
387
+ */
388
+ declare class NodeFilesystemEnvironment extends FilesystemEnvironmentBase<NodeFilesystemEnvironmentConfig> {
389
+ /**
390
+ * Constructs a new NodeFilesystemEnvironment instance.
391
+ *
392
+ * @param config - Environment configuration including the mandatory directoryPath.
393
+ */
394
+ constructor(config: NodeFilesystemEnvironmentConfig);
395
+ /**
396
+ * Gets the environment name.
397
+ *
398
+ * @returns The environment name.
399
+ */
400
+ get name(): string;
401
+ /**
402
+ * Checks whether a file exists at the specified path relative to the project directory.
403
+ *
404
+ * @param relativePath - The path to the file to check, relative to the project directory.
405
+ * @returns True if the file exists, false otherwise.
406
+ */
407
+ protected fileExists(relativePath: string): Promise<boolean>;
408
+ /**
409
+ * Gets the content of a file at the specified path, relative to the project directory.
410
+ *
411
+ * When this method is called, it is guaranteed that the file exists.
412
+ *
413
+ * @param relativePath - The path to the file to read, relative to the project directory.
414
+ * @returns The content of the file.
415
+ */
416
+ protected readFileContent(relativePath: string): Promise<string>;
417
+ /**
418
+ * Writes content to a file at the specified path, relative to the project directory.
419
+ *
420
+ * This method unconditionally writes the content, even if a file already exists at the path, or if the file is new.
421
+ *
422
+ * @param relativePath - The path to the file to write, relative to the project directory.
423
+ * @param content - The content to write to the file.
424
+ */
425
+ protected writeFileContent(relativePath: string, content: string): Promise<void>;
426
+ /**
427
+ * Deletes a file at the specified path, relative to the project directory.
428
+ *
429
+ * When this method is called, it is guaranteed that the file exists.
430
+ *
431
+ * @param relativePath - The path to the file to delete, relative to the project directory.
432
+ */
433
+ protected deleteFileContent(relativePath: string): Promise<void>;
434
+ /**
435
+ * Moves the content of a file from a source path to a destination path, relative to the project directory.
436
+ *
437
+ * When this method is called, it is guaranteed that the source file exists.
438
+ * This method unconditionally moves the content, even if a file already exists at the destination path.
439
+ *
440
+ * @param relativeSourcePath - The path to the file to move, relative to the project directory.
441
+ * @param relativeDestinationPath - The path to move the file to, relative to the project directory.
442
+ */
443
+ protected moveFileContent(relativeSourcePath: string, relativeDestinationPath: string): Promise<void>;
444
+ }
445
+
446
+ type UnsafeLocalEnvironmentConfig = {
447
+ directoryPath: string;
448
+ };
449
+ declare const UnsafeLocalEnvironmentName = "unsafe-local";
450
+ /**
451
+ * A local command line execution environment in a specific directory, without any safety mechanisms.
452
+ *
453
+ * WARNING: This environment is unsafe because it allows unrestricted access to
454
+ * the local file system and command line. It should only be used in controlled
455
+ * environments where security is not a concern.
456
+ */
457
+ declare class UnsafeLocalEnvironment extends UnixEnvironmentBase<UnsafeLocalEnvironmentConfig> {
458
+ protected readonly _commandPrefix: string;
459
+ /**
460
+ * Constructs a new environment instance.
461
+ *
462
+ * @param config - Environment configuration.
463
+ */
464
+ constructor(config: UnsafeLocalEnvironmentConfig);
465
+ /**
466
+ * Gets the environment name.
467
+ *
468
+ * @returns The environment name.
469
+ */
470
+ get name(): string;
471
+ /**
472
+ * Executes a command in the environment and returns the exit code, stdout, and stderr.
473
+ *
474
+ * @param command - The command to execute.
475
+ * @returns A promise that resolves to a tuple containing the exit code, stdout, and stderr.
476
+ */
477
+ protected executeCommand(command: string): Promise<[number, string, string]>;
478
+ }
479
+
480
+ type FlexibleInputSchema<T> = ToolInterface<T, unknown>['inputSchema'];
481
+ type FlexibleOutputSchema<T> = ToolInterface<unknown, T>['outputSchema'];
482
+ type ToolMetadata<ToolInputType, ToolOutputType> = {
483
+ name: string;
484
+ description: string;
485
+ inputSchema: FlexibleInputSchema<ToolInputType>;
486
+ outputSchema: FlexibleOutputSchema<ToolOutputType>;
487
+ needsApproval: boolean;
488
+ };
489
+ /**
490
+ * Base class for a tool.
491
+ */
492
+ declare abstract class ToolBase<ToolConfig extends ToolConfig, ToolInputType, ToolOutputType> implements ToolInterface<ToolInputType, ToolOutputType> {
493
+ readonly _toolConfig: ToolConfig;
494
+ protected readonly _name: string;
495
+ protected readonly _description: string;
496
+ protected readonly _inputSchema: FlexibleInputSchema<ToolInputType>;
497
+ protected readonly _outputSchema: FlexibleOutputSchema<ToolOutputType>;
498
+ protected readonly _needsApproval: boolean;
499
+ /**
500
+ * Constructs a new tool instance.
501
+ *
502
+ * @param toolConfig - Optional tool config, can be used to override some defaults.
503
+ */
504
+ constructor(toolConfig?: ToolConfig);
505
+ /**
506
+ * Gets the tool name.
507
+ *
508
+ * @returns The tool name.
509
+ */
510
+ get name(): string;
511
+ /**
512
+ * Gets the tool description.
513
+ *
514
+ * @returns The tool description.
515
+ */
516
+ get description(): string;
517
+ /**
518
+ * Gets the input schema for the tool.
519
+ *
520
+ * @returns The input schema.
521
+ */
522
+ get inputSchema(): FlexibleInputSchema<ToolInputType>;
523
+ /**
524
+ * Gets the input schema for the tool.
525
+ *
526
+ * @returns The input schema.
527
+ */
528
+ get outputSchema(): FlexibleInputSchema<ToolOutputType>;
529
+ /**
530
+ * Gets whether the tool needs approval before use.
531
+ *
532
+ * @returns True if the tool needs approval, false otherwise.
533
+ */
534
+ get needsApproval(): boolean;
535
+ /**
536
+ * Gets the examples for the tool.
537
+ *
538
+ * @returns The tool examples.
539
+ */
540
+ abstract get examples(): Array<ToolExample<ToolInputType, ToolOutputType>>;
541
+ /**
542
+ * Executes the tool with the given input.
543
+ *
544
+ * @param input - The input for the tool.
545
+ * @param options - Options from the tool call.
546
+ * @returns A promise that resolves to the tool execution result.
547
+ */
548
+ abstract execute(input: ToolInputType, options: ToolCallOptions): Promise<ToolOutputType>;
549
+ /**
550
+ * Converts the tool output to a format suitable for model consumption.
551
+ *
552
+ * @param output - The output from the tool execution.
553
+ * @returns The formatted tool result.
554
+ */
555
+ abstract toModelOutput(output: ToolOutputType): ModelFormattedToolResult;
556
+ /**
557
+ * Returns the metadata for the tool.
558
+ *
559
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
560
+ *
561
+ * @returns The tool metadata.
562
+ */
563
+ protected abstract getMetadata(): ToolMetadata<ToolInputType, ToolOutputType>;
564
+ }
565
+
566
+ type EnvironmentToolMetadata<ToolInputType, ToolOutputType> = ToolMetadata<ToolInputType, ToolOutputType>;
567
+ /**
568
+ * Base class for an execution environment tool.
569
+ */
570
+ declare abstract class EnvironmentToolBase<ToolConfig extends ToolConfig, ToolInputType, ToolOutputType, EnvironmentType> extends ToolBase<ToolConfig, ToolInputType, ToolOutputType> implements EnvironmentToolInterface<ToolInputType, ToolOutputType, EnvironmentType> {
571
+ protected readonly _environment: EnvironmentType;
572
+ /**
573
+ * Constructs a new `EnvironmentToolBase` instance.
574
+ *
575
+ * @param environment - The execution environment to apply the tool in.
576
+ * @param toolConfig - Optional tool config, can be used to override some defaults.
577
+ */
578
+ constructor(environment: EnvironmentType, toolConfig?: ToolConfig);
579
+ /**
580
+ * Gets the current execution environment for the tool.
581
+ *
582
+ * @returns The current execution environment.
583
+ */
584
+ get environment(): EnvironmentType;
585
+ /**
586
+ * Executes the tool with the given input.
587
+ *
588
+ * @param input - The input for the tool.
589
+ * @param _options - Options from the tool call.
590
+ * @returns A promise that resolves to the tool execution result.
591
+ */
592
+ execute(input: ToolInputType, _options: ToolCallOptions): Promise<ToolOutputType>;
593
+ /**
594
+ * Returns the metadata for the tool.
595
+ *
596
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
597
+ *
598
+ * @returns The tool metadata.
599
+ */
600
+ protected abstract getMetadata(): EnvironmentToolMetadata<ToolInputType, ToolOutputType>;
601
+ /**
602
+ * Executes the tool in the given execution environment with the given input.
603
+ *
604
+ * @param env - The execution environment to use.
605
+ * @param input - The input for the tool.
606
+ * @returns A promise that resolves to the tool execution result.
607
+ */
608
+ protected abstract executeForEnvironment(env: EnvironmentType, input: ToolInputType): Promise<ToolOutputType>;
609
+ }
610
+
611
+ declare const CopyFileToolName = "copy_file";
612
+ type CopyFileToolConfig = ToolConfig;
613
+ declare const CopyFileToolInput: z$1.ZodObject<{
614
+ sourcePath: z$1.ZodString;
615
+ destinationPath: z$1.ZodString;
616
+ }, z$1.core.$strip>;
617
+ type CopyFileToolInput = z$1.infer<typeof CopyFileToolInput>;
618
+ declare const CopyFileToolOutput: z$1.ZodObject<{
619
+ sourcePath: z$1.ZodString;
620
+ destinationPath: z$1.ZodString;
621
+ message: z$1.ZodString;
622
+ }, z$1.core.$strip>;
623
+ type CopyFileToolOutput = z$1.infer<typeof CopyFileToolOutput>;
624
+ /**
625
+ * Class for the CopyFile tool.
626
+ */
627
+ declare class CopyFileTool extends EnvironmentToolBase<CopyFileToolConfig, CopyFileToolInput, CopyFileToolOutput, FilesystemEnvironmentInterface> {
628
+ /**
629
+ * Returns the metadata for the tool.
630
+ *
631
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
632
+ *
633
+ * @returns The tool metadata.
634
+ */
635
+ protected getMetadata(): EnvironmentToolMetadata<CopyFileToolInput, CopyFileToolOutput>;
636
+ /**
637
+ * Executes the tool in the given execution environment with the given input.
638
+ *
639
+ * @param env - The execution environment to use.
640
+ * @param input - The input for the tool.
641
+ * @returns A promise that resolves to the tool execution result.
642
+ */
643
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: CopyFileToolInput): Promise<CopyFileToolOutput>;
644
+ /**
645
+ * Converts the tool output to a format suitable for model consumption.
646
+ *
647
+ * @param output - The output from the tool execution.
648
+ * @returns The formatted tool result.
649
+ */
650
+ toModelOutput(output: CopyFileToolOutput): ModelFormattedToolResult;
651
+ /**
652
+ * Gets the examples for the tool.
653
+ *
654
+ * @returns The tool examples.
655
+ */
656
+ get examples(): Array<ToolExample<CopyFileToolInput, CopyFileToolOutput>>;
657
+ }
658
+
659
+ declare const DeleteFileToolName = "delete_file";
660
+ type DeleteFileToolConfig = ToolConfig;
661
+ declare const DeleteFileToolInput: z$1.ZodObject<{
662
+ path: z$1.ZodString;
663
+ }, z$1.core.$strip>;
664
+ type DeleteFileToolInput = z$1.infer<typeof DeleteFileToolInput>;
665
+ declare const DeleteFileToolOutput: z$1.ZodObject<{
666
+ path: z$1.ZodString;
667
+ message: z$1.ZodString;
668
+ }, z$1.core.$strip>;
669
+ type DeleteFileToolOutput = z$1.infer<typeof DeleteFileToolOutput>;
670
+ /**
671
+ * Class for the DeleteFile tool.
672
+ */
673
+ declare class DeleteFileTool extends EnvironmentToolBase<DeleteFileToolConfig, DeleteFileToolInput, DeleteFileToolOutput, FilesystemEnvironmentInterface> {
674
+ /**
675
+ * Returns the metadata for the tool.
676
+ *
677
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
678
+ *
679
+ * @returns The tool metadata.
680
+ */
681
+ protected getMetadata(): EnvironmentToolMetadata<DeleteFileToolInput, DeleteFileToolOutput>;
682
+ /**
683
+ * Executes the tool in the given execution environment with the given input.
684
+ *
685
+ * @param env - The execution environment to use.
686
+ * @param input - The input for the tool.
687
+ * @returns A promise that resolves to the tool execution result.
688
+ */
689
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: DeleteFileToolInput): Promise<DeleteFileToolOutput>;
690
+ /**
691
+ * Converts the tool output to a format suitable for model consumption.
692
+ *
693
+ * @param output - The output from the tool execution.
694
+ * @returns The formatted tool result.
695
+ */
696
+ toModelOutput(output: DeleteFileToolOutput): ModelFormattedToolResult;
697
+ /**
698
+ * Gets the examples for the tool.
699
+ *
700
+ * @returns The tool examples.
701
+ */
702
+ get examples(): Array<ToolExample<DeleteFileToolInput, DeleteFileToolOutput>>;
703
+ }
704
+
705
+ declare const EditFileToolName = "edit_file";
706
+ type EditFileToolConfig = ToolConfig;
707
+ declare const EditFileToolInput: z$1.ZodObject<{
708
+ path: z$1.ZodString;
709
+ oldString: z$1.ZodString;
710
+ newString: z$1.ZodString;
711
+ replaceAll: z$1.ZodOptional<z$1.ZodBoolean>;
712
+ }, z$1.core.$strip>;
713
+ type EditFileToolInput = z$1.infer<typeof EditFileToolInput>;
714
+ declare const EditFileToolOutput: z$1.ZodObject<{
715
+ path: z$1.ZodString;
716
+ oldString: z$1.ZodString;
717
+ newString: z$1.ZodString;
718
+ replacements: z$1.ZodNumber;
719
+ message: z$1.ZodString;
720
+ }, z$1.core.$strip>;
721
+ type EditFileToolOutput = z$1.infer<typeof EditFileToolOutput>;
722
+ /**
723
+ * Class for the EditFile tool.
724
+ */
725
+ declare class EditFileTool extends EnvironmentToolBase<EditFileToolConfig, EditFileToolInput, EditFileToolOutput, FilesystemEnvironmentInterface> {
726
+ /**
727
+ * Returns the metadata for the tool.
728
+ *
729
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
730
+ *
731
+ * @returns The tool metadata.
732
+ */
733
+ protected getMetadata(): EnvironmentToolMetadata<EditFileToolInput, EditFileToolOutput>;
734
+ /**
735
+ * Executes the tool in the given execution environment with the given input.
736
+ *
737
+ * @param env - The execution environment to use.
738
+ * @param input - The input for the tool.
739
+ * @returns A promise that resolves to the tool execution result.
740
+ */
741
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: EditFileToolInput): Promise<EditFileToolOutput>;
742
+ /**
743
+ * Converts the tool output to a format suitable for model consumption.
744
+ *
745
+ * @param output - The output from the tool execution.
746
+ * @returns The formatted tool result.
747
+ */
748
+ toModelOutput(output: EditFileToolOutput): ModelFormattedToolResult;
749
+ /**
750
+ * Gets the examples for the tool.
751
+ *
752
+ * @returns The tool examples.
753
+ */
754
+ get examples(): Array<ToolExample<EditFileToolInput, EditFileToolOutput>>;
755
+ }
756
+
757
+ declare const GetProjectFileStructureToolName = "get_project_file_structure";
758
+ type GetProjectFileStructureToolConfig = ToolConfig;
759
+ declare const GetProjectFileStructureToolInput: z$1.ZodObject<{
760
+ path: z$1.ZodOptional<z$1.ZodString>;
761
+ excludeGitIgnored: z$1.ZodOptional<z$1.ZodBoolean>;
762
+ }, z$1.core.$strip>;
763
+ type GetProjectFileStructureToolInput = z$1.infer<typeof GetProjectFileStructureToolInput>;
764
+ declare const GetProjectFileStructureToolOutput: z$1.ZodObject<{
765
+ files: z$1.ZodArray<z$1.ZodString>;
766
+ excludeGitIgnored: z$1.ZodBoolean;
767
+ }, z$1.core.$strip>;
768
+ type GetProjectFileStructureToolOutput = z$1.infer<typeof GetProjectFileStructureToolOutput>;
769
+ /**
770
+ * Class for the GetProjectFileStructure tool.
771
+ */
772
+ declare class GetProjectFileStructureTool extends EnvironmentToolBase<GetProjectFileStructureToolConfig, GetProjectFileStructureToolInput, GetProjectFileStructureToolOutput, CommandLineEnvironmentInterface> {
773
+ /**
774
+ * Returns the metadata for the tool.
775
+ *
776
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
777
+ *
778
+ * @returns The tool metadata.
779
+ */
780
+ protected getMetadata(): EnvironmentToolMetadata<GetProjectFileStructureToolInput, GetProjectFileStructureToolOutput>;
781
+ /**
782
+ * Executes the tool in the given execution environment with the given input.
783
+ *
784
+ * @param env - The execution environment to use.
785
+ * @param input - The input for the tool.
786
+ * @returns A promise that resolves to the tool execution result.
787
+ */
788
+ protected executeForEnvironment(env: CommandLineEnvironmentInterface, input: GetProjectFileStructureToolInput): Promise<GetProjectFileStructureToolOutput>;
789
+ /**
790
+ * Converts the tool output to a format suitable for model consumption.
791
+ *
792
+ * @param output - The output from the tool execution.
793
+ * @returns The formatted tool result.
794
+ */
795
+ toModelOutput(output: GetProjectFileStructureToolOutput): ModelFormattedToolResult;
796
+ /**
797
+ * Gets the examples for the tool.
798
+ *
799
+ * @returns The tool examples.
800
+ */
801
+ get examples(): Array<ToolExample<GetProjectFileStructureToolInput, GetProjectFileStructureToolOutput>>;
802
+ }
803
+
804
+ declare const GlobToolName = "glob";
805
+ type GlobToolConfig = ToolConfig;
806
+ declare const GlobToolInput: z$1.ZodObject<{
807
+ searchPattern: z$1.ZodString;
808
+ searchPath: z$1.ZodOptional<z$1.ZodString>;
809
+ excludeGitIgnored: z$1.ZodOptional<z$1.ZodBoolean>;
810
+ }, z$1.core.$strip>;
811
+ type GlobToolInput = z$1.infer<typeof GlobToolInput>;
812
+ declare const GlobToolOutput: z$1.ZodObject<{
813
+ searchPattern: z$1.ZodString;
814
+ searchPath: z$1.ZodString;
815
+ excludeGitIgnored: z$1.ZodBoolean;
816
+ matchingPaths: z$1.ZodArray<z$1.ZodString>;
817
+ }, z$1.core.$strip>;
818
+ type GlobToolOutput = z$1.infer<typeof GlobToolOutput>;
819
+ /**
820
+ * Class for the Glob tool.
821
+ */
822
+ declare class GlobTool extends EnvironmentToolBase<GlobToolConfig, GlobToolInput, GlobToolOutput, CommandLineEnvironmentInterface> {
823
+ /**
824
+ * Returns the metadata for the tool.
825
+ *
826
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
827
+ *
828
+ * @returns The tool metadata.
829
+ */
830
+ protected getMetadata(): EnvironmentToolMetadata<GlobToolInput, GlobToolOutput>;
831
+ /**
832
+ * Executes the tool in the given execution environment with the given input.
833
+ *
834
+ * @param env - The execution environment to use.
835
+ * @param input - The input for the tool.
836
+ * @returns A promise that resolves to the tool execution result.
837
+ */
838
+ protected executeForEnvironment(env: CommandLineEnvironmentInterface, input: GlobToolInput): Promise<GlobToolOutput>;
839
+ /**
840
+ * Converts the tool output to a format suitable for model consumption.
841
+ *
842
+ * @param output - The output from the tool execution.
843
+ * @returns The formatted tool result.
844
+ */
845
+ toModelOutput(output: GlobToolOutput): ModelFormattedToolResult;
846
+ /**
847
+ * Gets the examples for the tool.
848
+ *
849
+ * @returns The tool examples.
850
+ */
851
+ get examples(): Array<ToolExample<GlobToolInput, GlobToolOutput>>;
852
+ }
853
+
854
+ declare const ListDirectoryToolName = "list_directory";
855
+ type ListDirectoryToolConfig = ToolConfig;
856
+ declare const ListDirectoryToolInput: z$1.ZodObject<{
857
+ path: z$1.ZodString;
858
+ }, z$1.core.$strip>;
859
+ type ListDirectoryToolInput = z$1.infer<typeof ListDirectoryToolInput>;
860
+ declare const ListDirectoryToolOutput: z$1.ZodObject<{
861
+ path: z$1.ZodString;
862
+ files: z$1.ZodArray<z$1.ZodString>;
863
+ directories: z$1.ZodArray<z$1.ZodString>;
864
+ }, z$1.core.$strip>;
865
+ type ListDirectoryToolOutput = z$1.infer<typeof ListDirectoryToolOutput>;
866
+ /**
867
+ * Class for the ListDirectory tool.
868
+ */
869
+ declare class ListDirectoryTool extends EnvironmentToolBase<ListDirectoryToolConfig, ListDirectoryToolInput, ListDirectoryToolOutput, CommandLineEnvironmentInterface> {
870
+ /**
871
+ * Returns the metadata for the tool.
872
+ *
873
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
874
+ *
875
+ * @returns The tool metadata.
876
+ */
877
+ protected getMetadata(): EnvironmentToolMetadata<ListDirectoryToolInput, ListDirectoryToolOutput>;
878
+ /**
879
+ * Executes the tool in the given execution environment with the given input.
880
+ *
881
+ * @param env - The execution environment to use.
882
+ * @param input - The input for the tool.
883
+ * @returns A promise that resolves to the tool execution result.
884
+ */
885
+ protected executeForEnvironment(env: CommandLineEnvironmentInterface, input: ListDirectoryToolInput): Promise<ListDirectoryToolOutput>;
886
+ /**
887
+ * Converts the tool output to a format suitable for model consumption.
888
+ *
889
+ * @param output - The output from the tool execution.
890
+ * @returns The formatted tool result.
891
+ */
892
+ toModelOutput(output: ListDirectoryToolOutput): ModelFormattedToolResult;
893
+ /**
894
+ * Gets the examples for the tool.
895
+ *
896
+ * @returns The tool examples.
897
+ */
898
+ get examples(): Array<ToolExample<ListDirectoryToolInput, ListDirectoryToolOutput>>;
899
+ }
900
+
901
+ declare const MoveFileToolName = "move_file";
902
+ type MoveFileToolConfig = ToolConfig;
903
+ declare const MoveFileToolInput: z$1.ZodObject<{
904
+ sourcePath: z$1.ZodString;
905
+ destinationPath: z$1.ZodString;
906
+ }, z$1.core.$strip>;
907
+ type MoveFileToolInput = z$1.infer<typeof MoveFileToolInput>;
908
+ declare const MoveFileToolOutput: z$1.ZodObject<{
909
+ sourcePath: z$1.ZodString;
910
+ destinationPath: z$1.ZodString;
911
+ message: z$1.ZodString;
912
+ }, z$1.core.$strip>;
913
+ type MoveFileToolOutput = z$1.infer<typeof MoveFileToolOutput>;
914
+ /**
915
+ * Class for the MoveFile tool.
916
+ */
917
+ declare class MoveFileTool extends EnvironmentToolBase<MoveFileToolConfig, MoveFileToolInput, MoveFileToolOutput, FilesystemEnvironmentInterface> {
918
+ /**
919
+ * Returns the metadata for the tool.
920
+ *
921
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
922
+ *
923
+ * @returns The tool metadata.
924
+ */
925
+ protected getMetadata(): EnvironmentToolMetadata<MoveFileToolInput, MoveFileToolOutput>;
926
+ /**
927
+ * Executes the tool in the given execution environment with the given input.
928
+ *
929
+ * @param env - The execution environment to use.
930
+ * @param input - The input for the tool.
931
+ * @returns A promise that resolves to the tool execution result.
932
+ */
933
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: MoveFileToolInput): Promise<MoveFileToolOutput>;
934
+ /**
935
+ * Converts the tool output to a format suitable for model consumption.
936
+ *
937
+ * @param output - The output from the tool execution.
938
+ * @returns The formatted tool result.
939
+ */
940
+ toModelOutput(output: MoveFileToolOutput): ModelFormattedToolResult;
941
+ /**
942
+ * Gets the examples for the tool.
943
+ *
944
+ * @returns The tool examples.
945
+ */
946
+ get examples(): Array<ToolExample<MoveFileToolInput, MoveFileToolOutput>>;
947
+ }
948
+
949
+ declare const ReadFileToolName = "read_file";
950
+ type ReadFileToolConfig = ToolConfig;
951
+ declare const ReadFileToolInput: z$1.ZodObject<{
952
+ path: z$1.ZodString;
953
+ }, z$1.core.$strip>;
954
+ type ReadFileToolInput = z$1.infer<typeof ReadFileToolInput>;
955
+ declare const ReadFileToolOutput: z$1.ZodObject<{
956
+ path: z$1.ZodString;
957
+ content: z$1.ZodString;
958
+ }, z$1.core.$strip>;
959
+ type ReadFileToolOutput = z$1.infer<typeof ReadFileToolOutput>;
960
+ /**
961
+ * Class for the ReadFile tool.
962
+ */
963
+ declare class ReadFileTool extends EnvironmentToolBase<ReadFileToolConfig, ReadFileToolInput, ReadFileToolOutput, FilesystemEnvironmentInterface> {
964
+ /**
965
+ * Returns the metadata for the tool.
966
+ *
967
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
968
+ *
969
+ * @returns The tool metadata.
970
+ */
971
+ protected getMetadata(): EnvironmentToolMetadata<ReadFileToolInput, ReadFileToolOutput>;
972
+ /**
973
+ * Executes the tool in the given execution environment with the given input.
974
+ *
975
+ * @param env - The execution environment to use.
976
+ * @param input - The input for the tool.
977
+ * @returns A promise that resolves to the tool execution result.
978
+ */
979
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: ReadFileToolInput): Promise<ReadFileToolOutput>;
980
+ /**
981
+ * Converts the tool output to a format suitable for model consumption.
982
+ *
983
+ * @param output - The output from the tool execution.
984
+ * @returns The formatted tool result.
985
+ */
986
+ toModelOutput(output: ReadFileToolOutput): ModelFormattedToolResult;
987
+ /**
988
+ * Gets the examples for the tool.
989
+ *
990
+ * @returns The tool examples.
991
+ */
992
+ get examples(): Array<ToolExample<ReadFileToolInput, ReadFileToolOutput>>;
993
+ }
994
+
995
+ declare const ReadManyFilesToolName = "read_many_files";
996
+ type ReadManyFilesToolConfig = ToolConfig;
997
+ declare const ReadManyFilesToolInput: z$1.ZodObject<{
998
+ paths: z$1.ZodArray<z$1.ZodString>;
999
+ }, z$1.core.$strip>;
1000
+ type ReadManyFilesToolInput = z$1.infer<typeof ReadManyFilesToolInput>;
1001
+ declare const ReadManyFilesToolOutput: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
1002
+ path: z$1.ZodString;
1003
+ content: z$1.ZodString;
1004
+ }, z$1.core.$strip>>;
1005
+ type ReadManyFilesToolOutput = z$1.infer<typeof ReadManyFilesToolOutput>;
1006
+ /**
1007
+ * Class for the ReadManyFiles tool.
1008
+ */
1009
+ declare class ReadManyFilesTool extends EnvironmentToolBase<ReadManyFilesToolConfig, ReadManyFilesToolInput, ReadManyFilesToolOutput, FilesystemEnvironmentInterface> {
1010
+ /**
1011
+ * Returns the metadata for the tool.
1012
+ *
1013
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
1014
+ *
1015
+ * @returns The tool metadata.
1016
+ */
1017
+ protected getMetadata(): EnvironmentToolMetadata<ReadManyFilesToolInput, ReadManyFilesToolOutput>;
1018
+ /**
1019
+ * Executes the tool in the given execution environment with the given input.
1020
+ *
1021
+ * @param env - The execution environment to use.
1022
+ * @param input - The input for the tool.
1023
+ * @returns A promise that resolves to the tool execution result.
1024
+ */
1025
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: ReadManyFilesToolInput): Promise<ReadManyFilesToolOutput>;
1026
+ /**
1027
+ * Converts the tool output to a format suitable for model consumption.
1028
+ *
1029
+ * @param output - The output from the tool execution.
1030
+ * @returns The formatted tool result.
1031
+ */
1032
+ toModelOutput(output: ReadManyFilesToolOutput): ModelFormattedToolResult;
1033
+ /**
1034
+ * Gets the examples for the tool.
1035
+ *
1036
+ * @returns The tool examples.
1037
+ */
1038
+ get examples(): Array<ToolExample<ReadManyFilesToolInput, ReadManyFilesToolOutput>>;
1039
+ }
1040
+
1041
+ declare const RunCommandToolName = "run_command";
1042
+ type RunCommandToolConfig = ToolConfig;
1043
+ declare const RunCommandToolInput: z$1.ZodObject<{
1044
+ command: z$1.ZodString;
1045
+ }, z$1.core.$strip>;
1046
+ type RunCommandToolInput = z$1.infer<typeof RunCommandToolInput>;
1047
+ declare const RunCommandToolOutput: z$1.ZodObject<{
1048
+ command: z$1.ZodString;
1049
+ exitCode: z$1.ZodNumber;
1050
+ stdout: z$1.ZodString;
1051
+ stderr: z$1.ZodString;
1052
+ }, z$1.core.$strip>;
1053
+ type RunCommandToolOutput = z$1.infer<typeof RunCommandToolOutput>;
1054
+ /**
1055
+ * Class for the RunCommand tool.
1056
+ *
1057
+ * WARNING: This tool can be dangerous if misused. It allows executing arbitrary commands in the environment.
1058
+ * Only allow using this tool in sandboxed environments where the potential risks are understood and mitigated.
1059
+ */
1060
+ declare class RunCommandTool extends EnvironmentToolBase<RunCommandToolConfig, RunCommandToolInput, RunCommandToolOutput, CommandLineEnvironmentInterface> {
1061
+ /**
1062
+ * Returns the metadata for the tool.
1063
+ *
1064
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
1065
+ *
1066
+ * @returns The tool metadata.
1067
+ */
1068
+ protected getMetadata(): EnvironmentToolMetadata<RunCommandToolInput, RunCommandToolOutput>;
1069
+ /**
1070
+ * Executes the tool in the given execution environment with the given input.
1071
+ *
1072
+ * @param env - The execution environment to use.
1073
+ * @param input - The input for the tool.
1074
+ * @returns A promise that resolves to the tool execution result.
1075
+ */
1076
+ protected executeForEnvironment(env: CommandLineEnvironmentInterface, input: RunCommandToolInput): Promise<RunCommandToolOutput>;
1077
+ /**
1078
+ * Converts the tool output to a format suitable for model consumption.
1079
+ *
1080
+ * @param output - The output from the tool execution.
1081
+ * @returns The formatted tool result.
1082
+ */
1083
+ toModelOutput(output: RunCommandToolOutput): ModelFormattedToolResult;
1084
+ /**
1085
+ * Gets the examples for the tool.
1086
+ *
1087
+ * @returns The tool examples.
1088
+ */
1089
+ get examples(): Array<ToolExample<RunCommandToolInput, RunCommandToolOutput>>;
1090
+ }
1091
+
1092
+ declare const WriteFileToolName = "write_file";
1093
+ type WriteFileToolConfig = ToolConfig;
1094
+ declare const WriteFileToolInput: z$1.ZodObject<{
1095
+ path: z$1.ZodString;
1096
+ content: z$1.ZodString;
1097
+ }, z$1.core.$strip>;
1098
+ type WriteFileToolInput = z$1.infer<typeof WriteFileToolInput>;
1099
+ declare const WriteFileToolOutput: z$1.ZodObject<{
1100
+ path: z$1.ZodString;
1101
+ message: z$1.ZodString;
1102
+ }, z$1.core.$strip>;
1103
+ type WriteFileToolOutput = z$1.infer<typeof WriteFileToolOutput>;
1104
+ /**
1105
+ * Class for the WriteFile tool.
1106
+ */
1107
+ declare class WriteFileTool extends EnvironmentToolBase<WriteFileToolConfig, WriteFileToolInput, WriteFileToolOutput, FilesystemEnvironmentInterface> {
1108
+ /**
1109
+ * Returns the metadata for the tool.
1110
+ *
1111
+ * The name, description, and needsApproval properties are defaults which can be overridden in the constructor.
1112
+ *
1113
+ * @returns The tool metadata.
1114
+ */
1115
+ protected getMetadata(): EnvironmentToolMetadata<WriteFileToolInput, WriteFileToolOutput>;
1116
+ /**
1117
+ * Executes the tool in the given execution environment with the given input.
1118
+ *
1119
+ * @param env - The execution environment to use.
1120
+ * @param input - The input for the tool.
1121
+ * @returns A promise that resolves to the tool execution result.
1122
+ */
1123
+ protected executeForEnvironment(env: FilesystemEnvironmentInterface, input: WriteFileToolInput): Promise<WriteFileToolOutput>;
1124
+ /**
1125
+ * Converts the tool output to a format suitable for model consumption.
1126
+ *
1127
+ * @param output - The output from the tool execution.
1128
+ * @returns The formatted tool result.
1129
+ */
1130
+ toModelOutput(output: WriteFileToolOutput): ModelFormattedToolResult;
1131
+ /**
1132
+ * Gets the examples for the tool.
1133
+ *
1134
+ * @returns The tool examples.
1135
+ */
1136
+ get examples(): Array<ToolExample<WriteFileToolInput, WriteFileToolOutput>>;
1137
+ }
1138
+
1139
+ declare const availableEnvironmentTools: {
1140
+ read_file: typeof ReadFileTool;
1141
+ write_file: typeof WriteFileTool;
1142
+ delete_file: typeof DeleteFileTool;
1143
+ edit_file: typeof EditFileTool;
1144
+ move_file: typeof MoveFileTool;
1145
+ copy_file: typeof CopyFileTool;
1146
+ read_many_files: typeof ReadManyFilesTool;
1147
+ get_project_file_structure: typeof GetProjectFileStructureTool;
1148
+ glob: typeof GlobTool;
1149
+ list_directory: typeof ListDirectoryTool;
1150
+ run_command: typeof RunCommandTool;
1151
+ };
1152
+ type EnvironmentToolClasses = {
1153
+ [ReadFileToolName]: ReadFileTool;
1154
+ [WriteFileToolName]: WriteFileTool;
1155
+ [DeleteFileToolName]: DeleteFileTool;
1156
+ [EditFileToolName]: EditFileTool;
1157
+ [MoveFileToolName]: MoveFileTool;
1158
+ [CopyFileToolName]: CopyFileTool;
1159
+ [ReadManyFilesToolName]: ReadManyFilesTool;
1160
+ [GetProjectFileStructureToolName]: GetProjectFileStructureTool;
1161
+ [GlobToolName]: GlobTool;
1162
+ [ListDirectoryToolName]: ListDirectoryTool;
1163
+ [RunCommandToolName]: RunCommandTool;
1164
+ };
1165
+ type EnvironmentToolSafetyLevel = 'readonly' | 'basic' | 'all';
1166
+ declare const EnvironmentToolSafetyLevels: EnvironmentToolSafetyLevel[];
1167
+ type EnvironmentToolGenerics<T> = T extends EnvironmentToolBase<infer ToolConfig, infer ToolInput, infer ToolOutput, infer ToolEnvironment> ? {
1168
+ ToolConfigType: ToolConfig;
1169
+ ToolInputType: ToolInput;
1170
+ ToolOutputType: ToolOutput;
1171
+ ToolEnvironmentType: ToolEnvironment;
1172
+ } : never;
1173
+ type EnvironmentToolConfigOf<T> = T extends {
1174
+ _toolConfig: infer C;
1175
+ } ? C : never;
1176
+ type EnvironmentToolInputTypeOf<T> = EnvironmentToolGenerics<T>['ToolInputType'];
1177
+ type EnvironmentToolOutputTypeOf<T> = EnvironmentToolGenerics<T>['ToolOutputType'];
1178
+ type EnvironmentToolEnvironmentTypeOf<T> = EnvironmentToolGenerics<T>['ToolEnvironmentType'];
1179
+ type EnvironmentToolName = keyof typeof availableEnvironmentTools;
1180
+ declare const EnvironmentToolNames: EnvironmentToolName[];
1181
+ /**
1182
+ * Creates an environment tool instance based on the provided name, execution environment, and configuration.
1183
+ *
1184
+ * @param toolName - The name identifying the type of environment tool to create.
1185
+ * @param environment - The execution environment to create the tool for.
1186
+ * @param config - The configuration object for the environment tool.
1187
+ * @returns An instance of the specified environment tool.
1188
+ */
1189
+ declare function createEnvironmentTool<T extends EnvironmentToolName>(toolName: T, environment: EnvironmentToolEnvironmentTypeOf<EnvironmentToolClasses[T]>, config?: EnvironmentToolConfigOf<EnvironmentToolClasses[T]>): EnvironmentToolClasses[T];
1190
+ type ToolCreatorConfig = EnvironmentToolName extends infer T ? T extends EnvironmentToolName ? {
1191
+ toolName: T;
1192
+ toolConfig?: EnvironmentToolConfigOf<EnvironmentToolClasses[T]>;
1193
+ } : never : never;
1194
+ type ToolsDefinition = Array<EnvironmentToolName | ToolCreatorConfig> | EnvironmentToolSafetyLevel;
1195
+ type ToolWithIO = EnvironmentToolName extends infer T ? T extends EnvironmentToolName ? Tool<EnvironmentToolInputTypeOf<EnvironmentToolClasses[T]>, EnvironmentToolOutputTypeOf<EnvironmentToolClasses[T]>> : never : never;
1196
+ /**
1197
+ * Creates a map of tools for the given environment.
1198
+ *
1199
+ * @param environment - The execution environment to create the tools for.
1200
+ * @param toolsDefinition - The names of the tools to create, or 'readonly', 'basic', or 'all' as a shortcut for groups of available tools.
1201
+ * @returns A record mapping tool names to their corresponding Tool instances.
1202
+ */
1203
+ declare function createToolsForEnvironment(environment: Environment, toolsDefinition?: ToolsDefinition): Record<string, ToolWithIO>;
1204
+ /**
1205
+ * Creates a map of tools for the given environment, modifying tool names with the environment name to avoid conflicts.
1206
+ *
1207
+ * For example, if the environment name is "env1" and the tool is "read_file", the modified tool name will be "read_file_in_env1".
1208
+ *
1209
+ * @param environmentName - The name of the environment. Will be used in tool names to avoid conflicts.
1210
+ * @param environment - The execution environment to create the tools for.
1211
+ * @param toolsDefinition - The names of the tools to create, or 'readonly', 'basic', or 'all' as a shortcut for groups of available tools.
1212
+ * @returns A record mapping tool names to their corresponding Tool instances.
1213
+ */
1214
+ declare function createToolsForNamedEnvironment(environmentName: string, environment: Environment, toolsDefinition?: ToolsDefinition): Record<string, ToolWithIO>;
1215
+
1216
+ type CodeAgentCreatorConfig = Experimental_AgentSettings<Record<string, Tool>> & {
1217
+ maxSteps: number;
1218
+ allowSubmit?: boolean;
1219
+ logStep?: (stepLog: string, stepIndex: number) => void;
1220
+ omitAdditionalInstructions?: boolean;
1221
+ } & ({
1222
+ environment: Environment;
1223
+ environmentToolsDefinition: ToolsDefinition;
1224
+ } | {
1225
+ environments: Record<string, Environment>;
1226
+ environmentToolsDefinition: Record<string, ToolsDefinition>;
1227
+ } | Record<string, never>);
1228
+ /**
1229
+ * Creates an AI code agent configured to operate on one or more specified execution environments with tools.
1230
+ *
1231
+ * @param agentConfig - Configuration options for the code agent, including environments, tools definition, and agent settings.
1232
+ * @returns An instance of Agent configured with the specified environment tools and settings.
1233
+ */
1234
+ declare function createCodeAgent(agentConfig: CodeAgentCreatorConfig): Experimental_Agent<Record<string, Tool>>;
1235
+
1236
+ declare const availableEnvironments: {
1237
+ "unsafe-local": typeof UnsafeLocalEnvironment;
1238
+ docker: typeof DockerEnvironment;
1239
+ "mock-filesystem": typeof MockFilesystemEnvironment;
1240
+ "node-filesystem": typeof NodeFilesystemEnvironment;
1241
+ };
1242
+ type EnvironmentClasses = {
1243
+ [UnsafeLocalEnvironmentName]: UnsafeLocalEnvironment;
1244
+ [DockerEnvironmentName]: DockerEnvironment;
1245
+ [MockFilesystemEnvironmentName]: MockFilesystemEnvironment;
1246
+ [NodeFilesystemEnvironmentName]: NodeFilesystemEnvironment;
1247
+ };
1248
+ type EnvironmentConfigOf<T> = T extends FilesystemEnvironmentBase<infer X> ? X : never;
1249
+ type EnvironmentName = keyof typeof availableEnvironments;
1250
+ declare const EnvironmentNames: EnvironmentName[];
1251
+ /**
1252
+ * Creates an environment instance based on the provided name and configuration.
1253
+ *
1254
+ * @param environmentName - The name identifying the type of environment to create.
1255
+ * @param config - The configuration object for the environment.
1256
+ * @returns An instance of the specified environment.
1257
+ */
1258
+ declare function createEnvironment<T extends EnvironmentName>(environmentName: T, config: EnvironmentConfigOf<EnvironmentClasses[T]>): EnvironmentClasses[T];
1259
+
1260
+ export { type CodeAgentCreatorConfig, type CommandLineEnvironmentInterface, CopyFileResult, CopyFileTool, type CopyFileToolConfig, CopyFileToolInput, CopyFileToolName, CopyFileToolOutput, DeleteFileResult, DeleteFileTool, type DeleteFileToolConfig, DeleteFileToolInput, DeleteFileToolName, DeleteFileToolOutput, DockerEnvironment, type DockerEnvironmentConfig, DockerEnvironmentName, EditFileTool, type EditFileToolConfig, EditFileToolInput, EditFileToolName, EditFileToolOutput, type Environment, type EnvironmentName, EnvironmentNames, type EnvironmentToolInterface, type EnvironmentToolName, EnvironmentToolNames, type EnvironmentToolSafetyLevel, EnvironmentToolSafetyLevels, type FilesystemEnvironmentInterface, GetProjectFileStructureTool, type GetProjectFileStructureToolConfig, GetProjectFileStructureToolInput, GetProjectFileStructureToolName, GetProjectFileStructureToolOutput, GlobTool, type GlobToolConfig, GlobToolInput, GlobToolName, GlobToolOutput, ListDirectoryTool, type ListDirectoryToolConfig, ListDirectoryToolInput, ListDirectoryToolName, ListDirectoryToolOutput, MockFilesystemEnvironment, type MockFilesystemEnvironmentConfig, MockFilesystemEnvironmentName, type ModelFormattedToolResult, MoveFileResult, MoveFileTool, type MoveFileToolConfig, MoveFileToolInput, MoveFileToolName, MoveFileToolOutput, NodeFilesystemEnvironment, type NodeFilesystemEnvironmentConfig, NodeFilesystemEnvironmentName, ReadFileResult, ReadFileTool, type ReadFileToolConfig, ReadFileToolInput, ReadFileToolName, ReadFileToolOutput, ReadManyFilesTool, type ReadManyFilesToolConfig, ReadManyFilesToolInput, ReadManyFilesToolName, ReadManyFilesToolOutput, RunCommandResult, RunCommandTool, type RunCommandToolConfig, RunCommandToolInput, RunCommandToolName, RunCommandToolOutput, type ToolConfig, type ToolExample, type ToolInterface, type ToolsDefinition, UnsafeLocalEnvironment, type UnsafeLocalEnvironmentConfig, UnsafeLocalEnvironmentName, WriteFileResult, WriteFileTool, type WriteFileToolConfig, WriteFileToolInput, WriteFileToolName, WriteFileToolOutput, createCodeAgent, createEnvironment, createEnvironmentTool, createToolsForEnvironment, createToolsForNamedEnvironment };