llmz 0.0.13 → 0.0.15

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 (52) hide show
  1. package/CLAUDE.md +363 -0
  2. package/README.md +61 -34
  3. package/dist/abort-signal.d.ts +40 -0
  4. package/dist/chat.d.ts +325 -0
  5. package/dist/{chunk-KH6JQYQA.js → chunk-2D2DE7CD.js} +2 -2
  6. package/dist/chunk-3G3BS5IA.cjs +256 -0
  7. package/dist/{chunk-SNDVQU5A.js → chunk-3JYCCI4S.js} +1 -1
  8. package/dist/chunk-A7QHWVD7.js +493 -0
  9. package/dist/{chunk-IH2WQFO5.js → chunk-EE6NVDID.js} +1 -1
  10. package/dist/{chunk-4L6D2A6O.cjs → chunk-FZJHYLM2.cjs} +14 -14
  11. package/dist/{chunk-JGVAZO4X.cjs → chunk-GZPN7RGH.cjs} +2 -2
  12. package/dist/{chunk-SHJDRZF5.cjs → chunk-PIDLNYIP.cjs} +25 -25
  13. package/dist/{chunk-PRVFVXT4.js → chunk-RBRTK37G.js} +383 -4
  14. package/dist/{chunk-HJKOSEH2.cjs → chunk-TCRRSS44.cjs} +397 -18
  15. package/dist/chunk-VPTFUOIK.js +256 -0
  16. package/dist/{chunk-276Q6EWP.cjs → chunk-WHNOR4ZU.cjs} +3 -0
  17. package/dist/chunk-XGJOEQMW.cjs +493 -0
  18. package/dist/{chunk-4MNIJGK6.js → chunk-ZORRILUV.js} +3 -0
  19. package/dist/context.d.ts +412 -4
  20. package/dist/{dual-modes-T53P72CH.js → dual-modes-7FI4T35O.js} +3 -3
  21. package/dist/{dual-modes-VLIGPIHX.cjs → dual-modes-OFHV2C3X.cjs} +4 -4
  22. package/dist/exit-XAYKJ6TR.cjs +8 -0
  23. package/dist/{exit-YORW76T3.js → exit-YLO7BY7Z.js} +2 -2
  24. package/dist/exit.d.ts +369 -2
  25. package/dist/index.cjs +253 -28
  26. package/dist/index.d.ts +71 -1
  27. package/dist/index.js +242 -17
  28. package/dist/{llmz-ROOX7RYI.js → llmz-67EZPJ4E.js} +113 -39
  29. package/dist/{llmz-QLZBDG2Z.cjs → llmz-WVNKAMCP.cjs} +123 -49
  30. package/dist/llmz.d.ts +142 -5
  31. package/dist/objects.d.ts +350 -1
  32. package/dist/result.d.ts +809 -6
  33. package/dist/snapshots.d.ts +181 -1
  34. package/dist/{tool-QP4MVRWI.cjs → tool-O4SFRIE4.cjs} +4 -4
  35. package/dist/{tool-N6ODRRGH.js → tool-PCOYOCRH.js} +3 -3
  36. package/dist/tool.d.ts +470 -2
  37. package/dist/{truncator-IY2MXOMC.js → truncator-BSP6PQPC.js} +2 -2
  38. package/dist/truncator-W3NXBLYJ.cjs +10 -0
  39. package/dist/types.d.ts +3 -0
  40. package/dist/{typings-GDMY6VY2.js → typings-WYHEFCYB.js} +2 -2
  41. package/dist/{typings-2CPHOFDN.cjs → typings-Y45GMPZT.cjs} +3 -3
  42. package/dist/utils-L5QAQXV2.cjs +39 -0
  43. package/dist/{utils-N24IHDFA.js → utils-RQHQ2KOG.js} +1 -1
  44. package/docs/TODO.md +919 -0
  45. package/package.json +3 -3
  46. package/dist/chunk-C6WNNTEV.cjs +0 -212
  47. package/dist/chunk-GWFYZDUR.cjs +0 -105
  48. package/dist/chunk-JAGB2AOU.js +0 -212
  49. package/dist/chunk-JMSZKB4T.js +0 -105
  50. package/dist/exit-TRXEU4OU.cjs +0 -8
  51. package/dist/truncator-DUMWEGQO.cjs +0 -10
  52. package/dist/utils-A7WNEFTA.cjs +0 -39
