@orkestrel/toolbox 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,55 +1,55 @@
1
- import { AgentInterface } from '@orkestrel/agent';
2
- import { AgentRegistryInterface } from '@orkestrel/agent';
1
+ import type { AgentInterface } from '@orkestrel/agent';
2
+ import type { AgentRegistryInterface } from '@orkestrel/agent';
3
3
  import { ArrayShape } from '@orkestrel/contract';
4
4
  import { BooleanShape } from '@orkestrel/contract';
5
- import { Condition } from '@orkestrel/database';
6
- import { ConditionConnector } from '@orkestrel/database';
7
- import { ContractInterface } from '@orkestrel/contract';
8
- import { ContractShape } from '@orkestrel/contract';
9
- import { ConversationStoreInterface } from '@orkestrel/agent';
10
- import { DatabaseErrorCode } from '@orkestrel/database';
11
- import { DatabaseInterface } from '@orkestrel/database';
12
- import { DriverInterface } from '@orkestrel/database';
13
- import { Include } from '@orkestrel/relation';
14
- import { IndexMap } from '@orkestrel/database';
5
+ import type { Condition } from '@orkestrel/database';
6
+ import type { ConditionConnector } from '@orkestrel/database';
7
+ import type { ContractInterface } from '@orkestrel/contract';
8
+ import type { ContractShape } from '@orkestrel/contract';
9
+ import type { ConversationStoreInterface } from '@orkestrel/agent';
10
+ import type { DatabaseErrorCode } from '@orkestrel/database';
11
+ import type { DatabaseInterface } from '@orkestrel/database';
12
+ import type { DriverInterface } from '@orkestrel/database';
13
+ import type { Include } from '@orkestrel/relation';
14
+ import type { IndexMap } from '@orkestrel/database';
15
15
  import { JSONShape } from '@orkestrel/contract';
16
- import { KeyFunction } from '@orkestrel/database';
16
+ import type { KeyFunction } from '@orkestrel/database';
17
+ import type { LifecycleStatus } from '@orkestrel/workflow';
17
18
  import { LiteralShape } from '@orkestrel/contract';
18
- import { ModelInterface } from '@orkestrel/relation';
19
+ import type { ModelInterface } from '@orkestrel/relation';
19
20
  import { NumberShape } from '@orkestrel/contract';
20
21
  import { ObjectShape } from '@orkestrel/contract';
21
22
  import { OptionalShape } from '@orkestrel/contract';
22
- import { OrderDirection } from '@orkestrel/database';
23
- import { PrimaryMap } from '@orkestrel/database';
24
- import { QueryInput } from '@orkestrel/database';
25
- import { RelationErrorCode } from '@orkestrel/relation';
26
- import { RelationManagerInterface } from '@orkestrel/relation';
23
+ import type { OrderDirection } from '@orkestrel/database';
24
+ import type { PrimaryMap } from '@orkestrel/database';
25
+ import type { QueryInput } from '@orkestrel/database';
26
+ import type { RelationErrorCode } from '@orkestrel/relation';
27
+ import type { RelationManagerInterface } from '@orkestrel/relation';
27
28
  import { StringShape } from '@orkestrel/contract';
28
- import { TableInterface } from '@orkestrel/database';
29
- import { TableMap } from '@orkestrel/database';
30
- import { TerminalManagerInterface } from '@orkestrel/terminal';
31
- import { ToolInterface } from '@orkestrel/tool';
32
- import { ToolManagerInterface } from '@orkestrel/tool';
29
+ import type { TableInterface } from '@orkestrel/database';
30
+ import type { TableMap } from '@orkestrel/database';
31
+ import type { TerminalManagerInterface } from '@orkestrel/terminal';
32
+ import type { ToolInterface } from '@orkestrel/tool';
33
+ import type { ToolManagerInterface } from '@orkestrel/tool';
33
34
  import { UnionShape } from '@orkestrel/contract';
34
- import { WorkflowDefinition } from '@orkestrel/workflow';
35
- import { WorkflowFault } from '@orkestrel/workflow';
36
- import { WorkflowFunction } from '@orkestrel/workflow';
37
- import { WorkflowFunctions } from '@orkestrel/workflow';
38
- import { WorkflowResult } from '@orkestrel/workflow';
39
- import { WorkflowRunnerInterface } from '@orkestrel/workflow';
40
- import { WorkflowStatus } from '@orkestrel/workflow';
41
- import { WorkflowStoreInterface } from '@orkestrel/workflow';
42
- import { WorkspaceManagerInterface } from '@orkestrel/workspace';
43
- import { WorkspaceStoreInterface } from '@orkestrel/workspace';
44
-
45
- /**
46
- * The maximum nesting depth a delegation chain (agent tool → sub-agent → agent tool → …) may
47
- * reach — the bound {@link import('./factories.js').createAgentTool}'s depth/cycle guard
35
+ import type { WorkflowDefinition } from '@orkestrel/workflow';
36
+ import type { WorkflowFault } from '@orkestrel/workflow';
37
+ import type { WorkflowFunction } from '@orkestrel/workflow';
38
+ import type { WorkflowRegistry } from '@orkestrel/workflow';
39
+ import type { WorkflowResult } from '@orkestrel/workflow';
40
+ import type { WorkflowRunnerInterface } from '@orkestrel/workflow';
41
+ import type { WorkflowStoreInterface } from '@orkestrel/workflow';
42
+ import type { WorkspaceManagerInterface } from '@orkestrel/workspace';
43
+ import type { WorkspaceStoreInterface } from '@orkestrel/workspace';
44
+
45
+ /**
46
+ * Holds the maximum nesting depth a delegation chain (agent tool → sub-agent → agent tool → …) may
47
+ * reach, `8` — 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
52
- * sharing one reference): the two guards bound DIFFERENT chains (workflow nesting vs. agent
51
+ * Deliberately a separate constant from {@link MAX_WORKFLOW_CHAIN} (rather than the guards
52
+ * sharing one reference): they bound different chains (workflow nesting against 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
55
55
  * by shared reference.
@@ -57,36 +57,40 @@ 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
67
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
66
+ * Holds the name {@link import('./factories.js').createAgentTool} advertises by default, `'agent'`
67
+ * — the key a 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}
73
- * advertises in place of {@link AGENT_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
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
76
- * {@link import('./factories.js').createDescribeTool}.
72
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
73
+ * {@link import('./factories.js').createAgentTool} advertises in place of
74
+ * {@link AGENT_TOOL_DESCRIPTION} — one sentence offering sub-agent delegation and pointing at
75
+ * `describe` for the optional overrides.
76
+ *
77
+ * @remarks
78
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
79
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
80
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
77
81
  */
78
82
  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
83
 
80
- /** A contextual agent adapter carrying immutable metadata for Toolbox composition. */
84
+ /** Represents a contextual agent adapter carrying immutable metadata for Toolbox composition. */
81
85
  export declare type AgentFunction = WorkflowFunction & {
82
86
  readonly category: 'agent';
83
87
  readonly lineage: WorkflowLineage;
84
88
  };
85
89
 
86
90
  /**
87
- * Options for {@link import('./factories.js').createAgentFunction} — the OPT-IN adapter that
88
- * wraps a live `AgentInterface` (`@orkestrel/agent`) as an {@link AgentFunction} with immutable
89
- * lineage metadata and optional nested-workflow composition.
91
+ * Represents the options for {@link import('./factories.js').createAgentFunction} — the opt-in
92
+ * adapter that wraps a live `AgentInterface` (`@orkestrel/agent`) as an {@link AgentFunction} with
93
+ * immutable lineage metadata and optional nested-workflow composition.
90
94
  *
91
95
  * @remarks
92
96
  * All fields are optional. An empty lineage is resolved from the controller's root workflow when
@@ -103,34 +107,20 @@ export declare type AgentFunction = WorkflowFunction & {
103
107
  export declare interface AgentFunctionOptions {
104
108
  readonly runner?: WorkflowRunnerInterface;
105
109
  readonly lineage?: WorkflowLineage;
106
- readonly functions?: WorkflowFunctions;
110
+ readonly functions?: WorkflowRegistry;
107
111
  readonly agents?: WorkflowAgents;
108
112
  readonly store?: WorkflowStoreInterface;
109
113
  }
110
114
 
111
115
  /**
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`
127
- * plus the minimal optional `AgentJobInput` (`@orkestrel/agent`) fields a caller may override
128
- * per-call.
116
+ * Represents the flat args {@link import('./factories.js').createAgentTool} accepts — a delegated
117
+ * `task` plus the minimal optional `AgentJobInput` (`@orkestrel/agent`) fields a caller may
118
+ * override per-call.
129
119
  *
130
120
  * @remarks
131
121
  * `task` becomes the seed user message in the sub-agent's rehydrated conversation
132
122
  * (`AgentJobInput.messages`). `provider` / `tools` / `system` shadow the tool's own
133
- * {@link AgentToolOptions} defaults for this ONE call when supplied.
123
+ * {@link AgentToolOptions} defaults for this one call when supplied.
134
124
  */
