@orkestrel/toolbox 0.0.11 → 0.0.12

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.
@@ -14,6 +14,7 @@ import { Include } from '@orkestrel/relation';
14
14
  import { IndexMap } from '@orkestrel/database';
15
15
  import { JSONShape } from '@orkestrel/contract';
16
16
  import { KeyFunction } from '@orkestrel/database';
17
+ import { LifecycleStatus } from '@orkestrel/workflow';
17
18
  import { LiteralShape } from '@orkestrel/contract';
18
19
  import { ModelInterface } from '@orkestrel/relation';
19
20
  import { NumberShape } from '@orkestrel/contract';
@@ -34,21 +35,20 @@ import { UnionShape } from '@orkestrel/contract';
34
35
  import { WorkflowDefinition } from '@orkestrel/workflow';
35
36
  import { WorkflowFault } from '@orkestrel/workflow';
36
37
  import { WorkflowFunction } from '@orkestrel/workflow';
37
- import { WorkflowFunctions } from '@orkestrel/workflow';
38
+ import { WorkflowRegistry } from '@orkestrel/workflow';
38
39
  import { WorkflowResult } from '@orkestrel/workflow';
39
40
  import { WorkflowRunnerInterface } from '@orkestrel/workflow';
40
- import { WorkflowStatus } from '@orkestrel/workflow';
41
41
  import { WorkflowStoreInterface } from '@orkestrel/workflow';
42
42
  import { WorkspaceManagerInterface } from '@orkestrel/workspace';
43
43
  import { WorkspaceStoreInterface } from '@orkestrel/workspace';
44
44
 
45
45
  /**
46
- * The maximum nesting depth a delegation chain (agent tool → sub-agent → agent tool → …) may
46
+ * Holds the maximum nesting depth a delegation chain (agent tool → sub-agent → agent tool → …) may
47
47
  * reach — the bound {@link import('./factories.js').createAgentTool}'s depth/cycle guard
48
48
  * enforces.
49
49
  *
50
50
  * @remarks
51
- * Deliberately a SEPARATE constant from {@link MAX_WORKFLOW_DEPTH} (rather than the two guards
51
+ * Deliberately a SEPARATE constant from {@link MAX_WORKFLOW_CHAIN} (rather than the two guards
52
52
  * sharing one reference): the two guards bound DIFFERENT chains (workflow nesting vs. agent
53
53
  * delegation) that happen to share a value today, and keeping this bound decoupled means a
54
54
  * future change to one never silently shifts the other. Same numeric value by convention, not
@@ -57,34 +57,34 @@ import { WorkspaceStoreInterface } from '@orkestrel/workspace';
57
57
  export declare const AGENT_TOOL_DEPTH = 8;
58
58
 
59
59
  /**
60
- * The description {@link import('./factories.js').createAgentTool} advertises — a short guide
60
+ * Holds the description {@link import('./factories.js').createAgentTool} advertises — a short guide
61
61
  * covering the required task and optional provider, tools, and system overrides.
62
62
  */
63
63
  export declare const AGENT_TOOL_DESCRIPTION: string;
64
64
 
65
65
  /**
66
- * The name {@link import('./factories.js').createAgentTool} advertises by default — the key a
66
+ * Holds the name {@link import('./factories.js').createAgentTool} advertises by default — the key a
67
67
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
68
68
  */
69
69
  export declare const AGENT_TOOL_NAME = "agent";
70
70
 
71
71
  /**
72
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createAgentTool}
72
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createAgentTool}
73
73
  * advertises in place of {@link AGENT_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
74
74
  * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
75
- * for the full teaching description; the full text stays retrievable via
75
+ * for the full teaching description; the full text stays retrievable through
76
76
  * {@link import('./factories.js').createDescribeTool}.
77
77
  */
78
78
  export declare const AGENT_TOOL_SUMMARY = "Delegate a task to a sub-agent and return its result; each call runs one sub-agent turn to completion. Call describe('agent') for the optional provider/tools/system overrides.";
79
79
 
80
- /** A contextual agent adapter carrying immutable metadata for Toolbox composition. */
80
+ /** Represents a contextual agent adapter carrying immutable metadata for Toolbox composition. */
81
81
  export declare type AgentFunction = WorkflowFunction & {
82
82
  readonly category: 'agent';
83
83
  readonly lineage: WorkflowLineage;
84
84
  };
85
85
 
86
86
  /**
87
- * Options for {@link import('./factories.js').createAgentFunction} — the OPT-IN adapter that
87
+ * Represents the options for {@link import('./factories.js').createAgentFunction} — the OPT-IN adapter that
88
88
  * wraps a live `AgentInterface` (`@orkestrel/agent`) as an {@link AgentFunction} with immutable
89
89
  * lineage metadata and optional nested-workflow composition.
90
90
  *
@@ -103,27 +103,13 @@ export declare type AgentFunction = WorkflowFunction & {
103
103
  export declare interface AgentFunctionOptions {
104
104
  readonly runner?: WorkflowRunnerInterface;
105
105
  readonly lineage?: WorkflowLineage;
106
- readonly functions?: WorkflowFunctions;
106
+ readonly functions?: WorkflowRegistry;
107
107
  readonly agents?: WorkflowAgents;
108
108
  readonly store?: WorkflowStoreInterface;
109
109
  }
110
110
 
111
111
  /**
112
- * The ancestry identifier of an agent in a run chain — `agent:<name>`.
113
- *
114
- * @remarks
115
- * The agent counterpart of {@link workflowTag}: {@link import('./factories.js').createAgentFunction}
116
- * / {@link import('./factories.js').createWorkflowTool} guard against re-entering an agent or
117
- * workflow already in the chain (this package's typed `DEPTH` `ToolboxError`). The
118
- * `agent:` namespace keeps it distinct from a same-string workflow id.
119
- *
120
- * @param name - The agent's identifier / registry name
121
- * @returns The namespaced ancestry tag (`agent:<name>`)
122
- */
123
- export declare function agentTag(name: string): string;
124
-
125
- /**
126
- * The FLAT args {@link import('./factories.js').createAgentTool} accepts — a delegated `task`
112
+ * Represents the FLAT args {@link import('./factories.js').createAgentTool} accepts — a delegated `task`
127
113
  * plus the minimal optional `AgentJobInput` (`@orkestrel/agent`) fields a caller may override
128
114
  * per-call.
129
115
  *
@@ -140,7 +126,7 @@ export declare interface AgentToolArguments {
140
126
  }
141
127
 
142
128
  /**
143
- * Options for {@link import('./factories.js').createAgentTool} — the sub-agent delegation
129
+ * Represents the options for {@link import('./factories.js').createAgentTool} — the sub-agent delegation
144
130
  * defaults, the nesting-depth / cycle guard bookkeeping, and the advertised tool overrides.
145
131
  *
146
132
  * @remarks
@@ -166,7 +152,7 @@ export declare interface AgentToolArguments {
166
152
  * audit log rather than colliding). Omitted ⇒ no persistence from this tool.
167
153
  *
168
154
  * Conversation persistence for a delegated sub-agent has TWO independent seams, composable
169
- * together: this `store` slot persists EACH delegation's conversation individually, and/or an
155
+ * together: this `store` slot persists EACH delegation's conversation individually, and an
170
156
  * `AgentRegistryInterface` built with `AgentRegistryOptions.store` (`@orkestrel/agent`) backs
171
157
  * EVERY agent it builds — including ones built through this tool — with a store-backed
172
158
  * `ConversationManagerInterface` of its own. Neither is required; either or both may be used.
@@ -183,7 +169,7 @@ export declare interface AgentToolOptions {
183
169
  }
184
170
 
185
171
  /**
186
- * The shape of {@link import('./types.js').AgentToolArguments} —
172
+ * Describes the shape of {@link import('./types.js').AgentToolArguments} —
187
173
  * {@link import('./factories.js').createAgentTool}'s advertised `parameters`.
188
174
  *
189
175
  * @remarks
@@ -197,32 +183,32 @@ export declare const agentToolShape: ObjectShape<{
197
183
  system: OptionalShape<StringShape>;
198
184
  }, false>;
199
185
 
200
- /** The pending/answer protocol {@link import('./factories.js').createAnswerTool} advertises. */
186
+ /** Holds the pending/answer protocol {@link import('./factories.js').createAnswerTool} advertises. */
201
187
  export declare const ANSWER_TOOL_DESCRIPTION: string;
202
188
 
203
189
  /**
204
- * The name {@link import('./factories.js').createAnswerTool} advertises by default — the key a
190
+ * Holds the name {@link import('./factories.js').createAnswerTool} advertises by default — the key a
205
191
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
206
192
  */
207
193
  export declare const ANSWER_TOOL_NAME = "answer";
208
194
 
209
195
  /**
210
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createAnswerTool}
196
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createAnswerTool}
211
197
  * advertises in place of {@link ANSWER_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
212
198
  * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
213
- * for the full teaching description; the full text stays retrievable via
199
+ * for the full teaching description; the full text stays retrievable through
214
200
  * {@link import('./factories.js').createDescribeTool}.
215
201
  */
216
202
  export declare const ANSWER_TOOL_SUMMARY = "List forms addressed to this terminal, or answer one by id with a values record. Call describe('answer') for the required fields.";
217
203
 
218
204
  /**
219
- * Options for {@link import('./factories.js').createAnswerTool} — the live
205
+ * Represents the options for {@link import('./factories.js').createAnswerTool} — the live
220
206
  * {@link TerminalManagerInterface} (`@orkestrel/terminal`) to list / answer prompts through, the
221
207
  * terminal name `to`, and the advertised tool overrides.
222
208
  *
223
209
  * @remarks
224
210
  * - `manager` — the terminal manager whose `pending(to)` / `answer(to, id, values)` the tool's
225
- * handler calls — `pending` lists the forms currently addressed to `to`, `answer` resolves
211
+ * handler calls — `pending` lists the forms addressed to `to`, `answer` resolves
226
212
  * one by `id`. A failed `answer` (`TerminalAnswerError`) re-surfaces as a typed
227
213
  * `ANSWER` {@link import('./errors.js').ToolboxError}.
228
214
  * - `to` — the terminal identity this tool lists / answers prompts FOR.
@@ -237,7 +223,7 @@ export declare interface AnswerToolOptions {
237
223
  }
238
224
 
239
225
  /**
240
- * The shape of {@link import('./factories.js').createAnswerTool}'s call arguments — discriminated
226
+ * Describes the shape of {@link import('./factories.js').createAnswerTool}'s call arguments — discriminated
241
227
  * by `operation`: `'pending'` lists the forms addressed to this tool's terminal, while `'answer'`
242
228
  * resolves one by `id` with a complete `values` record.
243
229
  *
@@ -254,13 +240,26 @@ export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
254
240
  }, false>]>;
255
241
 
256
242
  /**
257
- * Clamp a `'records'` call's query to a row cap, and build the PROBE query the caller reads
243
+ * Represents the PROBE query and effective row limit {@link import('./helpers.js').clampQuery} returns.
244
+ *
245
+ * @remarks
246
+ * `limit` is the effective ceiling — `min(query?.limit ?? cap, cap)`, floored at `0`. `query`
247
+ * requests one row MORE than that, so a caller detects truncation from the returned row count
248
+ * without a separate `count` round trip.
249
+ */
250
+ export declare interface ClampedQuery {
251
+ readonly query: QueryInput;
252
+ readonly limit: number;
253
+ }
254
+
255
+ /**
256
+ * Clamps a `'records'` call's query to a row cap, and builds the PROBE query the caller reads
258
257
  * with — the pure leaf {@link import('./factories.js').createDatabaseTool}'s `'records'` operation
259
258
  * uses to detect truncation without a separate `count` round trip.
260
259
  *
261
260
  * @remarks
262
- * The effective limit is `min(query?.limit ?? cap, cap)`, floored at `0` (so a caller can never
263
- * exceed the configured cap by supplying a larger `query.limit`). The returned probe query
261
+ * {@link resolveLimit} picks the effective limit, so a caller can never exceed the configured cap
262
+ * by supplying a larger `query.limit`, and can never drive it below `0`. The returned probe query
264
263
  * requests ONE MORE row than the effective limit (`limit: effective + 1`) — if storage returns
265
264
  * that many, the caller knows the true result was truncated (`rows.length > effective`) and slices
266
265
  * back down to `effective` before returning.
@@ -279,38 +278,50 @@ export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
279
278
  * @param cap - The row-count ceiling
280
279
  * @returns The PROBE query (`limit` bumped by one) and the effective `limit`
281
280
  */
282
- export declare function clampQuery(query: QueryInput | undefined, cap: number): Readonly<{
283
- query: QueryInput;
284
- limit: number;
285
- }>;
281
+ export declare function clampQuery(query: QueryInput | undefined, cap: number): ClampedQuery;
286
282
 
287
- /** One column's declared type — a primitive shorthand, or `integer` for a whole-number `number`. */
288
- export declare type ColumnKind = 'string' | 'integer' | 'number' | 'boolean';
283
+ /** Represents one column's declared primitive — a shorthand, or `integer` for a whole-number `number`. */
284
+ export declare type ColumnPrimitive = 'string' | 'integer' | 'number' | 'boolean';
289
285
 
290
- /** A {@link import('./types.js').ColumnKind} literal — the leaf {@link columnSpecShape} wraps. */
291
- export declare const columnKindShape: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
292
-
293
- /** Compile one {@link ColumnSpec} into its `@orkestrel/database` column shape — the per-column leaf {@link expandTables} maps over. */
294
- export declare function columnShape(spec: ColumnSpec): ContractShape;
286
+ /** Describes a {@link import('./types.js').ColumnPrimitive} literal — the leaf {@link columnSpecShape} wraps. */
287
+ export declare const columnPrimitiveShape: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
295
288
 
296
289
  /**
297
- * One table column's spec — either a bare {@link ColumnKind} shorthand, or `{ type, optional }`
298
- * when the column may be absent from a row.
290
+ * Represents one table column's spec — either a bare {@link ColumnPrimitive} shorthand, or
291
+ * `{ primitive, optional }` when the column may be absent from a row.
299
292
  */
300
- export declare type ColumnSpec = ColumnKind | Readonly<{
301
- type: ColumnKind;
293
+ export declare type ColumnSpec = ColumnPrimitive | Readonly<{
294
+ primitive: ColumnPrimitive;
302
295
  optional?: boolean;
303
296
  }>;
304
297
 
305
- /** A {@link import('./types.js').ColumnSpec} — a bare {@link columnKindShape}, or `{ type, optional }`. */
298
+ /** Describes a {@link import('./types.js').ColumnSpec} — a bare {@link columnPrimitiveShape}, or `{ primitive, optional }`. */
306
299
  export declare const columnSpecShape: UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
307
- type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
300
+ primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
308
301
  optional: OptionalShape<BooleanShape>;
309
302
  }, false>]>;
310
303
 
311
304
  /**
312
- * Complete a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesize any
313
- * MISSING `id` deterministically + positionally, and default any MISSING `name` to its
305
+ * Compiles one {@link ColumnSpec} into its `@orkestrel/database` column shape — the per-column leaf
306
+ * {@link expandTables} maps over.
307
+ *
308
+ * @param spec - The column spec to compile
309
+ * @returns The `@orkestrel/database` column shape, wrapped in `optionalShape` when the spec declares `optional: true`
310
+ */
311
+ export declare function compileColumn(spec: ColumnSpec): ContractShape;
312
+
313
+ /**
314
+ * Compiles one {@link import('./types.js').ColumnPrimitive} into its primitive
315
+ * `@orkestrel/database` shape — the leaf {@link compileColumn} wraps.
316
+ *
317
+ * @param primitive - The declared column primitive
318
+ * @returns The matching primitive `@orkestrel/database` shape
319
+ */
320
+ export declare function compileColumnPrimitive(primitive: ColumnPrimitive): ContractShape;
321
+
322
+ /**
323
+ * Completes a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesizes any
324
+ * MISSING `id` deterministically + positionally, and defaults any MISSING `name` to its
314
325
  * (now-resolved) `id`.
315
326
  *
316
327
  * @remarks
@@ -318,7 +329,7 @@ export declare const columnSpecShape: UnionShape<readonly [ LiteralShape<readonl
318
329
  * `phase-<i>`, and task `j` of that phase is `<phaseId>-task-<j>` (so a provided phase id flows
319
330
  * into its tasks' synthesized ids). A PROVIDED `id` / `name` at any level is kept VERBATIM —
320
331
  * synthesis touches only the omitted ones. A missing `name` defaults to the resolved `id` (never
321
- * the other way round), so the result always has both. `run`, `description`, the per-phase
332
+ * the other way round), so the result always has both. `behavior`, `description`, the per-phase
322
333
  * `concurrency` / `bail`, the per-task `retries` / `timeout`, and the workflow `bail` carry over
323
334
  * unchanged. The result is a complete {@link WorkflowDefinition}; the caller still validates it
324
335
  * against the STRICT contract.
@@ -329,7 +340,7 @@ export declare const columnSpecShape: UnionShape<readonly [ LiteralShape<readonl
329
340
  export declare function completeDraft(draft: WorkflowDraft): WorkflowDefinition;
330
341
 
331
342
  /**
332
- * Complete one {@link PhaseDraft} into a strict phase definition — the per-phase step of
343
+ * Completes one {@link PhaseDraft} into a strict phase definition — the per-phase step of
333
344
  * {@link completeDraft} (phase `index` → `phase-<index>` when its id is omitted).
334
345
  *
335
346
  * @param phase - The draft phase
@@ -339,7 +350,7 @@ export declare function completeDraft(draft: WorkflowDraft): WorkflowDefinition;
339
350
  export declare function completePhaseDraft(phase: PhaseDraft, index: number): WorkflowDefinition['phases'][number];
340
351
 
341
352
  /**
342
- * Complete one {@link TaskDraft} into a strict task definition — the per-task leaf step of
353
+ * Completes one {@link TaskDraft} into a strict task definition — the per-task leaf step of
343
354
  * {@link completeDraft} (task `index` of phase `<phaseId>` → `<phaseId>-task-<index>` when its id
344
355
  * is omitted).
345
356
  *
@@ -350,7 +361,7 @@ export declare function completePhaseDraft(phase: PhaseDraft, index: number): Wo
350
361
  */