package/dist/tool.d.ts CHANGED
@@ -1,18 +1,207 @@
1
1
  import { TypeOf } from '@bpinternal/zui';
2
2
  import { JSONSchema7 } from 'json-schema';
3
- import { ZuiType } from './types.js';
3
+ import { Serializable, ZuiType } from './types.js';
4
+ /**
5
+ * Input parameters passed to tool retry functions.
6
+ *
7
+ * @template I - The input type for the tool
8
+ */
4
9
  type ToolRetryInput<I> = {
10
+ /** The original input that was passed to the tool */
5
11
  input: I;
12
+ /** The current attempt number (starting from 1) */
6
13
  attempt: number;
14
+ /** The error that caused the retry, if any */
7
15
  error?: unknown;
8
16
  };
17
+ /**
18
+ * Function signature for custom tool retry logic.
19
+ *
20
+ * Retry functions receive information about the failed attempt and return a boolean
21
+ * indicating whether the tool should be retried. This allows for sophisticated
22
+ * retry strategies based on error types, attempt counts, or other factors.
23
+ *
24
+ * @template I - The input type for the tool
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const retryLogic: ToolRetryFn<{ url: string }> = ({ attempt, error }) => {
29
+ * // Retry up to 3 times for network errors, but not for auth errors
30
+ * if (attempt >= 3) return false
31
+ * if (error?.message?.includes('401') || error?.message?.includes('403')) return false
32
+ * return error?.message?.includes('network') || error?.message?.includes('timeout')
33
+ * }
34
+ * ```
35
+ */
9
36
  export type ToolRetryFn<I> = (args: ToolRetryInput<I>) => boolean | Promise<boolean>;
37
+ /** @internal Utility type to check if T is an object (but not a function) */
10
38
  type IsObject<T> = T extends object ? (T extends Function ? false : true) : false;
39
+ /** @internal Utility type that makes object types partial, but leaves primitives unchanged */
11
40
  type SmartPartial<T> = IsObject<T> extends true ? Partial<T> : T;
41
+ /**
42
+ * Context information passed to tool handlers during execution.
43
+ *
44
+ * This context provides metadata about the tool call, which can be useful
45
+ * for logging, debugging, or implementing features like call tracking.
46
+ */
12
47
  type ToolCallContext = {
48
+ /** Unique identifier for this specific tool call */
13
49
  callId: string;
14
50
  };
