@robota-sdk/agent-tools 3.0.0-beta.63 → 3.0.0-beta.64

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.
@@ -1,504 +0,0 @@
1
- import { IToolRegistry, ITool, IToolSchema, TToolParameters, TUniversalValue, IFunctionTool, TToolExecutor, IEventService, IToolExecutionContext, IToolResult, IParameterValidationResult, IOpenAPIToolConfig } from '@robota-sdk/agent-core';
2
-
3
- /**
4
- * Result returned by a CLI tool invocation
5
- */
6
- interface TToolResult {
7
- success: boolean;
8
- output: string;
9
- error?: string;
10
- exitCode?: number;
11
- /** Start line number of the edit in the original file (Edit tool only) */
12
- startLine?: number;
13
- }
14
-
15
- interface ISandboxRunOptions {
16
- timeoutMs?: number;
17
- workingDirectory?: string;
18
- }
19
- interface ISandboxRunResult {
20
- stdout: string;
21
- stderr?: string;
22
- exitCode: number;
23
- }
24
- interface IWorkspaceManifestFileEntry {
25
- type: 'file';
26
- content: string;
27
- encoding?: 'utf8';
28
- }
29
- interface IWorkspaceManifestDirectoryEntry {
30
- type: 'dir';
31
- }
32
- interface IWorkspaceManifestLocalFileEntry {
33
- type: 'localFile';
34
- src: string;
35
- }
36
- interface IWorkspaceManifestLocalDirectoryEntry {
37
- type: 'localDir';
38
- src: string;
39
- }
40
- interface IWorkspaceManifestGitRepositoryEntry {
41
- type: 'gitRepo';
42
- url: string;
43
- ref?: string;
44
- shallow?: boolean;
45
- }
46
- interface IWorkspaceManifestS3MountEntry {
47
- type: 's3Mount';
48
- bucket: string;
49
- prefix?: string;
50
- region: string;
51
- }
52
- interface IWorkspaceManifestGcsMountEntry {
53
- type: 'gcsMount';
54
- bucket: string;
55
- prefix?: string;
56
- }
57
- interface IWorkspaceManifestR2MountEntry {
58
- type: 'r2Mount';
59
- bucket: string;
60
- accountId: string;
61
- prefix?: string;
62
- }
63
- interface IWorkspaceManifestAzureBlobMountEntry {
64
- type: 'azureBlobMount';
65
- container: string;
66
- account: string;
67
- prefix?: string;
68
- }
69
- type TWorkspaceManifestEntry = IWorkspaceManifestFileEntry | IWorkspaceManifestDirectoryEntry | IWorkspaceManifestLocalFileEntry | IWorkspaceManifestLocalDirectoryEntry | IWorkspaceManifestGitRepositoryEntry | IWorkspaceManifestS3MountEntry | IWorkspaceManifestGcsMountEntry | IWorkspaceManifestR2MountEntry | IWorkspaceManifestAzureBlobMountEntry;
70
- interface IWorkspaceManifestPermissions {
71
- read?: string[];
72
- write?: string[];
73
- }
74
- interface IWorkspaceManifest {
75
- entries: Record<string, TWorkspaceManifestEntry>;
76
- environment?: Record<string, string>;
77
- permissions?: IWorkspaceManifestPermissions;
78
- }
79
- interface IWorkspaceManifestApplyOptions {
80
- targetRoot?: string;
81
- hostRoot?: string;
82
- }
83
- type TWorkspaceManifestApplyStatus = 'applied' | 'unsupported';
84
- interface IWorkspaceManifestAppliedEntry {
85
- path: string;
86
- type: TWorkspaceManifestEntry['type'];
87
- status: TWorkspaceManifestApplyStatus;
88
- message?: string;
89
- }
90
- interface IWorkspaceManifestApplyResult {
91
- entries: IWorkspaceManifestAppliedEntry[];
92
- }
93
- interface ISandboxClient {
94
- run(command: string, options?: ISandboxRunOptions): Promise<ISandboxRunResult>;
95
- readFile(path: string): Promise<string>;
96
- writeFile(path: string, content: string): Promise<void>;
97
- applyManifest?(manifest: IWorkspaceManifest, options?: IWorkspaceManifestApplyOptions): Promise<IWorkspaceManifestApplyResult>;
98
- /** Return a provider-owned resumable workspace reference. */
99
- snapshot?(): Promise<string>;
100
- /** Hydrate this client from a provider-owned workspace reference. */
101
- restore?(snapshotId: string): Promise<void>;
102
- }
103
- interface ISandboxToolOptions {
104
- sandboxClient?: ISandboxClient;
105
- }
106
-
107
- interface IE2BCommandStartOptions {
108
- timeoutMs?: number;
109
- cwd?: string;
110
- background?: false;
111
- }
112
- interface IE2BCommandResult {
113
- stdout?: string;
114
- stderr?: string;
115
- exitCode?: number;
116
- exit_code?: number;
117
- }
118
- interface IE2BCommands {
119
- run(command: string, options?: IE2BCommandStartOptions): Promise<IE2BCommandResult>;
120
- }
121
- interface IE2BFiles {
122
- read(path: string): Promise<string | Uint8Array>;
123
- write(path: string, content: string): Promise<void>;
124
- }
125
- interface IE2BSnapshot {
126
- snapshotId?: string;
127
- id?: string;
128
- }
129
- interface IE2BSandboxAdapter {
130
- sandboxId?: string;
131
- commands: IE2BCommands;
132
- files: IE2BFiles;
133
- pause?(): Promise<boolean | string | void>;
134
- connect?(): Promise<IE2BSandboxAdapter>;
135
- createSnapshot?(): Promise<IE2BSnapshot>;
136
- }
137
- interface IE2BSandboxClientOptions {
138
- sandbox: IE2BSandboxAdapter;
139
- connectSandbox?: (sandboxId: string) => Promise<IE2BSandboxAdapter>;
140
- createSandboxFromSnapshot?: (snapshotId: string) => Promise<IE2BSandboxAdapter>;
141
- }
142
- declare class E2BSandboxClient implements ISandboxClient {
143
- private sandbox;
144
- private readonly connectSandbox?;
145
- private readonly createSandboxFromSnapshot?;
146
- constructor(options: IE2BSandboxClientOptions);
147
- run(command: string, options?: ISandboxRunOptions): Promise<ISandboxRunResult>;
148
- readFile(path: string): Promise<string>;
149
- writeFile(path: string, content: string): Promise<void>;
150
- snapshot(): Promise<string>;
151
- restore(snapshotId: string): Promise<void>;
152
- }
153
-
154
- type TInMemorySandboxRunHandler = (command: string, options: ISandboxRunOptions | undefined, files: ReadonlyMap<string, string>) => Promise<ISandboxRunResult> | ISandboxRunResult;
155
- interface IInMemorySandboxClientOptions {
156
- files?: Record<string, string>;
157
- runHandler?: TInMemorySandboxRunHandler;
158
- }
159
- declare class InMemorySandboxClient implements ISandboxClient {
160
- private readonly files;
161
- private readonly snapshots;
162
- private readonly runHandler?;
163
- private snapshotSequence;
164
- constructor(options?: IInMemorySandboxClientOptions);
165
- run(command: string, options?: ISandboxRunOptions): Promise<ISandboxRunResult>;
166
- readFile(path: string): Promise<string>;
167
- writeFile(path: string, content: string): Promise<void>;
168
- snapshot(): Promise<string>;
169
- restore(snapshotId: string): Promise<void>;
170
- getFile(path: string): string | undefined;
171
- }
172
-
173
- declare function applyWorkspaceManifest(sandboxClient: ISandboxClient, manifest: IWorkspaceManifest, options?: IWorkspaceManifestApplyOptions): Promise<IWorkspaceManifestApplyResult>;
174
- declare function validateWorkspaceManifestPath(path: string): string;
175
-
176
- /**
177
- * Tool registry implementation
178
- * Manages tool registration, validation, and retrieval
179
- */
180
- declare class ToolRegistry implements IToolRegistry {
181
- private tools;
182
- /**
183
- * Register a tool
184
- */
185
- register(tool: ITool): void;
186
- /**
187
- * Unregister a tool
188
- */
189
- unregister(name: string): void;
190
- /**
191
- * Get tool by name
192
- */
193
- get(name: string): ITool | undefined;
194
- /**
195
- * Get all registered tools
196
- */
197
- getAll(): ITool[];
198
- /**
199
- * Get tool schemas
200
- */
201
- getSchemas(): IToolSchema[];
202
- /**
203
- * Check if tool exists
204
- */
205
- has(name: string): boolean;
206
- /**
207
- * Clear all tools
208
- */
209
- clear(): void;
210
- /**
211
- * Get tool names
212
- */
213
- getToolNames(): string[];
214
- /**
215
- * Get tools by pattern
216
- */
217
- getToolsByPattern(pattern: string | RegExp): ITool[];
218
- /**
219
- * Get tool count
220
- */
221
- size(): number;
222
- /**
223
- * Validate tool schema
224
- */
225
- private validateToolSchema;
226
- }
227
-
228
- /**
229
- * FunctionTool - Type definitions for Facade pattern implementation
230
- *
231
- * REASON: Complex Zod schema type compatibility requires separation of concerns
232
- * ALTERNATIVES_CONSIDERED:
233
- * 1. Fix all Zod undefined issues in single file (creates maintenance burden)
234
- * 2. Use any types strategically (reduces type safety)
235
- * 3. Remove Zod support entirely (breaks existing functionality)
236
- * 4. Create complex conditional types (adds cognitive overhead)
237
- * 5. Use type assertions everywhere (increases runtime risk)
238
- * NOTE: Tool functionality is now integrated into @robota-sdk/agent-tools package
239
- */
240
-
241
- /**
242
- * Zod schema compatibility types
243
- */
244
- interface IZodParseResult {
245
- success: boolean;
246
- data?: TToolParameters;
247
- error?: string | Error;
248
- }
249
- interface IZodSchemaDef {
250
- typeName?: string;
251
- innerType?: IZodSchema;
252
- valueType?: IZodSchema;
253
- checks?: Array<{
254
- kind: string;
255
- value?: TUniversalValue;
256
- }>;
257
- shape?: () => Record<string, IZodSchema>;
258
- type?: IZodSchema;
259
- values?: TUniversalValue[];
260
- description?: string;
261
- unknownKeys?: 'passthrough' | 'strip' | 'strict';
262
- }
263
- interface IZodSchema {
264
- parse(value: TToolParameters): TToolParameters;
265
- safeParse(value: TToolParameters): IZodParseResult;
266
- _def?: IZodSchemaDef;
267
- }
268
- /**
269
- * Parameter type validation options
270
- */
271
- interface IFunctionToolValidationOptions {
272
- strict?: boolean;
273
- allowUnknown?: boolean;
274
- validateTypes?: boolean;
275
- }
276
- /**
277
- * Schema conversion options
278
- */
279
- interface ISchemaConversionOptions {
280
- includeDescription?: boolean;
281
- strictTypes?: boolean;
282
- allowAdditionalProperties?: boolean;
283
- }
284
- /**
285
- * Tool execution metadata
286
- */
287
- interface IFunctionToolExecutionMetadata {
288
- executionTime: number;
289
- toolName: string;
290
- parameters: TToolParameters;
291
- }
292
- /**
293
- * Tool result with metadata
294
- */
295
- interface IFunctionToolResult {
296
- success: boolean;
297
- data: TUniversalValue;
298
- metadata?: IFunctionToolExecutionMetadata;
299
- }
300
-
301
- /**
302
- * Function tool implementation
303
- * Wraps a JavaScript function as a tool with schema validation
304
- *
305
- * Implements IFunctionTool without extending AbstractTool to avoid
306
- * circular runtime dependency (tools → agents → tools).
307
- */
308
- declare class FunctionTool implements IFunctionTool {
309
- readonly schema: IToolSchema;
310
- readonly fn: TToolExecutor;
311
- private eventService;
312
- constructor(schema: IToolSchema, fn: TToolExecutor);
313
- /**
314
- * Get tool name
315
- */
316
- getName(): string;
317
- /**
318
- * Set EventService for post-construction injection.
319
- * Accepts EventService as-is without transformation.
320
- * Caller is responsible for providing properly configured EventService.
321
- */
322
- setEventService(eventService: IEventService | undefined): void;
323
- /**
324
- * Execute the function tool
325
- */
326
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
327
- /**
328
- * Validate parameters (simple boolean result)
329
- */
330
- validate(parameters: TToolParameters): boolean;
331
- /**
332
- * Validate tool parameters with detailed result
333
- */
334
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
335
- /**
336
- * Get tool description
337
- */
338
- getDescription(): string;
339
- /**
340
- * Validate constructor inputs
341
- */
342
- private validateConstructorInputs;
343
- }
344
- /**
345
- * Helper function to create a function tool from a simple function
346
- */
347
- declare function createFunctionTool(name: string, description: string, parameters: IToolSchema['parameters'], fn: TToolExecutor): FunctionTool;
348
- /**
349
- * Helper function to create a function tool from Zod schema
350
- */
351
- declare function createZodFunctionTool(name: string, description: string, zodSchema: IZodSchema, fn: TToolExecutor): FunctionTool;
352
-
353
- /**
354
- * OpenAPI tool implementation
355
- * Executes API calls based on OpenAPI 3.0 specifications
356
- *
357
- * Implements ITool without extending AbstractTool to avoid
358
- * circular runtime dependency (tools → agents → tools).
359
- */
360
- declare class OpenAPITool implements ITool {
361
- readonly schema: IToolSchema;
362
- private readonly apiSpec;
363
- private readonly operationId;
364
- private readonly baseURL;
365
- private readonly config;
366
- private eventService;
367
- constructor(config: IOpenAPIToolConfig);
368
- /**
369
- * Execute the OpenAPI tool
370
- */
371
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
372
- /**
373
- * Validate tool parameters
374
- */
375
- validate(parameters: TToolParameters): boolean;
376
- /**
377
- * Validate tool parameters with detailed result
378
- */
379
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
380
- /**
381
- * Get tool name
382
- */
383
- getName(): string;
384
- /**
385
- * Set EventService for post-construction injection.
386
- */
387
- setEventService(eventService: IEventService | undefined): void;
388
- /**
389
- * Get tool description
390
- */
391
- getDescription(): string;
392
- /**
393
- * Execute the actual API call
394
- * @private
395
- */
396
- private executeAPICall;
397
- /**
398
- * Build HTTP request configuration from OpenAPI operation and parameters
399
- */
400
- private buildRequestConfig;
401
- /**
402
- * Create tool schema from OpenAPI operation specification
403
- */
404
- private createSchemaFromOpenAPI;
405
- }
406
- /**
407
- * Factory function to create OpenAPI tools from specification
408
- */
409
- declare function createOpenAPITool(config: IOpenAPIToolConfig): OpenAPITool;
410
-
411
- /**
412
- * FunctionTool - Schema conversion utilities for Facade pattern
413
- *
414
- * REASON: Complex Zod to JSON schema conversion requires isolated utility functions
415
- * ALTERNATIVES_CONSIDERED:
416
- * 1. Keep conversion logic in main class (violates single responsibility)
417
- * 2. Use third-party library (adds external dependency)
418
- * 3. Manual conversion each time (code duplication)
419
- * 4. Runtime type checking only (loses compile-time safety)
420
- * 5. Remove Zod support (breaks backward compatibility)
421
- * TODO: Consider caching conversion results for performance
422
- */
423
-
424
- /**
425
- * Convert Zod schema to JSON Schema format with safe undefined handling
426
- */
427
- declare function zodToJsonSchema(schema: IZodSchema, options?: ISchemaConversionOptions): IToolSchema['parameters'];
428
-
429
- /**
430
- * Create a BashTool instance — register with Robota agent tools registry.
431
- */
432
- declare function createBashTool(options?: ISandboxToolOptions): FunctionTool;
433
- /**
434
- * BashTool instance — register with Robota agent tools registry.
435
- */
436
- declare const bashTool: FunctionTool;
437
-
438
- /**
439
- * Create a ReadTool instance — register with Robota agent tools registry.
440
- */
441
- declare function createReadTool(options?: ISandboxToolOptions): FunctionTool;
442
- /**
443
- * ReadTool instance — register with Robota agent tools registry.
444
- */
445
- declare const readTool: FunctionTool;
446
-
447
- /**
448
- * Create a WriteTool instance — register with Robota agent tools registry.
449
- */
450
- declare function createWriteTool(options?: ISandboxToolOptions): FunctionTool;
451
- /**
452
- * WriteTool instance — register with Robota agent tools registry.
453
- */
454
- declare const writeTool: FunctionTool;
455
-
456
- /**
457
- * Create an EditTool instance — register with Robota agent tools registry.
458
- */
459
- declare function createEditTool(options?: ISandboxToolOptions): FunctionTool;
460
- /**
461
- * EditTool instance — register with Robota agent tools registry.
462
- */
463
- declare const editTool: FunctionTool;
464
-
465
- /**
466
- * GlobTool — fast file pattern search using fast-glob.
467
- *
468
- * Excludes node_modules and .git by default.
469
- * Results are sorted by modification time (most recently modified first).
470
- */
471
- /**
472
- * GlobTool instance — register with Robota agent tools registry.
473
- */
474
- declare const globTool: FunctionTool;
475
-
476
- /**
477
- * GrepTool — recursive regex content search.
478
- *
479
- * Supports two output modes:
480
- * - files_with_matches (default): return only file paths that contain a match
481
- * - content: return matching lines with optional context lines
482
- */
483
- /**
484
- * GrepTool instance — register with Robota agent tools registry.
485
- */
486
- declare const grepTool: FunctionTool;
487
-
488
- /**
489
- * WebFetchTool — fetch a URL and return its content as text.
490
- *
491
- * HTML is stripped to plain text for readability. Uses Node.js native fetch.
492
- * Output is capped at 30K chars (same as other tools).
493
- */
494
- declare const webFetchTool: FunctionTool;
495
-
496
- /**
497
- * WebSearchTool — search the web and return results.
498
- *
499
- * Uses Brave Search API when BRAVE_API_KEY is set.
500
- * Returns an error with setup instructions otherwise.
501
- */
502
- declare const webSearchTool: FunctionTool;
503
-
504
- export { E2BSandboxClient, FunctionTool, type IE2BSandboxAdapter, type IE2BSandboxClientOptions, type IFunctionToolExecutionMetadata, type IFunctionToolResult, type IFunctionToolValidationOptions, type IInMemorySandboxClientOptions, type ISandboxClient, type ISandboxRunOptions, type ISandboxRunResult, type ISandboxToolOptions, type ISchemaConversionOptions, type IWorkspaceManifest, type IWorkspaceManifestAppliedEntry, type IWorkspaceManifestApplyOptions, type IWorkspaceManifestApplyResult, type IWorkspaceManifestAzureBlobMountEntry, type IWorkspaceManifestDirectoryEntry, type IWorkspaceManifestFileEntry, type IWorkspaceManifestGcsMountEntry, type IWorkspaceManifestGitRepositoryEntry, type IWorkspaceManifestLocalDirectoryEntry, type IWorkspaceManifestLocalFileEntry, type IWorkspaceManifestPermissions, type IWorkspaceManifestR2MountEntry, type IWorkspaceManifestS3MountEntry, type IZodParseResult, type IZodSchema, type IZodSchemaDef, InMemorySandboxClient, OpenAPITool, type TInMemorySandboxRunHandler, type TToolResult, type TWorkspaceManifestApplyStatus, type TWorkspaceManifestEntry, ToolRegistry, applyWorkspaceManifest, bashTool, createBashTool, createEditTool, createFunctionTool, createOpenAPITool, createReadTool, createWriteTool, createZodFunctionTool, editTool, globTool, grepTool, readTool, validateWorkspaceManifestPath, webFetchTool, webSearchTool, writeTool, zodToJsonSchema };