@orkestrel/tool 0.0.11 → 0.0.13

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/README.md CHANGED
@@ -10,7 +10,7 @@ registry around it: definitions to advertise, calls to dispatch, results to corr
10
10
  per-call error isolation so one bad tool never takes down the run.
11
11
 
12
12
  Nothing here is model-specific. An agent loop, an MCP bridge, and plain application code are all
13
- just callers.
13
+ callers.
14
14
 
15
15
  ## Install
16
16
 
@@ -1,8 +1,39 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _orkestrel_contract = require("@orkestrel/contract");
3
+ //#region src/core/helpers.ts
4
+ /**
5
+ * Projects a tool onto the plain definition advertised to a caller.
6
+ *
7
+ * @remarks
8
+ * The projection is a fresh object carrying `name`, then `description` only when the
9
+ * tool authored a summary or a description, then `parameters` only when the tool
10
+ * authored a schema. An authored `summary` is advertised in place of the full
11
+ * `description`, which stays on the tool for direct lookup. The parameter schema is
12
+ * copied by reference and never cloned, so the definition is never a live handle on
13
+ * the tool's handler.
14
+ *
15
+ * @param tool - The tool to project
16
+ * @returns A fresh definition carrying only the fields the tool authored
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { Tool, toolToDefinition } from '@orkestrel/tool'
21
+ *
22
+ * const echo = new Tool({ name: 'echo', summary: 'Echo a value.', execute: (args) => args.value })
23
+ * toolToDefinition(echo) // { name: 'echo', description: 'Echo a value.' }
24
+ * ```
25
+ */
26
+ function toolToDefinition(tool) {
27
+ const definition = { name: tool.name };
28
+ const description = tool.summary ?? tool.description;
29
+ if (description !== void 0) definition.description = description;
30
+ if (tool.parameters !== void 0) definition.parameters = tool.parameters;
31
+ return definition;
32
+ }
33
+ //#endregion
3
34
  //#region src/core/validators.ts