15
- export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiType> {
51
+ export declare namespace Tool {
52
+ type JSON = {
53
+ name: string;
54
+ aliases: string[];
55
+ description?: string;
56
+ metadata: Record<string, unknown>;
57
+ input?: JSONSchema7;
58
+ output?: JSONSchema7;
59
+ staticInputValues?: SmartPartial<TypeOf<ZuiType>>;
60
+ maxRetries: number;
61
+ };
62
+ }
63
+ /**
64
+ * Tool represents a callable function that agents can use to interact with external systems.
65
+ *
66
+ * Tools are the core building blocks of LLMz agents, providing type-safe interfaces between
67
+ * the generated TypeScript code and external APIs, databases, file systems, or any other
68
+ * service your agent needs to interact with.
69
+ *
70
+ * ## Key Features
71
+ * - **Type Safety**: Full TypeScript inference with Zui/Zod schema validation
72
+ * - **Input/Output Validation**: Automatic validation of inputs and outputs against schemas
73
+ * - **Retry Logic**: Built-in retry mechanisms with custom retry functions
74
+ * - **Static Values**: Pre-configure parameters that won't change between calls
75
+ * - **Tool Cloning**: Create variations of existing tools with modified behavior
76
+ * - **TypeScript Generation**: Generate type definitions for LLM context
77
+ * - **Error Handling**: Comprehensive error handling with detailed validation messages
78
+ *
79
+ * ## Basic Usage
80
+ *
81
+ * ### Simple Tool
82
+ * ```typescript
83
+ * const weatherTool = new Tool({
84
+ * name: 'getCurrentWeather',
85
+ * description: 'Gets current weather conditions for a city',
86
+ * input: z.object({
87
+ * city: z.string().describe('City name'),
88
+ * units: z.enum(['celsius', 'fahrenheit']).default('celsius'),
89
+ * }),
90
+ * output: z.object({
91
+ * temperature: z.number(),
92
+ * condition: z.string(),
93
+ * humidity: z.number(),
94
+ * }),
95
+ * async handler({ city, units }) {
96
+ * const response = await fetch(`/api/weather?city=${city}&units=${units}`)
97
+ * return response.json()
98
+ * },
99
+ * })
100
+ * ```
101
+ *
102
+ * ### Using Tools in Execute
103
+ * ```typescript
104
+ * const result = await execute({
105
+ * instructions: 'Get the weather for San Francisco and recommend clothing',
106
+ * tools: [weatherTool],
107
+ * client,
108
+ * })
109
+ * ```
110
+ *
111
+ * ## Advanced Patterns
112
+ *
113
+ * ### Static Input Values
114
+ * Pre-configure parameters that shouldn't change:
115
+ * ```typescript
116
+ * const restrictedWeatherTool = weatherTool.setStaticInputValues({
117
+ * units: 'celsius' // Always use celsius, agent can't override
118
+ * })
119
+ * ```
120
+ *
121
+ * ### Retry Logic
122
+ * Add resilience with custom retry logic:
123
+ * ```typescript
124
+ * const resilientTool = new Tool({
125
+ * name: 'apiCall',
126
+ * // ... other properties
127
+ * async handler({ endpoint }) {
128
+ * const response = await fetch(endpoint)
129
+ * if (!response.ok) throw new Error(`API error: ${response.status}`)
130
+ * return response.json()
131
+ * },
132
+ * retry: ({ attempt, error }) => {
133
+ * // Retry up to 3 times for network errors, but not auth errors
134
+ * if (attempt >= 3) return false
135
+ * if (error.message.includes('401') || error.message.includes('403')) return false
136
+ * return true
137
+ * },
138
+ * })
139
+ * ```
140
+ *
141
+ * ### Tool Cloning
142
+ * Create variations of existing tools:
143
+ * ```typescript
144
+ * const enhancedWeatherTool = weatherTool.clone({
145
+ * name: 'getEnhancedWeather',
146
+ * description: 'Gets weather with additional forecasting',
147
+ * output: (original) => original!.extend({
148
+ * forecast: z.array(z.object({
149
+ * day: z.string(),
150
+ * temperature: z.number(),
151
+ * condition: z.string(),
152
+ * })),
153
+ * }),
154
+ * async handler(input) {
155
+ * const basicWeather = await weatherTool.execute(input, ctx)
156
+ * const forecast = await getForecast(input.city)
157
+ * return { ...basicWeather, forecast }
158
+ * },
159
+ * })
160
+ * ```
161
+ *
162
+ * ## Schema Design Best Practices
163
+ *
164
+ * ### Rich Descriptions
165
+ * Use detailed descriptions to help the LLM understand when and how to use tools:
166
+ * ```typescript
167
+ * input: z.object({
168
+ * query: z.string()
169
+ * .min(1)
170
+ * .max(500)
171
+ * .describe('Search query - be specific and include relevant keywords'),
172
+ * maxResults: z.number()
173
+ * .min(1)
174
+ * .max(50)
175
+ * .default(10)
176
+ * .describe('Maximum number of results to return (1-50, default: 10)'),
177
+ * includeSnippets: z.boolean()
178
+ * .default(true)
179
+ * .describe('Whether to include content snippets in results'),
180
+ * })
181
+ * ```
182
+ *
183
+ * ### Enums for Controlled Values
184
+ * Use enums to restrict inputs to valid options:
185
+ * ```typescript
186
+ * input: z.object({
187
+ * operation: z.enum(['create', 'read', 'update', 'delete'])
188
+ * .describe('CRUD operation to perform'),
189
+ * format: z.enum(['json', 'csv', 'xml'])
190
+ * .default('json')
191
+ * .describe('Output format for the response'),
192
+ * })
193
+ * ```
194
+ *
195
+ * ## Error Handling
196
+ *
197
+ * Tools automatically handle:
198
+ * - **Input validation**: Invalid inputs throw descriptive errors
199
+ * - **Output validation**: Outputs are validated but invalid outputs are still returned
200
+ * - **Handler errors**: Exceptions in handlers are caught and can trigger retries
201
+ * - **Type coercion**: Basic type coercion where possible
202
+ *
203
+ */
204
+ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiType> implements Serializable<Tool.JSON> {
16
205
  private _staticInputValues?;
17
206
  name: string;
18
207
  aliases: string[];
@@ -22,10 +211,136 @@ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiTy
22
211
  output?: JSONSchema7;
23
212
  retry?: ToolRetryFn<TypeOf<I>>;
24
213
  MAX_RETRIES: number;
214
+ /**
215
+ * Sets static input values that will be automatically applied to all tool calls.
216
+ *
217
+ * Static values allow you to pre-configure certain parameters that shouldn't change
218
+ * between calls, effectively removing them from the LLM's control while ensuring
219
+ * they're always present when the tool executes.
220
+ *
221
+ * @param values - Partial input values to apply statically. Set to null/undefined to clear.
222
+ * @returns The tool instance for method chaining
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * // Create a tool with configurable parameters
227
+ * const searchTool = new Tool({
228
+ * name: 'search',
229
+ * input: z.object({
230
+ * query: z.string(),
231
+ * maxResults: z.number().default(10),
232
+ * includeSnippets: z.boolean().default(true),
233
+ * }),
234
+ * handler: async ({ query, maxResults, includeSnippets }) => {
235
+ * // Implementation
236
+ * },
237
+ * })
238
+ *
239
+ * // Create a restricted version with static values
240
+ * const restrictedSearch = searchTool.setStaticInputValues({
241
+ * maxResults: 5, // Always limit to 5 results
242
+ * includeSnippets: false, // Never include snippets
243
+ * })
244
+ *
245
+ * // LLM can only control 'query' parameter now
246
+ * // The tool will always use maxResults: 5, includeSnippets: false
247
+ * ```
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * // Clear static values
252
+ * const unrestricted = restrictedTool.setStaticInputValues(null)
253
+ * ```
254
+ */
25
255
  setStaticInputValues(values: SmartPartial<TypeOf<I>>): this;
256
+ /**
257
+ * Gets the computed input schema with static values applied.
258
+ *
259
+ * This property returns the final input schema that will be used for validation,
260
+ * including any static input values that have been set via setStaticInputValues().
261
+ *
262
+ * @returns The Zui schema for input validation
263
+ * @internal
264
+ */
26
265
  get zInput(): import("@bpinternal/zui").ZodTypeAny;
266
+ /**
267
+ * Gets the output schema for validation.
268
+ *
269
+ * @returns The Zui schema for output validation
270
+ * @internal
271
+ */
27
272
  get zOutput(): import("@bpinternal/zui").ZodTypeAny | import("@bpinternal/zui").ZodVoid;
273
+ /**
274
+ * Renames the tool and updates its aliases.
275
+ *
276
+ * @param name - New name for the tool (must be a valid identifier)
277
+ * @returns The tool instance for method chaining
278
+ * @throws Error if the name is not a valid identifier
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * const weatherTool = new Tool({ name: 'getWeather', ... })
283
+ * weatherTool.rename('getCurrentWeather')
284
+ * console.log(weatherTool.name) // 'getCurrentWeather'
285
+ * ```
286
+ */
28
287
  rename(name: string): this;
288
+ /**
289
+ * Creates a new tool based on this one with modified properties.
290
+ *
291
+ * Clone allows you to create variations of existing tools with different names,
292
+ * schemas, handlers, or other configuration. This is useful for creating specialized
293
+ * versions of tools or adding additional functionality.
294
+ *
295
+ * @param props - Properties to override in the cloned tool
296
+ * @returns A new Tool instance with the specified modifications
297
+ * @throws Error if cloning fails due to invalid configuration
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * // Create a basic search tool
302
+ * const basicSearch = new Tool({
303
+ * name: 'search',
304
+ * input: z.object({ query: z.string() }),
305
+ * output: z.object({ results: z.array(z.string()) }),
306
+ * handler: async ({ query }) => ({ results: await search(query) }),
307
+ * })
308
+ *
309
+ * // Clone with enhanced output schema
310
+ * const enhancedSearch = basicSearch.clone({
311
+ * name: 'enhancedSearch',
312
+ * description: 'Search with additional metadata',
313
+ * output: (original) => original!.extend({
314
+ * totalResults: z.number(),
315
+ * searchTime: z.number(),
316
+ * }),
317
+ * handler: async ({ query }) => {
318
+ * const startTime = Date.now()
319
+ * const results = await search(query)
320
+ * return {
321
+ * results: results.items,
322
+ * totalResults: results.total,
323
+ * searchTime: Date.now() - startTime,
324
+ * }
325
+ * },
326
+ * })
327
+ * ```
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * // Clone with restricted access
332
+ * const restrictedTool = adminTool.clone({
333
+ * name: 'userTool',
334
+ * handler: async (input, ctx) => {
335
+ * // Add authorization check
336
+ * if (!isAuthorized(ctx.callId)) {
337
+ * throw new Error('Unauthorized access')
338
+ * }
339
+ * return adminTool.execute(input, ctx)
340
+ * },
341
+ * })
342
+ * ```
343
+ */
29
344
  clone<IX extends ZuiType = I, OX extends ZuiType = O>(props?: Partial<{
30
345
  name: string;
31
346
  aliases?: string[];
@@ -38,6 +353,82 @@ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiTy
38
353
  retry: ToolRetryFn<TypeOf<IX>>;
39
354
  }>): Tool<IX, OX>;
40
355
  private _handler;
356
+ /**
357
+ * Creates a new Tool instance.
358
+ *
359
+ * @param props - Tool configuration properties
360
+ * @param props.name - Unique tool name (must be valid TypeScript identifier)
361
+ * @param props.description - Human-readable description for the LLM
362
+ * @param props.input - Zui/Zod schema for input validation (optional)
363
+ * @param props.output - Zui/Zod schema for output validation (optional)
364
+ * @param props.handler - Async function that implements the tool logic
365
+ * @param props.aliases - Alternative names for the tool (optional)
366
+ * @param props.metadata - Additional metadata for the tool (optional)
367
+ * @param props.staticInputValues - Default input values (optional)
368
+ * @param props.retry - Custom retry logic function (optional)
369
+ *
370
+ * @throws Error if name is not a valid identifier
371
+ * @throws Error if description is not a string
372
+ * @throws Error if metadata is not an object
373
+ * @throws Error if handler is not a function
374
+ * @throws Error if aliases contains invalid identifiers
375
+ * @throws Error if input/output schemas are invalid
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * const weatherTool = new Tool({
380
+ * name: 'getCurrentWeather',
381
+ * description: 'Fetches current weather data for a given city',
382
+ * aliases: ['weather', 'getWeather'], // Alternative names
383
+ *
384
+ * input: z.object({
385
+ * city: z.string().min(1).describe('City name to get weather for'),
386
+ * units: z.enum(['celsius', 'fahrenheit']).default('celsius'),
387
+ * includeHourly: z.boolean().default(false),
388
+ * }),
389
+ *
390
+ * output: z.object({
391
+ * temperature: z.number(),
392
+ * description: z.string(),
393
+ * humidity: z.number().min(0).max(100),
394
+ * hourlyForecast: z.array(z.object({
395
+ * hour: z.number(),
396
+ * temp: z.number(),
397
+ * condition: z.string(),
398
+ * })).optional(),
399
+ * }),
400
+ *
401
+ * async handler({ city, units, includeHourly }) {
402
+ * const response = await fetch(`/api/weather?city=${encodeURIComponent(city)}&units=${units}`)
403
+ * const data = await response.json()
404
+ *
405
+ * const result = {
406
+ * temperature: data.main.temp,
407
+ * description: data.weather[0].description,
408
+ * humidity: data.main.humidity,
409
+ * }
410
+ *
411
+ * if (includeHourly) {
412
+ * result.hourlyForecast = data.hourly?.slice(0, 24) || []
413
+ * }
414
+ *
415
+ * return result
416
+ * },
417
+ *
418
+ * // Optional: Add retry logic for network errors
419
+ * retry: ({ attempt, error }) => {
420
+ * return attempt < 3 && error.message.includes('network')
421
+ * },
422
+ *
423
+ * // Optional: Add metadata
424
+ * metadata: {
425
+ * category: 'weather',
426
+ * rateLimit: 100,
427
+ * cacheable: true,
428
+ * },
429
+ * })
430
+ * ```
431
+ */
41
432
  constructor(props: {
42
433
  name: string;
43
434
  aliases?: string[];
@@ -49,8 +440,85 @@ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiTy
49
440
  handler: (args: TypeOf<I>, ctx: ToolCallContext) => Promise<TypeOf<O>>;
50
441
  retry?: ToolRetryFn<TypeOf<I>>;
51
442
  });
443
+ /**
444
+ * Executes the tool with the given input and context.
445
+ *
446
+ * This method handles input validation, retry logic, output validation, and error handling.
447
+ * It's called internally by the LLMz execution engine when generated code calls the tool.
448
+ *
449
+ * @param input - Input data to pass to the tool handler
450
+ * @param ctx - Tool call context containing call ID and other metadata
451
+ * @returns Promise resolving to the tool's output
452
+ * @throws Error if input validation fails
453
+ * @throws Error if tool execution fails after all retries
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * // Direct tool execution (usually done by LLMz internally)
458
+ * const result = await weatherTool.execute(
459
+ * { city: 'San Francisco', units: 'fahrenheit' },
460
+ * { callId: 'call_123' }
461
+ * )
462
+ * console.log(result.temperature) // 72
463
+ * ```
464
+ *
465
+ * @internal This method is primarily used internally by the LLMz execution engine
466
+ */
52
467
  execute(input: TypeOf<I>, ctx: ToolCallContext): Promise<TypeOf<O>>;
468
+ /**
469
+ * Generates TypeScript type definitions for this tool.
470
+ *
471
+ * This method creates TypeScript function declarations that are included in the
472
+ * LLM's context to help it understand how to call the tool correctly. The generated
473
+ * types include parameter types, return types, and JSDoc comments with descriptions.
474
+ *
475
+ * @returns Promise resolving to TypeScript declaration string
476
+ */
53
477
  getTypings(): Promise<string>;
478
+ /**
479
+ * Ensures all tools in an array have unique names by appending numbers to duplicates.
480
+ *
481
+ * When multiple tools have the same name, this method renames them by appending
482
+ * incrementing numbers (tool1, tool2, etc.) to avoid conflicts. Tools with already
483
+ * unique names are left unchanged.
484
+ *
485
+ * You usually don't need to call this method directly, as LLMz will automatically detect and rename tools with conflicting names.
486
+ *
487
+ * @param tools - Array of tools to process for unique names
488
+ * @returns Array of tools with guaranteed unique names
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * const tools = [
493
+ * new Tool({ name: 'search', handler: async () => {} }),
494
+ * new Tool({ name: 'search', handler: async () => {} }),
495
+ * new Tool({ name: 'unique', handler: async () => {} }),
496
+ * new Tool({ name: 'search', handler: async () => {} }),
497
+ * ]
498
+ *
499
+ * const uniqueTools = Tool.withUniqueNames(tools)
500
+ * console.log(uniqueTools.map(t => t.name))
501
+ * // Output: ['search1', 'search1', 'unique', 'search']
502
+ * // Note: The last occurrence keeps the original name
503
+ * ```
504
+ *
505
+ * @static
506
+ */
54
507
  static withUniqueNames: (tools: Tool<any, any>[]) => Tool<any, any>[];
508
+ /**
509
+ * Converts the tool to its JSON representation.
510
+ *
511
+ * @returns JSON representation of the Tool instance
512
+ */
513
+ toJSON(): {
514
+ name: string;
515
+ aliases: string[];
516
+ description: string | undefined;
517
+ metadata: Record<string, unknown>;
518
+ input: JSONSchema7 | undefined;
519
+ output: JSONSchema7 | undefined;
520
+ staticInputValues: unknown;
521
+ maxRetries: number;
522
+ };
55
523
  }
56
524
  export {};
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  truncateWrappedContent,
3
3
  wrapContent
4
- } from "./chunk-SNDVQU5A.js";
5
- import "./chunk-4MNIJGK6.js";
4
+ } from "./chunk-3JYCCI4S.js";
5
+ import "./chunk-ZORRILUV.js";
6
6
  import "./chunk-7WRN4E42.js";
