@robota-sdk/agent-tools 3.0.0-beta.7 → 3.0.0-beta.70

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,370 +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
- }
12
-
13
- /**
14
- * Tool registry implementation
15
- * Manages tool registration, validation, and retrieval
16
- */
17
- declare class ToolRegistry implements IToolRegistry {
18
- private tools;
19
- /**
20
- * Register a tool
21
- */
22
- register(tool: ITool): void;
23
- /**
24
- * Unregister a tool
25
- */
26
- unregister(name: string): void;
27
- /**
28
- * Get tool by name
29
- */
30
- get(name: string): ITool | undefined;
31
- /**
32
- * Get all registered tools
33
- */
34
- getAll(): ITool[];
35
- /**
36
- * Get tool schemas
37
- */
38
- getSchemas(): IToolSchema[];
39
- /**
40
- * Check if tool exists
41
- */
42
- has(name: string): boolean;
43
- /**
44
- * Clear all tools
45
- */
46
- clear(): void;
47
- /**
48
- * Get tool names
49
- */
50
- getToolNames(): string[];
51
- /**
52
- * Get tools by pattern
53
- */
54
- getToolsByPattern(pattern: string | RegExp): ITool[];
55
- /**
56
- * Get tool count
57
- */
58
- size(): number;
59
- /**
60
- * Validate tool schema
61
- */
62
- private validateToolSchema;
63
- }
64
-
65
- /**
66
- * FunctionTool - Type definitions for Facade pattern implementation
67
- *
68
- * REASON: Complex Zod schema type compatibility requires separation of concerns
69
- * ALTERNATIVES_CONSIDERED:
70
- * 1. Fix all Zod undefined issues in single file (creates maintenance burden)
71
- * 2. Use any types strategically (reduces type safety)
72
- * 3. Remove Zod support entirely (breaks existing functionality)
73
- * 4. Create complex conditional types (adds cognitive overhead)
74
- * 5. Use type assertions everywhere (increases runtime risk)
75
- * NOTE: Tool functionality is now integrated into @robota-sdk/agent-tools package
76
- */
77
-
78
- /**
79
- * Zod schema compatibility types
80
- */
81
- interface IZodParseResult {
82
- success: boolean;
83
- data?: TToolParameters;
84
- error?: string | Error;
85
- }
86
- interface IZodSchemaDef {
87
- typeName?: string;
88
- innerType?: IZodSchema;
89
- valueType?: IZodSchema;
90
- checks?: Array<{
91
- kind: string;
92
- value?: TUniversalValue;
93
- }>;
94
- shape?: () => Record<string, IZodSchema>;
95
- type?: IZodSchema;
96
- values?: TUniversalValue[];
97
- description?: string;
98
- }
99
- interface IZodSchema {
100
- parse(value: TToolParameters): TToolParameters;
101
- safeParse(value: TToolParameters): IZodParseResult;
102
- _def?: IZodSchemaDef;
103
- }
104
- /**
105
- * Parameter type validation options
106
- */
107
- interface IFunctionToolValidationOptions {
108
- strict?: boolean;
109
- allowUnknown?: boolean;
110
- validateTypes?: boolean;
111
- }
112
- /**
113
- * Schema conversion options
114
- */
115
- interface ISchemaConversionOptions {
116
- includeDescription?: boolean;
117
- strictTypes?: boolean;
118
- allowAdditionalProperties?: boolean;
119
- }
120
- /**
121
- * Tool execution metadata
122
- */
123
- interface IFunctionToolExecutionMetadata {
124
- executionTime: number;
125
- toolName: string;
126
- parameters: TToolParameters;
127
- }
128
- /**
129
- * Tool result with metadata
130
- */
131
- interface IFunctionToolResult {
132
- success: boolean;
133
- data: TUniversalValue;
134
- metadata?: IFunctionToolExecutionMetadata;
135
- }
136
-
137
- /**
138
- * Function tool implementation
139
- * Wraps a JavaScript function as a tool with schema validation
140
- *
141
- * Implements IFunctionTool without extending AbstractTool to avoid
142
- * circular runtime dependency (tools → agents → tools).
143
- */
144
- declare class FunctionTool implements IFunctionTool {
145
- readonly schema: IToolSchema;
146
- readonly fn: TToolExecutor;
147
- private eventService;
148
- constructor(schema: IToolSchema, fn: TToolExecutor);
149
- /**
150
- * Get tool name
151
- */
152
- getName(): string;
153
- /**
154
- * Set EventService for post-construction injection.
155
- * Accepts EventService as-is without transformation.
156
- * Caller is responsible for providing properly configured EventService.
157
- */
158
- setEventService(eventService: IEventService | undefined): void;
159
- /**
160
- * Execute the function tool
161
- */
162
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
163
- /**
164
- * Validate parameters (simple boolean result)
165
- */
166
- validate(parameters: TToolParameters): boolean;
167
- /**
168
- * Validate tool parameters with detailed result
169
- */
170
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
171
- /**
172
- * Get tool description
173
- */
174
- getDescription(): string;
175
- /**
176
- * Get detailed validation errors
177
- */
178
- private getValidationErrors;
179
- /**
180
- * Validate individual parameter type
181
- */
182
- private validateParameterType;
183
- /**
184
- * Validate constructor inputs
185
- */
186
- private validateConstructorInputs;
187
- }
188
- /**
189
- * Helper function to create a function tool from a simple function
190
- */
191
- declare function createFunctionTool(name: string, description: string, parameters: IToolSchema['parameters'], fn: TToolExecutor): FunctionTool;
192
- /**
193
- * Helper function to create a function tool from Zod schema
194
- */
195
- declare function createZodFunctionTool(name: string, description: string, zodSchema: IZodSchema, fn: TToolExecutor): FunctionTool;
196
-
197
- /**
198
- * OpenAPI tool implementation
199
- * Executes API calls based on OpenAPI 3.0 specifications
200
- *
201
- * Implements ITool without extending AbstractTool to avoid
202
- * circular runtime dependency (tools → agents → tools).
203
- */
204
- declare class OpenAPITool implements ITool {
205
- readonly schema: IToolSchema;
206
- private readonly apiSpec;
207
- private readonly operationId;
208
- private readonly baseURL;
209
- private readonly config;
210
- private eventService;
211
- constructor(config: IOpenAPIToolConfig);
212
- /**
213
- * Execute the OpenAPI tool
214
- */
215
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
216
- /**
217
- * Validate tool parameters
218
- */
219
- validate(parameters: TToolParameters): boolean;
220
- /**
221
- * Validate tool parameters with detailed result
222
- */
223
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
224
- /**
225
- * Get tool name
226
- */
227
- getName(): string;
228
- /**
229
- * Set EventService for post-construction injection.
230
- */
231
- setEventService(eventService: IEventService | undefined): void;
232
- /**
233
- * Get tool description
234
- */
235
- getDescription(): string;
236
- /**
237
- * Execute the actual API call
238
- * @private
239
- */
240
- private executeAPICall;
241
- /**
242
- * Find the operation in the OpenAPI specification
243
- */
244
- private findOperation;
245
- /**
246
- * Build HTTP request configuration from OpenAPI operation and parameters
247
- */
248
- private buildRequestConfig;
249
- /**
250
- * Create tool schema from OpenAPI operation specification
251
- */
252
- private createSchemaFromOpenAPI;
253
- /**
254
- * Convert OpenAPI parameter to tool parameter schema
255
- */
256
- private convertOpenAPIParamToSchema;
257
- /**
258
- * Convert OpenAPI schema to parameter schema
259
- */
260
- private convertOpenAPISchemaToParameterSchema;
261
- /**
262
- * Map OpenAPI type to JSON schema type
263
- */
264
- private mapOpenAPIType;
265
- }
266
- /**
267
- * Factory function to create OpenAPI tools from specification
268
- */
269
- declare function createOpenAPITool(config: IOpenAPIToolConfig): OpenAPITool;
270
-
271
- /**
272
- * FunctionTool - Schema conversion utilities for Facade pattern
273
- *
274
- * REASON: Complex Zod to JSON schema conversion requires isolated utility functions
275
- * ALTERNATIVES_CONSIDERED:
276
- * 1. Keep conversion logic in main class (violates single responsibility)
277
- * 2. Use third-party library (adds external dependency)
278
- * 3. Manual conversion each time (code duplication)
279
- * 4. Runtime type checking only (loses compile-time safety)
280
- * 5. Remove Zod support (breaks backward compatibility)
281
- * TODO: Consider caching conversion results for performance
282
- */
283
-
284
- /**
285
- * Convert Zod schema to JSON Schema format with safe undefined handling
286
- */
287
- declare function zodToJsonSchema(schema: IZodSchema, options?: ISchemaConversionOptions): IToolSchema['parameters'];
288
-
289
- /**
290
- * BashTool — execute shell commands via child_process.spawn
291
- *
292
- * Returns TToolResult JSON string. Non-zero exit is returned as success:true
293
- * with exitCode set, matching Claude Code behaviour (the command ran, it just
294
- * exited non-zero — the LLM can decide what to do with that information).
295
- */
296
- /**
297
- * BashTool instance — register with Robota agent tools registry.
298
- */
299
- declare const bashTool: FunctionTool;
300
-
301
- /**
302
- * ReadTool — read a file and return its contents with line numbers (cat -n style).
303
- *
304
- * Supports offset/limit for partial reads. Detects binary files and refuses to
305
- * return their raw bytes. Default limit is 2000 lines.
306
- */
307
- /**
308
- * ReadTool instance — register with Robota agent tools registry.
309
- */
310
- declare const readTool: FunctionTool;
311
-
312
- /**
313
- * WriteTool — write content to a file, auto-creating parent directories.
314
- */
315
- /**
316
- * WriteTool instance — register with Robota agent tools registry.
317
- */
318
- declare const writeTool: FunctionTool;
319
-
320
- /**
321
- * EditTool — perform string-replace edits on a file.
322
- *
323
- * By default, requires the oldString to appear exactly once in the file
324
- * (ensuring surgical edits). Pass replaceAll:true to replace all occurrences.
325
- */
326
- /**
327
- * EditTool instance — register with Robota agent tools registry.
328
- */
329
- declare const editTool: FunctionTool;
330
-
331
- /**
332
- * GlobTool — fast file pattern search using fast-glob.
333
- *
334
- * Excludes node_modules and .git by default.
335
- * Results are sorted by modification time (most recently modified first).
336
- */
337
- /**
338
- * GlobTool instance — register with Robota agent tools registry.
339
- */
340
- declare const globTool: FunctionTool;
341
-
342
- /**
343
- * GrepTool — recursive regex content search.
344
- *
345
- * Supports two output modes:
346
- * - files_with_matches (default): return only file paths that contain a match
347
- * - content: return matching lines with optional context lines
348
- */
349
- /**
350
- * GrepTool instance — register with Robota agent tools registry.
351
- */
352
- declare const grepTool: FunctionTool;
353
-
354
- /**
355
- * WebFetchTool — fetch a URL and return its content as text.
356
- *
357
- * HTML is stripped to plain text for readability. Uses Node.js native fetch.
358
- * Output is capped at 30K chars (same as other tools).
359
- */
360
- declare const webFetchTool: FunctionTool;
361
-
362
- /**
363
- * WebSearchTool — search the web and return results.
364
- *
365
- * Uses Brave Search API when BRAVE_API_KEY is set.
366
- * Returns an error with setup instructions otherwise.
367
- */
368
- declare const webSearchTool: FunctionTool;
369
-
370
- export { FunctionTool, type IFunctionToolExecutionMetadata, type IFunctionToolResult, type IFunctionToolValidationOptions, type ISchemaConversionOptions, type IZodParseResult, type IZodSchema, type IZodSchemaDef, OpenAPITool, type TToolResult, ToolRegistry, bashTool, createFunctionTool, createOpenAPITool, createZodFunctionTool, editTool, globTool, grepTool, readTool, webFetchTool, webSearchTool, writeTool, zodToJsonSchema };