@orkestrel/toolbox 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/src/core/index.cjs +397 -287
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +844 -714
- package/dist/src/core/index.d.ts +844 -714
- package/dist/src/core/index.js +397 -287
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +8 -5
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +22 -18
- package/dist/src/server/index.d.ts +22 -18
- package/dist/src/server/index.js +8 -5
- package/dist/src/server/index.js.map +1 -1
- package/package.json +22 -23
package/dist/src/core/index.d.ts
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
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';
|
|
17
|
-
import { LifecycleStatus } from '@orkestrel/workflow';
|
|
16
|
+
import type { KeyFunction } from '@orkestrel/database';
|
|
17
|
+
import type { LifecycleStatus } from '@orkestrel/workflow';
|
|
18
18
|
import { LiteralShape } from '@orkestrel/contract';
|
|
19
|
-
import { ModelInterface } from '@orkestrel/relation';
|
|
19
|
+
import type { ModelInterface } from '@orkestrel/relation';
|
|
20
20
|
import { NumberShape } from '@orkestrel/contract';
|
|
21
21
|
import { ObjectShape } from '@orkestrel/contract';
|
|
22
22
|
import { OptionalShape } from '@orkestrel/contract';
|
|
23
|
-
import { OrderDirection } from '@orkestrel/database';
|
|
24
|
-
import { PrimaryMap } from '@orkestrel/database';
|
|
25
|
-
import { QueryInput } from '@orkestrel/database';
|
|
26
|
-
import { RelationErrorCode } from '@orkestrel/relation';
|
|
27
|
-
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';
|
|
28
28
|
import { StringShape } from '@orkestrel/contract';
|
|
29
|
-
import { TableInterface } from '@orkestrel/database';
|
|
30
|
-
import { TableMap } from '@orkestrel/database';
|
|
31
|
-
import { TerminalManagerInterface } from '@orkestrel/terminal';
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
29
|
+
import type { TableInterface } from '@orkestrel/database';
|
|
30
|
+
import type { TableMap } from '@orkestrel/database';
|
|
31
|
+
import type { TerminalManagerInterface } from '@orkestrel/terminal';
|
|
32
|
+
import type { ToolContext } from '@orkestrel/tool';
|
|
33
|
+
import type { ToolInterface } from '@orkestrel/tool';
|
|
34
|
+
import type { ToolManagerInterface } from '@orkestrel/tool';
|
|
34
35
|
import { UnionShape } from '@orkestrel/contract';
|
|
35
|
-
import { WorkflowDefinition } from '@orkestrel/workflow';
|
|
36
|
-
import { WorkflowFault } from '@orkestrel/workflow';
|
|
37
|
-
import { WorkflowFunction } from '@orkestrel/workflow';
|
|
38
|
-
import { WorkflowRegistry } from '@orkestrel/workflow';
|
|
39
|
-
import { WorkflowResult } from '@orkestrel/workflow';
|
|
40
|
-
import { WorkflowRunnerInterface } from '@orkestrel/workflow';
|
|
41
|
-
import { WorkflowStoreInterface } from '@orkestrel/workflow';
|
|
42
|
-
import { WorkspaceManagerInterface } from '@orkestrel/workspace';
|
|
43
|
-
import { WorkspaceStoreInterface } from '@orkestrel/workspace';
|
|
36
|
+
import type { WorkflowDefinition } from '@orkestrel/workflow';
|
|
37
|
+
import type { WorkflowFault } from '@orkestrel/workflow';
|
|
38
|
+
import type { WorkflowFunction } from '@orkestrel/workflow';
|
|
39
|
+
import type { WorkflowRegistry } from '@orkestrel/workflow';
|
|
40
|
+
import type { WorkflowResult } from '@orkestrel/workflow';
|
|
41
|
+
import type { WorkflowRunnerInterface } from '@orkestrel/workflow';
|
|
42
|
+
import type { WorkflowStoreInterface } from '@orkestrel/workflow';
|
|
43
|
+
import type { WorkspaceManagerInterface } from '@orkestrel/workspace';
|
|
44
|
+
import type { WorkspaceStoreInterface } from '@orkestrel/workspace';
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* Holds 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
|
|
48
|
+
* reach, `8` — the bound {@link import('./factories.js').createAgentTool}'s depth/cycle guard
|
|
48
49
|
* enforces.
|
|
49
50
|
*
|
|
50
51
|
* @remarks
|
|
51
|
-
* Deliberately a
|
|
52
|
-
* sharing one reference):
|
|
52
|
+
* Deliberately a separate constant from {@link MAX_WORKFLOW_CHAIN} (rather than the guards
|
|
53
|
+
* sharing one reference): they bound different chains (workflow nesting against agent
|
|
53
54
|
* delegation) that happen to share a value today, and keeping this bound decoupled means a
|
|
54
55
|
* future change to one never silently shifts the other. Same numeric value by convention, not
|
|
55
56
|
* by shared reference.
|
|
@@ -63,17 +64,21 @@ export declare const AGENT_TOOL_DEPTH = 8;
|
|
|
63
64
|
export declare const AGENT_TOOL_DESCRIPTION: string;
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
* Holds the name {@link import('./factories.js').createAgentTool} advertises by default
|
|
67
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
67
|
+
* Holds the name {@link import('./factories.js').createAgentTool} advertises by default, `'agent'`
|
|
68
|
+
* — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
68
69
|
*/
|
|
69
70
|
export declare const AGENT_TOOL_NAME = "agent";
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* for the
|
|
76
|
-
*
|
|
73
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
74
|
+
* {@link import('./factories.js').createAgentTool} advertises in place of
|
|
75
|
+
* {@link AGENT_TOOL_DESCRIPTION} — one sentence offering sub-agent delegation and pointing at
|
|
76
|
+
* `describe` for the optional overrides.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
80
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
81
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
77
82
|
*/
|
|
78
83
|
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
84
|
|
|
@@ -84,9 +89,9 @@ export declare type AgentFunction = WorkflowFunction & {
|
|
|
84
89
|
};
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
|
-
* Represents the options for {@link import('./factories.js').createAgentFunction} — the
|
|
88
|
-
* wraps a live `AgentInterface` (`@orkestrel/agent`) as an {@link AgentFunction} with
|
|
89
|
-
* lineage metadata and optional nested-workflow composition.
|
|
92
|
+
* Represents the options for {@link import('./factories.js').createAgentFunction} — the opt-in
|
|
93
|
+
* adapter that wraps a live `AgentInterface` (`@orkestrel/agent`) as an {@link AgentFunction} with
|
|
94
|
+
* immutable lineage metadata and optional nested-workflow composition.
|
|
90
95
|
*
|
|
91
96
|
* @remarks
|
|
92
97
|
* All fields are optional. An empty lineage is resolved from the controller's root workflow when
|
|
@@ -109,14 +114,14 @@ export declare interface AgentFunctionOptions {
|
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
/**
|
|
112
|
-
* Represents the
|
|
113
|
-
* plus the minimal optional `AgentJobInput` (`@orkestrel/agent`) fields a caller may
|
|
114
|
-
* per-call.
|
|
117
|
+
* Represents the flat args {@link import('./factories.js').createAgentTool} accepts — a delegated
|
|
118
|
+
* `task` plus the minimal optional `AgentJobInput` (`@orkestrel/agent`) fields a caller may
|
|
119
|
+
* override per-call.
|
|
115
120
|
*
|
|
116
121
|
* @remarks
|
|
117
122
|
* `task` becomes the seed user message in the sub-agent's rehydrated conversation
|
|
118
123
|
* (`AgentJobInput.messages`). `provider` / `tools` / `system` shadow the tool's own
|
|
119
|
-
* {@link AgentToolOptions} defaults for this
|
|
124
|
+
* {@link AgentToolOptions} defaults for this one call when supplied.
|
|
120
125
|
*/
|
|
121
126
|
export declare interface AgentToolArguments {
|
|
122
127
|
readonly task: string;
|
|
@@ -132,12 +137,12 @@ export declare interface AgentToolArguments {
|
|
|
132
137
|
* @remarks
|
|
133
138
|
* - `name` / `description` — advertised tool overrides; default to
|
|
134
139
|
* {@link import('./constants.js').AGENT_TOOL_NAME} / {@link import('./constants.js').AGENT_TOOL_DESCRIPTION}.
|
|
135
|
-
* - `provider` — the
|
|
136
|
-
* that supplies its own `provider` overrides this. One of `provider` (here or per-call)
|
|
140
|
+
* - `provider` — the default registry provider key used when a call omits `provider`; a call
|
|
141
|
+
* that supplies its own `provider` overrides this. One of `provider` (here or per-call) must
|
|
137
142
|
* resolve, or the handler throws a typed `TOOL` {@link import('./errors.js').ToolboxError}.
|
|
138
|
-
* - `tools` — the
|
|
143
|
+
* - `tools` — the default registry tool-name list loaded into the delegated sub-agent; a
|
|
139
144
|
* per-call `tools` list overrides (never merges with) this default.
|
|
140
|
-
* - `system` — the
|
|
145
|
+
* - `system` — the default system prompt seeding the sub-agent's context; a per-call `system`
|
|
141
146
|
* overrides this.
|
|
142
147
|
* - `depth` — this invocation's nesting depth (default `0`); a delegated sub-agent that itself
|
|
143
148
|
* calls this tool again runs at `depth + 1`, bounded by
|
|
@@ -145,17 +150,17 @@ export declare interface AgentToolArguments {
|
|
|
145
150
|
* - `ancestry` — the sub-agent identifiers already in this delegation chain (default empty); a
|
|
146
151
|
* cycle (the resolved agent already present) is rejected with a typed `DEPTH`
|
|
147
152
|
* {@link import('./errors.js').ToolboxError}.
|
|
148
|
-
* - `store` — this package's
|
|
153
|
+
* - `store` — this package's addition: when supplied, the handler persists the delegated
|
|
149
154
|
* sub-agent's active conversation snapshot (`store.set(agent.context.conversations.active.snapshot())`)
|
|
150
|
-
*
|
|
155
|
+
* after `agent.generate()` settles successfully, before returning — one snapshot per delegation
|
|
151
156
|
* (each `registry.build` mints a fresh conversation id, so a shared store accumulates an
|
|
152
157
|
* audit log rather than colliding). Omitted ⇒ no persistence from this tool.
|
|
153
158
|
*
|
|
154
|
-
* Conversation persistence for a delegated sub-agent has
|
|
155
|
-
* together: this `store` slot persists
|
|
159
|
+
* Conversation persistence for a delegated sub-agent has independent seams, composable
|
|
160
|
+
* together: this `store` slot persists each delegation's conversation individually, and an
|
|
156
161
|
* `AgentRegistryInterface` built with `AgentRegistryOptions.store` (`@orkestrel/agent`) backs
|
|
157
|
-
*
|
|
158
|
-
* `ConversationManagerInterface` of its own. Neither is required
|
|
162
|
+
* every agent it builds — including ones built through this tool — with a store-backed
|
|
163
|
+
* `ConversationManagerInterface` of its own. Neither is required, and they compose.
|
|
159
164
|
*/
|
|
160
165
|
export declare interface AgentToolOptions {
|
|
161
166
|
readonly name?: string;
|
|
@@ -176,28 +181,36 @@ export declare interface AgentToolOptions {
|
|
|
176
181
|
* `task` is the only required field (a non-empty string); `provider` / `tools` / `system`
|
|
177
182
|
* are per-call overrides of the tool's own configured defaults.
|
|
178
183
|
*/
|
|
179
|
-
export declare const agentToolShape: ObjectShape<{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
export declare const agentToolShape: ObjectShape< {
|
|
185
|
+
task: StringShape;
|
|
186
|
+
provider: OptionalShape<StringShape>;
|
|
187
|
+
tools: OptionalShape<ArrayShape<StringShape>>;
|
|
188
|
+
system: OptionalShape<StringShape>;
|
|
184
189
|
}, false>;
|
|
185
190
|
|
|
186
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Holds the protocol {@link import('./factories.js').createAnswerTool} advertises — the `pending`
|
|
193
|
+
* and `answer` operations and the `values` record an answer supplies, each with a worked example.
|
|
194
|
+
*/
|
|
187
195
|
export declare const ANSWER_TOOL_DESCRIPTION: string;
|
|
188
196
|
|
|
189
197
|
/**
|
|
190
|
-
* Holds the name {@link import('./factories.js').createAnswerTool} advertises by default
|
|
191
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
198
|
+
* Holds the name {@link import('./factories.js').createAnswerTool} advertises by default,
|
|
199
|
+
* `'answer'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
200
|
+
* under.
|
|
192
201
|
*/
|
|
193
202
|
export declare const ANSWER_TOOL_NAME = "answer";
|
|
194
203
|
|
|
195
204
|
/**
|
|
196
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
205
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
206
|
+
* {@link import('./factories.js').createAnswerTool} advertises in place of
|
|
207
|
+
* {@link ANSWER_TOOL_DESCRIPTION} — one sentence offering the pending listing and the answer call,
|
|
208
|
+
* and pointing at `describe` for the fields each takes.
|
|
209
|
+
*
|
|
210
|
+
* @remarks
|
|
211
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
212
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
213
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
201
214
|
*/
|
|
202
215
|
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.";
|
|
203
216
|
|
|
@@ -211,7 +224,7 @@ export declare const ANSWER_TOOL_SUMMARY = "List forms addressed to this termina
|
|
|
211
224
|
* handler calls — `pending` lists the forms addressed to `to`, `answer` resolves
|
|
212
225
|
* one by `id`. A failed `answer` (`TerminalAnswerError`) re-surfaces as a typed
|
|
213
226
|
* `ANSWER` {@link import('./errors.js').ToolboxError}.
|
|
214
|
-
* - `to` — the terminal identity this tool lists / answers prompts
|
|
227
|
+
* - `to` — the terminal identity this tool lists / answers prompts for.
|
|
215
228
|
* - `name` / `description` — advertised tool overrides; default to
|
|
216
229
|
* {@link import('./constants.js').ANSWER_TOOL_NAME} / {@link import('./constants.js').ANSWER_TOOL_DESCRIPTION}.
|
|
217
230
|
*/
|
|
@@ -231,20 +244,21 @@ export declare interface AnswerToolOptions {
|
|
|
231
244
|
* `values` is first bounded to exact JSON. The handler then narrows it with the originating Form
|
|
232
245
|
* package's `isFormValues` guard before the terminal manager applies it to the parked live form.
|
|
233
246
|
*/
|
|
234
|
-
export declare const answerToolShape: UnionShape<readonly [
|
|
235
|
-
|
|
236
|
-
}, false>, ObjectShape<{
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
export declare const answerToolShape: UnionShape<readonly [ObjectShape< {
|
|
248
|
+
operation: LiteralShape<readonly ["pending"]>;
|
|
249
|
+
}, false>, ObjectShape< {
|
|
250
|
+
operation: LiteralShape<readonly ["answer"]>;
|
|
251
|
+
id: StringShape;
|
|
252
|
+
values: JSONShape;
|
|
240
253
|
}, false>]>;
|
|
241
254
|
|
|
242
255
|
/**
|
|
243
|
-
* Represents the
|
|
256
|
+
* Represents the probe query and effective row limit {@link import('./helpers.js').clampQuery}
|
|
257
|
+
* returns.
|
|
244
258
|
*
|
|
245
259
|
* @remarks
|
|
246
260
|
* `limit` is the effective ceiling — `min(query?.limit ?? cap, cap)`, floored at `0`. `query`
|
|
247
|
-
* requests one row
|
|
261
|
+
* requests one row more than that, so a caller detects truncation from the returned row count
|
|
248
262
|
* without a separate `count` round trip.
|
|
249
263
|
*/
|
|
250
264
|
export declare interface ClampedQuery {
|
|
@@ -253,14 +267,14 @@ export declare interface ClampedQuery {
|
|
|
253
267
|
}
|
|
254
268
|
|
|
255
269
|
/**
|
|
256
|
-
* Clamps a `'records'` call's query to a row cap, and builds the
|
|
257
|
-
*
|
|
258
|
-
*
|
|
270
|
+
* Clamps a `'records'` call's query to a row cap, and builds the probe query the caller reads with
|
|
271
|
+
* — the pure leaf {@link import('./factories.js').createDatabaseTool}'s `'records'` operation uses
|
|
272
|
+
* to detect truncation without a separate `count` round trip.
|
|
259
273
|
*
|
|
260
274
|
* @remarks
|
|
261
275
|
* {@link resolveLimit} picks the effective limit, so a caller can never exceed the configured cap
|
|
262
276
|
* by supplying a larger `query.limit`, and can never drive it below `0`. The returned probe query
|
|
263
|
-
* requests
|
|
277
|
+
* requests one more row than the effective limit (`limit: effective + 1`) — if storage returns
|
|
264
278
|
* that many, the caller knows the true result was truncated (`rows.length > effective`) and slices
|
|
265
279
|
* back down to `effective` before returning.
|
|
266
280
|
*
|
|
@@ -276,7 +290,7 @@ export declare interface ClampedQuery {
|
|
|
276
290
|
*
|
|
277
291
|
* @param query - The live query to clamp (or `undefined`)
|
|
278
292
|
* @param cap - The row-count ceiling
|
|
279
|
-
* @returns The
|
|
293
|
+
* @returns The probe query (`limit` bumped by one) and the effective `limit`
|
|
280
294
|
*/
|
|
281
295
|
export declare function clampQuery(query: QueryInput | undefined, cap: number): ClampedQuery;
|
|
282
296
|
|
|
@@ -296,9 +310,9 @@ export declare type ColumnSpec = ColumnPrimitive | Readonly<{
|
|
|
296
310
|
}>;
|
|
297
311
|
|
|
298
312
|
/** Describes a {@link import('./types.js').ColumnSpec} — a bare {@link columnPrimitiveShape}, or `{ primitive, optional }`. */
|
|
299
|
-
export declare const columnSpecShape: UnionShape<readonly [
|
|
300
|
-
|
|
301
|
-
|
|
313
|
+
export declare const columnSpecShape: UnionShape<readonly [LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape< {
|
|
314
|
+
primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
315
|
+
optional: OptionalShape<BooleanShape>;
|
|
302
316
|
}, false>]>;
|
|
303
317
|
|
|
304
318
|
/**
|
|
@@ -320,21 +334,21 @@ export declare function compileColumn(spec: ColumnSpec): ContractShape;
|
|
|
320
334
|
export declare function compileColumnPrimitive(primitive: ColumnPrimitive): ContractShape;
|
|
321
335
|
|
|
322
336
|
/**
|
|
323
|
-
* Completes a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesizes
|
|
324
|
-
*
|
|
325
|
-
*
|
|
337
|
+
* Completes a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesizes a
|
|
338
|
+
* missing `id` deterministically and positionally, and defaults a missing `name` to its resolved
|
|
339
|
+
* `id`.
|
|
326
340
|
*
|
|
327
341
|
* @remarks
|
|
328
342
|
* The positional id scheme is stable and human-legible: the workflow is `wf`, phase `i` is
|
|
329
343
|
* `phase-<i>`, and task `j` of that phase is `<phaseId>-task-<j>` (so a provided phase id flows
|
|
330
|
-
* into its tasks' synthesized ids). A
|
|
344
|
+
* into its tasks' synthesized ids). A provided `id` / `name` at any level is kept verbatim —
|
|
331
345
|
* synthesis touches only the omitted ones. A missing `name` defaults to the resolved `id` (never
|
|
332
|
-
* the other way round), so the result always
|
|
346
|
+
* the other way round), so the result always carries an `id` and a `name`. `behavior`, `description`, the per-phase
|
|
333
347
|
* `concurrency` / `bail`, the per-task `retries` / `timeout`, and the workflow `bail` carry over
|
|
334
348
|
* unchanged. The result is a complete {@link WorkflowDefinition}; the caller still validates it
|
|
335
|
-
* against the
|
|
349
|
+
* against the strict contract.
|
|
336
350
|
*
|
|
337
|
-
* @param draft - The draft workflow (id
|
|
351
|
+
* @param draft - The draft workflow (`id` and `name` optional at the workflow, phase, and task levels)
|
|
338
352
|
* @returns A complete {@link WorkflowDefinition} with every id/name filled
|
|
339
353
|
*/
|
|
340
354
|
export declare function completeDraft(draft: WorkflowDraft): WorkflowDefinition;
|
|
@@ -361,12 +375,15 @@ export declare function completePhaseDraft(phase: PhaseDraft, index: number): Wo
|
|
|
361
375
|
*/
|
|
362
376
|
export declare function completeTaskDraft(task: TaskDraft, phaseId: string, index: number): WorkflowDefinition['phases'][number]['tasks'][number];
|
|
363
377
|
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
378
|
+
/**
|
|
379
|
+
* Describes one serialized where condition — `values` is always an array, even for a single-value
|
|
380
|
+
* operator.
|
|
381
|
+
*/
|
|
382
|
+
export declare const conditionShape: ObjectShape< {
|
|
383
|
+
column: StringShape;
|
|
384
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
385
|
+
values: ArrayShape<JSONShape>;
|
|
386
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
370
387
|
}, false>;
|
|
371
388
|
|
|
372
389
|
/**
|
|
@@ -408,8 +425,8 @@ export declare const conditionShape: ObjectShape<{
|
|
|
408
425
|
export declare function createAgentFunction(agent: AgentInterface, options?: AgentFunctionOptions): AgentFunction;
|
|
409
426
|
|
|
410
427
|
/**
|
|
411
|
-
* Builds an LLM-callable sub-agent delegation tool — resolves a live, seeded `AgentInterface`
|
|
412
|
-
* from `registry` and runs it to completion for
|
|
428
|
+
* Builds an LLM-callable sub-agent delegation tool — it resolves a live, seeded `AgentInterface`
|
|
429
|
+
* from `registry` and runs it to completion for one delegated `task`.
|
|
413
430
|
*
|
|
414
431
|
* @remarks
|
|
415
432
|
* The universal tool-handler contract: validates the call args against
|
|
@@ -417,10 +434,10 @@ export declare function createAgentFunction(agent: AgentInterface, options?: Age
|
|
|
417
434
|
* sub-agent's conversation as a single `user` message; `provider` / `tools` / `system` fall
|
|
418
435
|
* back to the tool's own {@link import('./types.js').AgentToolOptions} defaults), rehydrates the sub-agent through
|
|
419
436
|
* `registry.build`, runs it with `agent.generate()`, and returns the settled
|
|
420
|
-
* `AgentResult.content` string (the sub-agent's final text). A missing / unresolvable `provider`, or a malformed call,
|
|
437
|
+
* `AgentResult.content` string (the sub-agent's final text). A missing / unresolvable `provider`, or a malformed call, throws a typed `TOOL`
|
|
421
438
|
* {@link import('./errors.js').ToolboxError}; a delegation that would exceed
|
|
422
439
|
* {@link import('./constants.js').AGENT_TOOL_DEPTH}, or re-enter an already-delegated agent (a
|
|
423
|
-
* cycle),
|
|
440
|
+
* cycle), throws a typed `DEPTH` {@link import('./errors.js').ToolboxError}, each isolated
|
|
424
441
|
* by the `ToolManagerInterface` into the canonical tool result's top-level `error`.
|
|
425
442
|
*
|
|
426
443
|
* `AgentInterface` (`@orkestrel/agent`) exposes no teardown method — a bound sub-agent's
|
|
@@ -449,9 +466,8 @@ export declare function createAgentFunction(agent: AgentInterface, options?: Age
|
|
|
449
466
|
export declare function createAgentTool(registry: AgentRegistryInterface, options?: AgentToolOptions): ToolInterface;
|
|
450
467
|
|
|
451
468
|
/**
|
|
452
|
-
* Builds an LLM-callable answer tool — the
|
|
453
|
-
* addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of
|
|
454
|
-
* them by id.
|
|
469
|
+
* Builds an LLM-callable answer tool — the answer side of the terminal seam. It lists the forms
|
|
470
|
+
* addressed to {@link import('./types.js').AnswerToolOptions.to}, or answers one of them by id.
|
|
455
471
|
*
|
|
456
472
|
* @remarks
|
|
457
473
|
* The universal tool-handler contract: validates the call args against
|
|
@@ -461,10 +477,10 @@ export declare function createAgentTool(registry: AgentRegistryInterface, option
|
|
|
461
477
|
* and applies it through
|
|
462
478
|
* `TerminalManagerInterface.answer` — a rejected / unknown / unresolvable outcome
|
|
463
479
|
* (`TerminalAnswerResult.error`) re-surfaces as a typed `ANSWER` `ToolboxError`; success returns
|
|
464
|
-
* `{ answered: id }`. `to` is
|
|
480
|
+
* `{ answered: id }`. `to` is fixed at construction
|
|
465
481
|
* ({@link import('./types.js').AnswerToolOptions.to}) — never read from the model-supplied args —
|
|
466
482
|
* so a model cannot spoof which terminal it is answering for. Concurrent answerers racing on one
|
|
467
|
-
* endpoint are
|
|
483
|
+
* endpoint are first-write-wins — a late answer to an already-settled form returns a typed
|
|
468
484
|
* `ANSWER` `ToolboxError` (surfaced as a 422 over HTTP).
|
|
469
485
|
*
|
|
470
486
|
* @param options - The live manager, the fixed `to` identity, and advertised overrides (see
|
|
@@ -511,7 +527,7 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
|
|
|
511
527
|
* @remarks
|
|
512
528
|
* The universal tool-handler contract: validates the call args against
|
|
513
529
|
* {@link import('./shapers.js').databaseToolShape}, dispatches to the matching operation, and
|
|
514
|
-
*
|
|
530
|
+
* returns a plain result on success. A database is resolved lazily and cached for the tool's
|
|
515
531
|
* lifetime — `'create'` mints one from `tables` ({@link import('./compilers.js').expandTables}) and
|
|
516
532
|
* a registered `driver` key ({@link import('./types.js').DatabaseToolOptions.drivers}, default
|
|
517
533
|
* `{ memory: () => createMemoryDriver() }`); any other operation addressing an uncached id falls
|
|
@@ -536,7 +552,7 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
|
|
|
536
552
|
* ({@link import('./helpers.js').inferDatabaseCode}); an `ToolboxError` thrown by this tool's own
|
|
537
553
|
* guards passes through unwrapped.
|
|
538
554
|
*
|
|
539
|
-
* A lazily re-minted database over the
|
|
555
|
+
* A lazily re-minted database over the default in-memory driver yields an empty database — only
|
|
540
556
|
* the {@link import('./types.js').DatabaseDefinition} schema persists in `store`, never rows;
|
|
541
557
|
* durable rows need a persistent driver factory registered in
|
|
542
558
|
* {@link import('./types.js').DatabaseToolOptions.drivers}. `'destroy'` closes whatever handle is
|
|
@@ -544,7 +560,7 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
|
|
|
544
560
|
* {@link import('./types.js').DatabaseToolOptions.databases} handle — the embedder relinquishes
|
|
545
561
|
* that handle's lifecycle to this tool for any id it wires in. This tool assumes the
|
|
546
562
|
* single-writer, non-reentrant model `@orkestrel/database` itself assumes — concurrent calls
|
|
547
|
-
* against one id are
|
|
563
|
+
* against one id are not serialized by this tool. `'get'` is uncapped by
|
|
548
564
|
* {@link import('./types.js').DatabaseToolOptions.limit} (bounded only by the caller's `key` array
|
|
549
565
|
* size), unlike `'records'` / `'find'` / `'links'`.
|
|
550
566
|
*
|
|
@@ -556,19 +572,21 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
|
|
|
556
572
|
* import { createDatabaseTool } from '@src/core'
|
|
557
573
|
*
|
|
558
574
|
* const tool = createDatabaseTool()
|
|
559
|
-
* await tool.execute(
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
* }
|
|
575
|
+
* await tool.execute(
|
|
576
|
+
* {
|
|
577
|
+
* operation: 'create',
|
|
578
|
+
* id: 'shop',
|
|
579
|
+
* tables: { products: { columns: { name: 'string', price: 'number' } } },
|
|
580
|
+
* },
|
|
581
|
+
* { signal: new AbortController().signal },
|
|
582
|
+
* )
|
|
564
583
|
* ```
|
|
565
584
|
*/
|
|
566
585
|
export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolInterface;
|
|
567
586
|
|
|
568
587
|
/**
|
|
569
|
-
* Builds an LLM-callable tool that returns the
|
|
570
|
-
* name — the counterpart to the lean `summary` the other tools in this package advertise
|
|
571
|
-
* (`AGENT_TOOL_SUMMARY` / `WORKFLOW_TOOL_SUMMARY` / `WORKSPACE_TOOL_SUMMARY`).
|
|
588
|
+
* Builds an LLM-callable tool that returns the full `description` of another registered tool by
|
|
589
|
+
* name — the counterpart to the lean `summary` the other tools in this package advertise.
|
|
572
590
|
*
|
|
573
591
|
* @remarks
|
|
574
592
|
* `ToolManagerInterface.definitions()` (`@orkestrel/tool`) advertises `tool.summary ??
|
|
@@ -579,8 +597,8 @@ export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolI
|
|
|
579
597
|
* tool has no `description` of its own, then a placeholder when it has neither).
|
|
580
598
|
*
|
|
581
599
|
* The universal tool-handler contract: validates the call args against
|
|
582
|
-
* {@link import('./shapers.js').describeToolShape},
|
|
583
|
-
* success,
|
|
600
|
+
* {@link import('./shapers.js').describeToolShape}, returns the plain description string on
|
|
601
|
+
* success, throws a typed `TOOL` {@link import('./errors.js').ToolboxError} on a malformed call
|
|
584
602
|
* or an unknown tool name.
|
|
585
603
|
*
|
|
586
604
|
* @param tools - The `ToolManagerInterface` (`@orkestrel/tool`) whose registered tools this
|
|
@@ -602,36 +620,38 @@ export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolI
|
|
|
602
620
|
export declare function createDescribeTool(tools: ToolManagerInterface): ToolInterface;
|
|
603
621
|
|
|
604
622
|
/**
|
|
605
|
-
* Wraps one
|
|
606
|
-
* `ToolInterface` — the endpoint half of the
|
|
607
|
-
* {@link createInferTool}, is a standalone inference utility).
|
|
623
|
+
* Wraps one concrete endpoint ({@link import('./types.js').EndpointDefinition}) as an LLM-callable
|
|
624
|
+
* `ToolInterface` — the endpoint half of the bridge from an existing API or database into an MCP
|
|
625
|
+
* tool (the other half, {@link createInferTool}, is a standalone inference utility).
|
|
608
626
|
*
|
|
609
627
|
* @remarks
|
|
610
|
-
* `parameters` is inferred
|
|
628
|
+
* `parameters` is inferred once at construction from `definition.samples` through
|
|
611
629
|
* `@orkestrel/contract`'s `samplesToSchema` (tuned by {@link import('./types.js').EndpointToolOptions}'s
|
|
612
630
|
* `format` / `enum`), wrapping a non-object root as `{ value: <schema> }` through `schemaToObject` —
|
|
613
|
-
* the
|
|
614
|
-
* ({@link import('./types.js').EndpointToolOptions.validate} `true`), the
|
|
615
|
-
* `@orkestrel/contract`'s `schemaToShape` compiles it
|
|
631
|
+
* the same object-rooted schema is both the advertised `parameters` and, by default
|
|
632
|
+
* ({@link import('./types.js').EndpointToolOptions.validate} `true`), the enforced contract:
|
|
633
|
+
* `@orkestrel/contract`'s `schemaToShape` compiles it once (through `createContract`) into a
|
|
616
634
|
* `ContractInterface` whose `.parse` runs on every call's `args` before `definition.execute` — a
|
|
617
|
-
*
|
|
635
|
+
* normalizing parse, not a strict type check: a scalar is coerced to its inferred type where the
|
|
618
636
|
* house parsers coerce (a number to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/
|
|
619
|
-
* `'false'`/`1`/`0`), so `definition.execute` receives the
|
|
637
|
+
* `'false'`/`1`/`0`), so `definition.execute` receives the coerced value (for example `7` sent for a
|
|
620
638
|
* string slot arrives as `'7'`), not the raw call value. A call whose `args` fails to parse into
|
|
621
|
-
* a record — a required key missing, or a value not coercible to its slot's type —
|
|
639
|
+
* a record — a required key missing, or a value not coercible to its slot's type — throws a
|
|
622
640
|
* typed `TOOL` {@link import('./errors.js').ToolboxError} carrying the compiled contract's
|
|
623
641
|
* structured `explain` faults, and `definition.execute` is never called. `format` annotations are
|
|
624
|
-
*
|
|
642
|
+
* never asserted, and a key outside the closed inferred schema is silently dropped rather than
|
|
625
643
|
* rejected (see {@link import('./types.js').EndpointToolOptions.validate}). With
|
|
626
|
-
* `validate: false`, the tool's `execute`
|
|
627
|
-
* `definition.execute`
|
|
628
|
-
*
|
|
644
|
+
* `validate: false`, the tool's `execute` passes through the model-supplied `args` to
|
|
645
|
+
* `definition.execute` without re-validation — the raw-passthrough opt-out. The execution context
|
|
646
|
+
* the tool's `execute` receives reaches `definition.execute` unchanged whichever way `args` are
|
|
647
|
+
* handled, so a handler that reads `context.signal` observes the caller's cancellation. Either way,
|
|
648
|
+
* the definition's return flows back as the tool call's plain result; a throw propagates uncaught,
|
|
629
649
|
* isolated by the `ToolManagerInterface` (`@orkestrel/tool`) into the canonical error envelope
|
|
630
650
|
* — never caught or re-wrapped here.
|
|
631
651
|
*
|
|
632
652
|
* @param definition - The endpoint's identity, non-empty samples, and local handler (see
|
|
633
653
|
* {@link import('./types.js').EndpointDefinition})
|
|
634
|
-
* @param options - Construction-time inference tuning
|
|
654
|
+
* @param options - Construction-time inference tuning and the validate opt-out (see
|
|
635
655
|
* {@link import('./types.js').EndpointToolOptions})
|
|
636
656
|
* @returns A `ToolInterface` named `definition.name`
|
|
637
657
|
*
|
|
@@ -670,44 +690,44 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
|
|
|
670
690
|
export declare function createEndpointTool(definition: EndpointDefinition, options?: EndpointToolOptions): ToolInterface;
|
|
671
691
|
|
|
672
692
|
/**
|
|
673
|
-
* Builds a standalone LLM-callable tool that infers a JSON Schema from example values — the
|
|
674
|
-
*
|
|
675
|
-
* {@link createEndpointTool}, wraps one
|
|
693
|
+
* Builds a standalone LLM-callable tool that infers a JSON Schema from example values — the utility
|
|
694
|
+
* half of the bridge from an existing API or database into an MCP tool (the other half,
|
|
695
|
+
* {@link createEndpointTool}, wraps one concrete endpoint).
|
|
676
696
|
*
|
|
677
697
|
* @remarks
|
|
678
698
|
* The universal tool-handler contract: validates the call args against
|
|
679
699
|
* {@link import('./shapers.js').inferToolShape} (`samples` non-empty, `format` / `enum` optional
|
|
680
700
|
* booleans, `candidates` an optional array), infers a schema through `@orkestrel/contract`'s
|
|
681
701
|
* `samplesToSchema`, wraps a non-object root as `{ value: <schema> }` through `schemaToObject` (mirrors
|
|
682
|
-
* the tool-parameters convention every other `create*Tool` factory advertises), and
|
|
702
|
+
* the tool-parameters convention every other `create*Tool` factory advertises), and returns the
|
|
683
703
|
* resulting parameters record. An empty `samples` array fails `inferToolShape`'s `min: 1` bound —
|
|
684
704
|
* `contract.parse` returns `undefined` and the handler throws a typed `TOOL`
|
|
685
705
|
* {@link import('./errors.js').ToolboxError}.
|
|
686
706
|
*
|
|
687
|
-
* When `candidates` is
|
|
688
|
-
* this array existed. When `candidates` is
|
|
689
|
-
* compiles a
|
|
690
|
-
* `schemaToShape`,
|
|
707
|
+
* When `candidates` is absent, the return is the bare parameters record — unchanged from before
|
|
708
|
+
* this array existed. When `candidates` is present (any array, including empty), the handler
|
|
709
|
+
* compiles a separate per-call contract from the raw inferred schema (through `@orkestrel/contract`'s
|
|
710
|
+
* `schemaToShape`, not the `schemaToObject`-wrapped parameters — a bare-value sample checks a
|
|
691
711
|
* bare-value candidate) and returns `{ parameters, checks }`, one check per candidate at the same
|
|
692
|
-
* index. Every entry has a
|
|
693
|
-
* when `valid` is `false`: `valid` is the
|
|
694
|
-
*
|
|
695
|
-
* string slot) — here a conformance report answers "does this value conform
|
|
696
|
-
* string slot is `valid: false`, full stop. `coercible` answers a
|
|
697
|
-
*
|
|
712
|
+
* index. Every entry has a uniform shape — `{ index, valid, coercible }`, with `faults` added only
|
|
713
|
+
* when `valid` is `false`: `valid` is the strict guard verdict (`checker.is(candidate)`), the
|
|
714
|
+
* opposite of {@link createEndpointTool}'s enforcement, which coerces (`7` becomes `'7'` for a
|
|
715
|
+
* string slot) — here a conformance report answers "does this value conform as-is": `7` against a
|
|
716
|
+
* string slot is `valid: false`, full stop. `coercible` answers a separate question — "would the
|
|
717
|
+
* normalizing parse accept this value", that is would {@link createEndpointTool}'s default enforcement
|
|
698
718
|
* admit it (`checker.parse(candidate) !== undefined`) — computed for every candidate regardless of
|
|
699
719
|
* `valid`; by the house parse/guard round-trip, a `valid: true` entry is
|
|
700
|
-
*
|
|
720
|
+
* always also `coercible: true`. `@orkestrel/contract`'s `explain` mirrors the normalizing
|
|
701
721
|
* `parse`'s leniency, not `is`'s strictness — so a strictly-invalid but coercible candidate (`7`
|
|
702
|
-
* against a string slot) yields `{ valid: false, coercible: true, faults: [] }`:
|
|
722
|
+
* against a string slot) yields `{ valid: false, coercible: true, faults: [] }`: empty faults, because
|
|
703
723
|
* the mismatch the normalizing parse would silently fix is not one `explain` reports. `faults`
|
|
704
|
-
* therefore only ever populates for a
|
|
724
|
+
* therefore only ever populates for a non-coercible mismatch — a wrong type the parse can't coerce
|
|
705
725
|
* (a boolean in a string slot), a missing required key, or an out-of-enum value — where
|
|
706
726
|
* `coercible: false`. `checker.is` / `.parse` / `.explain` are all total over JSON-safe input — a
|
|
707
|
-
* JSON-safe hostile candidate (a `__proto__`-carrying object, deeply nested data) reaches
|
|
708
|
-
* and yields a bounded, non-throwing per-candidate verdict; a
|
|
709
|
-
* throwing-getter `Proxy`) never reaches the checker at all — it fails the
|
|
710
|
-
* against {@link import('./shapers.js').inferToolShape} and rejects the
|
|
727
|
+
* JSON-safe hostile candidate (a `__proto__`-carrying object, deeply nested data) reaches each of them
|
|
728
|
+
* and yields a bounded, non-throwing per-candidate verdict; a non-JSON-safe candidate (for example a
|
|
729
|
+
* throwing-getter `Proxy`) never reaches the checker at all — it fails the outer `args` parse
|
|
730
|
+
* against {@link import('./shapers.js').inferToolShape} and rejects the whole call with the same
|
|
711
731
|
* `TOOL` {@link import('./errors.js').ToolboxError} a malformed `samples`/`format`/`enum` throws,
|
|
712
732
|
* with no per-candidate verdict produced.
|
|
713
733
|
*
|
|
@@ -750,8 +770,8 @@ export declare function createInferTool(options?: InferToolOptions): ToolInterfa
|
|
|
750
770
|
|
|
751
771
|
/**
|
|
752
772
|
* Creates the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of database
|
|
753
|
-
* definitions, the
|
|
754
|
-
*
|
|
773
|
+
* definitions, the default store the database and relation tools persist their `DatabaseDefinition`
|
|
774
|
+
* configs through.
|
|
755
775
|
*
|
|
756
776
|
* @returns A {@link DefinitionStoreInterface}
|
|
757
777
|
*
|
|
@@ -765,20 +785,23 @@ export declare function createInferTool(options?: InferToolOptions): ToolInterfa
|
|
|
765
785
|
export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
|
|
766
786
|
|
|
767
787
|
/**
|
|
768
|
-
* Builds an LLM-callable form tool — the
|
|
769
|
-
*
|
|
788
|
+
* Builds an LLM-callable form tool — the ask side of the terminal seam. It asks a multi-field form
|
|
789
|
+
* and blocks until the addressed terminal answers, returning the resolved values record.
|
|
770
790
|
*
|
|
771
791
|
* @remarks
|
|
772
792
|
* The universal tool-handler contract: validates the call args against
|
|
773
793
|
* {@link import('./shapers.js').promptToolShape}, parses the call's schema through
|
|
774
794
|
* `@orkestrel/form`, constructs the live form, and passes it to `TerminalManagerInterface.ask`.
|
|
775
|
-
* `from` is
|
|
795
|
+
* `from` is fixed at construction
|
|
776
796
|
* ({@link import('./types.js').PromptToolOptions.from}) — never read from the model-supplied
|
|
777
|
-
* args — so a model cannot spoof which terminal is asking. A form
|
|
797
|
+
* args — so a model cannot spoof which terminal is asking. A form cycle rejects with
|
|
778
798
|
* `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
|
|
779
799
|
* {@link import('./errors.js').ToolboxError}; an expired form re-surfaces as `EXPIRE`; an
|
|
780
800
|
* unknown `to` (or any other `TerminalError`) re-surfaces as `TOOL`, naming the unknown terminal
|
|
781
|
-
* and how many brokers the manager holds (`manager.count`).
|
|
801
|
+
* and how many brokers the manager holds (`manager.count`). A schema `parseForm` refuses — an
|
|
802
|
+
* unknown control, a duplicate field name, a `'select'` or `'checkbox'` field without usable
|
|
803
|
+
* `choices` — throws a typed `TOOL` error up front, so a malformed schema never parks as a form
|
|
804
|
+
* nobody can answer.
|
|
782
805
|
*
|
|
783
806
|
* @param options - The live manager, the fixed `from` identity, and advertised overrides (see
|
|
784
807
|
* {@link import('./types.js').PromptToolOptions})
|
|
@@ -809,14 +832,14 @@ export declare function createPromptTool(options: PromptToolOptions): ToolInterf
|
|
|
809
832
|
* The universal tool-handler contract: validates the call args against
|
|
810
833
|
* {@link import('./shapers.js').relationToolShape}, resolves the addressed
|
|
811
834
|
* {@link import('@orkestrel/relation').RelationManagerInterface} — an explicit `manager` field
|
|
812
|
-
* must match a key of {@link import('./types.js').RelationToolOptions.managers}, an
|
|
813
|
-
* resolves to the
|
|
835
|
+
* must match a key of {@link import('./types.js').RelationToolOptions.managers}, an omitted one
|
|
836
|
+
* resolves to the sole registered manager, either miss throwing a typed `TOOL`
|
|
814
837
|
* {@link import('./errors.js').ToolboxError}
|
|
815
838
|
* ({@link import('./helpers.js').resolveRelationManager}) — then resolves `model` against it
|
|
816
839
|
* ({@link import('./helpers.js').resolveRelationModel}, same typed-`TOOL`-on-miss shape), and
|
|
817
|
-
* dispatches to the matched operation,
|
|
840
|
+
* dispatches to the matched operation, returning a plain result on success.
|
|
818
841
|
*
|
|
819
|
-
* `'load'` / `'find'` expand the call's
|
|
842
|
+
* `'load'` / `'find'` expand the call's flat dot-path `include` list into a live
|
|
820
843
|
* `@orkestrel/relation` `Include` tree through {@link import('./helpers.js').expandInclude}, capped
|
|
821
844
|
* at {@link import('./types.js').RelationToolOptions.depth} (default
|
|
822
845
|
* {@link import('./constants.js').RELATION_TOOL_DEPTH}) — a path exceeding the cap, or carrying an
|
|
@@ -826,7 +849,7 @@ export declare function createPromptTool(options: PromptToolOptions): ToolInterf
|
|
|
826
849
|
* result to {@link import('./types.js').RelationToolOptions.limit} (default
|
|
827
850
|
* {@link import('./constants.js').RELATION_TOOL_LIMIT}), taken through
|
|
828
851
|
* {@link import('./helpers.js').resolveLimit} — `'find'` probes one row past the effective limit to
|
|
829
|
-
* report `truncated`; `'links'` (which has no upstream pagination) fetches the
|
|
852
|
+
* report `truncated`; `'links'` (which has no upstream pagination) fetches the full linked-key
|
|
830
853
|
* list and slices/truncates it the same way. `'link'` / `'unlink'` write / remove one `through` junction
|
|
831
854
|
* row.
|
|
832
855
|
*
|
|
@@ -845,21 +868,26 @@ export declare function createPromptTool(options: PromptToolOptions): ToolInterf
|
|
|
845
868
|
* import { createRelationTool } from '@src/core'
|
|
846
869
|
*
|
|
847
870
|
* const tool = createRelationTool({ managers: { shop: manager } })
|
|
848
|
-
* await tool.execute(
|
|
871
|
+
* await tool.execute(
|
|
872
|
+
* { operation: 'load', model: 'accounts', key: 'acc1', include: ['contacts'] },
|
|
873
|
+
* { signal: new AbortController().signal },
|
|
874
|
+
* )
|
|
849
875
|
* ```
|
|
850
876
|
*/
|
|
851
877
|
export declare function createRelationTool(options: RelationToolOptions): ToolInterface;
|
|
852
878
|
|
|
853
879
|
/**
|
|
854
|
-
* Wraps a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the
|
|
855
|
-
* adapter that lets a `function`-form task run a `@orkestrel/tool` tool
|
|
880
|
+
* Wraps a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the opt-in
|
|
881
|
+
* adapter that lets a `function`-form task run a `@orkestrel/tool` tool by name.
|
|
856
882
|
*
|
|
857
883
|
* @remarks
|
|
858
884
|
* Composes into a caller's `WorkflowOptions.functions` registry like any other behavior
|
|
859
885
|
* (`{ publish: createToolFunction(tools, 'publish') }`); the pure workflow runner has no
|
|
860
886
|
* knowledge of tools itself. The returned function executes `name` against `tools` with the
|
|
861
887
|
* task's `controller.input` as the call arguments. The adapter resolves the live tool, calls its
|
|
862
|
-
* `execute` method directly, and deep-gates the returned unknown through `parseJSONValue`.
|
|
888
|
+
* `execute` method directly, and deep-gates the returned unknown through `parseJSONValue`. The
|
|
889
|
+
* execution context it passes carries the task's own `controller.signal`, so a handler that
|
|
890
|
+
* reads `context.signal` observes the caller's cancellation.
|
|
863
891
|
* Genuine execution throws retain identity. An unregistered name or non-JSON return throws this
|
|
864
892
|
* package's typed `TOOL` `ToolboxError`.
|
|
865
893
|
*
|
|
@@ -882,7 +910,9 @@ export declare function createRelationTool(options: RelationToolOptions): ToolIn
|
|
|
882
910
|
export declare function createToolFunction(tools: ToolManagerInterface, name: string): WorkflowFunction;
|
|
883
911
|
|
|
884
912
|
/**
|
|
885
|
-
* Compiles the lenient workflow draft contract
|
|
913
|
+
* Compiles the lenient workflow draft contract {@link createWorkflowTool} parses an authored tree
|
|
914
|
+
* with — a `ContractInterface` over a {@link WorkflowDraft}, whose `id` and `name` are optional at
|
|
915
|
+
* the workflow, phase, and task levels.
|
|
886
916
|
*
|
|
887
917
|
* @returns The compiled {@link import('./types.js').WorkflowDraft} contract
|
|
888
918
|
*/
|
|
@@ -918,34 +948,33 @@ export declare function createWorkflowDraftContract(): ContractInterface<Workflo
|
|
|
918
948
|
export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): WorkflowRegistry;
|
|
919
949
|
|
|
920
950
|
/**
|
|
921
|
-
* Wraps a {@link WorkflowDefinition} as an LLM-callable tool — it
|
|
922
|
-
*
|
|
923
|
-
*
|
|
924
|
-
*
|
|
925
|
-
* named functions and native checkpoint store.
|
|
951
|
+
* Wraps a {@link WorkflowDefinition} as an LLM-callable tool — it advertises the flat authoring
|
|
952
|
+
* shape (`{ name?, steps: [{ name }] }`) as its `parameters`, and its handler completes the
|
|
953
|
+
* authored blob, validates it against the strict contract, and runs it through `runner`, forwarding
|
|
954
|
+
* the caller's optional named functions and native checkpoint store.
|
|
926
955
|
*
|
|
927
956
|
* @remarks
|
|
928
957
|
* A plain `ToolManagerInterface`-compatible tool (`@orkestrel/tool`), reproducing
|
|
929
958
|
* Toolbox's flat / draft / full authoring contract, strict soundness gate, and lineage guard.
|
|
930
|
-
* It is
|
|
959
|
+
* It is also the propagation carrier
|
|
931
960
|
* {@link createAgentFunction} binds onto a wrapped agent's `context.tools`: because a tool
|
|
932
961
|
* handler receives only the model-supplied `args`, the immutable lineage is closed over at bind
|
|
933
962
|
* time. The authored target is appended and its zero-based depth derived from workflow tags.
|
|
934
963
|
*
|
|
935
|
-
* **Widened authoring surface (additive — the canonical contract
|
|
936
|
-
* unchanged).** A 2B model reliably
|
|
937
|
-
*
|
|
938
|
-
* So the tool
|
|
964
|
+
* **Widened authoring surface (additive — the canonical contract and runner stay strict and
|
|
965
|
+
* unchanged).** A 2B model reliably calls the tool but cannot reliably emit the full nested
|
|
966
|
+
* {@link WorkflowDefinition}, whose every `id` and `name` is required across an all-or-nothing
|
|
967
|
+
* tree. So the tool accepts the authoring forms that follow and converges them on the same strict
|
|
939
968
|
* `createWorkflowContract` gate before running (soundness preserved):
|
|
940
|
-
* - the
|
|
969
|
+
* - the flat shape `{ name?, steps: [{ name }] }` — the advertised `parameters` (the simplest
|
|
941
970
|
* form, {@link import('./helpers.js').expandSteps}'d into one one-task phase per step);
|
|
942
|
-
* - a nested
|
|
971
|
+
* - a nested draft with any `id`/`name` omitted — {@link createWorkflowDraftContract}-parsed then
|
|
943
972
|
* {@link import('./helpers.js').completeDraft}'d (missing ids synthesized positionally);
|
|
944
973
|
* - the full nested {@link WorkflowDefinition} — the advanced escape-hatch, accepted as the draft
|
|
945
974
|
* super-set.
|
|
946
975
|
*
|
|
947
976
|
* The universal tool-handler contract: returns the plain run summary
|
|
948
|
-
* (`{ status, count, durable?, fault? }`) on success,
|
|
977
|
+
* (`{ status, count, durable?, fault? }`) on success, throws a typed `ToolboxError` on Toolbox
|
|
949
978
|
* boundary failures — malformed authored args (`TOOL`), or an over-deep / cyclic nested run
|
|
950
979
|
* (`DEPTH`) — and preserves genuine runner `WorkflowError`s. The `ToolManagerInterface` isolates every throw into the canonical tool result's
|
|
951
980
|
* top-level `error`, so nothing escapes the run. `options.lineage` is the propagation carrier
|
|
@@ -959,6 +988,34 @@ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface,
|
|
|
959
988
|
* @returns A `ToolInterface` (named {@link import('./constants.js').WORKFLOW_TOOL_NAME}) whose
|
|
960
989
|
* `parameters` advertise the flat authoring schema
|
|
961
990
|
*
|
|
991
|
+
* @example Authoring and running a workflow through the tool with a real ToolManager
|
|
992
|
+
* ```ts
|
|
993
|
+
* import { createWorkflowTool } from '@orkestrel/toolbox'
|
|
994
|
+
* import { createToolManager } from '@orkestrel/tool'
|
|
995
|
+
* import { createWorkflowRunner } from '@orkestrel/workflow'
|
|
996
|
+
* import type { WorkflowDefinition } from '@orkestrel/workflow'
|
|
997
|
+
*
|
|
998
|
+
* const definition: WorkflowDefinition = { id: 'release', name: 'Release', phases: [] }
|
|
999
|
+
* const runner = createWorkflowRunner()
|
|
1000
|
+
* const functions = {
|
|
1001
|
+
* compile: () => 'compiled',
|
|
1002
|
+
* publish: () => 'published',
|
|
1003
|
+
* }
|
|
1004
|
+
* const tool = createWorkflowTool(definition, runner, { functions })
|
|
1005
|
+
*
|
|
1006
|
+
* const tools = createToolManager()
|
|
1007
|
+
* tools.add(tool)
|
|
1008
|
+
*
|
|
1009
|
+
* // A small model authors the simple flat shape — no ids/names required.
|
|
1010
|
+
* const result = await tools.execute({
|
|
1011
|
+
* id: 'call-1',
|
|
1012
|
+
* name: 'workflow',
|
|
1013
|
+
* arguments: { name: 'release', steps: [{ name: 'compile' }, { name: 'publish' }] },
|
|
1014
|
+
* })
|
|
1015
|
+
* if (!result.success) throw new Error(result.error)
|
|
1016
|
+
* result.value // { status: 'completed', count: 2 } — the single-level envelope; no nested { id, name, value }
|
|
1017
|
+
* ```
|
|
1018
|
+
*
|
|
962
1019
|
* @example
|
|
963
1020
|
* ```ts
|
|
964
1021
|
* import { createWorkflowTool } from '@src/core'
|
|
@@ -975,42 +1032,35 @@ export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface,
|
|
|
975
1032
|
export declare function createWorkflowTool(definition: WorkflowDefinition, runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): ToolInterface;
|
|
976
1033
|
|
|
977
1034
|
/**
|
|
978
|
-
* Builds an LLM-callable workspace-editing tool — it
|
|
979
|
-
*
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
* returning the plain result. A malformed operation throws this package's `ToolboxError`; a
|
|
983
|
-
* genuine workspace-domain failure propagates `@orkestrel/workspace`'s typed `WorkspaceError`.
|
|
984
|
-
* EITHER drives a caller-supplied {@link WorkspaceToolOptions.manager} directly, OR
|
|
985
|
-
* constructs a fresh `WorkspaceManagerInterface` (`@orkestrel/workspace`) over
|
|
986
|
-
* {@link import('./types.js').WorkspaceToolOptions.store} (through `@orkestrel/workspace`'s
|
|
987
|
-
* `createWorkspaceManager`); neither given constructs a manager backed by
|
|
988
|
-
* `@orkestrel/workspace`'s in-memory store default.
|
|
1035
|
+
* Builds an LLM-callable workspace-editing tool — it advertises the `operation`-discriminated union
|
|
1036
|
+
* ({@link import('./shapers.js').workspaceToolShape}) as its `parameters`, and its handler parses
|
|
1037
|
+
* the model-supplied args against that contract and dispatches the matched operation against the
|
|
1038
|
+
* manager's active workspace, returning the plain result.
|
|
989
1039
|
*
|
|
990
1040
|
* @remarks
|
|
991
|
-
*
|
|
1041
|
+
* Manager-driven: every edit / read op (read / list / has / search / replace / write / splice /
|
|
992
1042
|
* prepend / append / move / remove) targets `manager.active`, so the model edits whichever
|
|
993
1043
|
* workspace is active and a host can re-point it (`WorkspaceManagerInterface.switch`) between
|
|
994
|
-
* turns.
|
|
1044
|
+
* turns. The registry ops make the model self-sufficient: `workspaces` lists the registered
|
|
995
1045
|
* workspaces (each `{ id, files, active }`) so it can discover an id, and `switch` re-points the
|
|
996
1046
|
* active workspace by id (lenient — an unknown id is a no-op reporting `switched: false`, never a
|
|
997
1047
|
* throw).
|
|
998
1048
|
*
|
|
999
|
-
*
|
|
1000
|
-
* remove / replace) run when `manager.active` is `undefined`
|
|
1001
|
-
* workspace (`manager.add()`) so the model can start writing; a pure-
|
|
1002
|
-
* has / search) against no active workspace returns the
|
|
1049
|
+
* No-active rule (the ergonomic seam): a writing op (write / splice / prepend / append / move /
|
|
1050
|
+
* remove / replace) run when `manager.active` is `undefined` auto-creates and activates a default
|
|
1051
|
+
* workspace (`manager.add()`) so the model can start writing; a pure-read op (read / list /
|
|
1052
|
+
* has / search) against no active workspace returns the empty result (`undefined` / `[]` /
|
|
1003
1053
|
* `false`), never creating one and never throwing.
|
|
1004
1054
|
*
|
|
1005
1055
|
* The handler conforms to the universal tool-handler contract: it `contract.parse`s
|
|
1006
|
-
* the args,
|
|
1007
|
-
* operation), else `switch`es on `op.operation` and
|
|
1056
|
+
* the args, throws a `TOOL` `ToolboxError` when no operation arm matched (a malformed / unknown
|
|
1057
|
+
* operation), else `switch`es on `op.operation` and returns the plain result — letting a
|
|
1008
1058
|
* `WorkspaceError` raised by the live workspace (`MISSING` / `MODALITY` / `PATTERN` / `RANGE`)
|
|
1009
|
-
*
|
|
1059
|
+
* propagate uncaught. The range edit is the flat `'splice'` op: its flat caret integers are
|
|
1010
1060
|
* reassembled into a `Range` (`@orkestrel/workspace`) by `rangeOf` and fed to the workspace's
|
|
1011
1061
|
* ranged `write`.
|
|
1012
1062
|
*
|
|
1013
|
-
* @param options - `manager` (drive directly)
|
|
1063
|
+
* @param options - `manager` (drive directly) or `store` (build a manager over it); neither ⇒
|
|
1014
1064
|
* an in-memory-backed manager (see {@link import('./types.js').WorkspaceToolOptions})
|
|
1015
1065
|
* @returns A `ToolInterface` (named {@link import('./constants.js').WORKSPACE_TOOL_NAME} by default)
|
|
1016
1066
|
*
|
|
@@ -1028,44 +1078,54 @@ export declare function createWorkspaceTool(options?: WorkspaceToolOptions): Too
|
|
|
1028
1078
|
|
|
1029
1079
|
/**
|
|
1030
1080
|
* Holds the description {@link import('./factories.js').createDatabaseTool} advertises — a
|
|
1031
|
-
* multi-line guide that teaches a small model the operation list, the
|
|
1081
|
+
* multi-line guide that teaches a small model the operation list, the serialized query form, and
|
|
1032
1082
|
* the {@link import('./types.js').TableSpec} column DSL.
|
|
1033
1083
|
*
|
|
1034
1084
|
* @remarks
|
|
1035
|
-
* The query form is deliberately
|
|
1036
|
-
* `{ column, operator, values, connector? }` where `values` is
|
|
1085
|
+
* The query form is deliberately serialized (never fluent) — every condition is a flat object
|
|
1086
|
+
* `{ column, operator, values, connector? }` where `values` is always an array, even for a
|
|
1037
1087
|
* single-value operator (`{ column: 'age', operator: 'from', values: [18] }`), so a small model
|
|
1038
1088
|
* never has to chain method calls or guess whether a value is scalar or a list.
|
|
1039
1089
|
*/
|
|
1040
1090
|
export declare const DATABASE_TOOL_DESCRIPTION: string;
|
|
1041
1091
|
|
|
1042
|
-
/**
|
|
1092
|
+
/**
|
|
1093
|
+
* Holds the default cap on rows a `records` call returns when the caller omits `query.limit`,
|
|
1094
|
+
* `1000` — the database tool's default row ceiling.
|
|
1095
|
+
*/
|
|
1043
1096
|
export declare const DATABASE_TOOL_LIMIT = 1000;
|
|
1044
1097
|
|
|
1045
1098
|
/** Lists the runtime-frozen database-tool mutation names disabled by `DatabaseToolOptions.readonly`. */
|
|
1046
1099
|
export declare const DATABASE_TOOL_MUTATIONS: readonly string[];
|
|
1047
1100
|
|
|
1048
1101
|
/**
|
|
1049
|
-
* Holds the name {@link import('./factories.js').createDatabaseTool} advertises by default
|
|
1050
|
-
* a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
1102
|
+
* Holds the name {@link import('./factories.js').createDatabaseTool} advertises by default,
|
|
1103
|
+
* `'database'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
1104
|
+
* under.
|
|
1051
1105
|
*/
|
|
1052
1106
|
export declare const DATABASE_TOOL_NAME = "database";
|
|
1053
1107
|
|
|
1054
1108
|
/**
|
|
1055
1109
|
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
1056
1110
|
* {@link import('./factories.js').createDatabaseTool} advertises in place of
|
|
1057
|
-
* {@link DATABASE_TOOL_DESCRIPTION}
|
|
1111
|
+
* {@link DATABASE_TOOL_DESCRIPTION} — one sentence offering the `operation`-keyed database call and
|
|
1112
|
+
* pointing at `describe` for the operation list, the query form, and the column DSL.
|
|
1113
|
+
*
|
|
1114
|
+
* @remarks
|
|
1115
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
1116
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
1117
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
1058
1118
|
*/
|
|
1059
1119
|
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.";
|
|
1060
1120
|
|
|
1061
1121
|
/**
|
|
1062
|
-
* Represents one database's
|
|
1063
|
-
* `primary`, `indexes`, and `version` schema configuration.
|
|
1122
|
+
* Represents one database's config-only definition — an `id`, a `driver`, and a {@link TableSpec},
|
|
1123
|
+
* with optional `primary`, `indexes`, and `version` schema configuration.
|
|
1064
1124
|
*
|
|
1065
1125
|
* @remarks
|
|
1066
|
-
* A `DatabaseDefinition` is
|
|
1126
|
+
* A `DatabaseDefinition` is never a live handle — it is the durable, serializable config a
|
|
1067
1127
|
* {@link DefinitionStoreInterface} persists and a tool factory turns into a real
|
|
1068
|
-
* `@orkestrel/database` `DatabaseInterface` (through `createDatabase`
|
|
1128
|
+
* `@orkestrel/database` `DatabaseInterface` (through `createDatabase` and {@link import('./compilers.js').expandTables})
|
|
1069
1129
|
* on demand. `primary` maps table names to primary-key columns; `indexes` maps table names to
|
|
1070
1130
|
* index column groups; `version` opts a capable driver into open-time schema reconciliation.
|
|
1071
1131
|
*/
|
|
@@ -1078,7 +1138,7 @@ export declare interface DatabaseDefinition {
|
|
|
1078
1138
|
readonly version?: number;
|
|
1079
1139
|
}
|
|
1080
1140
|
|
|
1081
|
-
/** Represents one opaque persisted row — the shape a `TableInterface
|
|
1141
|
+
/** 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. */
|
|
1082
1142
|
export declare interface DatabaseDefinitionRow {
|
|
1083
1143
|
readonly id: string;
|
|
1084
1144
|
readonly definition: unknown;
|
|
@@ -1086,25 +1146,25 @@ export declare interface DatabaseDefinitionRow {
|
|
|
1086
1146
|
|
|
1087
1147
|
/**
|
|
1088
1148
|
* Represents a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
|
|
1089
|
-
* database's durable
|
|
1149
|
+
* database's durable config state is a row, so persistence reduces to keyed point-access
|
|
1090
1150
|
* (`get` / `set` / `delete`) over a {@link TableInterface}, the driver-pluggable twin of the
|
|
1091
1151
|
* plain-`Map` {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}.
|
|
1092
1152
|
*
|
|
1093
1153
|
* @remarks
|
|
1094
1154
|
* The store is driver-agnostic: it holds a single {@link TableInterface} whose backend (memory,
|
|
1095
1155
|
* JSON, SQLite, IndexedDB) is chosen by whoever builds it (the factories), so a JSON / SQLite /
|
|
1096
|
-
* IndexedDB backend swaps in
|
|
1156
|
+
* IndexedDB backend swaps in without touching a consumer — the same seam as
|
|
1097
1157
|
* {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}. The driver defaults to
|
|
1098
1158
|
* memory ({@link import('../factories.js').createDatabaseDefinitionStore} passes
|
|
1099
|
-
* `createMemoryDriver()`), so it
|
|
1159
|
+
* `createMemoryDriver()`), so it also works in memory out of the box; you opt into the durable
|
|
1100
1160
|
* plumbing by passing a JSON / SQLite / IndexedDB driver.
|
|
1101
1161
|
*
|
|
1102
|
-
* The {@link DatabaseDefinition} is stored as
|
|
1103
|
-
* `{ id; definition }` ({@link DatabaseDefinitionRow}). The definition is already a
|
|
1104
|
-
* self-contained, pure-JSON
|
|
1105
|
-
*
|
|
1162
|
+
* The {@link DatabaseDefinition} is stored as one opaque JSON column — the table is a row of
|
|
1163
|
+
* `{ id; definition }` ({@link DatabaseDefinitionRow}). The definition is already a complete,
|
|
1164
|
+
* self-contained, pure-JSON config payload (never a live handle), so storing it whole is lossless
|
|
1165
|
+
* and keeps the row type flat (`definition` reads back as `unknown`).
|
|
1106
1166
|
*
|
|
1107
|
-
* - **`set(definition)` upserts under the definition's
|
|
1167
|
+
* - **`set(definition)` upserts under the definition's own `id`** (no separate id param) — it
|
|
1108
1168
|
* writes the row `{ id: definition.id, definition }`.
|
|
1109
1169
|
* - **`get(id)` resolves the stored definition for an id**, narrowing the opaque JSON column back
|
|
1110
1170
|
* to a {@link DatabaseDefinition} ({@link import('../validators.js').isDatabaseDefinition} — the
|
|
@@ -1112,7 +1172,7 @@ export declare interface DatabaseDefinitionRow {
|
|
|
1112
1172
|
* or the stored blob is malformed.
|
|
1113
1173
|
* - **`delete(id)` drops a definition by id**; an absent id is a no-op (no throw).
|
|
1114
1174
|
*
|
|
1115
|
-
* The public surface is
|
|
1175
|
+
* The public surface is exactly `get` / `set` / `delete` — no extra members (the method
|
|
1116
1176
|
* bijection with {@link DefinitionStoreInterface}).
|
|
1117
1177
|
*
|
|
1118
1178
|
* @example
|
|
@@ -1144,30 +1204,29 @@ export declare class DatabaseDefinitionStore implements DefinitionStoreInterface
|
|
|
1144
1204
|
*/
|
|
1145
1205
|
get(id: string): Promise<DatabaseDefinition | undefined>;
|
|
1146
1206
|
/**
|
|
1147
|
-
* Inserts or replaces a definition under its
|
|
1207
|
+
* Inserts or replaces a definition under its own `id` — the written row is `{ id, definition }`.
|
|
1148
1208
|
*
|
|
1149
1209
|
* @param definition - The config to persist; its own `id` is the row key (no separate id param)
|
|
1150
|
-
* @returns A promise settling
|
|
1210
|
+
* @returns A promise settling after the row is written
|
|
1151
1211
|
*/
|
|
1152
1212
|
set(definition: DatabaseDefinition): Promise<void>;
|
|
1153
1213
|
/**
|
|
1154
1214
|
* Drops the definition stored under `id`.
|
|
1155
1215
|
*
|
|
1156
1216
|
* @param id - The database id to drop; an absent id is a no-op, never a throw
|
|
1157
|
-
* @returns A promise settling
|
|
1217
|
+
* @returns A promise settling after no row is stored under `id`
|
|
1158
1218
|
*/
|
|
1159
1219
|
delete(id: string): Promise<void>;
|
|
1160
1220
|
}
|
|
1161
1221
|
|
|
1162
1222
|
/**
|
|
1163
|
-
* Represents the
|
|
1164
|
-
* {@link import('./shapers.js').queryShape}, which
|
|
1165
|
-
*
|
|
1166
|
-
* {@link QueryInput}.
|
|
1223
|
+
* Represents the serialized wire query a database-tool call carries — the parsed form of
|
|
1224
|
+
* {@link import('./shapers.js').queryShape}, which {@link import('./helpers.js').normalizeQuery}
|
|
1225
|
+
* normalizes into a live `@orkestrel/database` `QueryInput`.
|
|
1167
1226
|
*
|
|
1168
1227
|
* @remarks
|
|
1169
|
-
* Every condition is
|
|
1170
|
-
* `connector` is optional because the
|
|
1228
|
+
* Every condition is flat and its `values` is always an array, even for a single-value operator.
|
|
1229
|
+
* `connector` is optional because the last condition joins nothing forward; `normalizeQuery` defaults an
|
|
1171
1230
|
* omitted one to `'and'`. `order` / `limit` / `offset` carry over to the live query unchanged.
|
|
1172
1231
|
*/
|
|
1173
1232
|
export declare interface DatabaseQueryInput {
|
|
@@ -1186,7 +1245,8 @@ export declare interface DatabaseQueryInput {
|
|
|
1186
1245
|
}
|
|
1187
1246
|
|
|
1188
1247
|
/**
|
|
1189
|
-
* Resolves database
|
|
1248
|
+
* Resolves a database definition into a cached live handle for a database tool, over the tool's
|
|
1249
|
+
* live handles, its stored definitions, its driver registry, and an optional key generator.
|
|
1190
1250
|
*
|
|
1191
1251
|
* @example
|
|
1192
1252
|
* ```ts
|
|
@@ -1237,7 +1297,8 @@ export declare class DatabaseResolver {
|
|
|
1237
1297
|
*/
|
|
1238
1298
|
delete(id: string): void;
|
|
1239
1299
|
/**
|
|
1240
|
-
* Resolves a cached
|
|
1300
|
+
* Resolves a live database by id — the cached handle when one exists, otherwise a database
|
|
1301
|
+
* constructed from its stored definition.
|
|
1241
1302
|
*
|
|
1242
1303
|
* @param id - Database definition id
|
|
1243
1304
|
* @returns The cached or newly constructed live database
|
|
@@ -1254,7 +1315,7 @@ export declare class DatabaseResolver {
|
|
|
1254
1315
|
* caller-constructed database it manages alongside store-backed ones); keyed by the id a
|
|
1255
1316
|
* call's `id` field addresses.
|
|
1256
1317
|
* - `store` — the {@link DefinitionStoreInterface} the `'create'` operation persists its
|
|
1257
|
-
* {@link DatabaseDefinition}
|
|
1318
|
+
* {@link DatabaseDefinition} config through, and `'destroy'` deletes from; also the source
|
|
1258
1319
|
* `'get'`/every other operation resolves an id from when it isn't already cached. Omitted means
|
|
1259
1320
|
* no persistence — a database created without a store lives only for the tool's lifetime.
|
|
1260
1321
|
* - `drivers` — registry of driver-name to `() => DriverInterface` factories a `'create'` call's
|
|
@@ -1291,9 +1352,8 @@ export declare interface DatabaseToolOptions {
|
|
|
1291
1352
|
|
|
1292
1353
|
/**
|
|
1293
1354
|
* Describes the shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
|
|
1294
|
-
* discriminated by `operation` into the
|
|
1295
|
-
* `'
|
|
1296
|
-
* `'remove'` / `'destroy'`).
|
|
1355
|
+
* discriminated by `operation` into the database operations `'create'`, `'tables'`, `'get'`,
|
|
1356
|
+
* `'records'`, `'count'`, `'aggregate'`, `'add'`, `'set'`, `'update'`, `'remove'`, and `'destroy'`.
|
|
1297
1357
|
*
|
|
1298
1358
|
* @remarks
|
|
1299
1359
|
* Every arm carries `id` (the database id). `'create'` carries `tables` (the
|
|
@@ -1301,120 +1361,123 @@ export declare interface DatabaseToolOptions {
|
|
|
1301
1361
|
* {@link import('./compilers.js').expandTables}); `'get'` / `'update'` / `'remove'` carry `key`
|
|
1302
1362
|
* (one key or an array of keys, positional); `'add'` / `'set'` carry `row` (one row or an array of
|
|
1303
1363
|
* rows); `'update'` also carries `changes` (a loose partial row); `'records'` / `'count'` /
|
|
1304
|
-
* `'aggregate'` carry an optional `query` (the
|
|
1364
|
+
* `'aggregate'` carry an optional `query` (the serialized form — `values` is always an array,
|
|
1305
1365
|
* even for a single-value operator, so a caller never chains method calls or guesses arity).
|
|
1306
1366
|
*/
|
|
1307
|
-
export declare const databaseToolShape: UnionShape<readonly [
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
}, false>, ObjectShape<{
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
}, false>, ObjectShape<{
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
}, false>, ObjectShape<{
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
}, false>, ObjectShape<{
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}, false>, ObjectShape<{
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
}, false>, ObjectShape<{
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
}, false>, ObjectShape<{
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
}, false>, ObjectShape<{
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}, false>, ObjectShape<{
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
}, false>, ObjectShape<{
|
|
1406
|
-
|
|
1407
|
-
|
|
1367
|
+
export declare const databaseToolShape: UnionShape<readonly [ObjectShape< {
|
|
1368
|
+
operation: LiteralShape<readonly ["create"]>;
|
|
1369
|
+
id: StringShape;
|
|
1370
|
+
tables: ObjectShape<Record<never, never>, ObjectShape< {
|
|
1371
|
+
columns: ObjectShape<Record<never, never>, UnionShape<readonly [LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape< {
|
|
1372
|
+
primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
1373
|
+
optional: OptionalShape<BooleanShape>;
|
|
1374
|
+
}, false>]>>;
|
|
1375
|
+
}, false>>;
|
|
1376
|
+
driver: OptionalShape<StringShape>;
|
|
1377
|
+
primary: OptionalShape<ObjectShape<Record<never, never>, StringShape>>;
|
|
1378
|
+
indexes: OptionalShape<ObjectShape<Record<never, never>, ArrayShape<ArrayShape<StringShape>>>>;
|
|
1379
|
+
version: OptionalShape<NumberShape>;
|
|
1380
|
+
}, false>, ObjectShape< {
|
|
1381
|
+
operation: LiteralShape<readonly ["tables"]>;
|
|
1382
|
+
id: StringShape;
|
|
1383
|
+
}, false>, ObjectShape< {
|
|
1384
|
+
operation: LiteralShape<readonly ["get"]>;
|
|
1385
|
+
id: StringShape;
|
|
1386
|
+
table: StringShape;
|
|
1387
|
+
key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1388
|
+
}, false>, ObjectShape< {
|
|
1389
|
+
operation: LiteralShape<readonly ["records"]>;
|
|
1390
|
+
id: StringShape;
|
|
1391
|
+
table: StringShape;
|
|
1392
|
+
query: OptionalShape<ObjectShape< {
|
|
1393
|
+
conditions: OptionalShape<ArrayShape<ObjectShape< {
|
|
1394
|
+
column: StringShape;
|
|
1395
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1396
|
+
values: ArrayShape<JSONShape>;
|
|
1397
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1398
|
+
}, false>>>;
|
|
1399
|
+
order: OptionalShape<ArrayShape<ObjectShape< {
|
|
1400
|
+
column: StringShape;
|
|
1401
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1402
|
+
}, false>>>;
|
|
1403
|
+
limit: OptionalShape<NumberShape>;
|
|
1404
|
+
offset: OptionalShape<NumberShape>;
|
|
1405
|
+
}, false>>;
|
|
1406
|
+
}, false>, ObjectShape< {
|
|
1407
|
+
operation: LiteralShape<readonly ["count"]>;
|
|
1408
|
+
id: StringShape;
|
|
1409
|
+
table: StringShape;
|
|
1410
|
+
query: OptionalShape<ObjectShape< {
|
|
1411
|
+
conditions: OptionalShape<ArrayShape<ObjectShape< {
|
|
1412
|
+
column: StringShape;
|
|
1413
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1414
|
+
values: ArrayShape<JSONShape>;
|
|
1415
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1416
|
+
}, false>>>;
|
|
1417
|
+
order: OptionalShape<ArrayShape<ObjectShape< {
|
|
1418
|
+
column: StringShape;
|
|
1419
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1420
|
+
}, false>>>;
|
|
1421
|
+
limit: OptionalShape<NumberShape>;
|
|
1422
|
+
offset: OptionalShape<NumberShape>;
|
|
1423
|
+
}, false>>;
|
|
1424
|
+
}, false>, ObjectShape< {
|
|
1425
|
+
operation: LiteralShape<readonly ["aggregate"]>;
|
|
1426
|
+
id: StringShape;
|
|
1427
|
+
table: StringShape;
|
|
1428
|
+
function: LiteralShape<readonly ["count", "sum", "average", "minimum", "maximum"]>;
|
|
1429
|
+
column: StringShape;
|
|
1430
|
+
query: OptionalShape<ObjectShape< {
|
|
1431
|
+
conditions: OptionalShape<ArrayShape<ObjectShape< {
|
|
1432
|
+
column: StringShape;
|
|
1433
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1434
|
+
values: ArrayShape<JSONShape>;
|
|
1435
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1436
|
+
}, false>>>;
|
|
1437
|
+
order: OptionalShape<ArrayShape<ObjectShape< {
|
|
1438
|
+
column: StringShape;
|
|
1439
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1440
|
+
}, false>>>;
|
|
1441
|
+
limit: OptionalShape<NumberShape>;
|
|
1442
|
+
offset: OptionalShape<NumberShape>;
|
|
1443
|
+
}, false>>;
|
|
1444
|
+
}, false>, ObjectShape< {
|
|
1445
|
+
operation: LiteralShape<readonly ["add"]>;
|
|
1446
|
+
id: StringShape;
|
|
1447
|
+
table: StringShape;
|
|
1448
|
+
row: UnionShape<readonly [ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
|
|
1449
|
+
}, false>, ObjectShape< {
|
|
1450
|
+
operation: LiteralShape<readonly ["set"]>;
|
|
1451
|
+
id: StringShape;
|
|
1452
|
+
table: StringShape;
|
|
1453
|
+
row: UnionShape<readonly [ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
|
|
1454
|
+
}, false>, ObjectShape< {
|
|
1455
|
+
operation: LiteralShape<readonly ["update"]>;
|
|
1456
|
+
id: StringShape;
|
|
1457
|
+
table: StringShape;
|
|
1458
|
+
key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1459
|
+
changes: ObjectShape<Record<never, never>, JSONShape>;
|
|
1460
|
+
}, false>, ObjectShape< {
|
|
1461
|
+
operation: LiteralShape<readonly ["remove"]>;
|
|
1462
|
+
id: StringShape;
|
|
1463
|
+
table: StringShape;
|
|
1464
|
+
key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1465
|
+
}, false>, ObjectShape< {
|
|
1466
|
+
operation: LiteralShape<readonly ["destroy"]>;
|
|
1467
|
+
id: StringShape;
|
|
1408
1468
|
}, false>]>;
|
|
1409
1469
|
|
|
1410
1470
|
/**
|
|
1411
|
-
* Represents the point-access persistence seam for {@link DatabaseDefinition} configs —
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1471
|
+
* Represents the point-access persistence seam for {@link DatabaseDefinition} configs — the twin of
|
|
1472
|
+
* `@orkestrel/terminal`'s `TerminalStoreInterface`, storing a database's config-only blueprint
|
|
1473
|
+
* rather than a live handle. Every primitive is async; `delete` of an absent id is a no-op.
|
|
1414
1474
|
*/
|
|
1415
1475
|
export declare interface DefinitionStoreInterface {
|
|
1476
|
+
/** Resolves the persisted definition for `id`, or `undefined` when none is stored. */
|
|
1416
1477
|
get(id: string): Promise<DatabaseDefinition | undefined>;
|
|
1478
|
+
/** Inserts or replaces a definition under its own `id`, taking no separate id argument. */
|
|
1417
1479
|
set(definition: DatabaseDefinition): Promise<void>;
|
|
1480
|
+
/** Drops the definition for `id`, treating an absent id as a no-op that never throws. */
|
|
1418
1481
|
delete(id: string): Promise<void>;
|
|
1419
1482
|
}
|
|
1420
1483
|
|
|
@@ -1427,7 +1490,8 @@ export declare interface DefinitionStoreInterface {
|
|
|
1427
1490
|
export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
|
|
1428
1491
|
|
|
1429
1492
|
/**
|
|
1430
|
-
* Holds the
|
|
1493
|
+
* Holds the description {@link import('./factories.js').createDescribeTool} advertises — the
|
|
1494
|
+
* registered tool `name` it requires, and the full description of that tool it returns.
|
|
1431
1495
|
*
|
|
1432
1496
|
* @remarks
|
|
1433
1497
|
* Deliberately short — unlike the workflow / workspace / agent tools, this one has no authoring
|
|
@@ -1436,8 +1500,9 @@ export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
|
|
|
1436
1500
|
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).";
|
|
1437
1501
|
|
|
1438
1502
|
/**
|
|
1439
|
-
* Holds the name {@link import('./factories.js').createDescribeTool} advertises by default
|
|
1440
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
1503
|
+
* Holds the name {@link import('./factories.js').createDescribeTool} advertises by default,
|
|
1504
|
+
* `'describe'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
1505
|
+
* under.
|
|
1441
1506
|
*
|
|
1442
1507
|
* @remarks
|
|
1443
1508
|
* Pairs with the lean {@link AGENT_TOOL_SUMMARY} / {@link WORKFLOW_TOOL_SUMMARY} /
|
|
@@ -1455,8 +1520,8 @@ export declare const DESCRIBE_TOOL_NAME = "describe";
|
|
|
1455
1520
|
export declare const DESCRIBE_TOOL_SUMMARY = "Return the full description of a named registered tool.";
|
|
1456
1521
|
|
|
1457
1522
|
/**
|
|
1458
|
-
* Represents the
|
|
1459
|
-
* tool `name` whose full `description` a model wants back.
|
|
1523
|
+
* Represents the flat args {@link import('./factories.js').createDescribeTool} accepts — the
|
|
1524
|
+
* registered tool `name` whose full `description` a model wants back.
|
|
1460
1525
|
*
|
|
1461
1526
|
* @remarks
|
|
1462
1527
|
* `name` must match a tool registered on the {@link import('@orkestrel/tool').ToolManagerInterface}
|
|
@@ -1473,8 +1538,8 @@ export declare interface DescribeToolArguments {
|
|
|
1473
1538
|
* @remarks
|
|
1474
1539
|
* `name` is the only field (a non-empty string) — the registered tool name to look up.
|
|
1475
1540
|
*/
|
|
1476
|
-
export declare const describeToolShape: ObjectShape<{
|
|
1477
|
-
|
|
1541
|
+
export declare const describeToolShape: ObjectShape< {
|
|
1542
|
+
name: StringShape;
|
|
1478
1543
|
}, false>;
|
|
1479
1544
|
|
|
1480
1545
|
/**
|
|
@@ -1483,17 +1548,17 @@ export declare const describeToolShape: ObjectShape<{
|
|
|
1483
1548
|
* `parameters` are inferred from, and the local handler that runs a call.
|
|
1484
1549
|
*
|
|
1485
1550
|
* @remarks
|
|
1486
|
-
* `samples`
|
|
1487
|
-
* typed `TOOL` {@link import('./errors.js').ToolboxError} at
|
|
1488
|
-
*
|
|
1489
|
-
* `true`) `execute` receives the
|
|
1551
|
+
* `samples` must be non-empty — {@link import('./factories.js').createEndpointTool} throws a
|
|
1552
|
+
* typed `TOOL` {@link import('./errors.js').ToolboxError} at construction when it is empty,
|
|
1553
|
+
* because an empty sample set cannot infer a schema. By default ({@link EndpointToolOptions.validate}
|
|
1554
|
+
* `true`) `execute` receives the parsed, normalized args record — a copy of the model-supplied
|
|
1490
1555
|
* `args` with each scalar coerced to its inferred type (for example a number sent for a string slot
|
|
1491
1556
|
* arrives coerced to a string), checked against the same schema advertised as `parameters` — and
|
|
1492
1557
|
* a call with a missing required key or a non-coercible value never reaches `execute` at all (see
|
|
1493
1558
|
* {@link EndpointToolOptions.validate}). With
|
|
1494
|
-
* `validate: false`, `execute` receives the model-supplied `args`
|
|
1559
|
+
* `validate: false`, `execute` receives the model-supplied `args` verbatim (raw passthrough, never
|
|
1495
1560
|
* checked against the inferred schema). Either way `execute`'s return flows back as the tool
|
|
1496
|
-
* call's result; a throw
|
|
1561
|
+
* call's result; a throw propagates uncaught, isolated by the `ToolManagerInterface`
|
|
1497
1562
|
* (`@orkestrel/tool`) into the canonical error envelope. When `samples` are non-object values,
|
|
1498
1563
|
* the advertised schema wraps them under a single required `value` property, so `execute` receives
|
|
1499
1564
|
* an `args` record of the shape `{ value: ... }` — never the bare value.
|
|
@@ -1506,37 +1571,44 @@ export declare interface EndpointDefinition {
|
|
|
1506
1571
|
}
|
|
1507
1572
|
|
|
1508
1573
|
/**
|
|
1509
|
-
* Represents the handler {@link
|
|
1510
|
-
* `@orkestrel/tool`'s `ToolOptions.execute` signature
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1574
|
+
* Represents the handler {@link EndpointDefinition.execute} implements — it mirrors
|
|
1575
|
+
* `@orkestrel/tool`'s `ToolOptions.execute` signature exactly, so
|
|
1576
|
+
* {@link import('./factories.js').createEndpointTool} forwards the execution context it receives
|
|
1577
|
+
* to the handler unchanged and a handler that reads `context.signal` observes the caller's
|
|
1578
|
+
* cancellation.
|
|
1579
|
+
*
|
|
1580
|
+
* @remarks
|
|
1581
|
+
* The mirrored signature is the same `Readonly<Record<string, unknown>>` argument, the same
|
|
1582
|
+
* `ToolContext` second parameter, and the same `Promise<unknown> | unknown` return. A handler that
|
|
1583
|
+
* declares `args` alone still satisfies the type, the way a function declaring fewer parameters
|
|
1584
|
+
* than its contract does, so an endpoint definition written against the argument alone keeps
|
|
1585
|
+
* typechecking and reads no signal.
|
|
1514
1586
|
*/
|
|
1515
|
-
export declare type EndpointHandler = (args: Readonly<Record<string, unknown
|
|
1587
|
+
export declare type EndpointHandler = (args: Readonly<Record<string, unknown>>, context: ToolContext) => Promise<unknown> | unknown;
|
|
1516
1588
|
|
|
1517
1589
|
/**
|
|
1518
|
-
* Represents the construction-time tuning for {@link import('./factories.js').createEndpointTool} —
|
|
1519
|
-
* inferred `parameters` schema's `format`
|
|
1520
|
-
*
|
|
1590
|
+
* Represents the construction-time tuning for {@link import('./factories.js').createEndpointTool} —
|
|
1591
|
+
* the inferred `parameters` schema's `format` and `enum` constraints, and whether that same schema
|
|
1592
|
+
* is enforced at `execute` time.
|
|
1521
1593
|
*
|
|
1522
1594
|
* @remarks
|
|
1523
1595
|
* `format` / `enum` default to `false`, matching `@orkestrel/contract`'s own
|
|
1524
1596
|
* `ValueToSchemaOptions` defaults. `validate` defaults to `true`: the schema
|
|
1525
|
-
* `createEndpointTool` advertises as `parameters` (`samplesToSchema`
|
|
1526
|
-
* compiled
|
|
1527
|
-
* `ContractInterface` used to `parse` every call's `args` before `execute` runs — a
|
|
1528
|
-
* parse: a scalar value is
|
|
1597
|
+
* `createEndpointTool` advertises as `parameters` (`samplesToSchema` and `schemaToObject`) is
|
|
1598
|
+
* compiled once at construction (through `@orkestrel/contract`'s `schemaToShape`) into a
|
|
1599
|
+
* `ContractInterface` used to `parse` every call's `args` before `execute` runs — a normalizing
|
|
1600
|
+
* parse: a scalar value is coerced to its inferred type where the house parsers coerce (a number
|
|
1529
1601
|
* to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/`'false'`/`1`/`0`), so `execute`
|
|
1530
|
-
* receives the
|
|
1602
|
+
* receives the coerced values (for example `7` sent for a string slot arrives at `execute` as `'7'`), not
|
|
1531
1603
|
* the raw call args. A call whose `args` fails to parse — a required key missing, or a value not
|
|
1532
|
-
* coercible to its slot's type —
|
|
1604
|
+
* coercible to its slot's type — throws a typed `TOOL` {@link import('./errors.js').ToolboxError}
|
|
1533
1605
|
* carrying the structured `explain` faults, and `execute` is never called. Beyond that coercion,
|
|
1534
|
-
* enforcement is
|
|
1535
|
-
* annotations (`email`, `date-time`, `uuid`, `uri`, ...) are
|
|
1606
|
+
* enforcement is structural — required keys, `enum` membership, and numeric bounds — `format`
|
|
1607
|
+
* annotations (`email`, `date-time`, `uuid`, `uri`, ...) are never asserted, mirroring
|
|
1536
1608
|
* `@orkestrel/contract`'s own widening-only law for `schemaToShape`: a `format: true`-tuned
|
|
1537
|
-
* endpoint still
|
|
1538
|
-
* the inferred (closed, `additionalProperties: false`) schema is
|
|
1539
|
-
*
|
|
1609
|
+
* endpoint still accepts a non-conforming string in a format-tagged slot. A key not present in
|
|
1610
|
+
* the inferred (closed, `additionalProperties: false`) schema is never a rejection either — it is
|
|
1611
|
+
* silently dropped before `execute` runs (the same leniency `@orkestrel/contract`'s own `parse`
|
|
1540
1612
|
* grants a closed object generally), so `execute` may see fewer keys than the caller sent. Set
|
|
1541
1613
|
* `validate: false` when the endpoint's own handler validates its arguments, or when `samples`
|
|
1542
1614
|
* under-describe the real contract and the normalizing coercion would corrupt a call: the tool's
|
|
@@ -1550,15 +1622,15 @@ export declare interface EndpointToolOptions {
|
|
|
1550
1622
|
}
|
|
1551
1623
|
|
|
1552
1624
|
/**
|
|
1553
|
-
* Expands the relation tool's
|
|
1625
|
+
* Expands the relation tool's flat dot-path `include` list into a live `@orkestrel/relation`
|
|
1554
1626
|
* {@link Include} tree — the pure leaf {@link import('./factories.js').createRelationTool} calls
|
|
1555
1627
|
* before a `'load'` / `'find'` call.
|
|
1556
1628
|
*
|
|
1557
1629
|
* @remarks
|
|
1558
1630
|
* Each path splits on `'.'` into a chain of relation names, deep-merged into one nested
|
|
1559
|
-
* `Include` object with a leaf `true`. A longer path
|
|
1631
|
+
* `Include` object with a leaf `true`. A longer path subsumes a shorter sibling's bare `true` —
|
|
1560
1632
|
* `'contacts'` followed by `'contacts.account'` yields `{ contacts: { account: true } }`, never
|
|
1561
|
-
* overwriting the deeper chain. An
|
|
1633
|
+
* overwriting the deeper chain. An empty segment (`''`, from a leading/trailing/doubled `.`) or a
|
|
1562
1634
|
* path whose segment count exceeds `depth` throws a typed `TOOL` {@link ToolboxError}.
|
|
1563
1635
|
*
|
|
1564
1636
|
* @param paths - The flat dot-path `include` list (or `undefined` — yields `{}`)
|
|
@@ -1577,18 +1649,18 @@ export declare function expandInclude(paths: readonly string[] | undefined, dept
|
|
|
1577
1649
|
|
|
1578
1650
|
/**
|
|
1579
1651
|
* Expands a flat {@link WorkflowSteps} blob into a strict {@link WorkflowDefinition} — each step
|
|
1580
|
-
* becomes a one-task phase,
|
|
1652
|
+
* becomes a one-task phase, in order.
|
|
1581
1653
|
*
|
|
1582
1654
|
* @remarks
|
|
1583
|
-
* The expansion of the tool's
|
|
1655
|
+
* The expansion of the tool's advertised surface: the deliberately-reduced flat form. Each
|
|
1584
1656
|
* {@link import('./types.js').WorkflowStep} maps to a phase holding exactly one task: the step's
|
|
1585
1657
|
* `name` becomes the task's `behavior` (the behavior-registry key). Ids/names are auto-filled
|
|
1586
1658
|
* positionally — it builds an ids-omitted {@link WorkflowDraft} and delegates to
|
|
1587
|
-
* {@link completeDraft}, so the
|
|
1659
|
+
* {@link completeDraft}, so the lenient surfaces share one synthesis path (step `i` → phase
|
|
1588
1660
|
* `phase-<i>`, its task `phase-<i>-task-0`). The optional `name` becomes both the workflow's
|
|
1589
1661
|
* deterministic id and its name, so named flat workflows retain distinct persistence keys;
|
|
1590
1662
|
* omission keeps the shared draft fallback `wf`. The result is a complete definition the caller
|
|
1591
|
-
* validates against the
|
|
1663
|
+
* validates against the strict contract before running.
|
|
1592
1664
|
*
|
|
1593
1665
|
* @param flat - The flat steps blob (`{ name?, steps: [{ name }] }`)
|
|
1594
1666
|
* @returns A complete {@link WorkflowDefinition} (one one-task phase per step)
|
|
@@ -1618,21 +1690,29 @@ export declare function extendLineage(lineage: WorkflowLineage, tag: string): Wo
|
|
|
1618
1690
|
/** Describes the flat dot-path relation include list, expanded through {@link import('./helpers.js').expandInclude}. */
|
|
1619
1691
|
export declare const includeShape: OptionalShape<ArrayShape<StringShape>>;
|
|
1620
1692
|
|
|
1621
|
-
/**
|
|
1693
|
+
/**
|
|
1694
|
+
* Holds the schema-inference protocol {@link import('./factories.js').createInferTool} advertises —
|
|
1695
|
+
* the required `samples`, the optional `format`, `enum`, and `candidates` arguments, and a worked
|
|
1696
|
+
* example of the bare return and of the `candidates`-wrapped return.
|
|
1697
|
+
*/
|
|
1622
1698
|
export declare const INFER_TOOL_DESCRIPTION: string;
|
|
1623
1699
|
|
|
1624
1700
|
/**
|
|
1625
|
-
* Holds the name {@link import('./factories.js').createInferTool} advertises by default
|
|
1626
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
1701
|
+
* Holds the name {@link import('./factories.js').createInferTool} advertises by default, `'infer'`
|
|
1702
|
+
* — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
1627
1703
|
*/
|
|
1628
1704
|
export declare const INFER_TOOL_NAME = "infer";
|
|
1629
1705
|
|
|
1630
1706
|
/**
|
|
1631
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
1632
|
-
*
|
|
1633
|
-
*
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
1707
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
1708
|
+
* {@link import('./factories.js').createInferTool} advertises in place of
|
|
1709
|
+
* {@link INFER_TOOL_DESCRIPTION} — one sentence offering schema inference from example values and
|
|
1710
|
+
* pointing at `describe` for the fields it takes.
|
|
1711
|
+
*
|
|
1712
|
+
* @remarks
|
|
1713
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
1714
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
1715
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
1636
1716
|
*/
|
|
1637
1717
|
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.";
|
|
1638
1718
|
|
|
@@ -1676,9 +1756,9 @@ export declare function inferRelationCode(error: unknown): RelationErrorCode | u
|
|
|
1676
1756
|
export declare function inferTerminalCode(error: unknown): ToolboxErrorCode | undefined;
|
|
1677
1757
|
|
|
1678
1758
|
/**
|
|
1679
|
-
* Represents the options for {@link import('./factories.js').createInferTool} — advertised name
|
|
1680
|
-
* overrides only; `format`
|
|
1681
|
-
* {@link import('./shapers.js').inferToolShape}), not construction-time options,
|
|
1759
|
+
* Represents the options for {@link import('./factories.js').createInferTool} — advertised name and
|
|
1760
|
+
* description overrides only; `format` and `enum` are runtime call arguments (see
|
|
1761
|
+
* {@link import('./shapers.js').inferToolShape}), not construction-time options, because a model
|
|
1682
1762
|
* chooses them per call.
|
|
1683
1763
|
*/
|
|
1684
1764
|
export declare interface InferToolOptions {
|
|
@@ -1695,15 +1775,15 @@ export declare interface InferToolOptions {
|
|
|
1695
1775
|
* `samples` requires at least one element (`min: 1`) — an empty array parses to `undefined`,
|
|
1696
1776
|
* surfaced by the handler as a typed `TOOL` {@link import('./errors.js').ToolboxError}. When
|
|
1697
1777
|
* `candidates` is present (any array, including empty), the handler compiles a contract from the
|
|
1698
|
-
* freshly inferred schema and checks each candidate against it with a
|
|
1699
|
-
* coercion) — the opposite of {@link import('./factories.js').createEndpointTool}'s
|
|
1778
|
+
* freshly inferred schema and checks each candidate against it with a strict guard (`.is`, no
|
|
1779
|
+
* coercion) — the opposite of {@link import('./factories.js').createEndpointTool}'s normalizing
|
|
1700
1780
|
* `.parse` enforcement.
|
|
1701
1781
|
*/
|
|
1702
|
-
export declare const inferToolShape: ObjectShape<{
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1782
|
+
export declare const inferToolShape: ObjectShape< {
|
|
1783
|
+
samples: ArrayShape<JSONShape>;
|
|
1784
|
+
format: OptionalShape<BooleanShape>;
|
|
1785
|
+
enum: OptionalShape<BooleanShape>;
|
|
1786
|
+
candidates: OptionalShape<ArrayShape<JSONShape>>;
|
|
1707
1787
|
}, false>;
|
|
1708
1788
|
|
|
1709
1789
|
/**
|
|
@@ -1731,7 +1811,7 @@ export declare function isColumnPrimitive(value: unknown): value is ColumnPrimit
|
|
|
1731
1811
|
export declare function isColumnSpec(value: unknown): value is ColumnSpec;
|
|
1732
1812
|
|
|
1733
1813
|
/**
|
|
1734
|
-
* Narrows an unknown value to a {@link DatabaseDefinition} — a non-empty `id`
|
|
1814
|
+
* Narrows an unknown value to a {@link DatabaseDefinition} — a non-empty `id` and `driver`, a
|
|
1735
1815
|
* `tables` record whose every value is `{ columns: record of valid ColumnSpec }`, plus optional
|
|
1736
1816
|
* `primary`, `indexes`, and finite `version` schema configuration. The boundary guard a
|
|
1737
1817
|
* {@link import('./types.js').DefinitionStoreInterface} applies to an untrusted persisted blob
|
|
@@ -1743,7 +1823,7 @@ export declare function isColumnSpec(value: unknown): value is ColumnSpec;
|
|
|
1743
1823
|
export declare function isDatabaseDefinition(value: unknown): value is DatabaseDefinition;
|
|
1744
1824
|
|
|
1745
1825
|
/**
|
|
1746
|
-
* Narrows an unknown caught value to
|
|
1826
|
+
* Narrows an unknown caught value to a {@link ToolboxError}.
|
|
1747
1827
|
*
|
|
1748
1828
|
* @param value - The value to test (typically a `catch` binding)
|
|
1749
1829
|
* @returns True if `value` is an {@link ToolboxError}; false otherwise
|
|
@@ -1769,14 +1849,18 @@ export declare function isToolboxError(value: unknown): value is ToolboxError;
|
|
|
1769
1849
|
*/
|
|
1770
1850
|
export declare function isWorkflowLineage(value: unknown): value is WorkflowLineage;
|
|
1771
1851
|
|
|
1772
|
-
/**
|
|
1773
|
-
|
|
1852
|
+
/**
|
|
1853
|
+
* Describes one key value for the database tool and the relation tool — a string or number; the
|
|
1854
|
+
* array form (multiple keys, positional) resolves first, so an array argument is read as many keys
|
|
1855
|
+
* rather than one.
|
|
1856
|
+
*/
|
|
1857
|
+
export declare const keyShape: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1774
1858
|
|
|
1775
1859
|
/** Describes which registered relation manager to address — omitted resolves to the sole registered manager. */
|
|
1776
1860
|
export declare const managerShape: OptionalShape<StringShape>;
|
|
1777
1861
|
|
|
1778
1862
|
/**
|
|
1779
|
-
* Holds the maximum nesting depth a workflow → agent → workflow chain may reach — the bound
|
|
1863
|
+
* Holds the maximum nesting depth a workflow → agent → workflow chain may reach, `8` — the bound
|
|
1780
1864
|
* {@link import('./factories.js').createAgentFunction} and
|
|
1781
1865
|
* {@link import('./factories.js').createWorkflowTool}'s depth/cycle guards enforce.
|
|
1782
1866
|
*
|
|
@@ -1789,7 +1873,7 @@ export declare const MAX_WORKFLOW_CHAIN = 8;
|
|
|
1789
1873
|
|
|
1790
1874
|
/**
|
|
1791
1875
|
* Represents the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
|
|
1792
|
-
* {@link DatabaseDefinition}s keyed by database id, the
|
|
1876
|
+
* {@link DatabaseDefinition}s keyed by database id, the default store
|
|
1793
1877
|
* {@link import('../factories.js').createMemoryDefinitionStore} builds. It implements the same
|
|
1794
1878
|
* {@link DefinitionStoreInterface} contract as
|
|
1795
1879
|
* {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore}: this store copies on
|
|
@@ -1798,19 +1882,19 @@ export declare const MAX_WORKFLOW_CHAIN = 8;
|
|
|
1798
1882
|
*
|
|
1799
1883
|
* @remarks
|
|
1800
1884
|
* A plain `Map<string, DatabaseDefinition>` (the definition is already pure,
|
|
1801
|
-
* self-contained
|
|
1802
|
-
* structured-cloned on both write and read, keeping caller mutation outside the store. There is
|
|
1803
|
-
* idle-TTL and
|
|
1804
|
-
* backend (JSON / SQLite / IndexedDB) swaps in through the
|
|
1885
|
+
* self-contained config-only JSON, so no encoding is needed for the memory tier). Values are
|
|
1886
|
+
* structured-cloned on both write and read, keeping caller mutation outside the store. There is no
|
|
1887
|
+
* idle-TTL and no eviction: a persisted definition lives until an explicit `delete`. A durable
|
|
1888
|
+
* backend (JSON / SQLite / IndexedDB) swaps in through the same interface without touching a
|
|
1805
1889
|
* consumer — its driver-pluggable twin is
|
|
1806
1890
|
* {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore} (the definition as one
|
|
1807
1891
|
* opaque JSON column).
|
|
1808
1892
|
*
|
|
1809
1893
|
* - **`get` resolves the persisted definition for an id**, or `undefined` if none is stored.
|
|
1810
|
-
* - **`set` inserts / replaces under the definition's
|
|
1894
|
+
* - **`set` inserts / replaces under the definition's own `id`** (no separate id param).
|
|
1811
1895
|
* - **`delete` drops a definition by id**; an absent id is a no-op (no throw).
|
|
1812
1896
|
*
|
|
1813
|
-
* The public surface is
|
|
1897
|
+
* The public surface is exactly `get` / `set` / `delete` — no extra members (the method
|
|
1814
1898
|
* bijection with {@link DefinitionStoreInterface}).
|
|
1815
1899
|
*
|
|
1816
1900
|
* @example
|
|
@@ -1833,17 +1917,17 @@ export declare class MemoryDefinitionStore implements DefinitionStoreInterface {
|
|
|
1833
1917
|
*/
|
|
1834
1918
|
get(id: string): Promise<DatabaseDefinition | undefined>;
|
|
1835
1919
|
/**
|
|
1836
|
-
* Inserts or replaces a definition under its
|
|
1920
|
+
* Inserts or replaces a definition under its own `id`, copied into the backing `Map`.
|
|
1837
1921
|
*
|
|
1838
1922
|
* @param definition - The config to persist; its own `id` is the key (no separate id param)
|
|
1839
|
-
* @returns A promise settling
|
|
1923
|
+
* @returns A promise settling after the definition is stored
|
|
1840
1924
|
*/
|
|
1841
1925
|
set(definition: DatabaseDefinition): Promise<void>;
|
|
1842
1926
|
/**
|
|
1843
1927
|
* Drops the definition stored under `id`.
|
|
1844
1928
|
*
|
|
1845
1929
|
* @param id - The database id to drop; an absent id is a no-op, never a throw
|
|
1846
|
-
* @returns A promise settling
|
|
1930
|
+
* @returns A promise settling after no definition is stored under `id`
|
|
1847
1931
|
*/
|
|
1848
1932
|
delete(id: string): Promise<void>;
|
|
1849
1933
|
}
|
|
@@ -1858,11 +1942,11 @@ export declare function normalizeLineage(lineage?: WorkflowLineage): WorkflowLin
|
|
|
1858
1942
|
|
|
1859
1943
|
/**
|
|
1860
1944
|
* Returns the canonical live `@orkestrel/database` {@link QueryInput} for the database tool's
|
|
1861
|
-
* parsed
|
|
1945
|
+
* parsed serialized query — each condition's omitted `connector` defaults to `'and'`.
|
|
1862
1946
|
*
|
|
1863
1947
|
* @remarks
|
|
1864
1948
|
* The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
|
|
1865
|
-
* on the last condition (it has nothing to join
|
|
1949
|
+
* on the last condition (it has nothing to join forward to); the compiled `Condition` a live
|
|
1866
1950
|
* `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
|
|
1867
1951
|
* `limit` / `offset` pass through unchanged. Pure and total.
|
|
1868
1952
|
*
|
|
@@ -1871,13 +1955,16 @@ export declare function normalizeLineage(lineage?: WorkflowLineage): WorkflowLin
|
|
|
1871
1955
|
*/
|
|
1872
1956
|
export declare function normalizeQuery(query: DatabaseQueryInput | undefined): QueryInput | undefined;
|
|
1873
1957
|
|
|
1874
|
-
/** Describes one sort term. */
|
|
1875
|
-
export declare const orderShape: ObjectShape<{
|
|
1876
|
-
|
|
1877
|
-
|
|
1958
|
+
/** Describes one sort term — a `column` to sort by and the `direction` to sort it in. */
|
|
1959
|
+
export declare const orderShape: ObjectShape< {
|
|
1960
|
+
column: StringShape;
|
|
1961
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1878
1962
|
}, false>;
|
|
1879
1963
|
|
|
1880
|
-
/**
|
|
1964
|
+
/**
|
|
1965
|
+
* Represents a draft phase — a `PhaseDefinition` (`@orkestrel/workflow`) with optional `id` and
|
|
1966
|
+
* `name` and {@link TaskDraft} tasks.
|
|
1967
|
+
*/
|
|
1881
1968
|
export declare interface PhaseDraft {
|
|
1882
1969
|
readonly id?: string;
|
|
1883
1970
|
readonly name?: string;
|
|
@@ -1885,45 +1972,53 @@ export declare interface PhaseDraft {
|
|
|
1885
1972
|
readonly tasks: readonly TaskDraft[];
|
|
1886
1973
|
/** Caps the tasks in flight at once (a resource throttle); omitted ⇒ unbounded. */
|
|
1887
1974
|
readonly concurrency?: number;
|
|
1888
|
-
/** Holds the per-phase failure-policy
|
|
1975
|
+
/** Holds the per-phase failure-policy override; omitted ⇒ inherits the workflow `bail`. */
|
|
1889
1976
|
readonly bail?: boolean;
|
|
1890
1977
|
}
|
|
1891
1978
|
|
|
1892
1979
|
/**
|
|
1893
|
-
* Describes the shape of a
|
|
1894
|
-
* `name` are
|
|
1895
|
-
*/
|
|
1896
|
-
export declare const phaseDraftShape: ObjectShape<{
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1980
|
+
* Describes the shape of a phase in a draft workflow — identical to a strict phase shape except
|
|
1981
|
+
* that `id` and `name` are optional and each task takes {@link taskDraftShape}.
|
|
1982
|
+
*/
|
|
1983
|
+
export declare const phaseDraftShape: ObjectShape< {
|
|
1984
|
+
id: OptionalShape<StringShape>;
|
|
1985
|
+
name: OptionalShape<StringShape>;
|
|
1986
|
+
description: OptionalShape<StringShape>;
|
|
1987
|
+
tasks: ArrayShape<ObjectShape< {
|
|
1988
|
+
id: OptionalShape<StringShape>;
|
|
1989
|
+
name: OptionalShape<StringShape>;
|
|
1990
|
+
description: OptionalShape<StringShape>;
|
|
1991
|
+
behavior: OptionalShape<StringShape>;
|
|
1992
|
+
retries: OptionalShape<NumberShape>;
|
|
1993
|
+
timeout: OptionalShape<NumberShape>;
|
|
1994
|
+
}, false>>;
|
|
1995
|
+
concurrency: OptionalShape<NumberShape>;
|
|
1996
|
+
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
1910
1997
|
}, false>;
|
|
1911
1998
|
|
|
1912
|
-
/**
|
|
1999
|
+
/**
|
|
2000
|
+
* Holds the form protocol {@link import('./factories.js').createPromptTool} advertises — the
|
|
2001
|
+
* required `to` and `schema`, how a field declares its control and its rules, and a worked
|
|
2002
|
+
* example.
|
|
2003
|
+
*/
|
|
1913
2004
|
export declare const PROMPT_TOOL_DESCRIPTION: string;
|
|
1914
2005
|
|
|
1915
2006
|
/**
|
|
1916
|
-
* Holds the name {@link import('./factories.js').createPromptTool} advertises by default —
|
|
1917
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
2007
|
+
* Holds the name {@link import('./factories.js').createPromptTool} advertises by default, `'ask'` —
|
|
2008
|
+
* the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
1918
2009
|
*/
|
|
1919
2010
|
export declare const PROMPT_TOOL_NAME = "ask";
|
|
1920
2011
|
|
|
1921
2012
|
/**
|
|
1922
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
1923
|
-
*
|
|
1924
|
-
*
|
|
1925
|
-
*
|
|
1926
|
-
*
|
|
2013
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2014
|
+
* {@link import('./factories.js').createPromptTool} advertises in place of
|
|
2015
|
+
* {@link PROMPT_TOOL_DESCRIPTION} — one sentence offering the blocking multi-field ask and pointing
|
|
2016
|
+
* at `describe` for the schema.
|
|
2017
|
+
*
|
|
2018
|
+
* @remarks
|
|
2019
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
2020
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
2021
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
1927
2022
|
*/
|
|
1928
2023
|
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.";
|
|
1929
2024
|
|
|
@@ -1934,10 +2029,10 @@ export declare const PROMPT_TOOL_SUMMARY = "Ask another terminal a multi-field f
|
|
|
1934
2029
|
*
|
|
1935
2030
|
* @remarks
|
|
1936
2031
|
* - `manager` — the terminal manager whose `ask(from, to, form)` the tool's handler calls with a
|
|
1937
|
-
* live `@orkestrel/form` form;
|
|
2032
|
+
* live `@orkestrel/form` form; blocks the calling agent turn until the addressed terminal answers (or the ask
|
|
1938
2033
|
* rejects — a cycle throws `TerminalError('DEADLOCK')`, re-surfaced as a typed `DEADLOCK`
|
|
1939
2034
|
* {@link import('./errors.js').ToolboxError}; an expired prompt re-surfaces as `EXPIRE`).
|
|
1940
|
-
* - `from` — the terminal identity this tool asks
|
|
2035
|
+
* - `from` — the terminal identity this tool asks as; the model supplies the `to` target and the
|
|
1941
2036
|
* complete form schema per call.
|
|
1942
2037
|
* - `name` / `description` — advertised tool overrides; default to
|
|
1943
2038
|
* {@link import('./constants.js').PROMPT_TOOL_NAME} / {@link import('./constants.js').PROMPT_TOOL_DESCRIPTION}.
|
|
@@ -1957,63 +2052,80 @@ export declare interface PromptToolOptions {
|
|
|
1957
2052
|
* The contract first requires exact JSON. The handler then delegates schema parsing and semantic
|
|
1958
2053
|
* validation to `@orkestrel/form`'s `parseForm`, so Toolbox does not duplicate the form schema.
|
|
1959
2054
|
*/
|
|
1960
|
-
export declare const promptToolShape: ObjectShape<{
|
|
1961
|
-
|
|
1962
|
-
|
|
2055
|
+
export declare const promptToolShape: ObjectShape< {
|
|
2056
|
+
to: StringShape;
|
|
2057
|
+
schema: JSONShape;
|
|
1963
2058
|
}, false>;
|
|
1964
2059
|
|
|
1965
|
-
/** Describes the
|
|
1966
|
-
export declare const queryShape: ObjectShape<{
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
2060
|
+
/** Describes the serialized query form — conditions, order, and pagination. */
|
|
2061
|
+
export declare const queryShape: ObjectShape< {
|
|
2062
|
+
conditions: OptionalShape<ArrayShape<ObjectShape< {
|
|
2063
|
+
column: StringShape;
|
|
2064
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
2065
|
+
values: ArrayShape<JSONShape>;
|
|
2066
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
2067
|
+
}, false>>>;
|
|
2068
|
+
order: OptionalShape<ArrayShape<ObjectShape< {
|
|
2069
|
+
column: StringShape;
|
|
2070
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
2071
|
+
}, false>>>;
|
|
2072
|
+
limit: OptionalShape<NumberShape>;
|
|
2073
|
+
offset: OptionalShape<NumberShape>;
|
|
1979
2074
|
}, false>;
|
|
1980
2075
|
|
|
1981
|
-
/**
|
|
2076
|
+
/**
|
|
2077
|
+
* Holds the default cap on how many `include` path segments deep a `load` or `find` call may
|
|
2078
|
+
* traverse, `3` — the relation tool's default include-depth ceiling.
|
|
2079
|
+
*/
|
|
1982
2080
|
export declare const RELATION_TOOL_DEPTH = 3;
|
|
1983
2081
|
|
|
1984
2082
|
/**
|
|
1985
|
-
* Holds the
|
|
1986
|
-
* the operation list and the flat dot-path `include`
|
|
2083
|
+
* Holds the description {@link import('./factories.js').createRelationTool} advertises — a
|
|
2084
|
+
* multi-line guide that teaches a small model the operation list and the flat dot-path `include`
|
|
2085
|
+
* syntax.
|
|
1987
2086
|
*
|
|
1988
2087
|
* @remarks
|
|
1989
|
-
* An include path is a
|
|
2088
|
+
* An include path is a flat dot-separated string (`'contacts.account'`), never a nested object —
|
|
1990
2089
|
* the same small-model ergonomic lever the other tools in this package use for flat args.
|
|
1991
2090
|
*/
|
|
1992
2091
|
export declare const RELATION_TOOL_DESCRIPTION: string;
|
|
1993
2092
|
|
|
1994
|
-
/**
|
|
2093
|
+
/**
|
|
2094
|
+
* Holds the default cap on rows a `find` or `links` call returns when the caller omits `limit`,
|
|
2095
|
+
* `1000` — the relation tool's default row ceiling.
|
|
2096
|
+
*/
|
|
1995
2097
|
export declare const RELATION_TOOL_LIMIT = 1000;
|
|
1996
2098
|
|
|
1997
2099
|
/**
|
|
1998
|
-
* Holds the name
|
|
1999
|
-
* `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
2100
|
+
* Holds the name {@link import('./factories.js').createRelationTool} advertises by default,
|
|
2101
|
+
* `'relation'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
2102
|
+
* under.
|
|
2000
2103
|
*/
|
|
2001
2104
|
export declare const RELATION_TOOL_NAME = "relation";
|
|
2002
2105
|
|
|
2003
2106
|
/**
|
|
2004
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2005
|
-
* in place of
|
|
2107
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2108
|
+
* {@link import('./factories.js').createRelationTool} advertises in place of
|
|
2109
|
+
* {@link RELATION_TOOL_DESCRIPTION} — one sentence offering the `operation`-keyed relationship
|
|
2110
|
+
* traversal and pointing at `describe` for the include-path syntax.
|
|
2111
|
+
*
|
|
2112
|
+
* @remarks
|
|
2113
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
2114
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
2115
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
2006
2116
|
*/
|
|
2007
2117
|
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.";
|
|
2008
2118
|
|
|
2009
2119
|
/**
|
|
2010
|
-
* Represents the options for {@link import('./factories.js').createRelationTool}
|
|
2120
|
+
* Represents the options for {@link import('./factories.js').createRelationTool} — the required
|
|
2121
|
+
* live `RelationManagerInterface` registry a call addresses, the row cap, and the `include` depth
|
|
2122
|
+
* cap.
|
|
2011
2123
|
*
|
|
2012
2124
|
* @remarks
|
|
2013
2125
|
* - `managers` — the live `RelationManagerInterface` (`@orkestrel/relation`) registry a call's
|
|
2014
|
-
* optional `manager` field addresses by name;
|
|
2126
|
+
* optional `manager` field addresses by name; required (unlike the database tool's lazily
|
|
2015
2127
|
* resolved handles, a relation manager's relations are declared up front and cannot be minted
|
|
2016
|
-
* on demand from a tool call). A call that omits `manager` resolves to the
|
|
2128
|
+
* on demand from a tool call). A call that omits `manager` resolves to the sole registered
|
|
2017
2129
|
* manager when exactly one is registered, else throws a typed `TOOL`
|
|
2018
2130
|
* {@link import('./errors.js').ToolboxError} naming the registered manager keys.
|
|
2019
2131
|
* - `limit` — the row cap `'find'` / `'links'` enforce when a call's `limit` is omitted or
|
|
@@ -2034,49 +2146,49 @@ export declare interface RelationToolOptions {
|
|
|
2034
2146
|
|
|
2035
2147
|
/**
|
|
2036
2148
|
* Describes the shape of {@link import('./factories.js').createRelationTool}'s call arguments —
|
|
2037
|
-
* discriminated by `operation` into the
|
|
2038
|
-
* `'unlink'
|
|
2149
|
+
* discriminated by `operation` into the relation operations `'load'`, `'find'`, `'link'`,
|
|
2150
|
+
* `'unlink'`, and `'links'`.
|
|
2039
2151
|
*
|
|
2040
2152
|
* @remarks
|
|
2041
2153
|
* `'load'` fetches one or more rows (positional key/array) with `include` attached. `'find'`
|
|
2042
2154
|
* fetches rows (pagination / sort only) with `include` attached. `'link'` / `'unlink'` write /
|
|
2043
2155
|
* remove a `through` junction row; `'links'` lists a `through` relation's linked keys.
|
|
2044
2156
|
*/
|
|
2045
|
-
export declare const relationToolShape: UnionShape<readonly [
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
}, false>, ObjectShape<{
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
}, false>, ObjectShape<{
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
}, false>, ObjectShape<{
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
}, false>, ObjectShape<{
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2157
|
+
export declare const relationToolShape: UnionShape<readonly [ObjectShape< {
|
|
2158
|
+
operation: LiteralShape<readonly ["load"]>;
|
|
2159
|
+
manager: OptionalShape<StringShape>;
|
|
2160
|
+
model: StringShape;
|
|
2161
|
+
key: UnionShape<readonly [ArrayShape<UnionShape<readonly [StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
2162
|
+
include: OptionalShape<ArrayShape<StringShape>>;
|
|
2163
|
+
}, false>, ObjectShape< {
|
|
2164
|
+
operation: LiteralShape<readonly ["find"]>;
|
|
2165
|
+
manager: OptionalShape<StringShape>;
|
|
2166
|
+
model: StringShape;
|
|
2167
|
+
include: OptionalShape<ArrayShape<StringShape>>;
|
|
2168
|
+
limit: OptionalShape<NumberShape>;
|
|
2169
|
+
offset: OptionalShape<NumberShape>;
|
|
2170
|
+
sort: OptionalShape<StringShape>;
|
|
2171
|
+
direction: OptionalShape<LiteralShape<readonly ["ascending", "descending"]>>;
|
|
2172
|
+
}, false>, ObjectShape< {
|
|
2173
|
+
operation: LiteralShape<readonly ["link"]>;
|
|
2174
|
+
manager: OptionalShape<StringShape>;
|
|
2175
|
+
model: StringShape;
|
|
2176
|
+
key: UnionShape<readonly [StringShape, NumberShape]>;
|
|
2177
|
+
relation: StringShape;
|
|
2178
|
+
target: UnionShape<readonly [StringShape, NumberShape]>;
|
|
2179
|
+
}, false>, ObjectShape< {
|
|
2180
|
+
operation: LiteralShape<readonly ["unlink"]>;
|
|
2181
|
+
manager: OptionalShape<StringShape>;
|
|
2182
|
+
model: StringShape;
|
|
2183
|
+
key: UnionShape<readonly [StringShape, NumberShape]>;
|
|
2184
|
+
relation: StringShape;
|
|
2185
|
+
target: UnionShape<readonly [StringShape, NumberShape]>;
|
|
2186
|
+
}, false>, ObjectShape< {
|
|
2187
|
+
operation: LiteralShape<readonly ["links"]>;
|
|
2188
|
+
manager: OptionalShape<StringShape>;
|
|
2189
|
+
model: StringShape;
|
|
2190
|
+
key: UnionShape<readonly [StringShape, NumberShape]>;
|
|
2191
|
+
relation: StringShape;
|
|
2080
2192
|
}, false>]>;
|
|
2081
2193
|
|
|
2082
2194
|
/**
|
|
@@ -2110,7 +2222,7 @@ export declare function resolveLimit(requested: number | undefined, cap: number)
|
|
|
2110
2222
|
*
|
|
2111
2223
|
* @remarks
|
|
2112
2224
|
* An explicit `name` must match a key of `managers` (a miss throws a typed `TOOL`
|
|
2113
|
-
* {@link ToolboxError} naming the registered managers). An
|
|
2225
|
+
* {@link ToolboxError} naming the registered managers). An omitted `name` resolves to the sole
|
|
2114
2226
|
* registered manager when exactly one is registered, else throws the same typed error.
|
|
2115
2227
|
*
|
|
2116
2228
|
* @param managers - The tool's registered `RelationManagerInterface` map
|
|
@@ -2130,33 +2242,37 @@ export declare function resolveRelationManager(managers: Readonly<Record<string,
|
|
|
2130
2242
|
*/
|
|
2131
2243
|
export declare function resolveRelationModel(manager: RelationManagerInterface, name: string): ModelInterface;
|
|
2132
2244
|
|
|
2133
|
-
/** Describes a loose row — a flat object of column name to JSON value
|
|
2245
|
+
/** Describes a loose row — a flat object of column name to JSON value. */
|
|
2134
2246
|
export declare const rowShape: ObjectShape<Record<never, never>, JSONShape>;
|
|
2135
2247
|
|
|
2136
|
-
/**
|
|
2137
|
-
|
|
2248
|
+
/**
|
|
2249
|
+
* Describes one or many loose rows — the array form resolves first, so an array argument is read as
|
|
2250
|
+
* many rows rather than one.
|
|
2251
|
+
*/
|
|
2252
|
+
export declare const rowsShape: UnionShape<readonly [ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
|
|
2138
2253
|
|
|
2139
2254
|
/** Describes a single row key (not an array) — used by `'link'` / `'unlink'` / `'links'`, which address exactly one owning row. */
|
|
2140
|
-
export declare const singleKeyShape: UnionShape<readonly [
|
|
2255
|
+
export declare const singleKeyShape: UnionShape<readonly [StringShape, NumberShape]>;
|
|
2141
2256
|
|
|
2142
2257
|
/**
|
|
2143
|
-
* Describes the shape of
|
|
2258
|
+
* Describes the shape of one flat step — `{ name }` — the building block of
|
|
2259
|
+
* {@link workflowStepsShape}.
|
|
2144
2260
|
*
|
|
2145
2261
|
* @remarks
|
|
2146
|
-
* `name` is the
|
|
2262
|
+
* `name` is the registered behavior name the step runs (it becomes the task's `behavior`). The tool
|
|
2147
2263
|
* expands each step into a one-task phase, in order ({@link import('./helpers.js').expandSteps}).
|
|
2148
2264
|
*/
|
|
2149
|
-
export declare const stepShape: ObjectShape<{
|
|
2150
|
-
|
|
2265
|
+
export declare const stepShape: ObjectShape< {
|
|
2266
|
+
name: StringShape;
|
|
2151
2267
|
}, false>;
|
|
2152
2268
|
|
|
2153
2269
|
/**
|
|
2154
|
-
* Builds the plain success summary {@link import('./factories.js').createWorkflowTool} returns on
|
|
2155
|
-
*
|
|
2156
|
-
*
|
|
2270
|
+
* Builds the plain success summary {@link import('./factories.js').createWorkflowTool} returns on a
|
|
2271
|
+
* completed run — the universal tool-handler contract: return a plain value on success, appearing
|
|
2272
|
+
* identically over both the agent loop and MCP.
|
|
2157
2273
|
*
|
|
2158
2274
|
* @remarks
|
|
2159
|
-
* The summary is
|
|
2275
|
+
* The summary is lean: the workflow's terminal `status`, settled-task count, and exact optional
|
|
2160
2276
|
* native persistence outcome. It carries no synthetic `id` / `name`: a tool handler has no call
|
|
2161
2277
|
* id; the `ToolManagerInterface` (`@orkestrel/tool`) supplies the canonical envelope's identity.
|
|
2162
2278
|
*
|
|
@@ -2175,11 +2291,11 @@ export declare type TableSpec = Readonly<Record<string, Readonly<{
|
|
|
2175
2291
|
}>>>;
|
|
2176
2292
|
|
|
2177
2293
|
/** Describes a {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
|
|
2178
|
-
export declare const tableSpecShape: ObjectShape<Record<never, never>, ObjectShape<{
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2294
|
+
export declare const tableSpecShape: ObjectShape<Record<never, never>, ObjectShape< {
|
|
2295
|
+
columns: ObjectShape<Record<never, never>, UnionShape<readonly [LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape< {
|
|
2296
|
+
primitive: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
2297
|
+
optional: OptionalShape<BooleanShape>;
|
|
2298
|
+
}, false>]>>;
|
|
2183
2299
|
}, false>>;
|
|
2184
2300
|
|
|
2185
2301
|
/**
|
|
@@ -2200,8 +2316,8 @@ export declare function tagAgent(name: string): string;
|
|
|
2200
2316
|
* Returns the ancestry identifier of a workflow in a run chain — `workflow:<id>`.
|
|
2201
2317
|
*
|
|
2202
2318
|
* @remarks
|
|
2203
|
-
* Namespacing keeps a workflow id and a {@link tagAgent} agent name in
|
|
2204
|
-
* collision, so re-entering a workflow
|
|
2319
|
+
* Namespacing keeps a workflow id and a {@link tagAgent} agent name in one set without
|
|
2320
|
+
* collision, so re-entering a workflow or an agent already in the chain is a single `includes`
|
|
2205
2321
|
* check.
|
|
2206
2322
|
*
|
|
2207
2323
|
* @param id - The workflow definition's `id`
|
|
@@ -2210,11 +2326,12 @@ export declare function tagAgent(name: string): string;
|
|
|
2210
2326
|
export declare function tagWorkflow(id: string): string;
|
|
2211
2327
|
|
|
2212
2328
|
/**
|
|
2213
|
-
* Represents a draft task — a `TaskDefinition` (`@orkestrel/workflow`) with
|
|
2329
|
+
* Represents a draft task — a `TaskDefinition` (`@orkestrel/workflow`) with optional `id` and
|
|
2330
|
+
* `name`.
|
|
2214
2331
|
*
|
|
2215
2332
|
* @remarks
|
|
2216
2333
|
* The tool synthesizes a missing `id` positionally and defaults a missing `name` to its `id`
|
|
2217
|
-
* ({@link import('./helpers.js').completeDraft}). A
|
|
2334
|
+
* ({@link import('./helpers.js').completeDraft}). A provided `id` / `name` is preserved verbatim
|
|
2218
2335
|
* (and must be non-empty — the draft contract's `minLength: 1`).
|
|
2219
2336
|
*/
|
|
2220
2337
|
export declare interface TaskDraft {
|
|
@@ -2230,16 +2347,16 @@ export declare interface TaskDraft {
|
|
|
2230
2347
|
}
|
|
2231
2348
|
|
|
2232
2349
|
/**
|
|
2233
|
-
* Describes the shape of a {@link import('./types.js').TaskDraft} — identical to a strict task
|
|
2234
|
-
*
|
|
2350
|
+
* Describes the shape of a {@link import('./types.js').TaskDraft} — identical to a strict task
|
|
2351
|
+
* shape except that `id` and `name` are optional.
|
|
2235
2352
|
*/
|
|
2236
|
-
export declare const taskDraftShape: ObjectShape<{
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2353
|
+
export declare const taskDraftShape: ObjectShape< {
|
|
2354
|
+
id: OptionalShape<StringShape>;
|
|
2355
|
+
name: OptionalShape<StringShape>;
|
|
2356
|
+
description: OptionalShape<StringShape>;
|
|
2357
|
+
behavior: OptionalShape<StringShape>;
|
|
2358
|
+
retries: OptionalShape<NumberShape>;
|
|
2359
|
+
timeout: OptionalShape<NumberShape>;
|
|
2243
2360
|
}, false>;
|
|
2244
2361
|
|
|
2245
2362
|
/**
|
|
@@ -2250,7 +2367,7 @@ export declare const taskDraftShape: ObjectShape<{
|
|
|
2250
2367
|
* @remarks
|
|
2251
2368
|
* Carries a machine-readable `code` (see {@link import('./types.js').ToolboxErrorCode}) and
|
|
2252
2369
|
* an optional `context` bag for structured diagnostics. They are readable through an in-process
|
|
2253
|
-
* catch, including around a direct `tool.execute(args)` call. The `ToolManagerInterface`
|
|
2370
|
+
* catch, including around a direct `tool.execute(args, context)` call. The `ToolManagerInterface`
|
|
2254
2371
|
* (`@orkestrel/tool`) instead flattens every throw to the canonical tool result's top-level
|
|
2255
2372
|
* `error` message string under AGENTS' “narrow untrusted input with guards” rule.
|
|
2256
2373
|
*
|
|
@@ -2302,48 +2419,52 @@ export declare type ToolboxErrorCode = 'TOOL' | 'DEPTH' | 'DEADLOCK' | 'EXPIRE'
|
|
|
2302
2419
|
export declare const WORKFLOW_TOOL_DESCRIPTION: string;
|
|
2303
2420
|
|
|
2304
2421
|
/**
|
|
2305
|
-
* Holds a complete
|
|
2306
|
-
* {@link import('./factories.js').createWorkflowTool}: `{ name, steps: [{ name }] }`.
|
|
2422
|
+
* Holds a complete flat authoring example — the primary way a small model authors a workflow
|
|
2423
|
+
* through {@link import('./factories.js').createWorkflowTool}: `{ name, steps: [{ name }] }`.
|
|
2307
2424
|
*
|
|
2308
2425
|
* @remarks
|
|
2309
2426
|
* Each step becomes a one-task phase, in
|
|
2310
|
-
* order; a step's `name` is a
|
|
2427
|
+
* order; a step's `name` is a registered behavior name (not a label) — the registry key its
|
|
2311
2428
|
* task's `behavior` resolves against. The tool expands this
|
|
2312
2429
|
* ({@link import('./helpers.js').expandSteps}) into a valid `WorkflowDefinition`
|
|
2313
|
-
* (`@orkestrel/workflow`). It is embedded
|
|
2430
|
+
* (`@orkestrel/workflow`). It is embedded verbatim in {@link WORKFLOW_TOOL_DESCRIPTION}.
|
|
2314
2431
|
*/
|
|
2315
2432
|
export declare const WORKFLOW_TOOL_FLAT_EXAMPLE: WorkflowSteps;
|
|
2316
2433
|
|
|
2317
2434
|
/**
|
|
2318
|
-
* Holds the name {@link import('./factories.js').createWorkflowTool} advertises by default
|
|
2319
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
2320
|
-
* {@link import('./factories.js').createAgentFunction} binds the
|
|
2321
|
-
* under onto a wrapped agent's `context.tools`.
|
|
2435
|
+
* Holds the name {@link import('./factories.js').createWorkflowTool} advertises by default,
|
|
2436
|
+
* `'workflow'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers
|
|
2437
|
+
* under, and the name {@link import('./factories.js').createAgentFunction} binds the
|
|
2438
|
+
* depth/cycle-aware workflow tool under onto a wrapped agent's `context.tools`.
|
|
2322
2439
|
*
|
|
2323
2440
|
* @remarks
|
|
2324
2441
|
* The propagation seam's well-known key: when
|
|
2325
2442
|
* `createAgentFunction`'s `runner` option is supplied, it adds a `createWorkflowTool`-built tool
|
|
2326
|
-
* under this name to the agent's `context.tools`, so it can author
|
|
2443
|
+
* under this name to the agent's `context.tools`, so it can author and run a nested workflow
|
|
2327
2444
|
* (bounded by {@link MAX_WORKFLOW_CHAIN}).
|
|
2328
2445
|
*/
|
|
2329
2446
|
export declare const WORKFLOW_TOOL_NAME = "workflow";
|
|
2330
2447
|
|
|
2331
2448
|
/**
|
|
2332
|
-
* Holds a minimal
|
|
2333
|
-
* the flat shape: a full `WorkflowDefinition` (`@orkestrel/workflow`).
|
|
2449
|
+
* Holds a minimal nested authoring example — the advanced escape-hatch form a model can use instead
|
|
2450
|
+
* of the flat shape: a full `WorkflowDefinition` (`@orkestrel/workflow`).
|
|
2334
2451
|
*
|
|
2335
2452
|
* @remarks
|
|
2336
|
-
* The full
|
|
2337
|
-
* {@link WORKFLOW_TOOL_DESCRIPTION} as the advanced alternative. It is embedded
|
|
2453
|
+
* The full nested form, documented in
|
|
2454
|
+
* {@link WORKFLOW_TOOL_DESCRIPTION} as the advanced alternative. It is embedded verbatim.
|
|
2338
2455
|
*/
|
|
2339
2456
|
export declare const WORKFLOW_TOOL_NESTED_EXAMPLE: WorkflowDefinition;
|
|
2340
2457
|
|
|
2341
2458
|
/**
|
|
2342
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2343
|
-
*
|
|
2344
|
-
*
|
|
2345
|
-
* for the
|
|
2346
|
-
*
|
|
2459
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2460
|
+
* {@link import('./factories.js').createWorkflowTool} advertises in place of
|
|
2461
|
+
* {@link WORKFLOW_TOOL_DESCRIPTION} — one sentence offering multi-phase authoring and pointing at
|
|
2462
|
+
* `describe` for the authoring schema and its examples.
|
|
2463
|
+
*
|
|
2464
|
+
* @remarks
|
|
2465
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
2466
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
2467
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
2347
2468
|
*/
|
|
2348
2469
|
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.";
|
|
2349
2470
|
|
|
@@ -2351,8 +2472,8 @@ export declare const WORKFLOW_TOOL_SUMMARY = "Author and run a multi-phase workf
|
|
|
2351
2472
|
export declare type WorkflowAgents = Readonly<Record<string, AgentInterface>>;
|
|
2352
2473
|
|
|
2353
2474
|
/**
|
|
2354
|
-
* Represents a draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with
|
|
2355
|
-
*
|
|
2475
|
+
* Represents a draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with optional `id`
|
|
2476
|
+
* and `name` at the workflow, phase, and task levels.
|
|
2356
2477
|
*
|
|
2357
2478
|
* @remarks
|
|
2358
2479
|
* The lenient authoring form {@link import('./factories.js').createWorkflowDraftContract}
|
|
@@ -2370,49 +2491,52 @@ export declare interface WorkflowDraft {
|
|
|
2370
2491
|
}
|
|
2371
2492
|
|
|
2372
2493
|
/**
|
|
2373
|
-
* Describes the shape of a
|
|
2374
|
-
* are
|
|
2375
|
-
* identity
|
|
2494
|
+
* Describes the shape of a draft workflow — identical to a strict workflow shape except that `id`
|
|
2495
|
+
* and `name` are optional at the workflow, phase, and task levels, so a small model can omit every
|
|
2496
|
+
* identity string and let the tool synthesize them positionally.
|
|
2376
2497
|
*
|
|
2377
2498
|
* @remarks
|
|
2378
2499
|
* The lenient counterpart {@link import('./factories.js').createWorkflowDraftContract} compiles.
|
|
2379
2500
|
* `behavior` stays optional like the strict form; omission is the deliberate JSON `null` no-op. A
|
|
2380
2501
|
* provided `id` / `name` still has `minLength: 1` (so
|
|
2381
|
-
* an explicitly-empty `id: ''` is
|
|
2502
|
+
* an explicitly-empty `id: ''` is rejected, not auto-filled). After
|
|
2382
2503
|
* {@link import('./helpers.js').completeDraft} fills the missing ids/names, the result is
|
|
2383
|
-
* validated against the
|
|
2504
|
+
* validated against the strict `createWorkflowContract` (`@orkestrel/workflow`) gate before
|
|
2384
2505
|
* running.
|
|
2385
2506
|
*/
|
|
2386
|
-
export declare const workflowDraftShape: ObjectShape<{
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2507
|
+
export declare const workflowDraftShape: ObjectShape< {
|
|
2508
|
+
id: OptionalShape<StringShape>;
|
|
2509
|
+
name: OptionalShape<StringShape>;
|
|
2510
|
+
description: OptionalShape<StringShape>;
|
|
2511
|
+
phases: ArrayShape<ObjectShape< {
|
|
2512
|
+
id: OptionalShape<StringShape>;
|
|
2513
|
+
name: OptionalShape<StringShape>;
|
|
2514
|
+
description: OptionalShape<StringShape>;
|
|
2515
|
+
tasks: ArrayShape<ObjectShape< {
|
|
2516
|
+
id: OptionalShape<StringShape>;
|
|
2517
|
+
name: OptionalShape<StringShape>;
|
|
2518
|
+
description: OptionalShape<StringShape>;
|
|
2519
|
+
behavior: OptionalShape<StringShape>;
|
|
2520
|
+
retries: OptionalShape<NumberShape>;
|
|
2521
|
+
timeout: OptionalShape<NumberShape>;
|
|
2522
|
+
}, false>>;
|
|
2523
|
+
concurrency: OptionalShape<NumberShape>;
|
|
2524
|
+
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
2525
|
+
}, false>>;
|
|
2526
|
+
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
2406
2527
|
}, false>;
|
|
2407
2528
|
|
|
2408
|
-
/**
|
|
2529
|
+
/**
|
|
2530
|
+
* Represents one immutable workflow/agent call chain — strictly alternating tags, each unique,
|
|
2531
|
+
* beginning with a workflow tag.
|
|
2532
|
+
*/
|
|
2409
2533
|
export declare type WorkflowLineage = readonly string[];
|
|
2410
2534
|
|
|
2411
2535
|
/**
|
|
2412
2536
|
* Represents one flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
|
|
2413
2537
|
*
|
|
2414
2538
|
* @remarks
|
|
2415
|
-
* `name` is the
|
|
2539
|
+
* `name` is the registered behavior name the step runs (it becomes the task's `behavior`, not a
|
|
2416
2540
|
* human label) — resolved against a workflow-level functions registry at construction.
|
|
2417
2541
|
*/
|
|
2418
2542
|
export declare interface WorkflowStep {
|
|
@@ -2421,13 +2545,13 @@ export declare interface WorkflowStep {
|
|
|
2421
2545
|
}
|
|
2422
2546
|
|
|
2423
2547
|
/**
|
|
2424
|
-
* Represents the
|
|
2425
|
-
* `{ name?, steps }` — the simplest surface a small model can fill.
|
|
2548
|
+
* Represents the flat authoring blob {@link import('./factories.js').createWorkflowTool} advertises
|
|
2549
|
+
* — `{ name?, steps }` — the simplest surface a small model can fill.
|
|
2426
2550
|
*
|
|
2427
2551
|
* @remarks
|
|
2428
2552
|
* Each {@link WorkflowStep} becomes a one-task phase, in order
|
|
2429
2553
|
* ({@link import('./helpers.js').expandSteps}); `name` is the optional workflow name and
|
|
2430
|
-
* deterministic persistence id (
|
|
2554
|
+
* deterministic persistence id (each defaults to `wf` when omitted).
|
|
2431
2555
|
*/
|
|
2432
2556
|
export declare interface WorkflowSteps {
|
|
2433
2557
|
readonly name?: string;
|
|
@@ -2435,23 +2559,24 @@ export declare interface WorkflowSteps {
|
|
|
2435
2559
|
}
|
|
2436
2560
|
|
|
2437
2561
|
/**
|
|
2438
|
-
* Describes the
|
|
2439
|
-
* `parameters` — the simplest surface a small model can fill:
|
|
2562
|
+
* Describes the flat authoring shape {@link import('./factories.js').createWorkflowTool} advertises
|
|
2563
|
+
* as its `parameters` — the simplest surface a small model can fill:
|
|
2564
|
+
* `{ name?, steps: [{ name }] }`.
|
|
2440
2565
|
*
|
|
2441
2566
|
* @remarks
|
|
2442
2567
|
* A deliberately-reduced surface: a flat ordered list of steps, each a `{ name }`. The tool
|
|
2443
|
-
*
|
|
2568
|
+
* expands it ({@link import('./helpers.js').expandSteps}) into a full
|
|
2444
2569
|
* {@link import('./types.js').WorkflowDefinition} — one one-task phase per step, in order —
|
|
2445
|
-
* then validates against the
|
|
2446
|
-
* full nested form is
|
|
2447
|
-
* documented as the advanced escape-hatch in the tool's description — but
|
|
2570
|
+
* then validates against the strict `createWorkflowContract` (`@orkestrel/workflow`) gate. The
|
|
2571
|
+
* full nested form is still accepted by the tool (it branches on the args' shape) and is
|
|
2572
|
+
* documented as the advanced escape-hatch in the tool's description — but this is what
|
|
2448
2573
|
* `parameters` advertises.
|
|
2449
2574
|
*/
|
|
2450
|
-
export declare const workflowStepsShape: ObjectShape<{
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2575
|
+
export declare const workflowStepsShape: ObjectShape< {
|
|
2576
|
+
name: OptionalShape<StringShape>;
|
|
2577
|
+
steps: ArrayShape<ObjectShape< {
|
|
2578
|
+
name: StringShape;
|
|
2579
|
+
}, false>>;
|
|
2455
2580
|
}, false>;
|
|
2456
2581
|
|
|
2457
2582
|
/**
|
|
@@ -2496,8 +2621,8 @@ export declare interface WorkflowToolResult {
|
|
|
2496
2621
|
export declare const WORKSPACE_TOOL_DESCRIPTION: string;
|
|
2497
2622
|
|
|
2498
2623
|
/**
|
|
2499
|
-
* Holds a valid {@link import('./types.js').WorkspaceOperation} object — the canonical example
|
|
2500
|
-
*
|
|
2624
|
+
* Holds a valid {@link import('./types.js').WorkspaceOperation} object — the canonical example
|
|
2625
|
+
* embedded verbatim in {@link WORKSPACE_TOOL_DESCRIPTION}.
|
|
2501
2626
|
*
|
|
2502
2627
|
* @remarks
|
|
2503
2628
|
* A `'write'` op (the most common authoring
|
|
@@ -2507,56 +2632,61 @@ export declare const WORKSPACE_TOOL_DESCRIPTION: string;
|
|
|
2507
2632
|
export declare const WORKSPACE_TOOL_EXAMPLE: WorkspaceOperation;
|
|
2508
2633
|
|
|
2509
2634
|
/**
|
|
2510
|
-
* Holds the name {@link import('./factories.js').createWorkspaceTool} advertises by default
|
|
2511
|
-
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`)
|
|
2635
|
+
* Holds the name {@link import('./factories.js').createWorkspaceTool} advertises by default,
|
|
2636
|
+
* `'workspace'` — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`)
|
|
2637
|
+
* registers under.
|
|
2512
2638
|
*/
|
|
2513
2639
|
export declare const WORKSPACE_TOOL_NAME = "workspace";
|
|
2514
2640
|
|
|
2515
2641
|
/**
|
|
2516
|
-
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2517
|
-
*
|
|
2518
|
-
*
|
|
2519
|
-
*
|
|
2520
|
-
*
|
|
2642
|
+
* Holds the lean {@link import('@orkestrel/tool').ToolInterface.summary}
|
|
2643
|
+
* {@link import('./factories.js').createWorkspaceTool} advertises in place of
|
|
2644
|
+
* {@link WORKSPACE_TOOL_DESCRIPTION} — one sentence offering the `operation`-keyed file editing and
|
|
2645
|
+
* pointing at `describe` for the operation list and its fields.
|
|
2646
|
+
*
|
|
2647
|
+
* @remarks
|
|
2648
|
+
* A `ToolManagerInterface.definitions()` call (`@orkestrel/tool`) advertises
|
|
2649
|
+
* `summary ?? description`, so this one-sentence text stands in for the full teaching description;
|
|
2650
|
+
* the full text stays retrievable through {@link import('./factories.js').createDescribeTool}.
|
|
2521
2651
|
*/
|
|
2522
2652
|
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.";
|
|
2523
2653
|
|
|
2524
2654
|
/**
|
|
2525
|
-
* Represents one operation an agent invokes through
|
|
2526
|
-
*
|
|
2527
|
-
* discriminated by the `operation` literal (a
|
|
2528
|
-
* being performed —
|
|
2655
|
+
* Represents one operation an agent invokes through
|
|
2656
|
+
* {@link import('./factories.js').createWorkspaceTool} — a flat, descriptive tagged union over the
|
|
2657
|
+
* workspace edit, read, and navigation actions, discriminated by the `operation` literal (a
|
|
2658
|
+
* discriminant is named for its axis — the action being performed — never `kind`).
|
|
2529
2659
|
*
|
|
2530
2660
|
* @remarks
|
|
2531
|
-
* This is the
|
|
2661
|
+
* This is the source of truth the tool contract is typed to
|
|
2532
2662
|
* ({@link import('./shapers.js').workspaceToolShape} compiles to a structurally-identical guard /
|
|
2533
|
-
* parser / JSON Schema). Every field is
|
|
2534
|
-
* lever: a range edit is the
|
|
2663
|
+
* parser / JSON Schema). Every field is flat (no nested objects) — the small-model ergonomic
|
|
2664
|
+
* lever: a range edit is the flat integers of the `'splice'` arm (`fromLine` /
|
|
2535
2665
|
* `fromColumn` / `toLine` / `toColumn`), reassembled into a 1-based `Range`
|
|
2536
2666
|
* (`@orkestrel/workspace`)
|
|
2537
|
-
* by `rangeOf`, never a nested `{ start, end }`. Each
|
|
2538
|
-
* `WorkspaceInterface` call against the manager's
|
|
2667
|
+
* by `rangeOf`, never a nested `{ start, end }`. Each edit / read arm maps onto exactly one
|
|
2668
|
+
* `WorkspaceInterface` call against the manager's active workspace; the registry arms
|
|
2539
2669
|
* (`switch` / `workspaces`) drive the {@link WorkspaceManagerInterface} pointer instead —
|
|
2540
|
-
* `workspaces`
|
|
2670
|
+
* `workspaces` lists the workspaces the model can move between, and `switch` re-points which one
|
|
2541
2671
|
* the edit / read arms target.
|
|
2542
2672
|
*/
|
|
2543
2673
|
export declare type WorkspaceOperation =
|
|
2544
|
-
/** Reads a whole text file's text by `path` from the
|
|
2674
|
+
/** Reads a whole text file's text by `path` from the active workspace (a binary / absent path — or no active workspace — yields no content). */
|
|
2545
2675
|
{
|
|
2546
2676
|
readonly operation: 'read';
|
|
2547
2677
|
readonly path: string;
|
|
2548
2678
|
}
|
|
2549
|
-
/** Lists every file in the
|
|
2679
|
+
/** Lists every file in the active workspace (path / state / size / lines / kind summaries); `[]` when no workspace is active. */
|
|
2550
2680
|
| {
|
|
2551
2681
|
readonly operation: 'list';
|
|
2552
2682
|
}
|
|
2553
|
-
/** Reports whether a file exists at `path` in the
|
|
2683
|
+
/** Reports whether a file exists at `path` in the active workspace (`false` when no workspace is active). */
|
|
2554
2684
|
| {
|
|
2555
2685
|
readonly operation: 'has';
|
|
2556
2686
|
readonly path: string;
|
|
2557
2687
|
}
|
|
2558
2688
|
/**
|
|
2559
|
-
* Scans every text file for `query`, returning each hit (path
|
|
2689
|
+
* Scans every text file for `query`, returning each hit (the path, the 1-based line and column, and the line).
|
|
2560
2690
|
*
|
|
2561
2691
|
* @remarks
|
|
2562
2692
|
* `regex` treats `query` as a regular-expression source (default `false` — a literal substring);
|
|
@@ -2592,10 +2722,10 @@ export declare type WorkspaceOperation =
|
|
|
2592
2722
|
}
|
|
2593
2723
|
/**
|
|
2594
2724
|
* Splices `content` into an existing text file, replacing the 1-based range
|
|
2595
|
-
* `(fromLine, fromColumn)` (
|
|
2725
|
+
* `(fromLine, fromColumn)` (inclusive) → `(toLine, toColumn)` (exclusive).
|
|
2596
2726
|
*
|
|
2597
2727
|
* @remarks
|
|
2598
|
-
* The
|
|
2728
|
+
* The flat range edit — the four positive-integer caret components reassemble into a `Range`
|
|
2599
2729
|
* (`@orkestrel/workspace`) through `rangeOf`. An empty span (`from === to`) inserts; a span past
|
|
2600
2730
|
* the end is clamped. An inverted / sub-1 range throws `RANGE`; a binary target throws
|
|
2601
2731
|
* `MODALITY`; a missing target throws `MISSING`.
|
|
@@ -2636,25 +2766,25 @@ export declare type WorkspaceOperation =
|
|
|
2636
2766
|
| {
|
|
2637
2767
|
readonly operation: 'workspaces';
|
|
2638
2768
|
}
|
|
2639
|
-
/** Re-points the manager's
|
|
2769
|
+
/** 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. */
|
|
2640
2770
|
| {
|
|
2641
2771
|
readonly operation: 'switch';
|
|
2642
2772
|
readonly id: string;
|
|
2643
2773
|
};
|
|
2644
2774
|
|
|
2645
2775
|
/**
|
|
2646
|
-
* Represents the options for {@link import('./factories.js').createWorkspaceTool} —
|
|
2647
|
-
* {@link WorkspaceManagerInterface} to drive directly,
|
|
2648
|
-
* tool constructs a fresh manager over; neither given
|
|
2649
|
-
* `@orkestrel/workspace`'s in-memory store.
|
|
2776
|
+
* Represents the options for {@link import('./factories.js').createWorkspaceTool} — either a
|
|
2777
|
+
* caller-built {@link WorkspaceManagerInterface} to drive directly, or a
|
|
2778
|
+
* {@link WorkspaceStoreInterface} the tool constructs a fresh manager over; neither given
|
|
2779
|
+
* constructs a manager over `@orkestrel/workspace`'s in-memory store.
|
|
2650
2780
|
*
|
|
2651
2781
|
* @remarks
|
|
2652
|
-
* - `manager` — drive
|
|
2653
|
-
* operation targets). Takes priority over `store` when
|
|
2782
|
+
* - `manager` — drive this manager directly (its `active` workspace is what every edit / read
|
|
2783
|
+
* operation targets). Takes priority over `store` when the caller supplies `manager` and `store`.
|
|
2654
2784
|
* - `store` — construct a manager over this durable {@link WorkspaceStoreInterface} (through
|
|
2655
2785
|
* `@orkestrel/workspace`'s `createWorkspaceManager`) — used only when `manager` is omitted.
|
|
2656
2786
|
* The store only backs the manager's own `open` / `save` operations: the tool's edits are
|
|
2657
|
-
*
|
|
2787
|
+
* not auto-persisted — durability requires an explicit caller `save` on the manager
|
|
2658
2788
|
* (unlike the workflow tool's `store`, which is forwarded into native run-wide checkpoints).
|
|
2659
2789
|
* - `name` / `description` — advertised tool overrides; default to
|
|
2660
2790
|
* {@link import('./constants.js').WORKSPACE_TOOL_NAME} / {@link import('./constants.js').WORKSPACE_TOOL_DESCRIPTION}.
|
|
@@ -2670,71 +2800,71 @@ export declare interface WorkspaceToolOptions {
|
|
|
2670
2800
|
* Describes the shape of a {@link import('./types.js').WorkspaceOperation} — a descriptive tagged union
|
|
2671
2801
|
* over the workspace edit, read, and navigation operations, discriminated by the `operation`
|
|
2672
2802
|
* literal (never a bare `kind`). Each variant leads with its `operation`
|
|
2673
|
-
* discriminant then its
|
|
2803
|
+
* discriminant then its flat fields, every field through `stringShape` / `optionalShape` /
|
|
2674
2804
|
* `integerShape({ min: 1 })` / `booleanShape`, each carrying a strong field-level `description`.
|
|
2675
2805
|
*
|
|
2676
2806
|
* @remarks
|
|
2677
|
-
* The union compiles to an `anyOf` JSON Schema
|
|
2807
|
+
* The union compiles to an `anyOf` JSON Schema, a `unionOf` guard, and a first-match parser
|
|
2678
2808
|
* automatically ({@link import('./factories.js').createWorkspaceTool} types the result to the
|
|
2679
|
-
* hand-written {@link import('./types.js').WorkspaceOperation}). `limit` and the
|
|
2680
|
-
* caret components are
|
|
2681
|
-
* are `optionalShape(booleanShape(...))`. The
|
|
2809
|
+
* hand-written {@link import('./types.js').WorkspaceOperation}). `limit` and the `'splice'`
|
|
2810
|
+
* caret components are positive integers (`integerShape({ min: 1 })`); `regex` / `sensitive`
|
|
2811
|
+
* are `optionalShape(booleanShape(...))`. The registry arms — `workspaces` (list the
|
|
2682
2812
|
* workspaces the model can move between) and `switch` (re-point the active one by `id`) — let a
|
|
2683
|
-
* model
|
|
2684
|
-
*/
|
|
2685
|
-
export declare const workspaceToolShape: UnionShape<readonly [
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
}, false>, ObjectShape<{
|
|
2689
|
-
|
|
2690
|
-
}, false>, ObjectShape<{
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
}, false>, ObjectShape<{
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
}, false>, ObjectShape<{
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
}, false>, ObjectShape<{
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
}, false>, ObjectShape<{
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
}, false>, ObjectShape<{
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
}, false>, ObjectShape<{
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
}, false>, ObjectShape<{
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
}, false>, ObjectShape<{
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
}, false>, ObjectShape<{
|
|
2734
|
-
|
|
2735
|
-
}, false>, ObjectShape<{
|
|
2736
|
-
|
|
2737
|
-
|
|
2813
|
+
* model discover then choose which workspace the edit / read arms target.
|
|
2814
|
+
*/
|
|
2815
|
+
export declare const workspaceToolShape: UnionShape<readonly [ObjectShape< {
|
|
2816
|
+
operation: LiteralShape<readonly ["read"]>;
|
|
2817
|
+
path: StringShape;
|
|
2818
|
+
}, false>, ObjectShape< {
|
|
2819
|
+
operation: LiteralShape<readonly ["list"]>;
|
|
2820
|
+
}, false>, ObjectShape< {
|
|
2821
|
+
operation: LiteralShape<readonly ["has"]>;
|
|
2822
|
+
path: StringShape;
|
|
2823
|
+
}, false>, ObjectShape< {
|
|
2824
|
+
operation: LiteralShape<readonly ["search"]>;
|
|
2825
|
+
query: StringShape;
|
|
2826
|
+
regex: OptionalShape<BooleanShape>;
|
|
2827
|
+
sensitive: OptionalShape<BooleanShape>;
|
|
2828
|
+
limit: OptionalShape<NumberShape>;
|
|
2829
|
+
}, false>, ObjectShape< {
|
|
2830
|
+
operation: LiteralShape<readonly ["replace"]>;
|
|
2831
|
+
query: StringShape;
|
|
2832
|
+
replacement: StringShape;
|
|
2833
|
+
regex: OptionalShape<BooleanShape>;
|
|
2834
|
+
sensitive: OptionalShape<BooleanShape>;
|
|
2835
|
+
limit: OptionalShape<NumberShape>;
|
|
2836
|
+
}, false>, ObjectShape< {
|
|
2837
|
+
operation: LiteralShape<readonly ["write"]>;
|
|
2838
|
+
path: StringShape;
|
|
2839
|
+
content: StringShape;
|
|
2840
|
+
}, false>, ObjectShape< {
|
|
2841
|
+
operation: LiteralShape<readonly ["splice"]>;
|
|
2842
|
+
path: StringShape;
|
|
2843
|
+
content: StringShape;
|
|
2844
|
+
fromLine: NumberShape;
|
|
2845
|
+
fromColumn: NumberShape;
|
|
2846
|
+
toLine: NumberShape;
|
|
2847
|
+
toColumn: NumberShape;
|
|
2848
|
+
}, false>, ObjectShape< {
|
|
2849
|
+
operation: LiteralShape<readonly ["prepend"]>;
|
|
2850
|
+
path: StringShape;
|
|
2851
|
+
content: StringShape;
|
|
2852
|
+
}, false>, ObjectShape< {
|
|
2853
|
+
operation: LiteralShape<readonly ["append"]>;
|
|
2854
|
+
path: StringShape;
|
|
2855
|
+
content: StringShape;
|
|
2856
|
+
}, false>, ObjectShape< {
|
|
2857
|
+
operation: LiteralShape<readonly ["move"]>;
|
|
2858
|
+
from: StringShape;
|
|
2859
|
+
to: StringShape;
|
|
2860
|
+
}, false>, ObjectShape< {
|
|
2861
|
+
operation: LiteralShape<readonly ["remove"]>;
|
|
2862
|
+
path: StringShape;
|
|
2863
|
+
}, false>, ObjectShape< {
|
|
2864
|
+
operation: LiteralShape<readonly ["workspaces"]>;
|
|
2865
|
+
}, false>, ObjectShape< {
|
|
2866
|
+
operation: LiteralShape<readonly ["switch"]>;
|
|
2867
|
+
id: StringShape;
|
|
2738
2868
|
}, false>]>;
|
|
2739
2869
|
|
|
2740
2870
|
export { }
|