7
7
  export {
8
8
  truncateWrappedContent,
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
5
+ require('./chunk-WHNOR4ZU.cjs');
6
+ require('./chunk-UQOBUJIQ.cjs');
7
+
8
+
9
+
10
+ exports.truncateWrappedContent = _chunkGZPN7RGHcjs.truncateWrappedContent; exports.wrapContent = _chunkGZPN7RGHcjs.wrapContent;
package/dist/types.d.ts CHANGED
@@ -103,3 +103,6 @@ export type ZuiType<Output = any, Input = Output> = {
103
103
  readonly _output: Output;
104
104
  readonly _input: Input;
105
105
  };
106
+ export type Serializable<J = unknown> = {
107
+ toJSON(): J;
108
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-IH2WQFO5.js";
3
+ } from "./chunk-EE6NVDID.js";
4
4
  import "./chunk-JKVVQN2P.js";
5
5
  import "./chunk-JQBT7UWN.js";
6
- import "./chunk-4MNIJGK6.js";
6
+ import "./chunk-ZORRILUV.js";
7
7
  import "./chunk-7WRN4E42.js";
8
8
  export {
9
9
  getTypings
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk4L6D2A6Ocjs = require('./chunk-4L6D2A6O.cjs');
3
+ var _chunkFZJHYLM2cjs = require('./chunk-FZJHYLM2.cjs');
4
4
  require('./chunk-JDABP4SD.cjs');
5
5
  require('./chunk-IKSIOIIP.cjs');
6
- require('./chunk-276Q6EWP.cjs');
6
+ require('./chunk-WHNOR4ZU.cjs');
7
7
  require('./chunk-UQOBUJIQ.cjs');
8
8
 
9
9
 
10
- exports.getTypings = _chunk4L6D2A6Ocjs.getTypings;
10
+ exports.getTypings = _chunkFZJHYLM2cjs.getTypings;
@@ -0,0 +1,39 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
20
+ require('./chunk-UQOBUJIQ.cjs');
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ exports.Identifier = _chunkWHNOR4ZUcjs.Identifier; exports.Tokens = _chunkWHNOR4ZUcjs.Tokens; exports.awaitObject = _chunkWHNOR4ZUcjs.awaitObject; exports.convertObjectToZuiLiterals = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals; exports.escapeString = _chunkWHNOR4ZUcjs.escapeString; exports.getMultilineComment = _chunkWHNOR4ZUcjs.getMultilineComment; exports.getTokenizer = _chunkWHNOR4ZUcjs.getTokenizer; exports.init = _chunkWHNOR4ZUcjs.init; exports.isJsonSchema = _chunkWHNOR4ZUcjs.isJsonSchema; exports.isValidIdentifier = _chunkWHNOR4ZUcjs.isValidIdentifier; exports.isValidMessageName = _chunkWHNOR4ZUcjs.isValidMessageName; exports.isValidSchema = _chunkWHNOR4ZUcjs.isValidSchema; exports.isZuiSchema = _chunkWHNOR4ZUcjs.isZuiSchema; exports.stripInvalidIdentifiers = _chunkWHNOR4ZUcjs.stripInvalidIdentifiers; exports.toPropertyKey = _chunkWHNOR4ZUcjs.toPropertyKey; exports.toValidFunctionName = _chunkWHNOR4ZUcjs.toValidFunctionName; exports.toValidObjectName = _chunkWHNOR4ZUcjs.toValidObjectName;
@@ -16,7 +16,7 @@ import {
16
16
  toPropertyKey,
17
17
  toValidFunctionName,
18
18
  toValidObjectName
19
- } from "./chunk-4MNIJGK6.js";
19
+ } from "./chunk-ZORRILUV.js";
20
20
  import "./chunk-7WRN4E42.js";
21
21
  export {
22
22
  Identifier,