@jackchen_me/open-multi-agent 0.1.0

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 (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +280 -0
  3. package/dist/agent/agent.d.ts +121 -0
  4. package/dist/agent/agent.d.ts.map +1 -0
  5. package/dist/agent/agent.js +294 -0
  6. package/dist/agent/agent.js.map +1 -0
  7. package/dist/agent/pool.d.ts +128 -0
  8. package/dist/agent/pool.d.ts.map +1 -0
  9. package/dist/agent/pool.js +236 -0
  10. package/dist/agent/pool.js.map +1 -0
  11. package/dist/agent/runner.d.ts +120 -0
  12. package/dist/agent/runner.d.ts.map +1 -0
  13. package/dist/agent/runner.js +274 -0
  14. package/dist/agent/runner.js.map +1 -0
  15. package/dist/index.d.ts +73 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +87 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/llm/adapter.d.ts +38 -0
  20. package/dist/llm/adapter.d.ts.map +1 -0
  21. package/dist/llm/adapter.js +46 -0
  22. package/dist/llm/adapter.js.map +1 -0
  23. package/dist/llm/anthropic.d.ts +56 -0
  24. package/dist/llm/anthropic.d.ts.map +1 -0
  25. package/dist/llm/anthropic.js +307 -0
  26. package/dist/llm/anthropic.js.map +1 -0
  27. package/dist/llm/openai.d.ts +62 -0
  28. package/dist/llm/openai.d.ts.map +1 -0
  29. package/dist/llm/openai.js +424 -0
  30. package/dist/llm/openai.js.map +1 -0
  31. package/dist/memory/shared.d.ts +86 -0
  32. package/dist/memory/shared.d.ts.map +1 -0
  33. package/dist/memory/shared.js +155 -0
  34. package/dist/memory/shared.js.map +1 -0
  35. package/dist/memory/store.d.ts +64 -0
  36. package/dist/memory/store.d.ts.map +1 -0
  37. package/dist/memory/store.js +103 -0
  38. package/dist/memory/store.js.map +1 -0
  39. package/dist/orchestrator/orchestrator.d.ts +173 -0
  40. package/dist/orchestrator/orchestrator.d.ts.map +1 -0
  41. package/dist/orchestrator/orchestrator.js +698 -0
  42. package/dist/orchestrator/orchestrator.js.map +1 -0
  43. package/dist/orchestrator/scheduler.d.ts +112 -0
  44. package/dist/orchestrator/scheduler.d.ts.map +1 -0
  45. package/dist/orchestrator/scheduler.js +282 -0
  46. package/dist/orchestrator/scheduler.js.map +1 -0
  47. package/dist/task/queue.d.ts +160 -0
  48. package/dist/task/queue.d.ts.map +1 -0
  49. package/dist/task/queue.js +337 -0
  50. package/dist/task/queue.js.map +1 -0
  51. package/dist/task/task.d.ts +86 -0
  52. package/dist/task/task.d.ts.map +1 -0
  53. package/dist/task/task.js +201 -0
  54. package/dist/task/task.js.map +1 -0
  55. package/dist/team/messaging.d.ts +106 -0
  56. package/dist/team/messaging.d.ts.map +1 -0
  57. package/dist/team/messaging.js +182 -0
  58. package/dist/team/messaging.js.map +1 -0
  59. package/dist/team/team.d.ts +141 -0
  60. package/dist/team/team.d.ts.map +1 -0
  61. package/dist/team/team.js +282 -0
  62. package/dist/team/team.js.map +1 -0
  63. package/dist/tool/built-in/bash.d.ts +12 -0
  64. package/dist/tool/built-in/bash.d.ts.map +1 -0
  65. package/dist/tool/built-in/bash.js +133 -0
  66. package/dist/tool/built-in/bash.js.map +1 -0
  67. package/dist/tool/built-in/file-edit.d.ts +14 -0
  68. package/dist/tool/built-in/file-edit.d.ts.map +1 -0
  69. package/dist/tool/built-in/file-edit.js +130 -0
  70. package/dist/tool/built-in/file-edit.js.map +1 -0
  71. package/dist/tool/built-in/file-read.d.ts +12 -0
  72. package/dist/tool/built-in/file-read.d.ts.map +1 -0
  73. package/dist/tool/built-in/file-read.js +82 -0
  74. package/dist/tool/built-in/file-read.js.map +1 -0
  75. package/dist/tool/built-in/file-write.d.ts +11 -0
  76. package/dist/tool/built-in/file-write.d.ts.map +1 -0
  77. package/dist/tool/built-in/file-write.js +70 -0
  78. package/dist/tool/built-in/file-write.js.map +1 -0
  79. package/dist/tool/built-in/grep.d.ts +15 -0
  80. package/dist/tool/built-in/grep.d.ts.map +1 -0
  81. package/dist/tool/built-in/grep.js +287 -0
  82. package/dist/tool/built-in/grep.js.map +1 -0
  83. package/dist/tool/built-in/index.d.ts +36 -0
  84. package/dist/tool/built-in/index.d.ts.map +1 -0
  85. package/dist/tool/built-in/index.js +45 -0
  86. package/dist/tool/built-in/index.js.map +1 -0
  87. package/dist/tool/executor.d.ts +71 -0
  88. package/dist/tool/executor.d.ts.map +1 -0
  89. package/dist/tool/executor.js +116 -0
  90. package/dist/tool/executor.js.map +1 -0
  91. package/dist/tool/framework.d.ts +143 -0
  92. package/dist/tool/framework.d.ts.map +1 -0
  93. package/dist/tool/framework.js +371 -0
  94. package/dist/tool/framework.js.map +1 -0
  95. package/dist/types.d.ts +285 -0
  96. package/dist/types.d.ts.map +1 -0
  97. package/dist/types.js +8 -0
  98. package/dist/types.js.map +1 -0
  99. package/dist/utils/semaphore.d.ts +47 -0
  100. package/dist/utils/semaphore.d.ts.map +1 -0
  101. package/dist/utils/semaphore.js +85 -0
  102. package/dist/utils/semaphore.js.map +1 -0
  103. package/examples/01-single-agent.ts +131 -0
  104. package/examples/02-team-collaboration.ts +167 -0
  105. package/examples/03-task-pipeline.ts +201 -0
  106. package/examples/04-multi-model-team.ts +261 -0
  107. package/package.json +49 -0
  108. package/src/agent/agent.ts +364 -0
  109. package/src/agent/pool.ts +278 -0
  110. package/src/agent/runner.ts +413 -0
  111. package/src/index.ts +166 -0
  112. package/src/llm/adapter.ts +74 -0
  113. package/src/llm/anthropic.ts +388 -0
  114. package/src/llm/openai.ts +522 -0
  115. package/src/memory/shared.ts +181 -0
  116. package/src/memory/store.ts +124 -0
  117. package/src/orchestrator/orchestrator.ts +851 -0
  118. package/src/orchestrator/scheduler.ts +352 -0
  119. package/src/task/queue.ts +394 -0
  120. package/src/task/task.ts +232 -0
  121. package/src/team/messaging.ts +230 -0
  122. package/src/team/team.ts +334 -0
  123. package/src/tool/built-in/bash.ts +187 -0
  124. package/src/tool/built-in/file-edit.ts +154 -0
  125. package/src/tool/built-in/file-read.ts +105 -0
  126. package/src/tool/built-in/file-write.ts +81 -0
  127. package/src/tool/built-in/grep.ts +362 -0
  128. package/src/tool/built-in/index.ts +50 -0
  129. package/src/tool/executor.ts +178 -0
  130. package/src/tool/framework.ts +557 -0
  131. package/src/types.ts +362 -0
  132. package/src/utils/semaphore.ts +89 -0
  133. package/tsconfig.json +25 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/tool/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAO7C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAA;IACV,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;gBAEzB,QAAQ,EAAE,YAAY,EAAE,OAAO,GAAE,mBAAwB;IASrE;;;;;;;;;OASG;IACG,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC;IAsBtB;;;;;;;;OAQG;IACG,YAAY,CAChB,KAAK,EAAE,aAAa,EAAE,EACtB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAmBnC;;;;OAIG;YACW,OAAO;IAuCrB,qCAAqC;IACrC,OAAO,CAAC,WAAW;CAMpB"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Parallel tool executor with concurrency control and error isolation.
3
+ *
4
+ * Validates input via Zod schemas, enforces a maximum concurrency limit using
5
+ * a lightweight semaphore, tracks execution duration, and surfaces any
6
+ * execution errors as ToolResult objects rather than thrown exceptions.
7
+ *
8
+ * Types are imported from `../types` to ensure consistency with the rest of
9
+ * the framework.
10
+ */
11
+ import { Semaphore } from '../utils/semaphore.js';
12
+ /**
13
+ * Executes tools from a {@link ToolRegistry}, validating input against each
14
+ * tool's Zod schema and enforcing a concurrency limit for batch execution.
15
+ *
16
+ * All errors — including unknown tool names, Zod validation failures, and
17
+ * execution exceptions — are caught and returned as `ToolResult` objects with
18
+ * `isError: true` so the agent runner can forward them to the LLM.
19
+ */
20
+ export class ToolExecutor {
21
+ registry;
22
+ semaphore;
23
+ constructor(registry, options = {}) {
24
+ this.registry = registry;
25
+ this.semaphore = new Semaphore(options.maxConcurrency ?? 4);
26
+ }
27
+ // -------------------------------------------------------------------------
28
+ // Single execution
29
+ // -------------------------------------------------------------------------
30
+ /**
31
+ * Execute a single tool by name.
32
+ *
33
+ * Errors are caught and returned as a {@link ToolResult} with
34
+ * `isError: true` — this method itself never rejects.
35
+ *
36
+ * @param toolName The registered tool name.
37
+ * @param input Raw input object (before Zod validation).
38
+ * @param context Execution context forwarded to the tool.
39
+ */
40
+ async execute(toolName, input, context) {
41
+ const tool = this.registry.get(toolName);
42
+ if (tool === undefined) {
43
+ return this.errorResult(`Tool "${toolName}" is not registered in the ToolRegistry.`);
44
+ }
45
+ // Check abort before even starting
46
+ if (context.abortSignal?.aborted === true) {
47
+ return this.errorResult(`Tool "${toolName}" was aborted before execution began.`);
48
+ }
49
+ return this.runTool(tool, input, context);
50
+ }
51
+ // -------------------------------------------------------------------------
52
+ // Batch execution
53
+ // -------------------------------------------------------------------------
54
+ /**
55
+ * Execute multiple tool calls in parallel, honouring the concurrency limit.
56
+ *
57
+ * Returns a `Map` from call ID to result. Every call in `calls` is
58
+ * guaranteed to produce an entry — errors are captured as results.
59
+ *
60
+ * @param calls Array of tool calls to execute.
61
+ * @param context Shared execution context for all calls in this batch.
62
+ */
63
+ async executeBatch(calls, context) {
64
+ const results = new Map();
65
+ await Promise.all(calls.map(async (call) => {
66
+ const result = await this.semaphore.run(() => this.execute(call.name, call.input, context));
67
+ results.set(call.id, result);
68
+ }));
69
+ return results;
70
+ }
71
+ // -------------------------------------------------------------------------
72
+ // Private helpers
73
+ // -------------------------------------------------------------------------
74
+ /**
75
+ * Validate input with the tool's Zod schema, then call `execute`.
76
+ * Any synchronous or asynchronous error is caught and turned into an error
77
+ * ToolResult.
78
+ */
79
+ async runTool(
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ tool, rawInput, context) {
82
+ // --- Zod validation ---
83
+ const parseResult = tool.inputSchema.safeParse(rawInput);
84
+ if (!parseResult.success) {
85
+ const issues = parseResult.error.issues
86
+ .map((issue) => ` • ${issue.path.join('.')}: ${issue.message}`)
87
+ .join('\n');
88
+ return this.errorResult(`Invalid input for tool "${tool.name}":\n${issues}`);
89
+ }
90
+ // --- Abort check after parse (parse can be expensive for large inputs) ---
91
+ if (context.abortSignal?.aborted === true) {
92
+ return this.errorResult(`Tool "${tool.name}" was aborted before execution began.`);
93
+ }
94
+ // --- Execute ---
95
+ try {
96
+ const result = await tool.execute(parseResult.data, context);
97
+ return result;
98
+ }
99
+ catch (err) {
100
+ const message = err instanceof Error
101
+ ? err.message
102
+ : typeof err === 'string'
103
+ ? err
104
+ : JSON.stringify(err);
105
+ return this.errorResult(`Tool "${tool.name}" threw an error: ${message}`);
106
+ }
107
+ }
108
+ /** Construct an error ToolResult. */
109
+ errorResult(message) {
110
+ return {
111
+ data: message,
112
+ isError: true,
113
+ };
114
+ }
115
+ }
116
+ //# sourceMappingURL=executor.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AW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;YAC5D,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GACX,GAAG,YAAY,KAAK;gBAClB,CAAC,CAAC,GAAG,CAAC,OAAO;gBACb,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ;oBACvB,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YAC3B,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,IAAI,qBAAqB,OAAO,EAAE,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC;IAED,qCAAqC;IAC7B,WAAW,CAAC,OAAe;QACjC,OAAO;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Tool definition framework for open-multi-agent.
3
+ *
4
+ * Provides the core primitives for declaring, registering, and converting
5
+ * tools to the JSON Schema format that LLM APIs expect.
6
+ *
7
+ * Types shared with the rest of the framework (`ToolDefinition`, `ToolResult`,
8
+ * `ToolUseContext`) are imported from `../types` to ensure a single source of
9
+ * truth. This file re-exports them for the convenience of downstream callers
10
+ * who only need to import from `tool/framework`.
11
+ */
12
+ import { type ZodSchema } from 'zod';
13
+ import type { ToolDefinition, ToolResult, ToolUseContext, LLMToolDef } from '../types.js';
14
+ export type { ToolDefinition, ToolResult, ToolUseContext };
15
+ /** Minimal JSON Schema for a single property. */
16
+ export type JSONSchemaProperty = {
17
+ type: 'string';
18
+ description?: string;
19
+ enum?: string[];
20
+ } | {
21
+ type: 'number';
22
+ description?: string;
23
+ } | {
24
+ type: 'integer';
25
+ description?: string;
26
+ } | {
27
+ type: 'boolean';
28
+ description?: string;
29
+ } | {
30
+ type: 'null';
31
+ description?: string;
32
+ } | {
33
+ type: 'array';
34
+ items: JSONSchemaProperty;
35
+ description?: string;
36
+ } | {
37
+ type: 'object';
38
+ properties: Record<string, JSONSchemaProperty>;
39
+ required?: string[];
40
+ description?: string;
41
+ } | {
42
+ anyOf: JSONSchemaProperty[];
43
+ description?: string;
44
+ } | {
45
+ const: unknown;
46
+ description?: string;
47
+ } | Record<string, unknown>;
48
+ /**
49
+ * Define a typed tool. This is the single entry-point for creating tools
50
+ * that can be registered with a {@link ToolRegistry}.
51
+ *
52
+ * The returned object satisfies the {@link ToolDefinition} interface imported
53
+ * from `../types`.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const echoTool = defineTool({
58
+ * name: 'echo',
59
+ * description: 'Echo the input message back to the caller.',
60
+ * inputSchema: z.object({ message: z.string() }),
61
+ * execute: async ({ message }) => ({
62
+ * data: message,
63
+ * isError: false,
64
+ * }),
65
+ * })
66
+ * ```
67
+ */
68
+ export declare function defineTool<TInput>(config: {
69
+ name: string;
70
+ description: string;
71
+ inputSchema: ZodSchema<TInput>;
72
+ execute: (input: TInput, context: ToolUseContext) => Promise<ToolResult>;
73
+ }): ToolDefinition<TInput>;
74
+ /**
75
+ * Registry that holds a set of named tools and can produce the JSON Schema
76
+ * representation expected by LLM APIs (Anthropic, OpenAI, etc.).
77
+ */
78
+ export declare class ToolRegistry {
79
+ private readonly tools;
80
+ /**
81
+ * Add a tool to the registry. Throws if a tool with the same name has
82
+ * already been registered — prevents silent overwrites.
83
+ */
84
+ register(tool: ToolDefinition<any>): void;
85
+ /** Return a tool by name, or `undefined` if not found. */
86
+ get(name: string): ToolDefinition<any> | undefined;
87
+ /**
88
+ * Return all registered tool definitions as an array.
89
+ *
90
+ * Callers that only need names can do `registry.list().map(t => t.name)`.
91
+ * This matches the agent's `getTools()` pattern.
92
+ */
93
+ list(): ToolDefinition<any>[];
94
+ /**
95
+ * Return all registered tool definitions as an array.
96
+ * Alias for {@link list} — available for callers that prefer explicit naming.
97
+ */
98
+ getAll(): ToolDefinition<any>[];
99
+ /** Return true when a tool with the given name is registered. */
100
+ has(name: string): boolean;
101
+ /**
102
+ * Remove a tool by name.
103
+ * No-op if the tool was not registered — matches the agent's expected
104
+ * behaviour where `removeTool` is a graceful operation.
105
+ */
106
+ unregister(name: string): void;
107
+ /** Alias for {@link unregister} — available for symmetry with `register`. */
108
+ deregister(name: string): void;
109
+ /**
110
+ * Convert all registered tools to the {@link LLMToolDef} format used by LLM
111
+ * adapters. This is the primary method called by the agent runner before
112
+ * each LLM API call.
113
+ */
114
+ toToolDefs(): LLMToolDef[];
115
+ /**
116
+ * Convert all registered tools to the Anthropic-style `input_schema`
117
+ * format. Prefer {@link toToolDefs} for normal use; this method is exposed
118
+ * for callers that construct their own API payloads.
119
+ */
120
+ toLLMTools(): Array<{
121
+ name: string;
122
+ description: string;
123
+ input_schema: {
124
+ type: 'object';
125
+ properties: Record<string, JSONSchemaProperty>;
126
+ required?: string[];
127
+ };
128
+ }>;
129
+ }
130
+ /**
131
+ * Convert a Zod schema to a plain JSON Schema object suitable for inclusion
132
+ * in LLM API calls.
133
+ *
134
+ * Supported Zod types:
135
+ * z.string(), z.number(), z.boolean(), z.enum(), z.array(), z.object(),
136
+ * z.optional(), z.union(), z.literal(), z.describe(), z.nullable(),
137
+ * z.default(), z.intersection(), z.discriminatedUnion(), z.record(),
138
+ * z.tuple(), z.any(), z.unknown(), z.never(), z.effects() (transforms)
139
+ *
140
+ * Unsupported types fall back to `{}` (any) which is still valid JSON Schema.
141
+ */
142
+ export declare function zodToJsonSchema(schema: ZodSchema): Record<string, unknown>;
143
+ //# sourceMappingURL=framework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework.d.ts","sourceRoot":"","sources":["../../src/tool/framework.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,UAAU,EACX,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,cAAc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* Provides the core primitives for declaring, registering, and converting
5
+ * tools to the JSON Schema format that LLM APIs expect.
6
+ *
7
+ * Types shared with the rest of the framework (`ToolDefinition`, `ToolResult`,
8
+ * `ToolUseContext`) are imported from `../types` to ensure a single source of
9
+ * truth. This file re-exports them for the convenience of downstream callers
10
+ * who only need to import from `tool/framework`.
11
+ */
12
+ // ---------------------------------------------------------------------------
13
+ // defineTool
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Define a typed tool. This is the single entry-point for creating tools
17
+ * that can be registered with a {@link ToolRegistry}.
18
+ *
19
+ * The returned object satisfies the {@link ToolDefinition} interface imported
20
+ * from `../types`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const echoTool = defineTool({
25
+ * name: 'echo',
26
+ * description: 'Echo the input message back to the caller.',
27
+ * inputSchema: z.object({ message: z.string() }),
28
+ * execute: async ({ message }) => ({
29
+ * data: message,
30
+ * isError: false,
31
+ * }),
32
+ * })
33
+ * ```
34
+ */
35
+ export function defineTool(config) {
36
+ return {
37
+ name: config.name,
38
+ description: config.description,
39
+ inputSchema: config.inputSchema,
40
+ execute: config.execute,
41
+ };
42
+ }
43
+ // ---------------------------------------------------------------------------
44
+ // ToolRegistry
45
+ // ---------------------------------------------------------------------------
46
+ /**
47
+ * Registry that holds a set of named tools and can produce the JSON Schema
48
+ * representation expected by LLM APIs (Anthropic, OpenAI, etc.).
49
+ */
50
+ export class ToolRegistry {
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ tools = new Map();
53
+ /**
54
+ * Add a tool to the registry. Throws if a tool with the same name has
55
+ * already been registered — prevents silent overwrites.
56
+ */
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ register(tool) {
59
+ if (this.tools.has(tool.name)) {
60
+ throw new Error(`ToolRegistry: a tool named "${tool.name}" is already registered. ` +
61
+ 'Use a unique name or deregister the existing one first.');
62
+ }
63
+ this.tools.set(tool.name, tool);
64
+ }
65
+ /** Return a tool by name, or `undefined` if not found. */
66
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
+ get(name) {
68
+ return this.tools.get(name);
69
+ }
70
+ /**
71
+ * Return all registered tool definitions as an array.
72
+ *
73
+ * Callers that only need names can do `registry.list().map(t => t.name)`.
74
+ * This matches the agent's `getTools()` pattern.
75
+ */
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
+ list() {
78
+ return Array.from(this.tools.values());
79
+ }
80
+ /**
81
+ * Return all registered tool definitions as an array.
82
+ * Alias for {@link list} — available for callers that prefer explicit naming.
83
+ */
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ getAll() {
86
+ return Array.from(this.tools.values());
87
+ }
88
+ /** Return true when a tool with the given name is registered. */
89
+ has(name) {
90
+ return this.tools.has(name);
91
+ }
92
+ /**
93
+ * Remove a tool by name.
94
+ * No-op if the tool was not registered — matches the agent's expected
95
+ * behaviour where `removeTool` is a graceful operation.
96
+ */
97
+ unregister(name) {
98
+ this.tools.delete(name);
99
+ }
100
+ /** Alias for {@link unregister} — available for symmetry with `register`. */
101
+ deregister(name) {
102
+ this.tools.delete(name);
103
+ }
104
+ /**
105
+ * Convert all registered tools to the {@link LLMToolDef} format used by LLM
106
+ * adapters. This is the primary method called by the agent runner before
107
+ * each LLM API call.
108
+ */
109
+ toToolDefs() {
110
+ return Array.from(this.tools.values()).map((tool) => {
111
+ const schema = zodToJsonSchema(tool.inputSchema);
112
+ return {
113
+ name: tool.name,
114
+ description: tool.description,
115
+ inputSchema: schema,
116
+ };
117
+ });
118
+ }
119
+ /**
120
+ * Convert all registered tools to the Anthropic-style `input_schema`
121
+ * format. Prefer {@link toToolDefs} for normal use; this method is exposed
122
+ * for callers that construct their own API payloads.
123
+ */
124
+ toLLMTools() {
125
+ return Array.from(this.tools.values()).map((tool) => {
126
+ const schema = zodToJsonSchema(tool.inputSchema);
127
+ return {
128
+ name: tool.name,
129
+ description: tool.description,
130
+ input_schema: {
131
+ type: 'object',
132
+ properties: schema.properties ?? {},
133
+ ...(schema.required !== undefined
134
+ ? { required: schema.required }
135
+ : {}),
136
+ },
137
+ };
138
+ });
139
+ }
140
+ }
141
+ // ---------------------------------------------------------------------------
142
+ // zodToJsonSchema
143
+ // ---------------------------------------------------------------------------
144
+ /**
145
+ * Convert a Zod schema to a plain JSON Schema object suitable for inclusion
146
+ * in LLM API calls.
147
+ *
148
+ * Supported Zod types:
149
+ * z.string(), z.number(), z.boolean(), z.enum(), z.array(), z.object(),
150
+ * z.optional(), z.union(), z.literal(), z.describe(), z.nullable(),
151
+ * z.default(), z.intersection(), z.discriminatedUnion(), z.record(),
152
+ * z.tuple(), z.any(), z.unknown(), z.never(), z.effects() (transforms)
153
+ *
154
+ * Unsupported types fall back to `{}` (any) which is still valid JSON Schema.
155
+ */
156
+ export function zodToJsonSchema(schema) {
157
+ return convertZodType(schema);
158
+ }
159
+ // Internal recursive converter. We access Zod's internal `_def` structure
160
+ // because Zod v3 does not ship a first-class JSON Schema exporter.
161
+ function convertZodType(schema) {
162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+ const def = schema._def;
164
+ const description = def.description;
165
+ const withDesc = (result) => description !== undefined ? { ...result, description } : result;
166
+ switch (def.typeName) {
167
+ // -----------------------------------------------------------------------
168
+ // Primitives
169
+ // -----------------------------------------------------------------------
170
+ case ZodTypeName.ZodString:
171
+ return withDesc({ type: 'string' });
172
+ case ZodTypeName.ZodNumber:
173
+ return withDesc({ type: 'number' });
174
+ case ZodTypeName.ZodBigInt:
175
+ return withDesc({ type: 'integer' });
176
+ case ZodTypeName.ZodBoolean:
177
+ return withDesc({ type: 'boolean' });
178
+ case ZodTypeName.ZodNull:
179
+ return withDesc({ type: 'null' });
180
+ case ZodTypeName.ZodUndefined:
181
+ return withDesc({ type: 'null' });
182
+ case ZodTypeName.ZodDate:
183
+ return withDesc({ type: 'string', format: 'date-time' });
184
+ // -----------------------------------------------------------------------
185
+ // Literals
186
+ // -----------------------------------------------------------------------
187
+ case ZodTypeName.ZodLiteral: {
188
+ const literalDef = def;
189
+ return withDesc({ const: literalDef.value });
190
+ }
191
+ // -----------------------------------------------------------------------
192
+ // Enums
193
+ // -----------------------------------------------------------------------
194
+ case ZodTypeName.ZodEnum: {
195
+ const enumDef = def;
196
+ return withDesc({ type: 'string', enum: enumDef.values });
197
+ }
198
+ case ZodTypeName.ZodNativeEnum: {
199
+ const nativeEnumDef = def;
200
+ const values = Object.values(nativeEnumDef.values).filter((v) => typeof v === 'string' || typeof v === 'number');
201
+ return withDesc({ enum: values });
202
+ }
203
+ // -----------------------------------------------------------------------
204
+ // Arrays
205
+ // -----------------------------------------------------------------------
206
+ case ZodTypeName.ZodArray: {
207
+ const arrayDef = def;
208
+ return withDesc({
209
+ type: 'array',
210
+ items: convertZodType(arrayDef.type),
211
+ });
212
+ }
213
+ case ZodTypeName.ZodTuple: {
214
+ const tupleDef = def;
215
+ return withDesc({
216
+ type: 'array',
217
+ prefixItems: tupleDef.items.map(convertZodType),
218
+ });
219
+ }
220
+ // -----------------------------------------------------------------------
221
+ // Objects
222
+ // -----------------------------------------------------------------------
223
+ case ZodTypeName.ZodObject: {
224
+ const objectDef = def;
225
+ const properties = {};
226
+ const required = [];
227
+ for (const [key, value] of Object.entries(objectDef.shape())) {
228
+ properties[key] = convertZodType(value);
229
+ const innerDef = value._def;
230
+ const isOptional = innerDef.typeName === ZodTypeName.ZodOptional ||
231
+ innerDef.typeName === ZodTypeName.ZodDefault ||
232
+ innerDef.typeName === ZodTypeName.ZodNullable;
233
+ if (!isOptional) {
234
+ required.push(key);
235
+ }
236
+ }
237
+ const result = { type: 'object', properties };
238
+ if (required.length > 0)
239
+ result.required = required;
240
+ return withDesc(result);
241
+ }
242
+ case ZodTypeName.ZodRecord: {
243
+ const recordDef = def;
244
+ return withDesc({
245
+ type: 'object',
246
+ additionalProperties: convertZodType(recordDef.valueType),
247
+ });
248
+ }
249
+ // -----------------------------------------------------------------------
250
+ // Optional / Nullable / Default
251
+ // -----------------------------------------------------------------------
252
+ case ZodTypeName.ZodOptional: {
253
+ const optionalDef = def;
254
+ const inner = convertZodType(optionalDef.innerType);
255
+ return description !== undefined ? { ...inner, description } : inner;
256
+ }
257
+ case ZodTypeName.ZodNullable: {
258
+ const nullableDef = def;
259
+ const inner = convertZodType(nullableDef.innerType);
260
+ const type = inner.type;
261
+ if (typeof type === 'string') {
262
+ return withDesc({ ...inner, type: [type, 'null'] });
263
+ }
264
+ return withDesc({ anyOf: [inner, { type: 'null' }] });
265
+ }
266
+ case ZodTypeName.ZodDefault: {
267
+ const defaultDef = def;
268
+ const inner = convertZodType(defaultDef.innerType);
269
+ return withDesc({ ...inner, default: defaultDef.defaultValue() });
270
+ }
271
+ // -----------------------------------------------------------------------
272
+ // Union / Intersection / Discriminated Union
273
+ // -----------------------------------------------------------------------
274
+ case ZodTypeName.ZodUnion: {
275
+ const unionDef = def;
276
+ const options = unionDef.options.map(convertZodType);
277
+ return withDesc({ anyOf: options });
278
+ }
279
+ case ZodTypeName.ZodDiscriminatedUnion: {
280
+ const duDef = def;
281
+ const options = duDef.options.map(convertZodType);
282
+ return withDesc({ anyOf: options });
283
+ }
284
+ case ZodTypeName.ZodIntersection: {
285
+ const intDef = def;
286
+ return withDesc({
287
+ allOf: [convertZodType(intDef.left), convertZodType(intDef.right)],
288
+ });
289
+ }
290
+ // -----------------------------------------------------------------------
291
+ // Wrappers that forward to their inner type
292
+ // -----------------------------------------------------------------------
293
+ case ZodTypeName.ZodEffects: {
294
+ const effectsDef = def;
295
+ const inner = convertZodType(effectsDef.schema);
296
+ return description !== undefined ? { ...inner, description } : inner;
297
+ }
298
+ case ZodTypeName.ZodBranded: {
299
+ const brandedDef = def;
300
+ return withDesc(convertZodType(brandedDef.type));
301
+ }
302
+ case ZodTypeName.ZodReadonly: {
303
+ const readonlyDef = def;
304
+ return withDesc(convertZodType(readonlyDef.innerType));
305
+ }
306
+ case ZodTypeName.ZodCatch: {
307
+ const catchDef = def;
308
+ return withDesc(convertZodType(catchDef.innerType));
309
+ }
310
+ case ZodTypeName.ZodPipeline: {
311
+ const pipelineDef = def;
312
+ return withDesc(convertZodType(pipelineDef.in));
313
+ }
314
+ // -----------------------------------------------------------------------
315
+ // Any / Unknown – JSON Schema wildcard
316
+ // -----------------------------------------------------------------------
317
+ case ZodTypeName.ZodAny:
318
+ case ZodTypeName.ZodUnknown:
319
+ return withDesc({});
320
+ case ZodTypeName.ZodNever:
321
+ return withDesc({ not: {} });
322
+ case ZodTypeName.ZodVoid:
323
+ return withDesc({ type: 'null' });
324
+ // -----------------------------------------------------------------------
325
+ // Fallback
326
+ // -----------------------------------------------------------------------
327
+ default:
328
+ return withDesc({});
329
+ }
330
+ }
331
+ // ---------------------------------------------------------------------------
332
+ // Internal Zod type-name enum (mirrors Zod's internal ZodFirstPartyTypeKind)
333
+ // ---------------------------------------------------------------------------
334
+ var ZodTypeName;
335
+ (function (ZodTypeName) {
336
+ ZodTypeName["ZodString"] = "ZodString";
337
+ ZodTypeName["ZodNumber"] = "ZodNumber";
338
+ ZodTypeName["ZodBigInt"] = "ZodBigInt";
339
+ ZodTypeName["ZodBoolean"] = "ZodBoolean";
340
+ ZodTypeName["ZodDate"] = "ZodDate";
341
+ ZodTypeName["ZodUndefined"] = "ZodUndefined";
342
+ ZodTypeName["ZodNull"] = "ZodNull";
343
+ ZodTypeName["ZodAny"] = "ZodAny";
344
+ ZodTypeName["ZodUnknown"] = "ZodUnknown";
345
+ ZodTypeName["ZodNever"] = "ZodNever";
346
+ ZodTypeName["ZodVoid"] = "ZodVoid";
347
+ ZodTypeName["ZodArray"] = "ZodArray";
348
+ ZodTypeName["ZodObject"] = "ZodObject";
349
+ ZodTypeName["ZodUnion"] = "ZodUnion";
350
+ ZodTypeName["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
351
+ ZodTypeName["ZodIntersection"] = "ZodIntersection";
352
+ ZodTypeName["ZodTuple"] = "ZodTuple";
353
+ ZodTypeName["ZodRecord"] = "ZodRecord";
354
+ ZodTypeName["ZodMap"] = "ZodMap";
355
+ ZodTypeName["ZodSet"] = "ZodSet";
356
+ ZodTypeName["ZodFunction"] = "ZodFunction";
357
+ ZodTypeName["ZodLazy"] = "ZodLazy";
358
+ ZodTypeName["ZodLiteral"] = "ZodLiteral";
359
+ ZodTypeName["ZodEnum"] = "ZodEnum";
360
+ ZodTypeName["ZodEffects"] = "ZodEffects";
361
+ ZodTypeName["ZodNativeEnum"] = "ZodNativeEnum";
362
+ ZodTypeName["ZodOptional"] = "ZodOptional";
363
+ ZodTypeName["ZodNullable"] = "ZodNullable";
364
+ ZodTypeName["ZodDefault"] = "ZodDefault";
365
+ ZodTypeName["ZodCatch"] = "ZodCatch";
366
+ ZodTypeName["ZodPromise"] = "ZodPromise";
367
+ ZodTypeName["ZodBranded"] = "ZodBranded";
368
+ ZodTypeName["ZodPipeline"] = "ZodPipeline";
369
+ ZodTypeName["ZodReadonly"] = "ZodReadonly";
370
+ })(ZodTypeName || (ZodTypeName = {}));
371
+ //# sourceMappingURL=framework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"framework.js","sourceRoot":"","sources":["../../src/tool/framework.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAoCH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CAAS,MAKlC;IACC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,OAAO,YAAY;IACvB,8DAA8D;IAC7C,KAAK,GAAG,IAAI,GAAG,EAA+B,CAAA;IAE/D;;;OAGG;IACH,8DAA8D;IAC9D,QAAQ,CAAC,IAAyB;QACh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