@orkestrel/toolbox 0.0.1 → 0.0.2
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 +4 -2
- package/dist/src/core/index.cjs +424 -365
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +356 -312
- package/dist/src/core/index.d.ts +356 -312
- package/dist/src/core/index.js +416 -361
- package/dist/src/core/index.js.map +1 -1
- package/package.json +8 -7
package/dist/src/core/index.d.ts
CHANGED
|
@@ -2,18 +2,16 @@ import { AgentInterface } from '@orkestrel/agent';
|
|
|
2
2
|
import { AgentRegistryInterface } from '@orkestrel/agent';
|
|
3
3
|
import { ArrayShape } from '@orkestrel/contract';
|
|
4
4
|
import { BooleanShape } from '@orkestrel/contract';
|
|
5
|
-
import { ColumnSchema } from '@orkestrel/database';
|
|
6
5
|
import { Condition } from '@orkestrel/database';
|
|
7
|
-
import {
|
|
6
|
+
import { ConditionConnector } from '@orkestrel/database';
|
|
8
7
|
import { ContractInterface } from '@orkestrel/contract';
|
|
9
8
|
import { ContractShape } from '@orkestrel/contract';
|
|
10
9
|
import { ConversationStoreInterface } from '@orkestrel/agent';
|
|
11
|
-
import { Criteria } from '@orkestrel/database';
|
|
12
10
|
import { DatabaseErrorCode } from '@orkestrel/database';
|
|
13
11
|
import { DatabaseInterface } from '@orkestrel/database';
|
|
14
|
-
import { Direction } from '@orkestrel/database';
|
|
15
12
|
import { DriverInterface } from '@orkestrel/database';
|
|
16
13
|
import { Include } from '@orkestrel/relation';
|
|
14
|
+
import { IndexMap } from '@orkestrel/database';
|
|
17
15
|
import { JSONShape } from '@orkestrel/contract';
|
|
18
16
|
import { KeyFunction } from '@orkestrel/database';
|
|
19
17
|
import { LiteralShape } from '@orkestrel/contract';
|
|
@@ -21,25 +19,29 @@ import { ModelInterface } from '@orkestrel/relation';
|
|
|
21
19
|
import { NumberShape } from '@orkestrel/contract';
|
|
22
20
|
import { ObjectShape } from '@orkestrel/contract';
|
|
23
21
|
import { OptionalShape } from '@orkestrel/contract';
|
|
22
|
+
import { OrderDirection } from '@orkestrel/database';
|
|
23
|
+
import { PrimaryMap } from '@orkestrel/database';
|
|
24
24
|
import { PromptType } from '@orkestrel/terminal';
|
|
25
|
+
import { QueryInput } from '@orkestrel/database';
|
|
25
26
|
import { RelationErrorCode } from '@orkestrel/relation';
|
|
26
27
|
import { RelationManagerInterface } from '@orkestrel/relation';
|
|
27
28
|
import { StringShape } from '@orkestrel/contract';
|
|
28
29
|
import { TableInterface } from '@orkestrel/database';
|
|
29
|
-
import {
|
|
30
|
-
import { TablesShape } from '@orkestrel/database';
|
|
30
|
+
import { TableMap } from '@orkestrel/database';
|
|
31
31
|
import { TerminalManagerInterface } from '@orkestrel/terminal';
|
|
32
32
|
import { ToolInterface } from '@orkestrel/tool';
|
|
33
33
|
import { ToolManagerInterface } from '@orkestrel/tool';
|
|
34
34
|
import { UnionShape } from '@orkestrel/contract';
|
|
35
35
|
import { WorkflowDefinition } from '@orkestrel/workflow';
|
|
36
|
+
import { WorkflowFault } from '@orkestrel/workflow';
|
|
36
37
|
import { WorkflowFunction } from '@orkestrel/workflow';
|
|
38
|
+
import { WorkflowFunctions } from '@orkestrel/workflow';
|
|
37
39
|
import { WorkflowResult } from '@orkestrel/workflow';
|
|
38
40
|
import { WorkflowRunnerInterface } from '@orkestrel/workflow';
|
|
39
41
|
import { WorkflowStatus } from '@orkestrel/workflow';
|
|
40
42
|
import { WorkflowStoreInterface } from '@orkestrel/workflow';
|
|
41
|
-
import { WorkspaceManagerInterface } from '@orkestrel/
|
|
42
|
-
import { WorkspaceStoreInterface } from '@orkestrel/
|
|
43
|
+
import { WorkspaceManagerInterface } from '@orkestrel/workspace';
|
|
44
|
+
import { WorkspaceStoreInterface } from '@orkestrel/workspace';
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* The maximum nesting depth a delegation chain (agent tool → sub-agent → agent tool → …) may
|
|
@@ -55,6 +57,10 @@ import { WorkspaceStoreInterface } from '@orkestrel/agent';
|
|
|
55
57
|
*/
|
|
56
58
|
export declare const AGENT_TOOL_DEPTH = 8;
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The description {@link import('./factories.js').createAgentTool} advertises — a short guide
|
|
62
|
+
* covering the required task and optional provider, tools, and system overrides.
|
|
63
|
+
*/
|
|
58
64
|
export declare const AGENT_TOOL_DESCRIPTION: string;
|
|
59
65
|
|
|
60
66
|
/**
|
|
@@ -72,30 +78,35 @@ export declare const AGENT_TOOL_NAME = "agent";
|
|
|
72
78
|
*/
|
|
73
79
|
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.";
|
|
74
80
|
|
|
81
|
+
/** A contextual agent adapter carrying immutable metadata for Toolbox composition. */
|
|
82
|
+
export declare type AgentFunction = WorkflowFunction & {
|
|
83
|
+
readonly category: 'agent';
|
|
84
|
+
readonly lineage: WorkflowLineage;
|
|
85
|
+
};
|
|
86
|
+
|
|
75
87
|
/**
|
|
76
88
|
* Options for {@link import('./factories.js').createAgentFunction} — the OPT-IN adapter that
|
|
77
|
-
* wraps a live `AgentInterface` (`@orkestrel/agent`) as
|
|
78
|
-
*
|
|
79
|
-
* closure.
|
|
89
|
+
* wraps a live `AgentInterface` (`@orkestrel/agent`) as an {@link AgentFunction} with immutable
|
|
90
|
+
* lineage metadata and optional nested-workflow composition.
|
|
80
91
|
*
|
|
81
92
|
* @remarks
|
|
82
|
-
* All fields are optional
|
|
83
|
-
*
|
|
84
|
-
* - `runner` — when supplied, the adapter
|
|
93
|
+
* All fields are optional. An empty lineage is resolved from the controller's root workflow when
|
|
94
|
+
* the adapter runs; a configured lineage must already identify that exact workflow.
|
|
95
|
+
* - `runner` — when supplied, the adapter binds a recursion-safe
|
|
85
96
|
* {@link import('./factories.js').createWorkflowTool} onto the agent's `context.tools` (the
|
|
86
|
-
* propagation seam), so the agent can author
|
|
97
|
+
* propagation seam), so the agent can author and run a nested workflow through it. Omitted ⇒ the
|
|
87
98
|
* agent runs with no workflow tool bound.
|
|
88
|
-
* - `
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* - `
|
|
92
|
-
* cycle (this agent already present) is rejected with a typed `DEPTH` `WorkflowError`
|
|
93
|
-
* (`@orkestrel/workflow`).
|
|
99
|
+
* - `lineage` — the immutable alternating workflow/agent chain for this adapter's workflow.
|
|
100
|
+
* - `functions` — opaque host-owned leaf functions propagated unchanged.
|
|
101
|
+
* - `agents` — raw live agents Toolbox contextually adapts for each target workflow.
|
|
102
|
+
* - `store` — the native runner checkpoint store propagated through nested runs.
|
|
94
103
|
*/
|
|
95
104
|
export declare interface AgentFunctionOptions {
|
|
96
105
|
readonly runner?: WorkflowRunnerInterface;
|
|
97
|
-
readonly
|
|
98
|
-
readonly
|
|
106
|
+
readonly lineage?: WorkflowLineage;
|
|
107
|
+
readonly functions?: WorkflowFunctions;
|
|
108
|
+
readonly agents?: WorkflowAgents;
|
|
109
|
+
readonly store?: WorkflowStoreInterface;
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
/**
|
|
@@ -104,7 +115,7 @@ export declare interface AgentFunctionOptions {
|
|
|
104
115
|
* @remarks
|
|
105
116
|
* The agent counterpart of {@link workflowTag}: {@link import('./factories.js').createAgentFunction}
|
|
106
117
|
* / {@link import('./factories.js').createWorkflowTool} guard against re-entering an agent or
|
|
107
|
-
* workflow already in the chain (
|
|
118
|
+
* workflow already in the chain (this package's typed `DEPTH` `ToolboxError`). The
|
|
108
119
|
* `agent:` namespace keeps it distinct from a same-string workflow id.
|
|
109
120
|
*
|
|
110
121
|
* @param name - The agent's identifier / registry name
|
|
@@ -187,6 +198,7 @@ export declare const agentToolShape: ObjectShape<{
|
|
|
187
198
|
system: OptionalShape<StringShape>;
|
|
188
199
|
}, false>;
|
|
189
200
|
|
|
201
|
+
/** The pending/answer protocol {@link import('./factories.js').createAnswerTool} advertises. */
|
|
190
202
|
export declare const ANSWER_TOOL_DESCRIPTION: string;
|
|
191
203
|
|
|
192
204
|
/**
|
|
@@ -246,33 +258,33 @@ export declare const answerToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
246
258
|
}, false>]>;
|
|
247
259
|
|
|
248
260
|
/**
|
|
249
|
-
* Clamp a `'records'` call's
|
|
261
|
+
* Clamp a `'records'` call's query to a row cap, and build the PROBE query the caller reads
|
|
250
262
|
* with — the pure leaf {@link import('./factories.js').createDatabaseTool}'s `'records'` operation
|
|
251
263
|
* uses to detect truncation without a separate `count` round trip.
|
|
252
264
|
*
|
|
253
265
|
* @remarks
|
|
254
|
-
* The effective limit is `min(
|
|
255
|
-
* exceed the configured cap by supplying a larger `
|
|
266
|
+
* The effective limit is `min(query?.limit ?? cap, cap)`, floored at `0` (so a caller can never
|
|
267
|
+
* exceed the configured cap by supplying a larger `query.limit`). The returned probe query
|
|
256
268
|
* requests ONE MORE row than the effective limit (`limit: effective + 1`) — if storage returns
|
|
257
269
|
* that many, the caller knows the true result was truncated (`rows.length > effective`) and slices
|
|
258
270
|
* back down to `effective` before returning.
|
|
259
271
|
*
|
|
260
272
|
* @example
|
|
261
273
|
* ```ts
|
|
262
|
-
* import {
|
|
274
|
+
* import { clampQuery } from '@src/core'
|
|
263
275
|
*
|
|
264
|
-
* const {
|
|
265
|
-
* // limit === 100,
|
|
266
|
-
* const rows = await table.records(
|
|
276
|
+
* const { query, limit } = clampQuery(undefined, 100)
|
|
277
|
+
* // limit === 100, query.limit === 101 — a probe fetching one extra row
|
|
278
|
+
* const rows = await table.records(query)
|
|
267
279
|
* const truncated = rows.length > limit // true when storage had more than `limit` rows
|
|
268
280
|
* ```
|
|
269
281
|
*
|
|
270
|
-
* @param
|
|
282
|
+
* @param query - The live query to clamp (or `undefined`)
|
|
271
283
|
* @param cap - The row-count ceiling
|
|
272
|
-
* @returns The PROBE
|
|
284
|
+
* @returns The PROBE query (`limit` bumped by one) and the effective `limit`
|
|
273
285
|
*/
|
|
274
|
-
export declare function
|
|
275
|
-
|
|
286
|
+
export declare function clampQuery(query: QueryInput | undefined, cap: number): Readonly<{
|
|
287
|
+
query: QueryInput;
|
|
276
288
|
limit: number;
|
|
277
289
|
}>;
|
|
278
290
|
|
|
@@ -304,9 +316,6 @@ export declare type ColumnKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
|
304
316
|
/** A {@link import('./types.js').ColumnKind} literal — the leaf {@link columnSpecShape} wraps. */
|
|
305
317
|
export declare const columnKindShape: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
306
318
|
|
|
307
|
-
/** Map a column NAME + its live `@orkestrel/database` `ContractShape` to a {@link ColumnSchema} — the leaf {@link tableSchema} maps over. */
|
|
308
|
-
export declare function columnSchema(name: string, shape: ContractShape): ColumnSchema;
|
|
309
|
-
|
|
310
319
|
/** Compile one {@link ColumnSpec} into its `@orkestrel/database` column shape — the per-column leaf {@link expandTables} maps over. */
|
|
311
320
|
export declare function columnShape(spec: ColumnSpec): ContractShape;
|
|
312
321
|
|
|
@@ -377,34 +386,29 @@ export declare const conditionShape: ObjectShape<{
|
|
|
377
386
|
|
|
378
387
|
/**
|
|
379
388
|
* Wrap a live `AgentInterface` (`@orkestrel/agent`) as a {@link WorkflowFunction}
|
|
380
|
-
* (`@orkestrel/workflow`) — the
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
* @remarks
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
* A bound agent is effectively SINGLE-RUN: `context.tools.add` binds one `ToolInterface` under
|
|
400
|
-
* the fixed {@link import('./constants.js').WORKFLOW_TOOL_NAME}, and `agent.generate()` /
|
|
401
|
-
* `agent.abort()` are per-agent state. Two CONCURRENT tasks sharing the SAME `agent` instance
|
|
402
|
-
* race on that one tool binding (last-write-wins) and on generate/abort — give each concurrent
|
|
403
|
-
* task its OWN agent instance.
|
|
389
|
+
* (`@orkestrel/workflow`) — the opt-in adapter that runs the agent to a settled result and carries
|
|
390
|
+
* immutable lineage metadata for contextual Toolbox composition.
|
|
391
|
+
*
|
|
392
|
+
* @remarks
|
|
393
|
+
* Composes into a caller's registry like any other behavior; the pure workflow runner has no
|
|
394
|
+
* knowledge of agents itself. A root adapter derives its workflow lineage from the controller,
|
|
395
|
+
* while a contextual adapter requires an exact match. Repeated agents, repeated workflows, and
|
|
396
|
+
* targets deeper than {@link import('./constants.js').MAX_WORKFLOW_DEPTH} are rejected before
|
|
397
|
+
* agent or runner activity. When {@link import('./types.js').AgentFunctionOptions.runner} is
|
|
398
|
+
* supplied, the adapter binds a recursion-safe {@link createWorkflowTool} onto the agent's
|
|
399
|
+
* `context.tools`, propagating opaque leaves, raw agents, lineage, and the native store. The
|
|
400
|
+
* task's cancellation propagates through the Agent's native per-run signal seam:
|
|
401
|
+
* `agent.generate({ signal: controller.signal })` resolves a partial `AgentResult` on a cancel
|
|
402
|
+
* (never rejects), projected onto its exact JSON fields.
|
|
403
|
+
*
|
|
404
|
+
* A bound agent is single-run. A concurrent branch sharing the same real agent is rejected before
|
|
405
|
+
* its fixed {@link import('./constants.js').WORKFLOW_TOOL_NAME} binding can be replaced. Toolbox
|
|
406
|
+
* cannot serialize opaque external wrappers that hide or bypass the raw agent registry; hosts
|
|
407
|
+
* must give such concurrent work distinct agents.
|
|
404
408
|
*
|
|
405
409
|
* @param agent - The live `AgentInterface` to run
|
|
406
|
-
* @param options - The nested-workflow
|
|
407
|
-
* @returns A {@link
|
|
410
|
+
* @param options - The nested-workflow composition and lineage options
|
|
411
|
+
* @returns A frozen {@link AgentFunction} that runs `agent` to its settled result
|
|
408
412
|
*
|
|
409
413
|
* @example
|
|
410
414
|
* ```ts
|
|
@@ -416,7 +420,7 @@ export declare const conditionShape: ObjectShape<{
|
|
|
416
420
|
* await runner.execute(definition, { functions: { review } })
|
|
417
421
|
* ```
|
|
418
422
|
*/
|
|
419
|
-
export declare function createAgentFunction(agent: AgentInterface, options?: AgentFunctionOptions):
|
|
423
|
+
export declare function createAgentFunction(agent: AgentInterface, options?: AgentFunctionOptions): AgentFunction;
|
|
420
424
|
|
|
421
425
|
/**
|
|
422
426
|
* Build an LLM-callable sub-agent delegation tool — resolves a live, seeded `AgentInterface`
|
|
@@ -532,20 +536,18 @@ export declare function createDatabaseDefinitionStore(driver?: DriverInterface):
|
|
|
532
536
|
* `TOOL` {@link import('./errors.js').ToolboxError}). When a `store` is configured, `'create'`
|
|
533
537
|
* persists the new {@link import('./types.js').DatabaseDefinition} and `'destroy'` deletes it.
|
|
534
538
|
*
|
|
535
|
-
* `'
|
|
536
|
-
* and storage, a NEW typed view) and calls its `migrate` against the OLD deployed schema —
|
|
537
|
-
* derived from the handle's OWN `export()` (via {@link import('./helpers.js').tableSchema}), so it
|
|
538
|
-
* works for any handle, config-tracked or caller-supplied via
|
|
539
|
-
* {@link import('./types.js').DatabaseToolOptions.databases}. `'records'` clamps its `criteria` to
|
|
539
|
+
* `'records'` clamps its `query` to
|
|
540
540
|
* {@link import('./types.js').DatabaseToolOptions.limit} (default
|
|
541
541
|
* {@link import('./constants.js').DATABASE_TOOL_LIMIT}) via
|
|
542
|
-
* {@link import('./helpers.js').
|
|
543
|
-
* than the cap. Every operation's `
|
|
544
|
-
* {@link import('./helpers.js').
|
|
542
|
+
* {@link import('./helpers.js').clampQuery}, reporting `truncated` when storage held more rows
|
|
543
|
+
* than the cap. Every operation's `query` is normalized via
|
|
544
|
+
* {@link import('./helpers.js').queryOf} (defaults an omitted condition `connector` to `'and'`).
|
|
545
545
|
* When {@link import('./types.js').DatabaseToolOptions.readonly} is `true`, every mutating
|
|
546
|
-
* operation throws a typed `TOOL` `ToolboxError` before doing anything.
|
|
547
|
-
* {@link import('./types.js').DatabaseToolOptions.timeout} is
|
|
548
|
-
*
|
|
546
|
+
* operation throws a typed `TOOL` `ToolboxError` before doing anything. A configured
|
|
547
|
+
* {@link import('./types.js').DatabaseToolOptions.timeout} is passed as a fresh
|
|
548
|
+
* `AbortSignal.timeout(timeout)` only to table operations whose current database API accepts
|
|
549
|
+
* operation options (`records`, `count`, `aggregate`, `add`, `set`, `update`, and `remove`). It is
|
|
550
|
+
* not an outer deadline for resolution, construction, schema inspection, `get`, or `close`. A typed `@orkestrel/database`
|
|
549
551
|
* failure (`DatabaseError`) re-surfaces as a typed `DATABASE` `ToolboxError` carrying the
|
|
550
552
|
* original {@link import('@orkestrel/database').DatabaseErrorCode} in `context.code`
|
|
551
553
|
* ({@link import('./helpers.js').databaseToolCode}); an `ToolboxError` thrown by this tool's own
|
|
@@ -840,7 +842,7 @@ export declare function createPromptTool(options: PromptToolOptions): ToolInterf
|
|
|
840
842
|
* (positional many-key form, AGENTS §9.2) or a single key. `'find'` and `'links'` clamp their
|
|
841
843
|
* result to {@link import('./types.js').RelationToolOptions.limit} (default
|
|
842
844
|
* {@link import('./constants.js').RELATION_TOOL_LIMIT}) — `'find'` probes one row past the
|
|
843
|
-
* effective limit (mirroring {@link import('./helpers.js').
|
|
845
|
+
* effective limit (mirroring {@link import('./helpers.js').clampQuery}'s idiom) to report
|
|
844
846
|
* `truncated`; `'links'` (which has no upstream pagination) fetches the FULL linked-key list and
|
|
845
847
|
* slices/truncates it the same way. `'link'` / `'unlink'` write / remove one `through` junction
|
|
846
848
|
* row.
|
|
@@ -870,17 +872,13 @@ export declare function createRelationTool(options: RelationToolOptions): ToolIn
|
|
|
870
872
|
* adapter that lets a `function`-form task run a `@orkestrel/tool` tool BY NAME.
|
|
871
873
|
*
|
|
872
874
|
* @remarks
|
|
873
|
-
*
|
|
874
|
-
* `WorkflowOptions.functions` registry like any other behavior
|
|
875
|
+
* Composes into a caller's `WorkflowOptions.functions` registry like any other behavior
|
|
875
876
|
* (`{ publish: createToolFunction(tools, 'publish') }`); the pure workflow runner has no
|
|
876
877
|
* knowledge of tools itself. The returned function executes `name` against `tools` with the
|
|
877
|
-
* task's `controller.input` as the call arguments
|
|
878
|
-
* `
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
* a programmer error (an explicit binding to a name that doesn't exist) — unlike the engine's
|
|
882
|
-
* own silent auto-complete of an unresolved task handler, this THROWS a typed `TOOL`
|
|
883
|
-
* `WorkflowError` (`@orkestrel/workflow`).
|
|
878
|
+
* task's `controller.input` as the call arguments. The adapter resolves the live tool, calls its
|
|
879
|
+
* `execute` method directly, and deep-gates the returned unknown through `parseJSONValue`.
|
|
880
|
+
* Genuine execution throws retain identity. An unregistered name or non-JSON return throws this
|
|
881
|
+
* package's typed `TOOL` `ToolboxError`.
|
|
884
882
|
*
|
|
885
883
|
* @param tools - The `ToolManagerInterface` (`@orkestrel/tool`) the named tool is registered on
|
|
886
884
|
* @param name - The registered tool's name
|
|
@@ -901,51 +899,55 @@ export declare function createRelationTool(options: RelationToolOptions): ToolIn
|
|
|
901
899
|
export declare function createToolFunction(tools: ToolManagerInterface, name: string): WorkflowFunction;
|
|
902
900
|
|
|
903
901
|
/**
|
|
904
|
-
* Compile the
|
|
905
|
-
*
|
|
906
|
-
*
|
|
902
|
+
* Compile the lenient workflow draft contract used by {@link createWorkflowTool}.
|
|
903
|
+
*
|
|
904
|
+
* @returns The compiled {@link import('./types.js').WorkflowDraft} contract
|
|
905
|
+
*/
|
|
906
|
+
export declare function createWorkflowDraftContract(): ContractInterface<WorkflowDraft>;
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Compose opaque host functions and raw agents into one immutable workflow registry.
|
|
907
910
|
*
|
|
908
911
|
* @remarks
|
|
909
|
-
*
|
|
910
|
-
*
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
*
|
|
914
|
-
* `minLength: 1`, so an explicitly-empty `id: ''` is REJECTED (parses to `undefined`), never
|
|
915
|
-
* auto-filled — keeping "garbage" distinct from "omitted". `run` stays optional (a plain name
|
|
916
|
-
* string).
|
|
912
|
+
* This is the target-aware composition boundary used by direct runner consumers and
|
|
913
|
+
* {@link createWorkflowTool}. Opaque leaves are copied unchanged, marked agent adapters are
|
|
914
|
+
* rejected from that channel, raw agents are rebound to the supplied lineage, collisions fail
|
|
915
|
+
* closed, and the returned null-prototype record prevents inherited names from becoming phantom
|
|
916
|
+
* Workflow handlers.
|
|
917
917
|
*
|
|
918
|
-
* @
|
|
918
|
+
* @param runner - The native runner propagated into contextual agent adapters
|
|
919
|
+
* @param options - Target lineage, opaque functions, raw agents, and native store
|
|
920
|
+
* @returns A frozen null-prototype snapshot of the target workflow's callable registry
|
|
919
921
|
*
|
|
920
922
|
* @example
|
|
921
923
|
* ```ts
|
|
922
|
-
* import {
|
|
924
|
+
* import { createWorkflowFunctions } from '@src/core'
|
|
925
|
+
* import { createWorkflowRunner } from '@orkestrel/workflow'
|
|
923
926
|
*
|
|
924
|
-
* const
|
|
925
|
-
* const
|
|
926
|
-
*
|
|
927
|
-
*
|
|
927
|
+
* const runner = createWorkflowRunner()
|
|
928
|
+
* const functions = createWorkflowFunctions(runner, {
|
|
929
|
+
* functions: { publish: async () => 'published' },
|
|
930
|
+
* agents: { review: reviewAgent },
|
|
931
|
+
* })
|
|
932
|
+
* await runner.execute(definition, { functions })
|
|
928
933
|
* ```
|
|
929
934
|
*/
|
|
930
|
-
export declare function
|
|
935
|
+
export declare function createWorkflowFunctions(runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): WorkflowFunctions;
|
|
931
936
|
|
|
932
937
|
/**
|
|
933
938
|
* Wrap a {@link WorkflowDefinition} as an LLM-callable tool — it ADVERTISES the SIMPLE flat
|
|
934
939
|
* authoring shape (`{ name?, steps: [{ name }] }`) as its `parameters` so even a small model can
|
|
935
940
|
* author a complete tree, and its handler EXPANDS / COMPLETES the authored blob, validates it
|
|
936
|
-
* against the STRICT contract, runs it through `runner`,
|
|
937
|
-
*
|
|
938
|
-
* workflow's final snapshot after the run settles.
|
|
941
|
+
* against the STRICT contract, and runs it through `runner`, forwarding the caller's optional
|
|
942
|
+
* named functions and native checkpoint store.
|
|
939
943
|
*
|
|
940
944
|
* @remarks
|
|
941
945
|
* A plain `ToolManagerInterface`-compatible tool (`@orkestrel/tool`), reproducing
|
|
942
|
-
*
|
|
943
|
-
*
|
|
946
|
+
* Toolbox's flat / draft / full authoring contract, strict soundness gate, and lineage guard.
|
|
947
|
+
* It is ALSO the propagation carrier
|
|
944
948
|
* {@link createAgentFunction} binds onto a wrapped agent's `context.tools`: because a tool
|
|
945
|
-
* handler receives
|
|
946
|
-
*
|
|
947
|
-
* and the handler enforces the SAME depth / cycle guard itself before running the nested
|
|
948
|
-
* workflow at `depth + 1` with the extended ancestry.
|
|
949
|
+
* handler receives only the model-supplied `args`, the immutable lineage is closed over at bind
|
|
950
|
+
* time. The authored target is appended and its zero-based depth derived from workflow tags.
|
|
949
951
|
*
|
|
950
952
|
* **Widened authoring surface (additive — the canonical contract + runner stay STRICT and
|
|
951
953
|
* unchanged).** A 2B model reliably CALLS the tool but cannot reliably emit the full four-level
|
|
@@ -960,17 +962,17 @@ export declare function createWorkflowDraftContract(): ContractInterface<Workflo
|
|
|
960
962
|
* super-set.
|
|
961
963
|
*
|
|
962
964
|
* The universal tool-handler contract (AGENTS §14): returns the plain run summary
|
|
963
|
-
* (`{ status, count }`) on success, THROWS a typed `
|
|
964
|
-
*
|
|
965
|
-
* (`DEPTH`). The `ToolManagerInterface` isolates every throw into the canonical tool result's
|
|
966
|
-
* top-level `error`, so nothing escapes the run. `options.
|
|
967
|
-
*
|
|
968
|
-
*
|
|
969
|
-
*
|
|
965
|
+
* (`{ status, count, durable?, fault? }`) on success, THROWS a typed `ToolboxError` on Toolbox
|
|
966
|
+
* boundary failures — malformed authored args (`TOOL`), or an over-deep / cyclic nested run
|
|
967
|
+
* (`DEPTH`) — and preserves genuine runner `WorkflowError`s. The `ToolManagerInterface` isolates every throw into the canonical tool result's
|
|
968
|
+
* top-level `error`, so nothing escapes the run. `options.lineage` is the propagation carrier
|
|
969
|
+
* across a workflow → agent → workflow chain. Opaque `functions` remain host leaves; raw `agents`
|
|
970
|
+
* are contextually adapted through {@link createWorkflowFunctions}; native checkpoint persistence
|
|
971
|
+
* makes the final snapshot retrievable without a second Toolbox write.
|
|
970
972
|
*
|
|
971
973
|
* @param definition - The workflow the tool runs when called with no authored args
|
|
972
974
|
* @param runner - The `WorkflowRunnerInterface` (`@orkestrel/workflow`) that executes the (nested) workflow
|
|
973
|
-
* @param options -
|
|
975
|
+
* @param options - Lineage-aware functions, agents, and optional native store
|
|
974
976
|
* @returns A `ToolInterface` (named {@link import('./constants.js').WORKFLOW_TOOL_NAME}) whose
|
|
975
977
|
* `parameters` advertise the flat authoring schema
|
|
976
978
|
*
|
|
@@ -984,7 +986,7 @@ export declare function createWorkflowDraftContract(): ContractInterface<Workflo
|
|
|
984
986
|
* const store = createMemoryWorkflowStore()
|
|
985
987
|
* const tool = createWorkflowTool(definition, runner, { store })
|
|
986
988
|
* const tools = createToolManager()
|
|
987
|
-
* tools.add(tool) // authored runs
|
|
989
|
+
* tools.add(tool) // authored runs now use native checkpoints through `store`
|
|
988
990
|
* ```
|
|
989
991
|
*/
|
|
990
992
|
export declare function createWorkflowTool(definition: WorkflowDefinition, runner: WorkflowRunnerInterface, options?: WorkflowToolOptions): ToolInterface;
|
|
@@ -994,12 +996,13 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
|
|
|
994
996
|
* 13-op union ({@link import('./shapers.js').workspaceToolShape}) as its `parameters`, and its
|
|
995
997
|
* handler PARSES the model-supplied args against that contract and DISPATCHES the matched
|
|
996
998
|
* operation against the manager's ACTIVE workspace (the registry ops drive the manager itself),
|
|
997
|
-
* returning the plain result
|
|
998
|
-
*
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
999
|
+
* returning the plain result. A malformed operation throws this package's `ToolboxError`; a
|
|
1000
|
+
* genuine workspace-domain failure propagates `@orkestrel/workspace`'s typed `WorkspaceError`.
|
|
1001
|
+
* EITHER drives a caller-supplied {@link WorkspaceToolOptions.manager} directly, OR
|
|
1002
|
+
* constructs a fresh `WorkspaceManagerInterface` (`@orkestrel/workspace`) over
|
|
1003
|
+
* {@link import('./types.js').WorkspaceToolOptions.store} (via `@orkestrel/workspace`'s
|
|
1004
|
+
* `createWorkspaceManager`); neither given constructs a manager backed by
|
|
1005
|
+
* `@orkestrel/workspace`'s in-memory store default.
|
|
1003
1006
|
*
|
|
1004
1007
|
* @remarks
|
|
1005
1008
|
* MANAGER-DRIVEN: every edit / read op (read / list / has / search / replace / write / splice /
|
|
@@ -1017,12 +1020,12 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
|
|
|
1017
1020
|
* `false`), never creating one and never throwing.
|
|
1018
1021
|
*
|
|
1019
1022
|
* The handler conforms to the universal tool-handler contract (AGENTS §14): it `contract.parse`s
|
|
1020
|
-
* the args, THROWS a `TOOL` `
|
|
1023
|
+
* the args, THROWS a `TOOL` `ToolboxError` when no operation arm matched (a malformed / unknown
|
|
1021
1024
|
* operation), else `switch`es on `op.operation` and RETURNS the plain result — letting a
|
|
1022
1025
|
* `WorkspaceError` raised by the live workspace (`MODALITY` / `PATTERN` / `RANGE`) PROPAGATE
|
|
1023
1026
|
* uncaught. The range edit is the FLAT `'splice'` op: its four flat caret integers are
|
|
1024
|
-
* reassembled into a `Range` (`@orkestrel/
|
|
1025
|
-
* `write`.
|
|
1027
|
+
* reassembled into a `Range` (`@orkestrel/workspace`) by `rangeOf` and fed to the workspace's
|
|
1028
|
+
* ranged `write`.
|
|
1026
1029
|
*
|
|
1027
1030
|
* @param options - `manager` (drive directly) OR `store` (build a manager over it); neither ⇒
|
|
1028
1031
|
* an in-memory-backed manager (see {@link import('./types.js').WorkspaceToolOptions})
|
|
@@ -1040,68 +1043,24 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
|
|
|
1040
1043
|
*/
|
|
1041
1044
|
export declare function createWorkspaceTool(options?: WorkspaceToolOptions): ToolInterface;
|
|
1042
1045
|
|
|
1043
|
-
/**
|
|
1044
|
-
* Normalize the database tool's parsed SERIALIZED criteria into a live `@orkestrel/database`
|
|
1045
|
-
* {@link Criteria} — default each condition's OMITTED `connector` to `'and'`.
|
|
1046
|
-
*
|
|
1047
|
-
* @remarks
|
|
1048
|
-
* The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
|
|
1049
|
-
* on the last condition (it has nothing to join FORWARD to); the compiled `Condition` a live
|
|
1050
|
-
* `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
|
|
1051
|
-
* `limit` / `offset` pass through unchanged. Pure and total.
|
|
1052
|
-
*
|
|
1053
|
-
* @param criteria - The parsed criteria (or `undefined`)
|
|
1054
|
-
* @returns The equivalent live `Criteria`, or `undefined` when `criteria` is `undefined`
|
|
1055
|
-
*/
|
|
1056
|
-
export declare function criteriaOf(criteria: Readonly<{
|
|
1057
|
-
conditions?: readonly Readonly<{
|
|
1058
|
-
column: string;
|
|
1059
|
-
operator: Condition['operator'];
|
|
1060
|
-
values: readonly unknown[];
|
|
1061
|
-
connector?: Connector;
|
|
1062
|
-
}>[];
|
|
1063
|
-
order?: readonly Readonly<{
|
|
1064
|
-
column: string;
|
|
1065
|
-
direction: Direction;
|
|
1066
|
-
}>[];
|
|
1067
|
-
limit?: number;
|
|
1068
|
-
offset?: number;
|
|
1069
|
-
}> | undefined): Criteria | undefined;
|
|
1070
|
-
|
|
1071
|
-
/** The SERIALIZED criteria form — conditions, order, and pagination. */
|
|
1072
|
-
export declare const criteriaShape: ObjectShape<{
|
|
1073
|
-
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1074
|
-
column: StringShape;
|
|
1075
|
-
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1076
|
-
values: ArrayShape<JSONShape>;
|
|
1077
|
-
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1078
|
-
}, false>>>;
|
|
1079
|
-
order: OptionalShape<ArrayShape<ObjectShape<{
|
|
1080
|
-
column: StringShape;
|
|
1081
|
-
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1082
|
-
}, false>>>;
|
|
1083
|
-
limit: OptionalShape<NumberShape>;
|
|
1084
|
-
offset: OptionalShape<NumberShape>;
|
|
1085
|
-
}, false>;
|
|
1086
|
-
|
|
1087
1046
|
/**
|
|
1088
1047
|
* The DESCRIPTION the upcoming database tool will advertise — a multi-line guide that teaches a
|
|
1089
|
-
* small model the operation list, the SERIALIZED
|
|
1048
|
+
* small model the operation list, the SERIALIZED query form, and the {@link import('./types.js').TableSpec}
|
|
1090
1049
|
* column DSL.
|
|
1091
1050
|
*
|
|
1092
1051
|
* @remarks
|
|
1093
|
-
* The
|
|
1052
|
+
* The query form is deliberately SERIALIZED (never fluent) — every condition is a flat object
|
|
1094
1053
|
* `{ column, operator, values, connector? }` where `values` is ALWAYS an array, even for a
|
|
1095
1054
|
* single-value operator (`{ column: 'age', operator: 'from', values: [18] }`), so a small model
|
|
1096
1055
|
* never has to chain method calls or guess whether a value is scalar or a list.
|
|
1097
1056
|
*/
|
|
1098
1057
|
export declare const DATABASE_TOOL_DESCRIPTION: string;
|
|
1099
1058
|
|
|
1100
|
-
/** The default cap on rows a `records`
|
|
1059
|
+
/** The default cap on rows a `records` call returns when the caller omits `query.limit` — the upcoming database tool's default row ceiling. */
|
|
1101
1060
|
export declare const DATABASE_TOOL_LIMIT = 1000;
|
|
1102
1061
|
|
|
1103
|
-
/** The database
|
|
1104
|
-
export declare const DATABASE_TOOL_MUTATIONS:
|
|
1062
|
+
/** The runtime-frozen database-tool mutation names disabled by `DatabaseToolOptions.readonly`. */
|
|
1063
|
+
export declare const DATABASE_TOOL_MUTATIONS: readonly string[];
|
|
1105
1064
|
|
|
1106
1065
|
/**
|
|
1107
1066
|
* The name the upcoming `createDatabaseTool` factory will advertise by default — the key a model
|
|
@@ -1118,24 +1077,26 @@ export declare const DATABASE_TOOL_NAME = "database";
|
|
|
1118
1077
|
* The lean {@link import('@orkestrel/tool').ToolInterface.summary} the upcoming database tool
|
|
1119
1078
|
* will advertise in place of {@link DATABASE_TOOL_DESCRIPTION}.
|
|
1120
1079
|
*/
|
|
1121
|
-
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,
|
|
1080
|
+
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.";
|
|
1122
1081
|
|
|
1123
1082
|
/**
|
|
1124
|
-
* One database's CONFIG-ONLY definition — `id` + `driver` + {@link TableSpec}
|
|
1125
|
-
*
|
|
1083
|
+
* One database's CONFIG-ONLY definition — `id` + `driver` + {@link TableSpec}, with optional
|
|
1084
|
+
* `primary`, `indexes`, and `version` schema configuration.
|
|
1126
1085
|
*
|
|
1127
1086
|
* @remarks
|
|
1128
1087
|
* A `DatabaseDefinition` is NEVER a live handle — it is the durable, serializable config a
|
|
1129
1088
|
* {@link DefinitionStoreInterface} persists and a tool factory turns into a real
|
|
1130
1089
|
* `@orkestrel/database` `DatabaseInterface` (via `createDatabase` + {@link import('./helpers.js').expandTables})
|
|
1131
|
-
* on demand. `
|
|
1132
|
-
* driver
|
|
1090
|
+
* on demand. `primary` maps table names to primary-key columns; `indexes` maps table names to
|
|
1091
|
+
* index column groups; `version` opts a capable driver into open-time schema reconciliation.
|
|
1133
1092
|
*/
|
|
1134
1093
|
export declare interface DatabaseDefinition {
|
|
1135
1094
|
readonly id: string;
|
|
1136
1095
|
readonly driver: string;
|
|
1137
1096
|
readonly tables: TableSpec;
|
|
1138
|
-
readonly
|
|
1097
|
+
readonly primary?: PrimaryMap;
|
|
1098
|
+
readonly indexes?: IndexMap;
|
|
1099
|
+
readonly version?: number;
|
|
1139
1100
|
}
|
|
1140
1101
|
|
|
1141
1102
|
/** One opaque persisted row — the shape a `TableInterface<DatabaseDefinitionRow>`-backed store reads/writes; `definition` is narrowed with {@link import('./helpers.js').isDatabaseDefinition} on read. */
|
|
@@ -1209,7 +1170,7 @@ export declare class DatabaseDefinitionStore implements DefinitionStoreInterface
|
|
|
1209
1170
|
* ```ts
|
|
1210
1171
|
* import { DatabaseResolver } from '@orkestrel/toolbox'
|
|
1211
1172
|
*
|
|
1212
|
-
* const resolver = new DatabaseResolver(handles, drivers,
|
|
1173
|
+
* const resolver = new DatabaseResolver(handles, drivers, generator, store)
|
|
1213
1174
|
* const database = await resolver.resolve('shop')
|
|
1214
1175
|
* ```
|
|
1215
1176
|
*/
|
|
@@ -1220,10 +1181,10 @@ export declare class DatabaseResolver {
|
|
|
1220
1181
|
*
|
|
1221
1182
|
* @param handles - Initial live database handles cached by id
|
|
1222
1183
|
* @param drivers - Driver factories keyed by definition driver name
|
|
1223
|
-
* @param
|
|
1184
|
+
* @param generator - Optional key generator supplied to newly created databases
|
|
1224
1185
|
* @param store - Optional persistent definition store
|
|
1225
1186
|
*/
|
|
1226
|
-
constructor(handles: ReadonlyMap<string, DatabaseInterface>, drivers: Readonly<Record<string, () => DriverInterface>>,
|
|
1187
|
+
constructor(handles: ReadonlyMap<string, DatabaseInterface>, drivers: Readonly<Record<string, () => DriverInterface>>, generator?: KeyFunction, store?: DefinitionStoreInterface);
|
|
1227
1188
|
/**
|
|
1228
1189
|
* Determine whether a live database is cached by id.
|
|
1229
1190
|
*
|
|
@@ -1281,22 +1242,26 @@ export declare function databaseToolCode(error: unknown): DatabaseErrorCode | un
|
|
|
1281
1242
|
* - `databases` — live `DatabaseInterface` handles to seed the tool's cache with (e.g. a
|
|
1282
1243
|
* caller-constructed database it should manage alongside store-backed ones); keyed by the id a
|
|
1283
1244
|
* call's `id` field addresses.
|
|
1284
|
-
* - `store` — the {@link DefinitionStoreInterface} the `'create'`
|
|
1285
|
-
*
|
|
1245
|
+
* - `store` — the {@link DefinitionStoreInterface} the `'create'` operation persists its
|
|
1246
|
+
* {@link DatabaseDefinition} CONFIG through, and `'destroy'` deletes from; also the source
|
|
1286
1247
|
* `'get'`/every other operation resolves an id from when it isn't already cached. Omitted means
|
|
1287
1248
|
* no persistence — a database created without a store lives only for the tool's lifetime.
|
|
1288
1249
|
* - `drivers` — registry of driver-name to `() => DriverInterface` factories a `'create'` call's
|
|
1289
1250
|
* `driver` field (or a persisted definition's `driver`) resolves against. Defaults to
|
|
1290
1251
|
* `{ memory: () => createMemoryDriver() }` (`@orkestrel/database`).
|
|
1291
|
-
* - `
|
|
1292
|
-
* used when a written row lacks its primary key.
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1252
|
+
* - `generator` — the optional `KeyFunction` (`@orkestrel/database`) every minted database is
|
|
1253
|
+
* constructed with, used when a written row lacks its primary key. Omitted delegates to the
|
|
1254
|
+
* database's default generator.
|
|
1255
|
+
* - `limit` — the `'records'` row cap — via {@link import('./helpers.js').clampQuery}
|
|
1256
|
+
* — enforce when a call's `query.limit` is omitted or exceeds it. Defaults to
|
|
1295
1257
|
* {@link import('./constants.js').DATABASE_TOOL_LIMIT}.
|
|
1296
|
-
* - `timeout` —
|
|
1297
|
-
*
|
|
1258
|
+
* - `timeout` — a nonnegative safe-integer number of milliseconds. A fresh
|
|
1259
|
+
* `AbortSignal.timeout(timeout)` is passed only to table operations whose current database API
|
|
1260
|
+
* accepts operation options: `records`, `count`, `aggregate`, `add`, `set`, `update`, and
|
|
1261
|
+
* `remove`. It does not bound store resolution, construction, schema inspection, `get`, or
|
|
1262
|
+
* `close`, and is not an outer tool-call deadline.
|
|
1298
1263
|
* - `readonly` — when `true`, every mutating operation (`'create'` / `'add'` / `'set'` /
|
|
1299
|
-
* `'update'` / `'remove'` / `'
|
|
1264
|
+
* `'update'` / `'remove'` / `'destroy'`) throws a typed `TOOL`
|
|
1300
1265
|
* {@link import('./errors.js').ToolboxError} before doing anything.
|
|
1301
1266
|
* - `name` / `description` — advertised tool overrides; default to
|
|
1302
1267
|
* {@link import('./constants.js').DATABASE_TOOL_NAME} / {@link import('./constants.js').DATABASE_TOOL_DESCRIPTION}.
|
|
@@ -1307,7 +1272,7 @@ export declare interface DatabaseToolOptions {
|
|
|
1307
1272
|
readonly databases?: Readonly<Record<string, DatabaseInterface>>;
|
|
1308
1273
|
readonly store?: DefinitionStoreInterface;
|
|
1309
1274
|
readonly drivers?: Readonly<Record<string, () => DriverInterface>>;
|
|
1310
|
-
readonly
|
|
1275
|
+
readonly generator?: KeyFunction;
|
|
1311
1276
|
readonly limit?: number;
|
|
1312
1277
|
readonly timeout?: number;
|
|
1313
1278
|
readonly readonly?: boolean;
|
|
@@ -1315,17 +1280,17 @@ export declare interface DatabaseToolOptions {
|
|
|
1315
1280
|
|
|
1316
1281
|
/**
|
|
1317
1282
|
* The shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
|
|
1318
|
-
* discriminated by `operation` into the
|
|
1283
|
+
* discriminated by `operation` into the 11 database operations (`'create'` / `'tables'` /
|
|
1319
1284
|
* `'get'` / `'records'` / `'count'` / `'aggregate'` / `'add'` / `'set'` / `'update'` /
|
|
1320
|
-
* `'remove'` / `'
|
|
1285
|
+
* `'remove'` / `'destroy'`).
|
|
1321
1286
|
*
|
|
1322
1287
|
* @remarks
|
|
1323
|
-
* Every arm carries `id` (the database id). `'create'`
|
|
1288
|
+
* Every arm carries `id` (the database id). `'create'` carries `tables` (the
|
|
1324
1289
|
* {@link import('./types.js').TableSpec} column DSL, compiled via
|
|
1325
1290
|
* {@link import('./helpers.js').expandTables}); `'get'` / `'update'` / `'remove'` carry `key`
|
|
1326
1291
|
* (one key or an array of keys, positional); `'add'` / `'set'` carry `row` (one row or an array of
|
|
1327
1292
|
* rows); `'update'` also carries `changes` (a loose partial row); `'records'` / `'count'` /
|
|
1328
|
-
* `'aggregate'` carry an optional `
|
|
1293
|
+
* `'aggregate'` carry an optional `query` (the SERIALIZED form — `values` is ALWAYS an array,
|
|
1329
1294
|
* even for a single-value operator, so a caller never chains method calls or guesses arity).
|
|
1330
1295
|
*/
|
|
1331
1296
|
export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
|
|
@@ -1338,7 +1303,9 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
1338
1303
|
}, false>]>>;
|
|
1339
1304
|
}, false>>;
|
|
1340
1305
|
driver: OptionalShape<StringShape>;
|
|
1341
|
-
|
|
1306
|
+
primary: OptionalShape<ObjectShape<Record<never, never>, StringShape>>;
|
|
1307
|
+
indexes: OptionalShape<ObjectShape<Record<never, never>, ArrayShape<ArrayShape<StringShape>>>>;
|
|
1308
|
+
version: OptionalShape<NumberShape>;
|
|
1342
1309
|
}, false>, ObjectShape<{
|
|
1343
1310
|
operation: LiteralShape<readonly ["tables"]>;
|
|
1344
1311
|
id: StringShape;
|
|
@@ -1351,7 +1318,7 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
1351
1318
|
operation: LiteralShape<readonly ["records"]>;
|
|
1352
1319
|
id: StringShape;
|
|
1353
1320
|
table: StringShape;
|
|
1354
|
-
|
|
1321
|
+
query: OptionalShape<ObjectShape<{
|
|
1355
1322
|
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1356
1323
|
column: StringShape;
|
|
1357
1324
|
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
@@ -1369,7 +1336,7 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
1369
1336
|
operation: LiteralShape<readonly ["count"]>;
|
|
1370
1337
|
id: StringShape;
|
|
1371
1338
|
table: StringShape;
|
|
1372
|
-
|
|
1339
|
+
query: OptionalShape<ObjectShape<{
|
|
1373
1340
|
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1374
1341
|
column: StringShape;
|
|
1375
1342
|
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
@@ -1389,7 +1356,7 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
1389
1356
|
table: StringShape;
|
|
1390
1357
|
function: LiteralShape<readonly ["count", "sum", "average", "minimum", "maximum"]>;
|
|
1391
1358
|
column: StringShape;
|
|
1392
|
-
|
|
1359
|
+
query: OptionalShape<ObjectShape<{
|
|
1393
1360
|
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1394
1361
|
column: StringShape;
|
|
1395
1362
|
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
@@ -1424,15 +1391,6 @@ export declare const databaseToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
1424
1391
|
id: StringShape;
|
|
1425
1392
|
table: StringShape;
|
|
1426
1393
|
key: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1427
|
-
}, false>, ObjectShape<{
|
|
1428
|
-
operation: LiteralShape<readonly ["migrate"]>;
|
|
1429
|
-
id: StringShape;
|
|
1430
|
-
tables: ObjectShape<Record<never, never>, ObjectShape<{
|
|
1431
|
-
columns: ObjectShape<Record<never, never>, UnionShape<readonly [ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
|
|
1432
|
-
type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
1433
|
-
optional: OptionalShape<BooleanShape>;
|
|
1434
|
-
}, false>]>>;
|
|
1435
|
-
}, false>>;
|
|
1436
1394
|
}, false>, ObjectShape<{
|
|
1437
1395
|
operation: LiteralShape<readonly ["destroy"]>;
|
|
1438
1396
|
id: StringShape;
|
|
@@ -1449,6 +1407,14 @@ export declare interface DefinitionStoreInterface {
|
|
|
1449
1407
|
delete(id: string): Promise<void>;
|
|
1450
1408
|
}
|
|
1451
1409
|
|
|
1410
|
+
/**
|
|
1411
|
+
* Derive the zero-based workflow nesting depth from a valid lineage.
|
|
1412
|
+
*
|
|
1413
|
+
* @param lineage - The workflow/agent chain
|
|
1414
|
+
* @returns Zero for an empty/root lineage, then one per nested workflow
|
|
1415
|
+
*/
|
|
1416
|
+
export declare function deriveWorkflowDepth(lineage: WorkflowLineage): number;
|
|
1417
|
+
|
|
1452
1418
|
/**
|
|
1453
1419
|
* The DESCRIPTION {@link import('./factories.js').createDescribeTool} advertises.
|
|
1454
1420
|
*
|
|
@@ -1606,9 +1572,10 @@ export declare function expandInclude(paths: readonly string[] | undefined, dept
|
|
|
1606
1572
|
* `name` becomes the task's `run` (the behavior-registry key). Ids/names are auto-filled
|
|
1607
1573
|
* positionally — it builds an ids-omitted {@link WorkflowDraft} and delegates to
|
|
1608
1574
|
* {@link completeDraft}, so the two lenient surfaces share ONE synthesis path (step `i` → phase
|
|
1609
|
-
* `phase-<i>`, its task `phase-<i>-task-0`). The optional `name` becomes the workflow's
|
|
1610
|
-
*
|
|
1611
|
-
*
|
|
1575
|
+
* `phase-<i>`, its task `phase-<i>-task-0`). The optional `name` becomes both the workflow's
|
|
1576
|
+
* deterministic id and its name, so named flat workflows retain distinct persistence keys;
|
|
1577
|
+
* omission keeps the shared draft fallback `wf`. The result is a complete definition the caller
|
|
1578
|
+
* validates against the STRICT contract before running.
|
|
1612
1579
|
*
|
|
1613
1580
|
* @param flat - The flat steps blob (`{ name?, steps: [{ name }] }`)
|
|
1614
1581
|
* @returns A complete {@link WorkflowDefinition} (one one-task phase per step)
|
|
@@ -1616,19 +1583,29 @@ export declare function expandInclude(paths: readonly string[] | undefined, dept
|
|
|
1616
1583
|
export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
|
|
1617
1584
|
|
|
1618
1585
|
/**
|
|
1619
|
-
* Compile a {@link TableSpec} into the `@orkestrel/database` {@link
|
|
1586
|
+
* Compile a {@link TableSpec} into the `@orkestrel/database` {@link TableMap} it configures —
|
|
1620
1587
|
* each {@link ColumnSpec} maps to the matching primitive shaper (`'string'` → `stringShape()`,
|
|
1621
1588
|
* `'integer'` → `integerShape()`, `'number'` → `numberShape()`, `'boolean'` → `booleanShape()`),
|
|
1622
1589
|
* wrapped in `optionalShape` when the column declares `optional: true`. Total, pure.
|
|
1623
1590
|
*
|
|
1624
1591
|
* @param spec - The small-model-facing table layout
|
|
1625
|
-
* @returns The compiled `
|
|
1592
|
+
* @returns The compiled `TableMap` a `@orkestrel/database` `createDatabase` call accepts
|
|
1593
|
+
*/
|
|
1594
|
+
export declare function expandTables(spec: TableSpec): TableMap;
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Append one tag to a workflow lineage and return a frozen copy.
|
|
1598
|
+
*
|
|
1599
|
+
* @param lineage - The valid chain to extend
|
|
1600
|
+
* @param tag - The workflow or agent tag to append
|
|
1601
|
+
* @returns The validated immutable extension
|
|
1626
1602
|
*/
|
|
1627
|
-
export declare function
|
|
1603
|
+
export declare function extendLineage(lineage: WorkflowLineage, tag: string): WorkflowLineage;
|
|
1628
1604
|
|
|
1629
1605
|
/** Flat dot-path relation include list, expanded via {@link import('./helpers.js').expandInclude}. */
|
|
1630
1606
|
export declare const includeShape: OptionalShape<ArrayShape<StringShape>>;
|
|
1631
1607
|
|
|
1608
|
+
/** The schema-inference protocol {@link import('./factories.js').createInferTool} advertises. */
|
|
1632
1609
|
export declare const INFER_TOOL_DESCRIPTION: string;
|
|
1633
1610
|
|
|
1634
1611
|
/**
|
|
@@ -1677,6 +1654,14 @@ export declare const inferToolShape: ObjectShape<{
|
|
|
1677
1654
|
candidates: OptionalShape<ArrayShape<JSONShape>>;
|
|
1678
1655
|
}, false>;
|
|
1679
1656
|
|
|
1657
|
+
/**
|
|
1658
|
+
* Narrow an unknown callable to Toolbox's frozen contextual agent adapter metadata.
|
|
1659
|
+
*
|
|
1660
|
+
* @param value - The value to inspect
|
|
1661
|
+
* @returns Whether it is a frozen {@link AgentFunction} with a frozen valid lineage
|
|
1662
|
+
*/
|
|
1663
|
+
export declare function isAgentFunction(value: unknown): value is AgentFunction;
|
|
1664
|
+
|
|
1680
1665
|
/** Narrow an unknown value to a {@link import('./types.js').ColumnKind}. */
|
|
1681
1666
|
export declare function isColumnKind(value: unknown): value is ColumnKind;
|
|
1682
1667
|
|
|
@@ -1685,9 +1670,10 @@ export declare function isColumnSpec(value: unknown): value is ColumnSpec;
|
|
|
1685
1670
|
|
|
1686
1671
|
/**
|
|
1687
1672
|
* Narrow an unknown value to a {@link DatabaseDefinition} — a non-empty `id` + `driver`, a
|
|
1688
|
-
* `tables` record whose every value is `{ columns: record of valid ColumnSpec }`,
|
|
1689
|
-
* `
|
|
1690
|
-
* applies to an untrusted persisted blob
|
|
1673
|
+
* `tables` record whose every value is `{ columns: record of valid ColumnSpec }`, plus optional
|
|
1674
|
+
* `primary`, `indexes`, and finite `version` schema configuration. The boundary guard a
|
|
1675
|
+
* {@link import('./types.js').DefinitionStoreInterface} applies to an untrusted persisted blob
|
|
1676
|
+
* before trusting it as a definition (never an `as`).
|
|
1691
1677
|
*/
|
|
1692
1678
|
export declare function isDatabaseDefinition(value: unknown): value is DatabaseDefinition;
|
|
1693
1679
|
|
|
@@ -1710,12 +1696,28 @@ export declare function isDatabaseDefinition(value: unknown): value is DatabaseD
|
|
|
1710
1696
|
*/
|
|
1711
1697
|
export declare function isToolboxError(value: unknown): value is ToolboxError;
|
|
1712
1698
|
|
|
1699
|
+
/**
|
|
1700
|
+
* Narrow an unknown value to a valid alternating workflow lineage.
|
|
1701
|
+
*
|
|
1702
|
+
* @param value - The value to inspect
|
|
1703
|
+
* @returns Whether `value` is a unique, nonempty-tagged workflow/agent chain
|
|
1704
|
+
*/
|
|
1705
|
+
export declare function isWorkflowLineage(value: unknown): value is WorkflowLineage;
|
|
1706
|
+
|
|
1713
1707
|
/** One key value — a string or number; the array form (multiple keys, positional) resolves FIRST per AGENTS §9.2. */
|
|
1714
1708
|
export declare const keyShape: UnionShape<readonly [ ArrayShape<UnionShape<readonly [ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1715
1709
|
|
|
1716
1710
|
/** Map one {@link import('./types.js').ColumnKind} to its primitive `@orkestrel/database` shape — the leaf {@link columnShape} wraps. */
|
|
1717
1711
|
export declare function kindShape(kind: ColumnKind): ContractShape;
|
|
1718
1712
|
|
|
1713
|
+
/**
|
|
1714
|
+
* Build a validated, copied, and frozen workflow lineage value.
|
|
1715
|
+
*
|
|
1716
|
+
* @param lineage - The configured chain; omitted means a direct root
|
|
1717
|
+
* @returns An immutable caller-isolated lineage
|
|
1718
|
+
*/
|
|
1719
|
+
export declare function lineageOf(lineage?: WorkflowLineage): WorkflowLineage;
|
|
1720
|
+
|
|
1719
1721
|
/** Which registered relation manager to address — omitted resolves to the sole registered manager. */
|
|
1720
1722
|
export declare const managerShape: OptionalShape<StringShape>;
|
|
1721
1723
|
|
|
@@ -1725,11 +1727,9 @@ export declare const managerShape: OptionalShape<StringShape>;
|
|
|
1725
1727
|
* {@link import('./factories.js').createWorkflowTool}'s depth/cycle guards enforce.
|
|
1726
1728
|
*
|
|
1727
1729
|
* @remarks
|
|
1728
|
-
*
|
|
1729
|
-
*
|
|
1730
|
-
*
|
|
1731
|
-
* workflow through its bound workflow tool (that would be depth `MAX_WORKFLOW_DEPTH + 1`), so
|
|
1732
|
-
* the over-deep invocation is REJECTED (a typed `DEPTH` `WorkflowError` throw, `@orkestrel/workflow`).
|
|
1730
|
+
* Depth is zero-based and counts workflow tags after the root: the root plus eight nested
|
|
1731
|
+
* workflows is allowed, while a ninth nested workflow is rejected with this package's typed
|
|
1732
|
+
* `DEPTH` `ToolboxError`.
|
|
1733
1733
|
*/
|
|
1734
1734
|
export declare const MAX_WORKFLOW_DEPTH = 8;
|
|
1735
1735
|
|
|
@@ -1741,7 +1741,8 @@ export declare const MAX_WORKFLOW_DEPTH = 8;
|
|
|
1741
1741
|
*
|
|
1742
1742
|
* @remarks
|
|
1743
1743
|
* A plain `Map<string, DatabaseDefinition>` (AGENTS §21 — the definition is already pure,
|
|
1744
|
-
* self-contained CONFIG-only JSON, so no encoding is needed for the memory tier).
|
|
1744
|
+
* self-contained CONFIG-only JSON, so no encoding is needed for the memory tier). Values are
|
|
1745
|
+
* structured-cloned on both write and read, keeping caller mutation outside the store. There is NO
|
|
1745
1746
|
* idle-TTL and NO eviction: a persisted definition lives until an explicit `delete`. A durable
|
|
1746
1747
|
* backend (JSON / SQLite / IndexedDB) swaps in through the SAME interface without touching a
|
|
1747
1748
|
* consumer — its driver-pluggable twin is
|
|
@@ -1810,6 +1811,7 @@ export declare const phaseDraftShape: ObjectShape<{
|
|
|
1810
1811
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
1811
1812
|
}, false>;
|
|
1812
1813
|
|
|
1814
|
+
/** The full prompt protocol {@link import('./factories.js').createPromptTool} advertises. */
|
|
1813
1815
|
export declare const PROMPT_TOOL_DESCRIPTION: string;
|
|
1814
1816
|
|
|
1815
1817
|
/**
|
|
@@ -1893,6 +1895,50 @@ export declare const promptToolShape: ObjectShape<{
|
|
|
1893
1895
|
timeout: OptionalShape<NumberShape>;
|
|
1894
1896
|
}, false>;
|
|
1895
1897
|
|
|
1898
|
+
/**
|
|
1899
|
+
* Normalize the database tool's parsed SERIALIZED query into a live `@orkestrel/database`
|
|
1900
|
+
* {@link QueryInput} — default each condition's OMITTED `connector` to `'and'`.
|
|
1901
|
+
*
|
|
1902
|
+
* @remarks
|
|
1903
|
+
* The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
|
|
1904
|
+
* on the last condition (it has nothing to join FORWARD to); the compiled `Condition` a live
|
|
1905
|
+
* `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
|
|
1906
|
+
* `limit` / `offset` pass through unchanged. Pure and total.
|
|
1907
|
+
*
|
|
1908
|
+
* @param query - The parsed query (or `undefined`)
|
|
1909
|
+
* @returns The equivalent live `QueryInput`, or `undefined` when `query` is `undefined`
|
|
1910
|
+
*/
|
|
1911
|
+
export declare function queryOf(query: Readonly<{
|
|
1912
|
+
conditions?: readonly Readonly<{
|
|
1913
|
+
column: string;
|
|
1914
|
+
operator: Condition['operator'];
|
|
1915
|
+
values: readonly unknown[];
|
|
1916
|
+
connector?: ConditionConnector;
|
|
1917
|
+
}>[];
|
|
1918
|
+
order?: readonly Readonly<{
|
|
1919
|
+
column: string;
|
|
1920
|
+
direction: OrderDirection;
|
|
1921
|
+
}>[];
|
|
1922
|
+
limit?: number;
|
|
1923
|
+
offset?: number;
|
|
1924
|
+
}> | undefined): QueryInput | undefined;
|
|
1925
|
+
|
|
1926
|
+
/** The SERIALIZED query form — conditions, order, and pagination. */
|
|
1927
|
+
export declare const queryShape: ObjectShape<{
|
|
1928
|
+
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1929
|
+
column: StringShape;
|
|
1930
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1931
|
+
values: ArrayShape<JSONShape>;
|
|
1932
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1933
|
+
}, false>>>;
|
|
1934
|
+
order: OptionalShape<ArrayShape<ObjectShape<{
|
|
1935
|
+
column: StringShape;
|
|
1936
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1937
|
+
}, false>>>;
|
|
1938
|
+
limit: OptionalShape<NumberShape>;
|
|
1939
|
+
offset: OptionalShape<NumberShape>;
|
|
1940
|
+
}, false>;
|
|
1941
|
+
|
|
1896
1942
|
/** The default cap on how many `include` path segments deep a `load` / `find` call may traverse — the relation tool's default include-depth ceiling. */
|
|
1897
1943
|
export declare const RELATION_TOOL_DEPTH = 3;
|
|
1898
1944
|
|
|
@@ -2055,25 +2101,10 @@ export declare const stepShape: ObjectShape<{
|
|
|
2055
2101
|
name: StringShape;
|
|
2056
2102
|
}, false>;
|
|
2057
2103
|
|
|
2058
|
-
/**
|
|
2059
|
-
* Build one {@link TableSchema} from a table NAME and its `@orkestrel/database` `TableExport` —
|
|
2060
|
-
* the "deployed" schema shape `DatabaseInterface.migrate` diffs against, derived from a LIVE
|
|
2061
|
-
* handle's `export()` rather than a re-declared {@link TableSpec}, so it works for ANY handle
|
|
2062
|
-
* (config-tracked or caller-supplied).
|
|
2063
|
-
*
|
|
2064
|
-
* @param name - The table name
|
|
2065
|
-
* @param table - The table's `TableExport` (`{ key, columns }`, `@orkestrel/database`)
|
|
2066
|
-
* @returns The equivalent {@link TableSchema} (`indexes` empty — this package declares none)
|
|
2067
|
-
*/
|
|
2068
|
-
export declare function tableSchema(name: string, table: Readonly<{
|
|
2069
|
-
key: string;
|
|
2070
|
-
columns: Readonly<Record<string, ContractShape>>;
|
|
2071
|
-
}>): TableSchema;
|
|
2072
|
-
|
|
2073
2104
|
/**
|
|
2074
2105
|
* A database's table layout — one entry per table, each a flat map of column name to
|
|
2075
2106
|
* {@link ColumnSpec}. The small-model-facing DSL {@link import('./helpers.js').expandTables}
|
|
2076
|
-
* compiles into an `@orkestrel/database` `
|
|
2107
|
+
* compiles into an `@orkestrel/database` `TableMap`.
|
|
2077
2108
|
*/
|
|
2078
2109
|
export declare type TableSpec = Readonly<Record<string, Readonly<{
|
|
2079
2110
|
columns: Readonly<Record<string, ColumnSpec>>;
|
|
@@ -2099,11 +2130,11 @@ export declare interface TaskDraft {
|
|
|
2099
2130
|
readonly id?: string;
|
|
2100
2131
|
readonly name?: string;
|
|
2101
2132
|
readonly description?: string;
|
|
2102
|
-
/** The behavior reference — a registry key resolved against a workflow's functions registry at construction; omitted ⇒ no
|
|
2133
|
+
/** The behavior reference — a registry key resolved against a workflow's functions registry at construction; omitted ⇒ a deliberate JSON `null` no-op. */
|
|
2103
2134
|
readonly run?: string;
|
|
2104
|
-
/** Extra attempts after the first on failure (a non-negative integer);
|
|
2135
|
+
/** Extra attempts after the first on failure (a non-negative integer); persisted with the workflow. */
|
|
2105
2136
|
readonly retries?: number;
|
|
2106
|
-
/** The per-attempt deadline in milliseconds (
|
|
2137
|
+
/** The per-attempt deadline in milliseconds (`0..MAX_TIMER_MS`); persisted with the workflow. */
|
|
2107
2138
|
readonly timeout?: number;
|
|
2108
2139
|
}
|
|
2109
2140
|
|
|
@@ -2138,13 +2169,9 @@ export declare const taskDraftShape: ObjectShape<{
|
|
|
2138
2169
|
export declare function terminalToolCode(error: unknown): ToolboxErrorCode | undefined;
|
|
2139
2170
|
|
|
2140
2171
|
/**
|
|
2141
|
-
*
|
|
2142
|
-
*
|
|
2143
|
-
*
|
|
2144
|
-
* exceed the configured depth bound or re-enter an ancestor (`DEPTH`), a prompt cycle
|
|
2145
|
-
* (`DEADLOCK`), a prompt that expired before it was answered (`EXPIRE`), or an answer that
|
|
2146
|
-
* failed to apply (`ANSWER`) — the last three thrown by
|
|
2147
|
-
* {@link import('./factories.js').createPromptTool} / {@link import('./factories.js').createAnswerTool}.
|
|
2172
|
+
* A package-owned tool-call failure: malformed input or unresolved configuration (`TOOL`),
|
|
2173
|
+
* delegation depth/cycle rejection (`DEPTH`), prompt failure (`DEADLOCK` / `EXPIRE` / `ANSWER`),
|
|
2174
|
+
* or a translated upstream database/relation failure (`DATABASE` / `RELATION`).
|
|
2148
2175
|
*
|
|
2149
2176
|
* @remarks
|
|
2150
2177
|
* Carries a machine-readable `code` (see {@link import('./types.js').ToolboxErrorCode}) and
|
|
@@ -2195,6 +2222,10 @@ export declare class ToolboxError extends Error {
|
|
|
2195
2222
|
*/
|
|
2196
2223
|
export declare type ToolboxErrorCode = 'TOOL' | 'DEPTH' | 'DEADLOCK' | 'EXPIRE' | 'ANSWER' | 'DATABASE' | 'RELATION';
|
|
2197
2224
|
|
|
2225
|
+
/**
|
|
2226
|
+
* The description {@link import('./factories.js').createWorkflowTool} advertises — the flat
|
|
2227
|
+
* authoring form, its worked example, and the advanced nested definition form.
|
|
2228
|
+
*/
|
|
2198
2229
|
export declare const WORKFLOW_TOOL_DESCRIPTION: string;
|
|
2199
2230
|
|
|
2200
2231
|
/**
|
|
@@ -2202,7 +2233,7 @@ export declare const WORKFLOW_TOOL_DESCRIPTION: string;
|
|
|
2202
2233
|
* {@link import('./factories.js').createWorkflowTool}: `{ name, steps: [{ name }] }`.
|
|
2203
2234
|
*
|
|
2204
2235
|
* @remarks
|
|
2205
|
-
*
|
|
2236
|
+
* Each step becomes a one-task phase, in
|
|
2206
2237
|
* order; a step's `name` is a REGISTERED behavior name (not a label) — the registry key its
|
|
2207
2238
|
* task's `run` resolves against. The tool expands this
|
|
2208
2239
|
* ({@link import('./helpers.js').expandSteps}) into a valid `WorkflowDefinition`
|
|
@@ -2217,7 +2248,7 @@ export declare const WORKFLOW_TOOL_FLAT_EXAMPLE: WorkflowSteps;
|
|
|
2217
2248
|
* under onto a wrapped agent's `context.tools`.
|
|
2218
2249
|
*
|
|
2219
2250
|
* @remarks
|
|
2220
|
-
*
|
|
2251
|
+
* The propagation seam's well-known key: when
|
|
2221
2252
|
* `createAgentFunction`'s `runner` option is supplied, it adds a `createWorkflowTool`-built tool
|
|
2222
2253
|
* under this name to the agent's `context.tools`, so it can author + run a NESTED workflow
|
|
2223
2254
|
* (bounded by {@link MAX_WORKFLOW_DEPTH}).
|
|
@@ -2229,7 +2260,7 @@ export declare const WORKFLOW_TOOL_NAME = "workflow";
|
|
|
2229
2260
|
* the flat shape: a full `WorkflowDefinition` (`@orkestrel/workflow`).
|
|
2230
2261
|
*
|
|
2231
2262
|
* @remarks
|
|
2232
|
-
*
|
|
2263
|
+
* The full four-level form, documented in
|
|
2233
2264
|
* {@link WORKFLOW_TOOL_DESCRIPTION} as the advanced alternative. It is embedded VERBATIM.
|
|
2234
2265
|
*/
|
|
2235
2266
|
export declare const WORKFLOW_TOOL_NESTED_EXAMPLE: WorkflowDefinition;
|
|
@@ -2243,6 +2274,9 @@ export declare const WORKFLOW_TOOL_NESTED_EXAMPLE: WorkflowDefinition;
|
|
|
2243
2274
|
*/
|
|
2244
2275
|
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.";
|
|
2245
2276
|
|
|
2277
|
+
/** Raw live agents keyed by the workflow function names that invoke them. */
|
|
2278
|
+
export declare type WorkflowAgents = Readonly<Record<string, AgentInterface>>;
|
|
2279
|
+
|
|
2246
2280
|
/**
|
|
2247
2281
|
* A draft workflow — a `WorkflowDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`
|
|
2248
2282
|
* at all three levels (workflow / phase / task).
|
|
@@ -2269,7 +2303,8 @@ export declare interface WorkflowDraft {
|
|
|
2269
2303
|
*
|
|
2270
2304
|
* @remarks
|
|
2271
2305
|
* The lenient counterpart {@link import('./factories.js').createWorkflowDraftContract} compiles.
|
|
2272
|
-
* `run` stays
|
|
2306
|
+
* `run` stays optional like the strict form; omission is the deliberate JSON `null` no-op. A
|
|
2307
|
+
* provided `id` / `name` still has `minLength: 1` (so
|
|
2273
2308
|
* an explicitly-empty `id: ''` is REJECTED, not auto-filled). After
|
|
2274
2309
|
* {@link import('./helpers.js').completeDraft} fills the missing ids/names, the result is
|
|
2275
2310
|
* validated against the STRICT `createWorkflowContract` (`@orkestrel/workflow`) gate before
|
|
@@ -2297,6 +2332,9 @@ export declare const workflowDraftShape: ObjectShape<{
|
|
|
2297
2332
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
2298
2333
|
}, false>;
|
|
2299
2334
|
|
|
2335
|
+
/** One immutable workflow/agent call chain, beginning with a workflow tag. */
|
|
2336
|
+
export declare type WorkflowLineage = readonly string[];
|
|
2337
|
+
|
|
2300
2338
|
/**
|
|
2301
2339
|
* One flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
|
|
2302
2340
|
*
|
|
@@ -2315,8 +2353,8 @@ export declare interface WorkflowStep {
|
|
|
2315
2353
|
*
|
|
2316
2354
|
* @remarks
|
|
2317
2355
|
* Each {@link WorkflowStep} becomes a one-task phase, in order
|
|
2318
|
-
* ({@link import('./helpers.js').expandSteps}); `name` is the optional workflow name
|
|
2319
|
-
* when omitted).
|
|
2356
|
+
* ({@link import('./helpers.js').expandSteps}); `name` is the optional workflow name and
|
|
2357
|
+
* deterministic persistence id (both default to `wf` when omitted).
|
|
2320
2358
|
*/
|
|
2321
2359
|
export declare interface WorkflowSteps {
|
|
2322
2360
|
readonly name?: string;
|
|
@@ -2357,51 +2395,59 @@ export declare const workflowStepsShape: ObjectShape<{
|
|
|
2357
2395
|
export declare function workflowTag(id: string): string;
|
|
2358
2396
|
|
|
2359
2397
|
/**
|
|
2360
|
-
* Options for {@link import('./factories.js').createWorkflowTool}
|
|
2361
|
-
*
|
|
2362
|
-
*
|
|
2398
|
+
* Options for {@link import('./factories.js').createWorkflowTool} and
|
|
2399
|
+
* {@link import('./factories.js').createWorkflowFunctions} — lineage-aware composition of opaque
|
|
2400
|
+
* leaves, raw agents, and native workflow persistence.
|
|
2363
2401
|
*
|
|
2364
2402
|
* @remarks
|
|
2365
|
-
*
|
|
2366
|
-
*
|
|
2367
|
-
* `
|
|
2368
|
-
*
|
|
2369
|
-
*
|
|
2370
|
-
* built for a TOP-LEVEL caller omits them — its nested run starts the chain at depth `1` with
|
|
2371
|
-
* the bare `workflow:<id>` ancestry.
|
|
2372
|
-
*
|
|
2373
|
-
* `store` is this package's ADDITION: when supplied, the tool's handler persists the run's final
|
|
2374
|
-
* snapshot (`store.set(result.workflow.snapshot())`) once the run settles, so a workflow
|
|
2375
|
-
* authored + run through the tool is retrievable / restorable afterwards. Omitted ⇒ no
|
|
2376
|
-
* persistence.
|
|
2403
|
+
* A top-level workflow tool uses an empty lineage and establishes its authored target as depth
|
|
2404
|
+
* zero. A tool bound onto an agent carries a lineage ending in that agent; the target workflow is
|
|
2405
|
+
* appended at invocation. `functions` remains strictly opaque host behavior. `agents` is the raw
|
|
2406
|
+
* live registry Toolbox uses to mint target-specific {@link AgentFunction}s. `store` is forwarded
|
|
2407
|
+
* to the native runner, which owns checkpoints and reports final durability/fault state.
|
|
2377
2408
|
*/
|
|
2378
2409
|
export declare interface WorkflowToolOptions {
|
|
2379
|
-
|
|
2380
|
-
readonly
|
|
2381
|
-
|
|
2382
|
-
readonly ancestry?: readonly string[];
|
|
2410
|
+
readonly lineage?: WorkflowLineage;
|
|
2411
|
+
readonly functions?: WorkflowFunctions;
|
|
2412
|
+
readonly agents?: WorkflowAgents;
|
|
2383
2413
|
readonly store?: WorkflowStoreInterface;
|
|
2384
2414
|
}
|
|
2385
2415
|
|
|
2416
|
+
/** The JSON-safe run summary returned by {@link import('./factories.js').createWorkflowTool}. */
|
|
2417
|
+
export declare interface WorkflowToolResult {
|
|
2418
|
+
/** The workflow's native terminal status. */
|
|
2419
|
+
readonly status: WorkflowStatus;
|
|
2420
|
+
/** The number of settled task results. */
|
|
2421
|
+
readonly count: number;
|
|
2422
|
+
/** Whether the native runner stored its final state; omitted when no store was supplied. */
|
|
2423
|
+
readonly durable?: boolean;
|
|
2424
|
+
/** The native runner's first persistence failure; omitted when none occurred. */
|
|
2425
|
+
readonly fault?: WorkflowFault;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2386
2428
|
/**
|
|
2387
2429
|
* Build the plain success summary {@link import('./factories.js').createWorkflowTool} returns on
|
|
2388
2430
|
* a completed run — the universal tool-handler contract (AGENTS §14): return a plain value on
|
|
2389
2431
|
* success, appearing identically over BOTH the agent loop and MCP.
|
|
2390
2432
|
*
|
|
2391
2433
|
* @remarks
|
|
2392
|
-
* The summary is LEAN: the workflow's terminal `status
|
|
2393
|
-
*
|
|
2394
|
-
*
|
|
2395
|
-
* (`@orkestrel/tool`) supplies the canonical envelope's identity.)
|
|
2434
|
+
* The summary is LEAN: the workflow's terminal `status`, settled-task count, and exact optional
|
|
2435
|
+
* native persistence outcome. It carries no synthetic `id` / `name`: a tool handler has no call
|
|
2436
|
+
* id; the `ToolManagerInterface` (`@orkestrel/tool`) supplies the canonical envelope's identity.
|
|
2396
2437
|
*
|
|
2397
2438
|
* @param result - The terminal `WorkflowResult` (`@orkestrel/workflow`) the run produced
|
|
2398
|
-
* @returns The plain success summary — `{ status, count }`
|
|
2439
|
+
* @returns The plain success summary — `{ status, count, durable?, fault? }`
|
|
2399
2440
|
*/
|
|
2400
|
-
export declare function workflowToolSummary(result: WorkflowResult):
|
|
2401
|
-
status: WorkflowStatus;
|
|
2402
|
-
count: number;
|
|
2403
|
-
}>;
|
|
2441
|
+
export declare function workflowToolSummary(result: WorkflowResult): WorkflowToolResult;
|
|
2404
2442
|
|
|
2443
|
+
/**
|
|
2444
|
+
* The description {@link import('./factories.js').createWorkspaceTool} advertises — the
|
|
2445
|
+
* operation-keyed workspace protocol, all supported operations, and worked examples.
|
|
2446
|
+
*
|
|
2447
|
+
* @remarks
|
|
2448
|
+
* Mirrors {@link WORKFLOW_TOOL_DESCRIPTION}'s teaching style and embeds
|
|
2449
|
+
* {@link WORKSPACE_TOOL_EXAMPLE} verbatim.
|
|
2450
|
+
*/
|
|
2405
2451
|
export declare const WORKSPACE_TOOL_DESCRIPTION: string;
|
|
2406
2452
|
|
|
2407
2453
|
/**
|
|
@@ -2409,7 +2455,7 @@ export declare const WORKSPACE_TOOL_DESCRIPTION: string;
|
|
|
2409
2455
|
* VERBATIM in {@link WORKSPACE_TOOL_DESCRIPTION}.
|
|
2410
2456
|
*
|
|
2411
2457
|
* @remarks
|
|
2412
|
-
*
|
|
2458
|
+
* A `'write'` op (the most common authoring
|
|
2413
2459
|
* action): create or overwrite `notes.txt` with `hello`. Frozen so it cannot be mutated in
|
|
2414
2460
|
* place.
|
|
2415
2461
|
*/
|
|
@@ -2418,9 +2464,6 @@ export declare const WORKSPACE_TOOL_EXAMPLE: WorkspaceOperation;
|
|
|
2418
2464
|
/**
|
|
2419
2465
|
* The name {@link import('./factories.js').createWorkspaceTool} advertises by default — the key a
|
|
2420
2466
|
* model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
2421
|
-
*
|
|
2422
|
-
* @remarks
|
|
2423
|
-
* OWNED here now (ported from `@orkestrel/agent`).
|
|
2424
2467
|
*/
|
|
2425
2468
|
export declare const WORKSPACE_TOOL_NAME = "workspace";
|
|
2426
2469
|
|
|
@@ -2444,7 +2487,8 @@ export declare const WORKSPACE_TOOL_SUMMARY = "Read and edit files in a workspac
|
|
|
2444
2487
|
* ({@link import('./shapers.js').workspaceToolShape} compiles to a structurally-identical guard /
|
|
2445
2488
|
* parser / JSON Schema). Every field is FLAT (no nested objects) — the small-model ergonomic
|
|
2446
2489
|
* lever: a range edit is the four flat integers of the `'splice'` arm (`fromLine` /
|
|
2447
|
-
* `fromColumn` / `toLine` / `toColumn`), reassembled into a 1-based `Range`
|
|
2490
|
+
* `fromColumn` / `toLine` / `toColumn`), reassembled into a 1-based `Range`
|
|
2491
|
+
* (`@orkestrel/workspace`)
|
|
2448
2492
|
* by `rangeOf`, never a nested `{ start, end }`. Each EDIT / READ arm maps onto exactly one
|
|
2449
2493
|
* `WorkspaceInterface` call against the manager's ACTIVE workspace; the two REGISTRY arms
|
|
2450
2494
|
* (`switch` / `workspaces`) drive the {@link WorkspaceManagerInterface} pointer instead —
|
|
@@ -2471,28 +2515,28 @@ export declare type WorkspaceOperation =
|
|
|
2471
2515
|
*
|
|
2472
2516
|
* @remarks
|
|
2473
2517
|
* `regex` treats `query` as a regular-expression source (default `false` — a literal substring);
|
|
2474
|
-
* `
|
|
2518
|
+
* `sensitive` matches case-sensitively (default `true`); `limit` caps the total hits returned.
|
|
2475
2519
|
*/
|
|
2476
2520
|
| {
|
|
2477
2521
|
readonly operation: 'search';
|
|
2478
2522
|
readonly query: string;
|
|
2479
2523
|
readonly regex?: boolean;
|
|
2480
|
-
readonly
|
|
2524
|
+
readonly sensitive?: boolean;
|
|
2481
2525
|
readonly limit?: number;
|
|
2482
2526
|
}
|
|
2483
2527
|
/**
|
|
2484
2528
|
* Replace `query` with `replacement` across every text file, returning the tally.
|
|
2485
2529
|
*
|
|
2486
2530
|
* @remarks
|
|
2487
|
-
* Same matching axes as `search`: `regex` (default `false`), `
|
|
2488
|
-
* (cap the total replacements).
|
|
2531
|
+
* Same matching axes as `search`: `regex` (default `false`), `sensitive` (default `true`),
|
|
2532
|
+
* `limit` (cap the total replacements).
|
|
2489
2533
|
*/
|
|
2490
2534
|
| {
|
|
2491
2535
|
readonly operation: 'replace';
|
|
2492
2536
|
readonly query: string;
|
|
2493
2537
|
readonly replacement: string;
|
|
2494
2538
|
readonly regex?: boolean;
|
|
2495
|
-
readonly
|
|
2539
|
+
readonly sensitive?: boolean;
|
|
2496
2540
|
readonly limit?: number;
|
|
2497
2541
|
}
|
|
2498
2542
|
/** Write (create or overwrite) the whole file at `path` with `content`. */
|
|
@@ -2507,8 +2551,8 @@ export declare type WorkspaceOperation =
|
|
|
2507
2551
|
*
|
|
2508
2552
|
* @remarks
|
|
2509
2553
|
* The FLAT range edit — the four positive-integer caret components reassemble into a `Range`
|
|
2510
|
-
* (`@orkestrel/
|
|
2511
|
-
* end is clamped. An inverted / sub-1 range throws `RANGE`; a binary target throws
|
|
2554
|
+
* (`@orkestrel/workspace`) via `rangeOf`. An empty span (`from === to`) inserts; a span past
|
|
2555
|
+
* the end is clamped. An inverted / sub-1 range throws `RANGE`; a binary target throws
|
|
2512
2556
|
* `MODALITY`.
|
|
2513
2557
|
*/
|
|
2514
2558
|
| {
|
|
@@ -2557,16 +2601,16 @@ export declare type WorkspaceOperation =
|
|
|
2557
2601
|
* Options for {@link import('./factories.js').createWorkspaceTool} — EITHER a caller-built
|
|
2558
2602
|
* {@link WorkspaceManagerInterface} to drive directly, OR a {@link WorkspaceStoreInterface} the
|
|
2559
2603
|
* tool constructs a fresh manager over; neither given constructs a manager over
|
|
2560
|
-
* `@orkestrel/
|
|
2604
|
+
* `@orkestrel/workspace`'s in-memory store.
|
|
2561
2605
|
*
|
|
2562
2606
|
* @remarks
|
|
2563
2607
|
* - `manager` — drive THIS manager directly (its `active` workspace is what every edit / read
|
|
2564
2608
|
* operation targets). Takes priority over `store` when both are supplied.
|
|
2565
2609
|
* - `store` — construct a manager over this durable {@link WorkspaceStoreInterface} (via
|
|
2566
|
-
* `@orkestrel/
|
|
2610
|
+
* `@orkestrel/workspace`'s `createWorkspaceManager`) — used only when `manager` is omitted.
|
|
2567
2611
|
* The store only backs the manager's own `open` / `save` operations: the tool's edits are
|
|
2568
2612
|
* NOT auto-persisted — durability requires an explicit caller `save` on the manager
|
|
2569
|
-
* (unlike the workflow tool's `store`, which
|
|
2613
|
+
* (unlike the workflow tool's `store`, which is forwarded into native run-wide checkpoints).
|
|
2570
2614
|
* - `name` / `description` — advertised tool overrides; default to
|
|
2571
2615
|
* {@link import('./constants.js').WORKSPACE_TOOL_NAME} / {@link import('./constants.js').WORKSPACE_TOOL_DESCRIPTION}.
|
|
2572
2616
|
*/
|
|
@@ -2588,10 +2632,10 @@ export declare interface WorkspaceToolOptions {
|
|
|
2588
2632
|
* The union compiles to an `anyOf` JSON Schema + a `unionOf` guard + a first-match parser
|
|
2589
2633
|
* automatically ({@link import('./factories.js').createWorkspaceTool} types the result to the
|
|
2590
2634
|
* hand-written {@link import('./types.js').WorkspaceOperation}). `limit` and the four `'splice'`
|
|
2591
|
-
* caret components are POSITIVE integers (`integerShape({ min: 1 })`); `regex` / `
|
|
2592
|
-
* `optionalShape(booleanShape(...))`. The two REGISTRY arms — `workspaces` (list the
|
|
2593
|
-
* the model can move between) and `switch` (re-point the active one by `id`) — let a
|
|
2594
|
-
* DISCOVER then CHOOSE which workspace the edit / read arms target.
|
|
2635
|
+
* caret components are POSITIVE integers (`integerShape({ min: 1 })`); `regex` / `sensitive`
|
|
2636
|
+
* are `optionalShape(booleanShape(...))`. The two REGISTRY arms — `workspaces` (list the
|
|
2637
|
+
* workspaces the model can move between) and `switch` (re-point the active one by `id`) — let a
|
|
2638
|
+
* model DISCOVER then CHOOSE which workspace the edit / read arms target.
|
|
2595
2639
|
*/
|
|
2596
2640
|
export declare const workspaceToolShape: UnionShape<readonly [ ObjectShape<{
|
|
2597
2641
|
operation: LiteralShape<readonly ["read"]>;
|
|
@@ -2605,14 +2649,14 @@ export declare const workspaceToolShape: UnionShape<readonly [ ObjectShape<{
|
|
|
2605
2649
|
operation: LiteralShape<readonly ["search"]>;
|
|
2606
2650
|
query: StringShape;
|
|
2607
2651
|
regex: OptionalShape<BooleanShape>;
|
|
2608
|
-
|
|
2652
|
+
sensitive: OptionalShape<BooleanShape>;
|
|
2609
2653
|
limit: OptionalShape<NumberShape>;
|
|
2610
2654
|
}, false>, ObjectShape<{
|
|
2611
2655
|
operation: LiteralShape<readonly ["replace"]>;
|
|
2612
2656
|
query: StringShape;
|
|
2613
2657
|
replacement: StringShape;
|
|
2614
2658
|
regex: OptionalShape<BooleanShape>;
|
|
2615
|
-
|
|
2659
|
+
sensitive: OptionalShape<BooleanShape>;
|
|
2616
2660
|
limit: OptionalShape<NumberShape>;
|
|
2617
2661
|
}, false>, ObjectShape<{
|
|
2618
2662
|
operation: LiteralShape<readonly ["write"]>;
|