@agentforge/core 0.16.47 → 0.16.49

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.
package/dist/index.d.cts CHANGED
@@ -6,349 +6,68 @@ import { AnnotationRoot, BaseChannel, StateDefinition, UpdateType, StateGraph, E
6
6
  import { RunnableConfig } from '@langchain/core/runnables';
7
7
 
8
8
  /**
9
- * Tool System Types
10
- *
11
- * Core type definitions for the AgentForge tool system.
12
- * These types define the structure and metadata for tools.
13
- */
14
-
15
- /**
16
- * ToolCategory - Categories for organizing tools
17
- *
18
- * Why use an enum?
19
- * - Type safety: Can't use invalid categories
20
- * - Autocomplete: IDE suggests valid options
21
- * - Consistency: Everyone uses the same category names
22
- *
23
- * Example:
24
- * ```ts
25
- * const tool = { category: ToolCategory.FILE_SYSTEM };
26
- * ```
9
+ * Categories for organizing tools.
27
10
  */
28
11
  declare enum ToolCategory {
29
- /**
30
- * Tools for file system operations
31
- * Examples: read-file, write-file, list-directory
32
- */
33
12
  FILE_SYSTEM = "file-system",
34
- /**
35
- * Tools for web/HTTP operations
36
- * Examples: http-request, web-scrape, download-file
37
- */
38
13
  WEB = "web",
39
- /**
40
- * Tools for code operations
41
- * Examples: execute-code, analyze-syntax, format-code
42
- */
43
14
  CODE = "code",
44
- /**
45
- * Tools for database operations
46
- * Examples: query-database, insert-record, update-record
47
- */
48
15
  DATABASE = "database",
49
- /**
50
- * Tools for API integrations
51
- * Examples: github-api, slack-api, stripe-api
52
- */
53
16
  API = "api",
54
- /**
55
- * General utility tools
56
- * Examples: calculate, format-date, generate-uuid
57
- */
58
17
  UTILITY = "utility",
59
- /**
60
- * Custom/user-defined tools
61
- * Use this for tools that don't fit other categories
62
- */
63
18
  CUSTOM = "custom",
64
- /**
65
- * Tools for Agent Skills activation and resource loading
66
- * Examples: activate-skill, read-skill-resource
67
- */
68
19
  SKILLS = "skills"
69
20
  }
21
+
70
22
  /**
71
- * ToolExample - Example usage of a tool
72
- *
73
- * Why examples?
74
- * - Help LLMs understand how to use the tool
75
- * - Provide documentation for developers
76
- * - Enable few-shot learning in prompts
77
- *
78
- * Example:
79
- * ```ts
80
- * const example: ToolExample = {
81
- * description: 'Read a text file',
82
- * input: { path: './README.md' },
83
- * output: '# My Project\n\nWelcome...',
84
- * explanation: 'Reads the file and returns its contents as a string'
85
- * };
86
- * ```
23
+ * Example usage of a tool to aid documentation and prompt construction.
87
24
  */
88
25
  interface ToolExample {
89
- /**
90
- * What this example demonstrates
91
- * Should be concise and clear
92
- */
93
26
  description: string;
94
- /**
95
- * Example input parameters
96
- * Must match the tool's schema
97
- */
98
27
  input: Record<string, unknown>;
99
- /**
100
- * Expected output (optional)
101
- * Helps users understand what to expect
102
- */
103
28
  output?: unknown;
104
- /**
105
- * Additional explanation (optional)
106
- * Why this example works, edge cases, etc.
107
- */
108
29
  explanation?: string;
109
30
  }
31
+
110
32
  /**
111
- * ToolRelations - Defines relationships between tools
112
- *
113
- * Helps LLMs understand tool workflows and dependencies.
114
- *
115
- * Why tool relations?
116
- * - Express dependencies: "Must call tool X before tool Y"
117
- * - Suggest workflows: "After X, consider calling Y"
118
- * - Prevent conflicts: "Don't use X and Y together"
119
- * - Guide LLM decisions: Better tool selection and ordering
120
- *
121
- * Example:
122
- * ```ts
123
- * const relations: ToolRelations = {
124
- * requires: ['view-file'], // Must call this first
125
- * suggests: ['run-tests'], // Often used together
126
- * conflicts: ['delete-file'], // Don't use together
127
- * follows: ['search-codebase'], // Typically called after
128
- * precedes: ['edit-file'] // Typically called before
129
- * };
130
- * ```
33
+ * Relationships between tools to guide ordering and compatibility.
131
34
  */
132
35
  interface ToolRelations {
133
- /**
134
- * Tools that should be called before this tool
135
- *
136
- * Example: 'edit-file' requires 'view-file' to be called first
137
- * to ensure you know the file contents before editing.
138
- */
139
36
  requires?: string[];
140
- /**
141
- * Tools that work well with this tool
142
- *
143
- * Example: 'edit-file' suggests 'run-tests' to verify changes.
144
- */
145
37
  suggests?: string[];
146
- /**
147
- * Tools that conflict with this tool
148
- *
149
- * Example: 'create-file' conflicts with 'delete-file' on the same path.
150
- */
151
38
  conflicts?: string[];
152
- /**
153
- * Tools this typically follows in a workflow
154
- *
155
- * Example: 'edit-file' typically follows 'view-file' or 'search-codebase'.
156
- */
157
39
  follows?: string[];
158
- /**
159
- * Tools this typically precedes in a workflow
160
- *
161
- * Example: 'view-file' typically precedes 'edit-file'.
162
- */
163
40
  precedes?: string[];
164
41
  }
42
+
165
43
  /**
166
- * ToolMetadata - Rich metadata for a tool
167
- *
168
- * Why so much metadata?
169
- * - Better LLM understanding: More context = better tool selection
170
- * - Better developer experience: Clear documentation
171
- * - Better discoverability: Search by tags, categories
172
- * - Better maintenance: Version tracking, deprecation warnings
173
- *
174
- * Example:
175
- * ```ts
176
- * const metadata: ToolMetadata = {
177
- * name: 'read-file',
178
- * displayName: 'Read File',
179
- * description: 'Read contents of a file from the file system',
180
- * category: ToolCategory.FILE_SYSTEM,
181
- * tags: ['file', 'read', 'io'],
182
- * examples: [{ description: 'Read README', input: { path: './README.md' } }],
183
- * usageNotes: 'Paths are relative to current working directory',
184
- * limitations: ['Cannot read files larger than 10MB'],
185
- * version: '1.0.0',
186
- * author: 'AgentForge'
187
- * };
188
- * ```
44
+ * Rich metadata describing a tool, its examples, and its lifecycle state.
189
45
  */
190
46
  interface ToolMetadata {
191
- /**
192
- * Unique identifier for the tool
193
- * Must be kebab-case (lowercase with hyphens)
194
- * Examples: 'read-file', 'http-request', 'query-database'
195
- */
196
47
  name: string;
197
- /**
198
- * Clear description of what the tool does
199
- * Should be 1-2 sentences, written for LLMs to understand
200
- * Example: 'Read the contents of a file from the file system'
201
- */
202
48
  description: string;
203
- /**
204
- * Primary category for this tool
205
- * Used for grouping and filtering
206
- */
207
49
  category: ToolCategory;
208
- /**
209
- * Human-readable display name (optional)
210
- * Example: 'Read File' instead of 'read-file'
211
- */
212
50
  displayName?: string;
213
- /**
214
- * Tags for search and filtering (optional)
215
- * Example: ['file', 'read', 'io', 'filesystem']
216
- */
217
51
  tags?: string[];
218
- /**
219
- * Usage examples (optional but highly recommended)
220
- * Helps LLMs understand how to use the tool
221
- */
222
52
  examples?: ToolExample[];
223
- /**
224
- * Additional usage notes (optional)
225
- * Important details about how to use the tool
226
- * Example: 'Paths are relative to the current working directory'
227
- */
228
53
  usageNotes?: string;
229
- /**
230
- * Known limitations (optional)
231
- * What the tool cannot do
232
- * Example: ['Cannot read files larger than 10MB', 'Requires read permissions']
233
- */
234
54
  limitations?: string[];
235
- /**
236
- * Tool version (optional)
237
- * Semantic versioning recommended
238
- * Example: '1.0.0'
239
- */
240
55
  version?: string;
241
- /**
242
- * Tool author (optional)
243
- * Who created/maintains this tool
244
- * Example: 'AgentForge Team'
245
- */
246
56
  author?: string;
247
- /**
248
- * Deprecation flag (optional)
249
- * Set to true if this tool should no longer be used
250
- */
251
57
  deprecated?: boolean;
252
- /**
253
- * Replacement tool name (optional)
254
- * If deprecated, what tool should be used instead?
255
- * Example: 'read-file-v2'
256
- */
257
58
  replacedBy?: string;
258
- /**
259
- * Tool relations (optional)
260
- * Defines relationships with other tools
261
- *
262
- * Helps LLMs understand:
263
- * - Which tools should be called before/after this tool
264
- * - Which tools work well together
265
- * - Which tools conflict with this tool
266
- *
267
- * Example:
268
- * ```ts
269
- * relations: {
270
- * requires: ['view-file'],
271
- * suggests: ['run-tests'],
272
- * follows: ['search-codebase']
273
- * }
274
- * ```
275
- */
276
59
  relations?: ToolRelations;
277
60
  }
61
+
278
62
  /**
279
- * Tool - Complete tool definition
280
- *
281
- * This is the main interface that combines:
282
- * - Metadata: What the tool is and how to use it
283
- * - Schema: What inputs it accepts (validated with Zod)
284
- * - Execute: The actual implementation
285
- *
286
- * Why generic types?
287
- * - TInput: Type of the input parameters (inferred from schema)
288
- * - TOutput: Type of the return value
289
- * - This gives us full type safety!
290
- *
291
- * Example:
292
- * ```ts
293
- * const readFileTool: Tool<{ path: string }, string> = {
294
- * metadata: { name: 'read-file', ... },
295
- * schema: z.object({ path: z.string() }),
296
- * execute: async ({ path }) => {
297
- * // Implementation here
298
- * return fileContents;
299
- * }
300
- * };
301
- * ```
63
+ * Complete tool contract combining metadata, input schema, and invocation API.
302
64
  */
303
65
  interface Tool<TInput = unknown, TOutput = unknown> {
304
- /**
305
- * Rich metadata about the tool
306
- */
307
66
  metadata: ToolMetadata;
308
- /**
309
- * Zod schema for input validation
310
- *
311
- * Why Zod?
312
- * - Runtime validation: Catch errors before execution
313
- * - Type inference: TypeScript types from schema
314
- * - Great error messages: Clear validation errors
315
- * - JSON Schema conversion: For LangChain integration
316
- */
317
67
  schema: z.ZodSchema<TInput>;
318
- /**
319
- * Tool implementation (primary method)
320
- *
321
- * Why async?
322
- * - Most tools do I/O (files, network, database)
323
- * - Async is more flexible (can handle both sync and async)
324
- *
325
- * The input is automatically validated against the schema
326
- * before this function is called.
327
- *
328
- * This is the industry standard method name used by LangChain.
329
- *
330
- * @example
331
- * ```ts
332
- * const result = await tool.invoke({ input: 'hello' });
333
- * ```
334
- */
335
68
  invoke: (input: TInput) => Promise<TOutput>;
336
69
  /**
337
- * Deprecated alias for invoke()
338
- *
339
- * @deprecated Use invoke() instead. This method will be removed in v1.0.0.
340
- *
341
- * Both methods do exactly the same thing, but invoke() is the industry
342
- * standard used by LangChain and should be preferred.
343
- *
344
- * @example
345
- * ```ts
346
- * // ❌ Deprecated (still works, but will be removed in v1.0.0):
347
- * const result1 = await tool.execute({ input: 'hello' });
348
- *
349
- * // ✅ Preferred (industry standard):
350
- * const result2 = await tool.invoke({ input: 'hello' });
351
- * ```
70
+ * @deprecated Use `invoke` instead.
352
71
  */
353
72
  execute?: (input: TInput) => Promise<TOutput>;
354
73
  }
@@ -1009,10 +728,6 @@ declare class ToolRegistry {
1009
728
  generatePrompt(options?: PromptOptions): string;
1010
729
  }
1011
730
 
1012
- /**
1013
- * Tool Executor - Async tool execution with resource management
1014
- * @module tools/executor
1015
- */
1016
731
  type Priority$1 = 'low' | 'normal' | 'high' | 'critical';
1017
732
  type BackoffStrategy$1 = 'linear' | 'exponential' | 'fixed';
1018
733
  interface RetryPolicy {
@@ -1022,6 +737,14 @@ interface RetryPolicy {
1022
737
  maxDelay?: number;
1023
738
  retryableErrors?: string[];
1024
739
  }
740
+ interface ExecutableTool<TInput = unknown, TOutput = unknown> {
741
+ name?: string;
742
+ metadata?: {
743
+ name?: string;
744
+ };
745
+ invoke?: (input: TInput) => Promise<TOutput>;
746
+ execute?: (input: TInput) => Promise<TOutput>;
747
+ }
1025
748
  interface ToolExecutorConfig {
1026
749
  maxConcurrent?: number;
1027
750
  timeout?: number;
@@ -1044,13 +767,12 @@ interface ExecutionMetrics {
1044
767
  averageDuration: number;
1045
768
  byPriority: Record<Priority$1, number>;
1046
769
  }
1047
- interface ExecutableTool<TInput = unknown, TOutput = unknown> {
1048
- metadata?: {
1049
- name?: string;
1050
- };
1051
- invoke?: (input: TInput) => Promise<TOutput>;
1052
- execute?: (input: TInput) => Promise<TOutput>;
1053
- }
770
+
771
+ /**
772
+ * Tool Executor - Async tool execution with resource management
773
+ * @module tools/executor
774
+ */
775
+
1054
776
  /**
1055
777
  * Create a tool executor with resource management
1056
778
  */