@orkestrel/toolbox 0.0.21 → 0.0.22
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/dist/src/core/index.cjs +61 -52
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +28 -9
- package/dist/src/core/index.d.ts +28 -9
- package/dist/src/core/index.js +62 -54
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +14 -15
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +14 -15
- package/dist/src/server/index.js.map +1 -1
- package/package.json +18 -18
|
@@ -13,6 +13,7 @@ import type { DriverInterface } from '@orkestrel/database';
|
|
|
13
13
|
import type { Guard } from '@orkestrel/contract';
|
|
14
14
|
import type { Include } from '@orkestrel/relation';
|
|
15
15
|
import type { IndexMap } from '@orkestrel/database';
|
|
16
|
+
import type { JSONRecord } from '@orkestrel/contract';
|
|
16
17
|
import { JSONShape } from '@orkestrel/contract';
|
|
17
18
|
import type { KeyFunction } from '@orkestrel/database';
|
|
18
19
|
import type { LifecycleStatus } from '@orkestrel/workflow';
|
|
@@ -306,8 +307,8 @@ export declare const columnPrimitiveShape: LiteralShape<readonly ["string", "int
|
|
|
306
307
|
* `{ primitive, optional }` when the column may be absent from a row.
|
|
307
308
|
*/
|
|
308
309
|
export declare type ColumnSpec = ColumnPrimitive | Readonly<{
|
|
309
|
-
primitive: ColumnPrimitive;
|
|
310
|
-
optional?: boolean;
|
|
310
|
+
readonly primitive: ColumnPrimitive;
|
|
311
|
+
readonly optional?: boolean;
|
|
311
312
|
}>;
|
|
312
313
|
|
|
313
314
|
/** Describes a {@link import('./types.js').ColumnSpec} — a bare {@link columnPrimitiveShape}, or `{ primitive, optional }`. */
|
|
@@ -1232,14 +1233,14 @@ export declare class DatabaseDefinitionStore implements DefinitionStoreInterface
|
|
|
1232
1233
|
*/
|
|
1233
1234
|
export declare interface DatabaseQueryInput {
|
|
1234
1235
|
readonly conditions?: ReadonlyArray<Readonly<{
|
|
1235
|
-
column: string;
|
|
1236
|
-
operator: Condition['operator'];
|
|
1237
|
-
values: readonly unknown[];
|
|
1238
|
-
connector?: ConditionConnector;
|
|
1236
|
+
readonly column: string;
|
|
1237
|
+
readonly operator: Condition['operator'];
|
|
1238
|
+
readonly values: readonly unknown[];
|
|
1239
|
+
readonly connector?: ConditionConnector;
|
|
1239
1240
|
}>>;
|
|
1240
1241
|
readonly order?: ReadonlyArray<Readonly<{
|
|
1241
|
-
column: string;
|
|
1242
|
-
direction: OrderDirection;
|
|
1242
|
+
readonly column: string;
|
|
1243
|
+
readonly direction: OrderDirection;
|
|
1243
1244
|
}>>;
|
|
1244
1245
|
readonly limit?: number;
|
|
1245
1246
|
readonly offset?: number;
|
|
@@ -1826,6 +1827,10 @@ export declare function isDatabaseDefinition(value: unknown): value is DatabaseD
|
|
|
1826
1827
|
/**
|
|
1827
1828
|
* Narrows an unknown caught value to a {@link ToolboxError}.
|
|
1828
1829
|
*
|
|
1830
|
+
* @remarks
|
|
1831
|
+
* Recognizes the self-brand across package copies and subclasses without requiring a name.
|
|
1832
|
+
* Rejects transparent proxies and validates the code and optional context.
|
|
1833
|
+
*
|
|
1829
1834
|
* @param value - The value to test (typically a `catch` binding)
|
|
1830
1835
|
* @returns True if `value` is an {@link ToolboxError}; false otherwise
|
|
1831
1836
|
*
|
|
@@ -2243,6 +2248,20 @@ export declare function resolveRelationManager(managers: Readonly<Record<string,
|
|
|
2243
2248
|
*/
|
|
2244
2249
|
export declare function resolveRelationModel(manager: RelationManagerInterface, name: string): ModelInterface;
|
|
2245
2250
|
|
|
2251
|
+
/**
|
|
2252
|
+
* Resolves an owned workflow input through the supplied flat or draft contracts.
|
|
2253
|
+
* @example
|
|
2254
|
+
* ```ts
|
|
2255
|
+
* import { createContract } from '@orkestrel/contract'
|
|
2256
|
+
* import { completeDraft, createWorkflowDraftContract, resolveWorkflowTarget, workflowStepsShape } from '@src/core'
|
|
2257
|
+
*
|
|
2258
|
+
* const definition = completeDraft({ phases: [{ tasks: [{}] }] })
|
|
2259
|
+
* const steps: import('@orkestrel/contract').ContractInterface<import('./types.js').WorkflowSteps> = createContract(workflowStepsShape)
|
|
2260
|
+
* resolveWorkflowTarget({}, definition, steps, createWorkflowDraftContract()) // definition
|
|
2261
|
+
* ```
|
|
2262
|
+
*/
|
|
2263
|
+
export declare function resolveWorkflowTarget(owned: JSONRecord, definition: WorkflowDefinition, steps: ContractInterface<WorkflowSteps>, draft: ContractInterface<WorkflowDraft>): WorkflowDefinition | undefined;
|
|
2264
|
+
|
|
2246
2265
|
/** Describes a loose row — a flat object of column name to JSON value. */
|
|
2247
2266
|
export declare const rowShape: ObjectShape<Record<never, never>, JSONShape>;
|
|
2248
2267
|
|
|
@@ -2288,7 +2307,7 @@ export declare function summarizeWorkflow(result: WorkflowResult): WorkflowToolR
|
|
|
2288
2307
|
* compiles into an `@orkestrel/database` `TableMap`.
|
|
2289
2308
|
*/
|
|
2290
2309
|
export declare type TableSpec = Readonly<Record<string, Readonly<{
|
|
2291
|
-
columns: Readonly<Record<string, ColumnSpec>>;
|
|
2310
|
+
readonly columns: Readonly<Record<string, ColumnSpec>>;
|
|
2292
2311
|
}>>>;
|
|
2293
2312
|
|
|
2294
2313
|
/** Describes a {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { DriverInterface } from '@orkestrel/database';
|
|
|
13
13
|
import type { Guard } from '@orkestrel/contract';
|
|
14
14
|
import type { Include } from '@orkestrel/relation';
|
|
15
15
|
import type { IndexMap } from '@orkestrel/database';
|
|
16
|
+
import type { JSONRecord } from '@orkestrel/contract';
|
|
16
17
|
import { JSONShape } from '@orkestrel/contract';
|
|
17
18
|
import type { KeyFunction } from '@orkestrel/database';
|
|
18
19
|
import type { LifecycleStatus } from '@orkestrel/workflow';
|
|
@@ -306,8 +307,8 @@ export declare const columnPrimitiveShape: LiteralShape<readonly ["string", "int
|
|
|
306
307
|
* `{ primitive, optional }` when the column may be absent from a row.
|
|
307
308
|
*/
|
|
308
309
|
export declare type ColumnSpec = ColumnPrimitive | Readonly<{
|
|
309
|
-
primitive: ColumnPrimitive;
|
|
310
|
-
optional?: boolean;
|
|
310
|
+
readonly primitive: ColumnPrimitive;
|
|
311
|
+
readonly optional?: boolean;
|
|
311
312
|
}>;
|
|
312
313
|
|
|
313
314
|
/** Describes a {@link import('./types.js').ColumnSpec} — a bare {@link columnPrimitiveShape}, or `{ primitive, optional }`. */
|
|
@@ -1232,14 +1233,14 @@ export declare class DatabaseDefinitionStore implements DefinitionStoreInterface
|
|
|
1232
1233
|
*/
|
|
1233
1234
|
export declare interface DatabaseQueryInput {
|
|
1234
1235
|
readonly conditions?: ReadonlyArray<Readonly<{
|
|
1235
|
-
column: string;
|
|
1236
|
-
operator: Condition['operator'];
|
|
1237
|
-
values: readonly unknown[];
|
|
1238
|
-
connector?: ConditionConnector;
|
|
1236
|
+
readonly column: string;
|
|
1237
|
+
readonly operator: Condition['operator'];
|
|
1238
|
+
readonly values: readonly unknown[];
|
|
1239
|
+
readonly connector?: ConditionConnector;
|
|
1239
1240
|
}>>;
|
|
1240
1241
|
readonly order?: ReadonlyArray<Readonly<{
|
|
1241
|
-
column: string;
|
|
1242
|
-
direction: OrderDirection;
|
|
1242
|
+
readonly column: string;
|
|
1243
|
+
readonly direction: OrderDirection;
|
|
1243
1244
|
}>>;
|
|
1244
1245
|
readonly limit?: number;
|
|
1245
1246
|
readonly offset?: number;
|
|
@@ -1826,6 +1827,10 @@ export declare function isDatabaseDefinition(value: unknown): value is DatabaseD
|
|
|
1826
1827
|
/**
|
|
1827
1828
|
* Narrows an unknown caught value to a {@link ToolboxError}.
|
|
1828
1829
|
*
|
|
1830
|
+
* @remarks
|
|
1831
|
+
* Recognizes the self-brand across package copies and subclasses without requiring a name.
|
|
1832
|
+
* Rejects transparent proxies and validates the code and optional context.
|
|
1833
|
+
*
|
|
1829
1834
|
* @param value - The value to test (typically a `catch` binding)
|
|
1830
1835
|
* @returns True if `value` is an {@link ToolboxError}; false otherwise
|
|
1831
1836
|
*
|
|
@@ -2243,6 +2248,20 @@ export declare function resolveRelationManager(managers: Readonly<Record<string,
|
|
|
2243
2248
|
*/
|
|
2244
2249
|
export declare function resolveRelationModel(manager: RelationManagerInterface, name: string): ModelInterface;
|
|
2245
2250
|
|
|
2251
|
+
/**
|
|
2252
|
+
* Resolves an owned workflow input through the supplied flat or draft contracts.
|
|
2253
|
+
* @example
|
|
2254
|
+
* ```ts
|
|
2255
|
+
* import { createContract } from '@orkestrel/contract'
|
|
2256
|
+
* import { completeDraft, createWorkflowDraftContract, resolveWorkflowTarget, workflowStepsShape } from '@src/core'
|
|
2257
|
+
*
|
|
2258
|
+
* const definition = completeDraft({ phases: [{ tasks: [{}] }] })
|
|
2259
|
+
* const steps: import('@orkestrel/contract').ContractInterface<import('./types.js').WorkflowSteps> = createContract(workflowStepsShape)
|
|
2260
|
+
* resolveWorkflowTarget({}, definition, steps, createWorkflowDraftContract()) // definition
|
|
2261
|
+
* ```
|
|
2262
|
+
*/
|
|
2263
|
+
export declare function resolveWorkflowTarget(owned: JSONRecord, definition: WorkflowDefinition, steps: ContractInterface<WorkflowSteps>, draft: ContractInterface<WorkflowDraft>): WorkflowDefinition | undefined;
|
|
2264
|
+
|
|
2246
2265
|
/** Describes a loose row — a flat object of column name to JSON value. */
|
|
2247
2266
|
export declare const rowShape: ObjectShape<Record<never, never>, JSONShape>;
|
|
2248
2267
|
|
|
@@ -2288,7 +2307,7 @@ export declare function summarizeWorkflow(result: WorkflowResult): WorkflowToolR
|
|
|
2288
2307
|
* compiles into an `@orkestrel/database` `TableMap`.
|
|
2289
2308
|
*/
|
|
2290
2309
|
export declare type TableSpec = Readonly<Record<string, Readonly<{
|
|
2291
|
-
columns: Readonly<Record<string, ColumnSpec>>;
|
|
2310
|
+
readonly columns: Readonly<Record<string, ColumnSpec>>;
|
|
2292
2311
|
}>>>;
|
|
2293
2312
|
|
|
2294
2313
|
/** Describes a {@link import('./types.js').TableSpec} — table name to `{ columns }`, each column a {@link columnSpecShape}. */
|
package/dist/src/core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { arrayShape, attempt, booleanShape, cloneJSONRecord, createContract, integerShape, isArray, isBoolean, isError, isFiniteNumber, isFunction,
|
|
1
|
+
import { INTRINSICS, arrayShape, attempt, booleanShape, cloneJSONRecord, createContract, holds, integerShape, isArray, isBoolean, isError, isFiniteNumber, isFunction, isNonEmptyString, isNumber, isObject, isRecord, isString, jsonShape, literalOf, literalShape, numberShape, objectShape, optionalShape, parseJSONValue, rawShape, recordShape, samplesToSchema, schemaToObject, schemaToParameters, schemaToShape, stringShape, unionShape } from "@orkestrel/contract";
|
|
2
2
|
import { MAX_TIMER_MS, createWorkflowContract } from "@orkestrel/workflow";
|
|
3
3
|
import { isTerminalError } from "@orkestrel/terminal";
|
|
4
4
|
import { createDatabase, createMemoryDriver, isDatabaseError } from "@orkestrel/database";
|
|
@@ -7,7 +7,7 @@ import { agentResultToJSON } from "@orkestrel/agent";
|
|
|
7
7
|
import { createWorkspaceManager, isText, rangeOf } from "@orkestrel/workspace";
|
|
8
8
|
import { createTool } from "@orkestrel/tool";
|
|
9
9
|
import { createForm, isFormError, isFormValues, parseForm } from "@orkestrel/form";
|
|
10
|
-
|
|
10
|
+
// src/core/constants.ts
|
|
11
11
|
/**
|
|
12
12
|
* Holds the name {@link import('./factories.js').createAgentTool} advertises by default, `'agent'`
|
|
13
13
|
* — the key a model calls and the `ToolManagerInterface` (`@orkestrel/tool`) registers under.
|
|
@@ -580,8 +580,7 @@ var INFER_TOOL_DESCRIPTION = [
|
|
|
580
580
|
]
|
|
581
581
|
})}`
|
|
582
582
|
].join("\n");
|
|
583
|
-
|
|
584
|
-
//#region src/core/errors.ts
|
|
583
|
+
// src/core/errors.ts
|
|
585
584
|
/**
|
|
586
585
|
* Represents a package-owned tool-call failure: malformed input or unresolved configuration (`TOOL`),
|
|
587
586
|
* delegation depth/cycle rejection (`DEPTH`), prompt failure (`DEADLOCK` / `EXPIRE` / `ANSWER`),
|
|
@@ -609,6 +608,7 @@ var ToolboxError = class extends Error {
|
|
|
609
608
|
code;
|
|
610
609
|
constructor(code, message, context) {
|
|
611
610
|
super(message);
|
|
611
|
+
INTRINSICS.define(this, Symbol.for("@orkestrel/toolbox.ToolboxError"), { value: this });
|
|
612
612
|
this.name = "ToolboxError";
|
|
613
613
|
this.code = code;
|
|
614
614
|
if (context !== void 0) this.context = context;
|
|
@@ -617,6 +617,10 @@ var ToolboxError = class extends Error {
|
|
|
617
617
|
/**
|
|
618
618
|
* Narrows an unknown caught value to a {@link ToolboxError}.
|
|
619
619
|
*
|
|
620
|
+
* @remarks
|
|
621
|
+
* Recognizes the self-brand across package copies and subclasses without requiring a name.
|
|
622
|
+
* Rejects transparent proxies and validates the code and optional context.
|
|
623
|
+
*
|
|
620
624
|
* @param value - The value to test (typically a `catch` binding)
|
|
621
625
|
* @returns True if `value` is an {@link ToolboxError}; false otherwise
|
|
622
626
|
*
|
|
@@ -632,10 +636,14 @@ var ToolboxError = class extends Error {
|
|
|
632
636
|
* ```
|
|
633
637
|
*/
|
|
634
638
|
function isToolboxError(value) {
|
|
635
|
-
return
|
|
639
|
+
return holds(() => {
|
|
640
|
+
if (!(value instanceof Error && INTRINSICS.prototype(value) !== Error.prototype && INTRINSICS.describe(value, Symbol.for("@orkestrel/toolbox.ToolboxError"))?.value === value)) return false;
|
|
641
|
+
const code = INTRINSICS.reflect.read(value, "code");
|
|
642
|
+
const context = INTRINSICS.reflect.read(value, "context");
|
|
643
|
+
return (code === "TOOL" || code === "DEPTH" || code === "DEADLOCK" || code === "EXPIRE" || code === "ANSWER" || code === "DATABASE" || code === "RELATION") && (context === void 0 || isObject(context) || isFunction(context));
|
|
644
|
+
});
|
|
636
645
|
}
|
|
637
|
-
|
|
638
|
-
//#region src/core/validators.ts
|
|
646
|
+
// src/core/validators.ts
|
|
639
647
|
/**
|
|
640
648
|
* Narrows an unknown value to a valid alternating workflow lineage.
|
|
641
649
|
*
|
|
@@ -725,8 +733,7 @@ function isDatabaseDefinition(value) {
|
|
|
725
733
|
if (value.version !== void 0 && !isFiniteNumber(value.version)) return false;
|
|
726
734
|
return true;
|
|
727
735
|
}
|
|
728
|
-
|
|
729
|
-
//#region src/core/shapers.ts
|
|
736
|
+
// src/core/shapers.ts
|
|
730
737
|
/**
|
|
731
738
|
* Describes the shape of {@link import('./factories.js').createPromptTool}'s call arguments — `to` names the
|
|
732
739
|
* terminal identity and `schema` carries the complete multi-field form document.
|
|
@@ -1308,8 +1315,7 @@ var inferToolShape = objectShape({
|
|
|
1308
1315
|
enum: optionalShape(booleanShape({ description: "Infer enum constraints from repeated literal values. Defaults to false." })),
|
|
1309
1316
|
candidates: optionalShape(arrayShape(jsonShape(), { description: "Optional values to check against the freshly inferred schema. When present, the tool returns a per-candidate verdict (strict — no coercion) alongside the inferred parameters." }))
|
|
1310
1317
|
});
|
|
1311
|
-
|
|
1312
|
-
//#region src/core/helpers.ts
|
|
1318
|
+
// src/core/helpers.ts
|
|
1313
1319
|
/**
|
|
1314
1320
|
* Returns the ancestry identifier of a workflow in a run chain — `workflow:<id>`.
|
|
1315
1321
|
*
|
|
@@ -1555,51 +1561,46 @@ function inferRelationCode(error) {
|
|
|
1555
1561
|
* ```
|
|
1556
1562
|
*/
|
|
1557
1563
|
function expandInclude(paths, depth) {
|
|
1558
|
-
|
|
1559
|
-
for (const path of paths ?? []) {
|
|
1564
|
+
return Iterator.from(paths ?? []).reduce((include, path) => {
|
|
1560
1565
|
const segments = path.split(".");
|
|
1561
1566
|
if (segments.length > depth || segments.some((segment) => segment.length === 0)) throw new ToolboxError("TOOL", `malformed include path '${path}'`, {
|
|
1562
1567
|
path,
|
|
1563
1568
|
depth
|
|
1564
1569
|
});
|
|
1565
|
-
const ancestors = [];
|
|
1566
|
-
let branch = include;
|
|
1570
|
+
const ancestors = [include];
|
|
1567
1571
|
const last = segments.length - 1;
|
|
1568
|
-
for (
|
|
1569
|
-
|
|
1570
|
-
|
|
1572
|
+
for (const [index, segment] of segments.entries()) {
|
|
1573
|
+
if (index === last) break;
|
|
1574
|
+
const branch = ancestors.at(-1);
|
|
1575
|
+
if (branch === void 0) throw new ToolboxError("TOOL", `malformed include path '${path}'`, {
|
|
1571
1576
|
path,
|
|
1572
1577
|
depth
|
|
1573
1578
|
});
|
|
1574
|
-
ancestors.push(branch);
|
|
1575
1579
|
const existing = branch[segment];
|
|
1576
|
-
|
|
1580
|
+
ancestors.push(isObject(existing) ? existing : {});
|
|
1577
1581
|
}
|
|
1578
1582
|
const leaf = segments[last];
|
|
1579
|
-
|
|
1583
|
+
const branch = ancestors.at(-1);
|
|
1584
|
+
if (leaf === void 0 || branch === void 0) throw new ToolboxError("TOOL", `malformed include path '${path}'`, {
|
|
1580
1585
|
path,
|
|
1581
1586
|
depth
|
|
1582
1587
|
});
|
|
1583
1588
|
const existing = branch[leaf];
|
|
1584
|
-
|
|
1585
|
-
...branch,
|
|
1586
|
-
[leaf]: existing === void 0 ? true : existing
|
|
1587
|
-
};
|
|
1588
|
-
for (let index = last - 1; index >= 0; index--) {
|
|
1589
|
-
const ancestor = ancestors[index];
|
|
1589
|
+
return ancestors.slice(0, -1).reduceRight((merged, ancestor, index) => {
|
|
1590
1590
|
const segment = segments[index];
|
|
1591
|
-
if (
|
|
1591
|
+
if (segment === void 0) throw new ToolboxError("TOOL", `malformed include path '${path}'`, {
|
|
1592
1592
|
path,
|
|
1593
1593
|
depth
|
|
1594
1594
|
});
|
|
1595
|
-
|
|
1595
|
+
return {
|
|
1596
1596
|
...ancestor,
|
|
1597
1597
|
[segment]: merged
|
|
1598
1598
|
};
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1599
|
+
}, {
|
|
1600
|
+
...branch,
|
|
1601
|
+
[leaf]: existing === void 0 ? true : existing
|
|
1602
|
+
});
|
|
1603
|
+
}, {});
|
|
1603
1604
|
}
|
|
1604
1605
|
/**
|
|
1605
1606
|
* Resolves which registered {@link RelationManagerInterface} a relation-tool call addresses — the
|
|
@@ -1735,8 +1736,28 @@ function clampQuery(query, cap) {
|
|
|
1735
1736
|
limit
|
|
1736
1737
|
};
|
|
1737
1738
|
}
|
|
1738
|
-
|
|
1739
|
-
|
|
1739
|
+
/**
|
|
1740
|
+
* Resolves an owned workflow input through the supplied flat or draft contracts.
|
|
1741
|
+
* @example
|
|
1742
|
+
* ```ts
|
|
1743
|
+
* import { createContract } from '@orkestrel/contract'
|
|
1744
|
+
* import { completeDraft, createWorkflowDraftContract, resolveWorkflowTarget, workflowStepsShape } from '@src/core'
|
|
1745
|
+
*
|
|
1746
|
+
* const definition = completeDraft({ phases: [{ tasks: [{}] }] })
|
|
1747
|
+
* const steps: import('@orkestrel/contract').ContractInterface<import('./types.js').WorkflowSteps> = createContract(workflowStepsShape)
|
|
1748
|
+
* resolveWorkflowTarget({}, definition, steps, createWorkflowDraftContract()) // definition
|
|
1749
|
+
* ```
|
|
1750
|
+
*/
|
|
1751
|
+
function resolveWorkflowTarget(owned, definition, steps, draft) {
|
|
1752
|
+
if (Object.keys(owned).length === 0) return definition;
|
|
1753
|
+
if (isArray(owned.steps)) {
|
|
1754
|
+
const flat = steps.parse(owned);
|
|
1755
|
+
return flat === void 0 ? void 0 : expandSteps(flat);
|
|
1756
|
+
}
|
|
1757
|
+
const parsed = draft.parse(owned);
|
|
1758
|
+
return parsed === void 0 ? void 0 : completeDraft(parsed);
|
|
1759
|
+
}
|
|
1760
|
+
// src/core/compilers.ts
|
|
1740
1761
|
/**
|
|
1741
1762
|
* Compiles a {@link TableSpec} into the `@orkestrel/database` {@link TableMap} it configures —
|
|
1742
1763
|
* each {@link ColumnSpec} maps to the matching primitive shaper (`'string'` → `stringShape()`,
|
|
@@ -1781,8 +1802,7 @@ function compileColumnPrimitive(primitive) {
|
|
|
1781
1802
|
if (primitive === "number") return numberShape();
|
|
1782
1803
|
return booleanShape();
|
|
1783
1804
|
}
|
|
1784
|
-
|
|
1785
|
-
//#region src/core/stores/MemoryDefinitionStore.ts
|
|
1805
|
+
// src/core/stores/MemoryDefinitionStore.ts
|
|
1786
1806
|
/**
|
|
1787
1807
|
* Represents the in-memory {@link DefinitionStoreInterface} — a process-lifetime `Map` of
|
|
1788
1808
|
* {@link DatabaseDefinition}s keyed by database id, the default store
|
|
@@ -1852,8 +1872,7 @@ var MemoryDefinitionStore = class {
|
|
|
1852
1872
|
return Promise.resolve();
|
|
1853
1873
|
}
|
|
1854
1874
|
};
|
|
1855
|
-
|
|
1856
|
-
//#region src/core/stores/DatabaseDefinitionStore.ts
|
|
1875
|
+
// src/core/stores/DatabaseDefinitionStore.ts
|
|
1857
1876
|
/**
|
|
1858
1877
|
* Represents a {@link DefinitionStoreInterface} backed by one table of the `@orkestrel/database` layer — a
|
|
1859
1878
|
* database's durable config state is a row, so persistence reduces to keyed point-access
|
|
@@ -1941,8 +1960,7 @@ var DatabaseDefinitionStore = class {
|
|
|
1941
1960
|
await this.#table.remove(id);
|
|
1942
1961
|
}
|
|
1943
1962
|
};
|
|
1944
|
-
|
|
1945
|
-
//#region src/core/databases/DatabaseResolver.ts
|
|
1963
|
+
// src/core/databases/DatabaseResolver.ts
|
|
1946
1964
|
/**
|
|
1947
1965
|
* Resolves a database definition into a cached live handle for a database tool, over the tool's
|
|
1948
1966
|
* live handles, its stored definitions, its driver registry, and an optional key generator.
|
|
@@ -2045,8 +2063,7 @@ var DatabaseResolver = class {
|
|
|
2045
2063
|
throw new ToolboxError("TOOL", `unknown database '${id}'`, { id });
|
|
2046
2064
|
}
|
|
2047
2065
|
};
|
|
2048
|
-
|
|
2049
|
-
//#region src/core/factories.ts
|
|
2066
|
+
// src/core/factories.ts
|
|
2050
2067
|
/**
|
|
2051
2068
|
* Wraps a registered tool as a {@link WorkflowFunction} (`@orkestrel/workflow`) — the opt-in
|
|
2052
2069
|
* adapter that lets a `function`-form task run a `@orkestrel/tool` tool by name.
|
|
@@ -2335,15 +2352,7 @@ function createWorkflowTool(definition, runner, options) {
|
|
|
2335
2352
|
const cloned = attempt(() => cloneJSONRecord(args));
|
|
2336
2353
|
if (!cloned.success) throw new ToolboxError("TOOL", "malformed workflow definition", { workflow: definition.id });
|
|
2337
2354
|
const owned = cloned.value;
|
|
2338
|
-
|
|
2339
|
-
if (Object.keys(owned).length === 0) target = definition;
|
|
2340
|
-
else if (isArray(owned.steps)) {
|
|
2341
|
-
const flat = steps.parse(owned);
|
|
2342
|
-
target = flat === void 0 ? void 0 : expandSteps(flat);
|
|
2343
|
-
} else {
|
|
2344
|
-
const parsed = draft.parse(owned);
|
|
2345
|
-
target = parsed === void 0 ? void 0 : completeDraft(parsed);
|
|
2346
|
-
}
|
|
2355
|
+
const target = resolveWorkflowTarget(owned, definition, steps, draft);
|
|
2347
2356
|
if (target === void 0 || !strict.is(target)) throw new ToolboxError("TOOL", "malformed workflow definition", { workflow: definition.id });
|
|
2348
2357
|
const tag = tagWorkflow(target.id);
|
|
2349
2358
|
if (lineage.includes(tag)) throw new ToolboxError("DEPTH", `workflow '${target.id}' is already an ancestor (cycle)`, {
|
|
@@ -3385,7 +3394,6 @@ function createEndpointTool(definition, options) {
|
|
|
3385
3394
|
}
|
|
3386
3395
|
});
|
|
3387
3396
|
}
|
|
3388
|
-
|
|
3389
|
-
export { AGENT_TOOL_DEPTH, AGENT_TOOL_DESCRIPTION, AGENT_TOOL_NAME, AGENT_TOOL_SUMMARY, ANSWER_TOOL_DESCRIPTION, ANSWER_TOOL_NAME, ANSWER_TOOL_SUMMARY, DATABASE_TOOL_DESCRIPTION, DATABASE_TOOL_LIMIT, DATABASE_TOOL_MUTATIONS, DATABASE_TOOL_NAME, DATABASE_TOOL_SUMMARY, DESCRIBE_TOOL_DESCRIPTION, DESCRIBE_TOOL_NAME, DESCRIBE_TOOL_SUMMARY, DatabaseDefinitionStore, DatabaseResolver, INFER_TOOL_DESCRIPTION, INFER_TOOL_NAME, INFER_TOOL_SUMMARY, MAX_WORKFLOW_CHAIN, MemoryDefinitionStore, PROMPT_TOOL_DESCRIPTION, PROMPT_TOOL_NAME, PROMPT_TOOL_SUMMARY, RELATION_TOOL_DEPTH, RELATION_TOOL_DESCRIPTION, RELATION_TOOL_LIMIT, RELATION_TOOL_NAME, RELATION_TOOL_SUMMARY, ToolboxError, WORKFLOW_TOOL_DESCRIPTION, WORKFLOW_TOOL_FLAT_EXAMPLE, WORKFLOW_TOOL_NAME, WORKFLOW_TOOL_NESTED_EXAMPLE, WORKFLOW_TOOL_SUMMARY, WORKSPACE_TOOL_DESCRIPTION, WORKSPACE_TOOL_EXAMPLE, WORKSPACE_TOOL_NAME, WORKSPACE_TOOL_SUMMARY, agentToolShape, answerToolShape, clampQuery, columnPrimitiveShape, columnSpecShape, compileColumn, compileColumnPrimitive, completeDraft, completePhaseDraft, completeTaskDraft, conditionShape, createAgentFunction, createAgentTool, createAnswerTool, createDatabaseDefinitionStore, createDatabaseTool, createDescribeTool, createEndpointTool, createInferTool, createMemoryDefinitionStore, createPromptTool, createRelationTool, createToolFunction, createWorkflowDraftContract, createWorkflowFunctions, createWorkflowTool, createWorkspaceTool, databaseToolShape, deriveWorkflowDepth, describeToolShape, expandInclude, expandSteps, expandTables, extendLineage, includeShape, inferDatabaseCode, inferRelationCode, inferTerminalCode, inferToolShape, isAgentFunction, isColumnPrimitive, isColumnSpec, isDatabaseDefinition, isToolboxError, isWorkflowLineage, keyShape, managerShape, normalizeLineage, normalizeQuery, orderShape, phaseDraftShape, promptToolShape, queryShape, relationToolShape, resolveLimit, resolveRelationManager, resolveRelationModel, rowShape, rowsShape, singleKeyShape, stepShape, summarizeWorkflow, tableSpecShape, tagAgent, tagWorkflow, taskDraftShape, workflowDraftShape, workflowStepsShape, workspaceToolShape };
|
|
3397
|
+
export { AGENT_TOOL_DEPTH, AGENT_TOOL_DESCRIPTION, AGENT_TOOL_NAME, AGENT_TOOL_SUMMARY, ANSWER_TOOL_DESCRIPTION, ANSWER_TOOL_NAME, ANSWER_TOOL_SUMMARY, DATABASE_TOOL_DESCRIPTION, DATABASE_TOOL_LIMIT, DATABASE_TOOL_MUTATIONS, DATABASE_TOOL_NAME, DATABASE_TOOL_SUMMARY, DESCRIBE_TOOL_DESCRIPTION, DESCRIBE_TOOL_NAME, DESCRIBE_TOOL_SUMMARY, DatabaseDefinitionStore, DatabaseResolver, INFER_TOOL_DESCRIPTION, INFER_TOOL_NAME, INFER_TOOL_SUMMARY, MAX_WORKFLOW_CHAIN, MemoryDefinitionStore, PROMPT_TOOL_DESCRIPTION, PROMPT_TOOL_NAME, PROMPT_TOOL_SUMMARY, RELATION_TOOL_DEPTH, RELATION_TOOL_DESCRIPTION, RELATION_TOOL_LIMIT, RELATION_TOOL_NAME, RELATION_TOOL_SUMMARY, ToolboxError, WORKFLOW_TOOL_DESCRIPTION, WORKFLOW_TOOL_FLAT_EXAMPLE, WORKFLOW_TOOL_NAME, WORKFLOW_TOOL_NESTED_EXAMPLE, WORKFLOW_TOOL_SUMMARY, WORKSPACE_TOOL_DESCRIPTION, WORKSPACE_TOOL_EXAMPLE, WORKSPACE_TOOL_NAME, WORKSPACE_TOOL_SUMMARY, agentToolShape, answerToolShape, clampQuery, columnPrimitiveShape, columnSpecShape, compileColumn, compileColumnPrimitive, completeDraft, completePhaseDraft, completeTaskDraft, conditionShape, createAgentFunction, createAgentTool, createAnswerTool, createDatabaseDefinitionStore, createDatabaseTool, createDescribeTool, createEndpointTool, createInferTool, createMemoryDefinitionStore, createPromptTool, createRelationTool, createToolFunction, createWorkflowDraftContract, createWorkflowFunctions, createWorkflowTool, createWorkspaceTool, databaseToolShape, deriveWorkflowDepth, describeToolShape, expandInclude, expandSteps, expandTables, extendLineage, includeShape, inferDatabaseCode, inferRelationCode, inferTerminalCode, inferToolShape, isAgentFunction, isColumnPrimitive, isColumnSpec, isDatabaseDefinition, isToolboxError, isWorkflowLineage, keyShape, managerShape, normalizeLineage, normalizeQuery, orderShape, phaseDraftShape, promptToolShape, queryShape, relationToolShape, resolveLimit, resolveRelationManager, resolveRelationModel, resolveWorkflowTarget, rowShape, rowsShape, singleKeyShape, stepShape, summarizeWorkflow, tableSpecShape, tagAgent, tagWorkflow, taskDraftShape, workflowDraftShape, workflowStepsShape, workspaceToolShape };
|
|
3390
3398
|
|
|
3391
3399
|
//# sourceMappingURL=index.js.map
|