@orkestrel/tool 0.0.2 → 0.0.4
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 -1
- package/dist/src/core/index.cjs +1619 -0
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1172 -30
- package/dist/src/core/index.d.ts +1172 -30
- package/dist/src/core/index.js +1569 -2
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.d.cts +125 -3
- package/dist/src/server/index.d.ts +125 -3
- package/package.json +13 -9
- package/dist/src/server/constants.d.ts +0 -12
- package/dist/src/server/factories.d.ts +0 -44
- package/dist/src/server/types.d.ts +0 -60
package/dist/src/core/index.d.ts
CHANGED
|
@@ -2,14 +2,32 @@ 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
|
+
import { Condition } from '@orkestrel/database';
|
|
7
|
+
import { Connector } from '@orkestrel/database';
|
|
5
8
|
import { ContractInterface } from '@orkestrel/contract';
|
|
9
|
+
import { ContractShape } from '@orkestrel/contract';
|
|
6
10
|
import { ConversationStoreInterface } from '@orkestrel/agent';
|
|
11
|
+
import { Criteria } from '@orkestrel/database';
|
|
12
|
+
import { DatabaseErrorCode } from '@orkestrel/database';
|
|
13
|
+
import { DatabaseInterface } from '@orkestrel/database';
|
|
14
|
+
import { Direction } from '@orkestrel/database';
|
|
15
|
+
import { DriverInterface } from '@orkestrel/database';
|
|
16
|
+
import { Include } from '@orkestrel/relation';
|
|
17
|
+
import { JSONShape } from '@orkestrel/contract';
|
|
18
|
+
import { KeyFunction } from '@orkestrel/database';
|
|
7
19
|
import { LiteralShape } from '@orkestrel/contract';
|
|
20
|
+
import { ModelInterface } from '@orkestrel/relation';
|
|
8
21
|
import { NumberShape } from '@orkestrel/contract';
|
|
9
22
|
import { ObjectShape } from '@orkestrel/contract';
|
|
10
23
|
import { OptionalShape } from '@orkestrel/contract';
|
|
11
24
|
import { PromptType } from '@orkestrel/terminal';
|
|
25
|
+
import { RelationErrorCode } from '@orkestrel/relation';
|
|
26
|
+
import { RelationManagerInterface } from '@orkestrel/relation';
|
|
12
27
|
import { StringShape } from '@orkestrel/contract';
|
|
28
|
+
import { TableInterface } from '@orkestrel/database';
|
|
29
|
+
import { TableSchema } from '@orkestrel/database';
|
|
30
|
+
import { TablesShape } from '@orkestrel/database';
|
|
13
31
|
import { TerminalManagerInterface } from '@orkestrel/terminal';
|
|
14
32
|
import { ToolInterface } from '@orkestrel/agent';
|
|
15
33
|
import { ToolManagerInterface } from '@orkestrel/agent';
|
|
@@ -119,6 +137,9 @@ export declare interface AgentToolArguments {
|
|
|
119
137
|
* (`DEADLOCK`), a prompt that expired before it was answered (`EXPIRE`), or an answer that
|
|
120
138
|
* failed to apply (`ANSWER`) — the last three thrown by
|
|
121
139
|
* {@link import('./factories.js').createPromptTool} / {@link import('./factories.js').createAnswerTool}.
|
|
140
|
+
* The upcoming database / relation tools (SRC-1's later units) will throw it too: a typed
|
|
141
|
+
* `@orkestrel/database` failure re-surfaces as `DATABASE`, a typed `@orkestrel/relation` failure
|
|
142
|
+
* as `RELATION` — each carrying the package's own granular error code in `context`.
|
|
122
143
|
*
|
|
123
144
|
* @remarks
|
|
124
145
|
* Carries a machine-readable `code` (see {@link import('./types.js').AgentToolErrorCode}) and
|
|
@@ -160,8 +181,12 @@ export declare class AgentToolError extends Error {
|
|
|
160
181
|
* `ANSWER` — {@link import('./factories.js').createAnswerTool}'s answer call failed to apply
|
|
161
182
|
* (an unknown prompt id, a rejected value, or the terminal itself unknown —
|
|
162
183
|
* `TerminalAnswerResult.error`, `@orkestrel/terminal`).
|
|
184
|
+
* `DATABASE` — a typed `@orkestrel/database` failure (`DatabaseError`), re-surfaced with the
|
|
185
|
+
* granular {@link import('@orkestrel/database').DatabaseErrorCode} carried in `context`.
|
|
186
|
+
* `RELATION` — a typed `@orkestrel/relation` failure (`RelationError`), re-surfaced with the
|
|
187
|
+
* granular {@link import('@orkestrel/relation').RelationErrorCode} carried in `context`.
|
|
163
188
|
*/
|
|
164
|
-
export declare type AgentToolErrorCode = 'TOOL' | 'DEPTH' | 'DEADLOCK' | 'EXPIRE' | 'ANSWER';
|
|
189
|
+
export declare type AgentToolErrorCode = 'TOOL' | 'DEPTH' | 'DEADLOCK' | 'EXPIRE' | 'ANSWER' | 'DATABASE' | 'RELATION';
|
|
165
190
|
|
|
166
191
|
/**
|
|
167
192
|
* Options for {@link import('./factories.js').createAgentTool} — the sub-agent delegation
|
|
@@ -219,7 +244,7 @@ export declare const agentToolShape: ObjectShape<{
|
|
|
219
244
|
provider: OptionalShape<StringShape>;
|
|
220
245
|
tools: OptionalShape<ArrayShape<StringShape>>;
|
|
221
246
|
system: OptionalShape<StringShape>;
|
|
222
|
-
}>;
|
|
247
|
+
}, false>;
|
|
223
248
|
|
|
224
249
|
export declare const ANSWER_TOOL_DESCRIPTION: string;
|
|
225
250
|
|
|
@@ -273,11 +298,42 @@ export declare interface AnswerToolOptions {
|
|
|
273
298
|
*/
|
|
274
299
|
export declare const answerToolShape: UnionShape<[ ObjectShape<{
|
|
275
300
|
operation: LiteralShape<readonly ["pending"]>;
|
|
276
|
-
}>, ObjectShape<{
|
|
301
|
+
}, false>, ObjectShape<{
|
|
277
302
|
operation: LiteralShape<readonly ["answer"]>;
|
|
278
303
|
id: StringShape;
|
|
279
304
|
value: UnionShape<[ StringShape, BooleanShape, ArrayShape<StringShape>]>;
|
|
280
|
-
}>]>;
|
|
305
|
+
}, false>]>;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Clamp a `'records'` call's criteria to a row cap, and build the PROBE criteria the caller reads
|
|
309
|
+
* with — the pure leaf {@link import('./factories.js').createDatabaseTool}'s `'records'` operation
|
|
310
|
+
* uses to detect truncation without a separate `count` round trip.
|
|
311
|
+
*
|
|
312
|
+
* @remarks
|
|
313
|
+
* The effective limit is `min(criteria?.limit ?? cap, cap)`, floored at `0` (so a caller can never
|
|
314
|
+
* exceed the configured cap by supplying a larger `criteria.limit`). The returned probe criteria
|
|
315
|
+
* requests ONE MORE row than the effective limit (`limit: effective + 1`) — if storage returns
|
|
316
|
+
* that many, the caller knows the true result was truncated (`rows.length > effective`) and slices
|
|
317
|
+
* back down to `effective` before returning.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* import { clampCriteria } from '@src/core'
|
|
322
|
+
*
|
|
323
|
+
* const { criteria, limit } = clampCriteria(undefined, 100)
|
|
324
|
+
* // limit === 100, criteria.limit === 101 — a probe fetching one extra row
|
|
325
|
+
* const rows = await table.records(criteria)
|
|
326
|
+
* const truncated = rows.length > limit // true when storage had more than `limit` rows
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @param criteria - The live criteria to clamp (or `undefined`)
|
|
330
|
+
* @param cap - The row-count ceiling
|
|
331
|
+
* @returns The PROBE criteria (`limit` bumped by one) and the effective `limit`
|
|
332
|
+
*/
|
|
333
|
+
export declare function clampCriteria(criteria: Criteria | undefined, cap: number): Readonly<{
|
|
334
|
+
criteria: Criteria;
|
|
335
|
+
limit: number;
|
|
336
|
+
}>;
|
|
281
337
|
|
|
282
338
|
/**
|
|
283
339
|
* Normalize an LLM-supplied answer `value` to the type {@link PromptType} `form` expects, so a
|
|
@@ -301,6 +357,33 @@ export declare const answerToolShape: UnionShape<[ ObjectShape<{
|
|
|
301
357
|
*/
|
|
302
358
|
export declare function coerceAnswer(form: PromptType, value: unknown): string | boolean | readonly string[];
|
|
303
359
|
|
|
360
|
+
/** One column's declared type — a primitive shorthand, or `integer` for a whole-number `number`. */
|
|
361
|
+
export declare type ColumnKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
362
|
+
|
|
363
|
+
/** A {@link import('./types.js').ColumnKind} literal — the leaf {@link columnSpecShape} wraps. */
|
|
364
|
+
export declare const columnKindShape: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
365
|
+
|
|
366
|
+
/** Map a column NAME + its live `@orkestrel/database` `ContractShape` to a {@link ColumnSchema} — the leaf {@link tableSchema} maps over. */
|
|
367
|
+
export declare function columnSchema(name: string, shape: ContractShape): ColumnSchema;
|
|
368
|
+
|
|
369
|
+
/** Compile one {@link ColumnSpec} into its `@orkestrel/database` column shape — the per-column leaf {@link expandTables} maps over. */
|
|
370
|
+
export declare function columnShape(spec: ColumnSpec): ContractShape;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* One table column's spec — either a bare {@link ColumnKind} shorthand, or `{ type, optional }`
|
|
374
|
+
* when the column may be absent from a row.
|
|
375
|
+
*/
|
|
376
|
+
export declare type ColumnSpec = ColumnKind | Readonly<{
|
|
377
|
+
type: ColumnKind;
|
|
378
|
+
optional?: boolean;
|
|
379
|
+
}>;
|
|
380
|
+
|
|
381
|
+
/** A {@link import('./types.js').ColumnSpec} — a bare {@link columnKindShape}, or `{ type, optional }`. */
|
|
382
|
+
export declare const columnSpecShape: UnionShape<[ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
|
|
383
|
+
type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
384
|
+
optional: OptionalShape<BooleanShape>;
|
|
385
|
+
}, false>]>;
|
|
386
|
+
|
|
304
387
|
/**
|
|
305
388
|
* Complete a {@link WorkflowDraft} into a strict {@link WorkflowDefinition} — synthesize any
|
|
306
389
|
* MISSING `id` deterministically + positionally, and default any MISSING `name` to its
|
|
@@ -343,6 +426,14 @@ export declare function completePhaseDraft(phase: PhaseDraft, index: number): Wo
|
|
|
343
426
|
*/
|
|
344
427
|
export declare function completeTaskDraft(task: TaskDraft, phaseId: string, index: number): WorkflowDefinition['phases'][number]['tasks'][number];
|
|
345
428
|
|
|
429
|
+
/** One SERIALIZED WHERE condition — `values` is ALWAYS an array, even for a single-value operator. */
|
|
430
|
+
export declare const conditionShape: ObjectShape<{
|
|
431
|
+
column: StringShape;
|
|
432
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
433
|
+
values: ArrayShape<JSONShape>;
|
|
434
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
435
|
+
}, false>;
|
|
436
|
+
|
|
346
437
|
/**
|
|
347
438
|
* Wrap a live `AgentInterface` (`@orkestrel/agent`) as a {@link WorkflowFunction}
|
|
348
439
|
* (`@orkestrel/workflow`) — the OPT-IN adapter that runs the agent to a settled result, folding
|
|
@@ -465,6 +556,87 @@ export declare function createAgentTool(registry: AgentRegistryInterface, option
|
|
|
465
556
|
*/
|
|
466
557
|
export declare function createAnswerTool(options: AnswerToolOptions): ToolInterface;
|
|
467
558
|
|
|
559
|
+
/**
|
|
560
|
+
* Create a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database`
|
|
561
|
+
* layer — the driver-pluggable twin of {@link createMemoryDefinitionStore}, storing each
|
|
562
|
+
* database's definition as one opaque JSON column.
|
|
563
|
+
*
|
|
564
|
+
* @param driver - The {@link DriverInterface} backing the table (default an in-memory driver)
|
|
565
|
+
* @returns A {@link DefinitionStoreInterface}
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```ts
|
|
569
|
+
* import { createDatabaseDefinitionStore } from '@src/core'
|
|
570
|
+
*
|
|
571
|
+
* const store = createDatabaseDefinitionStore() // in-memory by default
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
export declare function createDatabaseDefinitionStore(driver?: DriverInterface): DefinitionStoreInterface;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Build an LLM-callable database tool — create, query, and mutate `@orkestrel/database`
|
|
578
|
+
* databases through one `operation`-discriminated call (AGENTS §14, matching
|
|
579
|
+
* {@link createWorkspaceTool}'s single-tool-many-operations shape).
|
|
580
|
+
*
|
|
581
|
+
* @remarks
|
|
582
|
+
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
583
|
+
* {@link import('./shapers.js').databaseToolShape}, dispatches to the matching operation, and
|
|
584
|
+
* RETURNS a plain result on success. A database is resolved lazily and cached for the tool's
|
|
585
|
+
* lifetime — `'create'` mints one from `tables` ({@link import('./helpers.js').expandTables}) and
|
|
586
|
+
* a registered `driver` key ({@link import('./types.js').DatabaseToolOptions.drivers}, default
|
|
587
|
+
* `{ memory: () => createMemoryDriver() }`); any other operation addressing an uncached id falls
|
|
588
|
+
* back to {@link import('./types.js').DatabaseToolOptions.store} (an unknown id throws a typed
|
|
589
|
+
* `TOOL` {@link import('./errors.js').AgentToolError}). When a `store` is configured, `'create'`
|
|
590
|
+
* persists the new {@link import('./types.js').DatabaseDefinition} and `'destroy'` deletes it.
|
|
591
|
+
*
|
|
592
|
+
* `'migrate'` re-declares a LIVE handle's tables via `DatabaseInterface.import` (the SAME driver
|
|
593
|
+
* and storage, a NEW typed view) and calls its `migrate` against the OLD deployed schema —
|
|
594
|
+
* derived from the handle's OWN `export()` (via {@link import('./helpers.js').tableSchema}), so it
|
|
595
|
+
* works for any handle, config-tracked or caller-supplied via
|
|
596
|
+
* {@link import('./types.js').DatabaseToolOptions.databases}. `'records'` clamps its `criteria` to
|
|
597
|
+
* {@link import('./types.js').DatabaseToolOptions.limit} (default
|
|
598
|
+
* {@link import('./constants.js').DATABASE_TOOL_LIMIT}) via
|
|
599
|
+
* {@link import('./helpers.js').clampCriteria}, reporting `truncated` when storage held more rows
|
|
600
|
+
* than the cap. Every operation's `criteria` is normalized via
|
|
601
|
+
* {@link import('./helpers.js').criteriaOf} (defaults an omitted condition `connector` to `'and'`).
|
|
602
|
+
* When {@link import('./types.js').DatabaseToolOptions.readonly} is `true`, every mutating
|
|
603
|
+
* operation throws a typed `TOOL` `AgentToolError` before doing anything. When
|
|
604
|
+
* {@link import('./types.js').DatabaseToolOptions.timeout} is set, every `@orkestrel/database` call
|
|
605
|
+
* this tool makes is given a fresh `AbortSignal.timeout(timeout)`. A typed `@orkestrel/database`
|
|
606
|
+
* failure (`DatabaseError`) re-surfaces as a typed `DATABASE` `AgentToolError` carrying the
|
|
607
|
+
* original {@link import('@orkestrel/database').DatabaseErrorCode} in `context.code`
|
|
608
|
+
* ({@link import('./helpers.js').databaseToolCode}); an `AgentToolError` thrown by this tool's own
|
|
609
|
+
* guards passes through unwrapped.
|
|
610
|
+
*
|
|
611
|
+
* A lazily re-minted database over the DEFAULT in-memory driver yields an EMPTY database — only
|
|
612
|
+
* the {@link import('./types.js').DatabaseDefinition} schema persists in `store`, never rows;
|
|
613
|
+
* durable rows need a persistent driver factory registered in
|
|
614
|
+
* {@link import('./types.js').DatabaseToolOptions.drivers}. `'destroy'` closes whatever handle is
|
|
615
|
+
* cached for the id, including an embedder-supplied
|
|
616
|
+
* {@link import('./types.js').DatabaseToolOptions.databases} handle — the embedder relinquishes
|
|
617
|
+
* that handle's lifecycle to this tool for any id it wires in. This tool assumes the
|
|
618
|
+
* single-writer, non-reentrant model `@orkestrel/database` itself assumes — concurrent calls
|
|
619
|
+
* against one id are NOT serialized by this tool. `'get'` is uncapped by
|
|
620
|
+
* {@link import('./types.js').DatabaseToolOptions.limit} (bounded only by the caller's `key` array
|
|
621
|
+
* size), unlike `'records'` / `'find'` / `'links'`.
|
|
622
|
+
*
|
|
623
|
+
* @param options - The tool's configuration (see {@link import('./types.js').DatabaseToolOptions})
|
|
624
|
+
* @returns A `ToolInterface` (named {@link import('./constants.js').DATABASE_TOOL_NAME} by default)
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```ts
|
|
628
|
+
* import { createDatabaseTool } from '@src/core'
|
|
629
|
+
*
|
|
630
|
+
* const tool = createDatabaseTool()
|
|
631
|
+
* await tool.execute({
|
|
632
|
+
* operation: 'create',
|
|
633
|
+
* id: 'shop',
|
|
634
|
+
* tables: { products: { columns: { name: 'string', price: 'number' } } },
|
|
635
|
+
* })
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
638
|
+
export declare function createDatabaseTool(options?: DatabaseToolOptions): ToolInterface;
|
|
639
|
+
|
|
468
640
|
/**
|
|
469
641
|
* Build an LLM-callable tool that returns the FULL `description` of another registered tool by
|
|
470
642
|
* name — the counterpart to the lean `summary` the other tools in this package advertise
|
|
@@ -501,6 +673,169 @@ export declare function createAnswerTool(options: AnswerToolOptions): ToolInterf
|
|
|
501
673
|
*/
|
|
502
674
|
export declare function createDescribeTool(tools: ToolManagerInterface): ToolInterface;
|
|
503
675
|
|
|
676
|
+
/**
|
|
677
|
+
* Wrap one CONCRETE endpoint ({@link import('./types.js').EndpointDefinition}) as an LLM-callable
|
|
678
|
+
* `ToolInterface` — the endpoint half of the "existing API/DB → MCP tool" bridge (the other half,
|
|
679
|
+
* {@link createInferTool}, is a standalone inference utility).
|
|
680
|
+
*
|
|
681
|
+
* @remarks
|
|
682
|
+
* `parameters` is inferred ONCE at construction from `definition.samples` via
|
|
683
|
+
* `@orkestrel/contract`'s `samplesToSchema` (tuned by {@link import('./types.js').EndpointToolOptions}'s
|
|
684
|
+
* `format` / `enum`), wrapping a non-object root as `{ value: <schema> }` via `schemaToObject` —
|
|
685
|
+
* the SAME object-rooted schema is both the ADVERTISED `parameters` and, by default
|
|
686
|
+
* ({@link import('./types.js').EndpointToolOptions.validate} `true`), the ENFORCED contract:
|
|
687
|
+
* `@orkestrel/contract` 0.0.7's `schemaToShape` compiles it ONCE (via `createContract`) into a
|
|
688
|
+
* `ContractInterface` whose `.parse` runs on every call's `args` before `definition.invoke` — a
|
|
689
|
+
* NORMALIZING parse, not a strict type check: a scalar is COERCED to its inferred type where the
|
|
690
|
+
* house parsers coerce (a number to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/
|
|
691
|
+
* `'false'`/`1`/`0`), so `definition.invoke` receives the COERCED value (e.g. `7` sent for a
|
|
692
|
+
* string slot arrives as `'7'`), not the raw call value. A call whose `args` fails to parse into
|
|
693
|
+
* a record — a required key missing, or a value not coercible to its slot's type — THROWS a
|
|
694
|
+
* typed `TOOL` {@link import('./errors.js').AgentToolError} carrying the compiled contract's
|
|
695
|
+
* structured `explain` faults, and `definition.invoke` is never called. `format` annotations are
|
|
696
|
+
* NEVER asserted, and a key outside the closed inferred schema is SILENTLY DROPPED rather than
|
|
697
|
+
* rejected (see {@link import('./types.js').EndpointToolOptions.validate}). With
|
|
698
|
+
* `validate: false`, `execute` PASSES THROUGH the model-supplied `args` to `definition.invoke`
|
|
699
|
+
* WITHOUT re-validation — the pre-0.0.7 behavior, preserved as an explicit opt-out. Either way,
|
|
700
|
+
* `invoke`'s return flows back as the tool call's plain result; a throw PROPAGATES uncaught,
|
|
701
|
+
* isolated by the `ToolManagerInterface` (`@orkestrel/agent`) into the canonical error envelope
|
|
702
|
+
* (AGENTS §14) — never caught or re-wrapped here.
|
|
703
|
+
*
|
|
704
|
+
* @param definition - The endpoint's identity, non-empty samples, and local handler (see
|
|
705
|
+
* {@link import('./types.js').EndpointDefinition})
|
|
706
|
+
* @param options - Construction-time inference tuning + the validate opt-out (see
|
|
707
|
+
* {@link import('./types.js').EndpointToolOptions})
|
|
708
|
+
* @returns A `ToolInterface` named `definition.name`
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```ts
|
|
712
|
+
* import { createEndpointTool } from '@src/core'
|
|
713
|
+
* import { createToolManager } from '@orkestrel/agent'
|
|
714
|
+
*
|
|
715
|
+
* const tool = createEndpointTool({
|
|
716
|
+
* name: 'lookupUser',
|
|
717
|
+
* description: 'Look up a user by id.',
|
|
718
|
+
* samples: [{ id: '1', name: 'Ada' }, { id: '2', name: 'Bob' }],
|
|
719
|
+
* invoke: (args) => ({ id: args.id, name: 'Ada' }),
|
|
720
|
+
* })
|
|
721
|
+
* const tools = createToolManager()
|
|
722
|
+
* tools.add(tool)
|
|
723
|
+
*
|
|
724
|
+
* // conforming args (all required keys present) parse and reach `invoke`
|
|
725
|
+
* const result = await tools.execute({
|
|
726
|
+
* id: 'call-1',
|
|
727
|
+
* name: 'lookupUser',
|
|
728
|
+
* arguments: { id: '1', name: 'Ada' },
|
|
729
|
+
* })
|
|
730
|
+
* // result.value -> { id: '1', name: 'Ada' }
|
|
731
|
+
*
|
|
732
|
+
* // a nonconforming call (id is not coercible to the required string) is rejected before
|
|
733
|
+
* // `invoke` runs
|
|
734
|
+
* const rejected = await tools.execute({
|
|
735
|
+
* id: 'call-2',
|
|
736
|
+
* name: 'lookupUser',
|
|
737
|
+
* arguments: { id: true, name: 'Ada' },
|
|
738
|
+
* })
|
|
739
|
+
* // rejected.error -> the TOOL AgentToolError message
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
export declare function createEndpointTool(definition: EndpointDefinition, options?: EndpointToolOptions): ToolInterface;
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Build a standalone LLM-callable tool that infers a JSON Schema from example values — the
|
|
746
|
+
* utility half of the "existing API/DB → MCP tool" bridge (the other half,
|
|
747
|
+
* {@link createEndpointTool}, wraps one CONCRETE endpoint).
|
|
748
|
+
*
|
|
749
|
+
* @remarks
|
|
750
|
+
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
751
|
+
* {@link import('./shapers.js').inferToolShape} (`samples` non-empty, `format` / `enum` optional
|
|
752
|
+
* booleans, `candidates` an optional array), infers a schema via `@orkestrel/contract`'s
|
|
753
|
+
* `samplesToSchema`, wraps a non-object root as `{ value: <schema> }` via `schemaToObject` (mirrors
|
|
754
|
+
* the tool-parameters convention every other `create*Tool` factory advertises), and RETURNS the
|
|
755
|
+
* resulting parameters record. An empty `samples` array fails `inferToolShape`'s `min: 1` bound —
|
|
756
|
+
* `contract.parse` returns `undefined` and the handler throws a typed `TOOL`
|
|
757
|
+
* {@link import('./errors.js').AgentToolError}.
|
|
758
|
+
*
|
|
759
|
+
* When `candidates` is ABSENT, the return is the bare parameters record — unchanged from before
|
|
760
|
+
* this array existed. When `candidates` is PRESENT (any array, including empty), the handler
|
|
761
|
+
* compiles a SEPARATE per-call contract from the RAW inferred schema (via `@orkestrel/contract`'s
|
|
762
|
+
* `schemaToShape`, NOT the `schemaToObject`-wrapped parameters — a bare-value sample checks a
|
|
763
|
+
* bare-value candidate) and returns `{ parameters, checks }`, one check per candidate at the same
|
|
764
|
+
* index. Every entry has a UNIFORM shape — `{ index, valid, coercible }`, with `faults` added ONLY
|
|
765
|
+
* when `valid` is `false`: `valid` is the STRICT guard verdict (`checker.is(candidate)`), the
|
|
766
|
+
* OPPOSITE of {@link createEndpointTool}'s enforcement, which coerces (`7` becomes `'7'` for a
|
|
767
|
+
* string slot) — here a conformance report answers "does this value conform AS-IS": `7` against a
|
|
768
|
+
* string slot is `valid: false`, full stop. `coercible` answers a SEPARATE question — "would the
|
|
769
|
+
* NORMALIZING parse accept this value", i.e. would {@link createEndpointTool}'s default enforcement
|
|
770
|
+
* admit it (`checker.parse(candidate) !== undefined`) — computed for every candidate regardless of
|
|
771
|
+
* `valid`; by the house parse/guard round-trip guarantee (AGENTS §14), a `valid: true` entry is
|
|
772
|
+
* ALWAYS also `coercible: true`. `@orkestrel/contract` 0.0.7's `explain` mirrors the normalizing
|
|
773
|
+
* `parse`'s leniency, not `is`'s strictness — so a strictly-invalid but coercible candidate (`7`
|
|
774
|
+
* against a string slot) yields `{ valid: false, coercible: true, faults: [] }`: EMPTY faults, since
|
|
775
|
+
* the mismatch the normalizing parse would silently fix is not one `explain` reports. `faults`
|
|
776
|
+
* therefore only ever populates for a NON-coercible mismatch — a wrong type the parse can't coerce
|
|
777
|
+
* (a boolean in a string slot), a missing required key, or an out-of-enum value — where
|
|
778
|
+
* `coercible: false`. `checker.is` / `.parse` / `.explain` are all total over JSON-safe input — a
|
|
779
|
+
* JSON-safe hostile candidate (a `__proto__`-carrying object, deeply nested data) reaches all three
|
|
780
|
+
* and yields a bounded, non-throwing per-candidate verdict; a NON-JSON-safe candidate (e.g. a
|
|
781
|
+
* throwing-getter `Proxy`) never reaches the checker at all — it fails the OUTER `args` parse
|
|
782
|
+
* against {@link import('./shapers.js').inferToolShape} and rejects the WHOLE call with the same
|
|
783
|
+
* `TOOL` {@link import('./errors.js').AgentToolError} a malformed `samples`/`format`/`enum` throws,
|
|
784
|
+
* with no per-candidate verdict produced.
|
|
785
|
+
*
|
|
786
|
+
* @param options - Advertised `name` / `description` overrides (see
|
|
787
|
+
* {@link import('./types.js').InferToolOptions})
|
|
788
|
+
* @returns A `ToolInterface` (named {@link import('./constants.js').INFER_TOOL_NAME} by default)
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* ```ts
|
|
792
|
+
* import { createInferTool } from '@src/core'
|
|
793
|
+
* import { createToolManager } from '@orkestrel/agent'
|
|
794
|
+
*
|
|
795
|
+
* const tool = createInferTool()
|
|
796
|
+
* const tools = createToolManager()
|
|
797
|
+
* tools.add(tool)
|
|
798
|
+
*
|
|
799
|
+
* const result = await tools.execute({
|
|
800
|
+
* id: 'call-1',
|
|
801
|
+
* name: 'infer',
|
|
802
|
+
* arguments: { samples: [{ id: 1, name: 'Ada' }, { id: 2, name: 'Bob' }] },
|
|
803
|
+
* })
|
|
804
|
+
* // result.value -> { type: 'object', properties: { id: {...}, name: {...} }, ... }
|
|
805
|
+
*
|
|
806
|
+
* // with candidates, the result is wrapped with per-candidate verdicts
|
|
807
|
+
* const checked = await tools.execute({
|
|
808
|
+
* id: 'call-2',
|
|
809
|
+
* name: 'infer',
|
|
810
|
+
* arguments: {
|
|
811
|
+
* samples: [{ id: 1, name: 'Ada' }],
|
|
812
|
+
* candidates: [{ id: 2, name: 'Bob' }, { id: 'x', name: 'Cy' }],
|
|
813
|
+
* },
|
|
814
|
+
* })
|
|
815
|
+
* // checked.value -> { parameters: {...}, checks: [
|
|
816
|
+
* // { index: 0, valid: true, coercible: true },
|
|
817
|
+
* // { index: 1, valid: false, coercible: false, faults: [...] },
|
|
818
|
+
* // ] }
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
export declare function createInferTool(options?: InferToolOptions): ToolInterface;
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Create the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of database
|
|
825
|
+
* definitions, the DEFAULT store the upcoming database / relation tools will persist their
|
|
826
|
+
* `DatabaseDefinition` configs through.
|
|
827
|
+
*
|
|
828
|
+
* @returns A {@link DefinitionStoreInterface}
|
|
829
|
+
*
|
|
830
|
+
* @example
|
|
831
|
+
* ```ts
|
|
832
|
+
* import { createMemoryDefinitionStore } from '@src/core'
|
|
833
|
+
*
|
|
834
|
+
* const store = createMemoryDefinitionStore()
|
|
835
|
+
* ```
|
|
836
|
+
*/
|
|
837
|
+
export declare function createMemoryDefinitionStore(): DefinitionStoreInterface;
|
|
838
|
+
|
|
504
839
|
/**
|
|
505
840
|
* Build an LLM-callable prompt tool — the ASK side of the terminal seam. Asks
|
|
506
841
|
* {@link import('./types.js').PromptToolOptions.to} a question and BLOCKS until it answers,
|
|
@@ -537,6 +872,55 @@ export declare function createDescribeTool(tools: ToolManagerInterface): ToolInt
|
|
|
537
872
|
*/
|
|
538
873
|
export declare function createPromptTool(options: PromptToolOptions): ToolInterface;
|
|
539
874
|
|
|
875
|
+
/**
|
|
876
|
+
* Build an LLM-callable relation tool — traverse and edit `@orkestrel/relation` relationships
|
|
877
|
+
* through one `operation`-discriminated call (AGENTS §14, matching {@link createDatabaseTool}'s
|
|
878
|
+
* single-tool-many-operations shape).
|
|
879
|
+
*
|
|
880
|
+
* @remarks
|
|
881
|
+
* The universal tool-handler contract (AGENTS §14): validates the call args against
|
|
882
|
+
* {@link import('./shapers.js').relationToolShape}, resolves the addressed
|
|
883
|
+
* {@link import('@orkestrel/relation').RelationManagerInterface} — an explicit `manager` field
|
|
884
|
+
* must match a key of {@link import('./types.js').RelationToolOptions.managers}, an OMITTED one
|
|
885
|
+
* resolves to the SOLE registered manager, either miss throwing a typed `TOOL`
|
|
886
|
+
* {@link import('./errors.js').AgentToolError}
|
|
887
|
+
* ({@link import('./helpers.js').relationManagerOf}) — then resolves `model` against it
|
|
888
|
+
* ({@link import('./helpers.js').relationModelOf}, same typed-`TOOL`-on-miss shape), and
|
|
889
|
+
* dispatches to the matched operation, RETURNING a plain result on success.
|
|
890
|
+
*
|
|
891
|
+
* `'load'` / `'find'` expand the call's FLAT dot-path `include` list into a live
|
|
892
|
+
* `@orkestrel/relation` `Include` tree via {@link import('./helpers.js').expandInclude}, capped
|
|
893
|
+
* at {@link import('./types.js').RelationToolOptions.depth} (default
|
|
894
|
+
* {@link import('./constants.js').RELATION_TOOL_DEPTH}) — a path exceeding the cap, or carrying an
|
|
895
|
+
* empty segment, throws a typed `TOOL` error. `'load'` dispatches on whether `key` is an array
|
|
896
|
+
* (positional many-key form, AGENTS §9.2) or a single key. `'find'` and `'links'` clamp their
|
|
897
|
+
* result to {@link import('./types.js').RelationToolOptions.limit} (default
|
|
898
|
+
* {@link import('./constants.js').RELATION_TOOL_LIMIT}) — `'find'` probes one row past the
|
|
899
|
+
* effective limit (mirroring {@link import('./helpers.js').clampCriteria}'s idiom) to report
|
|
900
|
+
* `truncated`; `'links'` (which has no upstream pagination) fetches the FULL linked-key list and
|
|
901
|
+
* slices/truncates it the same way. `'link'` / `'unlink'` write / remove one `through` junction
|
|
902
|
+
* row.
|
|
903
|
+
*
|
|
904
|
+
* A typed `@orkestrel/relation` failure (`RelationError`) re-surfaces as a typed `RELATION`
|
|
905
|
+
* `AgentToolError` carrying the original {@link import('@orkestrel/relation').RelationErrorCode}
|
|
906
|
+
* in `context.code`; a typed `@orkestrel/database` failure underneath it (`DatabaseError`)
|
|
907
|
+
* re-surfaces as a typed `DATABASE` `AgentToolError`, mirroring {@link createDatabaseTool}'s error
|
|
908
|
+
* mapping; an `AgentToolError` thrown by this tool's own guards (malformed args, an unknown
|
|
909
|
+
* manager/model) passes through unwrapped.
|
|
910
|
+
*
|
|
911
|
+
* @param options - The tool's configuration (see {@link import('./types.js').RelationToolOptions})
|
|
912
|
+
* @returns A `ToolInterface` (named {@link import('./constants.js').RELATION_TOOL_NAME} by default)
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```ts
|
|
916
|
+
* import { createRelationTool } from '@src/core'
|
|
917
|
+
*
|
|
918
|
+
* const tool = createRelationTool({ managers: { shop: manager } })
|
|
919
|
+
* await tool.execute({ operation: 'load', model: 'accounts', key: 'acc1', include: ['contacts'] })
|
|
920
|
+
* ```
|
|
921
|
+
*/
|
|
922
|
+
export declare function createRelationTool(options: RelationToolOptions): ToolInterface;
|
|
923
|
+
|
|
540
924
|
/**
|
|
541
925
|
* Wrap a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the OPT-IN
|
|
542
926
|
* adapter that lets a `function`-form task run a `@orkestrel/agent` tool BY NAME.
|
|
@@ -712,6 +1096,355 @@ export declare function createWorkflowTool(definition: WorkflowDefinition, runne
|
|
|
712
1096
|
*/
|
|
713
1097
|
export declare function createWorkspaceTool(options?: WorkspaceToolOptions): ToolInterface;
|
|
714
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* Normalize the database tool's parsed SERIALIZED criteria into a live `@orkestrel/database`
|
|
1101
|
+
* {@link Criteria} — default each condition's OMITTED `connector` to `'and'`.
|
|
1102
|
+
*
|
|
1103
|
+
* @remarks
|
|
1104
|
+
* The wire form ({@link import('./shapers.js').databaseToolShape}) lets a caller drop `connector`
|
|
1105
|
+
* on the last condition (it has nothing to join FORWARD to); the compiled `Condition` a live
|
|
1106
|
+
* `@orkestrel/database` table call accepts always carries one, so this fills the gap. `order` /
|
|
1107
|
+
* `limit` / `offset` pass through unchanged. Pure and total.
|
|
1108
|
+
*
|
|
1109
|
+
* @param criteria - The parsed criteria (or `undefined`)
|
|
1110
|
+
* @returns The equivalent live `Criteria`, or `undefined` when `criteria` is `undefined`
|
|
1111
|
+
*/
|
|
1112
|
+
export declare function criteriaOf(criteria: Readonly<{
|
|
1113
|
+
conditions?: readonly Readonly<{
|
|
1114
|
+
column: string;
|
|
1115
|
+
operator: Condition['operator'];
|
|
1116
|
+
values: readonly unknown[];
|
|
1117
|
+
connector?: Connector;
|
|
1118
|
+
}>[];
|
|
1119
|
+
order?: readonly Readonly<{
|
|
1120
|
+
column: string;
|
|
1121
|
+
direction: Direction;
|
|
1122
|
+
}>[];
|
|
1123
|
+
limit?: number;
|
|
1124
|
+
offset?: number;
|
|
1125
|
+
}> | undefined): Criteria | undefined;
|
|
1126
|
+
|
|
1127
|
+
/** The SERIALIZED criteria form — conditions, order, and pagination. */
|
|
1128
|
+
export declare const criteriaShape: ObjectShape<{
|
|
1129
|
+
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1130
|
+
column: StringShape;
|
|
1131
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1132
|
+
values: ArrayShape<JSONShape>;
|
|
1133
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1134
|
+
}, false>>>;
|
|
1135
|
+
order: OptionalShape<ArrayShape<ObjectShape<{
|
|
1136
|
+
column: StringShape;
|
|
1137
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1138
|
+
}, false>>>;
|
|
1139
|
+
limit: OptionalShape<NumberShape>;
|
|
1140
|
+
offset: OptionalShape<NumberShape>;
|
|
1141
|
+
}, false>;
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* The DESCRIPTION the upcoming database tool will advertise — a multi-line guide that teaches a
|
|
1145
|
+
* small model the operation list, the SERIALIZED criteria form, and the {@link import('./types.js').TableSpec}
|
|
1146
|
+
* column DSL.
|
|
1147
|
+
*
|
|
1148
|
+
* @remarks
|
|
1149
|
+
* The criteria form is deliberately SERIALIZED (never fluent) — every condition is a flat object
|
|
1150
|
+
* `{ column, operator, values, connector? }` where `values` is ALWAYS an array, even for a
|
|
1151
|
+
* single-value operator (`{ column: 'age', operator: 'from', values: [18] }`), so a small model
|
|
1152
|
+
* never has to chain method calls or guess whether a value is scalar or a list.
|
|
1153
|
+
*/
|
|
1154
|
+
export declare const DATABASE_TOOL_DESCRIPTION: string;
|
|
1155
|
+
|
|
1156
|
+
/** The default cap on rows a `records` / `remove` call returns (or acts on) when the caller omits `criteria.limit` — the upcoming database tool's default row ceiling. */
|
|
1157
|
+
export declare const DATABASE_TOOL_LIMIT = 1000;
|
|
1158
|
+
|
|
1159
|
+
/** The database tool's mutating operations — disabled by `DatabaseToolOptions.readonly`. */
|
|
1160
|
+
export declare const DATABASE_TOOL_MUTATIONS: Set<string>;
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* The name the upcoming `createDatabaseTool` factory will advertise by default — the key a model
|
|
1164
|
+
* calls and the `ToolManagerInterface` (`@orkestrel/agent`) registers under.
|
|
1165
|
+
*
|
|
1166
|
+
* @remarks
|
|
1167
|
+
* SRC-1 of a 3-unit spine: this unit lands the persistence + schema foundation
|
|
1168
|
+
* ({@link import('./types.js').DatabaseDefinition}, {@link import('./types.js').DefinitionStoreInterface},
|
|
1169
|
+
* {@link import('./helpers.js').expandTables}); `createDatabaseTool` itself is built in a later unit.
|
|
1170
|
+
*/
|
|
1171
|
+
export declare const DATABASE_TOOL_NAME = "database";
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* The lean {@link import('@orkestrel/agent').ToolInterface.summary} the upcoming database tool
|
|
1175
|
+
* will advertise in place of {@link DATABASE_TOOL_DESCRIPTION}.
|
|
1176
|
+
*/
|
|
1177
|
+
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, migrate, destroy), chosen by the 'operation' field. Call describe('database') for the full operation list, the criteria form, and the column DSL.";
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* One database's CONFIG-ONLY definition — `id` + `driver` + {@link TableSpec} (+ optional `keys`),
|
|
1181
|
+
* the pure-JSON blueprint the upcoming database / relation tools build a live database from.
|
|
1182
|
+
*
|
|
1183
|
+
* @remarks
|
|
1184
|
+
* A `DatabaseDefinition` is NEVER a live handle — it is the durable, serializable config a
|
|
1185
|
+
* {@link DefinitionStoreInterface} persists and a tool factory turns into a real
|
|
1186
|
+
* `@orkestrel/database` `DatabaseInterface` (via `createDatabase` + {@link import('./helpers.js').expandTables})
|
|
1187
|
+
* on demand. `keys`, when present, maps a table name to its primary-key column (omitted ⇒ the
|
|
1188
|
+
* driver's default primary key).
|
|
1189
|
+
*/
|
|
1190
|
+
export declare interface DatabaseDefinition {
|
|
1191
|
+
readonly id: string;
|
|
1192
|
+
readonly driver: string;
|
|
1193
|
+
readonly tables: TableSpec;
|
|
1194
|
+
readonly keys?: Readonly<Record<string, string>>;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/** One opaque persisted row — the shape a `TableInterface<DatabaseDefinitionRow>`-backed store reads/writes; `definition` is narrowed with {@link import('./helpers.js').isDatabaseDefinition} on read. */
|
|
1198
|
+
export declare interface DatabaseDefinitionRow {
|
|
1199
|
+
readonly id: string;
|
|
1200
|
+
readonly definition: unknown;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* A {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
|
|
1205
|
+
* database's durable CONFIG state IS a row, so persistence reduces to keyed point-access
|
|
1206
|
+
* (`get` / `set` / `delete`) over a {@link TableInterface}, the driver-pluggable twin of the
|
|
1207
|
+
* plain-`Map` {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}.
|
|
1208
|
+
*
|
|
1209
|
+
* @remarks
|
|
1210
|
+
* The store is driver-agnostic: it holds a single {@link TableInterface} whose backend (memory,
|
|
1211
|
+
* JSON, SQLite, IndexedDB) is chosen by whoever builds it (the factories), so a JSON / SQLite /
|
|
1212
|
+
* IndexedDB backend swaps in WITHOUT touching a consumer — the same seam as
|
|
1213
|
+
* {@link import('./MemoryDefinitionStore.js').MemoryDefinitionStore}. The driver defaults to
|
|
1214
|
+
* memory ({@link import('../factories.js').createDatabaseDefinitionStore} passes
|
|
1215
|
+
* `createMemoryDriver()`), so it ALSO works in memory out of the box; you opt into the durable
|
|
1216
|
+
* plumbing by passing a JSON / SQLite / IndexedDB driver.
|
|
1217
|
+
*
|
|
1218
|
+
* The {@link DatabaseDefinition} is stored as ONE OPAQUE JSON COLUMN — the table is a row of
|
|
1219
|
+
* `{ id; definition }` ({@link DatabaseDefinitionRow}). The definition is already a COMPLETE,
|
|
1220
|
+
* self-contained, pure-JSON CONFIG payload (never a live handle), so storing it whole is lossless
|
|
1221
|
+
* AND keeps the row type flat (`definition` reads back as `unknown`).
|
|
1222
|
+
*
|
|
1223
|
+
* - **`set(definition)` upserts under the definition's OWN `id`** (no separate id param) — it
|
|
1224
|
+
* writes the row `{ id: definition.id, definition }`.
|
|
1225
|
+
* - **`get(id)` resolves the stored definition for an id**, narrowing the opaque JSON column back
|
|
1226
|
+
* to a {@link DatabaseDefinition} ({@link import('../helpers.js').isDatabaseDefinition} — the
|
|
1227
|
+
* AGENTS §14 boundary narrow for an untrusted storage read), or `undefined` if none is stored
|
|
1228
|
+
* or the stored blob is malformed.
|
|
1229
|
+
* - **`delete(id)` drops a definition by id**; an absent id is a no-op (no throw).
|
|
1230
|
+
*
|
|
1231
|
+
* The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
|
|
1232
|
+
* bijection with {@link DefinitionStoreInterface}).
|
|
1233
|
+
*
|
|
1234
|
+
* @example
|
|
1235
|
+
* ```ts
|
|
1236
|
+
* import { createDatabaseDefinitionStore, createMemoryDriver } from '@src/core'
|
|
1237
|
+
*
|
|
1238
|
+
* const store = createDatabaseDefinitionStore(createMemoryDriver()) // a durable driver swaps in here
|
|
1239
|
+
* await store.set({ id: 'shop', driver: 'memory', tables: {} }) // persist the config (one JSON column)
|
|
1240
|
+
* const definition = await store.get('shop')
|
|
1241
|
+
* await store.delete('shop')
|
|
1242
|
+
* ```
|
|
1243
|
+
*/
|
|
1244
|
+
export declare class DatabaseDefinitionStore implements DefinitionStoreInterface {
|
|
1245
|
+
#private;
|
|
1246
|
+
/**
|
|
1247
|
+
* Wrap a table as a definition store.
|
|
1248
|
+
*
|
|
1249
|
+
* @param table - The {@link TableInterface} holding the definitions — its row is the
|
|
1250
|
+
* {@link DatabaseDefinitionRow} `{ id; definition }` shape (the definition one opaque JSON column)
|
|
1251
|
+
*/
|
|
1252
|
+
constructor(table: TableInterface<DatabaseDefinitionRow>);
|
|
1253
|
+
/** Resolve the persisted definition for `id`, narrowing the opaque JSON column back to a `DatabaseDefinition`. */
|
|
1254
|
+
get(id: string): Promise<DatabaseDefinition | undefined>;
|
|
1255
|
+
/** Insert or replace under the definition's OWN `id` (no separate id param) — the row is `{ id, definition }`. */
|
|
1256
|
+
set(definition: DatabaseDefinition): Promise<void>;
|
|
1257
|
+
/** Drop a definition by id; an absent id is a no-op (no throw). */
|
|
1258
|
+
delete(id: string): Promise<void>;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Map a caught error to the {@link AgentToolErrorCode} the upcoming database tool should throw
|
|
1263
|
+
* with — the pure classification step of that factory's error handling, mirroring
|
|
1264
|
+
* {@link terminalToolCode}'s idiom for `@orkestrel/database`.
|
|
1265
|
+
*
|
|
1266
|
+
* @param error - The value caught from a `@orkestrel/database` table operation
|
|
1267
|
+
* @returns The granular {@link DatabaseErrorCode}, or `undefined` if `error` is not a `DatabaseError`
|
|
1268
|
+
*/
|
|
1269
|
+
export declare function databaseToolCode(error: unknown): DatabaseErrorCode | undefined;
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Options for {@link import('./factories.js').createDatabaseTool} — SRC-2 of the 3-unit database
|
|
1273
|
+
* / relation spine, built over the SRC-1 foundation ({@link DatabaseDefinition},
|
|
1274
|
+
* {@link DefinitionStoreInterface}, {@link import('./helpers.js').expandTables}).
|
|
1275
|
+
*
|
|
1276
|
+
* @remarks
|
|
1277
|
+
* - `databases` — live `DatabaseInterface` handles to seed the tool's cache with (e.g. a
|
|
1278
|
+
* caller-constructed database it should manage alongside store-backed ones); keyed by the id a
|
|
1279
|
+
* call's `id` field addresses.
|
|
1280
|
+
* - `store` — the {@link DefinitionStoreInterface} the `'create'` / `'migrate'` operations persist
|
|
1281
|
+
* their {@link DatabaseDefinition} CONFIG through, and `'destroy'` deletes from; also the source
|
|
1282
|
+
* `'get'`/every other operation resolves an id from when it isn't already cached. Omitted means
|
|
1283
|
+
* no persistence — a database created without a store lives only for the tool's lifetime.
|
|
1284
|
+
* - `drivers` — registry of driver-name to `() => DriverInterface` factories a `'create'` call's
|
|
1285
|
+
* `driver` field (or a persisted definition's `driver`) resolves against. Defaults to
|
|
1286
|
+
* `{ memory: () => createMemoryDriver() }` (`@orkestrel/database`).
|
|
1287
|
+
* - `key` — the `KeyFunction` (`@orkestrel/database`) every minted database is constructed with,
|
|
1288
|
+
* used when a written row lacks its primary key. Defaults to `generateUUID`.
|
|
1289
|
+
* - `limit` — the row cap `'records'` / `'remove'` — via {@link import('./helpers.js').clampCriteria}
|
|
1290
|
+
* — enforce when a call's `criteria.limit` is omitted or exceeds it. Defaults to
|
|
1291
|
+
* {@link import('./constants.js').DATABASE_TOOL_LIMIT}.
|
|
1292
|
+
* - `timeout` — milliseconds; when set, every `@orkestrel/database` call this tool makes is given
|
|
1293
|
+
* a fresh `AbortSignal.timeout(timeout)` per tool call.
|
|
1294
|
+
* - `readonly` — when `true`, every mutating operation (`'create'` / `'add'` / `'set'` /
|
|
1295
|
+
* `'update'` / `'remove'` / `'migrate'` / `'destroy'`) throws a typed `TOOL`
|
|
1296
|
+
* {@link import('./errors.js').AgentToolError} before doing anything.
|
|
1297
|
+
* - `name` / `description` — advertised tool overrides; default to
|
|
1298
|
+
* {@link import('./constants.js').DATABASE_TOOL_NAME} / {@link import('./constants.js').DATABASE_TOOL_DESCRIPTION}.
|
|
1299
|
+
*/
|
|
1300
|
+
export declare interface DatabaseToolOptions {
|
|
1301
|
+
readonly name?: string;
|
|
1302
|
+
readonly description?: string;
|
|
1303
|
+
readonly databases?: Readonly<Record<string, DatabaseInterface>>;
|
|
1304
|
+
readonly store?: DefinitionStoreInterface;
|
|
1305
|
+
readonly drivers?: Readonly<Record<string, () => DriverInterface>>;
|
|
1306
|
+
readonly key?: KeyFunction;
|
|
1307
|
+
readonly limit?: number;
|
|
1308
|
+
readonly timeout?: number;
|
|
1309
|
+
readonly readonly?: boolean;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* The shape of {@link import('./factories.js').createDatabaseTool}'s call arguments —
|
|
1314
|
+
* discriminated by `operation` into the 12 database operations (`'create'` / `'tables'` /
|
|
1315
|
+
* `'get'` / `'records'` / `'count'` / `'aggregate'` / `'add'` / `'set'` / `'update'` /
|
|
1316
|
+
* `'remove'` / `'migrate'` / `'destroy'`).
|
|
1317
|
+
*
|
|
1318
|
+
* @remarks
|
|
1319
|
+
* Every arm carries `id` (the database id). `'create'` / `'migrate'` carry `tables` (the
|
|
1320
|
+
* {@link import('./types.js').TableSpec} column DSL, compiled via
|
|
1321
|
+
* {@link import('./helpers.js').expandTables}); `'get'` / `'update'` / `'remove'` carry `key`
|
|
1322
|
+
* (one key or an array of keys, positional); `'add'` / `'set'` carry `row` (one row or an array of
|
|
1323
|
+
* rows); `'update'` also carries `changes` (a loose partial row); `'records'` / `'count'` /
|
|
1324
|
+
* `'aggregate'` carry an optional `criteria` (the SERIALIZED form — `values` is ALWAYS an array,
|
|
1325
|
+
* even for a single-value operator, so a caller never chains method calls or guesses arity).
|
|
1326
|
+
*/
|
|
1327
|
+
export declare const databaseToolShape: UnionShape<[ ObjectShape<{
|
|
1328
|
+
operation: LiteralShape<readonly ["create"]>;
|
|
1329
|
+
id: StringShape;
|
|
1330
|
+
tables: ObjectShape<Record<never, never>, ObjectShape<{
|
|
1331
|
+
columns: ObjectShape<Record<never, never>, UnionShape<[ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
|
|
1332
|
+
type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
1333
|
+
optional: OptionalShape<BooleanShape>;
|
|
1334
|
+
}, false>]>>;
|
|
1335
|
+
}, false>>;
|
|
1336
|
+
driver: OptionalShape<StringShape>;
|
|
1337
|
+
keys: OptionalShape<ObjectShape<Record<never, never>, StringShape>>;
|
|
1338
|
+
}, false>, ObjectShape<{
|
|
1339
|
+
operation: LiteralShape<readonly ["tables"]>;
|
|
1340
|
+
id: StringShape;
|
|
1341
|
+
}, false>, ObjectShape<{
|
|
1342
|
+
operation: LiteralShape<readonly ["get"]>;
|
|
1343
|
+
id: StringShape;
|
|
1344
|
+
table: StringShape;
|
|
1345
|
+
key: UnionShape<[ ArrayShape<UnionShape<[ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1346
|
+
}, false>, ObjectShape<{
|
|
1347
|
+
operation: LiteralShape<readonly ["records"]>;
|
|
1348
|
+
id: StringShape;
|
|
1349
|
+
table: StringShape;
|
|
1350
|
+
criteria: OptionalShape<ObjectShape<{
|
|
1351
|
+
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1352
|
+
column: StringShape;
|
|
1353
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1354
|
+
values: ArrayShape<JSONShape>;
|
|
1355
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1356
|
+
}, false>>>;
|
|
1357
|
+
order: OptionalShape<ArrayShape<ObjectShape<{
|
|
1358
|
+
column: StringShape;
|
|
1359
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1360
|
+
}, false>>>;
|
|
1361
|
+
limit: OptionalShape<NumberShape>;
|
|
1362
|
+
offset: OptionalShape<NumberShape>;
|
|
1363
|
+
}, false>>;
|
|
1364
|
+
}, false>, ObjectShape<{
|
|
1365
|
+
operation: LiteralShape<readonly ["count"]>;
|
|
1366
|
+
id: StringShape;
|
|
1367
|
+
table: StringShape;
|
|
1368
|
+
criteria: OptionalShape<ObjectShape<{
|
|
1369
|
+
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1370
|
+
column: StringShape;
|
|
1371
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1372
|
+
values: ArrayShape<JSONShape>;
|
|
1373
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1374
|
+
}, false>>>;
|
|
1375
|
+
order: OptionalShape<ArrayShape<ObjectShape<{
|
|
1376
|
+
column: StringShape;
|
|
1377
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1378
|
+
}, false>>>;
|
|
1379
|
+
limit: OptionalShape<NumberShape>;
|
|
1380
|
+
offset: OptionalShape<NumberShape>;
|
|
1381
|
+
}, false>>;
|
|
1382
|
+
}, false>, ObjectShape<{
|
|
1383
|
+
operation: LiteralShape<readonly ["aggregate"]>;
|
|
1384
|
+
id: StringShape;
|
|
1385
|
+
table: StringShape;
|
|
1386
|
+
function: LiteralShape<readonly ["count", "sum", "average", "minimum", "maximum"]>;
|
|
1387
|
+
column: StringShape;
|
|
1388
|
+
criteria: OptionalShape<ObjectShape<{
|
|
1389
|
+
conditions: OptionalShape<ArrayShape<ObjectShape<{
|
|
1390
|
+
column: StringShape;
|
|
1391
|
+
operator: LiteralShape<readonly ["equals", "not", "above", "below", "from", "to", "between", "like", "glob", "starts", "ends", "any", "none", "absent", "present"]>;
|
|
1392
|
+
values: ArrayShape<JSONShape>;
|
|
1393
|
+
connector: OptionalShape<LiteralShape<readonly ["and", "or"]>>;
|
|
1394
|
+
}, false>>>;
|
|
1395
|
+
order: OptionalShape<ArrayShape<ObjectShape<{
|
|
1396
|
+
column: StringShape;
|
|
1397
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1398
|
+
}, false>>>;
|
|
1399
|
+
limit: OptionalShape<NumberShape>;
|
|
1400
|
+
offset: OptionalShape<NumberShape>;
|
|
1401
|
+
}, false>>;
|
|
1402
|
+
}, false>, ObjectShape<{
|
|
1403
|
+
operation: LiteralShape<readonly ["add"]>;
|
|
1404
|
+
id: StringShape;
|
|
1405
|
+
table: StringShape;
|
|
1406
|
+
row: UnionShape<[ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
|
|
1407
|
+
}, false>, ObjectShape<{
|
|
1408
|
+
operation: LiteralShape<readonly ["set"]>;
|
|
1409
|
+
id: StringShape;
|
|
1410
|
+
table: StringShape;
|
|
1411
|
+
row: UnionShape<[ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
|
|
1412
|
+
}, false>, ObjectShape<{
|
|
1413
|
+
operation: LiteralShape<readonly ["update"]>;
|
|
1414
|
+
id: StringShape;
|
|
1415
|
+
table: StringShape;
|
|
1416
|
+
key: UnionShape<[ ArrayShape<UnionShape<[ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1417
|
+
changes: ObjectShape<Record<never, never>, JSONShape>;
|
|
1418
|
+
}, false>, ObjectShape<{
|
|
1419
|
+
operation: LiteralShape<readonly ["remove"]>;
|
|
1420
|
+
id: StringShape;
|
|
1421
|
+
table: StringShape;
|
|
1422
|
+
key: UnionShape<[ ArrayShape<UnionShape<[ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1423
|
+
}, false>, ObjectShape<{
|
|
1424
|
+
operation: LiteralShape<readonly ["migrate"]>;
|
|
1425
|
+
id: StringShape;
|
|
1426
|
+
tables: ObjectShape<Record<never, never>, ObjectShape<{
|
|
1427
|
+
columns: ObjectShape<Record<never, never>, UnionShape<[ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
|
|
1428
|
+
type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
1429
|
+
optional: OptionalShape<BooleanShape>;
|
|
1430
|
+
}, false>]>>;
|
|
1431
|
+
}, false>>;
|
|
1432
|
+
}, false>, ObjectShape<{
|
|
1433
|
+
operation: LiteralShape<readonly ["destroy"]>;
|
|
1434
|
+
id: StringShape;
|
|
1435
|
+
}, false>]>;
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* The point-access persistence seam (AGENTS §5 — Stores) for {@link DatabaseDefinition} configs —
|
|
1439
|
+
* the twin of `@orkestrel/terminal`'s `TerminalStoreInterface`, storing a database's CONFIG-ONLY
|
|
1440
|
+
* blueprint (never a live handle). Every primitive is async; `delete` of an absent id is a no-op.
|
|
1441
|
+
*/
|
|
1442
|
+
export declare interface DefinitionStoreInterface {
|
|
1443
|
+
get(id: string): Promise<DatabaseDefinition | undefined>;
|
|
1444
|
+
set(definition: DatabaseDefinition): Promise<void>;
|
|
1445
|
+
delete(id: string): Promise<void>;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
715
1448
|
/**
|
|
716
1449
|
* The DESCRIPTION {@link import('./factories.js').createDescribeTool} advertises.
|
|
717
1450
|
*
|
|
@@ -761,7 +1494,103 @@ export declare interface DescribeToolArguments {
|
|
|
761
1494
|
*/
|
|
762
1495
|
export declare const describeToolShape: ObjectShape<{
|
|
763
1496
|
name: StringShape;
|
|
764
|
-
}>;
|
|
1497
|
+
}, false>;
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* One concrete endpoint {@link import('./factories.js').createEndpointTool} wraps as an
|
|
1501
|
+
* LLM-callable `ToolInterface` — the advertised identity, a non-empty set of example values its
|
|
1502
|
+
* `parameters` are inferred from, and the local handler that runs a call.
|
|
1503
|
+
*
|
|
1504
|
+
* @remarks
|
|
1505
|
+
* `samples` MUST be non-empty — {@link import('./factories.js').createEndpointTool} throws a
|
|
1506
|
+
* typed `TOOL` {@link import('./errors.js').AgentToolError} at CONSTRUCTION when it is empty,
|
|
1507
|
+
* since an empty sample set cannot infer a schema. By DEFAULT ({@link EndpointToolOptions.validate}
|
|
1508
|
+
* `true`) `invoke` receives the PARSED, NORMALIZED args record — a copy of the model-supplied
|
|
1509
|
+
* `args` with each scalar coerced to its inferred type (e.g. a number sent for a string slot
|
|
1510
|
+
* arrives coerced to a string), checked against the same schema advertised as `parameters` — and
|
|
1511
|
+
* a call with a missing required key or a non-coercible value never reaches `invoke` at all (see
|
|
1512
|
+
* {@link EndpointToolOptions.validate}). With
|
|
1513
|
+
* `validate: false`, `invoke` receives the model-supplied `args` VERBATIM (raw passthrough, never
|
|
1514
|
+
* checked against the inferred schema). Either way `invoke`'s return flows back as the tool
|
|
1515
|
+
* call's result; a throw PROPAGATES uncaught, isolated by the `ToolManagerInterface`
|
|
1516
|
+
* (`@orkestrel/agent`) into the canonical error envelope. When `samples` are non-object values,
|
|
1517
|
+
* the advertised schema wraps them under a single required `value` property, so `invoke` receives
|
|
1518
|
+
* an `args` record of the shape `{ value: ... }` — never the bare value.
|
|
1519
|
+
*/
|
|
1520
|
+
export declare interface EndpointDefinition {
|
|
1521
|
+
readonly name: string;
|
|
1522
|
+
readonly description: string;
|
|
1523
|
+
readonly samples: readonly unknown[];
|
|
1524
|
+
readonly invoke: EndpointHandler;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* The handler {@link import('./types.js').EndpointDefinition.invoke} implements — mirrors
|
|
1529
|
+
* `@orkestrel/agent`'s `ToolOptions.execute` signature EXACTLY (same `Readonly<Record<string,
|
|
1530
|
+
* unknown>>` argument, same `Promise<unknown> | unknown` return) so
|
|
1531
|
+
* `execute: (args) => definition.invoke(args)` typechecks with zero assertions in
|
|
1532
|
+
* {@link import('./factories.js').createEndpointTool}.
|
|
1533
|
+
*/
|
|
1534
|
+
export declare type EndpointHandler = (args: Readonly<Record<string, unknown>>) => Promise<unknown> | unknown;
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Construction-time tuning for {@link import('./factories.js').createEndpointTool} — the
|
|
1538
|
+
* inferred `parameters` schema's `format` / `enum` constraints, and whether that same schema is
|
|
1539
|
+
* ENFORCED at `execute` time.
|
|
1540
|
+
*
|
|
1541
|
+
* @remarks
|
|
1542
|
+
* `format` / `enum` default to `false`, matching `@orkestrel/contract`'s own
|
|
1543
|
+
* `ValueToSchemaOptions` defaults. `validate` defaults to `true`: the schema
|
|
1544
|
+
* `createEndpointTool` advertises as `parameters` (`samplesToSchema` + `schemaToObject`) is
|
|
1545
|
+
* compiled ONCE at construction (via `@orkestrel/contract` 0.0.7's `schemaToShape`) into a
|
|
1546
|
+
* `ContractInterface` used to `parse` every call's `args` before `invoke` runs — a NORMALIZING
|
|
1547
|
+
* parse: a scalar value is COERCED to its inferred type where the house parsers coerce (a number
|
|
1548
|
+
* to/from a numeric string, a boolean from `'1'`/`'0'`/`'true'`/`'false'`/`1`/`0`), so `invoke`
|
|
1549
|
+
* receives the COERCED values (e.g. `7` sent for a string slot arrives at `invoke` as `'7'`), not
|
|
1550
|
+
* the raw call args. A call whose `args` fails to parse — a required key missing, or a value not
|
|
1551
|
+
* coercible to its slot's type — THROWS a typed `TOOL` {@link import('./errors.js').AgentToolError}
|
|
1552
|
+
* carrying the structured `explain` faults, and `invoke` is never called. Beyond that coercion,
|
|
1553
|
+
* enforcement is STRUCTURAL — required keys, `enum` membership, and numeric bounds — `format`
|
|
1554
|
+
* annotations (`email`, `date-time`, `uuid`, `uri`, ...) are NEVER asserted, mirroring
|
|
1555
|
+
* `@orkestrel/contract`'s own widening-only law for `schemaToShape`: a `format: true`-tuned
|
|
1556
|
+
* endpoint still ACCEPTS a non-conforming string in a format-tagged slot. A key NOT present in
|
|
1557
|
+
* the inferred (closed, `additionalProperties: false`) schema is NEVER a rejection either — it is
|
|
1558
|
+
* SILENTLY DROPPED before `invoke` runs (the same leniency `@orkestrel/contract`'s own `parse`
|
|
1559
|
+
* grants a closed object generally), so `invoke` may see fewer keys than the caller sent. Set
|
|
1560
|
+
* `validate: false` to restore the PRE-0.0.7 behavior exactly — `execute` passes the
|
|
1561
|
+
* model-supplied `args` straight to `invoke` UNCHANGED, unchecked and unstripped.
|
|
1562
|
+
*/
|
|
1563
|
+
export declare interface EndpointToolOptions {
|
|
1564
|
+
readonly format?: boolean;
|
|
1565
|
+
readonly enum?: boolean;
|
|
1566
|
+
readonly validate?: boolean;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Expand the relation tool's FLAT dot-path `include` list into a live `@orkestrel/relation`
|
|
1571
|
+
* {@link Include} tree — the pure leaf {@link import('./factories.js').createRelationTool} calls
|
|
1572
|
+
* before a `'load'` / `'find'` call.
|
|
1573
|
+
*
|
|
1574
|
+
* @remarks
|
|
1575
|
+
* Each path splits on `'.'` into a chain of relation names, deep-merged into one nested
|
|
1576
|
+
* `Include` object with a leaf `true`. A longer path SUBSUMES a shorter sibling's bare `true` —
|
|
1577
|
+
* `'contacts'` followed by `'contacts.account'` yields `{ contacts: { account: true } }`, never
|
|
1578
|
+
* overwriting the deeper chain. An EMPTY segment (`''`, from a leading/trailing/doubled `.`) or a
|
|
1579
|
+
* path whose segment count exceeds `depth` throws a typed `TOOL` {@link AgentToolError}.
|
|
1580
|
+
*
|
|
1581
|
+
* @param paths - The flat dot-path `include` list (or `undefined` — yields `{}`)
|
|
1582
|
+
* @param depth - The max segment count a single path may reach
|
|
1583
|
+
* @returns The equivalent nested {@link Include}
|
|
1584
|
+
*
|
|
1585
|
+
* @example
|
|
1586
|
+
* ```ts
|
|
1587
|
+
* import { expandInclude } from '@src/core'
|
|
1588
|
+
*
|
|
1589
|
+
* expandInclude(['contacts', 'contacts.account'], 3)
|
|
1590
|
+
* // { contacts: { account: true } }
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
export declare function expandInclude(paths: readonly string[] | undefined, depth: number): Include;
|
|
765
1594
|
|
|
766
1595
|
/**
|
|
767
1596
|
* Expand a flat {@link WorkflowSteps} blob into a strict {@link WorkflowDefinition} — each step
|
|
@@ -782,6 +1611,68 @@ export declare const describeToolShape: ObjectShape<{
|
|
|
782
1611
|
*/
|
|
783
1612
|
export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
|
|
784
1613
|
|
|
1614
|
+
/**
|
|
1615
|
+
* Compile a {@link TableSpec} into the `@orkestrel/database` {@link TablesShape} it configures —
|
|
1616
|
+
* each {@link ColumnSpec} maps to the matching primitive shaper (`'string'` → `stringShape()`,
|
|
1617
|
+
* `'integer'` → `integerShape()`, `'number'` → `numberShape()`, `'boolean'` → `booleanShape()`),
|
|
1618
|
+
* wrapped in `optionalShape` when the column declares `optional: true`. Total, pure.
|
|
1619
|
+
*
|
|
1620
|
+
* @param spec - The small-model-facing table layout
|
|
1621
|
+
* @returns The compiled `TablesShape` a `@orkestrel/database` `createDatabase` call accepts
|
|
1622
|
+
*/
|
|
1623
|
+
export declare function expandTables(spec: TableSpec): TablesShape;
|
|
1624
|
+
|
|
1625
|
+
/** Flat dot-path relation include list, expanded via {@link import('./helpers.js').expandInclude}. */
|
|
1626
|
+
export declare const includeShape: OptionalShape<ArrayShape<StringShape>>;
|
|
1627
|
+
|
|
1628
|
+
export declare const INFER_TOOL_DESCRIPTION: string;
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* The name {@link import('./factories.js').createInferTool} advertises by default — the key a
|
|
1632
|
+
* model calls and the `ToolManagerInterface` (`@orkestrel/agent`) registers under.
|
|
1633
|
+
*/
|
|
1634
|
+
export declare const INFER_TOOL_NAME = "infer";
|
|
1635
|
+
|
|
1636
|
+
/**
|
|
1637
|
+
* The lean {@link import('@orkestrel/agent').ToolInterface.summary} {@link import('./factories.js').createInferTool}
|
|
1638
|
+
* advertises in place of {@link INFER_TOOL_DESCRIPTION} — a `ToolManagerInterface.definitions()`
|
|
1639
|
+
* (`@orkestrel/agent`) advertises `summary ?? description`, so this one-sentence text stands in
|
|
1640
|
+
* for the full teaching description; the full text stays retrievable via
|
|
1641
|
+
* {@link import('./factories.js').createDescribeTool}.
|
|
1642
|
+
*/
|
|
1643
|
+
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.";
|
|
1644
|
+
|
|
1645
|
+
/**
|
|
1646
|
+
* Options for {@link import('./factories.js').createInferTool} — advertised name/description
|
|
1647
|
+
* overrides only; `format` / `enum` are RUNTIME call arguments (see
|
|
1648
|
+
* {@link import('./shapers.js').inferToolShape}), not construction-time options, since a model
|
|
1649
|
+
* chooses them per call.
|
|
1650
|
+
*/
|
|
1651
|
+
export declare interface InferToolOptions {
|
|
1652
|
+
readonly name?: string;
|
|
1653
|
+
readonly description?: string;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
/**
|
|
1657
|
+
* The shape of {@link import('./factories.js').createInferTool}'s call arguments — one or more
|
|
1658
|
+
* example `samples` to infer a JSON Schema from, plus per-call `format` / `enum` toggles and an
|
|
1659
|
+
* optional `candidates` array to check against the inferred schema.
|
|
1660
|
+
*
|
|
1661
|
+
* @remarks
|
|
1662
|
+
* `samples` requires at least one element (`min: 1`) — an empty array parses to `undefined`,
|
|
1663
|
+
* surfaced by the handler as a typed `TOOL` {@link import('./errors.js').AgentToolError}. When
|
|
1664
|
+
* `candidates` is present (any array, including empty), the handler compiles a contract from the
|
|
1665
|
+
* freshly inferred schema and checks each candidate against it with a STRICT guard (`.is`, no
|
|
1666
|
+
* coercion) — the opposite of {@link import('./factories.js').createEndpointTool}'s NORMALIZING
|
|
1667
|
+
* `.parse` enforcement.
|
|
1668
|
+
*/
|
|
1669
|
+
export declare const inferToolShape: ObjectShape<{
|
|
1670
|
+
samples: ArrayShape<JSONShape>;
|
|
1671
|
+
format: OptionalShape<BooleanShape>;
|
|
1672
|
+
enum: OptionalShape<BooleanShape>;
|
|
1673
|
+
candidates: OptionalShape<ArrayShape<JSONShape>>;
|
|
1674
|
+
}, false>;
|
|
1675
|
+
|
|
785
1676
|
/**
|
|
786
1677
|
* Type guard narrowing an unknown caught value to an {@link AgentToolError}.
|
|
787
1678
|
*
|
|
@@ -801,6 +1692,29 @@ export declare function expandSteps(flat: WorkflowSteps): WorkflowDefinition;
|
|
|
801
1692
|
*/
|
|
802
1693
|
export declare function isAgentToolError(value: unknown): value is AgentToolError;
|
|
803
1694
|
|
|
1695
|
+
/** Narrow an unknown value to a {@link import('./types.js').ColumnKind}. */
|
|
1696
|
+
export declare function isColumnKind(value: unknown): value is ColumnKind;
|
|
1697
|
+
|
|
1698
|
+
/** Narrow an unknown value to a {@link ColumnSpec} — a valid {@link import('./types.js').ColumnKind} shorthand, or `{ type, optional }` with a valid `type`. */
|
|
1699
|
+
export declare function isColumnSpec(value: unknown): value is ColumnSpec;
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Narrow an unknown value to a {@link DatabaseDefinition} — a non-empty `id` + `driver`, a
|
|
1703
|
+
* `tables` record whose every value is `{ columns: record of valid ColumnSpec }`, and an optional
|
|
1704
|
+
* `keys` record of strings. The boundary guard a {@link import('./types.js').DefinitionStoreInterface}
|
|
1705
|
+
* applies to an untrusted persisted blob before trusting it as a definition (never an `as`).
|
|
1706
|
+
*/
|
|
1707
|
+
export declare function isDatabaseDefinition(value: unknown): value is DatabaseDefinition;
|
|
1708
|
+
|
|
1709
|
+
/** One key value — a string or number; the array form (multiple keys, positional) resolves FIRST per AGENTS §9.2. */
|
|
1710
|
+
export declare const keyShape: UnionShape<[ ArrayShape<UnionShape<[ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1711
|
+
|
|
1712
|
+
/** Map one {@link import('./types.js').ColumnKind} to its primitive `@orkestrel/database` shape — the leaf {@link columnShape} wraps. */
|
|
1713
|
+
export declare function kindShape(kind: ColumnKind): ContractShape;
|
|
1714
|
+
|
|
1715
|
+
/** Which registered relation manager to address — omitted resolves to the sole registered manager. */
|
|
1716
|
+
export declare const managerShape: OptionalShape<StringShape>;
|
|
1717
|
+
|
|
804
1718
|
/**
|
|
805
1719
|
* The maximum nesting depth a workflow → agent → workflow chain may reach — the bound
|
|
806
1720
|
* {@link import('./factories.js').createAgentFunction} and
|
|
@@ -815,6 +1729,51 @@ export declare function isAgentToolError(value: unknown): value is AgentToolErro
|
|
|
815
1729
|
*/
|
|
816
1730
|
export declare const MAX_WORKFLOW_DEPTH = 8;
|
|
817
1731
|
|
|
1732
|
+
/**
|
|
1733
|
+
* The in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
|
|
1734
|
+
* {@link DatabaseDefinition}s keyed by database id, the DEFAULT store
|
|
1735
|
+
* {@link import('../factories.js').createMemoryDefinitionStore} builds. The EXACT twin of
|
|
1736
|
+
* {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore}.
|
|
1737
|
+
*
|
|
1738
|
+
* @remarks
|
|
1739
|
+
* A plain `Map<string, DatabaseDefinition>` (AGENTS §21 — the definition is already pure,
|
|
1740
|
+
* self-contained CONFIG-only JSON, so no encoding is needed for the memory tier). There is NO
|
|
1741
|
+
* idle-TTL and NO eviction: a persisted definition lives until an explicit `delete`. A durable
|
|
1742
|
+
* backend (JSON / SQLite / IndexedDB) swaps in through the SAME interface without touching a
|
|
1743
|
+
* consumer — its driver-pluggable twin is
|
|
1744
|
+
* {@link import('./DatabaseDefinitionStore.js').DatabaseDefinitionStore} (the definition as one
|
|
1745
|
+
* opaque JSON column).
|
|
1746
|
+
*
|
|
1747
|
+
* - **`get` resolves the persisted definition for an id**, or `undefined` if none is stored.
|
|
1748
|
+
* - **`set` inserts / replaces under the definition's OWN `id`** (no separate id param).
|
|
1749
|
+
* - **`delete` drops a definition by id**; an absent id is a no-op (no throw).
|
|
1750
|
+
*
|
|
1751
|
+
* The public surface is EXACTLY `get` / `set` / `delete` — no extra members (the §22 method
|
|
1752
|
+
* bijection with {@link DefinitionStoreInterface}).
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
* ```ts
|
|
1756
|
+
* import { createMemoryDefinitionStore } from '@src/core'
|
|
1757
|
+
*
|
|
1758
|
+
* const store = createMemoryDefinitionStore()
|
|
1759
|
+
* await store.set({ id: 'shop', driver: 'memory', tables: {} })
|
|
1760
|
+
* const definition = await store.get('shop')
|
|
1761
|
+
* await store.delete('shop')
|
|
1762
|
+
* ```
|
|
1763
|
+
*/
|
|
1764
|
+
export declare class MemoryDefinitionStore implements DefinitionStoreInterface {
|
|
1765
|
+
#private;
|
|
1766
|
+
get(id: string): Promise<DatabaseDefinition | undefined>;
|
|
1767
|
+
set(definition: DatabaseDefinition): Promise<void>;
|
|
1768
|
+
delete(id: string): Promise<void>;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/** One sort term. */
|
|
1772
|
+
export declare const orderShape: ObjectShape<{
|
|
1773
|
+
column: StringShape;
|
|
1774
|
+
direction: LiteralShape<readonly ["ascending", "descending"]>;
|
|
1775
|
+
}, false>;
|
|
1776
|
+
|
|
818
1777
|
/** A draft phase — a `PhaseDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name` and {@link TaskDraft} tasks. */
|
|
819
1778
|
export declare interface PhaseDraft {
|
|
820
1779
|
readonly id?: string;
|
|
@@ -842,10 +1801,10 @@ export declare const phaseDraftShape: ObjectShape<{
|
|
|
842
1801
|
run: OptionalShape<StringShape>;
|
|
843
1802
|
retries: OptionalShape<NumberShape>;
|
|
844
1803
|
timeout: OptionalShape<NumberShape>;
|
|
845
|
-
}>>;
|
|
1804
|
+
}, false>>;
|
|
846
1805
|
concurrency: OptionalShape<NumberShape>;
|
|
847
1806
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
848
|
-
}>;
|
|
1807
|
+
}, false>;
|
|
849
1808
|
|
|
850
1809
|
export declare const PROMPT_TOOL_DESCRIPTION: string;
|
|
851
1810
|
|
|
@@ -912,7 +1871,7 @@ export declare const promptToolShape: ObjectShape<{
|
|
|
912
1871
|
name: StringShape;
|
|
913
1872
|
value: StringShape;
|
|
914
1873
|
description: OptionalShape<StringShape>;
|
|
915
|
-
}>>>;
|
|
1874
|
+
}, boolean | ContractShape>>>;
|
|
916
1875
|
mask: OptionalShape<StringShape>;
|
|
917
1876
|
min: OptionalShape<NumberShape>;
|
|
918
1877
|
max: OptionalShape<NumberShape>;
|
|
@@ -926,9 +1885,160 @@ export declare const promptToolShape: ObjectShape<{
|
|
|
926
1885
|
numeric: OptionalShape<BooleanShape>;
|
|
927
1886
|
integer: OptionalShape<BooleanShape>;
|
|
928
1887
|
alphanumeric: OptionalShape<BooleanShape>;
|
|
929
|
-
}>>;
|
|
1888
|
+
}, boolean | ContractShape>>;
|
|
930
1889
|
timeout: OptionalShape<NumberShape>;
|
|
931
|
-
}>;
|
|
1890
|
+
}, false>;
|
|
1891
|
+
|
|
1892
|
+
/** The default cap on how many `include` path segments deep a `load` / `find` call may traverse — the relation tool's default include-depth ceiling. */
|
|
1893
|
+
export declare const RELATION_TOOL_DEPTH = 3;
|
|
1894
|
+
|
|
1895
|
+
/**
|
|
1896
|
+
* The DESCRIPTION the relation tool advertises — a multi-line guide that teaches a small model
|
|
1897
|
+
* the operation list and the flat dot-path `include` syntax.
|
|
1898
|
+
*
|
|
1899
|
+
* @remarks
|
|
1900
|
+
* An include path is a FLAT dot-separated string (`'contacts.account'`), never a nested object —
|
|
1901
|
+
* the same small-model ergonomic lever the other tools in this package use for flat args.
|
|
1902
|
+
*/
|
|
1903
|
+
export declare const RELATION_TOOL_DESCRIPTION: string;
|
|
1904
|
+
|
|
1905
|
+
/** The default cap on rows a `find` / `links` call returns when the caller omits `limit` — the relation tool's default row ceiling. */
|
|
1906
|
+
export declare const RELATION_TOOL_LIMIT = 1000;
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* The name `createRelationTool` advertises by default — the key a model calls and the
|
|
1910
|
+
* `ToolManagerInterface` (`@orkestrel/agent`) registers under.
|
|
1911
|
+
*/
|
|
1912
|
+
export declare const RELATION_TOOL_NAME = "relation";
|
|
1913
|
+
|
|
1914
|
+
/**
|
|
1915
|
+
* The lean {@link import('@orkestrel/agent').ToolInterface.summary} the relation tool advertises
|
|
1916
|
+
* in place of {@link RELATION_TOOL_DESCRIPTION}.
|
|
1917
|
+
*/
|
|
1918
|
+
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.";
|
|
1919
|
+
|
|
1920
|
+
/** One key value — a string or number; the array form (multiple keys, positional) resolves FIRST per AGENTS §9.2. */
|
|
1921
|
+
export declare const relationKeyShape: UnionShape<[ ArrayShape<UnionShape<[ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
1922
|
+
|
|
1923
|
+
/**
|
|
1924
|
+
* Resolve which registered {@link RelationManagerInterface} a relation-tool call addresses — the
|
|
1925
|
+
* pure manager-resolution leaf {@link import('./factories.js').createRelationTool} calls on
|
|
1926
|
+
* every operation.
|
|
1927
|
+
*
|
|
1928
|
+
* @remarks
|
|
1929
|
+
* An explicit `name` must match a key of `managers` (a miss throws a typed `TOOL`
|
|
1930
|
+
* {@link AgentToolError} naming the registered managers). An OMITTED `name` resolves to the sole
|
|
1931
|
+
* registered manager when exactly one is registered, else throws the same typed error.
|
|
1932
|
+
*
|
|
1933
|
+
* @param managers - The tool's registered `RelationManagerInterface` map
|
|
1934
|
+
* @param name - The call's optional `manager` field
|
|
1935
|
+
* @returns The resolved {@link RelationManagerInterface}
|
|
1936
|
+
*/
|
|
1937
|
+
export declare function relationManagerOf(managers: Readonly<Record<string, RelationManagerInterface>>, name: string | undefined): RelationManagerInterface;
|
|
1938
|
+
|
|
1939
|
+
/**
|
|
1940
|
+
* Resolve a `model` name against a live {@link RelationManagerInterface} — the pure model-lookup
|
|
1941
|
+
* leaf {@link import('./factories.js').createRelationTool} calls on every operation, mirroring
|
|
1942
|
+
* {@link relationManagerOf}'s guard shape.
|
|
1943
|
+
*
|
|
1944
|
+
* @param manager - The resolved {@link RelationManagerInterface}
|
|
1945
|
+
* @param name - The call's `model` field
|
|
1946
|
+
* @returns The model's {@link ModelInterface}
|
|
1947
|
+
*/
|
|
1948
|
+
export declare function relationModelOf(manager: RelationManagerInterface, name: string): ModelInterface;
|
|
1949
|
+
|
|
1950
|
+
/**
|
|
1951
|
+
* Map a caught error to the {@link AgentToolErrorCode} the upcoming relation tool should throw
|
|
1952
|
+
* with — the pure classification step of that factory's error handling, mirroring
|
|
1953
|
+
* {@link terminalToolCode}'s idiom for `@orkestrel/relation`.
|
|
1954
|
+
*
|
|
1955
|
+
* @param error - The value caught from a `@orkestrel/relation` operation
|
|
1956
|
+
* @returns The granular {@link RelationErrorCode}, or `undefined` if `error` is not a `RelationError`
|
|
1957
|
+
*/
|
|
1958
|
+
export declare function relationToolCode(error: unknown): RelationErrorCode | undefined;
|
|
1959
|
+
|
|
1960
|
+
/**
|
|
1961
|
+
* Options for {@link import('./factories.js').createRelationTool} — SRC-3 (the final unit) of
|
|
1962
|
+
* the 3-unit database / relation spine.
|
|
1963
|
+
*
|
|
1964
|
+
* @remarks
|
|
1965
|
+
* - `managers` — the live `RelationManagerInterface` (`@orkestrel/relation`) registry a call's
|
|
1966
|
+
* optional `manager` field addresses by name; REQUIRED (unlike the database tool's lazily
|
|
1967
|
+
* resolved handles, a relation manager's relations are declared up front and cannot be minted
|
|
1968
|
+
* on demand from a tool call). A call that omits `manager` resolves to the SOLE registered
|
|
1969
|
+
* manager when exactly one is registered, else throws a typed `TOOL`
|
|
1970
|
+
* {@link import('./errors.js').AgentToolError} naming the registered manager keys.
|
|
1971
|
+
* - `limit` — the row cap `'find'` / `'links'` enforce when a call's `limit` is omitted or
|
|
1972
|
+
* exceeds it. Defaults to {@link import('./constants.js').RELATION_TOOL_LIMIT}.
|
|
1973
|
+
* - `depth` — the max dot-path segment count `'load'` / `'find'`'s `include` paths may reach
|
|
1974
|
+
* ({@link import('./helpers.js').expandInclude}). Defaults to
|
|
1975
|
+
* {@link import('./constants.js').RELATION_TOOL_DEPTH}.
|
|
1976
|
+
* - `name` / `description` — advertised tool overrides; default to
|
|
1977
|
+
* {@link import('./constants.js').RELATION_TOOL_NAME} / {@link import('./constants.js').RELATION_TOOL_DESCRIPTION}.
|
|
1978
|
+
*/
|
|
1979
|
+
export declare interface RelationToolOptions {
|
|
1980
|
+
readonly name?: string;
|
|
1981
|
+
readonly description?: string;
|
|
1982
|
+
readonly managers: Readonly<Record<string, RelationManagerInterface>>;
|
|
1983
|
+
readonly limit?: number;
|
|
1984
|
+
readonly depth?: number;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
/**
|
|
1988
|
+
* The shape of {@link import('./factories.js').createRelationTool}'s call arguments —
|
|
1989
|
+
* discriminated by `operation` into the 5 relation operations (`'load'` / `'find'` / `'link'` /
|
|
1990
|
+
* `'unlink'` / `'links'`).
|
|
1991
|
+
*
|
|
1992
|
+
* @remarks
|
|
1993
|
+
* `'load'` fetches one or more rows (positional key/array) with `include` attached. `'find'`
|
|
1994
|
+
* fetches rows (pagination / sort only) with `include` attached. `'link'` / `'unlink'` write /
|
|
1995
|
+
* remove a `through` junction row; `'links'` lists a `through` relation's linked keys.
|
|
1996
|
+
*/
|
|
1997
|
+
export declare const relationToolShape: UnionShape<[ ObjectShape<{
|
|
1998
|
+
operation: LiteralShape<readonly ["load"]>;
|
|
1999
|
+
manager: OptionalShape<StringShape>;
|
|
2000
|
+
model: StringShape;
|
|
2001
|
+
key: UnionShape<[ ArrayShape<UnionShape<[ StringShape, NumberShape]>>, StringShape, NumberShape]>;
|
|
2002
|
+
include: OptionalShape<ArrayShape<StringShape>>;
|
|
2003
|
+
}, false>, ObjectShape<{
|
|
2004
|
+
operation: LiteralShape<readonly ["find"]>;
|
|
2005
|
+
manager: OptionalShape<StringShape>;
|
|
2006
|
+
model: StringShape;
|
|
2007
|
+
include: OptionalShape<ArrayShape<StringShape>>;
|
|
2008
|
+
limit: OptionalShape<NumberShape>;
|
|
2009
|
+
offset: OptionalShape<NumberShape>;
|
|
2010
|
+
sort: OptionalShape<StringShape>;
|
|
2011
|
+
direction: OptionalShape<LiteralShape<readonly ["ascending", "descending"]>>;
|
|
2012
|
+
}, false>, ObjectShape<{
|
|
2013
|
+
operation: LiteralShape<readonly ["link"]>;
|
|
2014
|
+
manager: OptionalShape<StringShape>;
|
|
2015
|
+
model: StringShape;
|
|
2016
|
+
key: UnionShape<[ StringShape, NumberShape]>;
|
|
2017
|
+
relation: StringShape;
|
|
2018
|
+
target: UnionShape<[ StringShape, NumberShape]>;
|
|
2019
|
+
}, false>, ObjectShape<{
|
|
2020
|
+
operation: LiteralShape<readonly ["unlink"]>;
|
|
2021
|
+
manager: OptionalShape<StringShape>;
|
|
2022
|
+
model: StringShape;
|
|
2023
|
+
key: UnionShape<[ StringShape, NumberShape]>;
|
|
2024
|
+
relation: StringShape;
|
|
2025
|
+
target: UnionShape<[ StringShape, NumberShape]>;
|
|
2026
|
+
}, false>, ObjectShape<{
|
|
2027
|
+
operation: LiteralShape<readonly ["links"]>;
|
|
2028
|
+
manager: OptionalShape<StringShape>;
|
|
2029
|
+
model: StringShape;
|
|
2030
|
+
key: UnionShape<[ StringShape, NumberShape]>;
|
|
2031
|
+
relation: StringShape;
|
|
2032
|
+
}, false>]>;
|
|
2033
|
+
|
|
2034
|
+
/** A loose row — a flat object of column name to JSON value; the array form (multiple rows) resolves FIRST per AGENTS §9.2. */
|
|
2035
|
+
export declare const rowShape: ObjectShape<Record<never, never>, JSONShape>;
|
|
2036
|
+
|
|
2037
|
+
/** One or many loose rows — the array form resolves FIRST per AGENTS §9.2. */
|
|
2038
|
+
export declare const rowsShape: UnionShape<[ ArrayShape<ObjectShape<Record<never, never>, JSONShape>>, ObjectShape<Record<never, never>, JSONShape>]>;
|
|
2039
|
+
|
|
2040
|
+
/** A single row key (not an array) — used by `'link'` / `'unlink'` / `'links'`, which address exactly one owning row. */
|
|
2041
|
+
export declare const singleKeyShape: UnionShape<[ StringShape, NumberShape]>;
|
|
932
2042
|
|
|
933
2043
|
/**
|
|
934
2044
|
* The shape of ONE flat step — `{ name }` — the building block of {@link workflowStepsShape}.
|
|
@@ -939,7 +2049,39 @@ export declare const promptToolShape: ObjectShape<{
|
|
|
939
2049
|
*/
|
|
940
2050
|
export declare const stepShape: ObjectShape<{
|
|
941
2051
|
name: StringShape;
|
|
942
|
-
}>;
|
|
2052
|
+
}, false>;
|
|
2053
|
+
|
|
2054
|
+
/**
|
|
2055
|
+
* Build one {@link TableSchema} from a table NAME and its `@orkestrel/database` `TableExport` —
|
|
2056
|
+
* the "deployed" schema shape `DatabaseInterface.migrate` diffs against, derived from a LIVE
|
|
2057
|
+
* handle's `export()` rather than a re-declared {@link TableSpec}, so it works for ANY handle
|
|
2058
|
+
* (config-tracked or caller-supplied).
|
|
2059
|
+
*
|
|
2060
|
+
* @param name - The table name
|
|
2061
|
+
* @param table - The table's `TableExport` (`{ key, columns }`, `@orkestrel/database`)
|
|
2062
|
+
* @returns The equivalent {@link TableSchema} (`indexes` empty — this package declares none)
|
|
2063
|
+
*/
|
|
2064
|
+
export declare function tableSchema(name: string, table: Readonly<{
|
|
2065
|
+
key: string;
|
|
2066
|
+
columns: Readonly<Record<string, ContractShape>>;
|
|
2067
|
+
}>): TableSchema;
|
|
2068
|
+
|
|
2069
|
+
/**
|
|
2070
|
+
* A database's table layout — one entry per table, each a flat map of column name to
|
|
2071
|
+
* {@link ColumnSpec}. The small-model-facing DSL {@link import('./helpers.js').expandTables}
|
|
2072
|
+
* compiles into an `@orkestrel/database` `TablesShape`.
|
|
2073
|
+
*/
|
|
2074
|
+
export declare type TableSpec = Readonly<Record<string, Readonly<{
|
|
2075
|
+
columns: Readonly<Record<string, ColumnSpec>>;
|
|
2076
|
+
}>>>;
|
|
2077
|
+
|
|
2078
|
+
/** A {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
|
|
2079
|
+
export declare const tableSpecShape: ObjectShape<Record<never, never>, ObjectShape<{
|
|
2080
|
+
columns: ObjectShape<Record<never, never>, UnionShape<[ LiteralShape<readonly ["string", "integer", "number", "boolean"]>, ObjectShape<{
|
|
2081
|
+
type: LiteralShape<readonly ["string", "integer", "number", "boolean"]>;
|
|
2082
|
+
optional: OptionalShape<BooleanShape>;
|
|
2083
|
+
}, false>]>>;
|
|
2084
|
+
}, false>>;
|
|
943
2085
|
|
|
944
2086
|
/**
|
|
945
2087
|
* A draft task — a `TaskDefinition` (`@orkestrel/workflow`) with OPTIONAL `id` / `name`.
|
|
@@ -972,7 +2114,7 @@ export declare const taskDraftShape: ObjectShape<{
|
|
|
972
2114
|
run: OptionalShape<StringShape>;
|
|
973
2115
|
retries: OptionalShape<NumberShape>;
|
|
974
2116
|
timeout: OptionalShape<NumberShape>;
|
|
975
|
-
}>;
|
|
2117
|
+
}, false>;
|
|
976
2118
|
|
|
977
2119
|
/**
|
|
978
2120
|
* Map a caught error to the {@link AgentToolErrorCode} the terminal-tool factory should throw
|
|
@@ -1086,12 +2228,12 @@ export declare const workflowDraftShape: ObjectShape<{
|
|
|
1086
2228
|
run: OptionalShape<StringShape>;
|
|
1087
2229
|
retries: OptionalShape<NumberShape>;
|
|
1088
2230
|
timeout: OptionalShape<NumberShape>;
|
|
1089
|
-
}>>;
|
|
2231
|
+
}, false>>;
|
|
1090
2232
|
concurrency: OptionalShape<NumberShape>;
|
|
1091
2233
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
1092
|
-
}>>;
|
|
2234
|
+
}, false>>;
|
|
1093
2235
|
bail: OptionalShape<LiteralShape<readonly [true, false]>>;
|
|
1094
|
-
}>;
|
|
2236
|
+
}, false>;
|
|
1095
2237
|
|
|
1096
2238
|
/**
|
|
1097
2239
|
* One flat step — `{ name }` — the building block of a {@link WorkflowSteps} blob.
|
|
@@ -1136,8 +2278,8 @@ export declare const workflowStepsShape: ObjectShape<{
|
|
|
1136
2278
|
name: OptionalShape<StringShape>;
|
|
1137
2279
|
steps: ArrayShape<ObjectShape<{
|
|
1138
2280
|
name: StringShape;
|
|
1139
|
-
}>>;
|
|
1140
|
-
}>;
|
|
2281
|
+
}, false>>;
|
|
2282
|
+
}, false>;
|
|
1141
2283
|
|
|
1142
2284
|
/**
|
|
1143
2285
|
* The ancestry identifier of a workflow in a run chain — `workflow:<id>`.
|
|
@@ -1392,29 +2534,29 @@ export declare interface WorkspaceToolOptions {
|
|
|
1392
2534
|
export declare const workspaceToolShape: UnionShape<[ ObjectShape<{
|
|
1393
2535
|
operation: LiteralShape<readonly ["read"]>;
|
|
1394
2536
|
path: StringShape;
|
|
1395
|
-
}>, ObjectShape<{
|
|
2537
|
+
}, false>, ObjectShape<{
|
|
1396
2538
|
operation: LiteralShape<readonly ["list"]>;
|
|
1397
|
-
}>, ObjectShape<{
|
|
2539
|
+
}, false>, ObjectShape<{
|
|
1398
2540
|
operation: LiteralShape<readonly ["has"]>;
|
|
1399
2541
|
path: StringShape;
|
|
1400
|
-
}>, ObjectShape<{
|
|
2542
|
+
}, false>, ObjectShape<{
|
|
1401
2543
|
operation: LiteralShape<readonly ["search"]>;
|
|
1402
2544
|
query: StringShape;
|
|
1403
2545
|
regex: OptionalShape<BooleanShape>;
|
|
1404
2546
|
exact: OptionalShape<BooleanShape>;
|
|
1405
2547
|
limit: OptionalShape<NumberShape>;
|
|
1406
|
-
}>, ObjectShape<{
|
|
2548
|
+
}, false>, ObjectShape<{
|
|
1407
2549
|
operation: LiteralShape<readonly ["replace"]>;
|
|
1408
2550
|
query: StringShape;
|
|
1409
2551
|
replacement: StringShape;
|
|
1410
2552
|
regex: OptionalShape<BooleanShape>;
|
|
1411
2553
|
exact: OptionalShape<BooleanShape>;
|
|
1412
2554
|
limit: OptionalShape<NumberShape>;
|
|
1413
|
-
}>, ObjectShape<{
|
|
2555
|
+
}, false>, ObjectShape<{
|
|
1414
2556
|
operation: LiteralShape<readonly ["write"]>;
|
|
1415
2557
|
path: StringShape;
|
|
1416
2558
|
content: StringShape;
|
|
1417
|
-
}>, ObjectShape<{
|
|
2559
|
+
}, false>, ObjectShape<{
|
|
1418
2560
|
operation: LiteralShape<readonly ["splice"]>;
|
|
1419
2561
|
path: StringShape;
|
|
1420
2562
|
content: StringShape;
|
|
@@ -1422,26 +2564,26 @@ export declare const workspaceToolShape: UnionShape<[ ObjectShape<{
|
|
|
1422
2564
|
fromColumn: NumberShape;
|
|
1423
2565
|
toLine: NumberShape;
|
|
1424
2566
|
toColumn: NumberShape;
|
|
1425
|
-
}>, ObjectShape<{
|
|
2567
|
+
}, false>, ObjectShape<{
|
|
1426
2568
|
operation: LiteralShape<readonly ["prepend"]>;
|
|
1427
2569
|
path: StringShape;
|
|
1428
2570
|
content: StringShape;
|
|
1429
|
-
}>, ObjectShape<{
|
|
2571
|
+
}, false>, ObjectShape<{
|
|
1430
2572
|
operation: LiteralShape<readonly ["append"]>;
|
|
1431
2573
|
path: StringShape;
|
|
1432
2574
|
content: StringShape;
|
|
1433
|
-
}>, ObjectShape<{
|
|
2575
|
+
}, false>, ObjectShape<{
|
|
1434
2576
|
operation: LiteralShape<readonly ["move"]>;
|
|
1435
2577
|
from: StringShape;
|
|
1436
2578
|
to: StringShape;
|
|
1437
|
-
}>, ObjectShape<{
|
|
2579
|
+
}, false>, ObjectShape<{
|
|
1438
2580
|
operation: LiteralShape<readonly ["remove"]>;
|
|
1439
2581
|
path: StringShape;
|
|
1440
|
-
}>, ObjectShape<{
|
|
2582
|
+
}, false>, ObjectShape<{
|
|
1441
2583
|
operation: LiteralShape<readonly ["workspaces"]>;
|
|
1442
|
-
}>, ObjectShape<{
|
|
2584
|
+
}, false>, ObjectShape<{
|
|
1443
2585
|
operation: LiteralShape<readonly ["switch"]>;
|
|
1444
2586
|
id: StringShape;
|
|
1445
|
-
}>]>;
|
|
2587
|
+
}, false>]>;
|
|
1446
2588
|
|
|
1447
2589
|
export { }
|