351
362
  export declare function completeTaskDraft(task: TaskDraft, phaseId: string, index: number): WorkflowDefinition['phases'][number]['tasks'][number];
352
363
 
353
- /** One SERIALIZED WHERE condition — `values` is ALWAYS an array, even for a single-value operator. */
364
+ /** Describes one SERIALIZED WHERE condition — `values` is ALWAYS an array, even for a single-value operator. */
354
365
  export declare const conditionShape: ObjectShape<{
355
366
  column: StringShape;
356
367
  operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
@@ -359,7 +370,7 @@ export declare const conditionShape: ObjectShape<{
359
370
  }, false>;
360
371
 
361
372
  /**
362
- * Wrap a live `AgentInterface` (`@orkestrel/agent`) as a {@link WorkflowFunction}
373
+ * Wraps a live `AgentInterface` (`@orkestrel/agent`) as a {@link WorkflowFunction}
363
374
  * (`@orkestrel/workflow`) — the opt-in adapter that runs the agent to a settled result and carries
364
375
  * immutable lineage metadata for contextual Toolbox composition.
365
376
  *
@@ -367,7 +378,7 @@ export declare const conditionShape: ObjectShape<{
367
378
  * Composes into a caller's registry like any other behavior; the pure workflow runner has no
368
379
  * knowledge of agents itself. A root adapter derives its workflow lineage from the controller,
369
380
  * while a contextual adapter requires an exact match. Repeated agents, repeated workflows, and
370
- * targets deeper than {@link import('./constants.js').MAX_WORKFLOW_DEPTH} are rejected before
381
+ * targets deeper than {@link import('./constants.js').MAX_WORKFLOW_CHAIN} are rejected before
371
382
  * agent or runner activity. When {@link import('./types.js').AgentFunctionOptions.runner} is
372
383
  * supplied, the adapter binds a recursion-safe {@link createWorkflowTool} onto the agent's
373
384
  * `context.tools`, propagating opaque leaves, raw agents, lineage, and the native store. The
@@ -397,14 +408,14 @@ export declare const conditionShape: ObjectShape<{
397
408
  export declare function createAgentFunction(agent: AgentInterface, options?: AgentFunctionOptions): AgentFunction;
398
409
 
399
410
  /**
400
- * Build an LLM-callable sub-agent delegation tool — resolves a live, seeded `AgentInterface`
411
+ * Builds an LLM-callable sub-agent delegation tool — resolves a live, seeded `AgentInterface`
401
412
  * from `registry` and runs it to completion for ONE delegated `task`.
402
413
  *
403
414
  * @remarks
404
- * The universal tool-handler contract (AGENTS §14): validates the call args against
415
+ * The universal tool-handler contract: validates the call args against
405
416
  * {@link import('./shapers.js').agentToolShape}, assembles an `AgentJobInput` (`task` seeds the
406
417
  * sub-agent's conversation as a single `user` message; `provider` / `tools` / `system` fall
407
- * back to the tool's own {@link import('./types.js').AgentToolOptions} defaults), rehydrates the sub-agent via
418
+ * back to the tool's own {@link import('./types.js').AgentToolOptions} defaults), rehydrates the sub-agent through
408
419
  * `registry.build`, runs it with `agent.generate()`, and returns the settled
409
420
  * `AgentResult.content` string (the sub-agent's final text). A missing / unresolvable `provider`, or a malformed call, THROWS a typed `TOOL`
410
421
  * {@link import('./errors.js').ToolboxError}; a delegation that would exceed
@@ -438,16 +449,16 @@ export declare function createAgentFunction(agent: AgentInterface, options?: Age
438
449
  export declare function createAgentTool(registry: AgentRegistryInterface, options?: AgentToolOptions): ToolInterface;
439
450
 
440
451
  /**
441
- * Build an LLM-callable answer tool — the ANSWER side of the terminal seam. Lists the forms
442
- * currently addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of
452
+ * Builds an LLM-callable answer tool — the ANSWER side of the terminal seam. Lists the forms
453
+ * addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of
443
454
  * them by id.
444
455
  *
445
456
  * @remarks
446
- * The universal tool-handler contract (AGENTS §14): validates the call args against
457
+ * The universal tool-handler contract: validates the call args against
447
458
  * {@link import('./shapers.js').answerToolShape} (discriminated by `operation`). `'pending'`
448
- * returns a compact list (`{ id, from, schema }`) of every form currently addressed to `to`.
459
+ * returns a compact list (`{ id, from, schema }`) of every form addressed to `to`.
449
460
  * `'answer'` looks the form up by `id`, narrows the supplied `values` through `@orkestrel/form`,
450
- * and applies it via
461
+ * and applies it through
451
462
  * `TerminalManagerInterface.answer` — a rejected / unknown / unresolvable outcome
452
463
  * (`TerminalAnswerResult.error`) re-surfaces as a typed `ANSWER` `ToolboxError`; success returns
453
464
  * `{ answered: id }`. `to` is FIXED at construction
@@ -476,7 +487,7 @@ export declare function createAgentTool(registry: AgentRegistryInterface, option
476
487
  export declare function createAnswerTool(options: AnswerToolOptions): ToolInterface;
477
488
 
478
489
  /**
479
- * Create a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database`
490
+ * Creates a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database`
480
491
  * layer — the driver-pluggable twin of {@link createMemoryDefinitionStore}, storing each
481
492
  * database's definition as one opaque JSON column.
482
493
  *
@@ -493,15 +504,15 @@ export declare function createAnswerTool(options: AnswerToolOptions): ToolInterf
493
504
  export declare function createDatabaseDefinitionStore(driver?: DriverInterface): DefinitionStoreInterface;
494
505
 
495
506
  /**
496
- * Build an LLM-callable database tool — create, query, and mutate `@orkestrel/database`
497
- * databases through one `operation`-discriminated call (AGENTS §14, matching
507
+ * Builds an LLM-callable database tool — it creates, queries, and mutates `@orkestrel/database`
508
+ * databases through one `operation`-discriminated call (matching
498
509
  * {@link createWorkspaceTool}'s single-tool-many-operations shape).
499
510
  *
500
511
  * @remarks
501
- * The universal tool-handler contract (AGENTS §14): validates the call args against
512
+ * The universal tool-handler contract: validates the call args against
502
513
  * {@link import('./shapers.js').databaseToolShape}, dispatches to the matching operation, and
503
514
  * RETURNS a plain result on success. A database is resolved lazily and cached for the tool's
504
- * lifetime — `'create'` mints one from `tables` ({@link import('./helpers.js').expandTables}) and
515
+ * lifetime — `'create'` mints one from `tables` ({@link import('./compilers.js').expandTables}) and
505
516
  * a registered `driver` key ({@link import('./types.js').DatabaseToolOptions.drivers}, default
506
517
  * `{ memory: () => createMemoryDriver() }`); any other operation addressing an uncached id falls
507
518
  * back to {@link import('./types.js').DatabaseToolOptions.store} (an unknown id throws a typed
@@ -510,10 +521,10 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
510
521
  *
511
522
  * `'records'` clamps its `query` to
512
523
  * {@link import('./types.js').DatabaseToolOptions.limit} (default
513
- * {@link import('./constants.js').DATABASE_TOOL_LIMIT}) via
524
+ * {@link import('./constants.js').DATABASE_TOOL_LIMIT}) through
514
525
  * {@link import('./helpers.js').clampQuery}, reporting `truncated` when storage held more rows
515
- * than the cap. Every operation's `query` is normalized via
516
- * {@link import('./helpers.js').queryOf} (defaults an omitted condition `connector` to `'and'`).
526
+ * than the cap. Every operation's `query` is normalized through
527
+ * {@link import('./helpers.js').normalizeQuery} (defaults an omitted condition `connector` to `'and'`).
517
528
  * When {@link import('./types.js').DatabaseToolOptions.readonly} is `true`, every mutating
518
529
  * operation throws a typed `TOOL` `ToolboxError` before doing anything. A configured
519
530
  * {@link import('./types.js').DatabaseToolOptions.timeout} is passed as a fresh
@@ -522,7 +533,7 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
522
533
  * not an outer deadline for resolution, construction, schema inspection, `get`, or `close`. A typed `@orkestrel/database`
523
534
  * failure (`DatabaseError`) re-surfaces as a typed `DATABASE` `ToolboxError` carrying the
524
535
  * original {@link import('@orkestrel/database').DatabaseErrorCode} in `context.code`
525
- * ({@link import('./helpers.js').databaseToolCode}); an `ToolboxError` thrown by this tool's own
536
+ * ({@link import('./helpers.js').inferDatabaseCode}); an `ToolboxError` thrown by this tool's own
526
537
  * guards passes through unwrapped.
527
538
  *
528
539
  * A lazily re-minted database over the DEFAULT in-memory driver yields an EMPTY database — only
@@ -555,7 +566,7 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
555
566
  export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolInterface;
556
567
 
557
568
  /**
558
- * Build an LLM-callable tool that returns the FULL `description` of another registered tool by
569
+ * Builds an LLM-callable tool that returns the FULL `description` of another registered tool by
559
570
  * name — the counterpart to the lean `summary` the other tools in this package advertise
560
571
  * (`AGENT_TOOL_SUMMARY` / `WORKFLOW_TOOL_SUMMARY` / `WORKSPACE_TOOL_SUMMARY`).
561
572
  *
@@ -564,10 +575,10 @@ export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolI
564
575
  * tool.description` — a lean one-sentence summary stands in for a tool's full teaching
565
576
  * description when `summary` is set, keeping the advertised tool list compact for a small model.
566
577
  * This tool is the on-demand expansion seam: given a registered tool's `name`, it looks the tool
567
- * up via `tools.tool(name)` and returns its full `description` (falling back to `summary` when a
578
+ * up through `tools.tool(name)` and returns its full `description` (falling back to `summary` when a
568
579
  * tool has no `description` of its own, then a placeholder when it has neither).
569
580
  *
570
- * The universal tool-handler contract (AGENTS §14): validates the call args against
581
+ * The universal tool-handler contract: validates the call args against
571
582
  * {@link import('./shapers.js').describeToolShape}, RETURNS the plain description string on
572
583
  * success, THROWS a typed `TOOL` {@link import('./errors.js').ToolboxError} on a malformed call
573
584
  * or an unknown tool name.
@@ -591,32 +602,32 @@ export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolI
591
602
  export declare function createDescribeTool(tools: ToolManagerInterface): ToolInterface;
592
603
 
593
604
  /**
594
- * Wrap one CONCRETE endpoint ({@link import('./types.js').EndpointDefinition}) as an LLM-callable
605
+ * Wraps one CONCRETE endpoint ({@link import('./types.js').EndpointDefinition}) as an LLM-callable
595
606
  * `ToolInterface` — the endpoint half of the "existing API/DB → MCP tool" bridge (the other half,
596
607
  * {@link createInferTool}, is a standalone inference utility).
597
608
  *
598
609
  * @remarks
599
- * `parameters` is inferred ONCE at construction from `definition.samples` via
610
+ * `parameters` is inferred ONCE at construction from `definition.samples` through
600
611
  * `@orkestrel/contract`'s `samplesToSchema` (tuned by {@link import('./types.js').EndpointToolOptions}'s
601
- * `format` / `enum`), wrapping a non-object root as `{ value: <schema> }` via `schemaToObject` —
612
+ * `format` / `enum`), wrapping a non-object root as `{ value: <schema> }` through `schemaToObject` —
602
613
  * the SAME object-rooted schema is both the ADVERTISED `parameters` and, by default
603
614
  * ({@link import('./types.js').EndpointToolOptions.validate} `true`), the ENFORCED contract:
604
- * `@orkestrel/contract` 0.0.7's `schemaToShape` compiles it ONCE (via `createContract`) into a
605
- * `ContractInterface` whose `.parse` runs on every call's `args` before `definition.invoke` — a
615
+ * `@orkestrel/contract`'s `schemaToShape` compiles it ONCE (through `createContract`) into a
616
+ * `ContractInterface` whose `.parse` runs on every call's `args` before `definition.execute` — a
606
617
  * NORMALIZING parse, not a strict type check: a scalar is COERCED to its inferred type where the
607
618
  * house parsers coerce (a number to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/
608
- * `'false'`/`1`/`0`), so `definition.invoke` receives the COERCED value (e.g. `7` sent for a
619
+ * `'false'`/`1`/`0`), so `definition.execute` receives the COERCED value (for example `7` sent for a
609
620
  * string slot arrives as `'7'`), not the raw call value. A call whose `args` fails to parse into
610
621
  * a record — a required key missing, or a value not coercible to its slot's type — THROWS a
611
622
  * typed `TOOL` {@link import('./errors.js').ToolboxError} carrying the compiled contract's
612
- * structured `explain` faults, and `definition.invoke` is never called. `format` annotations are
623
+ * structured `explain` faults, and `definition.execute` is never called. `format` annotations are
613
624
  * NEVER asserted, and a key outside the closed inferred schema is SILENTLY DROPPED rather than
614
625
  * rejected (see {@link import('./types.js').EndpointToolOptions.validate}). With
615
- * `validate: false`, `execute` PASSES THROUGH the model-supplied `args` to `definition.invoke`
616
- * WITHOUT re-validation — the pre-0.0.7 behavior, preserved as an explicit opt-out. Either way,
617
- * `invoke`'s return flows back as the tool call's plain result; a throw PROPAGATES uncaught,
626
+ * `validate: false`, the tool's `execute` PASSES THROUGH the model-supplied `args` to
627
+ * `definition.execute` WITHOUT re-validation — the raw-passthrough opt-out. Either way, the
628
+ * definition's return flows back as the tool call's plain result; a throw PROPAGATES uncaught,
618
629
  * isolated by the `ToolManagerInterface` (`@orkestrel/tool`) into the canonical error envelope
619
- * (AGENTS §14) — never caught or re-wrapped here.
630
+ * — never caught or re-wrapped here.
620
631
  *
621
632
  * @param definition - The endpoint's identity, non-empty samples, and local handler (see
622
633
  * {@link import('./types.js').EndpointDefinition})
@@ -633,12 +644,12 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
633
644
  * name: 'lookupUser',
634
645
  * description: 'Look up a user by id.',
635
646
  * samples: [{ id: '1', name: 'Ada' }, { id: '2', name: 'Bob' }],
636
- * invoke: (args) => ({ id: args.id, name: 'Ada' }),
647
+ * execute: (args) => ({ id: args.id, name: 'Ada' }),
637
648
  * })
638
649
  * const tools = createToolManager()
639
650
  * tools.add(tool)
640
651
  *
641
- * // conforming args (all required keys present) parse and reach `invoke`
652
+ * // conforming args (all required keys present) parse and reach the definition's `execute`
642
653
  * const result = await tools.execute({
643
654
  * id: 'call-1',
644
655
  * name: 'lookupUser',
@@ -647,7 +658,7 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
647
658
  * // result.value -> { id: '1', name: 'Ada' }
648
659
  *
649
660
  * // a nonconforming call (id is not coercible to the required string) is rejected before
650
- * // `invoke` runs
661
+ * // the definition's `execute` runs
651
662
  * const rejected = await tools.execute({
652
663
  * id: 'call-2',
653
664
  * name: 'lookupUser',
@@ -659,15 +670,15 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
659
670
  export declare function createEndpointTool(definition: EndpointDefinition, options?: EndpointToolOptions): ToolInterface;
660
671
 
661
672
  /**
662
- * Build a standalone LLM-callable tool that infers a JSON Schema from example values — the
673
+ * Builds a standalone LLM-callable tool that infers a JSON Schema from example values — the
663
674
  * utility half of the "existing API/DB → MCP tool" bridge (the other half,
664
675
  * {@link createEndpointTool}, wraps one CONCRETE endpoint).
665
676
  *
666
677
  * @remarks
667
- * The universal tool-handler contract (AGENTS §14): validates the call args against
678
+ * The universal tool-handler contract: validates the call args against
668
679
  * {@link import('./shapers.js').inferToolShape} (`samples` non-empty, `format` / `enum` optional
669
- * booleans, `candidates` an optional array), infers a schema via `@orkestrel/contract`'s
670
- * `samplesToSchema`, wraps a non-object root as `{ value: <schema> }` via `schemaToObject` (mirrors
680
+ * booleans, `candidates` an optional array), infers a schema through `@orkestrel/contract`'s
681
+ * `samplesToSchema`, wraps a non-object root as `{ value: <schema> }` through `schemaToObject` (mirrors
671
682
  * the tool-parameters convention every other `create*Tool` factory advertises), and RETURNS the
672
683
  * resulting parameters record. An empty `samples` array fails `inferToolShape`'s `min: 1` bound —
673
684
  * `contract.parse` returns `undefined` and the handler throws a typed `TOOL`
@@ -675,7 +686,7 @@ export declare function createEndpointTool(definition: EndpointDefinition, optio
675
686
  *
676
687
  * When `candidates` is ABSENT, the return is the bare parameters record — unchanged from before
677
688
  * this array existed. When `candidates` is PRESENT (any array, including empty), the handler
678
- * compiles a SEPARATE per-call contract from the RAW inferred schema (via `@orkestrel/contract`'s
689
+ * compiles a SEPARATE per-call contract from the RAW inferred schema (through `@orkestrel/contract`'s
679
690
  * `schemaToShape`, NOT the `schemaToObject`-wrapped parameters — a bare-value sample checks a
680
691
  * bare-value candidate) and returns `{ parameters, checks }`, one check per candidate at the same
681
692
  * index. Every entry has a UNIFORM shape — `{ index, valid, coercible }`, with `faults` added ONLY
@@ -683,10 +694,10 @@ export declare function createEndpointTool(definition: EndpointDefinition, optio
683
694
  * OPPOSITE of {@link createEndpointTool}'s enforcement, which coerces (`7` becomes `'7'` for a
684
695
  * string slot) — here a conformance report answers "does this value conform AS-IS": `7` against a
685
696
  * string slot is `valid: false`, full stop. `coercible` answers a SEPARATE question — "would the
686
- * NORMALIZING parse accept this value", i.e. would {@link createEndpointTool}'s default enforcement
697
+ * NORMALIZING parse accept this value", that is would {@link createEndpointTool}'s default enforcement
687
698
  * admit it (`checker.parse(candidate) !== undefined`) — computed for every candidate regardless of
688
- * `valid`; by the house parse/guard round-trip guarantee (AGENTS §14), a `valid: true` entry is
689
- * ALWAYS also `coercible: true`. `@orkestrel/contract` 0.0.7's `explain` mirrors the normalizing
699
+ * `valid`; by the house parse/guard round-trip, a `valid: true` entry is
700
+ * ALWAYS also `coercible: true`. `@orkestrel/contract`'s `explain` mirrors the normalizing
690
701
  * `parse`'s leniency, not `is`'s strictness — so a strictly-invalid but coercible candidate (`7`
691
702
  * against a string slot) yields `{ valid: false, coercible: true, faults: [] }`: EMPTY faults, since
692
703
  * the mismatch the normalizing parse would silently fix is not one `explain` reports. `faults`
@@ -694,7 +705,7 @@ export declare function createEndpointTool(definition: EndpointDefinition, optio
694
705
  * (a boolean in a string slot), a missing required key, or an out-of-enum value — where
695
706
  * `coercible: false`. `checker.is` / `.parse` / `.explain` are all total over JSON-safe input — a
696
707
  * JSON-safe hostile candidate (a `__proto__`-carrying object, deeply nested data) reaches all three
697
- * and yields a bounded, non-throwing per-candidate verdict; a NON-JSON-safe candidate (e.g. a
708
+ * and yields a bounded, non-throwing per-candidate verdict; a NON-JSON-safe candidate (for example a
698
709
  * throwing-getter `Proxy`) never reaches the checker at all — it fails the OUTER `args` parse
699
710
  * against {@link import('./shapers.js').inferToolShape} and rejects the WHOLE call with the same
700
711
  * `TOOL` {@link import('./errors.js').ToolboxError} a malformed `samples`/`format`/`enum` throws,
@@ -738,8 +749,8 @@ export declare function createEndpointTool(definition: EndpointDefinition, optio
738
749
  export declare function createInferTool(options?: InferToolOptions): ToolInterface;
739
750
 
740
751
  /**
741
- * Create the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of database
742
- * definitions, the DEFAULT store the upcoming database / relation tools will persist their
752
+ * Creates the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of database
753
+ * definitions, the DEFAULT store the database and relation tools persist their
743
754
  * `DatabaseDefinition` configs through.
744
755
  *
745
756
  * @returns A {@link DefinitionStoreInterface}
@@ -754,11 +765,11 @@ export declare function createInferTool(options?: InferToolOptions): ToolInterfa
754
765
  export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
755
766
 
756
767
  /**
757
- * Build an LLM-callable form tool — the ASK side of the terminal seam. Asks
768
+ * Builds an LLM-callable form tool — the ASK side of the terminal seam. Asks
758
769
  * a multi-field form and BLOCKS until it answers, returning the resolved values record.
759
770
  *
760
771
  * @remarks
761
- * The universal tool-handler contract (AGENTS §14): validates the call args against
772
+ * The universal tool-handler contract: validates the call args against
762
773
  * {@link import('./shapers.js').promptToolShape}, parses the call's schema through
763
774
  * `@orkestrel/form`, constructs the live form, and passes it to `TerminalManagerInterface.ask`.
764
775
  * `from` is FIXED at construction
@@ -767,7 +778,7 @@ export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
767
778
  * `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
768
779
  * {@link import('./errors.js').ToolboxError}; an expired form re-surfaces as `EXPIRE`; an
769
780
  * unknown `to` (or any other `TerminalError`) re-surfaces as `TOOL`, naming the unknown terminal
770
- * plus the known ones (`manager.terminals()`).
781
+ * and how many brokers the manager holds (`manager.count`).
771
782
  *
772
783
  * @param options - The live manager, the fixed `from` identity, and advertised overrides (see
773
784
  * {@link import('./types.js').PromptToolOptions})
@@ -790,32 +801,33 @@ export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
790
801
  export declare function createPromptTool(options: PromptToolOptions): ToolInterface;
791
802
 
792
803
  /**
793
- * Build an LLM-callable relation tool — traverse and edit `@orkestrel/relation` relationships
794
- * through one `operation`-discriminated call (AGENTS §14, matching {@link createDatabaseTool}'s
804
+ * Builds an LLM-callable relation tool — it traverses and edits `@orkestrel/relation` relationships
805
+ * through one `operation`-discriminated call (matching {@link createDatabaseTool}'s
795
806
  * single-tool-many-operations shape).
796
807
  *
797
808
  * @remarks
798
- * The universal tool-handler contract (AGENTS §14): validates the call args against
809
+ * The universal tool-handler contract: validates the call args against
799
810
  * {@link import('./shapers.js').relationToolShape}, resolves the addressed
800
811
  * {@link import('@orkestrel/relation').RelationManagerInterface} — an explicit `manager` field
801
812
  * must match a key of {@link import('./types.js').RelationToolOptions.managers}, an OMITTED one
802
813
  * resolves to the SOLE registered manager, either miss throwing a typed `TOOL`
803
814
  * {@link import('./errors.js').ToolboxError}
804
- * ({@link import('./helpers.js').relationManagerOf}) — then resolves `model` against it
805
- * ({@link import('./helpers.js').relationModelOf}, same typed-`TOOL`-on-miss shape), and
815
+ * ({@link import('./helpers.js').resolveRelationManager}) — then resolves `model` against it
816
+ * ({@link import('./helpers.js').resolveRelationModel}, same typed-`TOOL`-on-miss shape), and
806
817
  * dispatches to the matched operation, RETURNING a plain result on success.
807
818
  *
808
819
  * `'load'` / `'find'` expand the call's FLAT dot-path `include` list into a live
809
- * `@orkestrel/relation` `Include` tree via {@link import('./helpers.js').expandInclude}, capped
820
+ * `@orkestrel/relation` `Include` tree through {@link import('./helpers.js').expandInclude}, capped
810
821
  * at {@link import('./types.js').RelationToolOptions.depth} (default
811
822
  * {@link import('./constants.js').RELATION_TOOL_DEPTH}) — a path exceeding the cap, or carrying an
812
823
  * empty segment, throws a typed `TOOL` error. `'load'` dispatches on whether `key` is an array
813
- * (positional many-key form, AGENTS §9.2) or a single key. `'find'` and `'links'` clamp their
824
+ * (positional many-key form — an array key is read as many keys rather than one) or a single key.
825
+ * `'find'` and `'links'` clamp their
814
826
  * result to {@link import('./types.js').RelationToolOptions.limit} (default
815
- * {@link import('./constants.js').RELATION_TOOL_LIMIT}) — `'find'` probes one row past the
816
- * effective limit (mirroring {@link import('./helpers.js').clampQuery}'s idiom) to report
817
- * `truncated`; `'links'` (which has no upstream pagination) fetches the FULL linked-key list and
818
- * slices/truncates it the same way. `'link'` / `'unlink'` write / remove one `through` junction
827
+ * {@link import('./constants.js').RELATION_TOOL_LIMIT}), taken through
828
+ * {@link import('./helpers.js').resolveLimit} — `'find'` probes one row past the effective limit to
829
+ * report `truncated`; `'links'` (which has no upstream pagination) fetches the FULL linked-key
830
+ * list and slices/truncates it the same way. `'link'` / `'unlink'` write / remove one `through` junction
819
831
  * row.
820
832
  *
821
833
  * A typed `@orkestrel/relation` failure (`RelationError`) re-surfaces as a typed `RELATION`
@@ -839,7 +851,7 @@ export declare function createPromptTool(options: PromptToolOptions): ToolInterf
839
851
  export declare function createRelationTool(options: RelationToolOptions): ToolInterface;
840
852
 
841
853
  /**
842
- * Wrap a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the OPT-IN
854
+ * Wraps a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the OPT-IN
843
855
  * adapter that lets a `function`-form task run a `@orkestrel/tool` tool BY NAME.
844
856
  *
845
857
  * @remarks
@@ -870,14 +882,14 @@ export declare function createRelationTool(options: RelationToolOptions): ToolIn
870
882
  export declare function createToolFunction(tools: ToolManagerInterface, name: string): WorkflowFunction;
871
883
 
872
884
  /**
873
- * Compile the lenient workflow draft contract used by {@link createWorkflowTool}.
885
+ * Compiles the lenient workflow draft contract used by {@link createWorkflowTool}.
874
886
  *
875
887
  * @returns The compiled {@link import('./types.js').WorkflowDraft} contract
876
888
  */
877
889
  export declare function createWorkflowDraftContract(): ContractInterface<WorkflowDraft>;
878
890
 
879
891
  /**
880
- * Compose opaque host functions and raw agents into one immutable workflow registry.
892
+ * Composes opaque host functions and raw agents into one immutable workflow registry.
881
893
  *
882
894
  * @remarks
883
895
  * This is the target-aware composition boundary used by direct runner consumers and
@@ -903,10 +915,10 @@ export declare function createWorkflowDraftContract(): ContractInterface<Workflo
903
915
  * await runner.execute(definition, { functions })
904
916
  * ```
905
917
  */
906
- export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): WorkflowFunctions;
918
+ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): WorkflowRegistry;
907
919
 