4
35
  /**
5
- * Determine whether an unknown value is structurally a {@link ToolCall}.
36
+ * Determines whether an unknown value is structurally a {@link ToolCall}.
6
37
  *
7
38
  * @remarks
8
39
  * This total guard accepts a plain record with string `id` and `name` fields and a
@@ -10,7 +41,7 @@ let _orkestrel_contract = require("@orkestrel/contract");
10
41
  * read or verified. Adversarial values return `false`.
11
42
  *
12
43
  * @param value - The value to test
13
- * @returns `true` when the value has the complete tool-call shape
44
+ * @returns True if the value has the complete tool-call shape; false otherwise
14
45
  *
15
46
  * @example
16
47
  * ```ts
@@ -26,7 +57,7 @@ function isToolCall(value) {
26
57
  //#endregion
27
58
  //#region src/core/tools/Tool.ts
28
59
  /**
29
- * An executable tool definition bound to a handler.
60
+ * Binds an executable tool definition to a handler.
30
61
  *
31
62
  * @remarks
32
63
  * Schema fields, arguments, and present caller context are forwarded by reference.
@@ -69,14 +100,15 @@ var Tool = class {
69
100
  //#endregion
70
101
  //#region src/core/tools/ToolManager.ts
71
102
  /**
72
- * An insertion-ordered tool registry with per-call error isolation.
103
+ * Represents an insertion-ordered tool registry with per-call error isolation.
73
104
  *
74
105
  * @remarks
75
106
  * A repeated name overwrites the registered tool without changing its insertion
76
107
  * position. Definitions advertise `summary` in place of `description` when present.
77
- * Unknown names and handler throws resolve to error results; batch execution preserves
78
- * input order and never fails as a whole because of an individual call. Optional
79
- * consumer-asserted caller context is forwarded without verification.
108
+ * Unknown names and handler throws resolve to error results; a call whose `id` or `name`
109
+ * accessor throws when read makes its call, and the batch holding it, reject. Batch
110
+ * execution preserves input order and isolates each call whose members are plain
111
+ * values. Optional consumer-asserted caller context is forwarded without verification.
80
112
  *
81
113
  * @example
82
114
  * ```ts
@@ -110,7 +142,7 @@ var ToolManager = class {
110
142
  return [...this.#tools.values()];
111
143
  }
112
144
  definitions() {
113
- return [...this.#tools.values()].map((tool) => this.#definition(tool));
145
+ return [...this.#tools.values()].map((tool) => toolToDefinition(tool));
114
146
  }
115
147
  execute(call) {
116
148
  if ((0, _orkestrel_contract.isArray)(call)) return Promise.all(call.map((one) => this.#run(one)));
@@ -118,8 +150,8 @@ var ToolManager = class {
118
150
  }
119
151
  remove(names) {
120
152
  if ((0, _orkestrel_contract.isArray)(names)) {
121
- let removed = false;
122
- for (const name of names) if (this.#tools.delete(name)) removed = true;
153
+ let removed = true;
154
+ for (const name of names) if (!this.#tools.delete(name)) removed = false;
123
155
  return removed;
124
156
  }
125
157
  return this.#tools.delete(names);
@@ -154,18 +186,11 @@ var ToolManager = class {
154
186
  };
155
187
  }
156
188
  }
157
- #definition(tool) {
158
- const definition = { name: tool.name };
159
- const description = tool.summary ?? tool.description;
160
- if (description !== void 0) definition.description = description;
161
- if (tool.parameters !== void 0) definition.parameters = tool.parameters;
162
- return definition;
163
- }
164
189
  };
165
190
  //#endregion
166
191
  //#region src/core/factories.ts
167
192
  /**
168
- * Create an executable tool.
193
+ * Creates an executable tool.
169
194
  *
170
195
  * @param options - The advertised definition and execution handler
171
196
  * @returns A tool bound to the supplied handler
@@ -185,7 +210,7 @@ function createTool(options) {
185
210
  return new Tool(options);
186
211
  }
187
212
  /**
188
- * Create an empty tool registry.
213
+ * Creates an empty tool registry.
189
214
  *
190
215
  * @returns A registry that advertises definitions and executes calls with per-call
191
216
  * error isolation
@@ -212,5 +237,6 @@ exports.ToolManager = ToolManager;
212
237
  exports.createTool = createTool;
213
238
  exports.createToolManager = createToolManager;
214
239
  exports.isToolCall = isToolCall;
240
+ exports.toolToDefinition = toolToDefinition;
215
241
 
216
242
  //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["#execute","#tools","#run"],"sources":["../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/tools/Tool.ts","../../../src/core/tools/ToolManager.ts","../../../src/core/factories.ts"],"sourcesContent":["import type { ToolDefinition, ToolInterface } from './types.js'\n\n/**\n * Projects a tool onto the plain definition advertised to a caller.\n *\n * @remarks\n * The projection is a fresh object carrying `name`, then `description` only when the\n * tool authored a summary or a description, then `parameters` only when the tool\n * authored a schema. An authored `summary` is advertised in place of the full\n * `description`, which stays on the tool for direct lookup. The parameter schema is\n * copied by reference and never cloned, so the definition is never a live handle on\n * the tool's handler.\n *\n * @param tool - The tool to project\n * @returns A fresh definition carrying only the fields the tool authored\n *\n * @example\n * ```ts\n * import { Tool, toolToDefinition } from '@orkestrel/tool'\n *\n * const echo = new Tool({ name: 'echo', summary: 'Echo a value.', execute: (args) => args.value })\n * toolToDefinition(echo) // { name: 'echo', description: 'Echo a value.' }\n * ```\n */\nexport function toolToDefinition(tool: ToolInterface): ToolDefinition {\n\tconst definition: {\n\t\tname: string\n\t\tdescription?: string\n\t\tparameters?: Readonly<Record<string, unknown>>\n\t} = {\n\t\tname: tool.name,\n\t}\n\tconst description = tool.summary ?? tool.description\n\tif (description !== undefined) definition.description = description\n\tif (tool.parameters !== undefined) definition.parameters = tool.parameters\n\treturn definition\n}\n","import type { ToolCall } from './types.js'\nimport { holds, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Determines whether an unknown value is structurally a {@link ToolCall}.\n *\n * @remarks\n * This total guard accepts a plain record with string `id` and `name` fields and a\n * plain-record `arguments` field. Optional caller context remains opaque and is not\n * read or verified. Adversarial values return `false`.\n *\n * @param value - The value to test\n * @returns True if the value has the complete tool-call shape; false otherwise\n *\n * @example\n * ```ts\n * import { isToolCall } from '@orkestrel/tool'\n *\n * isToolCall({ id: '1', name: 'search', arguments: { query: 'birds' } }) // true\n * isToolCall({ id: '1', name: 'search', arguments: [] }) // false\n * ```\n */\nexport function isToolCall(value: unknown): value is ToolCall {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) && isString(value.id) && isString(value.name) && isRecord(value.arguments),\n\t)\n}\n","import type { ToolInterface, ToolOptions } from '../types.js'\n\n/**\n * Binds an executable tool definition to a handler.\n *\n * @remarks\n * Schema fields, arguments, and present caller context are forwarded by reference.\n * Caller context is consumer-asserted and is not verified. Handler failures are not\n * caught here; {@link ToolManager} owns per-call error isolation.\n *\n * @example\n * ```ts\n * import { Tool } from '@orkestrel/tool'\n *\n * const tool = new Tool({\n * \tname: 'add',\n * \tdescription: 'Add two numbers',\n * \tparameters: {\n * \t\ttype: 'object',\n * \t\tproperties: { a: { type: 'number' }, b: { type: 'number' } },\n * \t},\n * \texecute: (args) => Number(args.a) + Number(args.b),\n * })\n * ```\n */\nexport class Tool implements ToolInterface {\n\treadonly name: string\n\treadonly description?: string\n\treadonly summary?: string\n\treadonly parameters?: Readonly<Record<string, unknown>>\n\treadonly #execute: (\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcaller?: unknown,\n\t) => Promise<unknown> | unknown\n\n\tconstructor(options: ToolOptions) {\n\t\tthis.name = options.name\n\t\tif (options.description !== undefined) this.description = options.description\n\t\tif (options.summary !== undefined) this.summary = options.summary\n\t\tif (options.parameters !== undefined) this.parameters = options.parameters\n\t\tthis.#execute = options.execute\n\t}\n\n\texecute(args: Readonly<Record<string, unknown>>, caller?: unknown): Promise<unknown> | unknown {\n\t\tif (caller === undefined) return this.#execute(args)\n\t\treturn this.#execute(args, caller)\n\t}\n}\n","import type {\n\tToolCall,\n\tToolDefinition,\n\tToolInterface,\n\tToolManagerInterface,\n\tToolResult,\n} from '../types.js'\nimport { attempt, isArray } from '@orkestrel/contract'\nimport { toolToDefinition } from '../helpers.js'\n\n/**\n * Represents an insertion-ordered tool registry with per-call error isolation.\n *\n * @remarks\n * A repeated name overwrites the registered tool without changing its insertion\n * position. Definitions advertise `summary` in place of `description` when present.\n * Unknown names and handler throws resolve to error results; a call whose `id` or `name`\n * accessor throws when read makes its call, and the batch holding it, reject. Batch\n * execution preserves input order and isolates each call whose members are plain\n * values. Optional consumer-asserted caller context is forwarded without verification.\n *\n * @example\n * ```ts\n * import { Tool, ToolManager } from '@orkestrel/tool'\n *\n * const tools = new ToolManager()\n * tools.add(new Tool({ name: 'add', execute: (args) => Number(args.x) + Number(args.y) }))\n * const result = await tools.execute({\n * \tid: '1',\n * \tname: 'add',\n * \targuments: { x: 1, y: 2 },\n * })\n * ```\n */\nexport class ToolManager implements ToolManagerInterface {\n\treadonly #tools = new Map<string, ToolInterface>()\n\n\tget count(): number {\n\t\treturn this.#tools.size\n\t}\n\n\tadd(tool: ToolInterface): void\n\tadd(tools: readonly ToolInterface[]): void\n\tadd(tools: ToolInterface | readonly ToolInterface[]): void {\n\t\tif (isArray(tools)) {\n\t\t\tfor (const tool of tools) this.#tools.set(tool.name, tool)\n\t\t\treturn\n\t\t}\n\t\tthis.#tools.set(tools.name, tools)\n\t}\n\n\ttool(name: string): ToolInterface | undefined {\n\t\treturn this.#tools.get(name)\n\t}\n\n\ttools(): readonly ToolInterface[] {\n\t\treturn [...this.#tools.values()]\n\t}\n\n\tdefinitions(): readonly ToolDefinition[] {\n\t\treturn [...this.#tools.values()].map((tool) => toolToDefinition(tool))\n\t}\n\n\texecute(call: ToolCall): Promise<ToolResult>\n\texecute(calls: readonly ToolCall[]): Promise<readonly ToolResult[]>\n\texecute(call: ToolCall | readonly ToolCall[]): Promise<ToolResult | readonly ToolResult[]> {\n\t\tif (isArray(call)) return Promise.all(call.map((one) => this.#run(one)))\n\t\treturn this.#run(call)\n\t}\n\n\tremove(name: string): boolean\n\tremove(names: readonly string[]): boolean\n\tremove(names: string | readonly string[]): boolean {\n\t\tif (isArray(names)) {\n\t\t\tlet removed = true\n\t\t\tfor (const name of names) {\n\t\t\t\tif (!this.#tools.delete(name)) removed = false\n\t\t\t}\n\t\t\treturn removed\n\t\t}\n\t\treturn this.#tools.delete(names)\n\t}\n\n\tclear(): void {\n\t\tthis.#tools.clear()\n\t}\n\n\tasync #run(call: ToolCall): Promise<ToolResult> {\n\t\tconst tool = this.#tools.get(call.name)\n\t\tif (tool === undefined) {\n\t\t\treturn {\n\t\t\t\tid: call.id,\n\t\t\t\tname: call.name,\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `tool not found: ${call.name}`,\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tconst caller = call.caller\n\t\t\tconst value = await (caller === undefined\n\t\t\t\t? tool.execute(call.arguments)\n\t\t\t\t: tool.execute(call.arguments, caller))\n\t\t\treturn { id: call.id, name: call.name, success: true, value }\n\t\t} catch (error) {\n\t\t\tconst message = attempt(() =>\n\t\t\t\terror instanceof Error ? String(error.message) : String(error),\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tid: call.id,\n\t\t\t\tname: call.name,\n\t\t\t\tsuccess: false,\n\t\t\t\terror: message.success ? message.value : 'Unknown thrown value',\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { ToolInterface, ToolManagerInterface, ToolOptions } from './types.js'\nimport { Tool } from './tools/Tool.js'\nimport { ToolManager } from './tools/ToolManager.js'\n\n/**\n * Creates an executable tool.\n *\n * @param options - The advertised definition and execution handler\n * @returns A tool bound to the supplied handler\n *\n * @example\n * ```ts\n * import { createTool } from '@orkestrel/tool'\n *\n * const add = createTool({\n * \tname: 'add',\n * \tdescription: 'Add two numbers',\n * \texecute: (args) => Number(args.a) + Number(args.b),\n * })\n * ```\n */\nexport function createTool(options: ToolOptions): ToolInterface {\n\treturn new Tool(options)\n}\n\n/**\n * Creates an empty tool registry.\n *\n * @returns A registry that advertises definitions and executes calls with per-call\n * error isolation\n *\n * @example\n * ```ts\n * import { createTool, createToolManager } from '@orkestrel/tool'\n *\n * const tools = createToolManager()\n * tools.add(createTool({ name: 'echo', execute: (args) => args.value }))\n * const result = await tools.execute({\n * \tid: '1',\n * \tname: 'echo',\n * \targuments: { value: 'hello' },\n * })\n * ```\n */\nexport function createToolManager(): ToolManagerInterface {\n\treturn new ToolManager()\n}\n"],"mappings":"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"}
@@ -2,7 +2,7 @@ import { Failure } from '@orkestrel/contract';
2
2
  import { Success } from '@orkestrel/contract';
3
3
 
4
4
  /**
5
- * Create an executable tool.
5
+ * Creates an executable tool.
6
6
  *
7
7
  * @param options - The advertised definition and execution handler
8
8
  * @returns A tool bound to the supplied handler
@@ -21,7 +21,7 @@ import { Success } from '@orkestrel/contract';
21
21
  export declare function createTool(options: ToolOptions): ToolInterface;
22
22
 
23
23
  /**
24
- * Create an empty tool registry.
24
+ * Creates an empty tool registry.
25
25
  *
26
26
  * @returns A registry that advertises definitions and executes calls with per-call
27
27
  * error isolation
@@ -42,7 +42,7 @@ export declare function createTool(options: ToolOptions): ToolInterface;
42
42
  export declare function createToolManager(): ToolManagerInterface;
43
43
 
44
44
  /**
45
- * Determine whether an unknown value is structurally a {@link ToolCall}.
45
+ * Determines whether an unknown value is structurally a {@link ToolCall}.
46
46
  *
47
47
  * @remarks
48
48
  * This total guard accepts a plain record with string `id` and `name` fields and a
@@ -50,7 +50,7 @@ export declare function createToolManager(): ToolManagerInterface;
50
50
  * read or verified. Adversarial values return `false`.
51
51
  *
52
52
  * @param value - The value to test
53
- * @returns `true` when the value has the complete tool-call shape
53
+ * @returns True if the value has the complete tool-call shape; false otherwise
54
54
  *
55
55
  * @example
56
56
  * ```ts
@@ -63,7 +63,7 @@ export declare function createToolManager(): ToolManagerInterface;
63
63
  export declare function isToolCall(value: unknown): value is ToolCall;
64
64
 
65
65
  /**
66
- * An executable tool definition bound to a handler.
66
+ * Binds an executable tool definition to a handler.
67
67
  *
68
68
  * @remarks
69
69
  * Schema fields, arguments, and present caller context are forwarded by reference.
@@ -96,7 +96,7 @@ export declare class Tool implements ToolInterface {
96
96
  }
97
97
 
98
98
  /**
99
- * A tool call issued by a caller.
99
+ * Describes a call issued by a caller.
100
100
  *
101
101
  * @remarks
102
102
  * `id` correlates the call with its later {@link ToolResult}. `arguments` is the
@@ -105,33 +105,33 @@ export declare class Tool implements ToolInterface {
105
105
  * every trust decision.
106
106
  */
107
107
  export declare interface ToolCall {
108
- /** The identifier that correlates this call with its result. */
108
+ /** Correlates this call with its result. */
109
109
  readonly id: string;
110
- /** The name of the tool to execute. */
110
+ /** Selects the tool to execute. */
111
111
  readonly name: string;
112
- /** The caller-supplied arguments record. */
112
+ /** Carries the record the caller supplied. */
113
113
  readonly arguments: Readonly<Record<string, unknown>>;
114
- /** Consumer-asserted caller context, forwarded without verification. */
114
+ /** Carries consumer-asserted context, forwarded without verification. */
115
115
  readonly caller?: unknown;
116
116
  }
117
117
 
118
118
  /**
119
- * A tool definition advertised to a caller.
119
+ * Describes a tool as advertised to a caller.
120
120
  *
121
121
  * @remarks
122
122
  * `parameters` is an open JSON Schema record describing the arguments the tool accepts.
123
123
  */
124
124
  export declare interface ToolDefinition {
125
- /** The name a caller uses to select the tool. */
125
+ /** Identifies the tool a caller selects. */
126
126
  readonly name: string;
127
- /** A description of the tool's behavior. */
127
+ /** Describes the tool's behavior. */
128
128
  readonly description?: string;
129
- /** The JSON Schema for the tool's arguments. */
129
+ /** Holds the JSON Schema for the tool's arguments. */
130
130
  readonly parameters?: Readonly<Record<string, unknown>>;
131
131
  }
132
132
 
133
133
  /**
134
- * The failed outcome of executing a {@link ToolCall}.
134
+ * Reports the failed outcome of executing a {@link ToolCall}.
135
135
  *
136
136
  * @remarks
137
137
  * `error` is the failure message: an unknown tool name, an `Error`'s message, or
@@ -140,24 +140,30 @@ export declare interface ToolDefinition {
140
140
  * `tool.execute(args)` in its own `try`/`catch`.
141
141
  */
142
142
  export declare interface ToolFailure extends Failure<string> {
143
- /** The identifier of the corresponding call. */
143
+ /** Identifies the corresponding call. */
144
144
  readonly id: string;
145
- /** The name of the called tool. */
145
+ /** Identifies the called tool. */
146
146
  readonly name: string;
147
147
  }
148
148
 
149
149
  /**
150
- * An executable tool: its advertised definition plus its local handler.
150
+ * Represents an executable tool: its advertised definition plus its local handler.
151
151
  *
152
152
  * @remarks
153
153
  * `summary`, when present, is advertised in place of the full `description` by a
154
154
  * {@link ToolManagerInterface}. The full description remains available on the tool.
155
155
  */
156
156
  export declare interface ToolInterface extends ToolDefinition {
157
- /** A concise description to advertise in place of the full description. */
157
+ /** Holds a concise description to advertise in place of the full description. */
158
158
  readonly summary?: string;
159
159
  /**
160
- * Execute the tool.
160
+ * Runs the tool's handler.
161
+ *
162
+ * @remarks
163
+ * Failures are not contained here: a synchronous throw propagates and an
164
+ * asynchronous rejection rejects. {@link ToolManagerInterface.execute} is where a
165
+ * call becomes a result. The registry omits `caller` from the invocation when the
166
+ * call carries none, so a handler reading its own arity sees one argument.
161
167
  *
162
168
  * @param args - The caller-supplied arguments record
163
169
  * @param caller - Optional consumer-asserted caller context, forwarded without verification
@@ -167,14 +173,15 @@ export declare interface ToolInterface extends ToolDefinition {
167
173
  }
168
174
 
169
175
  /**
170
- * An insertion-ordered tool registry with per-call error isolation.
176
+ * Represents an insertion-ordered tool registry with per-call error isolation.
171
177
  *
172
178
  * @remarks
173
179
  * A repeated name overwrites the registered tool without changing its insertion
174
180
  * position. Definitions advertise `summary` in place of `description` when present.
175
- * Unknown names and handler throws resolve to error results; batch execution preserves
176
- * input order and never fails as a whole because of an individual call. Optional
177
- * consumer-asserted caller context is forwarded without verification.
181
+ * Unknown names and handler throws resolve to error results; a call whose `id` or `name`
182
+ * accessor throws when read makes its call, and the batch holding it, reject. Batch
183
+ * execution preserves input order and isolates each call whose members are plain
184
+ * values. Optional consumer-asserted caller context is forwarded without verification.
178
185
  *
179
186
  * @example
180
187
  * ```ts
@@ -205,46 +212,47 @@ export declare class ToolManager implements ToolManagerInterface {
205
212
  }
206
213
 
207
214
  /**
208
- * A registry of executable tools with per-call error isolation.
215
+ * Represents a registry of executable tools with per-call error isolation.
209
216
  *
210
217
  * @remarks
211
218
  * Tools are keyed by name in insertion order. Adding an existing name overwrites its
212
- * value without changing its position. Every call resolves to a {@link ToolResult};
213
- * missing tools and thrown handlers become error results. Batch execution preserves
214
- * input order and isolates each call.
219
+ * value without changing its position. Every call whose members are plain values
220
+ * resolves to a {@link ToolResult}; missing tools and thrown handlers become error
221
+ * results, and a call whose `id` or `name` accessor throws when read makes `execute`
222
+ * reject instead. Batch execution preserves input order and isolates each such call.
215
223
  */
216
224
  export declare interface ToolManagerInterface {
217
- /** The number of registered tools. */
225
+ /** Reports how many tools are registered. */
218
226
  readonly count: number;
219
227
  /**
220
- * Register one tool.
228
+ * Registers one tool.
221
229
  *
222
230
  * @param tool - The tool to register
223
231
  * @returns Nothing
224
232
  */
225
233
  add(tool: ToolInterface): void;
226
234
  /**
227
- * Register a batch of tools.
235
+ * Registers a batch of tools.
228
236
  *
229
237
  * @param tools - The tools to register
230
238
  * @returns Nothing
231
239
  */
232
240
  add(tools: readonly ToolInterface[]): void;
233
241
  /**
234
- * Find one registered tool by name.
242
+ * Finds one registered tool by name.
235
243
  *
236
244
  * @param name - The registered tool name
237
245
  * @returns The tool when found, otherwise `undefined`
238
246
  */
239
247
  tool(name: string): ToolInterface | undefined;
240
248
  /**
241
- * List the registered tools in insertion order.
249
+ * Lists the registered tools in insertion order.
242
250
  *
243
251
  * @returns A new readonly array of registered tools
244
252
  */
245
253
  tools(): readonly ToolInterface[];
246
254
  /**
247
- * List the definitions advertised to a caller.
255
+ * Lists the definitions advertised to a caller.
248
256
  *
249
257
  * The projected `description` is the tool's `summary` when one was authored,
250
258
  * advertised in place of the full description. The full text stays on the tool
@@ -254,35 +262,35 @@ export declare interface ToolManagerInterface {
254
262
  */
255
263
  definitions(): readonly ToolDefinition[];
256
264
  /**
257
- * Execute one call with error isolation.
265
+ * Executes one call with error isolation.
258
266
  *
259
267
  * @param call - The tool call to execute, including optional caller context
260
268
  * @returns The correlated result
261
269
  */
262
270
  execute(call: ToolCall): Promise<ToolResult>;
263
271
  /**
264
- * Execute a batch of calls with per-call error isolation.
272
+ * Executes a batch of calls with per-call error isolation.
265
273
  *
266
274
  * @param calls - The tool calls to execute, including optional caller context
267
275
  * @returns The correlated results in input order
268
276
  */
269
277
  execute(calls: readonly ToolCall[]): Promise<readonly ToolResult[]>;
270
278
  /**
271
- * Remove one registered tool.
279
+ * Removes one registered tool.
272
280
  *
273
281
  * @param name - The tool name to remove
274
- * @returns Whether the tool was present
282
+ * @returns True if the tool was present; false otherwise
275
283
  */
276
284
  remove(name: string): boolean;
277
285
  /**
278
- * Remove a batch of registered tools.
286
+ * Removes a batch of registered tools.
279
287
  *
280
288
  * @param names - The tool names to remove
281
- * @returns Whether any named tool was present
289
+ * @returns True if every named tool was present; false otherwise
282
290
  */
283
291
  remove(names: readonly string[]): boolean;
284
292
  /**
285
- * Remove every registered tool.
293
+ * Removes every registered tool.
286
294
  *
287
295
  * @returns Nothing
288
296
  */
@@ -290,7 +298,7 @@ export declare interface ToolManagerInterface {
290
298
  }
291
299
 
292
300
  /**
293
- * Options for creating an executable tool.
301
+ * Configures an executable tool.
294
302
  *
295
303
  * @remarks
296
304
  * `name` identifies the tool, `description` and `parameters` define what is advertised
@@ -299,38 +307,64 @@ export declare interface ToolManagerInterface {
299
307
  * context. This package forwards that context without verification.
300
308
  */
301
309
  export declare interface ToolOptions {
302
- /** The name a caller uses to select the tool. */
310
+ /** Identifies the tool a caller selects. */
303
311
  readonly name: string;
304
- /** The full description of the tool's behavior. */
312
+ /** Describes the tool's behavior in full. */
305
313
  readonly description?: string;
306
- /** A concise description to advertise in place of the full description. */
314
+ /** Holds a concise description to advertise in place of the full description. */
307
315
  readonly summary?: string;
308
- /** The JSON Schema for the tool's arguments. */
316
+ /** Holds the JSON Schema for the tool's arguments. */
309
317
  readonly parameters?: Readonly<Record<string, unknown>>;
310
- /** The handler that receives arguments and optional unverified caller context. */
318
+ /** Handles the arguments and optional unverified caller context. */
311
319
  readonly execute: (args: Readonly<Record<string, unknown>>, caller?: unknown) => Promise<unknown> | unknown;
312
320
  }
313
321
 
314
322
  /**
315
- * The outcome of executing a {@link ToolCall}.
323
+ * Represents the outcome of executing a {@link ToolCall}.
316
324
  *
317
325
  * @remarks
318
- * Always a result and never a throw. Narrow on `success`.
326
+ * Always a result and never a throw for a call whose members are plain values. A call
327
+ * whose `id` or `name` accessor throws when read makes `execute` reject instead, because
328
+ * no correlated result can be built without them. Narrow on `success`.
319
329
  */
320
330
  export declare type ToolResult = ToolSuccess | ToolFailure;
321
331
 
322
332
  /**
323
- * The successful outcome of executing a {@link ToolCall}.
333
+ * Reports the successful outcome of executing a {@link ToolCall}.
324
334
  *
325
335
  * @remarks
326
336
  * `value` is whatever the handler returned — including `undefined`, `null`, `0`,
327
337
  * `''`, or `false`. A present value never implies a meaningful one.
328
338
  */
329
339
  export declare interface ToolSuccess extends Success<unknown> {
330
- /** The identifier of the corresponding call. */
340
+ /** Identifies the corresponding call. */
331
341
  readonly id: string;
332
- /** The name of the called tool. */
342
+ /** Identifies the called tool. */
333
343
  readonly name: string;
334
344
  }
335
345
 
346
+ /**
347
+ * Projects a tool onto the plain definition advertised to a caller.
348
+ *
349
+ * @remarks
350
+ * The projection is a fresh object carrying `name`, then `description` only when the
351
+ * tool authored a summary or a description, then `parameters` only when the tool
352
+ * authored a schema. An authored `summary` is advertised in place of the full
353
+ * `description`, which stays on the tool for direct lookup. The parameter schema is
354
+ * copied by reference and never cloned, so the definition is never a live handle on
355
+ * the tool's handler.
356
+ *
357
+ * @param tool - The tool to project
358
+ * @returns A fresh definition carrying only the fields the tool authored
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * import { Tool, toolToDefinition } from '@orkestrel/tool'
363
+ *
364
+ * const echo = new Tool({ name: 'echo', summary: 'Echo a value.', execute: (args) => args.value })
365
+ * toolToDefinition(echo) // { name: 'echo', description: 'Echo a value.' }
366
+ * ```
367
+ */
368
+ export declare function toolToDefinition(tool: ToolInterface): ToolDefinition;
369
+
336
370
  export { }
@@ -2,7 +2,7 @@ import { Failure } from '@orkestrel/contract';
2
2
  import { Success } from '@orkestrel/contract';
3
3
 
4
4
  /**
5
- * Create an executable tool.
5
+ * Creates an executable tool.
6
6
  *
7
7
  * @param options - The advertised definition and execution handler
8
8
  * @returns A tool bound to the supplied handler
@@ -21,7 +21,7 @@ import { Success } from '@orkestrel/contract';
21
21
  export declare function createTool(options: ToolOptions): ToolInterface;
22
22
 
23
23
  /**
24
- * Create an empty tool registry.
24
+ * Creates an empty tool registry.
25
25
  *
26
26
  * @returns A registry that advertises definitions and executes calls with per-call
27
27
  * error isolation
@@ -42,7 +42,7 @@ export declare function createTool(options: ToolOptions): ToolInterface;
42
42
  export declare function createToolManager(): ToolManagerInterface;
43
43
 
44
44
  /**
45
- * Determine whether an unknown value is structurally a {@link ToolCall}.
45
+ * Determines whether an unknown value is structurally a {@link ToolCall}.
46
46
  *
47
47
  * @remarks
48
48
  * This total guard accepts a plain record with string `id` and `name` fields and a
@@ -50,7 +50,7 @@ export declare function createToolManager(): ToolManagerInterface;
50
50
  * read or verified. Adversarial values return `false`.
51
51
  *
52
52
  * @param value - The value to test
53
- * @returns `true` when the value has the complete tool-call shape
53
+ * @returns True if the value has the complete tool-call shape; false otherwise
54
54
  *
55
55
  * @example
56
56
  * ```ts
@@ -63,7 +63,7 @@ export declare function createToolManager(): ToolManagerInterface;
63
63
  export declare function isToolCall(value: unknown): value is ToolCall;
64
64
 
65
65
  /**
66
- * An executable tool definition bound to a handler.
66
+ * Binds an executable tool definition to a handler.
67
67
  *
68
68
  * @remarks
69
69
  * Schema fields, arguments, and present caller context are forwarded by reference.
@@ -96,7 +96,7 @@ export declare class Tool implements ToolInterface {
96
96
  }
97
97
 
98
98
  /**
99
- * A tool call issued by a caller.
99
+ * Describes a call issued by a caller.
100
100
  *
101
101
  * @remarks
102
102
  * `id` correlates the call with its later {@link ToolResult}. `arguments` is the
@@ -105,33 +105,33 @@ export declare class Tool implements ToolInterface {
105
105
  * every trust decision.
106
106
  */
107
107
  export declare interface ToolCall {
108
- /** The identifier that correlates this call with its result. */
108
+ /** Correlates this call with its result. */
109
109
  readonly id: string;
110
- /** The name of the tool to execute. */
110
+ /** Selects the tool to execute. */
111
111
  readonly name: string;
112
- /** The caller-supplied arguments record. */
112
+ /** Carries the record the caller supplied. */
113
113
  readonly arguments: Readonly<Record<string, unknown>>;
114
- /** Consumer-asserted caller context, forwarded without verification. */
114
+ /** Carries consumer-asserted context, forwarded without verification. */
115
115
  readonly caller?: unknown;
116
116
  }
117
117
 
118
118
  /**
119
- * A tool definition advertised to a caller.
119
+ * Describes a tool as advertised to a caller.
120
120
  *
121
121
  * @remarks
122
122
  * `parameters` is an open JSON Schema record describing the arguments the tool accepts.
123
123
  */
124
124
  export declare interface ToolDefinition {
125
- /** The name a caller uses to select the tool. */
125
+ /** Identifies the tool a caller selects. */
126
126
  readonly name: string;
127
- /** A description of the tool's behavior. */
127
+ /** Describes the tool's behavior. */
128
128
  readonly description?: string;
129
- /** The JSON Schema for the tool's arguments. */
129
+ /** Holds the JSON Schema for the tool's arguments. */
130
130
  readonly parameters?: Readonly<Record<string, unknown>>;
131
131
  }
132
132
 
133
133
  /**
134
- * The failed outcome of executing a {@link ToolCall}.
134
+ * Reports the failed outcome of executing a {@link ToolCall}.
135
135
  *
136
136
  * @remarks
137
137
  * `error` is the failure message: an unknown tool name, an `Error`'s message, or
@@ -140,24 +140,30 @@ export declare interface ToolDefinition {
140
140
  * `tool.execute(args)` in its own `try`/`catch`.
141
141
  */
142
142
  export declare interface ToolFailure extends Failure<string> {
143
- /** The identifier of the corresponding call. */
143
+ /** Identifies the corresponding call. */
144
144
  readonly id: string;
145
- /** The name of the called tool. */
145
+ /** Identifies the called tool. */
146
146
  readonly name: string;
147
147
  }
148
148
 
149
149
  /**
150
- * An executable tool: its advertised definition plus its local handler.
150
+ * Represents an executable tool: its advertised definition plus its local handler.
151
151
  *
152
152
  * @remarks
153
153
  * `summary`, when present, is advertised in place of the full `description` by a
154
154
  * {@link ToolManagerInterface}. The full description remains available on the tool.
155
155
  */
156
156
  export declare interface ToolInterface extends ToolDefinition {
157
- /** A concise description to advertise in place of the full description. */
157
+ /** Holds a concise description to advertise in place of the full description. */
158
158
  readonly summary?: string;
159
159
  /**
160
- * Execute the tool.
160
+ * Runs the tool's handler.
161
+ *
162
+ * @remarks
163
+ * Failures are not contained here: a synchronous throw propagates and an
164
+ * asynchronous rejection rejects. {@link ToolManagerInterface.execute} is where a
165
+ * call becomes a result. The registry omits `caller` from the invocation when the
166
+ * call carries none, so a handler reading its own arity sees one argument.
161
167
  *
162
168
  * @param args - The caller-supplied arguments record
163
169
  * @param caller - Optional consumer-asserted caller context, forwarded without verification
@@ -167,14 +173,15 @@ export declare interface ToolInterface extends ToolDefinition {
167
173
  }
168
174
 
169
175
  /**
170
- * An insertion-ordered tool registry with per-call error isolation.
176
+ * Represents an insertion-ordered tool registry with per-call error isolation.
171
177
  *
172
178
  * @remarks
173
179
  * A repeated name overwrites the registered tool without changing its insertion
174
180
  * position. Definitions advertise `summary` in place of `description` when present.
175
- * Unknown names and handler throws resolve to error results; batch execution preserves
176
- * input order and never fails as a whole because of an individual call. Optional
177
- * consumer-asserted caller context is forwarded without verification.
181
+ * Unknown names and handler throws resolve to error results; a call whose `id` or `name`
182
+ * accessor throws when read makes its call, and the batch holding it, reject. Batch
183
+ * execution preserves input order and isolates each call whose members are plain
184
+ * values. Optional consumer-asserted caller context is forwarded without verification.
178
185
  *
179
186
  * @example
180
187
  * ```ts
@@ -205,46 +212,47 @@ export declare class ToolManager implements ToolManagerInterface {
205
212
  }
206
213
 
207
214
  /**
208
- * A registry of executable tools with per-call error isolation.
215
+ * Represents a registry of executable tools with per-call error isolation.
209
216
  *
210
217
  * @remarks
211
218
  * Tools are keyed by name in insertion order. Adding an existing name overwrites its
212
- * value without changing its position. Every call resolves to a {@link ToolResult};
213
- * missing tools and thrown handlers become error results. Batch execution preserves
214
- * input order and isolates each call.
219
+ * value without changing its position. Every call whose members are plain values
220
+ * resolves to a {@link ToolResult}; missing tools and thrown handlers become error
221
+ * results, and a call whose `id` or `name` accessor throws when read makes `execute`
222
+ * reject instead. Batch execution preserves input order and isolates each such call.
215
223
  */
216
224
  export declare interface ToolManagerInterface {
217
- /** The number of registered tools. */
225
+ /** Reports how many tools are registered. */
218
226
  readonly count: number;
219
227
  /**
220
- * Register one tool.
228
+ * Registers one tool.
221
229
  *
222
230
  * @param tool - The tool to register
223
231
  * @returns Nothing
224
232
  */
225
233
  add(tool: ToolInterface): void;
226
234
  /**
227
- * Register a batch of tools.
235
+ * Registers a batch of tools.
228
236
  *
229
237
  * @param tools - The tools to register
230
238
  * @returns Nothing
231
239
  */
232
240
  add(tools: readonly ToolInterface[]): void;
233
241
  /**
234
- * Find one registered tool by name.
242
+ * Finds one registered tool by name.
235
243
  *
236
244
  * @param name - The registered tool name
237
245
  * @returns The tool when found, otherwise `undefined`
238
246
  */
239
247
  tool(name: string): ToolInterface | undefined;
240
248
  /**
241
- * List the registered tools in insertion order.
249
+ * Lists the registered tools in insertion order.
242
250
  *
243
251
  * @returns A new readonly array of registered tools
244
252
  */
245
253
  tools(): readonly ToolInterface[];
246
254
  /**
247
- * List the definitions advertised to a caller.
255
+ * Lists the definitions advertised to a caller.
248
256
  *
249
257
  * The projected `description` is the tool's `summary` when one was authored,
250
258
  * advertised in place of the full description. The full text stays on the tool
@@ -254,35 +262,35 @@ export declare interface ToolManagerInterface {
254
262
  */
255
263
  definitions(): readonly ToolDefinition[];
256
264
  /**
257
- * Execute one call with error isolation.
265
+ * Executes one call with error isolation.
258
266
  *
259
267
  * @param call - The tool call to execute, including optional caller context
260
268
  * @returns The correlated result
261
269
  */
262
270
  execute(call: ToolCall): Promise<ToolResult>;
263
271
  /**
264
- * Execute a batch of calls with per-call error isolation.
272
+ * Executes a batch of calls with per-call error isolation.
265
273
  *
266
274
  * @param calls - The tool calls to execute, including optional caller context
267
275
  * @returns The correlated results in input order
268
276
  */
269
277
  execute(calls: readonly ToolCall[]): Promise<readonly ToolResult[]>;
270
278
  /**
271
- * Remove one registered tool.
279
+ * Removes one registered tool.
272
280
  *
273
281
  * @param name - The tool name to remove
274
- * @returns Whether the tool was present
282
+ * @returns True if the tool was present; false otherwise
275
283
  */
276
284
  remove(name: string): boolean;
277
285
  /**
278
- * Remove a batch of registered tools.
286
+ * Removes a batch of registered tools.
279
287
  *
280
288
  * @param names - The tool names to remove
281
- * @returns Whether any named tool was present
289
+ * @returns True if every named tool was present; false otherwise
282
290
  */
283
291
  remove(names: readonly string[]): boolean;
284
292
  /**
285
- * Remove every registered tool.
293
+ * Removes every registered tool.
286
294
  *
287
295
  * @returns Nothing
288
296
  */
@@ -290,7 +298,7 @@ export declare interface ToolManagerInterface {
290
298
  }
291
299
 
292
300
  /**
293
- * Options for creating an executable tool.
301
+ * Configures an executable tool.
294
302
  *
295
303
  * @remarks
296
304
  * `name` identifies the tool, `description` and `parameters` define what is advertised
@@ -299,38 +307,64 @@ export declare interface ToolManagerInterface {
299
307
  * context. This package forwards that context without verification.
300
308
  */
301
309
  export declare interface ToolOptions {
302
- /** The name a caller uses to select the tool. */
310
+ /** Identifies the tool a caller selects. */
303
311
  readonly name: string;
304
- /** The full description of the tool's behavior. */
312
+ /** Describes the tool's behavior in full. */
305
313
  readonly description?: string;
306
- /** A concise description to advertise in place of the full description. */
314
+ /** Holds a concise description to advertise in place of the full description. */
307
315
  readonly summary?: string;
308
- /** The JSON Schema for the tool's arguments. */
316
+ /** Holds the JSON Schema for the tool's arguments. */
309
317
  readonly parameters?: Readonly<Record<string, unknown>>;
310
- /** The handler that receives arguments and optional unverified caller context. */
318
+ /** Handles the arguments and optional unverified caller context. */
311
319
  readonly execute: (args: Readonly<Record<string, unknown>>, caller?: unknown) => Promise<unknown> | unknown;
312
320
  }
313
321
 
314
322
  /**
315
- * The outcome of executing a {@link ToolCall}.
323
+ * Represents the outcome of executing a {@link ToolCall}.
316
324
  *
317
325
  * @remarks
318
- * Always a result and never a throw. Narrow on `success`.
326
+ * Always a result and never a throw for a call whose members are plain values. A call
327
+ * whose `id` or `name` accessor throws when read makes `execute` reject instead, because
328
+ * no correlated result can be built without them. Narrow on `success`.
319
329
  */
320
330
  export declare type ToolResult = ToolSuccess | ToolFailure;
321
331
 
322
332
  /**
323
- * The successful outcome of executing a {@link ToolCall}.
333
+ * Reports the successful outcome of executing a {@link ToolCall}.
324
334
  *
325
335
  * @remarks
326
336
  * `value` is whatever the handler returned — including `undefined`, `null`, `0`,
327
337
  * `''`, or `false`. A present value never implies a meaningful one.
328
338
  */
329
339
  export declare interface ToolSuccess extends Success<unknown> {
330
- /** The identifier of the corresponding call. */
340
+ /** Identifies the corresponding call. */
331
341
  readonly id: string;
332
- /** The name of the called tool. */
342
+ /** Identifies the called tool. */
333
343
  readonly name: string;
334
344
  }
335
345
 
346
+ /**
347
+ * Projects a tool onto the plain definition advertised to a caller.
348
+ *
349
+ * @remarks
350
+ * The projection is a fresh object carrying `name`, then `description` only when the
351
+ * tool authored a summary or a description, then `parameters` only when the tool
352
+ * authored a schema. An authored `summary` is advertised in place of the full
353
+ * `description`, which stays on the tool for direct lookup. The parameter schema is
354
+ * copied by reference and never cloned, so the definition is never a live handle on
355
+ * the tool's handler.
356
+ *
357
+ * @param tool - The tool to project
358
+ * @returns A fresh definition carrying only the fields the tool authored
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * import { Tool, toolToDefinition } from '@orkestrel/tool'
363
+ *
364
+ * const echo = new Tool({ name: 'echo', summary: 'Echo a value.', execute: (args) => args.value })
365
+ * toolToDefinition(echo) // { name: 'echo', description: 'Echo a value.' }
366
+ * ```
367
+ */
368
+ export declare function toolToDefinition(tool: ToolInterface): ToolDefinition;
369
+
336
370
  export { }
@@ -1,7 +1,38 @@
1
1
  import { attempt, holds, isArray, isRecord, isString } from "@orkestrel/contract";
2
+ //#region src/core/helpers.ts
3
+ /**
4
+ * Projects a tool onto the plain definition advertised to a caller.
5
+ *
6
+ * @remarks
7
+ * The projection is a fresh object carrying `name`, then `description` only when the
8
+ * tool authored a summary or a description, then `parameters` only when the tool
9
+ * authored a schema. An authored `summary` is advertised in place of the full
10
+ * `description`, which stays on the tool for direct lookup. The parameter schema is
11
+ * copied by reference and never cloned, so the definition is never a live handle on
12
+ * the tool's handler.
13
+ *
14
+ * @param tool - The tool to project
15
+ * @returns A fresh definition carrying only the fields the tool authored
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { Tool, toolToDefinition } from '@orkestrel/tool'
20
+ *
21
+ * const echo = new Tool({ name: 'echo', summary: 'Echo a value.', execute: (args) => args.value })
22
+ * toolToDefinition(echo) // { name: 'echo', description: 'Echo a value.' }
23
+ * ```
24
+ */
25
+ function toolToDefinition(tool) {
26
+ const definition = { name: tool.name };
27
+ const description = tool.summary ?? tool.description;
28
+ if (description !== void 0) definition.description = description;
29
+ if (tool.parameters !== void 0) definition.parameters = tool.parameters;
30
+ return definition;
31
+ }
32
+ //#endregion
2
33
  //#region src/core/validators.ts
3
34
  /**
4
- * Determine whether an unknown value is structurally a {@link ToolCall}.
35
+ * Determines whether an unknown value is structurally a {@link ToolCall}.
5
36
  *
6
37
  * @remarks
7
38
  * This total guard accepts a plain record with string `id` and `name` fields and a
@@ -9,7 +40,7 @@ import { attempt, holds, isArray, isRecord, isString } from "@orkestrel/contract
9
40
  * read or verified. Adversarial values return `false`.
10
41
  *
11
42
  * @param value - The value to test
12
- * @returns `true` when the value has the complete tool-call shape
43
+ * @returns True if the value has the complete tool-call shape; false otherwise
13
44
  *
14
45
  * @example
15
46
  * ```ts
@@ -25,7 +56,7 @@ function isToolCall(value) {
25
56
  //#endregion
26
57
  //#region src/core/tools/Tool.ts
27
58
  /**
28
- * An executable tool definition bound to a handler.
59
+ * Binds an executable tool definition to a handler.
29
60
  *
30
61
  * @remarks
31
62
  * Schema fields, arguments, and present caller context are forwarded by reference.
@@ -68,14 +99,15 @@ var Tool = class {
68
99
  //#endregion
69
100
  //#region src/core/tools/ToolManager.ts
70
101
  /**
71
- * An insertion-ordered tool registry with per-call error isolation.
102
+ * Represents an insertion-ordered tool registry with per-call error isolation.
72
103
  *
73
104
  * @remarks
74
105
  * A repeated name overwrites the registered tool without changing its insertion
75
106
  * position. Definitions advertise `summary` in place of `description` when present.
76
- * Unknown names and handler throws resolve to error results; batch execution preserves
77
- * input order and never fails as a whole because of an individual call. Optional
78
- * consumer-asserted caller context is forwarded without verification.
107
+ * Unknown names and handler throws resolve to error results; a call whose `id` or `name`
108
+ * accessor throws when read makes its call, and the batch holding it, reject. Batch
109
+ * execution preserves input order and isolates each call whose members are plain
110
+ * values. Optional consumer-asserted caller context is forwarded without verification.
79
111
  *
80
112
  * @example
81
113
  * ```ts
@@ -109,7 +141,7 @@ var ToolManager = class {
109
141
  return [...this.#tools.values()];
110
142
  }
111
143
  definitions() {
112
- return [...this.#tools.values()].map((tool) => this.#definition(tool));
144
+ return [...this.#tools.values()].map((tool) => toolToDefinition(tool));
113
145
  }
114
146
  execute(call) {
115
147
  if (isArray(call)) return Promise.all(call.map((one) => this.#run(one)));
@@ -117,8 +149,8 @@ var ToolManager = class {
117
149
  }
118
150
  remove(names) {
119
151
  if (isArray(names)) {
120
- let removed = false;
121
- for (const name of names) if (this.#tools.delete(name)) removed = true;
152
+ let removed = true;
153
+ for (const name of names) if (!this.#tools.delete(name)) removed = false;
122
154
  return removed;
123
155
  }
124
156
  return this.#tools.delete(names);
@@ -153,18 +185,11 @@ var ToolManager = class {
153
185
  };
154
186
  }
155
187
  }
156
- #definition(tool) {
157
- const definition = { name: tool.name };
158
- const description = tool.summary ?? tool.description;
159
- if (description !== void 0) definition.description = description;
160
- if (tool.parameters !== void 0) definition.parameters = tool.parameters;
161
- return definition;
162
- }
163
188
  };
164
189
  //#endregion
165
190
  //#region src/core/factories.ts
166
191
  /**
167
- * Create an executable tool.
192
+ * Creates an executable tool.
168
193
  *
169
194
  * @param options - The advertised definition and execution handler
170
195
  * @returns A tool bound to the supplied handler
@@ -184,7 +209,7 @@ function createTool(options) {
184
209
  return new Tool(options);
185
210
  }
186
211
  /**
187
- * Create an empty tool registry.
212
+ * Creates an empty tool registry.
188
213
  *
189
214
  * @returns A registry that advertises definitions and executes calls with per-call
190
215
  * error isolation
@@ -206,6 +231,6 @@ function createToolManager() {
206
231
  return new ToolManager();
207
232
  }
208
233
  //#endregion
209
- export { Tool, ToolManager, createTool, createToolManager, isToolCall };
234
+ export { Tool, ToolManager, createTool, createToolManager, isToolCall, toolToDefinition };
210
235
 
211
236
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["#execute","#tools","#run"],"sources":["../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/tools/Tool.ts","../../../src/core/tools/ToolManager.ts","../../../src/core/factories.ts"],"sourcesContent":["import type { ToolDefinition, ToolInterface } from './types.js'\n\n/**\n * Projects a tool onto the plain definition advertised to a caller.\n *\n * @remarks\n * The projection is a fresh object carrying `name`, then `description` only when the\n * tool authored a summary or a description, then `parameters` only when the tool\n * authored a schema. An authored `summary` is advertised in place of the full\n * `description`, which stays on the tool for direct lookup. The parameter schema is\n * copied by reference and never cloned, so the definition is never a live handle on\n * the tool's handler.\n *\n * @param tool - The tool to project\n * @returns A fresh definition carrying only the fields the tool authored\n *\n * @example\n * ```ts\n * import { Tool, toolToDefinition } from '@orkestrel/tool'\n *\n * const echo = new Tool({ name: 'echo', summary: 'Echo a value.', execute: (args) => args.value })\n * toolToDefinition(echo) // { name: 'echo', description: 'Echo a value.' }\n * ```\n */\nexport function toolToDefinition(tool: ToolInterface): ToolDefinition {\n\tconst definition: {\n\t\tname: string\n\t\tdescription?: string\n\t\tparameters?: Readonly<Record<string, unknown>>\n\t} = {\n\t\tname: tool.name,\n\t}\n\tconst description = tool.summary ?? tool.description\n\tif (description !== undefined) definition.description = description\n\tif (tool.parameters !== undefined) definition.parameters = tool.parameters\n\treturn definition\n}\n","import type { ToolCall } from './types.js'\nimport { holds, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Determines whether an unknown value is structurally a {@link ToolCall}.\n *\n * @remarks\n * This total guard accepts a plain record with string `id` and `name` fields and a\n * plain-record `arguments` field. Optional caller context remains opaque and is not\n * read or verified. Adversarial values return `false`.\n *\n * @param value - The value to test\n * @returns True if the value has the complete tool-call shape; false otherwise\n *\n * @example\n * ```ts\n * import { isToolCall } from '@orkestrel/tool'\n *\n * isToolCall({ id: '1', name: 'search', arguments: { query: 'birds' } }) // true\n * isToolCall({ id: '1', name: 'search', arguments: [] }) // false\n * ```\n */\nexport function isToolCall(value: unknown): value is ToolCall {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) && isString(value.id) && isString(value.name) && isRecord(value.arguments),\n\t)\n}\n","import type { ToolInterface, ToolOptions } from '../types.js'\n\n/**\n * Binds an executable tool definition to a handler.\n *\n * @remarks\n * Schema fields, arguments, and present caller context are forwarded by reference.\n * Caller context is consumer-asserted and is not verified. Handler failures are not\n * caught here; {@link ToolManager} owns per-call error isolation.\n *\n * @example\n * ```ts\n * import { Tool } from '@orkestrel/tool'\n *\n * const tool = new Tool({\n * \tname: 'add',\n * \tdescription: 'Add two numbers',\n * \tparameters: {\n * \t\ttype: 'object',\n * \t\tproperties: { a: { type: 'number' }, b: { type: 'number' } },\n * \t},\n * \texecute: (args) => Number(args.a) + Number(args.b),\n * })\n * ```\n */\nexport class Tool implements ToolInterface {\n\treadonly name: string\n\treadonly description?: string\n\treadonly summary?: string\n\treadonly parameters?: Readonly<Record<string, unknown>>\n\treadonly #execute: (\n\t\targs: Readonly<Record<string, unknown>>,\n\t\tcaller?: unknown,\n\t) => Promise<unknown> | unknown\n\n\tconstructor(options: ToolOptions) {\n\t\tthis.name = options.name\n\t\tif (options.description !== undefined) this.description = options.description\n\t\tif (options.summary !== undefined) this.summary = options.summary\n\t\tif (options.parameters !== undefined) this.parameters = options.parameters\n\t\tthis.#execute = options.execute\n\t}\n\n\texecute(args: Readonly<Record<string, unknown>>, caller?: unknown): Promise<unknown> | unknown {\n\t\tif (caller === undefined) return this.#execute(args)\n\t\treturn this.#execute(args, caller)\n\t}\n}\n","import type {\n\tToolCall,\n\tToolDefinition,\n\tToolInterface,\n\tToolManagerInterface,\n\tToolResult,\n} from '../types.js'\nimport { attempt, isArray } from '@orkestrel/contract'\nimport { toolToDefinition } from '../helpers.js'\n\n/**\n * Represents an insertion-ordered tool registry with per-call error isolation.\n *\n * @remarks\n * A repeated name overwrites the registered tool without changing its insertion\n * position. Definitions advertise `summary` in place of `description` when present.\n * Unknown names and handler throws resolve to error results; a call whose `id` or `name`\n * accessor throws when read makes its call, and the batch holding it, reject. Batch\n * execution preserves input order and isolates each call whose members are plain\n * values. Optional consumer-asserted caller context is forwarded without verification.\n *\n * @example\n * ```ts\n * import { Tool, ToolManager } from '@orkestrel/tool'\n *\n * const tools = new ToolManager()\n * tools.add(new Tool({ name: 'add', execute: (args) => Number(args.x) + Number(args.y) }))\n * const result = await tools.execute({\n * \tid: '1',\n * \tname: 'add',\n * \targuments: { x: 1, y: 2 },\n * })\n * ```\n */\nexport class ToolManager implements ToolManagerInterface {\n\treadonly #tools = new Map<string, ToolInterface>()\n\n\tget count(): number {\n\t\treturn this.#tools.size\n\t}\n\n\tadd(tool: ToolInterface): void\n\tadd(tools: readonly ToolInterface[]): void\n\tadd(tools: ToolInterface | readonly ToolInterface[]): void {\n\t\tif (isArray(tools)) {\n\t\t\tfor (const tool of tools) this.#tools.set(tool.name, tool)\n\t\t\treturn\n\t\t}\n\t\tthis.#tools.set(tools.name, tools)\n\t}\n\n\ttool(name: string): ToolInterface | undefined {\n\t\treturn this.#tools.get(name)\n\t}\n\n\ttools(): readonly ToolInterface[] {\n\t\treturn [...this.#tools.values()]\n\t}\n\n\tdefinitions(): readonly ToolDefinition[] {\n\t\treturn [...this.#tools.values()].map((tool) => toolToDefinition(tool))\n\t}\n\n\texecute(call: ToolCall): Promise<ToolResult>\n\texecute(calls: readonly ToolCall[]): Promise<readonly ToolResult[]>\n\texecute(call: ToolCall | readonly ToolCall[]): Promise<ToolResult | readonly ToolResult[]> {\n\t\tif (isArray(call)) return Promise.all(call.map((one) => this.#run(one)))\n\t\treturn this.#run(call)\n\t}\n\n\tremove(name: string): boolean\n\tremove(names: readonly string[]): boolean\n\tremove(names: string | readonly string[]): boolean {\n\t\tif (isArray(names)) {\n\t\t\tlet removed = true\n\t\t\tfor (const name of names) {\n\t\t\t\tif (!this.#tools.delete(name)) removed = false\n\t\t\t}\n\t\t\treturn removed\n\t\t}\n\t\treturn this.#tools.delete(names)\n\t}\n\n\tclear(): void {\n\t\tthis.#tools.clear()\n\t}\n\n\tasync #run(call: ToolCall): Promise<ToolResult> {\n\t\tconst tool = this.#tools.get(call.name)\n\t\tif (tool === undefined) {\n\t\t\treturn {\n\t\t\t\tid: call.id,\n\t\t\t\tname: call.name,\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `tool not found: ${call.name}`,\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tconst caller = call.caller\n\t\t\tconst value = await (caller === undefined\n\t\t\t\t? tool.execute(call.arguments)\n\t\t\t\t: tool.execute(call.arguments, caller))\n\t\t\treturn { id: call.id, name: call.name, success: true, value }\n\t\t} catch (error) {\n\t\t\tconst message = attempt(() =>\n\t\t\t\terror instanceof Error ? String(error.message) : String(error),\n\t\t\t)\n\t\t\treturn {\n\t\t\t\tid: call.id,\n\t\t\t\tname: call.name,\n\t\t\t\tsuccess: false,\n\t\t\t\terror: message.success ? message.value : 'Unknown thrown value',\n\t\t\t}\n\t\t}\n\t}\n}\n","import type { ToolInterface, ToolManagerInterface, ToolOptions } from './types.js'\nimport { Tool } from './tools/Tool.js'\nimport { ToolManager } from './tools/ToolManager.js'\n\n/**\n * Creates an executable tool.\n *\n * @param options - The advertised definition and execution handler\n * @returns A tool bound to the supplied handler\n *\n * @example\n * ```ts\n * import { createTool } from '@orkestrel/tool'\n *\n * const add = createTool({\n * \tname: 'add',\n * \tdescription: 'Add two numbers',\n * \texecute: (args) => Number(args.a) + Number(args.b),\n * })\n * ```\n */\nexport function createTool(options: ToolOptions): ToolInterface {\n\treturn new Tool(options)\n}\n\n/**\n * Creates an empty tool registry.\n *\n * @returns A registry that advertises definitions and executes calls with per-call\n * error isolation\n *\n * @example\n * ```ts\n * import { createTool, createToolManager } from '@orkestrel/tool'\n *\n * const tools = createToolManager()\n * tools.add(createTool({ name: 'echo', execute: (args) => args.value }))\n * const result = await tools.execute({\n * \tid: '1',\n * \tname: 'echo',\n * \targuments: { value: 'hello' },\n * })\n * ```\n */\nexport function createToolManager(): ToolManagerInterface {\n\treturn new ToolManager()\n}\n"],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orkestrel/tool",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "The tool runtime for the @orkestrel line — JSON-Schema tool definitions, calls, results, executable tools, and a registry with per-call error isolation. Part of the @orkestrel line.",
5
5
  "keywords": [
6
6
  "agent",
@@ -52,33 +52,38 @@
52
52
  "format": "oxfmt --config .oxfmtrc.json --write .",
53
53
  "format:check": "oxfmt --config .oxfmtrc.json --check .",
54
54
  "lint:check": "oxlint --config .oxlintrc.json --deny-warnings .",
55
- "test": "npm run test:src && npm run test:policy && npm run test:config && npm run test:guides",
55
+ "test": "npm run test:src && npm run test:policy && npm run test:config && npm run test:setup && npm run test:guides",
56
56
  "test:src": "vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core",
57
57
  "test:src:core": "vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core",
58
58
  "test:policy": "vitest run --config vite.config.ts --no-cache --reporter=dot --project policy",
59
59
  "test:config": "vitest run --config vite.config.ts --no-cache --reporter=dot --project config",
60
- "test:guides": "vitest run --config vite.config.ts --reporter=dot --project guides",
60
+ "test:guides": "vitest run --config vite.config.ts --no-cache --reporter=dot --project guides",
61
61
  "build": "npm run clean && npm run build:src",
62
62
  "build:src": "npm run build:src:core",
63
63
  "build:src:core": "vite build --config configs/src/vite.core.config.ts && npm run copy dist/src/core/index.d.ts dist/src/core/index.d.cts",
64
- "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test"
64
+ "prepublishOnly": "npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:distribution -- --mode release",
65
+ "test:distribution": "vitest run --config vite.config.ts --no-cache --reporter=dot --project distribution",
66
+ "test:probe": "vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe",
67
+ "test:bench": "vitest bench --config vite.config.ts --no-cache --project probe",
68
+ "prepack": "npm run build",
69
+ "test:setup": "vitest run --config vite.config.ts --no-cache --reporter=dot --project setup"
65
70
  },
66
71
  "dependencies": {
67
- "@orkestrel/contract": "^0.0.12"
72
+ "@orkestrel/contract": "^0.0.16"
68
73
  },
69
74
  "devDependencies": {
70
- "@microsoft/api-extractor": "^7.58.12",
71
- "@orkestrel/guide": "^0.0.11",
72
- "@orkestrel/scaffold": "^0.0.38",
73
- "@orkestrel/test": "^0.0.6",
74
- "@types/node": "^26.1.2",
75
- "@vitest/browser-playwright": "^4.1.10",
76
- "oxfmt": "^0.62.0",
77
- "oxlint": "^1.77.0",
75
+ "@microsoft/api-extractor": "^7.59.0",
76
+ "@orkestrel/guide": "^0.0.16",
77
+ "@orkestrel/probe": "^0.0.11",
78
+ "@orkestrel/scaffold": "^0.0.61",
79
+ "@orkestrel/test": "^0.0.13",
80
+ "@types/node": "^26.4.1",
81
+ "oxfmt": "^0.66.0",
82
+ "oxlint": "^1.81.0",
78
83
  "typescript": "^6.0.3",
79
- "vite": "^8.2.1",
80
- "vite-plugin-dts": "^5.0.3",
81
- "vitest": "^4.1.10"
84
+ "vite": "^8.2.2",
85
+ "vite-plugin-dts": "^5.1.0",
86
+ "vitest": "^4.1.11"
82
87
  },
83
88
  "engines": {
84
89
  "node": ">=22.12.0"