@agentforge/core 0.16.34 → 0.16.36
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.cjs +74 -271
- package/dist/index.d.cts +9 -320
- package/dist/index.d.ts +9 -320
- package/dist/index.js +74 -271
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z, ZodTypeAny, output, ZodType, ZodTypeDef } from 'zod';
|
|
2
|
+
import * as _langchain_core_tools from '@langchain/core/tools';
|
|
2
3
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
4
|
import * as _langchain_langgraph from '@langchain/langgraph';
|
|
4
5
|
import { AnnotationRoot, BaseChannel, StateDefinition, UpdateType, StateGraph, END, MemorySaver, BaseCheckpointSaver, CheckpointTuple } from '@langchain/langgraph';
|
|
@@ -1146,6 +1147,8 @@ declare class ToolBuilder<TInput = unknown, TOutput = unknown> {
|
|
|
1146
1147
|
*/
|
|
1147
1148
|
declare function toolBuilder(): ToolBuilder;
|
|
1148
1149
|
|
|
1150
|
+
type RegistryTool = Tool<unknown, unknown>;
|
|
1151
|
+
|
|
1149
1152
|
type RegistryEventHandler<TData = unknown> = (data: TData) => void;
|
|
1150
1153
|
|
|
1151
1154
|
interface RegistryPromptOptions {
|
|
@@ -1159,355 +1162,41 @@ interface RegistryPromptOptions {
|
|
|
1159
1162
|
minimal?: boolean;
|
|
1160
1163
|
}
|
|
1161
1164
|
|
|
1162
|
-
/**
|
|
1163
|
-
* Tool Registry
|
|
1164
|
-
*
|
|
1165
|
-
* Central registry for managing and querying tools.
|
|
1166
|
-
* Provides CRUD operations, querying, and event notifications.
|
|
1167
|
-
*
|
|
1168
|
-
* @example
|
|
1169
|
-
* ```ts
|
|
1170
|
-
* const registry = new ToolRegistry();
|
|
1171
|
-
*
|
|
1172
|
-
* registry.register(readFileTool);
|
|
1173
|
-
* registry.register(writeFileTool);
|
|
1174
|
-
*
|
|
1175
|
-
* const fileTool = registry.get('read-file');
|
|
1176
|
-
* const fileTools = registry.getByCategory(ToolCategory.FILE_SYSTEM);
|
|
1177
|
-
* ```
|
|
1178
|
-
*/
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* Registry events
|
|
1182
|
-
*/
|
|
1183
1165
|
declare enum RegistryEvent {
|
|
1184
1166
|
TOOL_REGISTERED = "tool:registered",
|
|
1185
1167
|
TOOL_REMOVED = "tool:removed",
|
|
1186
1168
|
TOOL_UPDATED = "tool:updated",
|
|
1187
1169
|
REGISTRY_CLEARED = "registry:cleared"
|
|
1188
1170
|
}
|
|
1189
|
-
/**
|
|
1190
|
-
* Event handler type
|
|
1191
|
-
*/
|
|
1192
1171
|
type EventHandler = RegistryEventHandler;
|
|
1193
|
-
type RegisterManyTool = Tool<never, unknown>;
|
|
1194
|
-
type RegistryTool = Tool<unknown, unknown>;
|
|
1195
|
-
/**
|
|
1196
|
-
* Options for generating tool prompts
|
|
1197
|
-
*/
|
|
1198
1172
|
interface PromptOptions extends RegistryPromptOptions {
|
|
1199
|
-
/** Include usage examples in the prompt */
|
|
1200
|
-
includeExamples?: boolean;
|
|
1201
|
-
/** Include usage notes in the prompt */
|
|
1202
|
-
includeNotes?: boolean;
|
|
1203
|
-
/** Include limitations in the prompt */
|
|
1204
|
-
includeLimitations?: boolean;
|
|
1205
|
-
/** Include tool relations in the prompt */
|
|
1206
|
-
includeRelations?: boolean;
|
|
1207
|
-
/** Group tools by category */
|
|
1208
|
-
groupByCategory?: boolean;
|
|
1209
|
-
/** Filter by specific categories */
|
|
1210
|
-
categories?: ToolCategory[];
|
|
1211
|
-
/** Maximum number of examples to include per tool */
|
|
1212
|
-
maxExamplesPerTool?: number;
|
|
1213
|
-
/**
|
|
1214
|
-
* Minimal mode - only supplementary context, not full definitions
|
|
1215
|
-
*
|
|
1216
|
-
* Use this when tool definitions are sent via API (OpenAI, Anthropic, etc.)
|
|
1217
|
-
*
|
|
1218
|
-
* When true:
|
|
1219
|
-
* - Excludes basic tool name/description/parameters
|
|
1220
|
-
* - Includes only relations, examples, notes, limitations
|
|
1221
|
-
* - Tool names are used as headers for matching
|
|
1222
|
-
*
|
|
1223
|
-
* When false (default):
|
|
1224
|
-
* - Includes full tool definitions (current behavior)
|
|
1225
|
-
* - Backward compatible
|
|
1226
|
-
*/
|
|
1227
|
-
minimal?: boolean;
|
|
1228
1173
|
}
|
|
1229
|
-
|
|
1230
|
-
* Tool Registry - Central registry for managing tools
|
|
1231
|
-
*
|
|
1232
|
-
* Features:
|
|
1233
|
-
* - CRUD operations (register, get, remove, update)
|
|
1234
|
-
* - Query operations (by category, tag, search)
|
|
1235
|
-
* - Bulk operations (registerMany, clear)
|
|
1236
|
-
* - Event system for observability
|
|
1237
|
-
*
|
|
1238
|
-
* @example
|
|
1239
|
-
* ```ts
|
|
1240
|
-
* const registry = new ToolRegistry();
|
|
1241
|
-
*
|
|
1242
|
-
* // Register tools
|
|
1243
|
-
* registry.register(myTool);
|
|
1244
|
-
* registry.registerMany([tool1, tool2, tool3]);
|
|
1245
|
-
*
|
|
1246
|
-
* // Query tools
|
|
1247
|
-
* const tool = registry.get('my-tool');
|
|
1248
|
-
* const fileTools = registry.getByCategory(ToolCategory.FILE_SYSTEM);
|
|
1249
|
-
* const searchResults = registry.search('file');
|
|
1250
|
-
*
|
|
1251
|
-
* // Listen to events
|
|
1252
|
-
* registry.on(RegistryEvent.TOOL_REGISTERED, (tool) => {
|
|
1253
|
-
* console.log('Tool registered:', tool.metadata.name);
|
|
1254
|
-
* });
|
|
1255
|
-
* ```
|
|
1256
|
-
*/
|
|
1174
|
+
|
|
1257
1175
|
declare class ToolRegistry {
|
|
1258
1176
|
private tools;
|
|
1259
1177
|
private eventHandlers;
|
|
1260
1178
|
private readonly mutationEvents;
|
|
1261
1179
|
private readonly emitMutation;
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
* @param tool - The tool to register
|
|
1266
|
-
* @throws Error if a tool with the same name already exists
|
|
1267
|
-
*
|
|
1268
|
-
* @example
|
|
1269
|
-
* ```ts
|
|
1270
|
-
* registry.register(readFileTool);
|
|
1271
|
-
* ```
|
|
1272
|
-
*/
|
|
1180
|
+
private readonly mutations;
|
|
1181
|
+
private readonly queries;
|
|
1182
|
+
constructor();
|
|
1273
1183
|
register<TInput, TOutput>(tool: Tool<TInput, TOutput>): void;
|
|
1274
|
-
/**
|
|
1275
|
-
* Get a tool by name
|
|
1276
|
-
*
|
|
1277
|
-
* @param name - The tool name
|
|
1278
|
-
* @returns The tool, or undefined if not found
|
|
1279
|
-
*
|
|
1280
|
-
* @example
|
|
1281
|
-
* ```ts
|
|
1282
|
-
* const tool = registry.get('read-file');
|
|
1283
|
-
* if (tool) {
|
|
1284
|
-
* const result = await tool.execute({ path: './file.txt' });
|
|
1285
|
-
* }
|
|
1286
|
-
* ```
|
|
1287
|
-
*/
|
|
1288
1184
|
get(name: string): RegistryTool | undefined;
|
|
1289
|
-
/**
|
|
1290
|
-
* Check if a tool exists in the registry
|
|
1291
|
-
*
|
|
1292
|
-
* @param name - The tool name
|
|
1293
|
-
* @returns True if the tool exists
|
|
1294
|
-
*
|
|
1295
|
-
* @example
|
|
1296
|
-
* ```ts
|
|
1297
|
-
* if (registry.has('read-file')) {
|
|
1298
|
-
* console.log('Tool exists!');
|
|
1299
|
-
* }
|
|
1300
|
-
* ```
|
|
1301
|
-
*/
|
|
1302
1185
|
has(name: string): boolean;
|
|
1303
|
-
/**
|
|
1304
|
-
* Remove a tool from the registry
|
|
1305
|
-
*
|
|
1306
|
-
* @param name - The tool name
|
|
1307
|
-
* @returns True if the tool was removed, false if it didn't exist
|
|
1308
|
-
*
|
|
1309
|
-
* @example
|
|
1310
|
-
* ```ts
|
|
1311
|
-
* const removed = registry.remove('read-file');
|
|
1312
|
-
* console.log(removed ? 'Removed' : 'Not found');
|
|
1313
|
-
* ```
|
|
1314
|
-
*/
|
|
1315
1186
|
remove(name: string): boolean;
|
|
1316
|
-
/**
|
|
1317
|
-
* Update an existing tool
|
|
1318
|
-
*
|
|
1319
|
-
* @param name - The tool name
|
|
1320
|
-
* @param tool - The new tool definition
|
|
1321
|
-
* @returns True if updated, false if the tool didn't exist
|
|
1322
|
-
* @throws Error if the tool's metadata.name doesn't match the name parameter
|
|
1323
|
-
*
|
|
1324
|
-
* @example
|
|
1325
|
-
* ```ts
|
|
1326
|
-
* const updated = registry.update('read-file', newReadFileTool);
|
|
1327
|
-
* ```
|
|
1328
|
-
*/
|
|
1329
1187
|
update<TInput, TOutput>(name: string, tool: Tool<TInput, TOutput>): boolean;
|
|
1330
|
-
/**
|
|
1331
|
-
* Get all registered tools
|
|
1332
|
-
*
|
|
1333
|
-
* @returns Array of all tools
|
|
1334
|
-
*
|
|
1335
|
-
* @example
|
|
1336
|
-
* ```ts
|
|
1337
|
-
* const allTools = registry.getAll();
|
|
1338
|
-
* console.log(`Total tools: ${allTools.length}`);
|
|
1339
|
-
* ```
|
|
1340
|
-
*/
|
|
1341
1188
|
getAll(): RegistryTool[];
|
|
1342
|
-
/**
|
|
1343
|
-
* Get tools by category
|
|
1344
|
-
*
|
|
1345
|
-
* @param category - The tool category
|
|
1346
|
-
* @returns Array of tools in the category
|
|
1347
|
-
*
|
|
1348
|
-
* @example
|
|
1349
|
-
* ```ts
|
|
1350
|
-
* const fileTools = registry.getByCategory(ToolCategory.FILE_SYSTEM);
|
|
1351
|
-
* ```
|
|
1352
|
-
*/
|
|
1353
1189
|
getByCategory(category: ToolCategory): RegistryTool[];
|
|
1354
|
-
/**
|
|
1355
|
-
* Get tools by tag
|
|
1356
|
-
*
|
|
1357
|
-
* @param tag - The tag to search for
|
|
1358
|
-
* @returns Array of tools with the tag
|
|
1359
|
-
*
|
|
1360
|
-
* @example
|
|
1361
|
-
* ```ts
|
|
1362
|
-
* const fileTools = registry.getByTag('file');
|
|
1363
|
-
* ```
|
|
1364
|
-
*/
|
|
1365
1190
|
getByTag(tag: string): RegistryTool[];
|
|
1366
|
-
/**
|
|
1367
|
-
* Search tools by name or description
|
|
1368
|
-
*
|
|
1369
|
-
* Case-insensitive search across tool names, display names, and descriptions.
|
|
1370
|
-
*
|
|
1371
|
-
* @param query - The search query
|
|
1372
|
-
* @returns Array of matching tools
|
|
1373
|
-
*
|
|
1374
|
-
* @example
|
|
1375
|
-
* ```ts
|
|
1376
|
-
* const results = registry.search('file');
|
|
1377
|
-
* // Returns tools with 'file' in name or description
|
|
1378
|
-
* ```
|
|
1379
|
-
*/
|
|
1380
1191
|
search(query: string): RegistryTool[];
|
|
1381
|
-
|
|
1382
|
-
* Register multiple tools at once
|
|
1383
|
-
*
|
|
1384
|
-
* @param tools - Iterable of tools to register
|
|
1385
|
-
* @throws Error if any tool name conflicts with existing tools
|
|
1386
|
-
*
|
|
1387
|
-
* @example
|
|
1388
|
-
* ```ts
|
|
1389
|
-
* registry.registerMany([tool1, tool2, tool3]);
|
|
1390
|
-
* ```
|
|
1391
|
-
*/
|
|
1392
|
-
registerMany(tools: Iterable<RegisterManyTool>): void;
|
|
1393
|
-
/**
|
|
1394
|
-
* Clear all tools from the registry
|
|
1395
|
-
*
|
|
1396
|
-
* @example
|
|
1397
|
-
* ```ts
|
|
1398
|
-
* registry.clear();
|
|
1399
|
-
* console.log(registry.size()); // 0
|
|
1400
|
-
* ```
|
|
1401
|
-
*/
|
|
1192
|
+
registerMany(tools: Iterable<Tool<never, unknown>>): void;
|
|
1402
1193
|
clear(): void;
|
|
1403
|
-
/**
|
|
1404
|
-
* Get the number of registered tools
|
|
1405
|
-
*
|
|
1406
|
-
* @returns Number of tools in the registry
|
|
1407
|
-
*
|
|
1408
|
-
* @example
|
|
1409
|
-
* ```ts
|
|
1410
|
-
* console.log(`Registry has ${registry.size()} tools`);
|
|
1411
|
-
* ```
|
|
1412
|
-
*/
|
|
1413
1194
|
size(): number;
|
|
1414
|
-
/**
|
|
1415
|
-
* Get all tool names
|
|
1416
|
-
*
|
|
1417
|
-
* @returns Array of tool names
|
|
1418
|
-
*
|
|
1419
|
-
* @example
|
|
1420
|
-
* ```ts
|
|
1421
|
-
* const names = registry.getNames();
|
|
1422
|
-
* console.log('Available tools:', names.join(', '));
|
|
1423
|
-
* ```
|
|
1424
|
-
*/
|
|
1425
1195
|
getNames(): string[];
|
|
1426
|
-
/**
|
|
1427
|
-
* Register an event handler
|
|
1428
|
-
*
|
|
1429
|
-
* @param event - The event to listen for
|
|
1430
|
-
* @param handler - The handler function
|
|
1431
|
-
*
|
|
1432
|
-
* @example
|
|
1433
|
-
* ```ts
|
|
1434
|
-
* registry.on(RegistryEvent.TOOL_REGISTERED, (tool) => {
|
|
1435
|
-
* console.log('New tool:', tool.metadata.name);
|
|
1436
|
-
* });
|
|
1437
|
-
* ```
|
|
1438
|
-
*/
|
|
1439
1196
|
on(event: RegistryEvent, handler: EventHandler): void;
|
|
1440
|
-
/**
|
|
1441
|
-
* Unregister an event handler
|
|
1442
|
-
*
|
|
1443
|
-
* @param event - The event to stop listening for
|
|
1444
|
-
* @param handler - The handler function to remove
|
|
1445
|
-
*
|
|
1446
|
-
* @example
|
|
1447
|
-
* ```ts
|
|
1448
|
-
* const handler = (tool) => console.log(tool);
|
|
1449
|
-
* registry.on(RegistryEvent.TOOL_REGISTERED, handler);
|
|
1450
|
-
* registry.off(RegistryEvent.TOOL_REGISTERED, handler);
|
|
1451
|
-
* ```
|
|
1452
|
-
*/
|
|
1453
1197
|
off(event: RegistryEvent, handler: EventHandler): void;
|
|
1454
|
-
/**
|
|
1455
|
-
* Emit an event to all registered handlers
|
|
1456
|
-
*
|
|
1457
|
-
* @param event - The event to emit
|
|
1458
|
-
* @param data - The event data
|
|
1459
|
-
* @private
|
|
1460
|
-
*/
|
|
1461
1198
|
private emit;
|
|
1462
|
-
|
|
1463
|
-
* Convert all registered tools to LangChain format
|
|
1464
|
-
*
|
|
1465
|
-
* This allows the entire registry to be used with LangChain agents.
|
|
1466
|
-
*
|
|
1467
|
-
* @returns Array of LangChain DynamicStructuredTools
|
|
1468
|
-
*
|
|
1469
|
-
* @example
|
|
1470
|
-
* ```ts
|
|
1471
|
-
* const registry = new ToolRegistry();
|
|
1472
|
-
* registry.registerMany([tool1, tool2, tool3]);
|
|
1473
|
-
*
|
|
1474
|
-
* const langchainTools = registry.toLangChainTools();
|
|
1475
|
-
*
|
|
1476
|
-
* const agent = createAgent({
|
|
1477
|
-
* model: new ChatOpenAI(),
|
|
1478
|
-
* tools: langchainTools,
|
|
1479
|
-
* });
|
|
1480
|
-
* ```
|
|
1481
|
-
*/
|
|
1482
|
-
toLangChainTools(): DynamicStructuredTool[];
|
|
1483
|
-
/**
|
|
1484
|
-
* Generate a formatted prompt describing all tools
|
|
1485
|
-
*
|
|
1486
|
-
* Creates a human-readable description of all tools in the registry,
|
|
1487
|
-
* suitable for inclusion in LLM prompts.
|
|
1488
|
-
*
|
|
1489
|
-
* @param options - Options for customizing the prompt
|
|
1490
|
-
* @returns Formatted prompt string
|
|
1491
|
-
*
|
|
1492
|
-
* @example
|
|
1493
|
-
* ```ts
|
|
1494
|
-
* const prompt = registry.generatePrompt({
|
|
1495
|
-
* includeExamples: true,
|
|
1496
|
-
* groupByCategory: true,
|
|
1497
|
-
* maxExamplesPerTool: 2,
|
|
1498
|
-
* });
|
|
1499
|
-
*
|
|
1500
|
-
* console.log(prompt);
|
|
1501
|
-
* // Available Tools:
|
|
1502
|
-
* //
|
|
1503
|
-
* // FILE SYSTEM TOOLS:
|
|
1504
|
-
* // - read-file: Read a file from the file system
|
|
1505
|
-
* // Parameters: path (string)
|
|
1506
|
-
* // Example: Read a text file
|
|
1507
|
-
* // Input: { "path": "./README.md" }
|
|
1508
|
-
* // ...
|
|
1509
|
-
* ```
|
|
1510
|
-
*/
|
|
1199
|
+
toLangChainTools(): _langchain_core_tools.DynamicStructuredTool<_langchain_core_tools.ToolSchemaBase, any, any, any, string>[];
|
|
1511
1200
|
generatePrompt(options?: PromptOptions): string;
|
|
1512
1201
|
}
|
|
1513
1202
|
|