908
920
  /**
909
- * Wrap a {@link WorkflowDefinition} as an LLM-callable tool — it ADVERTISES the SIMPLE flat
921
+ * Wraps a {@link WorkflowDefinition} as an LLM-callable tool — it ADVERTISES the SIMPLE flat
910
922
  * authoring shape (`{ name?, steps: [{ name }] }`) as its `parameters` so even a small model can
911
923
  * author a complete tree, and its handler EXPANDS / COMPLETES the authored blob, validates it
912
924
  * against the STRICT contract, and runs it through `runner`, forwarding the caller's optional
@@ -932,7 +944,7 @@ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface,
932
944
  * - the full nested {@link WorkflowDefinition} — the advanced escape-hatch, accepted as the draft
933
945
  * super-set.
934
946
  *
935
- * The universal tool-handler contract (AGENTS §14): returns the plain run summary
947
+ * The universal tool-handler contract: returns the plain run summary
936
948
  * (`{ status, count, durable?, fault? }`) on success, THROWS a typed `ToolboxError` on Toolbox
937
949
  * boundary failures — malformed authored args (`TOOL`), or an over-deep / cyclic nested run
938
950
  * (`DEPTH`) — and preserves genuine runner `WorkflowError`s. The `ToolManagerInterface` isolates every throw into the canonical tool result's
@@ -963,15 +975,15 @@ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface,
963
975
  export declare function createWorkflowTool(definition: WorkflowDefinition, runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): ToolInterface;
964
976
 
965
977
  /**
966
- * Build an LLM-callable workspace-editing tool — it ADVERTISES the `operation`-discriminated
967
- * 13-op union ({@link import('./shapers.js').workspaceToolShape}) as its `parameters`, and its
978
+ * Builds an LLM-callable workspace-editing tool — it ADVERTISES the `operation`-discriminated
979
+ * union ({@link import('./shapers.js').workspaceToolShape}) as its `parameters`, and its
968
980
  * handler PARSES the model-supplied args against that contract and DISPATCHES the matched
969
981
  * operation against the manager's ACTIVE workspace (the registry ops drive the manager itself),
970
982
  * returning the plain result. A malformed operation throws this package's `ToolboxError`; a
971
983
  * genuine workspace-domain failure propagates `@orkestrel/workspace`'s typed `WorkspaceError`.
972
984
  * EITHER drives a caller-supplied {@link WorkspaceToolOptions.manager} directly, OR
973
985
  * constructs a fresh `WorkspaceManagerInterface` (`@orkestrel/workspace`) over
974
- * {@link import('./types.js').WorkspaceToolOptions.store} (via `@orkestrel/workspace`'s
986
+ * {@link import('./types.js').WorkspaceToolOptions.store} (through `@orkestrel/workspace`'s
975
987
  * `createWorkspaceManager`); neither given constructs a manager backed by
976
988
  * `@orkestrel/workspace`'s in-memory store default.
977
989
  *
@@ -986,15 +998,15 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
986
998
  *
987
999
  * NO-ACTIVE RULE (the ergonomic seam): a WRITING op (write / splice / prepend / append / move /
988
1000
  * remove / replace) run when `manager.active` is `undefined` AUTO-CREATES + activates a default
989
- * workspace (`manager.add()`) so the model can just start writing; a pure-READ op (read / list /
1001
+ * workspace (`manager.add()`) so the model can start writing; a pure-READ op (read / list /
990
1002
  * has / search) against no active workspace returns the EMPTY result (`undefined` / `[]` /
991
1003
  * `false`), never creating one and never throwing.
992
1004
  *
993
- * The handler conforms to the universal tool-handler contract (AGENTS §14): it `contract.parse`s
1005
+ * The handler conforms to the universal tool-handler contract: it `contract.parse`s
994
1006
  * the args, THROWS a `TOOL` `ToolboxError` when no operation arm matched (a malformed / unknown
995
1007
  * operation), else `switch`es on `op.operation` and RETURNS the plain result — letting a
996
- * `WorkspaceError` raised by the live workspace (`MODALITY` / `PATTERN` / `RANGE`) PROPAGATE
997
- * uncaught. The range edit is the FLAT `'splice'` op: its four flat caret integers are
1008
+ * `WorkspaceError` raised by the live workspace (`MISSING` / `MODALITY` / `PATTERN` / `RANGE`)
1009
+ * PROPAGATE uncaught. The range edit is the FLAT `'splice'` op: its four flat caret integers are
998
1010
  * reassembled into a `Range` (`@orkestrel/workspace`) by `rangeOf` and fed to the workspace's
999
1011
  * ranged `write`.
1000
1012
  *
@@ -1015,9 +1027,9 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
1015
1027
  export declare function createWorkspaceTool(options?: WorkspaceToolOptions): ToolInterface;
1016
1028
 
1017
1029
  /**
1018
- * The DESCRIPTION the upcoming database tool will advertise — a multi-line guide that teaches a
1019
- * small model the operation list, the SERIALIZED query form, and the {@link import('./types.js').TableSpec}
1020
- * column DSL.
1030
+ * Holds the description {@link import('./factories.js').createDatabaseTool} advertises — a
1031
+ * multi-line guide that teaches a small model the operation list, the SERIALIZED query form, and
1032
+ * the {@link import('./types.js').TableSpec} column DSL.
1021
1033
  *
1022
1034
  * @remarks
1023
1035
  * The query form is deliberately SERIALIZED (never fluent) — every condition is a flat object
@@ -1027,37 +1039,33 @@ export declare function createWorkspaceTool(options?: WorkspaceToolOptions): Too
1027
1039
  */
1028
1040
  export declare const DATABASE_TOOL_DESCRIPTION: string;
1029
1041
 
1030
- /** The default cap on rows a `records` call returns when the caller omits `query.limit` — the upcoming database tool's default row ceiling. */
1042
+ /** Holds the default cap on rows a `records` call returns when the caller omits `query.limit` — the database tool's default row ceiling. */
1031
1043
  export declare const DATABASE_TOOL_LIMIT = 1000;
1032
1044
 
1033
- /** The runtime-frozen database-tool mutation names disabled by `DatabaseToolOptions.readonly`. */
1045
+ /** Lists the runtime-frozen database-tool mutation names disabled by `DatabaseToolOptions.readonly`. */
1034
1046
  export declare const DATABASE_TOOL_MUTATIONS: readonly string[];
1035
1047
 
1036
1048
  /**
1037
- * The name the upcoming `createDatabaseTool` factory will advertise by default — the key a model
1038
- * calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1039
- *
1040
- * @remarks
1041
- * SRC-1 of a 3-unit spine: this unit lands the persistence + schema foundation
1042
- * ({@link import('./types.js').DatabaseDefinition}, {@link import('./types.js').DefinitionStoreInterface},
1043
- * {@link import('./helpers.js').expandTables}); `createDatabaseTool` itself is built in a later unit.
1049
+ * Holds the name {@link import('./factories.js').createDatabaseTool} advertises by default — the key
1050
+ * a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1044
1051
  */
1045
1052
  export declare const DATABASE_TOOL_NAME = "database";
1046
1053
 
1047
1054
  /**
1048
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} the upcoming database tool
1049
- * will advertise in place of {@link DATABASE_TOOL_DESCRIPTION}.
1055
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
1056
+ * {@link import('./factories.js').createDatabaseTool} advertises in place of
1057
+ * {@link DATABASE_TOOL_DESCRIPTION}.
1050
1058
  */
1051
1059
  export declare const DATABASE_TOOL_SUMMARY = "Create and query a database \u2014 one operation per call (create, tables, get, records, count, aggregate, add, set, update, remove, destroy), chosen by the 'operation' field. Call describe('database') for the full operation list, the query form, and the column DSL.";
1052
1060
 
1053
1061
  /**
1054
- * One database's CONFIG-ONLY definition — `id` + `driver` + {@link TableSpec}, with optional
1062
+ * Represents one database's CONFIG-ONLY definition — `id` + `driver` + {@link TableSpec}, with optional
1055
1063
  * `primary`, `indexes`, and `version` schema configuration.
1056
1064
  *
1057
1065
  * @remarks
1058
1066
  * A `DatabaseDefinition` is NEVER a live handle — it is the durable, serializable config a
1059
1067
  * {@link DefinitionStoreInterface} persists and a tool factory turns into a real
1060
- * `@orkestrel/database` `DatabaseInterface` (via `createDatabase` + {@link import('./helpers.js').expandTables})
1068
+ * `@orkestrel/database` `DatabaseInterface` (through `createDatabase` + {@link import('./compilers.js').expandTables})
1061
1069
  * on demand. `primary` maps table names to primary-key columns; `indexes` maps table names to
1062
1070
  * index column groups; `version` opts a capable driver into open-time schema reconciliation.
1063
1071
  */
@@ -1070,14 +1078,14 @@ export declare interface DatabaseDefinition {
1070
1078
  readonly version?: number;
1071
1079
  }
1072
1080
 
1073
- /** One opaque persisted row — the shape a `TableInterface<DatabaseDefinitionRow>`-backed store reads/writes; `definition` is narrowed with {@link import('./helpers.js').isDatabaseDefinition} on read. */
1081
+ /** Represents one opaque persisted row — the shape a `TableInterface<DatabaseDefinitionRow>`-backed store reads/writes; `definition` is narrowed with {@link import('./validators.js').isDatabaseDefinition} on read. */
1074
1082
  export declare interface DatabaseDefinitionRow {
1075
1083
  readonly id: string;
1076
1084
  readonly definition: unknown;
1077
1085
  }