135
125
  export declare interface AgentToolArguments {
136
126
  readonly task: string;
@@ -140,18 +130,18 @@ export declare interface AgentToolArguments {
140
130
  }
141
131
 
142
132
  /**
143
- * Options for {@link import('./factories.js').createAgentTool} — the sub-agent delegation
133
+ * Represents the options for {@link import('./factories.js').createAgentTool} — the sub-agent delegation
144
134
  * defaults, the nesting-depth / cycle guard bookkeeping, and the advertised tool overrides.
145
135
  *
146
136
  * @remarks
147
137
  * - `name` / `description` — advertised tool overrides; default to
148
138
  * {@link import('./constants.js').AGENT_TOOL_NAME} / {@link import('./constants.js').AGENT_TOOL_DESCRIPTION}.
149
- * - `provider` — the DEFAULT registry provider key used when a call omits `provider`; a call
150
- * that supplies its own `provider` overrides this. One of `provider` (here or per-call) MUST
139
+ * - `provider` — the default registry provider key used when a call omits `provider`; a call
140
+ * that supplies its own `provider` overrides this. One of `provider` (here or per-call) must
151
141
  * resolve, or the handler throws a typed `TOOL` {@link import('./errors.js').ToolboxError}.
152
- * - `tools` — the DEFAULT registry tool-name list loaded into the delegated sub-agent; a
142
+ * - `tools` — the default registry tool-name list loaded into the delegated sub-agent; a
153
143
  * per-call `tools` list overrides (never merges with) this default.
154
- * - `system` — the DEFAULT system prompt seeding the sub-agent's context; a per-call `system`
144
+ * - `system` — the default system prompt seeding the sub-agent's context; a per-call `system`
155
145
  * overrides this.
156
146
  * - `depth` — this invocation's nesting depth (default `0`); a delegated sub-agent that itself
157
147
  * calls this tool again runs at `depth + 1`, bounded by
@@ -159,17 +149,17 @@ export declare interface AgentToolArguments {
159
149
  * - `ancestry` — the sub-agent identifiers already in this delegation chain (default empty); a
160
150
  * cycle (the resolved agent already present) is rejected with a typed `DEPTH`
161
151
  * {@link import('./errors.js').ToolboxError}.
162
- * - `store` — this package's ADDITION: when supplied, the handler persists the delegated
152
+ * - `store` — this package's addition: when supplied, the handler persists the delegated
163
153
  * sub-agent's active conversation snapshot (`store.set(agent.context.conversations.active.snapshot())`)
164
- * once `agent.generate()` settles successfully, before returning — one snapshot per delegation
154
+ * after `agent.generate()` settles successfully, before returning — one snapshot per delegation
165
155
  * (each `registry.build` mints a fresh conversation id, so a shared store accumulates an
166
156
  * audit log rather than colliding). Omitted ⇒ no persistence from this tool.
167
157
  *
168
- * 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
158
+ * Conversation persistence for a delegated sub-agent has independent seams, composable
159
+ * together: this `store` slot persists each delegation's conversation individually, and an
170
160
  * `AgentRegistryInterface` built with `AgentRegistryOptions.store` (`@orkestrel/agent`) backs
171
- * EVERY agent it builds — including ones built through this tool — with a store-backed
172
- * `ConversationManagerInterface` of its own. Neither is required; either or both may be used.
161
+ * every agent it builds — including ones built through this tool — with a store-backed
162
+ * `ConversationManagerInterface` of its own. Neither is required, and they compose.
173
163
  */
174
164
  export declare interface AgentToolOptions {
175
165
  readonly name?: string;
@@ -183,49 +173,57 @@ export declare interface AgentToolOptions {
183
173
  }
184
174
 
185
175
  /**
186
- * The shape of {@link import('./types.js').AgentToolArguments} —
176
+ * Describes the shape of {@link import('./types.js').AgentToolArguments} —
187
177
  * {@link import('./factories.js').createAgentTool}'s advertised `parameters`.
188
178
  *
189
179
  * @remarks
190
180
  * `task` is the only required field (a non-empty string); `provider` / `tools` / `system`
191
181
  * are per-call overrides of the tool's own configured defaults.
192
182
  */
193
- export declare const agentToolShape: ObjectShape<{
194
- task: StringShape;
195
- provider: OptionalShape<StringShape>;
196
- tools: OptionalShape<ArrayShape<StringShape>>;
197
- system: OptionalShape<StringShape>;
183
+ export declare const agentToolShape: ObjectShape< {
184
+ task: StringShape;
185
+ provider: OptionalShape<StringShape>;
186
+ tools: OptionalShape<ArrayShape<StringShape>>;
187
+ system: OptionalShape<StringShape>;
198
188
  }, false>;
199
189
 
200
- /** The pending/answer protocol {@link import('./factories.js').createAnswerTool} advertises. */
190
+ /**
191
+ * Holds the protocol {@link import('./factories.js').createAnswerTool} advertises — the `pending`
192
+ * and `answer` operations and the `values` record an answer supplies, each with a worked example.
193
+ */
201
194
  export declare const ANSWER_TOOL_DESCRIPTION: string;
202
195
 
203
196
  /**
204
- * The name {@link import('./factories.js').createAnswerTool} advertises by default — the key a
205
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
197
+ * Holds the name {@link import('./factories.js').createAnswerTool} advertises by default,
198
+ * `'answer'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
199
+ * under.
206
200
  */
207
201
  export declare const ANSWER_TOOL_NAME = "answer";
208
202
 
209
203
  /**
210
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createAnswerTool}
211
- * advertises in place of {@link ANSWER_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
212
- * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
213
- * for the full teaching description; the full text stays retrievable via
214
- * {@link import('./factories.js').createDescribeTool}.
204
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
205
+ * {@link import('./factories.js').createAnswerTool} advertises in place of
206
+ * {@link ANSWER_TOOL_DESCRIPTION} — one sentence offering the pending listing and the answer call,
207
+ * and pointing at `describe` for the fields each takes.
208
+ *
209
+ * @remarks
210
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
211
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
212
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
215
213
  */
216
214
  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
215
 
218
216
  /**
219
- * Options for {@link import('./factories.js').createAnswerTool} — the live
217
+ * Represents the options for {@link import('./factories.js').createAnswerTool} — the live
220
218
  * {@link TerminalManagerInterface} (`@orkestrel/terminal`) to list / answer prompts through, the
221
219
  * terminal name `to`, and the advertised tool overrides.
222
220
  *
223
221
  * @remarks
224
222
  * - `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
223
+ * handler calls — `pending` lists the forms addressed to `to`, `answer` resolves
226
224
  * one by `id`. A failed `answer` (`TerminalAnswerError`) re-surfaces as a typed
227
225
  * `ANSWER` {@link import('./errors.js').ToolboxError}.
228
- * - `to` — the terminal identity this tool lists / answers prompts FOR.
226
+ * - `to` — the terminal identity this tool lists / answers prompts for.
229
227
  * - `name` / `description` — advertised tool overrides; default to
230
228
  * {@link import('./constants.js').ANSWER_TOOL_NAME} / {@link import('./constants.js').ANSWER_TOOL_DESCRIPTION}.
231
229
  */
@@ -237,7 +235,7 @@ export declare interface AnswerToolOptions {
237
235
  }
238
236
 
239
237
  /**
240
- * The shape of {@link import('./factories.js').createAnswerTool}'s call arguments — discriminated
238
+ * Describes the shape of {@link import('./factories.js').createAnswerTool}'s call arguments — discriminated
241
239
  * by `operation`: `'pending'` lists the forms addressed to this tool's terminal, while `'answer'`
242
240
  * resolves one by `id` with a complete `values` record.
243
241
  *
@@ -245,23 +243,37 @@ export declare interface AnswerToolOptions {
245
243
  * `values` is first bounded to exact JSON. The handler then narrows it with the originating Form
246
244
  * package's `isFormValues` guard before the terminal manager applies it to the parked live form.
247
245
  */
248
- export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
249
- operation: LiteralShape<readonly ["pending"]>;
250
- }, false>, ObjectShape<{
251
- operation: LiteralShape<readonly ["answer"]>;
252
- id: StringShape;
253
- values: JSONShape;
246
+ export declare const answerToolShape: UnionShape<readonly [ObjectShape< {
247
+ operation: LiteralShape<readonly ["pending"]>;
248
+ }, false>, ObjectShape< {
249
+ operation: LiteralShape<readonly ["answer"]>;
250
+ id: StringShape;
251
+ values: JSONShape;
254
252
  }, false>]>;
255
253
 
256
254
  /**
257
- * Clamp a `'records'` call's query to a row cap, and build the PROBE query the caller reads
258
- * with — the pure leaf {@link import('./factories.js').createDatabaseTool}'s `'records'` operation
259
- * uses to detect truncation without a separate `count` round trip.
255
+ * Represents the probe query and effective row limit {@link import('./helpers.js').clampQuery}
256
+ * returns.
260
257
  *
261
258
  * @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
264
- * requests ONE MORE row than the effective limit (`limit: effective + 1`) — if storage returns
259
+ * `limit` is the effective ceiling — `min(query?.limit ?? cap, cap)`, floored at `0`. `query`
260
+ * requests one row more than that, so a caller detects truncation from the returned row count
261
+ * without a separate `count` round trip.
262
+ */
263
+ export declare interface ClampedQuery {
264
+ readonly query: QueryInput;
265
+ readonly limit: number;
266
+ }
267
+
268
+ /**
269
+ * Clamps a `'records'` call's query to a row cap, and builds the probe query the caller reads with
270
+ * — the pure leaf {@link import('./factories.js').createDatabaseTool}'s `'records'` operation uses
271
+ * to detect truncation without a separate `count` round trip.
272
+ *
273
+ * @remarks
274
+ * {@link resolveLimit} picks the effective limit, so a caller can never exceed the configured cap
275
+ * by supplying a larger `query.limit`, and can never drive it below `0`. The returned probe query
276
+ * requests one more row than the effective limit (`limit: effective + 1`) — if storage returns
265
277
  * that many, the caller knows the true result was truncated (`rows.length > effective`) and slices
266
278
  * back down to `effective` before returning.
267
279
  *
@@ -277,59 +289,71 @@ export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
277
289
  *
278
290
  * @param query - The live query to clamp (or `undefined`)
279
291
  * @param cap - The row-count ceiling
280
- * @returns The PROBE query (`limit` bumped by one) and the effective `limit`
292
+ * @returns The probe query (`limit` bumped by one) and the effective `limit`
281
293
  */
282
- export declare function clampQuery(query: QueryInput | undefined, cap: number): Readonly<{
283
- query: QueryInput;
284
- limit: number;
285
- }>;
294
+ export declare function clampQuery(query: QueryInput | undefined, cap: number): ClampedQuery;
286
295
 
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';
296
+ /** Represents one column's declared primitive — a shorthand, or `integer` for a whole-number `number`. */
297
+ export declare type ColumnPrimitive = 'string' | 'integer' | 'number' | 'boolean';
289
298
 
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;
299
+ /** Describes a {@link import('./types.js').ColumnPrimitive} literal — the leaf {@link columnSpecShape} wraps. */
300
+ export declare const columnPrimitiveShape: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
295
301
 
296
302
  /**
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.
303
+ * Represents one table column's spec — either a bare {@link ColumnPrimitive} shorthand, or
304
+ * `{ primitive, optional }` when the column may be absent from a row.
299
305
  */
300
- export declare type ColumnSpec = ColumnKind | Readonly<{
301
- type: ColumnKind;
306
+ export declare type ColumnSpec = ColumnPrimitive | Readonly<{
307
+ primitive: ColumnPrimitive;
302
308
  optional?: boolean;
303
309
  }>;
304
310
 
305
- /** A {@link import('./types.js').ColumnSpec} — a bare {@link columnKindShape}, or `{ type, optional }`. */
306
- export declare const columnSpecShape: UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
307
- type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
308
- optional: OptionalShape<BooleanShape>;
311
+ /** Describes a {@link import('./types.js').ColumnSpec} — a bare {@link columnPrimitiveShape}, or `{ primitive, optional }`. */
312
+ export declare const columnSpecShape: UnionShape<readonly [LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape< {
313
+ primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
314
+ optional: OptionalShape<BooleanShape>;
309
315
  }, false>]>;
310
316
 
311
317
  /**
312
- * Complete a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesize any
313
- * MISSING `id` deterministically + positionally, and default any MISSING `name` to its
314
- * (now-resolved) `id`.
318
+ * Compiles one {@link ColumnSpec} into its `@orkestrel/database` column shape — the per-column leaf
319
+ * {@link expandTables} maps over.
320
+ *
321
+ * @param spec - The column spec to compile
322
+ * @returns The `@orkestrel/database` column shape, wrapped in `optionalShape` when the spec declares `optional: true`
323
+ */
324
+ export declare function compileColumn(spec: ColumnSpec): ContractShape;
325
+
326
+ /**
327
+ * Compiles one {@link import('./types.js').ColumnPrimitive} into its primitive
328
+ * `@orkestrel/database` shape — the leaf {@link compileColumn} wraps.
329
+ *
330
+ * @param primitive - The declared column primitive
331
+ * @returns The matching primitive `@orkestrel/database` shape
332
+ */
333
+ export declare function compileColumnPrimitive(primitive: ColumnPrimitive): ContractShape;
334
+
335
+ /**
336
+ * Completes a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesizes a
337
+ * missing `id` deterministically and positionally, and defaults a missing `name` to its resolved
338
+ * `id`.
315
339
  *
316
340
  * @remarks
317
341
  * The positional id scheme is stable and human-legible: the workflow is `wf`, phase `i` is
318
342
  * `phase-<i>`, and task `j` of that phase is `<phaseId>-task-<j>` (so a provided phase id flows
319
- * into its tasks' synthesized ids). A PROVIDED `id` / `name` at any level is kept VERBATIM —
343
+ * into its tasks' synthesized ids). A provided `id` / `name` at any level is kept verbatim —
320
344
  * 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
345
+ * the other way round), so the result always carries an `id` and a `name`. `behavior`, `description`, the per-phase
322
346
  * `concurrency` / `bail`, the per-task `retries` / `timeout`, and the workflow `bail` carry over
323
347
  * unchanged. The result is a complete {@link WorkflowDefinition}; the caller still validates it
324
- * against the STRICT contract.
348
+ * against the strict contract.
325
349
  *
326
- * @param draft - The draft workflow (id/name optional at all three levels)
350
+ * @param draft - The draft workflow (`id` and `name` optional at the workflow, phase, and task levels)
327
351
  * @returns A complete {@link WorkflowDefinition} with every id/name filled
328
352
  */
329
353
  export declare function completeDraft(draft: WorkflowDraft): WorkflowDefinition;
330
354
 
331
355
  /**
332
- * Complete one {@link PhaseDraft} into a strict phase definition — the per-phase step of
356
+ * Completes one {@link PhaseDraft} into a strict phase definition — the per-phase step of
333
357
  * {@link completeDraft} (phase `index` → `phase-<index>` when its id is omitted).
334
358
  *
335
359
  * @param phase - The draft phase
@@ -339,7 +363,7 @@ export declare function completeDraft(draft: WorkflowDraft): WorkflowDefinition;
339
363
  export declare function completePhaseDraft(phase: PhaseDraft, index: number): WorkflowDefinition['phases'][number];
340
364
 
341
365
  /**
342
- * Complete one {@link TaskDraft} into a strict task definition — the per-task leaf step of
366
+ * Completes one {@link TaskDraft} into a strict task definition — the per-task leaf step of
343
367
  * {@link completeDraft} (task `index` of phase `<phaseId>` → `<phaseId>-task-<index>` when its id
344
368
  * is omitted).
345
369
  *
@@ -350,16 +374,19 @@ export declare function completePhaseDraft(phase: PhaseDraft, index: number): Wo
350
374
  */
351
375
  export declare function completeTaskDraft(task: TaskDraft, phaseId: string, index: number): WorkflowDefinition['phases'][number]['tasks'][number];
352
376
 
353
- /** One SERIALIZED WHERE condition — `values` is ALWAYS an array, even for a single-value operator. */
354
- export declare const conditionShape: ObjectShape<{
355
- column: StringShape;
356
- operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
357
- values: ArrayShape<JSONShape>;
358
- connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
377
+ /**
378
+ * Describes one serialized where condition — `values` is always an array, even for a single-value
379
+ * operator.
380
+ */
381
+ export declare const conditionShape: ObjectShape< {
382
+ column: StringShape;
383
+ operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
384
+ values: ArrayShape<JSONShape>;
385
+ connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
359
386
  }, false>;
360
387
 
361
388
  /**
362
- * Wrap a live `AgentInterface` (`@orkestrel/agent`) as a {@link WorkflowFunction}
389
+ * Wraps a live `AgentInterface` (`@orkestrel/agent`) as a {@link WorkflowFunction}
363
390
  * (`@orkestrel/workflow`) — the opt-in adapter that runs the agent to a settled result and carries
364
391
  * immutable lineage metadata for contextual Toolbox composition.
365
392
  *
@@ -367,7 +394,7 @@ export declare const conditionShape: ObjectShape<{
367
394
  * Composes into a caller's registry like any other behavior; the pure workflow runner has no
368
395
  * knowledge of agents itself. A root adapter derives its workflow lineage from the controller,
369
396
  * 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
397
+ * targets deeper than {@link import('./constants.js').MAX_WORKFLOW_CHAIN} are rejected before
371
398
  * agent or runner activity. When {@link import('./types.js').AgentFunctionOptions.runner} is
372
399
  * supplied, the adapter binds a recursion-safe {@link createWorkflowTool} onto the agent's
373
400
  * `context.tools`, propagating opaque leaves, raw agents, lineage, and the native store. The
@@ -397,19 +424,19 @@ export declare const conditionShape: ObjectShape<{
397
424
  export declare function createAgentFunction(agent: AgentInterface, options?: AgentFunctionOptions): AgentFunction;
398
425
 
399
426
  /**
400
- * Build an LLM-callable sub-agent delegation tool — resolves a live, seeded `AgentInterface`
401
- * from `registry` and runs it to completion for ONE delegated `task`.
427
+ * Builds an LLM-callable sub-agent delegation tool — it resolves a live, seeded `AgentInterface`
428
+ * from `registry` and runs it to completion for one delegated `task`.
402
429
  *
403
430
  * @remarks
404
- * The universal tool-handler contract (AGENTS §14): validates the call args against
431
+ * The universal tool-handler contract: validates the call args against
405
432
  * {@link import('./shapers.js').agentToolShape}, assembles an `AgentJobInput` (`task` seeds the
406
433
  * 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
434
+ * back to the tool's own {@link import('./types.js').AgentToolOptions} defaults), rehydrates the sub-agent through
408
435
  * `registry.build`, runs it with `agent.generate()`, and returns the settled
409
- * `AgentResult.content` string (the sub-agent's final text). A missing / unresolvable `provider`, or a malformed call, THROWS a typed `TOOL`
436
+ * `AgentResult.content` string (the sub-agent's final text). A missing / unresolvable `provider`, or a malformed call, throws a typed `TOOL`
410
437
  * {@link import('./errors.js').ToolboxError}; a delegation that would exceed
411
438
  * {@link import('./constants.js').AGENT_TOOL_DEPTH}, or re-enter an already-delegated agent (a
412
- * cycle), THROWS a typed `DEPTH` {@link import('./errors.js').ToolboxError} — both isolated
439
+ * cycle), throws a typed `DEPTH` {@link import('./errors.js').ToolboxError}, each isolated
413
440
  * by the `ToolManagerInterface` into the canonical tool result's top-level `error`.
414
441
  *
415
442
  * `AgentInterface` (`@orkestrel/agent`) exposes no teardown method — a bound sub-agent's
@@ -438,22 +465,21 @@ export declare function createAgentFunction(agent: AgentInterface, options?: Age
438
465
  export declare function createAgentTool(registry: AgentRegistryInterface, options?: AgentToolOptions): ToolInterface;
439
466
 
440
467
  /**
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
443
- * them by id.
468
+ * Builds an LLM-callable answer tool — the answer side of the terminal seam. It lists the forms
469
+ * addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of them by id.
444
470
  *
445
471
  * @remarks
446
- * The universal tool-handler contract (AGENTS §14): validates the call args against
472
+ * The universal tool-handler contract: validates the call args against
447
473
  * {@link import('./shapers.js').answerToolShape} (discriminated by `operation`). `'pending'`
448
- * returns a compact list (`{ id, from, schema }`) of every form currently addressed to `to`.
474
+ * returns a compact list (`{ id, from, schema }`) of every form addressed to `to`.
449
475
  * `'answer'` looks the form up by `id`, narrows the supplied `values` through `@orkestrel/form`,
450
- * and applies it via
476
+ * and applies it through
451
477
  * `TerminalManagerInterface.answer` — a rejected / unknown / unresolvable outcome
452
478
  * (`TerminalAnswerResult.error`) re-surfaces as a typed `ANSWER` `ToolboxError`; success returns
453
- * `{ answered: id }`. `to` is FIXED at construction
479
+ * `{ answered: id }`. `to` is fixed at construction
454
480
  * ({@link import('./types.js').AnswerToolOptions.to}) — never read from the model-supplied args —
455
481
  * so a model cannot spoof which terminal it is answering for. Concurrent answerers racing on one
456
- * endpoint are FIRST-WRITE-WINS — a late answer to an already-settled form returns a typed
482
+ * endpoint are first-write-wins — a late answer to an already-settled form returns a typed
457
483
  * `ANSWER` `ToolboxError` (surfaced as a 422 over HTTP).
458
484
  *
459
485
  * @param options - The live manager, the fixed `to` identity, and advertised overrides (see
@@ -476,7 +502,7 @@ export declare function createAgentTool(registry: AgentRegistryInterface, option
476
502
  export declare function createAnswerTool(options: AnswerToolOptions): ToolInterface;
477
503
 
478
504
  /**
479
- * Create a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database`
505
+ * Creates a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database`
480
506
  * layer — the driver-pluggable twin of {@link createMemoryDefinitionStore}, storing each
481
507
  * database's definition as one opaque JSON column.
482
508
  *
@@ -493,15 +519,15 @@ export declare function createAnswerTool(options: AnswerToolOptions): ToolInterf
493
519
  export declare function createDatabaseDefinitionStore(driver?: DriverInterface): DefinitionStoreInterface;
494
520
 
495
521
  /**
496
- * Build an LLM-callable database tool — create, query, and mutate `@orkestrel/database`
497
- * databases through one `operation`-discriminated call (AGENTS §14, matching
522
+ * Builds an LLM-callable database tool — it creates, queries, and mutates `@orkestrel/database`
523
+ * databases through one `operation`-discriminated call (matching
498
524
  * {@link createWorkspaceTool}'s single-tool-many-operations shape).
499
525
  *
500
526
  * @remarks
501
- * The universal tool-handler contract (AGENTS §14): validates the call args against
527
+ * The universal tool-handler contract: validates the call args against
502
528
  * {@link import('./shapers.js').databaseToolShape}, dispatches to the matching operation, and
503
- * 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
529
+ * returns a plain result on success. A database is resolved lazily and cached for the tool's
530
+ * lifetime — `'create'` mints one from `tables` ({@link import('./compilers.js').expandTables}) and
505
531
  * a registered `driver` key ({@link import('./types.js').DatabaseToolOptions.drivers}, default
506
532
  * `{ memory: () => createMemoryDriver() }`); any other operation addressing an uncached id falls
507
533
  * back to {@link import('./types.js').DatabaseToolOptions.store} (an unknown id throws a typed
@@ -510,10 +536,10 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
510
536
  *
511
537
  * `'records'` clamps its `query` to
512
538
  * {@link import('./types.js').DatabaseToolOptions.limit} (default
513
- * {@link import('./constants.js').DATABASE_TOOL_LIMIT}) via
539
+ * {@link import('./constants.js').DATABASE_TOOL_LIMIT}) through
514
540
  * {@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'`).
541
+ * than the cap. Every operation's `query` is normalized through
542
+ * {@link import('./helpers.js').normalizeQuery} (defaults an omitted condition `connector` to `'and'`).
517
543
  * When {@link import('./types.js').DatabaseToolOptions.readonly} is `true`, every mutating
518
544
  * operation throws a typed `TOOL` `ToolboxError` before doing anything. A configured
519
545
  * {@link import('./types.js').DatabaseToolOptions.timeout} is passed as a fresh
@@ -522,10 +548,10 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
522
548
  * not an outer deadline for resolution, construction, schema inspection, `get`, or `close`. A typed `@orkestrel/database`
523
549
  * failure (`DatabaseError`) re-surfaces as a typed `DATABASE` `ToolboxError` carrying the
524
550
  * original {@link import('@orkestrel/database').DatabaseErrorCode} in `context.code`
525
- * ({@link import('./helpers.js').databaseToolCode}); an `ToolboxError` thrown by this tool's own
551
+ * ({@link import('./helpers.js').inferDatabaseCode}); an `ToolboxError` thrown by this tool's own
526
552
  * guards passes through unwrapped.
527
553
  *
528
- * A lazily re-minted database over the DEFAULT in-memory driver yields an EMPTY database — only
554
+ * A lazily re-minted database over the default in-memory driver yields an empty database — only
529
555
  * the {@link import('./types.js').DatabaseDefinition} schema persists in `store`, never rows;
530
556
  * durable rows need a persistent driver factory registered in
531
557
  * {@link import('./types.js').DatabaseToolOptions.drivers}. `'destroy'` closes whatever handle is
@@ -533,7 +559,7 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
533
559
  * {@link import('./types.js').DatabaseToolOptions.databases} handle — the embedder relinquishes
534
560
  * that handle's lifecycle to this tool for any id it wires in. This tool assumes the
535
561
  * single-writer, non-reentrant model `@orkestrel/database` itself assumes — concurrent calls
536
- * against one id are NOT serialized by this tool. `'get'` is uncapped by
562
+ * against one id are not serialized by this tool. `'get'` is uncapped by
537
563
  * {@link import('./types.js').DatabaseToolOptions.limit} (bounded only by the caller's `key` array
538
564
  * size), unlike `'records'` / `'find'` / `'links'`.
539
565
  *
@@ -555,21 +581,20 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
555
581
  export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolInterface;
556
582
 
557
583
  /**
558
- * Build an LLM-callable tool that returns the FULL `description` of another registered tool by
559
- * name — the counterpart to the lean `summary` the other tools in this package advertise
560
- * (`AGENT_TOOL_SUMMARY` / `WORKFLOW_TOOL_SUMMARY` / `WORKSPACE_TOOL_SUMMARY`).
584
+ * Builds an LLM-callable tool that returns the full `description` of another registered tool by
585
+ * name — the counterpart to the lean `summary` the other tools in this package advertise.
561
586
  *
562
587
  * @remarks
563
588
  * `ToolManagerInterface.definitions()` (`@orkestrel/tool`) advertises `tool.summary ??
564
589
  * tool.description` — a lean one-sentence summary stands in for a tool's full teaching
565
590
  * description when `summary` is set, keeping the advertised tool list compact for a small model.
566
591
  * 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
592
+ * up through `tools.tool(name)` and returns its full `description` (falling back to `summary` when a
568
593
  * tool has no `description` of its own, then a placeholder when it has neither).
569
594
  *
570
- * The universal tool-handler contract (AGENTS §14): validates the call args against
571
- * {@link import('./shapers.js').describeToolShape}, RETURNS the plain description string on
572
- * success, THROWS a typed `TOOL` {@link import('./errors.js').ToolboxError} on a malformed call
595
+ * The universal tool-handler contract: validates the call args against
596
+ * {@link import('./shapers.js').describeToolShape}, returns the plain description string on
597
+ * success, throws a typed `TOOL` {@link import('./errors.js').ToolboxError} on a malformed call
573
598
  * or an unknown tool name.
574
599
  *
575
600
  * @param tools - The `ToolManagerInterface` (`@orkestrel/tool`) whose registered tools this
@@ -591,36 +616,36 @@ export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolI
591
616
  export declare function createDescribeTool(tools: ToolManagerInterface): ToolInterface;
592
617
 
593
618
  /**
594
- * Wrap one CONCRETE endpoint ({@link import('./types.js').EndpointDefinition}) as an LLM-callable
595
- * `ToolInterface` — the endpoint half of the "existing API/DB → MCP tool" bridge (the other half,
596
- * {@link createInferTool}, is a standalone inference utility).
619
+ * Wraps one concrete endpoint ({@link import('./types.js').EndpointDefinition}) as an LLM-callable
620
+ * `ToolInterface` — the endpoint half of the bridge from an existing API or database into an MCP
621
+ * tool (the other half, {@link createInferTool}, is a standalone inference utility).
597
622
  *
598
623
  * @remarks
599
- * `parameters` is inferred ONCE at construction from `definition.samples` via
624
+ * `parameters` is inferred once at construction from `definition.samples` through
600
625
  * `@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` —
602
- * the SAME object-rooted schema is both the ADVERTISED `parameters` and, by default
603
- * ({@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
606
- * NORMALIZING parse, not a strict type check: a scalar is COERCED to its inferred type where the
626
+ * `format` / `enum`), wrapping a non-object root as `{ value: <schema> }` through `schemaToObject` —
627
+ * the same object-rooted schema is both the advertised `parameters` and, by default
628
+ * ({@link import('./types.js').EndpointToolOptions.validate} `true`), the enforced contract:
629
+ * `@orkestrel/contract`'s `schemaToShape` compiles it once (through `createContract`) into a
630
+ * `ContractInterface` whose `.parse` runs on every call's `args` before `definition.execute` — a
631
+ * normalizing parse, not a strict type check: a scalar is coerced to its inferred type where the
607
632
  * 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
633
+ * `'false'`/`1`/`0`), so `definition.execute` receives the coerced value (for example `7` sent for a
609
634
  * string slot arrives as `'7'`), not the raw call value. A call whose `args` fails to parse into
610
- * a record — a required key missing, or a value not coercible to its slot's type — THROWS a
635
+ * a record — a required key missing, or a value not coercible to its slot's type — throws a
611
636
  * 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
613
- * NEVER asserted, and a key outside the closed inferred schema is SILENTLY DROPPED rather than
637
+ * structured `explain` faults, and `definition.execute` is never called. `format` annotations are
638
+ * never asserted, and a key outside the closed inferred schema is silently dropped rather than
614
639
  * 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,
640
+ * `validate: false`, the tool's `execute` passes through the model-supplied `args` to
641
+ * `definition.execute` without re-validation — the raw-passthrough opt-out. Either way, the
642
+ * definition's return flows back as the tool call's plain result; a throw propagates uncaught,
618
643
  * isolated by the `ToolManagerInterface` (`@orkestrel/tool`) into the canonical error envelope
619
- * (AGENTS §14) — never caught or re-wrapped here.
644
+ * — never caught or re-wrapped here.
620
645
  *
621
646
  * @param definition - The endpoint's identity, non-empty samples, and local handler (see
622
647
  * {@link import('./types.js').EndpointDefinition})
623
- * @param options - Construction-time inference tuning + the validate opt-out (see
648
+ * @param options - Construction-time inference tuning and the validate opt-out (see
624
649
  * {@link import('./types.js').EndpointToolOptions})
625
650
  * @returns A `ToolInterface` named `definition.name`
626
651
  *
@@ -633,12 +658,12 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
633
658
  * name: 'lookupUser',
634
659
  * description: 'Look up a user by id.',
635
660
  * samples: [{ id: '1', name: 'Ada' }, { id: '2', name: 'Bob' }],
636
- * invoke: (args) => ({ id: args.id, name: 'Ada' }),
661
+ * execute: (args) => ({ id: args.id, name: 'Ada' }),
637
662
  * })
638
663
  * const tools = createToolManager()
639
664
  * tools.add(tool)
640
665
  *
641
- * // conforming args (all required keys present) parse and reach `invoke`
666
+ * // conforming args (all required keys present) parse and reach the definition's `execute`
642
667
  * const result = await tools.execute({
643
668
  * id: 'call-1',
644
669
  * name: 'lookupUser',
@@ -647,7 +672,7 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
647
672
  * // result.value -> { id: '1', name: 'Ada' }
648
673
  *
649
674
  * // a nonconforming call (id is not coercible to the required string) is rejected before
650
- * // `invoke` runs
675
+ * // the definition's `execute` runs
651
676
  * const rejected = await tools.execute({
652
677
  * id: 'call-2',
653
678
  * name: 'lookupUser',
@@ -659,44 +684,44 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
659
684
  export declare function createEndpointTool(definition: EndpointDefinition, options?: EndpointToolOptions): ToolInterface;
660
685
 
661
686
  /**
662
- * Build a standalone LLM-callable tool that infers a JSON Schema from example values — the
663
- * utility half of the "existing API/DB → MCP tool" bridge (the other half,
664
- * {@link createEndpointTool}, wraps one CONCRETE endpoint).
687
+ * Builds a standalone LLM-callable tool that infers a JSON Schema from example values — the utility
688
+ * half of the bridge from an existing API or database into an MCP tool (the other half,
689
+ * {@link createEndpointTool}, wraps one concrete endpoint).
665
690
  *
666
691
  * @remarks
667
- * The universal tool-handler contract (AGENTS §14): validates the call args against
692
+ * The universal tool-handler contract: validates the call args against
668
693
  * {@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
671
- * the tool-parameters convention every other `create*Tool` factory advertises), and RETURNS the
694
+ * booleans, `candidates` an optional array), infers a schema through `@orkestrel/contract`'s
695
+ * `samplesToSchema`, wraps a non-object root as `{ value: <schema> }` through `schemaToObject` (mirrors
696
+ * the tool-parameters convention every other `create*Tool` factory advertises), and returns the
672
697
  * resulting parameters record. An empty `samples` array fails `inferToolShape`'s `min: 1` bound —
673
698
  * `contract.parse` returns `undefined` and the handler throws a typed `TOOL`
674
699
  * {@link import('./errors.js').ToolboxError}.
675
700
  *
676
- * When `candidates` is ABSENT, the return is the bare parameters record — unchanged from before
677
- * 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
679
- * `schemaToShape`, NOT the `schemaToObject`-wrapped parameters — a bare-value sample checks a
701
+ * When `candidates` is absent, the return is the bare parameters record — unchanged from before
702
+ * this array existed. When `candidates` is present (any array, including empty), the handler
703
+ * compiles a separate per-call contract from the raw inferred schema (through `@orkestrel/contract`'s
704
+ * `schemaToShape`, not the `schemaToObject`-wrapped parameters — a bare-value sample checks a
680
705
  * bare-value candidate) and returns `{ parameters, checks }`, one check per candidate at the same
681
- * index. Every entry has a UNIFORM shape — `{ index, valid, coercible }`, with `faults` added ONLY
682
- * when `valid` is `false`: `valid` is the STRICT guard verdict (`checker.is(candidate)`), the
683
- * OPPOSITE of {@link createEndpointTool}'s enforcement, which coerces (`7` becomes `'7'` for a
684
- * string slot) — here a conformance report answers "does this value conform AS-IS": `7` against a
685
- * 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
706
+ * index. Every entry has a uniform shape — `{ index, valid, coercible }`, with `faults` added only
707
+ * when `valid` is `false`: `valid` is the strict guard verdict (`checker.is(candidate)`), the
708
+ * opposite of {@link createEndpointTool}'s enforcement, which coerces (`7` becomes `'7'` for a
709
+ * string slot) — here a conformance report answers "does this value conform as-is": `7` against a
710
+ * string slot is `valid: false`, full stop. `coercible` answers a separate question — "would the
711
+ * normalizing parse accept this value", that is would {@link createEndpointTool}'s default enforcement
687
712
  * 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
713
+ * `valid`; by the house parse/guard round-trip, a `valid: true` entry is
714
+ * always also `coercible: true`. `@orkestrel/contract`'s `explain` mirrors the normalizing
690
715
  * `parse`'s leniency, not `is`'s strictness — so a strictly-invalid but coercible candidate (`7`
691
- * against a string slot) yields `{ valid: false, coercible: true, faults: [] }`: EMPTY faults, since
716
+ * against a string slot) yields `{ valid: false, coercible: true, faults: [] }`: empty faults, because
692
717
  * the mismatch the normalizing parse would silently fix is not one `explain` reports. `faults`
693
- * therefore only ever populates for a NON-coercible mismatch — a wrong type the parse can't coerce
718
+ * therefore only ever populates for a non-coercible mismatch — a wrong type the parse can't coerce
694
719
  * (a boolean in a string slot), a missing required key, or an out-of-enum value — where
695
720
  * `coercible: false`. `checker.is` / `.parse` / `.explain` are all total over JSON-safe input — a
696
- * 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
698
- * throwing-getter `Proxy`) never reaches the checker at all — it fails the OUTER `args` parse
699
- * against {@link import('./shapers.js').inferToolShape} and rejects the WHOLE call with the same
721
+ * JSON-safe hostile candidate (a `__proto__`-carrying object, deeply nested data) reaches each of them
722
+ * and yields a bounded, non-throwing per-candidate verdict; a non-JSON-safe candidate (for example a
723
+ * throwing-getter `Proxy`) never reaches the checker at all — it fails the outer `args` parse
724
+ * against {@link import('./shapers.js').inferToolShape} and rejects the whole call with the same
700
725
  * `TOOL` {@link import('./errors.js').ToolboxError} a malformed `samples`/`format`/`enum` throws,
701
726
  * with no per-candidate verdict produced.
702
727
  *
@@ -738,9 +763,9 @@ export declare function createEndpointTool(definition: EndpointDefinition, optio
738
763
  export declare function createInferTool(options?: InferToolOptions): ToolInterface;
739
764
 
740
765
  /**
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
743
- * `DatabaseDefinition` configs through.
766
+ * Creates the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of database
767
+ * definitions, the default store the database and relation tools persist their `DatabaseDefinition`
768
+ * configs through.
744
769
  *
745
770
  * @returns A {@link DefinitionStoreInterface}
746
771
  *
@@ -754,20 +779,23 @@ export declare function createInferTool(options?: InferToolOptions): ToolInterfa
754
779
  export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
755
780
 
756
781
  /**
757
- * Build an LLM-callable form tool — the ASK side of the terminal seam. Asks
758
- * a multi-field form and BLOCKS until it answers, returning the resolved values record.
782
+ * Builds an LLM-callable form tool — the ask side of the terminal seam. It asks a multi-field form
783
+ * and blocks until the addressed terminal answers, returning the resolved values record.
759
784
  *
760
785
  * @remarks
761
- * The universal tool-handler contract (AGENTS §14): validates the call args against
786
+ * The universal tool-handler contract: validates the call args against
762
787
  * {@link import('./shapers.js').promptToolShape}, parses the call's schema through
763
788
  * `@orkestrel/form`, constructs the live form, and passes it to `TerminalManagerInterface.ask`.
764
- * `from` is FIXED at construction
789
+ * `from` is fixed at construction
765
790
  * ({@link import('./types.js').PromptToolOptions.from}) — never read from the model-supplied
766
- * args — so a model cannot spoof which terminal is asking. A form CYCLE rejects with
791
+ * args — so a model cannot spoof which terminal is asking. A form cycle rejects with
767
792
  * `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
768
793
  * {@link import('./errors.js').ToolboxError}; an expired form re-surfaces as `EXPIRE`; an
769
794
  * unknown `to` (or any other `TerminalError`) re-surfaces as `TOOL`, naming the unknown terminal
770
- * plus the known ones (`manager.terminals()`).
795
+ * and how many brokers the manager holds (`manager.count`). A schema `parseForm` refuses — an
796
+ * unknown control, a duplicate field name, a `'select'` or `'checkbox'` field without usable
797
+ * `choices` — throws a typed `TOOL` error up front, so a malformed schema never parks as a form
798
+ * nobody can answer.
771
799
  *
772
800
  * @param options - The live manager, the fixed `from` identity, and advertised overrides (see
773
801
  * {@link import('./types.js').PromptToolOptions})
@@ -790,32 +818,33 @@ export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
790
818
  export declare function createPromptTool(options: PromptToolOptions): ToolInterface;
791
819
 
792
820
  /**
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
821
+ * Builds an LLM-callable relation tool — it traverses and edits `@orkestrel/relation` relationships
822
+ * through one `operation`-discriminated call (matching {@link createDatabaseTool}'s
795
823
  * single-tool-many-operations shape).
796
824
  *
797
825
  * @remarks
798
- * The universal tool-handler contract (AGENTS §14): validates the call args against
826
+ * The universal tool-handler contract: validates the call args against
799
827
  * {@link import('./shapers.js').relationToolShape}, resolves the addressed
800
828
  * {@link import('@orkestrel/relation').RelationManagerInterface} — an explicit `manager` field
801
- * must match a key of {@link import('./types.js').RelationToolOptions.managers}, an OMITTED one
802
- * resolves to the SOLE registered manager, either miss throwing a typed `TOOL`
829
+ * must match a key of {@link import('./types.js').RelationToolOptions.managers}, an omitted one
830
+ * resolves to the sole registered manager, either miss throwing a typed `TOOL`
803
831
  * {@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
806
- * dispatches to the matched operation, RETURNING a plain result on success.
832
+ * ({@link import('./helpers.js').resolveRelationManager}) — then resolves `model` against it
833
+ * ({@link import('./helpers.js').resolveRelationModel}, same typed-`TOOL`-on-miss shape), and
834
+ * dispatches to the matched operation, returning a plain result on success.
807
835
  *
808
- * `'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
836
+ * `'load'` / `'find'` expand the call's flat dot-path `include` list into a live
837
+ * `@orkestrel/relation` `Include` tree through {@link import('./helpers.js').expandInclude}, capped
810
838
  * at {@link import('./types.js').RelationToolOptions.depth} (default
811
839
  * {@link import('./constants.js').RELATION_TOOL_DEPTH}) — a path exceeding the cap, or carrying an
812
840
  * 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
841
+ * (positional many-key form — an array key is read as many keys rather than one) or a single key.
842
+ * `'find'` and `'links'` clamp their
814
843
  * 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
844
+ * {@link import('./constants.js').RELATION_TOOL_LIMIT}), taken through
845
+ * {@link import('./helpers.js').resolveLimit} — `'find'` probes one row past the effective limit to
846
+ * report `truncated`; `'links'` (which has no upstream pagination) fetches the full linked-key
847
+ * list and slices/truncates it the same way. `'link'` / `'unlink'` write / remove one `through` junction
819
848
  * row.
820
849
  *
821
850
  * A typed `@orkestrel/relation` failure (`RelationError`) re-surfaces as a typed `RELATION`
@@ -839,8 +868,8 @@ export declare function createPromptTool(options: PromptToolOptions): ToolInterf
839
868
  export declare function createRelationTool(options: RelationToolOptions): ToolInterface;
840
869
 
841
870
  /**
842
- * Wrap a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the OPT-IN
843
- * adapter that lets a `function`-form task run a `@orkestrel/tool` tool BY NAME.
871
+ * Wraps a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the opt-in
872
+ * adapter that lets a `function`-form task run a `@orkestrel/tool` tool by name.
844
873
  *
845
874
  * @remarks
846
875
  * Composes into a caller's `WorkflowOptions.functions` registry like any other behavior
@@ -870,14 +899,16 @@ export declare function createRelationTool(options: RelationToolOptions): ToolIn
870
899
  export declare function createToolFunction(tools: ToolManagerInterface, name: string): WorkflowFunction;
871
900
 
872
901
  /**
873
- * Compile the lenient workflow draft contract used by {@link createWorkflowTool}.
902
+ * Compiles the lenient workflow draft contract {@link createWorkflowTool} parses an authored tree
903
+ * with — a `ContractInterface` over a {@link WorkflowDraft}, whose `id` and `name` are optional at
904
+ * the workflow, phase, and task levels.
874
905
  *
875
906
  * @returns The compiled {@link import('./types.js').WorkflowDraft} contract
876
907
  */
877
908
  export declare function createWorkflowDraftContract(): ContractInterface<WorkflowDraft>;
878
909
 
879
910
  /**
880
- * Compose opaque host functions and raw agents into one immutable workflow registry.
911
+ * Composes opaque host functions and raw agents into one immutable workflow registry.
881
912
  *
882
913
  * @remarks
883
914
  * This is the target-aware composition boundary used by direct runner consumers and
@@ -903,37 +934,36 @@ export declare function createWorkflowDraftContract(): ContractInterface<Workflo
903
934
  * await runner.execute(definition, { functions })
904
935
  * ```
905
936
  */
906
- export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): WorkflowFunctions;
937
+ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): WorkflowRegistry;
907
938
 
908
939
  /**
909
- * Wrap a {@link WorkflowDefinition} as an LLM-callable tool — it ADVERTISES the SIMPLE flat
910
- * authoring shape (`{ name?, steps: [{ name }] }`) as its `parameters` so even a small model can
911
- * author a complete tree, and its handler EXPANDS / COMPLETES the authored blob, validates it
912
- * against the STRICT contract, and runs it through `runner`, forwarding the caller's optional
913
- * named functions and native checkpoint store.
940
+ * Wraps a {@link WorkflowDefinition} as an LLM-callable tool — it advertises the flat authoring
941
+ * shape (`{ name?, steps: [{ name }] }`) as its `parameters`, and its handler completes the
942
+ * authored blob, validates it against the strict contract, and runs it through `runner`, forwarding
943
+ * the caller's optional named functions and native checkpoint store.
914
944
  *
915
945
  * @remarks
916
946
  * A plain `ToolManagerInterface`-compatible tool (`@orkestrel/tool`), reproducing
917
947
  * Toolbox's flat / draft / full authoring contract, strict soundness gate, and lineage guard.
918
- * It is ALSO the propagation carrier
948
+ * It is also the propagation carrier
919
949
  * {@link createAgentFunction} binds onto a wrapped agent's `context.tools`: because a tool
920
950
  * handler receives only the model-supplied `args`, the immutable lineage is closed over at bind
921
951
  * time. The authored target is appended and its zero-based depth derived from workflow tags.
922
952
  *
923
- * **Widened authoring surface (additive — the canonical contract + runner stay STRICT and
924
- * unchanged).** A 2B model reliably CALLS the tool but cannot reliably emit the full four-level
925
- * nested {@link WorkflowDefinition} (six required `id`/`name` strings, an all-or-nothing tree).
926
- * So the tool ACCEPTS three authoring forms and converges them on the SAME strict
953
+ * **Widened authoring surface (additive — the canonical contract and runner stay strict and
954
+ * unchanged).** A 2B model reliably calls the tool but cannot reliably emit the full nested
955
+ * {@link WorkflowDefinition}, whose every `id` and `name` is required across an all-or-nothing
956
+ * tree. So the tool accepts the authoring forms that follow and converges them on the same strict
927
957
  * `createWorkflowContract` gate before running (soundness preserved):
928
- * - the FLAT shape `{ name?, steps: [{ name }] }` — the ADVERTISED `parameters` (the simplest
958
+ * - the flat shape `{ name?, steps: [{ name }] }` — the advertised `parameters` (the simplest
929
959
  * form, {@link import('./helpers.js').expandSteps}'d into one one-task phase per step);
930
- * - a nested DRAFT with any `id`/`name` OMITTED — {@link createWorkflowDraftContract}-parsed then
960
+ * - a nested draft with any `id`/`name` omitted — {@link createWorkflowDraftContract}-parsed then
931
961
  * {@link import('./helpers.js').completeDraft}'d (missing ids synthesized positionally);
932
962
  * - the full nested {@link WorkflowDefinition} — the advanced escape-hatch, accepted as the draft
933
963
  * super-set.
934
964
  *
935
- * The universal tool-handler contract (AGENTS §14): returns the plain run summary
936
- * (`{ status, count, durable?, fault? }`) on success, THROWS a typed `ToolboxError` on Toolbox
965
+ * The universal tool-handler contract: returns the plain run summary
966
+ * (`{ status, count, durable?, fault? }`) on success, throws a typed `ToolboxError` on Toolbox
937
967
  * boundary failures — malformed authored args (`TOOL`), or an over-deep / cyclic nested run
938
968
  * (`DEPTH`) — and preserves genuine runner `WorkflowError`s. The `ToolManagerInterface` isolates every throw into the canonical tool result's
939
969
  * top-level `error`, so nothing escapes the run. `options.lineage` is the propagation carrier
@@ -947,6 +977,34 @@ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface,
947
977
  * @returns A `ToolInterface` (named {@link import('./constants.js').WORKFLOW_TOOL_NAME}) whose
948
978
  * `parameters` advertise the flat authoring schema
949
979
  *
980
+ * @example Authoring and running a workflow through the tool with a real ToolManager
981
+ * ```ts
982
+ * import { createWorkflowTool } from '@orkestrel/toolbox'
983
+ * import { createToolManager } from '@orkestrel/tool'
984
+ * import { createWorkflowRunner } from '@orkestrel/workflow'
985
+ * import type { WorkflowDefinition } from '@orkestrel/workflow'
986
+ *
987
+ * const definition: WorkflowDefinition = { id: 'release', name: 'Release', phases: [] }
988
+ * const runner = createWorkflowRunner()
989
+ * const functions = {
990
+ * compile: () => 'compiled',
991
+ * publish: () => 'published',
992
+ * }
993
+ * const tool = createWorkflowTool(definition, runner, { functions })
994
+ *
995
+ * const tools = createToolManager()
996
+ * tools.add(tool)
997
+ *
998
+ * // A small model authors the simple flat shape — no ids/names required.
999
+ * const result = await tools.execute({
1000
+ * id: 'call-1',
1001
+ * name: 'workflow',
1002
+ * arguments: { name: 'release', steps: [{ name: 'compile' }, { name: 'publish' }] },
1003
+ * })
1004
+ * if (!result.success) throw new Error(result.error)
1005
+ * result.value // { status: 'completed', count: 2 } — the single-level envelope; no nested { id, name, value }
1006
+ * ```
1007
+ *
950
1008
  * @example
951
1009
  * ```ts
952
1010
  * import { createWorkflowTool } from '@src/core'
@@ -963,42 +1021,35 @@ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface,
963
1021
  export declare function createWorkflowTool(definition: WorkflowDefinition, runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): ToolInterface;
964
1022
 
965
1023
  /**
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
968
- * handler PARSES the model-supplied args against that contract and DISPATCHES the matched
969
- * operation against the manager's ACTIVE workspace (the registry ops drive the manager itself),
970
- * returning the plain result. A malformed operation throws this package's `ToolboxError`; a
971
- * genuine workspace-domain failure propagates `@orkestrel/workspace`'s typed `WorkspaceError`.
972
- * EITHER drives a caller-supplied {@link WorkspaceToolOptions.manager} directly, OR
973
- * constructs a fresh `WorkspaceManagerInterface` (`@orkestrel/workspace`) over
974
- * {@link import('./types.js').WorkspaceToolOptions.store} (via `@orkestrel/workspace`'s
975
- * `createWorkspaceManager`); neither given constructs a manager backed by
976
- * `@orkestrel/workspace`'s in-memory store default.
1024
+ * Builds an LLM-callable workspace-editing tool — it advertises the `operation`-discriminated union
1025
+ * ({@link import('./shapers.js').workspaceToolShape}) as its `parameters`, and its handler parses
1026
+ * the model-supplied args against that contract and dispatches the matched operation against the
1027
+ * manager's active workspace, returning the plain result.
977
1028
  *
978
1029
  * @remarks
979
- * MANAGER-DRIVEN: every edit / read op (read / list / has / search / replace / write / splice /
1030
+ * Manager-driven: every edit / read op (read / list / has / search / replace / write / splice /
980
1031
  * prepend / append / move / remove) targets `manager.active`, so the model edits whichever
981
1032
  * workspace is active and a host can re-point it (`WorkspaceManagerInterface.switch`) between
982
- * turns. Two REGISTRY ops make the model self-sufficient: `workspaces` LISTS the registered
1033
+ * turns. The registry ops make the model self-sufficient: `workspaces` lists the registered
983
1034
  * workspaces (each `{ id, files, active }`) so it can discover an id, and `switch` re-points the
984
1035
  * active workspace by id (lenient — an unknown id is a no-op reporting `switched: false`, never a
985
1036
  * throw).
986
1037
  *
987
- * NO-ACTIVE RULE (the ergonomic seam): a WRITING op (write / splice / prepend / append / move /
988
- * 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 /
990
- * has / search) against no active workspace returns the EMPTY result (`undefined` / `[]` /
1038
+ * No-active rule (the ergonomic seam): a writing op (write / splice / prepend / append / move /
1039
+ * remove / replace) run when `manager.active` is `undefined` auto-creates and activates a default
1040
+ * workspace (`manager.add()`) so the model can start writing; a pure-read op (read / list /
1041
+ * has / search) against no active workspace returns the empty result (`undefined` / `[]` /
991
1042
  * `false`), never creating one and never throwing.
992
1043
  *
993
- * The handler conforms to the universal tool-handler contract (AGENTS §14): it `contract.parse`s
994
- * the args, THROWS a `TOOL` `ToolboxError` when no operation arm matched (a malformed / unknown
995
- * 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
1044
+ * The handler conforms to the universal tool-handler contract: it `contract.parse`s
1045
+ * the args, throws a `TOOL` `ToolboxError` when no operation arm matched (a malformed / unknown
1046
+ * operation), else `switch`es on `op.operation` and returns the plain result — letting a
1047
+ * `WorkspaceError` raised by the live workspace (`MISSING` / `MODALITY` / `PATTERN` / `RANGE`)
1048
+ * propagate uncaught. The range edit is the flat `'splice'` op: its flat caret integers are
998
1049
  * reassembled into a `Range` (`@orkestrel/workspace`) by `rangeOf` and fed to the workspace's
999
1050
  * ranged `write`.
1000
1051
  *
1001
- * @param options - `manager` (drive directly) OR `store` (build a manager over it); neither ⇒
1052
+ * @param options - `manager` (drive directly) or `store` (build a manager over it); neither ⇒
1002
1053
  * an in-memory-backed manager (see {@link import('./types.js').WorkspaceToolOptions})
1003
1054
  * @returns A `ToolInterface` (named {@link import('./constants.js').WORKSPACE_TOOL_NAME} by default)
1004
1055
  *
@@ -1015,49 +1066,55 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
1015
1066
  export declare function createWorkspaceTool(options?: WorkspaceToolOptions): ToolInterface;
1016
1067
 
1017
1068
  /**
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.
1069
+ * Holds the description {@link import('./factories.js').createDatabaseTool} advertises — a
1070
+ * multi-line guide that teaches a small model the operation list, the serialized query form, and
1071
+ * the {@link import('./types.js').TableSpec} column DSL.
1021
1072
  *
1022
1073
  * @remarks
1023
- * The query form is deliberately SERIALIZED (never fluent) — every condition is a flat object
1024
- * `{ column, operator, values, connector? }` where `values` is ALWAYS an array, even for a
1074
+ * The query form is deliberately serialized (never fluent) — every condition is a flat object
1075
+ * `{ column, operator, values, connector? }` where `values` is always an array, even for a
1025
1076
  * single-value operator (`{ column: 'age', operator: 'from', values: [18] }`), so a small model
1026
1077
  * never has to chain method calls or guess whether a value is scalar or a list.
1027
1078
  */
1028
1079
  export declare const DATABASE_TOOL_DESCRIPTION: string;
1029
1080
 
1030
- /** The default cap on rows a `records` call returns when the caller omits `query.limit` — the upcoming database tool's default row ceiling. */
1081
+ /**
1082
+ * Holds the default cap on rows a `records` call returns when the caller omits `query.limit`,
1083
+ * `1000` — the database tool's default row ceiling.
1084
+ */
1031
1085
  export declare const DATABASE_TOOL_LIMIT = 1000;
1032
1086
 
1033
- /** The runtime-frozen database-tool mutation names disabled by `DatabaseToolOptions.readonly`. */
1087
+ /** Lists the runtime-frozen database-tool mutation names disabled by `DatabaseToolOptions.readonly`. */
1034
1088
  export declare const DATABASE_TOOL_MUTATIONS: readonly string[];
1035
1089
 
1036
1090
  /**
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.
1091
+ * Holds the name {@link import('./factories.js').createDatabaseTool} advertises by default,
1092
+ * `'database'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
1093
+ * under.
1044
1094
  */
1045
1095
  export declare const DATABASE_TOOL_NAME = "database";
1046
1096
 
1047
1097
  /**
1048
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} the upcoming database tool
1049
- * will advertise in place of {@link DATABASE_TOOL_DESCRIPTION}.
1098
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
1099
+ * {@link import('./factories.js').createDatabaseTool} advertises in place of
1100
+ * {@link DATABASE_TOOL_DESCRIPTION} — one sentence offering the `operation`-keyed database call and
1101
+ * pointing at `describe` for the operation list, the query form, and the column DSL.
1102
+ *
1103
+ * @remarks
1104
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
1105
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
1106
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
1050
1107
  */
1051
1108
  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
1109
 
1053
1110
  /**
1054
- * One database's CONFIG-ONLY definition — `id` + `driver` + {@link TableSpec}, with optional
1055
- * `primary`, `indexes`, and `version` schema configuration.
1111
+ * Represents one database's config-only definition — an `id`, a `driver`, and a {@link TableSpec},
1112
+ * with optional `primary`, `indexes`, and `version` schema configuration.
1056
1113
  *
1057
1114
  * @remarks
1058
- * A `DatabaseDefinition` is NEVER a live handle — it is the durable, serializable config a
1115
+ * A `DatabaseDefinition` is never a live handle — it is the durable, serializable config a
1059
1116
  * {@link DefinitionStoreInterface} persists and a tool factory turns into a real
1060
- * `@orkestrel/database` `DatabaseInterface` (via `createDatabase` + {@link import('./helpers.js').expandTables})
1117
+ * `@orkestrel/database` `DatabaseInterface` (through `createDatabase` and {@link import('./compilers.js').expandTables})
1061
1118
  * on demand. `primary` maps table names to primary-key columns; `indexes` maps table names to
1062
1119
  * index column groups; `version` opts a capable driver into open-time schema reconciliation.
1063
1120
  */
@@ -1070,41 +1127,41 @@ export declare interface DatabaseDefinition {
1070
1127
  readonly version?: number;
1071
1128
  }
1072
1129
 
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. */
1130
+ /** Represents one opaque persisted row — the shape a definition-row-backed `TableInterface` store reads/writes; `definition` is narrowed with {@link import('./validators.js').isDatabaseDefinition} on read. */
1074
1131
  export declare interface DatabaseDefinitionRow {
1075
1132
  readonly id: string;
1076
1133
  readonly definition: unknown;
1077
1134
  }
1078
1135
 
1079
1136
  /**
1080
- * A {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
1081
- * database's durable CONFIG state IS a row, so persistence reduces to keyed point-access
1137
+ * Represents a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
1138
+ * database's durable config state is a row, so persistence reduces to keyed point-access
1082
1139
  * (`get` / `set` / `delete`) over a {@link TableInterface}, the driver-pluggable twin of the
1083
1140
  * plain-`Map` {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}.
1084
1141
  *
1085
1142
  * @remarks
1086
1143
  * The store is driver-agnostic: it holds a single {@link TableInterface} whose backend (memory,
1087
1144
  * JSON, SQLite, IndexedDB) is chosen by whoever builds it (the factories), so a JSON / SQLite /
1088
- * IndexedDB backend swaps in WITHOUT touching a consumer — the same seam as
1145
+ * IndexedDB backend swaps in without touching a consumer — the same seam as
1089
1146
  * {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}. The driver defaults to
1090
1147
  * memory ({@link import('../factories.js').createDatabaseDefinitionStore} passes
1091
- * `createMemoryDriver()`), so it ALSO works in memory out of the box; you opt into the durable
1148
+ * `createMemoryDriver()`), so it also works in memory out of the box; you opt into the durable
1092
1149
  * plumbing by passing a JSON / SQLite / IndexedDB driver.
1093
1150
  *
1094
- * The {@link DatabaseDefinition} is stored as ONE OPAQUE JSON COLUMN — the table is a row of
1095
- * `{ id; definition }` ({@link DatabaseDefinitionRow}). The definition is already a COMPLETE,
1096
- * self-contained, pure-JSON CONFIG payload (never a live handle), so storing it whole is lossless
1097
- * AND keeps the row type flat (`definition` reads back as `unknown`).
1151
+ * The {@link DatabaseDefinition} is stored as one opaque JSON column — the table is a row of
1152
+ * `{ id; definition }` ({@link DatabaseDefinitionRow}). The definition is already a complete,
1153
+ * self-contained, pure-JSON config payload (never a live handle), so storing it whole is lossless
1154
+ * and keeps the row type flat (`definition` reads back as `unknown`).
1098
1155
  *
1099
- * - **`set(definition)` upserts under the definition's OWN `id`** (no separate id param) — it
1156
+ * - **`set(definition)` upserts under the definition's own `id`** (no separate id param) — it
1100
1157
  * writes the row `{ id: definition.id, definition }`.
1101
1158
  * - **`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
1159
+ * to a {@link DatabaseDefinition} ({@link import('../validators.js').isDatabaseDefinition} — the
1160
+ * boundary narrow for an untrusted storage read), or `undefined` if none is stored
1104
1161
  * or the stored blob is malformed.
1105
1162
  * - **`delete(id)` drops a definition by id**; an absent id is a no-op (no throw).
1106
1163
  *
1107
- * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
1164
+ * The public surface is exactly `get` / `set` / `delete` — no extra members (the method
1108
1165
  * bijection with {@link DefinitionStoreInterface}).
1109
1166
  *
1110
1167
  * @example
@@ -1120,22 +1177,65 @@ export declare interface DatabaseDefinitionRow {
1120
1177
  export declare class DatabaseDefinitionStore implements DefinitionStoreInterface {
1121
1178
  #private;
1122
1179
  /**
1123
- * Wrap a table as a definition store.
1180
+ * Wraps a table as a definition store.
1124
1181
  *
1125
1182
  * @param table - The {@link TableInterface} holding the definitions — its row is the
1126
1183
  * {@link DatabaseDefinitionRow} `{ id; definition }` shape (the definition one opaque JSON column)
1127
1184
  */
1128
1185
  constructor(table: TableInterface<DatabaseDefinitionRow>);
1129
- /** Resolve the persisted definition for `id`, narrowing the opaque JSON column back to a `DatabaseDefinition`. */
1186
+ /**
1187
+ * Resolves the persisted definition for `id`, narrowing the opaque JSON column back to a
1188
+ * {@link DatabaseDefinition}.
1189
+ *
1190
+ * @param id - The database id to read
1191
+ * @returns The stored {@link DatabaseDefinition}, or `undefined` when none is stored or the
1192
+ * stored blob is malformed
1193
+ */
1130
1194
  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 }`. */
1195
+ /**
1196
+ * Inserts or replaces a definition under its own `id` — the written row is `{ id, definition }`.
1197
+ *
1198
+ * @param definition - The config to persist; its own `id` is the row key (no separate id param)
1199
+ * @returns A promise settling after the row is written
1200
+ */
1132
1201
  set(definition: DatabaseDefinition): Promise<void>;
1133
- /** Drop a definition by id; an absent id is a no-op (no throw). */
1202
+ /**
1203
+ * Drops the definition stored under `id`.
1204
+ *
1205
+ * @param id - The database id to drop; an absent id is a no-op, never a throw
1206
+ * @returns A promise settling after no row is stored under `id`
1207
+ */
1134
1208
  delete(id: string): Promise<void>;
1135
1209
  }
1136
1210
 
1137
1211
  /**
1138
- * Resolve database definitions into cached live handles for database tools.
1212
+ * Represents the serialized wire query a database-tool call carries — the parsed form of
1213
+ * {@link import('./shapers.js').queryShape}, which {@link import('./helpers.js').normalizeQuery}
1214
+ * normalizes into a live `@orkestrel/database` `QueryInput`.
1215
+ *
1216
+ * @remarks
1217
+ * Every condition is flat and its `values` is always an array, even for a single-value operator.
1218
+ * `connector` is optional because the last condition joins nothing forward; `normalizeQuery` defaults an
1219
+ * omitted one to `'and'`. `order` / `limit` / `offset` carry over to the live query unchanged.
1220
+ */
1221
+ export declare interface DatabaseQueryInput {
1222
+ readonly conditions?: ReadonlyArray<Readonly<{
1223
+ column: string;
1224
+ operator: Condition['operator'];
1225
+ values: readonly unknown[];
1226
+ connector?: ConditionConnector;
1227
+ }>>;
1228
+ readonly order?: ReadonlyArray<Readonly<{
1229
+ column: string;
1230
+ direction: OrderDirection;
1231
+ }>>;
1232
+ readonly limit?: number;
1233
+ readonly offset?: number;
1234
+ }
1235
+
1236
+ /**
1237
+ * Resolves a database definition into a cached live handle for a database tool, over the tool's
1238
+ * live handles, its stored definitions, its driver registry, and an optional key generator.
1139
1239
  *
1140
1240
  * @example
1141
1241
  * ```ts
@@ -1148,7 +1248,7 @@ export declare class DatabaseDefinitionStore implements DefinitionStoreInterface
1148
1248
  export declare class DatabaseResolver {
1149
1249
  #private;
1150
1250
  /**
1151
- * Create a database resolver over the tool's live state and optional definition store.
1251
+ * Creates a database resolver over the tool's live state and optional definition store.
1152
1252
  *
1153
1253
  * @param handles - Initial live database handles cached by id
1154
1254
  * @param drivers - Driver factories keyed by definition driver name
@@ -1157,21 +1257,21 @@ export declare class DatabaseResolver {
1157
1257
  */
1158
1258
  constructor(handles: ReadonlyMap<string, DatabaseInterface>, drivers: Readonly<Record<string, () => DriverInterface>>, generator?: KeyFunction, store?: DefinitionStoreInterface);
1159
1259
  /**
1160
- * Determine whether a live database is cached by id.
1260
+ * Determines whether a live database is cached by id.
1161
1261
  *
1162
1262
  * @param id - Database id
1163
- * @returns Whether a live handle is cached
1263
+ * @returns True if a live handle is cached; false otherwise
1164
1264
  */
1165
1265
  has(id: string): boolean;
1166
1266
  /**
1167
- * Read a cached database without consulting the definition store.
1267
+ * Reads a cached database without consulting the definition store.
1168
1268
  *
1169
1269
  * @param id - Database id
1170
1270
  * @returns The cached live database, or `undefined`
1171
1271
  */
1172
1272
  get(id: string): DatabaseInterface | undefined;
1173
1273
  /**
1174
- * Cache a live database by id.
1274
+ * Caches a live database by id.
1175
1275
  *
1176
1276
  * @param id - Database id
1177
1277
  * @param database - Live database handle
@@ -1179,14 +1279,15 @@ export declare class DatabaseResolver {
1179
1279
  */
1180
1280
  set(id: string, database: DatabaseInterface): void;
1181
1281
  /**
1182
- * Remove a cached live database by id.
1282
+ * Removes a cached live database by id.
1183
1283
  *
1184
1284
  * @param id - Database id
1185
1285
  * @returns Nothing
1186
1286
  */
1187
1287
  delete(id: string): void;
1188
1288
  /**
1189
- * Resolve a cached or stored database by id.
1289
+ * Resolves a live database by id — the cached handle when one exists, otherwise a database
1290
+ * constructed from its stored definition.
1190
1291
  *
1191
1292
  * @param id - Database definition id
1192
1293
  * @returns The cached or newly constructed live database
@@ -1195,26 +1296,15 @@ export declare class DatabaseResolver {
1195
1296
  }
1196
1297
 
1197
1298
  /**
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}).
1299
+ * Represents the options for {@link import('./factories.js').createDatabaseTool} — the live handles, definition
1300
+ * store, driver registry, key generator, row cap, timeout, and readonly gate the tool composes.
1211
1301
  *
1212
1302
  * @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
1303
+ * - `databases` — live `DatabaseInterface` handles to seed the tool's cache with (for example a
1304
+ * caller-constructed database it manages alongside store-backed ones); keyed by the id a
1215
1305
  * call's `id` field addresses.
1216
1306
  * - `store` — the {@link DefinitionStoreInterface} the `'create'` operation persists its
1217
- * {@link DatabaseDefinition} CONFIG through, and `'destroy'` deletes from; also the source
1307
+ * {@link DatabaseDefinition} config through, and `'destroy'` deletes from; also the source
1218
1308
  * `'get'`/every other operation resolves an id from when it isn't already cached. Omitted means
1219
1309
  * no persistence — a database created without a store lives only for the tool's lifetime.
1220
1310
  * - `drivers` — registry of driver-name to `() => DriverInterface` factories a `'create'` call's
@@ -1223,7 +1313,7 @@ export declare function databaseToolCode(error: unknown): DatabaseErrorCode | un
1223
1313
  * - `generator` — the optional `KeyFunction` (`@orkestrel/database`) every minted database is
1224
1314
  * constructed with, used when a written row lacks its primary key. Omitted delegates to the
1225
1315
  * database's default generator.
1226
- * - `limit` — the `'records'` row cap — via {@link import('./helpers.js').clampQuery}
1316
+ * - `limit` — the `'records'` row cap — through {@link import('./helpers.js').clampQuery}
1227
1317
  * — enforce when a call's `query.limit` is omitted or exceeds it. Defaults to
1228
1318
  * {@link import('./constants.js').DATABASE_TOOL_LIMIT}.
1229
1319
  * - `timeout` — a nonnegative safe-integer number of milliseconds. A fresh
@@ -1250,136 +1340,138 @@ export declare interface DatabaseToolOptions {
1250
1340
  }
1251
1341
 
1252
1342
  /**
1253
- * The shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
1254
- * discriminated by `operation` into the 11 database operations (`'create'` / `'tables'` /
1255
- * `'get'` / `'records'` / `'count'` / `'aggregate'` / `'add'` / `'set'` / `'update'` /
1256
- * `'remove'` / `'destroy'`).
1343
+ * Describes the shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
1344
+ * discriminated by `operation` into the database operations `'create'`, `'tables'`, `'get'`,
1345
+ * `'records'`, `'count'`, `'aggregate'`, `'add'`, `'set'`, `'update'`, `'remove'`, and `'destroy'`.
1257
1346
  *
1258
1347
  * @remarks
1259
1348
  * 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`
1349
+ * {@link import('./types.js').TableSpec} column DSL, compiled through
1350
+ * {@link import('./compilers.js').expandTables}); `'get'` / `'update'` / `'remove'` carry `key`
1262
1351
  * (one key or an array of keys, positional); `'add'` / `'set'` carry `row` (one row or an array of
1263
1352
  * rows); `'update'` also carries `changes` (a loose partial row); `'records'` / `'count'` /
1264
- * `'aggregate'` carry an optional `query` (the SERIALIZED form — `values` is ALWAYS an array,
1353
+ * `'aggregate'` carry an optional `query` (the serialized form — `values` is always an array,
1265
1354
  * even for a single-value operator, so a caller never chains method calls or guesses arity).
1266
1355
  */
1267
- export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
1268
- operation: LiteralShape<readonly ["create"]>;
1269
- id: StringShape;
1270
- tables: ObjectShape<Record<never, never>, ObjectShape<{
1271
- columns: ObjectShape<Record<never, never>, UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
1272
- type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
1273
- optional: OptionalShape<BooleanShape>;
1274
- }, false>]>>;
1275
- }, false>>;
1276
- driver: OptionalShape<StringShape>;
1277
- primary: OptionalShape<ObjectShape<Record<never, never>, StringShape>>;
1278
- indexes: OptionalShape<ObjectShape<Record<never, never>, ArrayShape<ArrayShape<StringShape>>>>;
1279
- version: OptionalShape<NumberShape>;
1280
- }, false>, ObjectShape<{
1281
- operation: LiteralShape<readonly ["tables"]>;
1282
- id: StringShape;
1283
- }, false>, ObjectShape<{
1284
- operation: LiteralShape<readonly ["get"]>;
1285
- id: StringShape;
1286
- table: StringShape;
1287
- key: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1288
- }, false>, ObjectShape<{
1289
- operation: LiteralShape<readonly ["records"]>;
1290
- id: StringShape;
1291
- table: StringShape;
1292
- query: OptionalShape<ObjectShape<{
1293
- conditions: OptionalShape<ArrayShape<ObjectShape<{
1294
- column: StringShape;
1295
- operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1296
- values: ArrayShape<JSONShape>;
1297
- connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1298
- }, false>>>;
1299
- order: OptionalShape<ArrayShape<ObjectShape<{
1300
- column: StringShape;
1301
- direction: LiteralShape<readonly ["ascending", "descending"]>;
1302
- }, false>>>;
1303
- limit: OptionalShape<NumberShape>;
1304
- offset: OptionalShape<NumberShape>;
1305
- }, false>>;
1306
- }, false>, ObjectShape<{
1307
- operation: LiteralShape<readonly ["count"]>;
1308
- id: StringShape;
1309
- table: StringShape;
1310
- query: OptionalShape<ObjectShape<{
1311
- conditions: OptionalShape<ArrayShape<ObjectShape<{
1312
- column: StringShape;
1313
- operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1314
- values: ArrayShape<JSONShape>;
1315
- connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1316
- }, false>>>;
1317
- order: OptionalShape<ArrayShape<ObjectShape<{
1318
- column: StringShape;
1319
- direction: LiteralShape<readonly ["ascending", "descending"]>;
1320
- }, false>>>;
1321
- limit: OptionalShape<NumberShape>;
1322
- offset: OptionalShape<NumberShape>;
1323
- }, false>>;
1324
- }, false>, ObjectShape<{
1325
- operation: LiteralShape<readonly ["aggregate"]>;
1326
- id: StringShape;
1327
- table: StringShape;
1328
- function: LiteralShape<readonly ["count", "sum", "average", "minimum", "maximum"]>;
1329
- column: StringShape;
1330
- query: OptionalShape<ObjectShape<{
1331
- conditions: OptionalShape<ArrayShape<ObjectShape<{
1332
- column: StringShape;
1333
- operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1334
- values: ArrayShape<JSONShape>;
1335
- connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1336
- }, false>>>;
1337
- order: OptionalShape<ArrayShape<ObjectShape<{
1338
- column: StringShape;
1339
- direction: LiteralShape<readonly ["ascending", "descending"]>;
1340
- }, false>>>;
1341
- limit: OptionalShape<NumberShape>;
1342
- offset: OptionalShape<NumberShape>;
1343
- }, false>>;
1344
- }, false>, ObjectShape<{
1345
- operation: LiteralShape<readonly ["add"]>;
1346
- id: StringShape;
1347
- table: StringShape;
1348
- row: UnionShape<readonly [ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
1349
- }, false>, ObjectShape<{
1350
- operation: LiteralShape<readonly ["set"]>;
1351
- id: StringShape;
1352
- table: StringShape;
1353
- row: UnionShape<readonly [ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
1354
- }, false>, ObjectShape<{
1355
- operation: LiteralShape<readonly ["update"]>;
1356
- id: StringShape;
1357
- table: StringShape;
1358
- key: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1359
- changes: ObjectShape<Record<never, never>, JSONShape>;
1360
- }, false>, ObjectShape<{
1361
- operation: LiteralShape<readonly ["remove"]>;
1362
- id: StringShape;
1363
- table: StringShape;
1364
- key: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1365
- }, false>, ObjectShape<{
1366
- operation: LiteralShape<readonly ["destroy"]>;
1367
- id: StringShape;
1356
+ export declare const databaseToolShape: UnionShape<readonly [ObjectShape< {
1357
+ operation: LiteralShape<readonly ["create"]>;
1358
+ id: StringShape;
1359
+ tables: ObjectShape<Record<never, never>, ObjectShape< {
1360
+ columns: ObjectShape<Record<never, never>, UnionShape<readonly [LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape< {
1361
+ primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
1362
+ optional: OptionalShape<BooleanShape>;
1363
+ }, false>]>>;
1364
+ }, false>>;
1365
+ driver: OptionalShape<StringShape>;
1366
+ primary: OptionalShape<ObjectShape<Record<never, never>, StringShape>>;
1367
+ indexes: OptionalShape<ObjectShape<Record<never, never>, ArrayShape<ArrayShape<StringShape>>>>;
1368
+ version: OptionalShape<NumberShape>;
1369
+ }, false>, ObjectShape< {
1370
+ operation: LiteralShape<readonly ["tables"]>;
1371
+ id: StringShape;
1372
+ }, false>, ObjectShape< {
1373
+ operation: LiteralShape<readonly ["get"]>;
1374
+ id: StringShape;
1375
+ table: StringShape;
1376
+ key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
1377
+ }, false>, ObjectShape< {
1378
+ operation: LiteralShape<readonly ["records"]>;
1379
+ id: StringShape;
1380
+ table: StringShape;
1381
+ query: OptionalShape<ObjectShape< {
1382
+ conditions: OptionalShape<ArrayShape<ObjectShape< {
1383
+ column: StringShape;
1384
+ operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1385
+ values: ArrayShape<JSONShape>;
1386
+ connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1387
+ }, false>>>;
1388
+ order: OptionalShape<ArrayShape<ObjectShape< {
1389
+ column: StringShape;
1390
+ direction: LiteralShape<readonly ["ascending", "descending"]>;
1391
+ }, false>>>;
1392
+ limit: OptionalShape<NumberShape>;
1393
+ offset: OptionalShape<NumberShape>;
1394
+ }, false>>;
1395
+ }, false>, ObjectShape< {
1396
+ operation: LiteralShape<readonly ["count"]>;
1397
+ id: StringShape;
1398
+ table: StringShape;
1399
+ query: OptionalShape<ObjectShape< {
1400
+ conditions: OptionalShape<ArrayShape<ObjectShape< {
1401
+ column: StringShape;
1402
+ operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1403
+ values: ArrayShape<JSONShape>;
1404
+ connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1405
+ }, false>>>;
1406
+ order: OptionalShape<ArrayShape<ObjectShape< {
1407
+ column: StringShape;
1408
+ direction: LiteralShape<readonly ["ascending", "descending"]>;
1409
+ }, false>>>;
1410
+ limit: OptionalShape<NumberShape>;
1411
+ offset: OptionalShape<NumberShape>;
1412
+ }, false>>;
1413
+ }, false>, ObjectShape< {
1414
+ operation: LiteralShape<readonly ["aggregate"]>;
1415
+ id: StringShape;
1416
+ table: StringShape;
1417
+ function: LiteralShape<readonly ["count", "sum", "average", "minimum", "maximum"]>;
1418
+ column: StringShape;
1419
+ query: OptionalShape<ObjectShape< {
1420
+ conditions: OptionalShape<ArrayShape<ObjectShape< {
1421
+ column: StringShape;
1422
+ operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1423
+ values: ArrayShape<JSONShape>;
1424
+ connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1425
+ }, false>>>;
1426
+ order: OptionalShape<ArrayShape<ObjectShape< {
1427
+ column: StringShape;
1428
+ direction: LiteralShape<readonly ["ascending", "descending"]>;
1429
+ }, false>>>;
1430
+ limit: OptionalShape<NumberShape>;
1431
+ offset: OptionalShape<NumberShape>;
1432
+ }, false>>;
1433
+ }, false>, ObjectShape< {
1434
+ operation: LiteralShape<readonly ["add"]>;
1435
+ id: StringShape;
1436
+ table: StringShape;
1437
+ row: UnionShape<readonly [ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
1438
+ }, false>, ObjectShape< {
1439
+ operation: LiteralShape<readonly ["set"]>;
1440
+ id: StringShape;
1441
+ table: StringShape;
1442
+ row: UnionShape<readonly [ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
1443
+ }, false>, ObjectShape< {
1444
+ operation: LiteralShape<readonly ["update"]>;
1445
+ id: StringShape;
1446
+ table: StringShape;
1447
+ key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
1448
+ changes: ObjectShape<Record<never, never>, JSONShape>;
1449
+ }, false>, ObjectShape< {
1450
+ operation: LiteralShape<readonly ["remove"]>;
1451
+ id: StringShape;
1452
+ table: StringShape;
1453
+ key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
1454
+ }, false>, ObjectShape< {
1455
+ operation: LiteralShape<readonly ["destroy"]>;
1456
+ id: StringShape;
1368
1457
  }, false>]>;
1369
1458
 
1370
1459
  /**
1371
- * The point-access persistence seam (AGENTS §5 — Stores) for {@link DatabaseDefinition} configs —
1372
- * the twin of `@orkestrel/terminal`'s `TerminalStoreInterface`, storing a database's CONFIG-ONLY
1373
- * blueprint (never a live handle). Every primitive is async; `delete` of an absent id is a no-op.
1460
+ * Represents the point-access persistence seam for {@link DatabaseDefinition} configs — the twin of
1461
+ * `@orkestrel/terminal`'s `TerminalStoreInterface`, storing a database's config-only blueprint
1462
+ * rather than a live handle. Every primitive is async; `delete` of an absent id is a no-op.
1374
1463
  */
1375
1464
  export declare interface DefinitionStoreInterface {
1465
+ /** Resolves the persisted definition for `id`, or `undefined` when none is stored. */
1376
1466
  get(id: string): Promise<DatabaseDefinition | undefined>;
1467
+ /** Inserts or replaces a definition under its own `id`, taking no separate id argument. */
1377
1468
  set(definition: DatabaseDefinition): Promise<void>;
1469
+ /** Drops the definition for `id`, treating an absent id as a no-op that never throws. */
1378
1470
  delete(id: string): Promise<void>;
1379
1471
  }
1380
1472
 
1381
1473
  /**
1382
- * Derive the zero-based workflow nesting depth from a valid lineage.
1474
+ * Derives the zero-based workflow nesting depth from a valid lineage.
1383
1475
  *
1384
1476
  * @param lineage - The workflow/agent chain
1385
1477
  * @returns Zero for an empty/root lineage, then one per nested workflow
@@ -1387,7 +1479,8 @@ export declare interface DefinitionStoreInterface {
1387
1479
  export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
1388
1480
 
1389
1481
  /**
1390
- * The DESCRIPTION {@link import('./factories.js').createDescribeTool} advertises.
1482
+ * Holds the description {@link import('./factories.js').createDescribeTool} advertises — the
1483
+ * registered tool `name` it requires, and the full description of that tool it returns.
1391
1484
  *
1392
1485
  * @remarks
1393
1486
  * Deliberately short — unlike the workflow / workspace / agent tools, this one has no authoring
@@ -1396,110 +1489,113 @@ export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
1396
1489
  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
1490
 
1398
1491
  /**
1399
- * The name {@link import('./factories.js').createDescribeTool} advertises by default — the key a
1400
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1492
+ * Holds the name {@link import('./factories.js').createDescribeTool} advertises by default,
1493
+ * `'describe'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
1494
+ * under.
1401
1495
  *
1402
1496
  * @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
1497
+ * Pairs with the lean {@link AGENT_TOOL_SUMMARY} / {@link WORKFLOW_TOOL_SUMMARY} /
1498
+ * {@link WORKSPACE_TOOL_SUMMARY} — a model that reads only the
1405
1499
  * advertised summary can call `describe` with that tool's registered name to get its full
1406
1500
  * teaching description back.
1407
1501
  */
1408
1502
  export declare const DESCRIBE_TOOL_NAME = "describe";
1409
1503
 
1410
1504
  /**
1411
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createDescribeTool}
1505
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createDescribeTool}
1412
1506
  * advertises — this tool needs no teaching of its own, so its summary and description are both
1413
1507
  * short.
1414
1508
  */
1415
1509
  export declare const DESCRIBE_TOOL_SUMMARY = "Return the full description of a named registered tool.";
1416
1510
 
1417
1511
  /**
1418
- * The FLAT args {@link import('./factories.js').createDescribeTool} accepts — the registered
1419
- * tool `name` whose full `description` a model wants back.
1512
+ * Represents the flat args {@link import('./factories.js').createDescribeTool} accepts — the
1513
+ * registered tool `name` whose full `description` a model wants back.
1420
1514
  *
1421
1515
  * @remarks
1422
1516
  * `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)`.
1517
+ * the describe tool was built over — it is looked up through `tools.tool(name)`.
1424
1518
  */
1425
1519
  export declare interface DescribeToolArguments {
1426
1520
  readonly name: string;
1427
1521
  }
1428
1522
 
1429
1523
  /**
1430
- * The shape of {@link import('./types.js').DescribeToolArguments} —
1524
+ * Describes the shape of {@link import('./types.js').DescribeToolArguments} —
1431
1525
  * {@link import('./factories.js').createDescribeTool}'s advertised `parameters`.
1432
1526
  *
1433
1527
  * @remarks
1434
1528
  * `name` is the only field (a non-empty string) — the registered tool name to look up.
1435
1529
  */
1436
- export declare const describeToolShape: ObjectShape<{
1437
- name: StringShape;
1530
+ export declare const describeToolShape: ObjectShape< {
1531
+ name: StringShape;
1438
1532
  }, false>;
1439
1533
 
1440
1534
  /**
1441
- * One concrete endpoint {@link import('./factories.js').createEndpointTool} wraps as an
1535
+ * Represents one concrete endpoint {@link import('./factories.js').createEndpointTool} wraps as an
1442
1536
  * LLM-callable `ToolInterface` — the advertised identity, a non-empty set of example values its
1443
1537
  * `parameters` are inferred from, and the local handler that runs a call.
1444
1538
  *
1445
1539
  * @remarks
1446
- * `samples` MUST be non-empty — {@link import('./factories.js').createEndpointTool} throws a
1447
- * typed `TOOL` {@link import('./errors.js').ToolboxError} at CONSTRUCTION when it is empty,
1448
- * 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
1540
+ * `samples` must be non-empty — {@link import('./factories.js').createEndpointTool} throws a
1541
+ * typed `TOOL` {@link import('./errors.js').ToolboxError} at construction when it is empty,
1542
+ * because an empty sample set cannot infer a schema. By default ({@link EndpointToolOptions.validate}
1543
+ * `true`) `execute` receives the parsed, normalized args record — a copy of the model-supplied
1544
+ * `args` with each scalar coerced to its inferred type (for example a number sent for a string slot
1451
1545
  * 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
1546
+ * a call with a missing required key or a non-coercible value never reaches `execute` at all (see
1453
1547
  * {@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
1456
- * call's result; a throw PROPAGATES uncaught, isolated by the `ToolManagerInterface`
1548
+ * `validate: false`, `execute` receives the model-supplied `args` verbatim (raw passthrough, never
1549
+ * checked against the inferred schema). Either way `execute`'s return flows back as the tool
1550
+ * call's result; a throw propagates uncaught, isolated by the `ToolManagerInterface`
1457
1551
  * (`@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
1552
+ * the advertised schema wraps them under a single required `value` property, so `execute` receives
1459
1553
  * an `args` record of the shape `{ value: ... }` — never the bare value.
1460
1554
  */
1461
1555
  export declare interface EndpointDefinition {
1462
1556
  readonly name: string;
1463
1557
  readonly description: string;
1464
1558
  readonly samples: readonly unknown[];
1465
- readonly invoke: EndpointHandler;
1559
+ readonly execute: EndpointHandler;
1466
1560
  }
1467
1561
 
1468
1562
  /**
1469
- * The handler {@link import('./types.js').EndpointDefinition.invoke} implements — mirrors
1470
- * `@orkestrel/tool`'s `ToolOptions.execute` signature EXACTLY (same `Readonly<Record<string,
1471
- * unknown>>` argument, same `Promise<unknown> | unknown` return) so
1472
- * `execute: (args) => definition.invoke(args)` typechecks with zero assertions in
1563
+ * Represents the handler {@link EndpointDefinition.execute} implements — it mirrors
1564
+ * `@orkestrel/tool`'s `ToolOptions.execute` signature exactly (the same
1565
+ * `Readonly<Record<string, unknown>>` argument, the same `Promise<unknown> | unknown` return), so
1566
+ * `execute: (args) => definition.execute(args)` typechecks with zero assertions in
1473
1567
  * {@link import('./factories.js').createEndpointTool}.
1474
1568
  */
1475
1569
  export declare type EndpointHandler = (args: Readonly<Record<string, unknown>>) => Promise<unknown> | unknown;
1476
1570
 
1477
1571
  /**
1478
- * Construction-time tuning for {@link import('./factories.js').createEndpointTool} — the
1479
- * inferred `parameters` schema's `format` / `enum` constraints, and whether that same schema is
1480
- * ENFORCED at `execute` time.
1572
+ * Represents the construction-time tuning for {@link import('./factories.js').createEndpointTool} —
1573
+ * the inferred `parameters` schema's `format` and `enum` constraints, and whether that same schema
1574
+ * is enforced at `execute` time.
1481
1575
  *
1482
1576
  * @remarks
1483
1577
  * `format` / `enum` default to `false`, matching `@orkestrel/contract`'s own
1484
1578
  * `ValueToSchemaOptions` defaults. `validate` defaults to `true`: the schema
1485
- * `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
1488
- * 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
1579
+ * `createEndpointTool` advertises as `parameters` (`samplesToSchema` and `schemaToObject`) is
1580
+ * compiled once at construction (through `@orkestrel/contract`'s `schemaToShape`) into a
1581
+ * `ContractInterface` used to `parse` every call's `args` before `execute` runs — a normalizing
1582
+ * parse: a scalar value is coerced to its inferred type where the house parsers coerce (a number
1583
+ * to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/`'false'`/`1`/`0`), so `execute`
1584
+ * receives the coerced values (for example `7` sent for a string slot arrives at `execute` as `'7'`), not
1491
1585
  * the raw call args. A call whose `args` fails to parse — a required key missing, or a value not
1492
- * 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,
1494
- * enforcement is STRUCTURAL — required keys, `enum` membership, and numeric bounds — `format`
1495
- * annotations (`email`, `date-time`, `uuid`, `uri`, ...) are NEVER asserted, mirroring
1586
+ * coercible to its slot's type — throws a typed `TOOL` {@link import('./errors.js').ToolboxError}
1587
+ * carrying the structured `explain` faults, and `execute` is never called. Beyond that coercion,
1588
+ * enforcement is structural — required keys, `enum` membership, and numeric bounds — `format`
1589
+ * annotations (`email`, `date-time`, `uuid`, `uri`, ...) are never asserted, mirroring
1496
1590
  * `@orkestrel/contract`'s own widening-only law for `schemaToShape`: a `format: true`-tuned
1497
- * endpoint still ACCEPTS a non-conforming string in a format-tagged slot. A key NOT present in
1498
- * 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.
1591
+ * endpoint still accepts a non-conforming string in a format-tagged slot. A key not present in
1592
+ * the inferred (closed, `additionalProperties: false`) schema is never a rejection either — it is
1593
+ * silently dropped before `execute` runs (the same leniency `@orkestrel/contract`'s own `parse`
1594
+ * grants a closed object generally), so `execute` may see fewer keys than the caller sent. Set
1595
+ * `validate: false` when the endpoint's own handler validates its arguments, or when `samples`
1596
+ * under-describe the real contract and the normalizing coercion would corrupt a call: the tool's
1597
+ * `execute` then passes the model-supplied `args` to the handler unchanged, unchecked and
1598
+ * unstripped.
1503
1599
  */
1504
1600
  export declare interface EndpointToolOptions {
1505
1601
  readonly format?: boolean;
@@ -1508,15 +1604,15 @@ export declare interface EndpointToolOptions {
1508
1604
  }
1509
1605
 
1510
1606
  /**
1511
- * Expand the relation tool's FLAT dot-path `include` list into a live `@orkestrel/relation`
1607
+ * Expands the relation tool's flat dot-path `include` list into a live `@orkestrel/relation`
1512
1608
  * {@link Include} tree — the pure leaf {@link import('./factories.js').createRelationTool} calls
1513
1609
  * before a `'load'` / `'find'` call.
1514
1610
  *
1515
1611
  * @remarks
1516
1612
  * Each path splits on `'.'` into a chain of relation names, deep-merged into one nested
1517
- * `Include` object with a leaf `true`. A longer path SUBSUMES a shorter sibling's bare `true` —
1613
+ * `Include` object with a leaf `true`. A longer path subsumes a shorter sibling's bare `true` —
1518
1614
  * `'contacts'` followed by `'contacts.account'` yields `{ contacts: { account: true } }`, never
1519
- * overwriting the deeper chain. An EMPTY segment (`''`, from a leading/trailing/doubled `.`) or a
1615
+ * overwriting the deeper chain. An empty segment (`''`, from a leading/trailing/doubled `.`) or a
1520
1616
  * path whose segment count exceeds `depth` throws a typed `TOOL` {@link ToolboxError}.
1521
1617
  *
1522
1618
  * @param paths - The flat dot-path `include` list (or `undefined` — yields `{}`)
@@ -1534,19 +1630,19 @@ export declare interface EndpointToolOptions {
1534
1630
  export declare function expandInclude(paths: readonly string[] | undefined, depth: number): Include;
1535
1631
 
1536
1632
  /**
1537
- * Expand a flat {@link WorkflowSteps} blob into a strict {@link WorkflowDefinition} — each step
1538
- * becomes a one-task phase, IN ORDER.
1633
+ * Expands a flat {@link WorkflowSteps} blob into a strict {@link WorkflowDefinition} — each step
1634
+ * becomes a one-task phase, in order.
1539
1635
  *
1540
1636
  * @remarks
1541
- * The expansion of the tool's ADVERTISED surface: the deliberately-reduced flat form. Each
1637
+ * The expansion of the tool's advertised surface: the deliberately-reduced flat form. Each
1542
1638
  * {@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
1639
+ * `name` becomes the task's `behavior` (the behavior-registry key). Ids/names are auto-filled
1544
1640
  * positionally — it builds an ids-omitted {@link WorkflowDraft} and delegates to
1545
- * {@link completeDraft}, so the two lenient surfaces share ONE synthesis path (step `i` → phase
1641
+ * {@link completeDraft}, so the lenient surfaces share one synthesis path (step `i` → phase
1546
1642
  * `phase-<i>`, its task `phase-<i>-task-0`). The optional `name` becomes both the workflow's
1547
1643
  * deterministic id and its name, so named flat workflows retain distinct persistence keys;
1548
1644
  * omission keeps the shared draft fallback `wf`. The result is a complete definition the caller
1549
- * validates against the STRICT contract before running.
1645
+ * validates against the strict contract before running.
1550
1646
  *
1551
1647
  * @param flat - The flat steps blob (`{ name?, steps: [{ name }] }`)
1552
1648
  * @returns A complete {@link WorkflowDefinition} (one one-task phase per step)
@@ -1554,7 +1650,7 @@ export declare function expandInclude(paths: readonly string[] | undefined, dept
1554
1650
  export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
1555
1651
 
1556
1652
  /**
1557
- * Compile a {@link TableSpec} into the `@orkestrel/database` {@link TableMap} it configures —
1653
+ * Compiles a {@link TableSpec} into the `@orkestrel/database` {@link TableMap} it configures —
1558
1654
  * each {@link ColumnSpec} maps to the matching primitive shaper (`'string'` → `stringShape()`,
1559
1655
  * `'integer'` → `integerShape()`, `'number'` → `numberShape()`, `'boolean'` → `booleanShape()`),
1560
1656
  * wrapped in `optionalShape` when the column declares `optional: true`. Total, pure.
@@ -1565,7 +1661,7 @@ export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
1565
1661
  export declare function expandTables(spec: TableSpec): TableMap;
1566
1662
 
1567
1663
  /**
1568
- * Append one tag to a workflow lineage and return a frozen copy.
1664
+ * Appends one tag to a workflow lineage and returns a frozen copy.
1569
1665
  *
1570
1666
  * @param lineage - The valid chain to extend
1571
1667
  * @param tag - The workflow or agent tag to append
@@ -1573,31 +1669,78 @@ export declare function expandTables(spec: TableSpec): TableMap;
1573
1669
  */
1574
1670
  export declare function extendLineage(lineage: WorkflowLineage, tag: string): WorkflowLineage;
1575
1671
 
1576
- /** Flat dot-path relation include list, expanded via {@link import('./helpers.js').expandInclude}. */
1672
+ /** Describes the flat dot-path relation include list, expanded through {@link import('./helpers.js').expandInclude}. */
1577
1673
  export declare const includeShape: OptionalShape<ArrayShape<StringShape>>;
1578
1674
 
1579
- /** The schema-inference protocol {@link import('./factories.js').createInferTool} advertises. */
1675
+ /**
1676
+ * Holds the schema-inference protocol {@link import('./factories.js').createInferTool} advertises —
1677
+ * the required `samples`, the optional `format`, `enum`, and `candidates` arguments, and a worked
1678
+ * example of the bare return and of the `candidates`-wrapped return.
1679
+ */
1580
1680
  export declare const INFER_TOOL_DESCRIPTION: string;
1581
1681
 
1582
1682
  /**
1583
- * The name {@link import('./factories.js').createInferTool} advertises by default — the key a
1584
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1683
+ * Holds the name {@link import('./factories.js').createInferTool} advertises by default, `'infer'`
1684
+ * — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1585
1685
  */
1586
1686
  export declare const INFER_TOOL_NAME = "infer";
1587
1687
 
1588
1688
  /**
1589
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createInferTool}
1590
- * advertises in place of {@link INFER_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
1591
- * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
1592
- * for the full teaching description; the full text stays retrievable via
1593
- * {@link import('./factories.js').createDescribeTool}.
1689
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
1690
+ * {@link import('./factories.js').createInferTool} advertises in place of
1691
+ * {@link INFER_TOOL_DESCRIPTION} — one sentence offering schema inference from example values and
1692
+ * pointing at `describe` for the fields it takes.
1693
+ *
1694
+ * @remarks
1695
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
1696
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
1697
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
1594
1698
  */
1595
1699
  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
1700
 
1597
1701
  /**
1598
- * Options for {@link import('./factories.js').createInferTool} — advertised name/description
1599
- * overrides only; `format` / `enum` are RUNTIME call arguments (see
1600
- * {@link import('./shapers.js').inferToolShape}), not construction-time options, since a model
1702
+ * Maps a caught error to the granular {@link DatabaseErrorCode} (`@orkestrel/database`) the code
1703
+ * {@link import('./factories.js').createDatabaseTool} throws with — the pure classification step
1704
+ * of that factory's error handling, mirroring {@link inferTerminalCode}'s idiom for
1705
+ * `@orkestrel/database`.
1706
+ *
1707
+ * @param error - The value caught from a `@orkestrel/database` table operation
1708
+ * @returns The granular {@link DatabaseErrorCode}, or `undefined` if `error` is not a `DatabaseError`
1709
+ */
1710
+ export declare function inferDatabaseCode(error: unknown): DatabaseErrorCode | undefined;
1711
+
1712
+ /**
1713
+ * Maps a caught error to the granular {@link RelationErrorCode} (`@orkestrel/relation`) the code
1714
+ * {@link import('./factories.js').createRelationTool} throws with — the pure classification step
1715
+ * of that factory's error handling, mirroring {@link inferTerminalCode}'s idiom for
1716
+ * `@orkestrel/relation`.
1717
+ *
1718
+ * @param error - The value caught from a `@orkestrel/relation` operation
1719
+ * @returns The granular {@link RelationErrorCode}, or `undefined` if `error` is not a `RelationError`
1720
+ */
1721
+ export declare function inferRelationCode(error: unknown): RelationErrorCode | undefined;
1722
+
1723
+ /**
1724
+ * Maps a caught error to the {@link ToolboxErrorCode} the terminal-tool factory throws with — the
1725
+ * pure classification step of that factory's error handling.
1726
+ *
1727
+ * @remarks
1728
+ * Narrows `error` with {@link isTerminalError} (`@orkestrel/terminal`) first: a non-`TerminalError`
1729
+ * value returns `undefined`, telling the caller this mapper does not apply (rethrow / handle
1730
+ * otherwise). For a genuine `TerminalError`, `'DEADLOCK'` maps to `'DEADLOCK'`, `'EXPIRE'` maps
1731
+ * to `'EXPIRE'`, and every other {@link import('@orkestrel/terminal').TerminalErrorCode}
1732
+ * (`'TARGET'`, `'LIMIT'`, `'CANCEL'`, `'DRIVER'`, `'DESTROYED'`) maps to the generic `'TOOL'`
1733
+ * code. The mapper only classifies — the factory performs the actual throw.
1734
+ *
1735
+ * @param error - The value caught from a terminal-manager operation (`ask` / `answer` / …)
1736
+ * @returns The mapped {@link ToolboxErrorCode}, or `undefined` if `error` is not a `TerminalError`
1737
+ */
1738
+ export declare function inferTerminalCode(error: unknown): ToolboxErrorCode | undefined;
1739
+
1740
+ /**
1741
+ * Represents the options for {@link import('./factories.js').createInferTool} — advertised name and
1742
+ * description overrides only; `format` and `enum` are runtime call arguments (see
1743
+ * {@link import('./shapers.js').inferToolShape}), not construction-time options, because a model
1601
1744
  * chooses them per call.
1602
1745
  */
1603
1746
  export declare interface InferToolOptions {
@@ -1606,7 +1749,7 @@ export declare interface InferToolOptions {
1606
1749
  }
1607
1750
 
1608
1751
  /**
1609
- * The shape of {@link import('./factories.js').createInferTool}'s call arguments — one or more
1752
+ * Describes the shape of {@link import('./factories.js').createInferTool}'s call arguments — one or more
1610
1753
  * example `samples` to infer a JSON Schema from, plus per-call `format` / `enum` toggles and an
1611
1754
  * optional `candidates` array to check against the inferred schema.
1612
1755
  *
@@ -1614,45 +1757,58 @@ export declare interface InferToolOptions {
1614
1757
  * `samples` requires at least one element (`min: 1`) — an empty array parses to `undefined`,
1615
1758
  * surfaced by the handler as a typed `TOOL` {@link import('./errors.js').ToolboxError}. When
1616
1759
  * `candidates` is present (any array, including empty), the handler compiles a contract from the
1617
- * freshly inferred schema and checks each candidate against it with a STRICT guard (`.is`, no
1618
- * coercion) — the opposite of {@link import('./factories.js').createEndpointTool}'s NORMALIZING
1760
+ * freshly inferred schema and checks each candidate against it with a strict guard (`.is`, no
1761
+ * coercion) — the opposite of {@link import('./factories.js').createEndpointTool}'s normalizing
1619
1762
  * `.parse` enforcement.
1620
1763
  */
1621
- export declare const inferToolShape: ObjectShape<{
1622
- samples: ArrayShape<JSONShape>;
1623
- format: OptionalShape<BooleanShape>;
1624
- enum: OptionalShape<BooleanShape>;
1625
- candidates: OptionalShape<ArrayShape<JSONShape>>;
1764
+ export declare const inferToolShape: ObjectShape< {
1765
+ samples: ArrayShape<JSONShape>;
1766
+ format: OptionalShape<BooleanShape>;
1767
+ enum: OptionalShape<BooleanShape>;
1768
+ candidates: OptionalShape<ArrayShape<JSONShape>>;
1626
1769
  }, false>;
1627
1770
 
1628
1771
  /**
1629
- * Narrow an unknown callable to Toolbox's frozen contextual agent adapter metadata.
1772
+ * Narrows an unknown callable to Toolbox's frozen contextual agent adapter metadata.
1630
1773
  *
1631
1774
  * @param value - The value to inspect
1632
- * @returns Whether it is a frozen {@link AgentFunction} with a frozen valid lineage
1775
+ * @returns True if it is a frozen {@link AgentFunction} with a frozen valid lineage; false otherwise
1633
1776
  */
1634
1777
  export declare function isAgentFunction(value: unknown): value is AgentFunction;
1635
1778
 
1636
- /** Narrow an unknown value to a {@link import('./types.js').ColumnKind}. */
1637
- export declare function isColumnKind(value: unknown): value is ColumnKind;
1779
+ /**
1780
+ * Narrows an unknown value to a {@link ColumnPrimitive}.
1781
+ *
1782
+ * @param value - The value to inspect
1783
+ * @returns True if `value` is `'string'`, `'integer'`, `'number'`, or `'boolean'`; false otherwise
1784
+ */
1785
+ export declare function isColumnPrimitive(value: unknown): value is ColumnPrimitive;
1638
1786
 
1639
- /** Narrow an unknown value to a {@link ColumnSpec} — a valid {@link import('./types.js').ColumnKind} shorthand, or `{ type, optional }` with a valid `type`. */
1787
+ /**
1788
+ * Narrows an unknown value to a {@link ColumnSpec}.
1789
+ *
1790
+ * @param value - The value to inspect
1791
+ * @returns True if `value` is a valid {@link ColumnPrimitive} shorthand or a `{ primitive, optional }` record with a valid `primitive`; false otherwise
1792
+ */
1640
1793
  export declare function isColumnSpec(value: unknown): value is ColumnSpec;
1641
1794
 
1642
1795
  /**
1643
- * Narrow an unknown value to a {@link DatabaseDefinition} — a non-empty `id` + `driver`, a
1796
+ * Narrows an unknown value to a {@link DatabaseDefinition} — a non-empty `id` and `driver`, a
1644
1797
  * `tables` record whose every value is `{ columns: record of valid ColumnSpec }`, plus optional
1645
1798
  * `primary`, `indexes`, and finite `version` schema configuration. The boundary guard a
1646
1799
  * {@link import('./types.js').DefinitionStoreInterface} applies to an untrusted persisted blob
1647
1800
  * before trusting it as a definition (never an `as`).
1801
+ *
1802
+ * @param value - The value to inspect
1803
+ * @returns True if `value` is a complete {@link DatabaseDefinition}; false otherwise
1648
1804
  */
1649
1805
  export declare function isDatabaseDefinition(value: unknown): value is DatabaseDefinition;
1650
1806
 
1651
1807
  /**
1652
- * Type guard narrowing an unknown caught value to an {@link ToolboxError}.
1808
+ * Narrows an unknown caught value to a {@link ToolboxError}.
1653
1809
  *
1654
1810
  * @param value - The value to test (typically a `catch` binding)
1655
- * @returns `true` when `value` is an {@link ToolboxError}
1811
+ * @returns True if `value` is an {@link ToolboxError}; false otherwise
1656
1812
  *
1657
1813
  * @example
1658
1814
  * ```ts
@@ -1668,32 +1824,25 @@ export declare function isDatabaseDefinition(value: unknown): value is DatabaseD
1668
1824
  export declare function isToolboxError(value: unknown): value is ToolboxError;
1669
1825
 
1670
1826
  /**
1671
- * Narrow an unknown value to a valid alternating workflow lineage.
1827
+ * Narrows an unknown value to a valid alternating workflow lineage.
1672
1828
  *
1673
1829
  * @param value - The value to inspect
1674
- * @returns Whether `value` is a unique, nonempty-tagged workflow/agent chain
1830
+ * @returns True if `value` is a unique, nonempty-tagged workflow/agent chain; false otherwise
1675
1831
  */
1676
1832
  export declare function isWorkflowLineage(value: unknown): value is WorkflowLineage;
1677
1833
 
1678
- /** One key value — a string or number; the array form (multiple keys, positional) resolves FIRST per AGENTS §9.2. */
1679
- export declare const keyShape: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1680
-
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
1834
  /**
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
1835
+ * Describes one key value for the database tool and the relation tool — a string or number; the
1836
+ * array form (multiple keys, positional) resolves first, so an array argument is read as many keys
1837
+ * rather than one.
1689
1838
  */
1690
- export declare function lineageOf(lineage?: WorkflowLineage): WorkflowLineage;
1839
+ export declare const keyShape: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
1691
1840
 
1692
- /** Which registered relation manager to address — omitted resolves to the sole registered manager. */
1841
+ /** Describes which registered relation manager to address — omitted resolves to the sole registered manager. */
1693
1842
  export declare const managerShape: OptionalShape<StringShape>;
1694
1843
 
1695
1844
  /**
1696
- * The maximum nesting depth a workflow → agent → workflow chain may reach — the bound
1845
+ * Holds the maximum nesting depth a workflow → agent → workflow chain may reach, `8` — the bound
1697
1846
  * {@link import('./factories.js').createAgentFunction} and
1698
1847
  * {@link import('./factories.js').createWorkflowTool}'s depth/cycle guards enforce.
1699
1848
  *
@@ -1702,29 +1851,32 @@ export declare const managerShape: OptionalShape<StringShape>;
1702
1851
  * workflows is allowed, while a ninth nested workflow is rejected with this package's typed
1703
1852
  * `DEPTH` `ToolboxError`.
1704
1853
  */
1705
- export declare const MAX_WORKFLOW_DEPTH = 8;
1854
+ export declare const MAX_WORKFLOW_CHAIN = 8;
1706
1855
 
1707
1856
  /**
1708
- * The in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
1709
- * {@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}.
1857
+ * Represents the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
1858
+ * {@link DatabaseDefinition}s keyed by database id, the default store
1859
+ * {@link import('../factories.js').createMemoryDefinitionStore} builds. It implements the same
1860
+ * {@link DefinitionStoreInterface} contract as
1861
+ * {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore}: this store copies on
1862
+ * write and on read; the table-backed store narrows an untrusted stored blob and reports
1863
+ * `undefined` for a malformed one.
1712
1864
  *
1713
1865
  * @remarks
1714
- * A plain `Map<string, DatabaseDefinition>` (AGENTS §21 — the definition is already pure,
1715
- * self-contained CONFIG-only JSON, so no encoding is needed for the memory tier). Values are
1716
- * structured-cloned on both write and read, keeping caller mutation outside the store. There is NO
1717
- * idle-TTL and NO eviction: a persisted definition lives until an explicit `delete`. A durable
1718
- * backend (JSON / SQLite / IndexedDB) swaps in through the SAME interface without touching a
1866
+ * A plain `Map<string, DatabaseDefinition>` (the definition is already pure,
1867
+ * self-contained config-only JSON, so no encoding is needed for the memory tier). Values are
1868
+ * structured-cloned on both write and read, keeping caller mutation outside the store. There is no
1869
+ * idle-TTL and no eviction: a persisted definition lives until an explicit `delete`. A durable
1870
+ * backend (JSON / SQLite / IndexedDB) swaps in through the same interface without touching a
1719
1871
  * consumer — its driver-pluggable twin is
1720
1872
  * {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore} (the definition as one
1721
1873
  * opaque JSON column).
1722
1874
  *
1723
1875
  * - **`get` resolves the persisted definition for an id**, or `undefined` if none is stored.
1724
- * - **`set` inserts / replaces under the definition's OWN `id`** (no separate id param).
1876
+ * - **`set` inserts / replaces under the definition's own `id`** (no separate id param).
1725
1877
  * - **`delete` drops a definition by id**; an absent id is a no-op (no throw).
1726
1878
  *
1727
- * The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
1879
+ * The public surface is exactly `get` / `set` / `delete` — no extra members (the method
1728
1880
  * bijection with {@link DefinitionStoreInterface}).
1729
1881
  *
1730
1882
  * @example
@@ -1739,78 +1891,130 @@ export declare const MAX_WORKFLOW_DEPTH = 8;
1739
1891
  */
1740
1892
  export declare class MemoryDefinitionStore implements DefinitionStoreInterface {
1741
1893
  #private;
1894
+ /**
1895
+ * Resolves the persisted definition for `id`, copied out of the backing `Map`.
1896
+ *
1897
+ * @param id - The database id to read
1898
+ * @returns The stored {@link DatabaseDefinition}, or `undefined` when none is stored
1899
+ */
1742
1900
  get(id: string): Promise<DatabaseDefinition | undefined>;
1901
+ /**
1902
+ * Inserts or replaces a definition under its own `id`, copied into the backing `Map`.
1903
+ *
1904
+ * @param definition - The config to persist; its own `id` is the key (no separate id param)
1905
+ * @returns A promise settling after the definition is stored
1906
+ */
1743
1907
  set(definition: DatabaseDefinition): Promise<void>;
1908
+ /**
1909
+ * Drops the definition stored under `id`.
1910
+ *
1911
+ * @param id - The database id to drop; an absent id is a no-op, never a throw
1912
+ * @returns A promise settling after no definition is stored under `id`
1913
+ */
1744
1914
  delete(id: string): Promise<void>;
1745
1915
  }
1746
1916
 
1747
- /** One sort term. */
1748
- export declare const orderShape: ObjectShape<{
1749
- column: StringShape;
1750
- direction: LiteralShape<readonly ["ascending", "descending"]>;
1917
+ /**
1918
+ * Returns the canonical workflow lineage — validated, copied, and frozen.
1919
+ *
1920
+ * @param lineage - The configured chain; omitted means a direct root
1921
+ * @returns An immutable caller-isolated lineage
1922
+ */
1923
+ export declare function normalizeLineage(lineage?: WorkflowLineage): WorkflowLineage;
1924
+
1925
+ /**
1926
+ * Returns the canonical live `@orkestrel/database` {@link QueryInput} for the database tool's
1927
+ * parsed serialized query — each condition's omitted `connector` defaults to `'and'`.
1928
+ *
1929
+ * @remarks
1930
+ * The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
1931
+ * on the last condition (it has nothing to join forward to); the compiled `Condition` a live
1932
+ * `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
1933
+ * `limit` / `offset` pass through unchanged. Pure and total.
1934
+ *
1935
+ * @param query - The parsed query (or `undefined`)
1936
+ * @returns The equivalent live `QueryInput`, or `undefined` when `query` is `undefined`
1937
+ */
1938
+ export declare function normalizeQuery(query: DatabaseQueryInput | undefined): QueryInput | undefined;
1939
+
1940
+ /** Describes one sort term — a `column` to sort by and the `direction` to sort it in. */
1941
+ export declare const orderShape: ObjectShape< {
1942
+ column: StringShape;
1943
+ direction: LiteralShape<readonly ["ascending", "descending"]>;
1751
1944
  }, false>;
1752
1945
 
1753
- /** A draft phase — a `PhaseDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name` and {@link TaskDraft} tasks. */
1946
+ /**
1947
+ * Represents a draft phase — a `PhaseDefinition` (`@orkestrel/workflow`) with optional `id` and
1948
+ * `name` and {@link TaskDraft} tasks.
1949
+ */
1754
1950
  export declare interface PhaseDraft {
1755
1951
  readonly id?: string;
1756
1952
  readonly name?: string;
1757
1953
  readonly description?: string;
1758
1954
  readonly tasks: readonly TaskDraft[];
1759
- /** Max tasks in flight at once (a resource throttle); omitted ⇒ unbounded. */
1955
+ /** Caps the tasks in flight at once (a resource throttle); omitted ⇒ unbounded. */
1760
1956
  readonly concurrency?: number;
1761
- /** The per-phase failure-policy OVERRIDE; omitted ⇒ inherits the workflow `bail`. */
1957
+ /** Holds the per-phase failure-policy override; omitted ⇒ inherits the workflow `bail`. */
1762
1958
  readonly bail?: boolean;
1763
1959
  }
1764
1960
 
1765
1961
  /**
1766
- * The shape of a PHASE in a draft workflow — identical to a strict phase shape EXCEPT `id` and
1767
- * `name` are OPTIONAL, and its tasks are {@link taskDraftShape}s.
1768
- */
1769
- export declare const phaseDraftShape: ObjectShape<{
1770
- id: OptionalShape<StringShape>;
1771
- name: OptionalShape<StringShape>;
1772
- description: OptionalShape<StringShape>;
1773
- tasks: ArrayShape<ObjectShape<{
1774
- id: OptionalShape<StringShape>;
1775
- name: OptionalShape<StringShape>;
1776
- description: OptionalShape<StringShape>;
1777
- run: OptionalShape<StringShape>;
1778
- retries: OptionalShape<NumberShape>;
1779
- timeout: OptionalShape<NumberShape>;
1780
- }, false>>;
1781
- concurrency: OptionalShape<NumberShape>;
1782
- bail: OptionalShape<LiteralShape<readonly [true, false]>>;
1962
+ * Describes the shape of a phase in a draft workflow — identical to a strict phase shape except
1963
+ * that `id` and `name` are optional and each task takes {@link taskDraftShape}.
1964
+ */
1965
+ export declare const phaseDraftShape: ObjectShape< {
1966
+ id: OptionalShape<StringShape>;
1967
+ name: OptionalShape<StringShape>;
1968
+ description: OptionalShape<StringShape>;
1969
+ tasks: ArrayShape<ObjectShape< {
1970
+ id: OptionalShape<StringShape>;
1971
+ name: OptionalShape<StringShape>;
1972
+ description: OptionalShape<StringShape>;
1973
+ behavior: OptionalShape<StringShape>;
1974
+ retries: OptionalShape<NumberShape>;
1975
+ timeout: OptionalShape<NumberShape>;
1976
+ }, false>>;
1977
+ concurrency: OptionalShape<NumberShape>;
1978
+ bail: OptionalShape<LiteralShape<readonly [true, false]>>;
1783
1979
  }, false>;
1784
1980
 
1785
- /** The full form protocol {@link import('./factories.js').createPromptTool} advertises. */
1981
+ /**
1982
+ * Holds the form protocol {@link import('./factories.js').createPromptTool} advertises — the
1983
+ * required `to` and `schema`, how a field declares its control and its rules, and a worked
1984
+ * example.
1985
+ */
1786
1986
  export declare const PROMPT_TOOL_DESCRIPTION: string;
1787
1987
 
1788
1988
  /**
1789
- * The name {@link import('./factories.js').createPromptTool} advertises by default — the key a
1790
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1989
+ * Holds the name {@link import('./factories.js').createPromptTool} advertises by default, `'ask'` —
1990
+ * the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
1791
1991
  */
1792
1992
  export declare const PROMPT_TOOL_NAME = "ask";
1793
1993
 
1794
1994
  /**
1795
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createPromptTool}
1796
- * advertises in place of {@link PROMPT_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
1797
- * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
1798
- * for the full teaching description; the full text stays retrievable via
1799
- * {@link import('./factories.js').createDescribeTool}.
1995
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
1996
+ * {@link import('./factories.js').createPromptTool} advertises in place of
1997
+ * {@link PROMPT_TOOL_DESCRIPTION} — one sentence offering the blocking multi-field ask and pointing
1998
+ * at `describe` for the schema.
1999
+ *
2000
+ * @remarks
2001
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
2002
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
2003
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
1800
2004
  */
1801
2005
  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
2006
 
1803
2007
  /**
1804
- * Options for {@link import('./factories.js').createPromptTool} — the live
2008
+ * Represents the options for {@link import('./factories.js').createPromptTool} — the live
1805
2009
  * {@link TerminalManagerInterface} (`@orkestrel/terminal`) to `ask` through, the terminal name
1806
2010
  * `from`, and the advertised tool overrides.
1807
2011
  *
1808
2012
  * @remarks
1809
2013
  * - `manager` — the terminal manager whose `ask(from, to, form)` the tool's handler calls with a
1810
- * live `@orkestrel/form` form; BLOCKS the calling agent turn until the addressed terminal answers (or the ask
2014
+ * live `@orkestrel/form` form; blocks the calling agent turn until the addressed terminal answers (or the ask
1811
2015
  * rejects — a cycle throws `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
1812
2016
  * {@link import('./errors.js').ToolboxError}; an expired prompt re-surfaces as `EXPIRE`).
1813
- * - `from` — the terminal identity this tool asks AS; the model supplies the `to` target and the
2017
+ * - `from` — the terminal identity this tool asks as; the model supplies the `to` target and the
1814
2018
  * complete form schema per call.
1815
2019
  * - `name` / `description` — advertised tool overrides; default to
1816
2020
  * {@link import('./constants.js').PROMPT_TOOL_NAME} / {@link import('./constants.js').PROMPT_TOOL_DESCRIPTION}.
@@ -1823,139 +2027,87 @@ export declare interface PromptToolOptions {
1823
2027
  }
1824
2028
 
1825
2029
  /**
1826
- * The shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
2030
+ * Describes the shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
1827
2031
  * terminal identity and `schema` carries the complete multi-field form document.
1828
2032
  *
1829
2033
  * @remarks
1830
2034
  * The contract first requires exact JSON. The handler then delegates schema parsing and semantic
1831
2035
  * validation to `@orkestrel/form`'s `parseForm`, so Toolbox does not duplicate the form schema.
1832
2036
  */
1833
- export declare const promptToolShape: ObjectShape<{
1834
- to: StringShape;
1835
- schema: JSONShape;
2037
+ export declare const promptToolShape: ObjectShape< {
2038
+ to: StringShape;
2039
+ schema: JSONShape;
1836
2040
  }, false>;
1837
2041
 
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. */
1867
- export declare const queryShape: ObjectShape<{
1868
- conditions: OptionalShape<ArrayShape<ObjectShape<{
1869
- column: StringShape;
1870
- operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
1871
- values: ArrayShape<JSONShape>;
1872
- connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
1873
- }, false>>>;
1874
- order: OptionalShape<ArrayShape<ObjectShape<{
1875
- column: StringShape;
1876
- direction: LiteralShape<readonly ["ascending", "descending"]>;
1877
- }, false>>>;
1878
- limit: OptionalShape<NumberShape>;
1879
- offset: OptionalShape<NumberShape>;
2042
+ /** Describes the serialized query form — conditions, order, and pagination. */
2043
+ export declare const queryShape: ObjectShape< {
2044
+ conditions: OptionalShape<ArrayShape<ObjectShape< {
2045
+ column: StringShape;
2046
+ operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
2047
+ values: ArrayShape<JSONShape>;
2048
+ connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
2049
+ }, false>>>;
2050
+ order: OptionalShape<ArrayShape<ObjectShape< {
2051
+ column: StringShape;
2052
+ direction: LiteralShape<readonly ["ascending", "descending"]>;
2053
+ }, false>>>;
2054
+ limit: OptionalShape<NumberShape>;
2055
+ offset: OptionalShape<NumberShape>;
1880
2056
  }, false>;
1881
2057
 
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. */
2058
+ /**
2059
+ * Holds the default cap on how many `include` path segments deep a `load` or `find` call may
2060
+ * traverse, `3` — the relation tool's default include-depth ceiling.
2061
+ */
1883
2062
  export declare const RELATION_TOOL_DEPTH = 3;
1884
2063
 
1885
2064
  /**
1886
- * The DESCRIPTION the relation tool advertises — a multi-line guide that teaches a small model
1887
- * the operation list and the flat dot-path `include` syntax.
2065
+ * Holds the description {@link import('./factories.js').createRelationTool} advertises — a
2066
+ * multi-line guide that teaches a small model the operation list and the flat dot-path `include`
2067
+ * syntax.
1888
2068
  *
1889
2069
  * @remarks
1890
- * An include path is a FLAT dot-separated string (`'contacts.account'`), never a nested object —
2070
+ * An include path is a flat dot-separated string (`'contacts.account'`), never a nested object —
1891
2071
  * the same small-model ergonomic lever the other tools in this package use for flat args.
1892
2072
  */
1893
2073
  export declare const RELATION_TOOL_DESCRIPTION: string;
1894
2074
 
1895
- /** The default cap on rows a `find` / `links` call returns when the caller omits `limit` — the relation tool's default row ceiling. */
1896
- export declare const RELATION_TOOL_LIMIT = 1000;
1897
-
1898
2075
  /**
1899
- * The name `createRelationTool` advertises by default — the key a model calls and the
1900
- * `ToolManagerInterface` (`@orkestrel/tool`) registers under.
2076
+ * Holds the default cap on rows a `find` or `links` call returns when the caller omits `limit`,
2077
+ * `1000` — the relation tool's default row ceiling.
1901
2078
  */
1902
- export declare const RELATION_TOOL_NAME = "relation";
2079
+ export declare const RELATION_TOOL_LIMIT = 1000;
1903
2080
 
1904
2081
  /**
1905
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} the relation tool advertises
1906
- * in place of {@link RELATION_TOOL_DESCRIPTION}.
2082
+ * Holds the name {@link import('./factories.js').createRelationTool} advertises by default,
2083
+ * `'relation'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
2084
+ * under.
1907
2085
  */
1908
- 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
-
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]>;
2086
+ export declare const RELATION_TOOL_NAME = "relation";
1912
2087
 
1913
2088
  /**
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.
2089
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
2090
+ * {@link import('./factories.js').createRelationTool} advertises in place of
2091
+ * {@link RELATION_TOOL_DESCRIPTION} — one sentence offering the `operation`-keyed relationship
2092
+ * traversal and pointing at `describe` for the include-path syntax.
1917
2093
  *
1918
2094
  * @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}
2095
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
2096
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
2097
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
1926
2098
  */
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;
2099
+ 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.";
1949
2100
 
1950
2101
  /**
1951
- * Options for {@link import('./factories.js').createRelationTool} — SRC-3 (the final unit) of
1952
- * the 3-unit database / relation spine.
2102
+ * Represents the options for {@link import('./factories.js').createRelationTool} — the required
2103
+ * live `RelationManagerInterface` registry a call addresses, the row cap, and the `include` depth
2104
+ * cap.
1953
2105
  *
1954
2106
  * @remarks
1955
2107
  * - `managers` — the live `RelationManagerInterface` (`@orkestrel/relation`) registry a call's
1956
- * optional `manager` field addresses by name; REQUIRED (unlike the database tool's lazily
2108
+ * optional `manager` field addresses by name; required (unlike the database tool's lazily
1957
2109
  * resolved handles, a relation manager's relations are declared up front and cannot be minted
1958
- * on demand from a tool call). A call that omits `manager` resolves to the SOLE registered
2110
+ * on demand from a tool call). A call that omits `manager` resolves to the sole registered
1959
2111
  * manager when exactly one is registered, else throws a typed `TOOL`
1960
2112
  * {@link import('./errors.js').ToolboxError} naming the registered manager keys.
1961
2113
  * - `limit` — the row cap `'find'` / `'links'` enforce when a call's `limit` is omitted or
@@ -1975,141 +2127,222 @@ export declare interface RelationToolOptions {
1975
2127
  }
1976
2128
 
1977
2129
  /**
1978
- * The shape of {@link import('./factories.js').createRelationTool}'s call arguments —
1979
- * discriminated by `operation` into the 5 relation operations (`'load'` / `'find'` / `'link'` /
1980
- * `'unlink'` / `'links'`).
2130
+ * Describes the shape of {@link import('./factories.js').createRelationTool}'s call arguments —
2131
+ * discriminated by `operation` into the relation operations `'load'`, `'find'`, `'link'`,
2132
+ * `'unlink'`, and `'links'`.
1981
2133
  *
1982
2134
  * @remarks
1983
2135
  * `'load'` fetches one or more rows (positional key/array) with `include` attached. `'find'`
1984
2136
  * fetches rows (pagination / sort only) with `include` attached. `'link'` / `'unlink'` write /
1985
2137
  * remove a `through` junction row; `'links'` lists a `through` relation's linked keys.
1986
2138
  */
1987
- export declare const relationToolShape: UnionShape<readonly [ ObjectShape<{
1988
- operation: LiteralShape<readonly ["load"]>;
1989
- manager: OptionalShape<StringShape>;
1990
- model: StringShape;
1991
- key: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
1992
- include: OptionalShape<ArrayShape<StringShape>>;
1993
- }, false>, ObjectShape<{
1994
- operation: LiteralShape<readonly ["find"]>;
1995
- manager: OptionalShape<StringShape>;
1996
- model: StringShape;
1997
- include: OptionalShape<ArrayShape<StringShape>>;
1998
- limit: OptionalShape<NumberShape>;
1999
- offset: OptionalShape<NumberShape>;
2000
- sort: OptionalShape<StringShape>;
2001
- direction: OptionalShape<LiteralShape<readonly ["ascending", "descending"]>>;
2002
- }, false>, ObjectShape<{
2003
- operation: LiteralShape<readonly ["link"]>;
2004
- manager: OptionalShape<StringShape>;
2005
- model: StringShape;
2006
- key: UnionShape<readonly [ StringShape, NumberShape]>;
2007
- relation: StringShape;
2008
- target: UnionShape<readonly [ StringShape, NumberShape]>;
2009
- }, false>, ObjectShape<{
2010
- operation: LiteralShape<readonly ["unlink"]>;
2011
- manager: OptionalShape<StringShape>;
2012
- model: StringShape;
2013
- key: UnionShape<readonly [ StringShape, NumberShape]>;
2014
- relation: StringShape;
2015
- target: UnionShape<readonly [ StringShape, NumberShape]>;
2016
- }, false>, ObjectShape<{
2017
- operation: LiteralShape<readonly ["links"]>;
2018
- manager: OptionalShape<StringShape>;
2019
- model: StringShape;
2020
- key: UnionShape<readonly [ StringShape, NumberShape]>;
2021
- relation: StringShape;
2139
+ export declare const relationToolShape: UnionShape<readonly [ObjectShape< {
2140
+ operation: LiteralShape<readonly ["load"]>;
2141
+ manager: OptionalShape<StringShape>;
2142
+ model: StringShape;
2143
+ key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
2144
+ include: OptionalShape<ArrayShape<StringShape>>;
2145
+ }, false>, ObjectShape< {
2146
+ operation: LiteralShape<readonly ["find"]>;
2147
+ manager: OptionalShape<StringShape>;
2148
+ model: StringShape;
2149
+ include: OptionalShape<ArrayShape<StringShape>>;
2150
+ limit: OptionalShape<NumberShape>;
2151
+ offset: OptionalShape<NumberShape>;
2152
+ sort: OptionalShape<StringShape>;
2153
+ direction: OptionalShape<LiteralShape<readonly ["ascending", "descending"]>>;
2154
+ }, false>, ObjectShape< {
2155
+ operation: LiteralShape<readonly ["link"]>;
2156
+ manager: OptionalShape<StringShape>;
2157
+ model: StringShape;
2158
+ key: UnionShape<readonly [StringShape, NumberShape]>;
2159
+ relation: StringShape;
2160
+ target: UnionShape<readonly [StringShape, NumberShape]>;
2161
+ }, false>, ObjectShape< {
2162
+ operation: LiteralShape<readonly ["unlink"]>;
2163
+ manager: OptionalShape<StringShape>;
2164
+ model: StringShape;
2165
+ key: UnionShape<readonly [StringShape, NumberShape]>;
2166
+ relation: StringShape;
2167
+ target: UnionShape<readonly [StringShape, NumberShape]>;
2168
+ }, false>, ObjectShape< {
2169
+ operation: LiteralShape<readonly ["links"]>;
2170
+ manager: OptionalShape<StringShape>;
2171
+ model: StringShape;
2172
+ key: UnionShape<readonly [StringShape, NumberShape]>;
2173
+ relation: StringShape;
2022
2174
  }, false>]>;
2023
2175
 
2024
- /** A loose row — a flat object of column name to JSON value; the array form (multiple rows) resolves FIRST per AGENTS §9.2. */
2176
+ /**
2177
+ * Picks the effective row limit a tool reads with — the requested count when it sits inside the
2178
+ * cap, the cap when it exceeds it, and `0` when either falls below zero.
2179
+ *
2180
+ * @remarks
2181
+ * The one place the database tool's `'records'` clamp ({@link clampQuery}) and the relation tool's
2182
+ * `'find'` / `'links'` truncation both take their ceiling from, so a negative construction-time
2183
+ * option can never reach a slice. Pure and total.
2184
+ *
2185
+ * @example
2186
+ * ```ts
2187
+ * import { resolveLimit } from '@src/core'
2188
+ *
2189
+ * resolveLimit(undefined, 100) // 100 — an omitted request takes the cap
2190
+ * resolveLimit(500, 100) // 100 — a request over the cap is clamped down
2191
+ * resolveLimit(-1, 100) // 0 — a negative request floors at zero
2192
+ * ```
2193
+ *
2194
+ * @param requested - The caller's requested row count (or `undefined`)
2195
+ * @param cap - The row-count ceiling
2196
+ * @returns The effective row limit, never below `0` and never above `cap`
2197
+ */
2198
+ export declare function resolveLimit(requested: number | undefined, cap: number): number;
2199
+
2200
+ /**
2201
+ * Resolves which registered {@link RelationManagerInterface} a relation-tool call addresses — the
2202
+ * pure manager-resolution leaf {@link import('./factories.js').createRelationTool} calls on
2203
+ * every operation.
2204
+ *
2205
+ * @remarks
2206
+ * An explicit `name` must match a key of `managers` (a miss throws a typed `TOOL`
2207
+ * {@link ToolboxError} naming the registered managers). An omitted `name` resolves to the sole
2208
+ * registered manager when exactly one is registered, else throws the same typed error.
2209
+ *
2210
+ * @param managers - The tool's registered `RelationManagerInterface` map
2211
+ * @param name - The call's optional `manager` field
2212
+ * @returns The resolved {@link RelationManagerInterface}
2213
+ */
2214
+ export declare function resolveRelationManager(managers: Readonly<Record<string, RelationManagerInterface>>, name: string | undefined): RelationManagerInterface;
2215
+
2216
+ /**
2217
+ * Resolves a `model` name against a live {@link RelationManagerInterface} — the pure model-lookup
2218
+ * leaf {@link import('./factories.js').createRelationTool} calls on every operation, mirroring
2219
+ * {@link resolveRelationManager}'s guard shape.
2220
+ *
2221
+ * @param manager - The resolved {@link RelationManagerInterface}
2222
+ * @param name - The call's `model` field
2223
+ * @returns The model's {@link ModelInterface}
2224
+ */
2225
+ export declare function resolveRelationModel(manager: RelationManagerInterface, name: string): ModelInterface;
2226
+
2227
+ /** Describes a loose row — a flat object of column name to JSON value. */
2025
2228
  export declare const rowShape: ObjectShape<Record<never, never>, JSONShape>;
2026
2229
 
2027
- /** One or many loose rows — the array form resolves FIRST per AGENTS §9.2. */
2028
- export declare const rowsShape: UnionShape<readonly [ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
2230
+ /**
2231
+ * Describes one or many loose rows — the array form resolves first, so an array argument is read as
2232
+ * many rows rather than one.
2233
+ */
2234
+ export declare const rowsShape: UnionShape<readonly [ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
2029
2235
 
2030
- /** A single row key (not an array) — used by `'link'` / `'unlink'` / `'links'`, which address exactly one owning row. */
2031
- export declare const singleKeyShape: UnionShape<readonly [ StringShape, NumberShape]>;
2236
+ /** Describes a single row key (not an array) — used by `'link'` / `'unlink'` / `'links'`, which address exactly one owning row. */
2237
+ export declare const singleKeyShape: UnionShape<readonly [StringShape, NumberShape]>;
2032
2238
 
2033
2239
  /**
2034
- * The shape of ONE flat step — `{ name }` — the building block of {@link workflowStepsShape}.
2240
+ * Describes the shape of one flat step — `{ name }` — the building block of
2241
+ * {@link workflowStepsShape}.
2035
2242
  *
2036
2243
  * @remarks
2037
- * `name` is the REGISTERED behavior name the step runs (it becomes the task's `run`). The tool
2244
+ * `name` is the registered behavior name the step runs (it becomes the task's `behavior`). The tool
2038
2245
  * expands each step into a one-task phase, in order ({@link import('./helpers.js').expandSteps}).
2039
2246
  */
2040
- export declare const stepShape: ObjectShape<{
2041
- name: StringShape;
2247
+ export declare const stepShape: ObjectShape< {
2248
+ name: StringShape;
2042
2249
  }, false>;
2043
2250
 
2044
2251
  /**
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}
2252
+ * Builds the plain success summary {@link import('./factories.js').createWorkflowTool} returns on a
2253
+ * completed run — the universal tool-handler contract: return a plain value on success, appearing
2254
+ * identically over both the agent loop and MCP.
2255
+ *
2256
+ * @remarks
2257
+ * The summary is lean: the workflow's terminal `status`, settled-task count, and exact optional
2258
+ * native persistence outcome. It carries no synthetic `id` / `name`: a tool handler has no call
2259
+ * id; the `ToolManagerInterface` (`@orkestrel/tool`) supplies the canonical envelope's identity.
2260
+ *
2261
+ * @param result - The terminal `WorkflowResult` (`@orkestrel/workflow`) the run produced
2262
+ * @returns The plain success summary — `{ status, count, durable?, fault? }`
2263
+ */
2264
+ export declare function summarizeWorkflow(result: WorkflowResult): WorkflowToolResult;
2265
+
2266
+ /**
2267
+ * Represents a database's table layout — one entry per table, each a flat map of column name to
2268
+ * {@link ColumnSpec}. The small-model-facing DSL {@link import('./compilers.js').expandTables}
2047
2269
  * compiles into an `@orkestrel/database` `TableMap`.
2048
2270
  */
2049
2271
  export declare type TableSpec = Readonly<Record<string, Readonly<{
2050
2272
  columns: Readonly<Record<string, ColumnSpec>>;
2051
2273
  }>>>;
2052
2274
 
2053
- /** A {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
2054
- export declare const tableSpecShape: ObjectShape<Record<never, never>, ObjectShape<{
2055
- columns: ObjectShape<Record<never, never>, UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
2056
- type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
2057
- optional: OptionalShape<BooleanShape>;
2058
- }, false>]>>;
2275
+ /** Describes a {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
2276
+ export declare const tableSpecShape: ObjectShape<Record<never, never>, ObjectShape< {
2277
+ columns: ObjectShape<Record<never, never>, UnionShape<readonly [LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape< {
2278
+ primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
2279
+ optional: OptionalShape<BooleanShape>;
2280
+ }, false>]>>;
2059
2281
  }, false>>;
2060
2282
 
2061
2283
  /**
2062
- * A draft task — a `TaskDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`.
2284
+ * Returns the ancestry identifier of an agent in a run chain — `agent:<name>`.
2285
+ *
2286
+ * @remarks
2287
+ * The agent counterpart of {@link tagWorkflow}: {@link import('./factories.js').createAgentFunction}
2288
+ * / {@link import('./factories.js').createWorkflowTool} guard against re-entering an agent or
2289
+ * workflow already in the chain (this package's typed `DEPTH` `ToolboxError`). The
2290
+ * `agent:` namespace keeps it distinct from a same-string workflow id.
2291
+ *
2292
+ * @param name - The agent's identifier / registry name
2293
+ * @returns The namespaced ancestry tag (`agent:<name>`)
2294
+ */
2295
+ export declare function tagAgent(name: string): string;
2296
+
2297
+ /**
2298
+ * Returns the ancestry identifier of a workflow in a run chain — `workflow:<id>`.
2299
+ *
2300
+ * @remarks
2301
+ * Namespacing keeps a workflow id and a {@link tagAgent} agent name in one set without
2302
+ * collision, so re-entering a workflow or an agent already in the chain is a single `includes`
2303
+ * check.
2304
+ *
2305
+ * @param id - The workflow definition's `id`
2306
+ * @returns The namespaced ancestry tag (`workflow:<id>`)
2307
+ */
2308
+ export declare function tagWorkflow(id: string): string;
2309
+
2310
+ /**
2311
+ * Represents a draft task — a `TaskDefinition` (`@orkestrel/workflow`) with optional `id` and
2312
+ * `name`.
2063
2313
  *
2064
2314
  * @remarks
2065
2315
  * The tool synthesizes a missing `id` positionally and defaults a missing `name` to its `id`
2066
- * ({@link import('./helpers.js').completeDraft}). A PROVIDED `id` / `name` is preserved verbatim
2316
+ * ({@link import('./helpers.js').completeDraft}). A provided `id` / `name` is preserved verbatim
2067
2317
  * (and must be non-empty — the draft contract's `minLength: 1`).
2068
2318
  */
2069
2319
  export declare interface TaskDraft {
2070
2320
  readonly id?: string;
2071
2321
  readonly name?: string;
2072
2322
  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. */
2323
+ /** Holds the registry key resolved against a workflow's functions registry at construction; omitted ⇒ a deliberate JSON `null` no-op. */
2324
+ readonly behavior?: string;
2325
+ /** Holds the extra attempts after the first on failure (a non-negative integer); persisted with the workflow. */
2076
2326
  readonly retries?: number;
2077
- /** The per-attempt deadline in milliseconds (`0..MAX_TIMER_MS`); persisted with the workflow. */
2327
+ /** Holds the per-attempt deadline in milliseconds (`0..MAX_TIMER_MS`); persisted with the workflow. */
2078
2328
  readonly timeout?: number;
2079
2329
  }
2080
2330
 
2081
2331
  /**
2082
- * The shape of a {@link import('./types.js').TaskDraft} — identical to a strict task shape
2083
- * EXCEPT `id` and `name` are OPTIONAL.
2332
+ * Describes the shape of a {@link import('./types.js').TaskDraft} — identical to a strict task
2333
+ * shape except that `id` and `name` are optional.
2084
2334
  */
2085
- export declare const taskDraftShape: ObjectShape<{
2086
- id: OptionalShape<StringShape>;
2087
- name: OptionalShape<StringShape>;
2088
- description: OptionalShape<StringShape>;
2089
- run: OptionalShape<StringShape>;
2090
- retries: OptionalShape<NumberShape>;
2091
- timeout: OptionalShape<NumberShape>;
2335
+ export declare const taskDraftShape: ObjectShape< {
2336
+ id: OptionalShape<StringShape>;
2337
+ name: OptionalShape<StringShape>;
2338
+ description: OptionalShape<StringShape>;
2339
+ behavior: OptionalShape<StringShape>;
2340
+ retries: OptionalShape<NumberShape>;
2341
+ timeout: OptionalShape<NumberShape>;
2092
2342
  }, false>;
2093
2343
 
2094
2344
  /**
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`),
2345
+ * Represents a package-owned tool-call failure: malformed input or unresolved configuration (`TOOL`),
2113
2346
  * delegation depth/cycle rejection (`DEPTH`), prompt failure (`DEADLOCK` / `EXPIRE` / `ANSWER`),
2114
2347
  * or a translated upstream database/relation failure (`DATABASE` / `RELATION`).
2115
2348
  *
@@ -2138,9 +2371,8 @@ export declare class ToolboxError extends Error {
2138
2371
  }
2139
2372
 
2140
2373
  /**
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).
2374
+ * Represents the machine-readable code a thrown {@link import('./errors.js').ToolboxError} carries — a
2375
+ * thrown, typed, code-bearing error, never a `{ error }` return.
2144
2376
  *
2145
2377
  * @remarks
2146
2378
  * `TOOL` — malformed calls and package-owned resolution or configuration failures, including
@@ -2163,68 +2395,72 @@ export declare class ToolboxError extends Error {
2163
2395
  export declare type ToolboxErrorCode = 'TOOL' | 'DEPTH' | 'DEADLOCK' | 'EXPIRE' | 'ANSWER' | 'DATABASE' | 'RELATION';
2164
2396
 
2165
2397
  /**
2166
- * The description {@link import('./factories.js').createWorkflowTool} advertises — the flat
2398
+ * Holds the description {@link import('./factories.js').createWorkflowTool} advertises — the flat
2167
2399
  * authoring form, its worked example, and the advanced nested definition form.
2168
2400
  */
2169
2401
  export declare const WORKFLOW_TOOL_DESCRIPTION: string;
2170
2402
 
2171
2403
  /**
2172
- * A complete FLAT authoring example — the PRIMARY way a small model authors a workflow through
2173
- * {@link import('./factories.js').createWorkflowTool}: `{ name, steps: [{ name }] }`.
2404
+ * Holds a complete flat authoring example — the primary way a small model authors a workflow
2405
+ * through {@link import('./factories.js').createWorkflowTool}: `{ name, steps: [{ name }] }`.
2174
2406
  *
2175
2407
  * @remarks
2176
2408
  * Each step becomes a one-task phase, in
2177
- * 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
2409
+ * order; a step's `name` is a registered behavior name (not a label) — the registry key its
2410
+ * task's `behavior` resolves against. The tool expands this
2179
2411
  * ({@link import('./helpers.js').expandSteps}) into a valid `WorkflowDefinition`
2180
- * (`@orkestrel/workflow`). It is embedded VERBATIM in {@link WORKFLOW_TOOL_DESCRIPTION}.
2412
+ * (`@orkestrel/workflow`). It is embedded verbatim in {@link WORKFLOW_TOOL_DESCRIPTION}.
2181
2413
  */
2182
2414
  export declare const WORKFLOW_TOOL_FLAT_EXAMPLE: WorkflowSteps;
2183
2415
 
2184
2416
  /**
2185
- * The name {@link import('./factories.js').createWorkflowTool} advertises by default — the key a
2186
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under, and the name
2187
- * {@link import('./factories.js').createAgentFunction} binds the depth/cycle-aware workflow tool
2188
- * under onto a wrapped agent's `context.tools`.
2417
+ * Holds the name {@link import('./factories.js').createWorkflowTool} advertises by default,
2418
+ * `'workflow'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
2419
+ * under, and the name {@link import('./factories.js').createAgentFunction} binds the
2420
+ * depth/cycle-aware workflow tool under onto a wrapped agent's `context.tools`.
2189
2421
  *
2190
2422
  * @remarks
2191
2423
  * The propagation seam's well-known key: when
2192
2424
  * `createAgentFunction`'s `runner` option is supplied, it adds a `createWorkflowTool`-built tool
2193
- * under this name to the agent's `context.tools`, so it can author + run a NESTED workflow
2194
- * (bounded by {@link MAX_WORKFLOW_DEPTH}).
2425
+ * under this name to the agent's `context.tools`, so it can author and run a nested workflow
2426
+ * (bounded by {@link MAX_WORKFLOW_CHAIN}).
2195
2427
  */
2196
2428
  export declare const WORKFLOW_TOOL_NAME = "workflow";
2197
2429
 
2198
2430
  /**
2199
- * A minimal NESTED authoring example — the ADVANCED escape-hatch form a model may use instead of
2200
- * the flat shape: a full `WorkflowDefinition` (`@orkestrel/workflow`).
2431
+ * Holds a minimal nested authoring example — the advanced escape-hatch form a model can use instead
2432
+ * of the flat shape: a full `WorkflowDefinition` (`@orkestrel/workflow`).
2201
2433
  *
2202
2434
  * @remarks
2203
- * The full four-level form, documented in
2204
- * {@link WORKFLOW_TOOL_DESCRIPTION} as the advanced alternative. It is embedded VERBATIM.
2435
+ * The full nested form, documented in
2436
+ * {@link WORKFLOW_TOOL_DESCRIPTION} as the advanced alternative. It is embedded verbatim.
2205
2437
  */
2206
2438
  export declare const WORKFLOW_TOOL_NESTED_EXAMPLE: WorkflowDefinition;
2207
2439
 
2208
2440
  /**
2209
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createWorkflowTool}
2210
- * advertises in place of {@link WORKFLOW_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
2211
- * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
2212
- * for the full teaching description; the full text stays retrievable via
2213
- * {@link import('./factories.js').createDescribeTool}.
2441
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
2442
+ * {@link import('./factories.js').createWorkflowTool} advertises in place of
2443
+ * {@link WORKFLOW_TOOL_DESCRIPTION} — one sentence offering multi-phase authoring and pointing at
2444
+ * `describe` for the authoring schema and its examples.
2445
+ *
2446
+ * @remarks
2447
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
2448
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
2449
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
2214
2450
  */
2215
2451
  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
2452
 
2217
- /** Raw live agents keyed by the workflow function names that invoke them. */
2453
+ /** Represents raw live agents keyed by the workflow function names that invoke them. */
2218
2454
  export declare type WorkflowAgents = Readonly<Record<string, AgentInterface>>;
2219
2455
 
2220
2456
  /**
2221
- * A draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`
2222
- * at all three levels (workflow / phase / task).
2457
+ * Represents a draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with optional `id`
2458
+ * and `name` at the workflow, phase, and task levels.
2223
2459
  *
2224
2460
  * @remarks
2225
2461
  * The lenient authoring form {@link import('./factories.js').createWorkflowDraftContract}
2226
2462
  * validates and {@link import('./helpers.js').completeDraft} completes into a strict
2227
- * `WorkflowDefinition`. `run` stays optional (a plain name string); the `bail` policy carries
2463
+ * `WorkflowDefinition`. `behavior` stays optional (a plain name string); the `bail` policy carries
2228
2464
  * over.
2229
2465
  */
2230
2466
  export declare interface WorkflowDraft {
@@ -2232,69 +2468,72 @@ export declare interface WorkflowDraft {
2232
2468
  readonly name?: string;
2233
2469
  readonly description?: string;
2234
2470
  readonly phases: readonly PhaseDraft[];
2235
- /** Failure policy: `false` (default) continues gracefully, `true` halts on the first failure. */
2471
+ /** Holds the failure policy: `false` (default) continues gracefully, `true` halts on the first failure. */
2236
2472
  readonly bail?: boolean;
2237
2473
  }
2238
2474
 
2239
2475
  /**
2240
- * The shape of a DRAFT workflow — identical to a strict workflow shape EXCEPT `id` and `name`
2241
- * are OPTIONAL at all three levels (workflow / phase / task), so a small model can omit the six
2242
- * identity strings and let the tool synthesize them positionally.
2476
+ * Describes the shape of a draft workflow — identical to a strict workflow shape except that `id`
2477
+ * and `name` are optional at the workflow, phase, and task levels, so a small model can omit every
2478
+ * identity string and let the tool synthesize them positionally.
2243
2479
  *
2244
2480
  * @remarks
2245
2481
  * 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
2482
+ * `behavior` stays optional like the strict form; omission is the deliberate JSON `null` no-op. A
2247
2483
  * provided `id` / `name` still has `minLength: 1` (so
2248
- * an explicitly-empty `id: ''` is REJECTED, not auto-filled). After
2484
+ * an explicitly-empty `id: ''` is rejected, not auto-filled). After
2249
2485
  * {@link import('./helpers.js').completeDraft} fills the missing ids/names, the result is
2250
- * validated against the STRICT `createWorkflowContract` (`@orkestrel/workflow`) gate before
2486
+ * validated against the strict `createWorkflowContract` (`@orkestrel/workflow`) gate before
2251
2487
  * running.
2252
2488
  */
2253
- export declare const workflowDraftShape: ObjectShape<{
2254
- id: OptionalShape<StringShape>;
2255
- name: OptionalShape<StringShape>;
2256
- description: OptionalShape<StringShape>;
2257
- phases: ArrayShape<ObjectShape<{
2258
- id: OptionalShape<StringShape>;
2259
- name: OptionalShape<StringShape>;
2260
- description: OptionalShape<StringShape>;
2261
- tasks: ArrayShape<ObjectShape<{
2262
- id: OptionalShape<StringShape>;
2263
- name: OptionalShape<StringShape>;
2264
- description: OptionalShape<StringShape>;
2265
- run: OptionalShape<StringShape>;
2266
- retries: OptionalShape<NumberShape>;
2267
- timeout: OptionalShape<NumberShape>;
2268
- }, false>>;
2269
- concurrency: OptionalShape<NumberShape>;
2270
- bail: OptionalShape<LiteralShape<readonly [true, false]>>;
2271
- }, false>>;
2272
- bail: OptionalShape<LiteralShape<readonly [true, false]>>;
2489
+ export declare const workflowDraftShape: ObjectShape< {
2490
+ id: OptionalShape<StringShape>;
2491
+ name: OptionalShape<StringShape>;
2492
+ description: OptionalShape<StringShape>;
2493
+ phases: ArrayShape<ObjectShape< {
2494
+ id: OptionalShape<StringShape>;
2495
+ name: OptionalShape<StringShape>;
2496
+ description: OptionalShape<StringShape>;
2497
+ tasks: ArrayShape<ObjectShape< {
2498
+ id: OptionalShape<StringShape>;
2499
+ name: OptionalShape<StringShape>;
2500
+ description: OptionalShape<StringShape>;
2501
+ behavior: OptionalShape<StringShape>;
2502
+ retries: OptionalShape<NumberShape>;
2503
+ timeout: OptionalShape<NumberShape>;
2504
+ }, false>>;
2505
+ concurrency: OptionalShape<NumberShape>;
2506
+ bail: OptionalShape<LiteralShape<readonly [true, false]>>;
2507
+ }, false>>;
2508
+ bail: OptionalShape<LiteralShape<readonly [true, false]>>;
2273
2509
  }, false>;
2274
2510
 
2275
- /** One immutable workflow/agent call chain, beginning with a workflow tag. */
2511
+ /**
2512
+ * Represents one immutable workflow/agent call chain — strictly alternating tags, each unique,
2513
+ * beginning with a workflow tag.
2514
+ */
2276
2515
  export declare type WorkflowLineage = readonly string[];
2277
2516
 
2278
2517
  /**
2279
- * One flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
2518
+ * Represents one flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
2280
2519
  *
2281
2520
  * @remarks
2282
- * `name` is the REGISTERED behavior name the step runs (it becomes the task's `run`, NOT a
2521
+ * `name` is the registered behavior name the step runs (it becomes the task's `behavior`, not a
2283
2522
  * human label) — resolved against a workflow-level functions registry at construction.
2284
2523
  */
2285
2524
  export declare interface WorkflowStep {
2286
- /** The registered behavior name this step runs (becomes the task's `run`). */
2525
+ /** Names the registered behavior this step runs (becomes the task's `behavior`). */
2287
2526
  readonly name: string;
2288
2527
  }
2289
2528
 
2290
2529
  /**
2291
- * The FLAT authoring blob {@link import('./factories.js').createWorkflowTool} advertises —
2292
- * `{ name?, steps }` — the simplest surface a small model can fill.
2530
+ * Represents the flat authoring blob {@link import('./factories.js').createWorkflowTool} advertises
2531
+ * — `{ name?, steps }` — the simplest surface a small model can fill.
2293
2532
  *
2294
2533
  * @remarks
2295
2534
  * Each {@link WorkflowStep} becomes a one-task phase, in order
2296
2535
  * ({@link import('./helpers.js').expandSteps}); `name` is the optional workflow name and
2297
- * deterministic persistence id (both default to `wf` when omitted).
2536
+ * deterministic persistence id (each defaults to `wf` when omitted).
2298
2537
  */
2299
2538
  export declare interface WorkflowSteps {
2300
2539
  readonly name?: string;
@@ -2302,40 +2541,28 @@ export declare interface WorkflowSteps {
2302
2541
  }
2303
2542
 
2304
2543
  /**
2305
- * The FLAT authoring shape {@link import('./factories.js').createWorkflowTool} advertises as its
2306
- * `parameters` — the simplest surface a small model can fill: `{ name?, steps: [{ name }] }`.
2544
+ * Describes the flat authoring shape {@link import('./factories.js').createWorkflowTool} advertises
2545
+ * as its `parameters` — the simplest surface a small model can fill:
2546
+ * `{ name?, steps: [{ name }] }`.
2307
2547
  *
2308
2548
  * @remarks
2309
2549
  * A deliberately-reduced surface: a flat ordered list of steps, each a `{ name }`. The tool
2310
- * EXPANDS it ({@link import('./helpers.js').expandSteps}) into a full
2550
+ * expands it ({@link import('./helpers.js').expandSteps}) into a full
2311
2551
  * {@link import('./types.js').WorkflowDefinition} — one one-task phase per step, in order —
2312
- * then validates against the STRICT `createWorkflowContract` (`@orkestrel/workflow`) gate. The
2313
- * full nested form is STILL accepted by the tool (it branches on the args' shape) and is
2314
- * documented as the advanced escape-hatch in the tool's description — but THIS is what
2552
+ * then validates against the strict `createWorkflowContract` (`@orkestrel/workflow`) gate. The
2553
+ * full nested form is still accepted by the tool (it branches on the args' shape) and is
2554
+ * documented as the advanced escape-hatch in the tool's description — but this is what
2315
2555
  * `parameters` advertises.
2316
2556
  */
2317
- export declare const workflowStepsShape: ObjectShape<{
2318
- name: OptionalShape<StringShape>;
2319
- steps: ArrayShape<ObjectShape<{
2320
- name: StringShape;
2321
- }, false>>;
2557
+ export declare const workflowStepsShape: ObjectShape< {
2558
+ name: OptionalShape<StringShape>;
2559
+ steps: ArrayShape<ObjectShape< {
2560
+ name: StringShape;
2561
+ }, false>>;
2322
2562
  }, false>;
2323
2563
 
2324
2564
  /**
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
2565
+ * Represents the options for {@link import('./factories.js').createWorkflowTool} and
2339
2566
  * {@link import('./factories.js').createWorkflowFunctions} — lineage-aware composition of opaque
2340
2567
  * leaves, raw agents, and native workflow persistence.
2341
2568
  *
@@ -2348,40 +2575,25 @@ export declare function workflowTag(id: string): string;
2348
2575
  */
2349
2576
  export declare interface WorkflowToolOptions {
2350
2577
  readonly lineage?: WorkflowLineage;
2351
- readonly functions?: WorkflowFunctions;
2578
+ readonly functions?: WorkflowRegistry;
2352
2579
  readonly agents?: WorkflowAgents;
2353
2580
  readonly store?: WorkflowStoreInterface;
2354
2581
  }
2355
2582
 
2356
- /** The JSON-safe run summary returned by {@link import('./factories.js').createWorkflowTool}. */
2583
+ /** Represents the JSON-safe run summary returned by {@link import('./factories.js').createWorkflowTool}. */
2357
2584
  export declare interface WorkflowToolResult {
2358
- /** The workflow's native terminal status. */
2359
- readonly status: WorkflowStatus;
2360
- /** The number of settled task results. */
2585
+ /** Holds the run's terminal {@link LifecycleStatus}. */
2586
+ readonly status: LifecycleStatus;
2587
+ /** Holds the tally of settled task results. */
2361
2588
  readonly count: number;
2362
- /** Whether the native runner stored its final state; omitted when no store was supplied. */
2589
+ /** Reports whether the native runner stored its final state; omitted when no store was supplied. */
2363
2590
  readonly durable?: boolean;
2364
- /** The native runner's first persistence failure; omitted when none occurred. */
2591
+ /** Holds the native runner's first persistence failure; omitted when none occurred. */
2365
2592
  readonly fault?: WorkflowFault;
2366
2593
  }
2367
2594
 
2368
2595
  /**
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
2596
+ * Holds the description {@link import('./factories.js').createWorkspaceTool} advertises — the
2385
2597
  * operation-keyed workspace protocol, all supported operations, and worked examples.
2386
2598
  *
2387
2599
  * @remarks
@@ -2391,8 +2603,8 @@ export declare function workflowToolSummary(result: WorkflowResult): WorkflowToo
2391
2603
  export declare const WORKSPACE_TOOL_DESCRIPTION: string;
2392
2604
 
2393
2605
  /**
2394
- * A valid {@link import('./types.js').WorkspaceOperation} object — the canonical example embedded
2395
- * VERBATIM in {@link WORKSPACE_TOOL_DESCRIPTION}.
2606
+ * Holds a valid {@link import('./types.js').WorkspaceOperation} object — the canonical example
2607
+ * embedded verbatim in {@link WORKSPACE_TOOL_DESCRIPTION}.
2396
2608
  *
2397
2609
  * @remarks
2398
2610
  * A `'write'` op (the most common authoring
@@ -2402,56 +2614,61 @@ export declare const WORKSPACE_TOOL_DESCRIPTION: string;
2402
2614
  export declare const WORKSPACE_TOOL_EXAMPLE: WorkspaceOperation;
2403
2615
 
2404
2616
  /**
2405
- * The name {@link import('./factories.js').createWorkspaceTool} advertises by default — the key a
2406
- * model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
2617
+ * Holds the name {@link import('./factories.js').createWorkspaceTool} advertises by default,
2618
+ * `'workspace'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`)
2619
+ * registers under.
2407
2620
  */
2408
2621
  export declare const WORKSPACE_TOOL_NAME = "workspace";
2409
2622
 
2410
2623
  /**
2411
- * The lean {@link import('@orkestrel/tool').ToolInterface.summary} {@link import('./factories.js').createWorkspaceTool}
2412
- * advertises in place of {@link WORKSPACE_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
2413
- * (`@orkestrel/tool`) advertises `summary ?? description`, so this one-sentence text stands in
2414
- * for the full teaching description; the full text stays retrievable via
2415
- * {@link import('./factories.js').createDescribeTool}.
2624
+ * Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
2625
+ * {@link import('./factories.js').createWorkspaceTool} advertises in place of
2626
+ * {@link WORKSPACE_TOOL_DESCRIPTION} — one sentence offering the `operation`-keyed file editing and
2627
+ * pointing at `describe` for the operation list and its fields.
2628
+ *
2629
+ * @remarks
2630
+ * A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
2631
+ * `summary ?? description`, so this one-sentence text stands in for the full teaching description;
2632
+ * the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
2416
2633
  */
2417
2634
  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
2635
 
2419
2636
  /**
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`).
2637
+ * Represents one operation an agent invokes through
2638
+ * {@link import('./factories.js').createWorkspaceTool} — a flat, descriptive tagged union over the
2639
+ * workspace edit, read, and navigation actions, discriminated by the `operation` literal (a
2640
+ * discriminant is named for its axis — the action being performed — never `kind`).
2424
2641
  *
2425
2642
  * @remarks
2426
- * This is the SOURCE OF TRUTH the tool contract is typed to
2643
+ * This is the source of truth the tool contract is typed to
2427
2644
  * ({@link import('./shapers.js').workspaceToolShape} compiles to a structurally-identical guard /
2428
- * parser / JSON Schema). Every field is FLAT (no nested objects) — the small-model ergonomic
2429
- * lever: a range edit is the four flat integers of the `'splice'` arm (`fromLine` /
2645
+ * parser / JSON Schema). Every field is flat (no nested objects) — the small-model ergonomic
2646
+ * lever: a range edit is the flat integers of the `'splice'` arm (`fromLine` /
2430
2647
  * `fromColumn` / `toLine` / `toColumn`), reassembled into a 1-based `Range`
2431
2648
  * (`@orkestrel/workspace`)
2432
- * by `rangeOf`, never a nested `{ start, end }`. Each EDIT / READ arm maps onto exactly one
2433
- * `WorkspaceInterface` call against the manager's ACTIVE workspace; the two REGISTRY arms
2649
+ * by `rangeOf`, never a nested `{ start, end }`. Each edit / read arm maps onto exactly one
2650
+ * `WorkspaceInterface` call against the manager's active workspace; the registry arms
2434
2651
  * (`switch` / `workspaces`) drive the {@link WorkspaceManagerInterface} pointer instead —
2435
- * `workspaces` LISTS the workspaces the model can move between, and `switch` re-points which one
2652
+ * `workspaces` lists the workspaces the model can move between, and `switch` re-points which one
2436
2653
  * the edit / read arms target.
2437
2654
  */
2438
2655
  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). */
2656
+ /** 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
2657
  {
2441
2658
  readonly operation: 'read';
2442
2659
  readonly path: string;
2443
2660
  }
2444
- /** List every file in the ACTIVE workspace (path / state / size / lines / kind summaries); `[]` when no workspace is active. */
2661
+ /** Lists every file in the active workspace (path / state / size / lines / kind summaries); `[]` when no workspace is active. */
2445
2662
  | {
2446
2663
  readonly operation: 'list';
2447
2664
  }
2448
- /** Whether a file exists at `path` in the ACTIVE workspace (`false` when no workspace is active). */
2665
+ /** Reports whether a file exists at `path` in the active workspace (`false` when no workspace is active). */
2449
2666
  | {
2450
2667
  readonly operation: 'has';
2451
2668
  readonly path: string;
2452
2669
  }
2453
2670
  /**
2454
- * Scan every text file for `query`, returning each hit (path + 1-based line / column + the line).
2671
+ * Scans every text file for `query`, returning each hit (the path, the 1-based line and column, and the line).
2455
2672
  *
2456
2673
  * @remarks
2457
2674
  * `regex` treats `query` as a regular-expression source (default `false` — a literal substring);
@@ -2465,7 +2682,7 @@ export declare type WorkspaceOperation =
2465
2682
  readonly limit?: number;
2466
2683
  }
2467
2684
  /**
2468
- * Replace `query` with `replacement` across every text file, returning the tally.
2685
+ * Replaces `query` with `replacement` across every text file, returning the tally.
2469
2686
  *
2470
2687
  * @remarks
2471
2688
  * Same matching axes as `search`: `regex` (default `false`), `sensitive` (default `true`),
@@ -2479,21 +2696,21 @@ export declare type WorkspaceOperation =
2479
2696
  readonly sensitive?: boolean;
2480
2697
  readonly limit?: number;
2481
2698
  }
2482
- /** Write (create or overwrite) the whole file at `path` with `content`. */
2699
+ /** Writes (creates or overwrites) the whole file at `path` with `content`. */
2483
2700
  | {
2484
2701
  readonly operation: 'write';
2485
2702
  readonly path: string;
2486
2703
  readonly content: string;
2487
2704
  }
2488
2705
  /**
2489
- * Splice `content` into an existing text file, replacing the 1-based range
2490
- * `(fromLine, fromColumn)` (INCLUSIVE) → `(toLine, toColumn)` (EXCLUSIVE).
2706
+ * Splices `content` into an existing text file, replacing the 1-based range
2707
+ * `(fromLine, fromColumn)` (inclusive) → `(toLine, toColumn)` (exclusive).
2491
2708
  *
2492
2709
  * @remarks
2493
- * 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
2710
+ * The flat range edit — the four positive-integer caret components reassemble into a `Range`
2711
+ * (`@orkestrel/workspace`) through `rangeOf`. An empty span (`from === to`) inserts; a span past
2495
2712
  * the end is clamped. An inverted / sub-1 range throws `RANGE`; a binary target throws
2496
- * `MODALITY`.
2713
+ * `MODALITY`; a missing target throws `MISSING`.
2497
2714
  */
2498
2715
  | {
2499
2716
  readonly operation: 'splice';
@@ -2504,52 +2721,52 @@ export declare type WorkspaceOperation =
2504
2721
  readonly toLine: number;
2505
2722
  readonly toColumn: number;
2506
2723
  }
2507
- /** Prepend `content` to the start of the file at `path` (creating it when absent). */
2724
+ /** Prepends `content` to the start of the file at `path` (creating it when absent). */
2508
2725
  | {
2509
2726
  readonly operation: 'prepend';
2510
2727
  readonly path: string;
2511
2728
  readonly content: string;
2512
2729
  }
2513
- /** Append `content` to the end of the file at `path` (creating it when absent). */
2730
+ /** Appends `content` to the end of the file at `path` (creating it when absent). */
2514
2731
  | {
2515
2732
  readonly operation: 'append';
2516
2733
  readonly path: string;
2517
2734
  readonly content: string;
2518
2735
  }
2519
- /** Re-key the file `from` → `to` (overwriting an occupied target). */
2736
+ /** Re-keys the file `from` → `to` (overwriting an occupied target). */
2520
2737
  | {
2521
2738
  readonly operation: 'move';
2522
2739
  readonly from: string;
2523
2740
  readonly to: string;
2524
2741
  }
2525
- /** Remove the file at `path` from the workspace. */
2742
+ /** Removes the file at `path` from the workspace. */
2526
2743
  | {
2527
2744
  readonly operation: 'remove';
2528
2745
  readonly path: string;
2529
2746
  }
2530
- /** List the workspaces the model can move between — each `{ id, files, active }` — so it can choose an `id` to `switch` to. */
2747
+ /** Lists the workspaces the model can move between — each `{ id, files, active }` — so it can choose an `id` to `switch` to. */
2531
2748
  | {
2532
2749
  readonly operation: 'workspaces';
2533
2750
  }
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. */
2751
+ /** 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
2752
  | {
2536
2753
  readonly operation: 'switch';
2537
2754
  readonly id: string;
2538
2755
  };
2539
2756
 
2540
2757
  /**
2541
- * Options for {@link import('./factories.js').createWorkspaceTool} — EITHER a caller-built
2542
- * {@link WorkspaceManagerInterface} to drive directly, OR a {@link WorkspaceStoreInterface} the
2543
- * tool constructs a fresh manager over; neither given constructs a manager over
2544
- * `@orkestrel/workspace`'s in-memory store.
2758
+ * Represents the options for {@link import('./factories.js').createWorkspaceTool} — either a
2759
+ * caller-built {@link WorkspaceManagerInterface} to drive directly, or a
2760
+ * {@link WorkspaceStoreInterface} the tool constructs a fresh manager over; neither given
2761
+ * constructs a manager over `@orkestrel/workspace`'s in-memory store.
2545
2762
  *
2546
2763
  * @remarks
2547
- * - `manager` — drive THIS manager directly (its `active` workspace is what every edit / read
2548
- * operation targets). Takes priority over `store` when both are supplied.
2549
- * - `store` — construct a manager over this durable {@link WorkspaceStoreInterface} (via
2764
+ * - `manager` — drive this manager directly (its `active` workspace is what every edit / read
2765
+ * operation targets). Takes priority over `store` when the caller supplies `manager` and `store`.
2766
+ * - `store` — construct a manager over this durable {@link WorkspaceStoreInterface} (through
2550
2767
  * `@orkestrel/workspace`'s `createWorkspaceManager`) — used only when `manager` is omitted.
2551
2768
  * The store only backs the manager's own `open` / `save` operations: the tool's edits are
2552
- * NOT auto-persisted — durability requires an explicit caller `save` on the manager
2769
+ * not auto-persisted — durability requires an explicit caller `save` on the manager
2553
2770
  * (unlike the workflow tool's `store`, which is forwarded into native run-wide checkpoints).
2554
2771
  * - `name` / `description` — advertised tool overrides; default to
2555
2772
  * {@link import('./constants.js').WORKSPACE_TOOL_NAME} / {@link import('./constants.js').WORKSPACE_TOOL_DESCRIPTION}.
@@ -2562,74 +2779,74 @@ export declare interface WorkspaceToolOptions {
2562
2779
  }
2563
2780
 
2564
2781
  /**
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` /
2782
+ * Describes the shape of a {@link import('./types.js').WorkspaceOperation} — a descriptive tagged union
2783
+ * over the workspace edit, read, and navigation operations, discriminated by the `operation`
2784
+ * literal (never a bare `kind`). Each variant leads with its `operation`
2785
+ * discriminant then its flat fields, every field through `stringShape` / `optionalShape` /
2569
2786
  * `integerShape({ min: 1 })` / `booleanShape`, each carrying a strong field-level `description`.
2570
2787
  *
2571
2788
  * @remarks
2572
- * The union compiles to an `anyOf` JSON Schema + a `unionOf` guard + a first-match parser
2789
+ * The union compiles to an `anyOf` JSON Schema, a `unionOf` guard, and a first-match parser
2573
2790
  * automatically ({@link import('./factories.js').createWorkspaceTool} types the result to the
2574
- * hand-written {@link import('./types.js').WorkspaceOperation}). `limit` and the four `'splice'`
2575
- * caret components are POSITIVE integers (`integerShape({ min: 1 })`); `regex` / `sensitive`
2576
- * are `optionalShape(booleanShape(...))`. The two REGISTRY arms — `workspaces` (list the
2791
+ * hand-written {@link import('./types.js').WorkspaceOperation}). `limit` and the `'splice'`
2792
+ * caret components are positive integers (`integerShape({ min: 1 })`); `regex` / `sensitive`
2793
+ * are `optionalShape(booleanShape(...))`. The registry arms — `workspaces` (list the
2577
2794
  * workspaces the model can move between) and `switch` (re-point the active one by `id`) — let a
2578
- * model DISCOVER then CHOOSE which workspace the edit / read arms target.
2579
- */
2580
- export declare const workspaceToolShape: UnionShape<readonly [ ObjectShape<{
2581
- operation: LiteralShape<readonly ["read"]>;
2582
- path: StringShape;
2583
- }, false>, ObjectShape<{
2584
- operation: LiteralShape<readonly ["list"]>;
2585
- }, false>, ObjectShape<{
2586
- operation: LiteralShape<readonly ["has"]>;
2587
- path: StringShape;
2588
- }, false>, ObjectShape<{
2589
- operation: LiteralShape<readonly ["search"]>;
2590
- query: StringShape;
2591
- regex: OptionalShape<BooleanShape>;
2592
- sensitive: OptionalShape<BooleanShape>;
2593
- limit: OptionalShape<NumberShape>;
2594
- }, false>, ObjectShape<{
2595
- operation: LiteralShape<readonly ["replace"]>;
2596
- query: StringShape;
2597
- replacement: StringShape;
2598
- regex: OptionalShape<BooleanShape>;
2599
- sensitive: OptionalShape<BooleanShape>;
2600
- limit: OptionalShape<NumberShape>;
2601
- }, false>, ObjectShape<{
2602
- operation: LiteralShape<readonly ["write"]>;
2603
- path: StringShape;
2604
- content: StringShape;
2605
- }, false>, ObjectShape<{
2606
- operation: LiteralShape<readonly ["splice"]>;
2607
- path: StringShape;
2608
- content: StringShape;
2609
- fromLine: NumberShape;
2610
- fromColumn: NumberShape;
2611
- toLine: NumberShape;
2612
- toColumn: NumberShape;
2613
- }, false>, ObjectShape<{
2614
- operation: LiteralShape<readonly ["prepend"]>;
2615
- path: StringShape;
2616
- content: StringShape;
2617
- }, false>, ObjectShape<{
2618
- operation: LiteralShape<readonly ["append"]>;
2619
- path: StringShape;
2620
- content: StringShape;
2621
- }, false>, ObjectShape<{
2622
- operation: LiteralShape<readonly ["move"]>;
2623
- from: StringShape;
2624
- to: StringShape;
2625
- }, false>, ObjectShape<{
2626
- operation: LiteralShape<readonly ["remove"]>;
2627
- path: StringShape;
2628
- }, false>, ObjectShape<{
2629
- operation: LiteralShape<readonly ["workspaces"]>;
2630
- }, false>, ObjectShape<{
2631
- operation: LiteralShape<readonly ["switch"]>;
2632
- id: StringShape;
2795
+ * model discover then choose which workspace the edit / read arms target.
2796
+ */
2797
+ export declare const workspaceToolShape: UnionShape<readonly [ObjectShape< {
2798
+ operation: LiteralShape<readonly ["read"]>;
2799
+ path: StringShape;
2800
+ }, false>, ObjectShape< {
2801
+ operation: LiteralShape<readonly ["list"]>;
2802
+ }, false>, ObjectShape< {
2803
+ operation: LiteralShape<readonly ["has"]>;
2804
+ path: StringShape;
2805
+ }, false>, ObjectShape< {
2806
+ operation: LiteralShape<readonly ["search"]>;
2807
+ query: StringShape;
2808
+ regex: OptionalShape<BooleanShape>;
2809
+ sensitive: OptionalShape<BooleanShape>;
2810
+ limit: OptionalShape<NumberShape>;
2811
+ }, false>, ObjectShape< {
2812
+ operation: LiteralShape<readonly ["replace"]>;
2813
+ query: StringShape;
2814
+ replacement: StringShape;
2815
+ regex: OptionalShape<BooleanShape>;
2816
+ sensitive: OptionalShape<BooleanShape>;
2817
+ limit: OptionalShape<NumberShape>;
2818
+ }, false>, ObjectShape< {
2819
+ operation: LiteralShape<readonly ["write"]>;
2820
+ path: StringShape;
2821
+ content: StringShape;
2822
+ }, false>, ObjectShape< {
2823
+ operation: LiteralShape<readonly ["splice"]>;
2824
+ path: StringShape;
2825
+ content: StringShape;
2826
+ fromLine: NumberShape;
2827
+ fromColumn: NumberShape;
2828
+ toLine: NumberShape;
2829
+ toColumn: NumberShape;
2830
+ }, false>, ObjectShape< {
2831
+ operation: LiteralShape<readonly ["prepend"]>;
2832
+ path: StringShape;
2833
+ content: StringShape;
2834
+ }, false>, ObjectShape< {
2835
+ operation: LiteralShape<readonly ["append"]>;
2836
+ path: StringShape;
2837
+ content: StringShape;
2838
+ }, false>, ObjectShape< {
2839
+ operation: LiteralShape<readonly ["move"]>;
2840
+ from: StringShape;
2841
+ to: StringShape;
2842
+ }, false>, ObjectShape< {
2843
+ operation: LiteralShape<readonly ["remove"]>;
2844
+ path: StringShape;
2845
+ }, false>, ObjectShape< {
2846
+ operation: LiteralShape<readonly ["workspaces"]>;
2847
+ }, false>, ObjectShape< {
2848
+ operation: LiteralShape<readonly ["switch"]>;
2849
+ id: StringShape;
2633
2850
  }, false>]>;
2634
2851
 
2635
2852
  export { }