1078
1086
 
1079
1087
  /**
1080
- * A {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
1088
+ * Represents a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
1081
1089
  * database's durable CONFIG state IS a row, so persistence reduces to keyed point-access
1082
1090
  * (`get` / `set` / `delete`) over a {@link TableInterface}, the driver-pluggable twin of the
1083
1091
  * plain-`Map` {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}.
@@ -1099,12 +1107,12 @@ export declare interface DatabaseDefinitionRow {
1099
1107
  * - **`set(definition)` upserts under the definition's OWN `id`** (no separate id param) — it
1100
1108
  * writes the row `{ id: definition.id, definition }`.
1101
1109
  * - **`get(id)` resolves the stored definition for an id**, narrowing the opaque JSON column back
1102
- * to a {@link DatabaseDefinition} ({@link import('../helpers.js').isDatabaseDefinition} — the
1103
- * AGENTS §14 boundary narrow for an untrusted storage read), or `undefined` if none is stored
1110
+ * to a {@link DatabaseDefinition} ({@link import('../validators.js').isDatabaseDefinition} — the
1111
+ * boundary narrow for an untrusted storage read), or `undefined` if none is stored
1104
1112
  * or the stored blob is malformed.
1105
1113
  * - **`delete(id)` drops a definition by id**; an absent id is a no-op (no throw).
1106
1114
  *
1107
- * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
1115
+ * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the method
1108
1116
  * bijection with {@link DefinitionStoreInterface}).
1109
1117
  *
1110
1118
  * @example
@@ -1120,22 +1128,65 @@ export declare interface DatabaseDefinitionRow {
1120
1128
  export declare class DatabaseDefinitionStore implements DefinitionStoreInterface {
1121
1129
  #private;
1122
1130
  /**
1123
- * Wrap a table as a definition store.
1131
+ * Wraps a table as a definition store.
1124
1132
  *
1125
1133
  * @param table - The {@link TableInterface} holding the definitions — its row is the
1126
1134
  * {@link DatabaseDefinitionRow} `{ id; definition }` shape (the definition one opaque JSON column)
1127
1135
  */
1128
1136
  constructor(table: TableInterface<DatabaseDefinitionRow>);
1129
- /** Resolve the persisted definition for `id`, narrowing the opaque JSON column back to a `DatabaseDefinition`. */
1137
+ /**
1138
+ * Resolves the persisted definition for `id`, narrowing the opaque JSON column back to a
1139
+ * {@link DatabaseDefinition}.
1140
+ *
1141
+ * @param id - The database id to read
1142
+ * @returns The stored {@link DatabaseDefinition}, or `undefined` when none is stored or the
1143
+ * stored blob is malformed
1144
+ */
1130
1145
  get(id: string): Promise<DatabaseDefinition | undefined>;
1131
- /** Insert or replace under the definition's OWN `id` (no separate id param) — the row is `{ id, definition }`. */
1146
+ /**
1147
+ * Inserts or replaces a definition under its OWN `id` — the written row is `{ id, definition }`.
1148
+ *
1149
+ * @param definition - The config to persist; its own `id` is the row key (no separate id param)
1150
+ * @returns A promise settling once the row is written
1151
+ */
1132
1152
  set(definition: DatabaseDefinition): Promise<void>;
1133
- /** Drop a definition by id; an absent id is a no-op (no throw). */
1153
+ /**
1154
+ * Drops the definition stored under `id`.
1155
+ *
1156
+ * @param id - The database id to drop; an absent id is a no-op, never a throw
1157
+ * @returns A promise settling once no row is stored under `id`
1158
+ */
1134
1159
  delete(id: string): Promise<void>;
1135
1160
  }
1136
1161
 
1137
1162
  /**
1138
- * Resolve database definitions into cached live handles for database tools.
1163
+ * Represents the SERIALIZED wire query a database-tool call carries — the parsed form of
1164
+ * {@link import('./shapers.js').queryShape}, which
1165
+ * {@link import('./helpers.js').normalizeQuery} normalizes into a live `@orkestrel/database`
1166
+ * {@link QueryInput}.
1167
+ *
1168
+ * @remarks
1169
+ * Every condition is FLAT and its `values` is ALWAYS an array, even for a single-value operator.
1170
+ * `connector` is optional because the LAST condition joins nothing forward; `normalizeQuery` defaults an
1171
+ * omitted one to `'and'`. `order` / `limit` / `offset` carry over to the live query unchanged.
1172
+ */
1173
+ export declare interface DatabaseQueryInput {
1174
+ readonly conditions?: ReadonlyArray<Readonly<{
1175
+ column: string;
1176
+ operator: Condition['operator'];
1177
+ values: readonly unknown[];
1178
+ connector?: ConditionConnector;
1179
+ }>>;
1180
+ readonly order?: ReadonlyArray<Readonly<{
1181
+ column: string;
1182
+ direction: OrderDirection;
1183
+ }>>;
1184
+ readonly limit?: number;
1185
+ readonly offset?: number;
1186
+ }
1187
+
1188
+ /**
1189
+ * Resolves database definitions into cached live handles for database tools.
1139
1190
  *
1140
1191
  * @example
1141
1192
  * ```ts
@@ -1148,7 +1199,7 @@ export declare class DatabaseDefinitionStore implements DefinitionStoreInterface
1148
1199
  export declare class DatabaseResolver {
1149
1200
  #private;
1150
1201
  /**
1151
- * Create a database resolver over the tool's live state and optional definition store.
1202
+ * Creates a database resolver over the tool's live state and optional definition store.
1152
1203
  *
1153
1204
  * @param handles - Initial live database handles cached by id
1154
1205
  * @param drivers - Driver factories keyed by definition driver name
@@ -1157,21 +1208,21 @@ export declare class DatabaseResolver {
1157
1208
  */
1158
1209
  constructor(handles: ReadonlyMap<string, DatabaseInterface>, drivers: Readonly<Record<string, () => DriverInterface>>, generator?: KeyFunction, store?: DefinitionStoreInterface);
1159
1210
  /**
1160
- * Determine whether a live database is cached by id.
1211
+ * Determines whether a live database is cached by id.
1161
1212
  *
1162
1213
  * @param id - Database id
1163
- * @returns Whether a live handle is cached
1214
+ * @returns True if a live handle is cached; false otherwise
1164
1215
  */
1165
1216
  has(id: string): boolean;
1166
1217
  /**
1167
- * Read a cached database without consulting the definition store.
1218
+ * Reads a cached database without consulting the definition store.
1168
1219
  *
1169
1220
  * @param id - Database id
1170
1221
  * @returns The cached live database, or `undefined`
1171
1222
  */
1172
1223
  get(id: string): DatabaseInterface | undefined;
1173
1224
  /**
1174
- * Cache a live database by id.
1225
+ * Caches a live database by id.
1175
1226
  *
1176
1227
  * @param id - Database id
1177
1228
  * @param database - Live database handle
@@ -1179,14 +1230,14 @@ export declare class DatabaseResolver {
1179
1230
  */
1180
1231
  set(id: string, database: DatabaseInterface): void;
1181
1232
  /**
1182
- * Remove a cached live database by id.
1233
+ * Removes a cached live database by id.
1183
1234
  *
1184
1235
  * @param id - Database id
1185
1236
  * @returns Nothing
1186
1237
  */
1187
1238
  delete(id: string): void;
1188
1239
  /**
1189
- * Resolve a cached or stored database by id.
1240
+ * Resolves a cached or stored database by id.
1190
1241
  *
1191
1242
  * @param id - Database definition id
1192
1243
  * @returns The cached or newly constructed live database
@@ -1195,23 +1246,12 @@ export declare class DatabaseResolver {
1195
1246
  }
1196
1247
 
1197
1248
  /**
1198
- * Map a caught error to the {@link ToolboxErrorCode} the upcoming database tool should throw
1199
- * with — the pure classification step of that factory's error handling, mirroring
1200
- * {@link terminalToolCode}'s idiom for `@orkestrel/database`.
1201
- *
1202
- * @param error - The value caught from a `@orkestrel/database` table operation
1203
- * @returns The granular {@link DatabaseErrorCode}, or `undefined` if `error` is not a `DatabaseError`
1204
- */
1205
- export declare function databaseToolCode(error: unknown): DatabaseErrorCode | undefined;
1206
-
1207
- /**
1208
- * Options for {@link import('./factories.js').createDatabaseTool} — SRC-2 of the 3-unit database
1209
- * / relation spine, built over the SRC-1 foundation ({@link DatabaseDefinition},
1210
- * {@link DefinitionStoreInterface}, {@link import('./helpers.js').expandTables}).
1249
+ * Represents the options for {@link import('./factories.js').createDatabaseTool} — the live handles, definition
1250
+ * store, driver registry, key generator, row cap, timeout, and readonly gate the tool composes.
1211
1251
  *
1212
1252
  * @remarks
1213
- * - `databases` — live `DatabaseInterface` handles to seed the tool's cache with (e.g. a
1214
- * caller-constructed database it should manage alongside store-backed ones); keyed by the id a
1253
+ * - `databases` — live `DatabaseInterface` handles to seed the tool's cache with (for example a
1254
+ * caller-constructed database it manages alongside store-backed ones); keyed by the id a
1215
1255
  * call's `id` field addresses.
1216
1256
  * - `store` — the {@link DefinitionStoreInterface} the `'create'` operation persists its
1217
1257
  * {@link DatabaseDefinition} CONFIG through, and `'destroy'` deletes from; also the source
@@ -1223,7 +1263,7 @@ export declare function databaseToolCode(error: unknown): DatabaseErrorCode | un
1223
1263
  * - `generator` — the optional `KeyFunction` (`@orkestrel/database`) every minted database is
1224
1264
  * constructed with, used when a written row lacks its primary key. Omitted delegates to the
1225
1265
  * database's default generator.
1226
- * - `limit` — the `'records'` row cap — via {@link import('./helpers.js').clampQuery}
1266
+ * - `limit` — the `'records'` row cap — through {@link import('./helpers.js').clampQuery}
1227
1267
  * — enforce when a call's `query.limit` is omitted or exceeds it. Defaults to
1228
1268
  * {@link import('./constants.js').DATABASE_TOOL_LIMIT}.
1229
1269
  * - `timeout` — a nonnegative safe-integer number of milliseconds. A fresh
@@ -1250,15 +1290,15 @@ export declare interface DatabaseToolOptions {
1250
1290
  }
1251
1291
 
1252
1292
  /**
1253
- * The shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
1293
+ * Describes the shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
1254
1294
  * discriminated by `operation` into the 11 database operations (`'create'` / `'tables'` /
1255
1295
  * `'get'` / `'records'` / `'count'` / `'aggregate'` / `'add'` / `'set'` / `'update'` /
1256
1296
  * `'remove'` / `'destroy'`).
1257
1297
  *
1258
1298
  * @remarks
1259
1299
  * Every arm carries `id` (the database id). `'create'` carries `tables` (the
1260
- * {@link import('./types.js').TableSpec} column DSL, compiled via
1261
- * {@link import('./helpers.js').expandTables}); `'get'` / `'update'` / `'remove'` carry `key`
1300
+ * {@link import('./types.js').TableSpec} column DSL, compiled through
1301
+ * {@link import('./compilers.js').expandTables}); `'get'` / `'update'` / `'remove'` carry `key`
1262
1302
  * (one key or an array of keys, positional); `'add'` / `'set'` carry `row` (one row or an array of
1263
1303
  * rows); `'update'` also carries `changes` (a loose partial row); `'records'` / `'count'` /
1264
1304
  * `'aggregate'` carry an optional `query` (the SERIALIZED form — `values` is ALWAYS an array,
@@ -1269,7 +1309,7 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
1269
1309
  id: StringShape;
1270
1310
  tables: ObjectShape<Record<never, never>, ObjectShape<{
1271
1311
  columns: ObjectShape<Record<never, never>, UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
1272
- type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
1312
+ primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
1273
1313
  optional: OptionalShape<BooleanShape>;
1274
1314
  }, false>]>>;
1275
1315
  }, false>>;
@@ -1368,7 +1408,7 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
1368
1408
  }, false>]>;
1369
1409
 
1370
1410
  /**
1371
- * The point-access persistence seam (AGENTS §5 — Stores) for {@link DatabaseDefinition} configs —
1411
+ * Represents the point-access persistence seam for {@link DatabaseDefinition} configs —
1372
1412
  * the twin of `@orkestrel/terminal`'s `TerminalStoreInterface`, storing a database's CONFIG-ONLY
1373
1413
  * blueprint (never a live handle). Every primitive is async; `delete` of an absent id is a no-op.
1374
1414
  */
@@ -1379,7 +1419,7 @@ export declare interface DefinitionStoreInterface {
1379
1419
  }
1380
1420
 
1381
1421
  /**
1382
- * Derive the zero-based workflow nesting depth from a valid lineage.
1422
+ * Derives the zero-based workflow nesting depth from a valid lineage.
1383
1423
  *
1384
1424
  * @param lineage - The workflow/agent chain
1385
1425
  * @returns Zero for an empty/root lineage, then one per nested workflow
@@ -1387,7 +1427,7 @@ export declare interface DefinitionStoreInterface {
1387
1427
  export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
1388
1428
 
1389
1429
  /**
1390
- * The DESCRIPTION {@link import('./factories.js').createDescribeTool} advertises.
1430
+ * Holds the DESCRIPTION {@link import('./factories.js').createDescribeTool} advertises.
1391
1431
  *
1392
1432
  * @remarks
1393
1433
  * Deliberately short — unlike the workflow / workspace / agent tools, this one has no authoring
@@ -1396,38 +1436,38 @@ export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
1396
1436
  export declare const DESCRIBE_TOOL_DESCRIPTION = "Return the full description of a registered tool by its name. Required: name - the registered tool name (see another tool listing for available names).";
1397
1437
 
1398
1438
  /**
1399
- * The name {@link import('./factories.js').createDescribeTool} advertises by default — the key a
1439
+ * Holds the name {@link import('./factories.js').createDescribeTool} advertises by default — the key a
1400
1440
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1401
1441
  *
1402
1442
  * @remarks
1403
- * Net-new: pairs with the other three tools' lean {@link AGENT_TOOL_SUMMARY} /
1404
- * {@link WORKFLOW_TOOL_SUMMARY} / {@link WORKSPACE_TOOL_SUMMARY} — a model that reads only the
1443
+ * Pairs with the lean {@link AGENT_TOOL_SUMMARY} / {@link WORKFLOW_TOOL_SUMMARY} /
1444
+ * {@link WORKSPACE_TOOL_SUMMARY} — a model that reads only the
1405
1445
  * advertised summary can call `describe` with that tool's registered name to get its full
1406
1446
  * teaching description back.
1407
1447
  */
1408
1448
  export declare const DESCRIBE_TOOL_NAME = "describe";
1409
1449
 
1410
1450
  /**
1411
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createDescribeTool}
1451
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createDescribeTool}
1412
1452
  * advertises — this tool needs no teaching of its own, so its summary and description are both
1413
1453
  * short.
1414
1454
  */
1415
1455
  export declare const DESCRIBE_TOOL_SUMMARY = "Return the full description of a named registered tool.";
1416
1456
 
1417
1457
  /**
1418
- * The FLAT args {@link import('./factories.js').createDescribeTool} accepts — the registered
1458
+ * Represents the FLAT args {@link import('./factories.js').createDescribeTool} accepts — the registered
1419
1459
  * tool `name` whose full `description` a model wants back.
1420
1460
  *
1421
1461
  * @remarks
1422
1462
  * `name` must match a tool registered on the {@link import('@orkestrel/tool').ToolManagerInterface}
1423
- * the describe tool was built over — it is looked up via `tools.tool(name)`.
1463
+ * the describe tool was built over — it is looked up through `tools.tool(name)`.
1424
1464
  */
1425
1465
  export declare interface DescribeToolArguments {
1426
1466
  readonly name: string;
1427
1467
  }
1428
1468
 
1429
1469
  /**
1430
- * The shape of {@link import('./types.js').DescribeToolArguments} —
1470
+ * Describes the shape of {@link import('./types.js').DescribeToolArguments} —
1431
1471
  * {@link import('./factories.js').createDescribeTool}'s advertised `parameters`.
1432
1472
  *
1433
1473
  * @remarks
@@ -1438,7 +1478,7 @@ export declare const describeToolShape: ObjectShape<{
1438
1478
  }, false>;
1439
1479
 
1440
1480
  /**
1441
- * One concrete endpoint {@link import('./factories.js').createEndpointTool} wraps as an
1481
+ * Represents one concrete endpoint {@link import('./factories.js').createEndpointTool} wraps as an
1442
1482
  * LLM-callable `ToolInterface` — the advertised identity, a non-empty set of example values its
1443
1483
  * `parameters` are inferred from, and the local handler that runs a call.
1444
1484
  *
@@ -1446,36 +1486,36 @@ export declare const describeToolShape: ObjectShape<{
1446
1486
  * `samples` MUST be non-empty — {@link import('./factories.js').createEndpointTool} throws a
1447
1487
  * typed `TOOL` {@link import('./errors.js').ToolboxError} at CONSTRUCTION when it is empty,
1448
1488
  * since an empty sample set cannot infer a schema. By DEFAULT ({@link EndpointToolOptions.validate}
1449
- * `true`) `invoke` receives the PARSED, NORMALIZED args record — a copy of the model-supplied
1450
- * `args` with each scalar coerced to its inferred type (e.g. a number sent for a string slot
1489
+ * `true`) `execute` receives the PARSED, NORMALIZED args record — a copy of the model-supplied
1490
+ * `args` with each scalar coerced to its inferred type (for example a number sent for a string slot
1451
1491
  * arrives coerced to a string), checked against the same schema advertised as `parameters` — and
1452
- * a call with a missing required key or a non-coercible value never reaches `invoke` at all (see
1492
+ * a call with a missing required key or a non-coercible value never reaches `execute` at all (see
1453
1493
  * {@link EndpointToolOptions.validate}). With
1454
- * `validate: false`, `invoke` receives the model-supplied `args` VERBATIM (raw passthrough, never
1455
- * checked against the inferred schema). Either way `invoke`'s return flows back as the tool
1494
+ * `validate: false`, `execute` receives the model-supplied `args` VERBATIM (raw passthrough, never
1495
+ * checked against the inferred schema). Either way `execute`'s return flows back as the tool
1456
1496
  * call's result; a throw PROPAGATES uncaught, isolated by the `ToolManagerInterface`
1457
1497
  * (`@orkestrel/tool`) into the canonical error envelope. When `samples` are non-object values,
1458
- * the advertised schema wraps them under a single required `value` property, so `invoke` receives
1498
+ * the advertised schema wraps them under a single required `value` property, so `execute` receives
1459
1499
  * an `args` record of the shape `{ value: ... }` — never the bare value.
1460
1500
  */
1461
1501
  export declare interface EndpointDefinition {
1462
1502
  readonly name: string;
1463
1503
  readonly description: string;
1464
1504
  readonly samples: readonly unknown[];
1465
- readonly invoke: EndpointHandler;
1505
+ readonly execute: EndpointHandler;
1466
1506
  }
1467
1507
 
1468
1508
  /**
1469
- * The handler {@link import('./types.js').EndpointDefinition.invoke} implements — mirrors
1509
+ * Represents the handler {@link import('./types.js').EndpointDefinition.execute} implements — mirrors
1470
1510
  * `@orkestrel/tool`'s `ToolOptions.execute` signature EXACTLY (same `Readonly<Record<string,
1471
1511
  * unknown>>` argument, same `Promise<unknown> | unknown` return) so
1472
- * `execute: (args) => definition.invoke(args)` typechecks with zero assertions in
1512
+ * `execute: (args) => definition.execute(args)` typechecks with zero assertions in
1473
1513
  * {@link import('./factories.js').createEndpointTool}.
1474
1514
  */
1475
1515
  export declare type EndpointHandler = (args: Readonly<Record<string, unknown>>) => Promise<unknown> | unknown;
1476
1516
 
1477
1517
  /**
1478
- * Construction-time tuning for {@link import('./factories.js').createEndpointTool} — the
1518
+ * Represents the construction-time tuning for {@link import('./factories.js').createEndpointTool} — the
1479
1519
  * inferred `parameters` schema's `format` / `enum` constraints, and whether that same schema is
1480
1520
  * ENFORCED at `execute` time.
1481
1521
  *
@@ -1483,23 +1523,25 @@ export declare type EndpointHandler = (args: Readonly<Record<string, unknown>>)
1483
1523
  * `format` / `enum` default to `false`, matching `@orkestrel/contract`'s own
1484
1524
  * `ValueToSchemaOptions` defaults. `validate` defaults to `true`: the schema
1485
1525
  * `createEndpointTool` advertises as `parameters` (`samplesToSchema` + `schemaToObject`) is
1486
- * compiled ONCE at construction (via `@orkestrel/contract` 0.0.7's `schemaToShape`) into a
1487
- * `ContractInterface` used to `parse` every call's `args` before `invoke` runs — a NORMALIZING
1526
+ * compiled ONCE at construction (through `@orkestrel/contract`'s `schemaToShape`) into a
1527
+ * `ContractInterface` used to `parse` every call's `args` before `execute` runs — a NORMALIZING
1488
1528
  * parse: a scalar value is COERCED to its inferred type where the house parsers coerce (a number
1489
- * to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/`'false'`/`1`/`0`), so `invoke`
1490
- * receives the COERCED values (e.g. `7` sent for a string slot arrives at `invoke` as `'7'`), not
1529
+ * to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/`'false'`/`1`/`0`), so `execute`
1530
+ * receives the COERCED values (for example `7` sent for a string slot arrives at `execute` as `'7'`), not
1491
1531
  * the raw call args. A call whose `args` fails to parse — a required key missing, or a value not
1492
1532
  * coercible to its slot's type — THROWS a typed `TOOL` {@link import('./errors.js').ToolboxError}
1493
- * carrying the structured `explain` faults, and `invoke` is never called. Beyond that coercion,
1533
+ * carrying the structured `explain` faults, and `execute` is never called. Beyond that coercion,
1494
1534
  * enforcement is STRUCTURAL — required keys, `enum` membership, and numeric bounds — `format`
1495
1535
  * annotations (`email`, `date-time`, `uuid`, `uri`, ...) are NEVER asserted, mirroring
1496
1536
  * `@orkestrel/contract`'s own widening-only law for `schemaToShape`: a `format: true`-tuned
1497
1537
  * endpoint still ACCEPTS a non-conforming string in a format-tagged slot. A key NOT present in
1498
1538
  * the inferred (closed, `additionalProperties: false`) schema is NEVER a rejection either — it is
1499
- * SILENTLY DROPPED before `invoke` runs (the same leniency `@orkestrel/contract`'s own `parse`
1500
- * grants a closed object generally), so `invoke` may see fewer keys than the caller sent. Set
1501
- * `validate: false` to restore the PRE-0.0.7 behavior exactly — `execute` passes the
1502
- * model-supplied `args` straight to `invoke` UNCHANGED, unchecked and unstripped.
1539
+ * SILENTLY DROPPED before `execute` runs (the same leniency `@orkestrel/contract`'s own `parse`
1540
+ * grants a closed object generally), so `execute` may see fewer keys than the caller sent. Set
1541
+ * `validate: false` when the endpoint's own handler validates its arguments, or when `samples`
1542
+ * under-describe the real contract and the normalizing coercion would corrupt a call: the tool's
1543
+ * `execute` then passes the model-supplied `args` to the handler unchanged, unchecked and
1544
+ * unstripped.
1503
1545
  */
1504
1546
  export declare interface EndpointToolOptions {
1505
1547
  readonly format?: boolean;
@@ -1508,7 +1550,7 @@ export declare interface EndpointToolOptions {
1508
1550
  }
1509
1551
 
1510
1552
  /**
1511
- * Expand the relation tool's FLAT dot-path `include` list into a live `@orkestrel/relation`
1553
+ * Expands the relation tool's FLAT dot-path `include` list into a live `@orkestrel/relation`
1512
1554
  * {@link Include} tree — the pure leaf {@link import('./factories.js').createRelationTool} calls
1513
1555
  * before a `'load'` / `'find'` call.
1514
1556
  *
@@ -1534,13 +1576,13 @@ export declare interface EndpointToolOptions {
1534
1576
  export declare function expandInclude(paths: readonly string[] | undefined, depth: number): Include;
1535
1577
 
1536
1578
  /**
1537
- * Expand a flat {@link WorkflowSteps} blob into a strict {@link WorkflowDefinition} — each step
1579
+ * Expands a flat {@link WorkflowSteps} blob into a strict {@link WorkflowDefinition} — each step
1538
1580
  * becomes a one-task phase, IN ORDER.
1539
1581
  *
1540
1582
  * @remarks
1541
1583
  * The expansion of the tool's ADVERTISED surface: the deliberately-reduced flat form. Each
1542
1584
  * {@link import('./types.js').WorkflowStep} maps to a phase holding exactly one task: the step's
1543
- * `name` becomes the task's `run` (the behavior-registry key). Ids/names are auto-filled
1585
+ * `name` becomes the task's `behavior` (the behavior-registry key). Ids/names are auto-filled
1544
1586
  * positionally — it builds an ids-omitted {@link WorkflowDraft} and delegates to
1545
1587
  * {@link completeDraft}, so the two lenient surfaces share ONE synthesis path (step `i` → phase
1546
1588
  * `phase-<i>`, its task `phase-<i>-task-0`). The optional `name` becomes both the workflow's
@@ -1554,7 +1596,7 @@ export declare function expandInclude(paths: readonly string[] | undefined, dept
1554
1596
  export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
1555
1597
 
1556
1598
  /**
1557
- * Compile a {@link TableSpec} into the `@orkestrel/database` {@link TableMap} it configures —
1599
+ * Compiles a {@link TableSpec} into the `@orkestrel/database` {@link TableMap} it configures —
1558
1600
  * each {@link ColumnSpec} maps to the matching primitive shaper (`'string'` → `stringShape()`,
1559
1601
  * `'integer'` → `integerShape()`, `'number'` → `numberShape()`, `'boolean'` → `booleanShape()`),
1560
1602
  * wrapped in `optionalShape` when the column declares `optional: true`. Total, pure.
@@ -1565,7 +1607,7 @@ export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
1565
1607
  export declare function expandTables(spec: TableSpec): TableMap;
1566
1608
 
1567
1609
  /**
1568
- * Append one tag to a workflow lineage and return a frozen copy.
1610
+ * Appends one tag to a workflow lineage and returns a frozen copy.
1569
1611
  *
1570
1612
  * @param lineage - The valid chain to extend
1571
1613
  * @param tag - The workflow or agent tag to append
@@ -1573,29 +1615,68 @@ export declare function expandTables(spec: TableSpec): TableMap;
1573
1615
  */
1574
1616
  export declare function extendLineage(lineage: WorkflowLineage, tag: string): WorkflowLineage;
1575
1617
 
1576
- /** Flat dot-path relation include list, expanded via {@link import('./helpers.js').expandInclude}. */
1618
+ /** Describes the flat dot-path relation include list, expanded through {@link import('./helpers.js').expandInclude}. */
1577
1619
  export declare const includeShape: OptionalShape<ArrayShape<StringShape>>;
1578
1620
 
1579
- /** The schema-inference protocol {@link import('./factories.js').createInferTool} advertises. */
1621
+ /** Holds the schema-inference protocol {@link import('./factories.js').createInferTool} advertises. */
1580
1622
  export declare const INFER_TOOL_DESCRIPTION: string;
1581
1623
 
1582
1624
  /**
1583
- * The name {@link import('./factories.js').createInferTool} advertises by default — the key a
1625
+ * Holds the name {@link import('./factories.js').createInferTool} advertises by default — the key a
1584
1626
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1585
1627
  */
1586
1628
  export declare const INFER_TOOL_NAME = "infer";
1587
1629
 
1588
1630
  /**
1589
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createInferTool}
1631
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createInferTool}
1590
1632
  * advertises in place of {@link INFER_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
1591
1633
  * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
1592
- * for the full teaching description; the full text stays retrievable via
1634
+ * for the full teaching description; the full text stays retrievable through
1593
1635
  * {@link import('./factories.js').createDescribeTool}.
1594
1636
  */
1595
1637
  export declare const INFER_TOOL_SUMMARY = "Infer a JSON Schema (as advertised tool parameters) from one or more example values. Call describe('infer') for the required fields.";
1596
1638
 
1597
1639
  /**
1598
- * Options for {@link import('./factories.js').createInferTool} — advertised name/description
1640
+ * Maps a caught error to the granular {@link DatabaseErrorCode} (`@orkestrel/database`) the code
1641
+ * {@link import('./factories.js').createDatabaseTool} throws with — the pure classification step
1642
+ * of that factory's error handling, mirroring {@link inferTerminalCode}'s idiom for
1643
+ * `@orkestrel/database`.
1644
+ *
1645
+ * @param error - The value caught from a `@orkestrel/database` table operation
1646
+ * @returns The granular {@link DatabaseErrorCode}, or `undefined` if `error` is not a `DatabaseError`
1647
+ */
1648
+ export declare function inferDatabaseCode(error: unknown): DatabaseErrorCode | undefined;
1649
+
1650
+ /**
1651
+ * Maps a caught error to the granular {@link RelationErrorCode} (`@orkestrel/relation`) the code
1652
+ * {@link import('./factories.js').createRelationTool} throws with — the pure classification step
1653
+ * of that factory's error handling, mirroring {@link inferTerminalCode}'s idiom for
1654
+ * `@orkestrel/relation`.
1655
+ *
1656
+ * @param error - The value caught from a `@orkestrel/relation` operation
1657
+ * @returns The granular {@link RelationErrorCode}, or `undefined` if `error` is not a `RelationError`
1658
+ */
1659
+ export declare function inferRelationCode(error: unknown): RelationErrorCode | undefined;
1660
+
1661
+ /**
1662
+ * Maps a caught error to the {@link ToolboxErrorCode} the terminal-tool factory throws with — the
1663
+ * pure classification step of that factory's error handling.
1664
+ *
1665
+ * @remarks
1666
+ * Narrows `error` with {@link isTerminalError} (`@orkestrel/terminal`) first: a non-`TerminalError`
1667
+ * value returns `undefined`, telling the caller this mapper does not apply (rethrow / handle
1668
+ * otherwise). For a genuine `TerminalError`, `'DEADLOCK'` maps to `'DEADLOCK'`, `'EXPIRE'` maps
1669
+ * to `'EXPIRE'`, and every other {@link import('@orkestrel/terminal').TerminalErrorCode}
1670
+ * (`'TARGET'`, `'LIMIT'`, `'CANCEL'`, `'DRIVER'`, `'DESTROYED'`) maps to the generic `'TOOL'`
1671
+ * code. The mapper only classifies — the factory performs the actual throw.
1672
+ *
1673
+ * @param error - The value caught from a terminal-manager operation (`ask` / `answer` / …)
1674
+ * @returns The mapped {@link ToolboxErrorCode}, or `undefined` if `error` is not a `TerminalError`
1675
+ */
1676
+ export declare function inferTerminalCode(error: unknown): ToolboxErrorCode | undefined;
1677
+
1678
+ /**
1679
+ * Represents the options for {@link import('./factories.js').createInferTool} — advertised name/description
1599
1680
  * overrides only; `format` / `enum` are RUNTIME call arguments (see
1600
1681
  * {@link import('./shapers.js').inferToolShape}), not construction-time options, since a model
1601
1682
  * chooses them per call.
@@ -1606,7 +1687,7 @@ export declare interface InferToolOptions {
1606
1687
  }
1607
1688
 
1608
1689
  /**
1609
- * The shape of {@link import('./factories.js').createInferTool}'s call arguments — one or more
1690
+ * Describes the shape of {@link import('./factories.js').createInferTool}'s call arguments — one or more
1610
1691
  * example `samples` to infer a JSON Schema from, plus per-call `format` / `enum` toggles and an
1611
1692
  * optional `candidates` array to check against the inferred schema.
1612
1693
  *
@@ -1626,33 +1707,46 @@ export declare const inferToolShape: ObjectShape<{
1626
1707
  }, false>;
1627
1708
 
1628
1709
  /**
1629
- * Narrow an unknown callable to Toolbox's frozen contextual agent adapter metadata.
1710
+ * Narrows an unknown callable to Toolbox's frozen contextual agent adapter metadata.
1630
1711
  *
1631
1712
  * @param value - The value to inspect
1632
- * @returns Whether it is a frozen {@link AgentFunction} with a frozen valid lineage
1713
+ * @returns True if it is a frozen {@link AgentFunction} with a frozen valid lineage; false otherwise
1633
1714
  */
1634
1715
  export declare function isAgentFunction(value: unknown): value is AgentFunction;
1635
1716
 
1636
- /** Narrow an unknown value to a {@link import('./types.js').ColumnKind}. */
1637
- export declare function isColumnKind(value: unknown): value is ColumnKind;
1717
+ /**
1718
+ * Narrows an unknown value to a {@link ColumnPrimitive}.
1719
+ *
1720
+ * @param value - The value to inspect
1721
+ * @returns True if `value` is `'string'`, `'integer'`, `'number'`, or `'boolean'`; false otherwise
1722
+ */
1723
+ export declare function isColumnPrimitive(value: unknown): value is ColumnPrimitive;
1638
1724
 
1639
- /** Narrow an unknown value to a {@link ColumnSpec} — a valid {@link import('./types.js').ColumnKind} shorthand, or `{ type, optional }` with a valid `type`. */
1725
+ /**
1726
+ * Narrows an unknown value to a {@link ColumnSpec}.
1727
+ *
1728
+ * @param value - The value to inspect
1729
+ * @returns True if `value` is a valid {@link ColumnPrimitive} shorthand or a `{ primitive, optional }` record with a valid `primitive`; false otherwise
1730
+ */
1640
1731
  export declare function isColumnSpec(value: unknown): value is ColumnSpec;
1641
1732
 
1642
1733
  /**
1643
- * Narrow an unknown value to a {@link DatabaseDefinition} — a non-empty `id` + `driver`, a
1734
+ * Narrows an unknown value to a {@link DatabaseDefinition} — a non-empty `id` + `driver`, a
1644
1735
  * `tables` record whose every value is `{ columns: record of valid ColumnSpec }`, plus optional
1645
1736
  * `primary`, `indexes`, and finite `version` schema configuration. The boundary guard a
1646
1737
  * {@link import('./types.js').DefinitionStoreInterface} applies to an untrusted persisted blob
1647
1738
  * before trusting it as a definition (never an `as`).
1739
+ *
1740
+ * @param value - The value to inspect
1741
+ * @returns True if `value` is a complete {@link DatabaseDefinition}; false otherwise
1648
1742
  */
1649
1743
  export declare function isDatabaseDefinition(value: unknown): value is DatabaseDefinition;
1650
1744
 
1651
1745
  /**
1652
- * Type guard narrowing an unknown caught value to an {@link ToolboxError}.
1746
+ * Narrows an unknown caught value to an {@link ToolboxError}.
1653
1747
  *
1654
1748
  * @param value - The value to test (typically a `catch` binding)
1655
- * @returns `true` when `value` is an {@link ToolboxError}
1749
+ * @returns True if `value` is an {@link ToolboxError}; false otherwise
1656
1750
  *
1657
1751
  * @example
1658
1752
  * ```ts
@@ -1668,32 +1762,21 @@ export declare function isDatabaseDefinition(value: unknown): value is DatabaseD
1668
1762
  export declare function isToolboxError(value: unknown): value is ToolboxError;
1669
1763
 
1670
1764
  /**
1671
- * Narrow an unknown value to a valid alternating workflow lineage.
1765
+ * Narrows an unknown value to a valid alternating workflow lineage.
1672
1766
  *
1673
1767
  * @param value - The value to inspect
1674
- * @returns Whether `value` is a unique, nonempty-tagged workflow/agent chain
1768
+ * @returns True if `value` is a unique, nonempty-tagged workflow/agent chain; false otherwise
1675
1769
  */
1676
1770
  export declare function isWorkflowLineage(value: unknown): value is WorkflowLineage;
1677
1771
 
1678
- /** One key value — a string or number; the array form (multiple keys, positional) resolves FIRST per AGENTS §9.2. */
1772
+ /** Describes one key value for the database tool and the relation tool — a string or number; the array form (multiple keys, positional) resolves FIRST, so an array argument is read as many keys rather than one. */
1679
1773
  export declare const keyShape: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1680
1774
 
1681
- /** Map one {@link import('./types.js').ColumnKind} to its primitive `@orkestrel/database` shape — the leaf {@link columnShape} wraps. */
1682
- export declare function kindShape(kind: ColumnKind): ContractShape;
1683
-
1684
- /**
1685
- * Build a validated, copied, and frozen workflow lineage value.
1686
- *
1687
- * @param lineage - The configured chain; omitted means a direct root
1688
- * @returns An immutable caller-isolated lineage
1689
- */
1690
- export declare function lineageOf(lineage?: WorkflowLineage): WorkflowLineage;
1691
-
1692
- /** Which registered relation manager to address — omitted resolves to the sole registered manager. */
1775
+ /** Describes which registered relation manager to address — omitted resolves to the sole registered manager. */
1693
1776
  export declare const managerShape: OptionalShape<StringShape>;
1694
1777
 
1695
1778
  /**
1696
- * The maximum nesting depth a workflow → agent → workflow chain may reach — the bound
1779
+ * Holds the maximum nesting depth a workflow → agent → workflow chain may reach — the bound
1697
1780
  * {@link import('./factories.js').createAgentFunction} and
1698
1781
  * {@link import('./factories.js').createWorkflowTool}'s depth/cycle guards enforce.
1699
1782
  *
@@ -1702,16 +1785,19 @@ export declare const managerShape: OptionalShape<StringShape>;
1702
1785
  * workflows is allowed, while a ninth nested workflow is rejected with this package's typed
1703
1786
  * `DEPTH` `ToolboxError`.
1704
1787
  */
1705
- export declare const MAX_WORKFLOW_DEPTH = 8;
1788
+ export declare const MAX_WORKFLOW_CHAIN = 8;
1706
1789
 
1707
1790
  /**
1708
- * The in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
1791
+ * Represents the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
1709
1792
  * {@link DatabaseDefinition}s keyed by database id, the DEFAULT store
1710
- * {@link import('../factories.js').createMemoryDefinitionStore} builds. The EXACT twin of
1711
- * {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore}.
1793
+ * {@link import('../factories.js').createMemoryDefinitionStore} builds. It implements the same
1794
+ * {@link DefinitionStoreInterface} contract as
1795
+ * {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore}: this store copies on
1796
+ * write and on read; the table-backed store narrows an untrusted stored blob and reports
1797
+ * `undefined` for a malformed one.
1712
1798
  *
1713
1799
  * @remarks
1714
- * A plain `Map<string, DatabaseDefinition>` (AGENTS §21 — the definition is already pure,
1800
+ * A plain `Map<string, DatabaseDefinition>` (the definition is already pure,
1715
1801
  * self-contained CONFIG-only JSON, so no encoding is needed for the memory tier). Values are
1716
1802
  * structured-cloned on both write and read, keeping caller mutation outside the store. There is NO
1717
1803
  * idle-TTL and NO eviction: a persisted definition lives until an explicit `delete`. A durable
@@ -1724,7 +1810,7 @@ export declare const MAX_WORKFLOW_DEPTH = 8;
1724
1810
  * - **`set` inserts / replaces under the definition's OWN `id`** (no separate id param).
1725
1811
  * - **`delete` drops a definition by id**; an absent id is a no-op (no throw).
1726
1812
  *
1727
- * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
1813
+ * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the method
1728
1814
  * bijection with {@link DefinitionStoreInterface}).
1729
1815
  *
1730
1816
  * @example
@@ -1739,31 +1825,72 @@ export declare const MAX_WORKFLOW_DEPTH = 8;
1739
1825
  */
1740
1826
  export declare class MemoryDefinitionStore implements DefinitionStoreInterface {
1741
1827
  #private;
1828
+ /**
1829
+ * Resolves the persisted definition for `id`, copied out of the backing `Map`.
1830
+ *
1831
+ * @param id - The database id to read
1832
+ * @returns The stored {@link DatabaseDefinition}, or `undefined` when none is stored
1833
+ */
1742
1834
  get(id: string): Promise<DatabaseDefinition | undefined>;
1835
+ /**
1836
+ * Inserts or replaces a definition under its OWN `id`, copied into the backing `Map`.
1837
+ *
1838
+ * @param definition - The config to persist; its own `id` is the key (no separate id param)
1839
+ * @returns A promise settling once the definition is stored
1840
+ */
1743
1841
  set(definition: DatabaseDefinition): Promise<void>;
1842
+ /**
1843
+ * Drops the definition stored under `id`.
1844
+ *
1845
+ * @param id - The database id to drop; an absent id is a no-op, never a throw
1846
+ * @returns A promise settling once no definition is stored under `id`
1847
+ */
1744
1848
  delete(id: string): Promise<void>;
1745
1849
  }
1746
1850
 
1747
- /** One sort term. */
1851
+ /**
1852
+ * Returns the canonical workflow lineage — validated, copied, and frozen.
1853
+ *
1854
+ * @param lineage - The configured chain; omitted means a direct root
1855
+ * @returns An immutable caller-isolated lineage
1856
+ */
1857
+ export declare function normalizeLineage(lineage?: WorkflowLineage): WorkflowLineage;
1858
+
1859
+ /**
1860
+ * Returns the canonical live `@orkestrel/database` {@link QueryInput} for the database tool's
1861
+ * parsed SERIALIZED query — each condition's OMITTED `connector` defaults to `'and'`.
1862
+ *
1863
+ * @remarks
1864
+ * The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
1865
+ * on the last condition (it has nothing to join FORWARD to); the compiled `Condition` a live
1866
+ * `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
1867
+ * `limit` / `offset` pass through unchanged. Pure and total.
1868
+ *
1869
+ * @param query - The parsed query (or `undefined`)
1870
+ * @returns The equivalent live `QueryInput`, or `undefined` when `query` is `undefined`
1871
+ */
1872
+ export declare function normalizeQuery(query: DatabaseQueryInput | undefined): QueryInput | undefined;
1873
+
1874
+ /** Describes one sort term. */
1748
1875
  export declare const orderShape: ObjectShape<{
1749
1876
  column: StringShape;
1750
1877
  direction: LiteralShape<readonly ["ascending", "descending"]>;
1751
1878
  }, false>;
1752
1879
 
1753
- /** A draft phase — a `PhaseDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name` and {@link TaskDraft} tasks. */
1880
+ /** Represents a draft phase — a `PhaseDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name` and {@link TaskDraft} tasks. */
1754
1881
  export declare interface PhaseDraft {
1755
1882
  readonly id?: string;
1756
1883
  readonly name?: string;
1757
1884
  readonly description?: string;
1758
1885
  readonly tasks: readonly TaskDraft[];
1759
- /** Max tasks in flight at once (a resource throttle); omitted ⇒ unbounded. */
1886
+ /** Caps the tasks in flight at once (a resource throttle); omitted ⇒ unbounded. */
1760
1887
  readonly concurrency?: number;
1761
- /** The per-phase failure-policy OVERRIDE; omitted ⇒ inherits the workflow `bail`. */
1888
+ /** Holds the per-phase failure-policy OVERRIDE; omitted ⇒ inherits the workflow `bail`. */
1762
1889
  readonly bail?: boolean;
1763
1890
  }
1764
1891
 
1765
1892
  /**
1766
- * The shape of a PHASE in a draft workflow — identical to a strict phase shape EXCEPT `id` and
1893
+ * Describes the shape of a PHASE in a draft workflow — identical to a strict phase shape EXCEPT `id` and
1767
1894
  * `name` are OPTIONAL, and its tasks are {@link taskDraftShape}s.
1768
1895
  */
1769
1896
  export declare const phaseDraftShape: ObjectShape<{
@@ -1774,7 +1901,7 @@ export declare const phaseDraftShape: ObjectShape<{
1774
1901
  id: OptionalShape<StringShape>;
1775
1902
  name: OptionalShape<StringShape>;
1776
1903
  description: OptionalShape<StringShape>;
1777
- run: OptionalShape<StringShape>;
1904
+ behavior: OptionalShape<StringShape>;
1778
1905
  retries: OptionalShape<NumberShape>;
1779
1906
  timeout: OptionalShape<NumberShape>;
1780
1907
  }, false>>;
@@ -1782,26 +1909,26 @@ export declare const phaseDraftShape: ObjectShape<{
1782
1909
  bail: OptionalShape<LiteralShape<readonly [true, false]>>;
1783
1910
  }, false>;
1784
1911
 
1785
- /** The full form protocol {@link import('./factories.js').createPromptTool} advertises. */
1912
+ /** Holds the full form protocol {@link import('./factories.js').createPromptTool} advertises. */
1786
1913
  export declare const PROMPT_TOOL_DESCRIPTION: string;
1787
1914
 
1788
1915
  /**
1789
- * The name {@link import('./factories.js').createPromptTool} advertises by default — the key a
1916
+ * Holds the name {@link import('./factories.js').createPromptTool} advertises by default — the key a
1790
1917
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1791
1918
  */
1792
1919
  export declare const PROMPT_TOOL_NAME = "ask";
1793
1920
 
1794
1921
  /**
1795
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createPromptTool}
1922
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createPromptTool}
1796
1923
  * advertises in place of {@link PROMPT_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
1797
1924
  * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
1798
- * for the full teaching description; the full text stays retrievable via
1925
+ * for the full teaching description; the full text stays retrievable through
1799
1926
  * {@link import('./factories.js').createDescribeTool}.
1800
1927
  */
1801
1928
  export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a multi-field form and BLOCK until it answers; the call resolves with the values record. Call describe('ask') for the schema.";
1802
1929
 
1803
1930
  /**
1804
- * Options for {@link import('./factories.js').createPromptTool} — the live
1931
+ * Represents the options for {@link import('./factories.js').createPromptTool} — the live
1805
1932
  * {@link TerminalManagerInterface} (`@orkestrel/terminal`) to `ask` through, the terminal name
1806
1933
  * `from`, and the advertised tool overrides.
1807
1934
  *
@@ -1823,7 +1950,7 @@ export declare interface PromptToolOptions {
1823
1950
  }
1824
1951
 
1825
1952
  /**
1826
- * The shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
1953
+ * Describes the shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
1827
1954
  * terminal identity and `schema` carries the complete multi-field form document.
1828
1955
  *
1829
1956
  * @remarks
@@ -1835,35 +1962,7 @@ export declare const promptToolShape: ObjectShape<{
1835
1962
  schema: JSONShape;
1836
1963
  }, false>;
1837
1964
 
1838
- /**
1839
- * Normalize the database tool's parsed SERIALIZED query into a live `@orkestrel/database`
1840
- * {@link QueryInput} — default each condition's OMITTED `connector` to `'and'`.
1841
- *
1842
- * @remarks
1843
- * The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
1844
- * on the last condition (it has nothing to join FORWARD to); the compiled `Condition` a live
1845
- * `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
1846
- * `limit` / `offset` pass through unchanged. Pure and total.
1847
- *
1848
- * @param query - The parsed query (or `undefined`)
1849
- * @returns The equivalent live `QueryInput`, or `undefined` when `query` is `undefined`
1850
- */
1851
- export declare function queryOf(query: Readonly<{
1852
- conditions?: ReadonlyArray<Readonly<{
1853
- column: string;
1854
- operator: Condition['operator'];
1855
- values: readonly unknown[];
1856
- connector?: ConditionConnector;
1857
- }>>;
1858
- order?: ReadonlyArray<Readonly<{
1859
- column: string;
1860
- direction: OrderDirection;
1861
- }>>;
1862
- limit?: number;
1863
- offset?: number;
1864
- }> | undefined): QueryInput | undefined;
1865
-
1866
- /** The SERIALIZED query form — conditions, order, and pagination. */
1965
+ /** Describes the SERIALIZED query form — conditions, order, and pagination. */
1867
1966
  export declare const queryShape: ObjectShape<{
1868
1967
  conditions: OptionalShape<ArrayShape<ObjectShape<{
1869
1968
  column: StringShape;
@@ -1879,11 +1978,11 @@ export declare const queryShape: ObjectShape<{
1879
1978
  offset: OptionalShape<NumberShape>;
1880
1979
  }, false>;
1881
1980
 
1882
- /** The default cap on how many `include` path segments deep a `load` / `find` call may traverse — the relation tool's default include-depth ceiling. */
1981
+ /** Holds the default cap on how many `include` path segments deep a `load` / `find` call may traverse — the relation tool's default include-depth ceiling. */
1883
1982
  export declare const RELATION_TOOL_DEPTH = 3;
1884
1983
 
1885
1984
  /**
1886
- * The DESCRIPTION the relation tool advertises — a multi-line guide that teaches a small model
1985
+ * Holds the DESCRIPTION the relation tool advertises — a multi-line guide that teaches a small model
1887
1986
  * the operation list and the flat dot-path `include` syntax.
1888
1987
  *
1889
1988
  * @remarks
@@ -1892,64 +1991,23 @@ export declare const RELATION_TOOL_DEPTH = 3;
1892
1991
  */
1893
1992
  export declare const RELATION_TOOL_DESCRIPTION: string;
1894
1993
 
1895
- /** The default cap on rows a `find` / `links` call returns when the caller omits `limit` — the relation tool's default row ceiling. */
1994
+ /** Holds the default cap on rows a `find` / `links` call returns when the caller omits `limit` — the relation tool's default row ceiling. */
1896
1995
  export declare const RELATION_TOOL_LIMIT = 1000;
1897
1996
 
1898
1997
  /**
1899
- * The name `createRelationTool` advertises by default — the key a model calls and the
1998
+ * Holds the name `createRelationTool` advertises by default — the key a model calls and the
1900
1999
  * `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1901
2000
  */
1902
2001
  export declare const RELATION_TOOL_NAME = "relation";
1903
2002
 
1904
2003
  /**
1905
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} the relation tool advertises
2004
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} the relation tool advertises
1906
2005
  * in place of {@link RELATION_TOOL_DESCRIPTION}.
1907
2006
  */
1908
2007
  export declare const RELATION_TOOL_SUMMARY = "Traverse and edit relationships between database rows \u2014 one operation per call (load, find, link, unlink, links), chosen by the 'operation' field. Call describe('relation') for the include-path syntax.";
1909
2008
 
1910
- /** One key value — a string or number; the array form (multiple keys, positional) resolves FIRST per AGENTS §9.2. */
1911
- export declare const relationKeyShape: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1912
-
1913
- /**
1914
- * Resolve which registered {@link RelationManagerInterface} a relation-tool call addresses — the
1915
- * pure manager-resolution leaf {@link import('./factories.js').createRelationTool} calls on
1916
- * every operation.
1917
- *
1918
- * @remarks
1919
- * An explicit `name` must match a key of `managers` (a miss throws a typed `TOOL`
1920
- * {@link ToolboxError} naming the registered managers). An OMITTED `name` resolves to the sole
1921
- * registered manager when exactly one is registered, else throws the same typed error.
1922
- *
1923
- * @param managers - The tool's registered `RelationManagerInterface` map
1924
- * @param name - The call's optional `manager` field
1925
- * @returns The resolved {@link RelationManagerInterface}
1926
- */
1927
- export declare function relationManagerOf(managers: Readonly<Record<string, RelationManagerInterface>>, name: string | undefined): RelationManagerInterface;
1928
-
1929
- /**
1930
- * Resolve a `model` name against a live {@link RelationManagerInterface} — the pure model-lookup
1931
- * leaf {@link import('./factories.js').createRelationTool} calls on every operation, mirroring
1932
- * {@link relationManagerOf}'s guard shape.
1933
- *
1934
- * @param manager - The resolved {@link RelationManagerInterface}
1935
- * @param name - The call's `model` field
1936
- * @returns The model's {@link ModelInterface}
1937
- */
1938
- export declare function relationModelOf(manager: RelationManagerInterface, name: string): ModelInterface;
1939
-
1940
- /**
1941
- * Map a caught error to the {@link ToolboxErrorCode} the upcoming relation tool should throw
1942
- * with — the pure classification step of that factory's error handling, mirroring
1943
- * {@link terminalToolCode}'s idiom for `@orkestrel/relation`.
1944
- *
1945
- * @param error - The value caught from a `@orkestrel/relation` operation
1946
- * @returns The granular {@link RelationErrorCode}, or `undefined` if `error` is not a `RelationError`
1947
- */
1948
- export declare function relationToolCode(error: unknown): RelationErrorCode | undefined;
1949
-
1950
2009
  /**
1951
- * Options for {@link import('./factories.js').createRelationTool} — SRC-3 (the final unit) of
1952
- * the 3-unit database / relation spine.
2010
+ * Represents the options for {@link import('./factories.js').createRelationTool}.
1953
2011
  *
1954
2012
  * @remarks
1955
2013
  * - `managers` — the live `RelationManagerInterface` (`@orkestrel/relation`) registry a call's
@@ -1975,7 +2033,7 @@ export declare interface RelationToolOptions {
1975
2033
  }
1976
2034
 
1977
2035
  /**
1978
- * The shape of {@link import('./factories.js').createRelationTool}'s call arguments —
2036
+ * Describes the shape of {@link import('./factories.js').createRelationTool}'s call arguments —
1979
2037
  * discriminated by `operation` into the 5 relation operations (`'load'` / `'find'` / `'link'` /
1980
2038
  * `'unlink'` / `'links'`).
1981
2039
  *
@@ -2021,20 +2079,71 @@ export declare const relationToolShape: UnionShape<readonly [ ObjectShape<{
2021
2079
  relation: StringShape;
2022
2080
  }, false>]>;
2023
2081
 
2024
- /** A loose row — a flat object of column name to JSON value; the array form (multiple rows) resolves FIRST per AGENTS §9.2. */
2082
+ /**
2083
+ * Picks the effective row limit a tool reads with — the requested count when it sits inside the
2084
+ * cap, the cap when it exceeds it, and `0` when either falls below zero.
2085
+ *
2086
+ * @remarks
2087
+ * The one place the database tool's `'records'` clamp ({@link clampQuery}) and the relation tool's
2088
+ * `'find'` / `'links'` truncation both take their ceiling from, so a negative construction-time
2089
+ * option can never reach a slice. Pure and total.
2090
+ *
2091
+ * @example
2092
+ * ```ts
2093
+ * import { resolveLimit } from '@src/core'
2094
+ *
2095
+ * resolveLimit(undefined, 100) // 100 — an omitted request takes the cap
2096
+ * resolveLimit(500, 100) // 100 — a request over the cap is clamped down
2097
+ * resolveLimit(-1, 100) // 0 — a negative request floors at zero
2098
+ * ```
2099
+ *
2100
+ * @param requested - The caller's requested row count (or `undefined`)
2101
+ * @param cap - The row-count ceiling
2102
+ * @returns The effective row limit, never below `0` and never above `cap`
2103
+ */
2104
+ export declare function resolveLimit(requested: number | undefined, cap: number): number;
2105
+
2106
+ /**
2107
+ * Resolves which registered {@link RelationManagerInterface} a relation-tool call addresses — the
2108
+ * pure manager-resolution leaf {@link import('./factories.js').createRelationTool} calls on
2109
+ * every operation.
2110
+ *
2111
+ * @remarks
2112
+ * An explicit `name` must match a key of `managers` (a miss throws a typed `TOOL`
2113
+ * {@link ToolboxError} naming the registered managers). An OMITTED `name` resolves to the sole
2114
+ * registered manager when exactly one is registered, else throws the same typed error.
2115
+ *
2116
+ * @param managers - The tool's registered `RelationManagerInterface` map
2117
+ * @param name - The call's optional `manager` field
2118
+ * @returns The resolved {@link RelationManagerInterface}
2119
+ */
2120
+ export declare function resolveRelationManager(managers: Readonly<Record<string, RelationManagerInterface>>, name: string | undefined): RelationManagerInterface;
2121
+
2122
+ /**
2123
+ * Resolves a `model` name against a live {@link RelationManagerInterface} — the pure model-lookup
2124
+ * leaf {@link import('./factories.js').createRelationTool} calls on every operation, mirroring
2125
+ * {@link resolveRelationManager}'s guard shape.
2126
+ *
2127
+ * @param manager - The resolved {@link RelationManagerInterface}
2128
+ * @param name - The call's `model` field
2129
+ * @returns The model's {@link ModelInterface}
2130
+ */
2131
+ export declare function resolveRelationModel(manager: RelationManagerInterface, name: string): ModelInterface;
2132
+
2133
+ /** Describes a loose row — a flat object of column name to JSON value; the array form (multiple rows) resolves FIRST, so an array argument is read as many rows rather than one. */
2025
2134
  export declare const rowShape: ObjectShape<Record<never, never>, JSONShape>;
2026
2135
 
2027
- /** One or many loose rows — the array form resolves FIRST per AGENTS §9.2. */
2136
+ /** Describes one or many loose rows — the array form resolves FIRST, so an array argument is read as many rows rather than one. */
2028
2137
  export declare const rowsShape: UnionShape<readonly [ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
2029
2138
 
2030
- /** A single row key (not an array) — used by `'link'` / `'unlink'` / `'links'`, which address exactly one owning row. */
2139
+ /** Describes a single row key (not an array) — used by `'link'` / `'unlink'` / `'links'`, which address exactly one owning row. */
2031
2140
  export declare const singleKeyShape: UnionShape<readonly [ StringShape, NumberShape]>;
2032
2141
 
2033
2142
  /**
2034
- * The shape of ONE flat step — `{ name }` — the building block of {@link workflowStepsShape}.
2143
+ * Describes the shape of ONE flat step — `{ name }` — the building block of {@link workflowStepsShape}.
2035
2144
  *
2036
2145
  * @remarks
2037
- * `name` is the REGISTERED behavior name the step runs (it becomes the task's `run`). The tool
2146
+ * `name` is the REGISTERED behavior name the step runs (it becomes the task's `behavior`). The tool
2038
2147
  * expands each step into a one-task phase, in order ({@link import('./helpers.js').expandSteps}).
2039
2148
  */
2040
2149
  export declare const stepShape: ObjectShape<{
@@ -2042,24 +2151,66 @@ export declare const stepShape: ObjectShape<{
2042
2151
  }, false>;
2043
2152
 
2044
2153
  /**
2045
- * A database's table layout — one entry per table, each a flat map of column name to
2046
- * {@link ColumnSpec}. The small-model-facing DSL {@link import('./helpers.js').expandTables}
2154
+ * Builds the plain success summary {@link import('./factories.js').createWorkflowTool} returns on
2155
+ * a completed run — the universal tool-handler contract: return a plain value on success,
2156
+ * appearing identically over BOTH the agent loop and MCP.
2157
+ *
2158
+ * @remarks
2159
+ * The summary is LEAN: the workflow's terminal `status`, settled-task count, and exact optional
2160
+ * native persistence outcome. It carries no synthetic `id` / `name`: a tool handler has no call
2161
+ * id; the `ToolManagerInterface` (`@orkestrel/tool`) supplies the canonical envelope's identity.
2162
+ *
2163
+ * @param result - The terminal `WorkflowResult` (`@orkestrel/workflow`) the run produced
2164
+ * @returns The plain success summary — `{ status, count, durable?, fault? }`
2165
+ */
2166
+ export declare function summarizeWorkflow(result: WorkflowResult): WorkflowToolResult;
2167
+
2168
+ /**
2169
+ * Represents a database's table layout — one entry per table, each a flat map of column name to
2170
+ * {@link ColumnSpec}. The small-model-facing DSL {@link import('./compilers.js').expandTables}
2047
2171
  * compiles into an `@orkestrel/database` `TableMap`.
2048
2172
  */
2049
2173
  export declare type TableSpec = Readonly<Record<string, Readonly<{
2050
2174
  columns: Readonly<Record<string, ColumnSpec>>;
2051
2175
  }>>>;
2052
2176
 
2053
- /** A {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
2177
+ /** Describes a {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
2054
2178
  export declare const tableSpecShape: ObjectShape<Record<never, never>, ObjectShape<{
2055
2179
  columns: ObjectShape<Record<never, never>, UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
2056
- type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
2180
+ primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
2057
2181
  optional: OptionalShape<BooleanShape>;
2058
2182
  }, false>]>>;
2059
2183
  }, false>>;
2060
2184
 
2061
2185
  /**
2062
- * A draft task — a `TaskDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`.
2186
+ * Returns the ancestry identifier of an agent in a run chain — `agent:<name>`.
2187
+ *
2188
+ * @remarks
2189
+ * The agent counterpart of {@link tagWorkflow}: {@link import('./factories.js').createAgentFunction}
2190
+ * / {@link import('./factories.js').createWorkflowTool} guard against re-entering an agent or
2191
+ * workflow already in the chain (this package's typed `DEPTH` `ToolboxError`). The
2192
+ * `agent:` namespace keeps it distinct from a same-string workflow id.
2193
+ *
2194
+ * @param name - The agent's identifier / registry name
2195
+ * @returns The namespaced ancestry tag (`agent:<name>`)
2196
+ */
2197
+ export declare function tagAgent(name: string): string;
2198
+
2199
+ /**
2200
+ * Returns the ancestry identifier of a workflow in a run chain — `workflow:<id>`.
2201
+ *
2202
+ * @remarks
2203
+ * Namespacing keeps a workflow id and a {@link tagAgent} agent name in ONE set without
2204
+ * collision, so re-entering a workflow OR an agent already in the chain is a single `includes`
2205
+ * check.
2206
+ *
2207
+ * @param id - The workflow definition's `id`
2208
+ * @returns The namespaced ancestry tag (`workflow:<id>`)
2209
+ */
2210
+ export declare function tagWorkflow(id: string): string;
2211
+
2212
+ /**
2213
+ * Represents a draft task — a `TaskDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`.
2063
2214
  *
2064
2215
  * @remarks
2065
2216
  * The tool synthesizes a missing `id` positionally and defaults a missing `name` to its `id`
@@ -2070,46 +2221,29 @@ export declare interface TaskDraft {
2070
2221
  readonly id?: string;
2071
2222
  readonly name?: string;
2072
2223
  readonly description?: string;
2073
- /** The behavior reference — a registry key resolved against a workflow's functions registry at construction; omitted ⇒ a deliberate JSON `null` no-op. */
2074
- readonly run?: string;
2075
- /** Extra attempts after the first on failure (a non-negative integer); persisted with the workflow. */
2224
+ /** Holds the registry key resolved against a workflow's functions registry at construction; omitted ⇒ a deliberate JSON `null` no-op. */
2225
+ readonly behavior?: string;
2226
+ /** Holds the extra attempts after the first on failure (a non-negative integer); persisted with the workflow. */
2076
2227
  readonly retries?: number;
2077
- /** The per-attempt deadline in milliseconds (`0..MAX_TIMER_MS`); persisted with the workflow. */
2228
+ /** Holds the per-attempt deadline in milliseconds (`0..MAX_TIMER_MS`); persisted with the workflow. */
2078
2229
  readonly timeout?: number;
2079
2230
  }
2080
2231
 
2081
2232
  /**
2082
- * The shape of a {@link import('./types.js').TaskDraft} — identical to a strict task shape
2233
+ * Describes the shape of a {@link import('./types.js').TaskDraft} — identical to a strict task shape
2083
2234
  * EXCEPT `id` and `name` are OPTIONAL.
2084
2235
  */
2085
2236
  export declare const taskDraftShape: ObjectShape<{
2086
2237
  id: OptionalShape<StringShape>;
2087
2238
  name: OptionalShape<StringShape>;
2088
2239
  description: OptionalShape<StringShape>;
2089
- run: OptionalShape<StringShape>;
2240
+ behavior: OptionalShape<StringShape>;
2090
2241
  retries: OptionalShape<NumberShape>;
2091
2242
  timeout: OptionalShape<NumberShape>;
2092
2243
  }, false>;
2093
2244
 
2094
2245
  /**
2095
- * Map a caught error to the {@link ToolboxErrorCode} the terminal-tool factory should throw
2096
- * with — the pure classification step of that factory's error handling.
2097
- *
2098
- * @remarks
2099
- * Narrows `error` with {@link isTerminalError} (`@orkestrel/terminal`) first: a non-`TerminalError`
2100
- * value returns `undefined`, telling the caller this mapper does not apply (rethrow / handle
2101
- * otherwise). For a genuine `TerminalError`, `'DEADLOCK'` maps to `'DEADLOCK'`, `'EXPIRE'` maps
2102
- * to `'EXPIRE'`, and every other {@link import('@orkestrel/terminal').TerminalErrorCode}
2103
- * (`'TARGET'`, `'LIMIT'`, `'CANCEL'`, `'DRIVER'`, `'DESTROYED'`) maps to the generic `'TOOL'`
2104
- * code. The mapper only classifies — the factory performs the actual throw.
2105
- *
2106
- * @param error - The value caught from a terminal-manager operation (`ask` / `answer` / …)
2107
- * @returns The mapped {@link ToolboxErrorCode}, or `undefined` if `error` is not a `TerminalError`
2108
- */
2109
- export declare function terminalToolCode(error: unknown): ToolboxErrorCode | undefined;
2110
-
2111
- /**
2112
- * A package-owned tool-call failure: malformed input or unresolved configuration (`TOOL`),
2246
+ * Represents a package-owned tool-call failure: malformed input or unresolved configuration (`TOOL`),
2113
2247
  * delegation depth/cycle rejection (`DEPTH`), prompt failure (`DEADLOCK` / `EXPIRE` / `ANSWER`),
2114
2248
  * or a translated upstream database/relation failure (`DATABASE` / `RELATION`).
2115
2249
  *
@@ -2138,9 +2272,8 @@ export declare class ToolboxError extends Error {
2138
2272
  }
2139
2273
 
2140
2274
  /**
2141
- * The seven-value machine-readable code a thrown
2142
- * {@link import('./errors.js').ToolboxError} carries (AGENTS §14: a thrown, typed,
2143
- * code-bearing error, never a `{ error }` return).
2275
+ * Represents the machine-readable code a thrown {@link import('./errors.js').ToolboxError} carries — a
2276
+ * thrown, typed, code-bearing error, never a `{ error }` return.
2144
2277
  *
2145
2278
  * @remarks
2146
2279
  * `TOOL` — malformed calls and package-owned resolution or configuration failures, including
@@ -2163,26 +2296,26 @@ export declare class ToolboxError extends Error {
2163
2296
  export declare type ToolboxErrorCode = 'TOOL' | 'DEPTH' | 'DEADLOCK' | 'EXPIRE' | 'ANSWER' | 'DATABASE' | 'RELATION';
2164
2297
 
2165
2298
  /**
2166
- * The description {@link import('./factories.js').createWorkflowTool} advertises — the flat
2299
+ * Holds the description {@link import('./factories.js').createWorkflowTool} advertises — the flat
2167
2300
  * authoring form, its worked example, and the advanced nested definition form.
2168
2301
  */
2169
2302
  export declare const WORKFLOW_TOOL_DESCRIPTION: string;
2170
2303
 
2171
2304
  /**
2172
- * A complete FLAT authoring example — the PRIMARY way a small model authors a workflow through
2305
+ * Holds a complete FLAT authoring example — the PRIMARY way a small model authors a workflow through
2173
2306
  * {@link import('./factories.js').createWorkflowTool}: `{ name, steps: [{ name }] }`.
2174
2307
  *
2175
2308
  * @remarks
2176
2309
  * Each step becomes a one-task phase, in
2177
2310
  * order; a step's `name` is a REGISTERED behavior name (not a label) — the registry key its
2178
- * task's `run` resolves against. The tool expands this
2311
+ * task's `behavior` resolves against. The tool expands this
2179
2312
  * ({@link import('./helpers.js').expandSteps}) into a valid `WorkflowDefinition`
2180
2313
  * (`@orkestrel/workflow`). It is embedded VERBATIM in {@link WORKFLOW_TOOL_DESCRIPTION}.
2181
2314
  */
2182
2315
  export declare const WORKFLOW_TOOL_FLAT_EXAMPLE: WorkflowSteps;
2183
2316
 
2184
2317
  /**
2185
- * The name {@link import('./factories.js').createWorkflowTool} advertises by default — the key a
2318
+ * Holds the name {@link import('./factories.js').createWorkflowTool} advertises by default — the key a
2186
2319
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under, and the name
2187
2320
  * {@link import('./factories.js').createAgentFunction} binds the depth/cycle-aware workflow tool
2188
2321
  * under onto a wrapped agent's `context.tools`.
@@ -2191,12 +2324,12 @@ export declare const WORKFLOW_TOOL_FLAT_EXAMPLE: WorkflowSteps;
2191
2324
  * The propagation seam's well-known key: when
2192
2325
  * `createAgentFunction`'s `runner` option is supplied, it adds a `createWorkflowTool`-built tool
2193
2326
  * under this name to the agent's `context.tools`, so it can author + run a NESTED workflow
2194
- * (bounded by {@link MAX_WORKFLOW_DEPTH}).
2327
+ * (bounded by {@link MAX_WORKFLOW_CHAIN}).
2195
2328
  */
2196
2329
  export declare const WORKFLOW_TOOL_NAME = "workflow";
2197
2330
 
2198
2331
  /**
2199
- * A minimal NESTED authoring example — the ADVANCED escape-hatch form a model may use instead of
2332
+ * Holds a minimal NESTED authoring example — the ADVANCED escape-hatch form a model may use instead of
2200
2333
  * the flat shape: a full `WorkflowDefinition` (`@orkestrel/workflow`).
2201
2334
  *
2202
2335
  * @remarks
@@ -2206,25 +2339,25 @@ export declare const WORKFLOW_TOOL_NAME = "workflow";
2206
2339
  export declare const WORKFLOW_TOOL_NESTED_EXAMPLE: WorkflowDefinition;
2207
2340
 
2208
2341
  /**
2209
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createWorkflowTool}
2342
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createWorkflowTool}
2210
2343
  * advertises in place of {@link WORKFLOW_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
2211
2344
  * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
2212
- * for the full teaching description; the full text stays retrievable via
2345
+ * for the full teaching description; the full text stays retrievable through
2213
2346
  * {@link import('./factories.js').createDescribeTool}.
2214
2347
  */
2215
2348
  export declare const WORKFLOW_TOOL_SUMMARY = "Author and run a multi-phase workflow in one call \u2014 phases run in sequence, tasks within a phase run concurrently. Call describe('workflow') for the full authoring schema and examples.";
2216
2349
 
2217
- /** Raw live agents keyed by the workflow function names that invoke them. */
2350
+ /** Represents raw live agents keyed by the workflow function names that invoke them. */
2218
2351
  export declare type WorkflowAgents = Readonly<Record<string, AgentInterface>>;
2219
2352
 
2220
2353
  /**
2221
- * A draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`
2354
+ * Represents a draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`
2222
2355
  * at all three levels (workflow / phase / task).
2223
2356
  *
2224
2357
  * @remarks
2225
2358
  * The lenient authoring form {@link import('./factories.js').createWorkflowDraftContract}
2226
2359
  * validates and {@link import('./helpers.js').completeDraft} completes into a strict
2227
- * `WorkflowDefinition`. `run` stays optional (a plain name string); the `bail` policy carries
2360
+ * `WorkflowDefinition`. `behavior` stays optional (a plain name string); the `bail` policy carries
2228
2361
  * over.
2229
2362
  */
2230
2363
  export declare interface WorkflowDraft {
@@ -2232,18 +2365,18 @@ export declare interface WorkflowDraft {
2232
2365
  readonly name?: string;
2233
2366
  readonly description?: string;
2234
2367
  readonly phases: readonly PhaseDraft[];
2235
- /** Failure policy: `false` (default) continues gracefully, `true` halts on the first failure. */
2368
+ /** Holds the failure policy: `false` (default) continues gracefully, `true` halts on the first failure. */
2236
2369
  readonly bail?: boolean;
2237
2370
  }
2238
2371
 
2239
2372
  /**
2240
- * The shape of a DRAFT workflow — identical to a strict workflow shape EXCEPT `id` and `name`
2373
+ * Describes the shape of a DRAFT workflow — identical to a strict workflow shape EXCEPT `id` and `name`
2241
2374
  * are OPTIONAL at all three levels (workflow / phase / task), so a small model can omit the six
2242
2375
  * identity strings and let the tool synthesize them positionally.
2243
2376
  *
2244
2377
  * @remarks
2245
2378
  * The lenient counterpart {@link import('./factories.js').createWorkflowDraftContract} compiles.
2246
- * `run` stays optional like the strict form; omission is the deliberate JSON `null` no-op. A
2379
+ * `behavior` stays optional like the strict form; omission is the deliberate JSON `null` no-op. A
2247
2380
  * provided `id` / `name` still has `minLength: 1` (so
2248
2381
  * an explicitly-empty `id: ''` is REJECTED, not auto-filled). After
2249
2382
  * {@link import('./helpers.js').completeDraft} fills the missing ids/names, the result is
@@ -2262,7 +2395,7 @@ export declare const workflowDraftShape: ObjectShape<{
2262
2395
  id: OptionalShape<StringShape>;
2263
2396
  name: OptionalShape<StringShape>;
2264
2397
  description: OptionalShape<StringShape>;
2265
- run: OptionalShape<StringShape>;
2398
+ behavior: OptionalShape<StringShape>;
2266
2399
  retries: OptionalShape<NumberShape>;
2267
2400
  timeout: OptionalShape<NumberShape>;
2268
2401
  }, false>>;
@@ -2272,23 +2405,23 @@ export declare const workflowDraftShape: ObjectShape<{
2272
2405
  bail: OptionalShape<LiteralShape<readonly [true, false]>>;
2273
2406
  }, false>;
2274
2407
 
2275
- /** One immutable workflow/agent call chain, beginning with a workflow tag. */
2408
+ /** Represents one immutable workflow/agent call chain, beginning with a workflow tag. */
2276
2409
  export declare type WorkflowLineage = readonly string[];
2277
2410
 
2278
2411
  /**
2279
- * One flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
2412
+ * Represents one flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
2280
2413
  *
2281
2414
  * @remarks
2282
- * `name` is the REGISTERED behavior name the step runs (it becomes the task's `run`, NOT a
2415
+ * `name` is the REGISTERED behavior name the step runs (it becomes the task's `behavior`, NOT a
2283
2416
  * human label) — resolved against a workflow-level functions registry at construction.
2284
2417
  */
2285
2418
  export declare interface WorkflowStep {
2286
- /** The registered behavior name this step runs (becomes the task's `run`). */
2419
+ /** Names the registered behavior this step runs (becomes the task's `behavior`). */
2287
2420
  readonly name: string;
2288
2421
  }
2289
2422
 
2290
2423
  /**
2291
- * The FLAT authoring blob {@link import('./factories.js').createWorkflowTool} advertises —
2424
+ * Represents the FLAT authoring blob {@link import('./factories.js').createWorkflowTool} advertises —
2292
2425
  * `{ name?, steps }` — the simplest surface a small model can fill.
2293
2426
  *
2294
2427
  * @remarks
@@ -2302,7 +2435,7 @@ export declare interface WorkflowSteps {
2302
2435
  }
2303
2436
 
2304
2437
  /**
2305
- * The FLAT authoring shape {@link import('./factories.js').createWorkflowTool} advertises as its
2438
+ * Describes the FLAT authoring shape {@link import('./factories.js').createWorkflowTool} advertises as its
2306
2439
  * `parameters` — the simplest surface a small model can fill: `{ name?, steps: [{ name }] }`.
2307
2440
  *
2308
2441
  * @remarks
@@ -2322,20 +2455,7 @@ export declare const workflowStepsShape: ObjectShape<{
2322
2455
  }, false>;
2323
2456
 
2324
2457
  /**
2325
- * The ancestry identifier of a workflow in a run chain — `workflow:<id>`.
2326
- *
2327
- * @remarks
2328
- * Namespacing keeps a workflow id and an {@link agentTag} agent name in ONE set without
2329
- * collision, so re-entering a workflow OR an agent already in the chain is a single `includes`
2330
- * check.
2331
- *
2332
- * @param id - The workflow definition's `id`
2333
- * @returns The namespaced ancestry tag (`workflow:<id>`)
2334
- */
2335
- export declare function workflowTag(id: string): string;
2336
-
2337
- /**
2338
- * Options for {@link import('./factories.js').createWorkflowTool} and
2458
+ * Represents the options for {@link import('./factories.js').createWorkflowTool} and
2339
2459
  * {@link import('./factories.js').createWorkflowFunctions} — lineage-aware composition of opaque
2340
2460
  * leaves, raw agents, and native workflow persistence.
2341
2461
  *
@@ -2348,40 +2468,25 @@ export declare function workflowTag(id: string): string;
2348
2468
  */
2349
2469
  export declare interface WorkflowToolOptions {
2350
2470
  readonly lineage?: WorkflowLineage;
2351
- readonly functions?: WorkflowFunctions;
2471
+ readonly functions?: WorkflowRegistry;
2352
2472
  readonly agents?: WorkflowAgents;
2353
2473
  readonly store?: WorkflowStoreInterface;
2354
2474
  }
2355
2475
 
2356
- /** The JSON-safe run summary returned by {@link import('./factories.js').createWorkflowTool}. */
2476
+ /** Represents the JSON-safe run summary returned by {@link import('./factories.js').createWorkflowTool}. */
2357
2477
  export declare interface WorkflowToolResult {
2358
- /** The workflow's native terminal status. */
2359
- readonly status: WorkflowStatus;
2360
- /** The number of settled task results. */
2478
+ /** Holds the run's terminal {@link LifecycleStatus}. */
2479
+ readonly status: LifecycleStatus;
2480
+ /** Holds the tally of settled task results. */
2361
2481
  readonly count: number;
2362
- /** Whether the native runner stored its final state; omitted when no store was supplied. */
2482
+ /** Reports whether the native runner stored its final state; omitted when no store was supplied. */
2363
2483
  readonly durable?: boolean;
2364
- /** The native runner's first persistence failure; omitted when none occurred. */
2484
+ /** Holds the native runner's first persistence failure; omitted when none occurred. */
2365
2485
  readonly fault?: WorkflowFault;
2366
2486
  }
2367
2487
 
2368
2488
  /**
2369
- * Build the plain success summary {@link import('./factories.js').createWorkflowTool} returns on
2370
- * a completed run — the universal tool-handler contract (AGENTS §14): return a plain value on
2371
- * success, appearing identically over BOTH the agent loop and MCP.
2372
- *
2373
- * @remarks
2374
- * The summary is LEAN: the workflow's terminal `status`, settled-task count, and exact optional
2375
- * native persistence outcome. It carries no synthetic `id` / `name`: a tool handler has no call
2376
- * id; the `ToolManagerInterface` (`@orkestrel/tool`) supplies the canonical envelope's identity.
2377
- *
2378
- * @param result - The terminal `WorkflowResult` (`@orkestrel/workflow`) the run produced
2379
- * @returns The plain success summary — `{ status, count, durable?, fault? }`
2380
- */
2381
- export declare function workflowToolSummary(result: WorkflowResult): WorkflowToolResult;
2382
-
2383
- /**
2384
- * The description {@link import('./factories.js').createWorkspaceTool} advertises — the
2489
+ * Holds the description {@link import('./factories.js').createWorkspaceTool} advertises — the
2385
2490
  * operation-keyed workspace protocol, all supported operations, and worked examples.
2386
2491
  *
2387
2492
  * @remarks
@@ -2391,7 +2496,7 @@ export declare function workflowToolSummary(result: WorkflowResult): WorkflowToo
2391
2496
  export declare const WORKSPACE_TOOL_DESCRIPTION: string;
2392
2497
 
2393
2498
  /**
2394
- * A valid {@link import('./types.js').WorkspaceOperation} object — the canonical example embedded
2499
+ * Holds a valid {@link import('./types.js').WorkspaceOperation} object — the canonical example embedded
2395
2500
  * VERBATIM in {@link WORKSPACE_TOOL_DESCRIPTION}.
2396
2501
  *
2397
2502
  * @remarks
@@ -2402,25 +2507,25 @@ export declare const WORKSPACE_TOOL_DESCRIPTION: string;
2402
2507
  export declare const WORKSPACE_TOOL_EXAMPLE: WorkspaceOperation;
2403
2508
 
2404
2509
  /**
2405
- * The name {@link import('./factories.js').createWorkspaceTool} advertises by default — the key a
2510
+ * Holds the name {@link import('./factories.js').createWorkspaceTool} advertises by default — the key a
2406
2511
  * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
2407
2512
  */
2408
2513
  export declare const WORKSPACE_TOOL_NAME = "workspace";
2409
2514
 
2410
2515
  /**
2411
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createWorkspaceTool}
2516
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createWorkspaceTool}
2412
2517
  * advertises in place of {@link WORKSPACE_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
2413
2518
  * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
2414
- * for the full teaching description; the full text stays retrievable via
2519
+ * for the full teaching description; the full text stays retrievable through
2415
2520
  * {@link import('./factories.js').createDescribeTool}.
2416
2521
  */
2417
2522
  export declare const WORKSPACE_TOOL_SUMMARY = "Read and edit files in a workspace \u2014 one operation per call (read, write, list, search, replace, splice, move, remove, plus workspace switching), chosen by the 'operation' field. Call describe('workspace') for the full operation list and fields.";
2418
2523
 
2419
2524
  /**
2420
- * One operation an agent invokes through {@link import('./factories.js').createWorkspaceTool} — a
2421
- * FLAT, descriptive tagged union over the 13 workspace edit / read / navigation actions,
2422
- * discriminated by the `operation` literal (AGENTS §4.8: a discriminant is named for its axis —
2423
- * the action being performed — NEVER `kind`).
2525
+ * Represents one operation an agent invokes through {@link import('./factories.js').createWorkspaceTool} — a
2526
+ * FLAT, descriptive tagged union over the workspace edit, read, and navigation actions,
2527
+ * discriminated by the `operation` literal (a discriminant is named for its axis — the action
2528
+ * being performed — NEVER `kind`).
2424
2529
  *
2425
2530
  * @remarks
2426
2531
  * This is the SOURCE OF TRUTH the tool contract is typed to
@@ -2436,22 +2541,22 @@ export declare const WORKSPACE_TOOL_SUMMARY = "Read and edit files in a workspac
2436
2541
  * the edit / read arms target.
2437
2542
  */
2438
2543
  export declare type WorkspaceOperation =
2439
- /** Read a whole text file's text by `path` from the ACTIVE workspace (a binary / absent path — or no active workspace — yields no content). */
2544
+ /** Reads a whole text file's text by `path` from the ACTIVE workspace (a binary / absent path — or no active workspace — yields no content). */
2440
2545
  {
2441
2546
  readonly operation: 'read';
2442
2547
  readonly path: string;
2443
2548
  }
2444
- /** List every file in the ACTIVE workspace (path / state / size / lines / kind summaries); `[]` when no workspace is active. */
2549
+ /** Lists every file in the ACTIVE workspace (path / state / size / lines / kind summaries); `[]` when no workspace is active. */
2445
2550
  | {
2446
2551
  readonly operation: 'list';
2447
2552
  }
2448
- /** Whether a file exists at `path` in the ACTIVE workspace (`false` when no workspace is active). */
2553
+ /** Reports whether a file exists at `path` in the ACTIVE workspace (`false` when no workspace is active). */
2449
2554
  | {
2450
2555
  readonly operation: 'has';
2451
2556
  readonly path: string;
2452
2557
  }
2453
2558
  /**
2454
- * Scan every text file for `query`, returning each hit (path + 1-based line / column + the line).
2559
+ * Scans every text file for `query`, returning each hit (path + 1-based line / column + the line).
2455
2560
  *
2456
2561
  * @remarks
2457
2562
  * `regex` treats `query` as a regular-expression source (default `false` — a literal substring);
@@ -2465,7 +2570,7 @@ export declare type WorkspaceOperation =
2465
2570
  readonly limit?: number;
2466
2571
  }
2467
2572
  /**
2468
- * Replace `query` with `replacement` across every text file, returning the tally.
2573
+ * Replaces `query` with `replacement` across every text file, returning the tally.
2469
2574
  *
2470
2575
  * @remarks
2471
2576
  * Same matching axes as `search`: `regex` (default `false`), `sensitive` (default `true`),
@@ -2479,21 +2584,21 @@ export declare type WorkspaceOperation =
2479
2584
  readonly sensitive?: boolean;
2480
2585
  readonly limit?: number;
2481
2586
  }
2482
- /** Write (create or overwrite) the whole file at `path` with `content`. */
2587
+ /** Writes (creates or overwrites) the whole file at `path` with `content`. */
2483
2588
  | {
2484
2589
  readonly operation: 'write';
2485
2590
  readonly path: string;
2486
2591
  readonly content: string;
2487
2592
  }
2488
2593
  /**
2489
- * Splice `content` into an existing text file, replacing the 1-based range
2594
+ * Splices `content` into an existing text file, replacing the 1-based range
2490
2595
  * `(fromLine, fromColumn)` (INCLUSIVE) → `(toLine, toColumn)` (EXCLUSIVE).
2491
2596
  *
2492
2597
  * @remarks
2493
2598
  * The FLAT range edit — the four positive-integer caret components reassemble into a `Range`
2494
- * (`@orkestrel/workspace`) via `rangeOf`. An empty span (`from === to`) inserts; a span past
2599
+ * (`@orkestrel/workspace`) through `rangeOf`. An empty span (`from === to`) inserts; a span past
2495
2600
  * the end is clamped. An inverted / sub-1 range throws `RANGE`; a binary target throws
2496
- * `MODALITY`.
2601
+ * `MODALITY`; a missing target throws `MISSING`.
2497
2602
  */
2498
2603
  | {
2499
2604
  readonly operation: 'splice';
@@ -2504,41 +2609,41 @@ export declare type WorkspaceOperation =
2504
2609
  readonly toLine: number;
2505
2610
  readonly toColumn: number;
2506
2611
  }
2507
- /** Prepend `content` to the start of the file at `path` (creating it when absent). */
2612
+ /** Prepends `content` to the start of the file at `path` (creating it when absent). */
2508
2613
  | {
2509
2614
  readonly operation: 'prepend';
2510
2615
  readonly path: string;
2511
2616
  readonly content: string;
2512
2617
  }
2513
- /** Append `content` to the end of the file at `path` (creating it when absent). */
2618
+ /** Appends `content` to the end of the file at `path` (creating it when absent). */
2514
2619
  | {
2515
2620
  readonly operation: 'append';
2516
2621
  readonly path: string;
2517
2622
  readonly content: string;
2518
2623
  }
2519
- /** Re-key the file `from` → `to` (overwriting an occupied target). */
2624
+ /** Re-keys the file `from` → `to` (overwriting an occupied target). */
2520
2625
  | {
2521
2626
  readonly operation: 'move';
2522
2627
  readonly from: string;
2523
2628
  readonly to: string;
2524
2629
  }
2525
- /** Remove the file at `path` from the workspace. */
2630
+ /** Removes the file at `path` from the workspace. */
2526
2631
  | {
2527
2632
  readonly operation: 'remove';
2528
2633
  readonly path: string;
2529
2634
  }
2530
- /** List the workspaces the model can move between — each `{ id, files, active }` — so it can choose an `id` to `switch` to. */
2635
+ /** Lists the workspaces the model can move between — each `{ id, files, active }` — so it can choose an `id` to `switch` to. */
2531
2636
  | {
2532
2637
  readonly operation: 'workspaces';
2533
2638
  }
2534
- /** Re-point the manager's ACTIVE workspace to the one with `id` (an unknown `id` is a lenient no-op). The edit / read arms target the active workspace from then on. */
2639
+ /** Re-points the manager's ACTIVE workspace to the one with `id` (an unknown `id` is a lenient no-op). The edit / read arms target the active workspace from then on. */
2535
2640
  | {
2536
2641
  readonly operation: 'switch';
2537
2642
  readonly id: string;
2538
2643
  };
2539
2644
 
2540
2645
  /**
2541
- * Options for {@link import('./factories.js').createWorkspaceTool} — EITHER a caller-built
2646
+ * Represents the options for {@link import('./factories.js').createWorkspaceTool} — EITHER a caller-built
2542
2647
  * {@link WorkspaceManagerInterface} to drive directly, OR a {@link WorkspaceStoreInterface} the
2543
2648
  * tool constructs a fresh manager over; neither given constructs a manager over
2544
2649
  * `@orkestrel/workspace`'s in-memory store.
@@ -2546,7 +2651,7 @@ export declare type WorkspaceOperation =
2546
2651
  * @remarks
2547
2652
  * - `manager` — drive THIS manager directly (its `active` workspace is what every edit / read
2548
2653
  * operation targets). Takes priority over `store` when both are supplied.
2549
- * - `store` — construct a manager over this durable {@link WorkspaceStoreInterface} (via
2654
+ * - `store` — construct a manager over this durable {@link WorkspaceStoreInterface} (through
2550
2655
  * `@orkestrel/workspace`'s `createWorkspaceManager`) — used only when `manager` is omitted.
2551
2656
  * The store only backs the manager's own `open` / `save` operations: the tool's edits are
2552
2657
  * NOT auto-persisted — durability requires an explicit caller `save` on the manager
@@ -2562,10 +2667,10 @@ export declare interface WorkspaceToolOptions {
2562
2667
  }
2563
2668
 
2564
2669
  /**
2565
- * The shape of a {@link import('./types.js').WorkspaceOperation} — a descriptive tagged union
2566
- * over the 13 workspace edit / read / navigation operations, discriminated by the `operation`
2567
- * literal (never a bare `kind`; AGENTS §4.4). Each variant leads with its `operation`
2568
- * discriminant then its FLAT fields, every field via `stringShape` / `optionalShape` /
2670
+ * Describes the shape of a {@link import('./types.js').WorkspaceOperation} — a descriptive tagged union
2671
+ * over the workspace edit, read, and navigation operations, discriminated by the `operation`
2672
+ * literal (never a bare `kind`). Each variant leads with its `operation`
2673
+ * discriminant then its FLAT fields, every field through `stringShape` / `optionalShape` /
2569
2674
  * `integerShape({ min: 1 })` / `booleanShape`, each carrying a strong field-level `description`.
2570
2675
  *
2571
2676
  * @remarks