toolsplice 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +104 -2
- package/dist/abortable.d.ts +6 -0
- package/dist/abortable.js +50 -0
- package/dist/adaptive-read.d.ts +50 -0
- package/dist/adaptive-read.js +780 -0
- package/dist/answer-wait.d.ts +7 -0
- package/dist/answer-wait.js +45 -0
- package/dist/cache-reads.d.ts +18 -0
- package/dist/cache-reads.js +89 -0
- package/dist/calibration-ledger.d.ts +37 -0
- package/dist/calibration-ledger.js +148 -0
- package/dist/calibration-marker.d.ts +4 -0
- package/dist/calibration-marker.js +77 -0
- package/dist/catalog-setup.d.ts +33 -0
- package/dist/catalog-setup.js +89 -0
- package/dist/catalog.d.ts +10 -0
- package/dist/catalog.js +42 -0
- package/dist/checkpoint-files.d.ts +15 -0
- package/dist/checkpoint-files.js +99 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1454 -0
- package/dist/coalesce-reads.d.ts +6 -0
- package/dist/coalesce-reads.js +33 -0
- package/dist/codegen.d.ts +44 -0
- package/dist/codegen.js +479 -0
- package/dist/contract-caller.d.ts +23 -0
- package/dist/contract-caller.js +326 -0
- package/dist/contract-corrections.d.ts +35 -0
- package/dist/contract-corrections.js +159 -0
- package/dist/contract-schema.d.ts +7 -0
- package/dist/contract-schema.js +156 -0
- package/dist/contracts.d.ts +72 -0
- package/dist/contracts.js +370 -0
- package/dist/core.d.ts +44 -0
- package/dist/core.js +43 -0
- package/dist/db-final-answer.d.ts +9 -0
- package/dist/db-final-answer.js +62 -0
- package/dist/define.d.ts +78 -0
- package/dist/define.js +14 -0
- package/dist/doctor.d.ts +22 -0
- package/dist/doctor.js +91 -0
- package/dist/drift.d.ts +23 -0
- package/dist/drift.js +111 -0
- package/dist/execution.d.ts +38 -0
- package/dist/execution.js +66 -0
- package/dist/extract.d.ts +34 -0
- package/dist/extract.js +73 -0
- package/dist/final-answer-stores.d.ts +71 -0
- package/dist/final-answer-stores.js +72 -0
- package/dist/final-answer.d.ts +32 -0
- package/dist/final-answer.js +104 -0
- package/dist/impact.d.ts +48 -0
- package/dist/impact.js +71 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +47 -0
- package/dist/local-tool.d.ts +18 -0
- package/dist/local-tool.js +32 -0
- package/dist/mcp-apps.d.ts +53 -0
- package/dist/mcp-apps.js +32 -0
- package/dist/mcp-event-delivery.d.ts +98 -0
- package/dist/mcp-event-delivery.js +211 -0
- package/dist/mcp-extensions.d.ts +46 -0
- package/dist/mcp-extensions.js +200 -0
- package/dist/mcp-peer.d.ts +45 -0
- package/dist/mcp-peer.js +207 -0
- package/dist/mcp-server-card.d.ts +21 -0
- package/dist/mcp-server-card.js +54 -0
- package/dist/ordered-transport.d.ts +12 -0
- package/dist/ordered-transport.js +106 -0
- package/dist/page-checkpoint.d.ts +71 -0
- package/dist/page-checkpoint.js +286 -0
- package/dist/page-read-gate.d.ts +15 -0
- package/dist/page-read-gate.js +48 -0
- package/dist/pattern.d.ts +3 -0
- package/dist/pattern.js +54 -0
- package/dist/postgres.d.ts +41 -0
- package/dist/postgres.js +264 -0
- package/dist/probe.d.ts +29 -0
- package/dist/probe.js +121 -0
- package/dist/proxy.d.ts +40 -0
- package/dist/proxy.js +436 -0
- package/dist/read-pages.d.ts +25 -0
- package/dist/read-pages.js +85 -0
- package/dist/read-policy.d.ts +6 -0
- package/dist/read-policy.js +16 -0
- package/dist/read-steps.d.ts +12 -0
- package/dist/read-steps.js +36 -0
- package/dist/result-session.d.ts +109 -0
- package/dist/result-session.js +620 -0
- package/dist/route-checkpoint.d.ts +3 -0
- package/dist/route-checkpoint.js +80 -0
- package/dist/route-driver-cli.d.ts +3 -0
- package/dist/route-driver-cli.js +43 -0
- package/dist/route-evaluation.d.ts +141 -0
- package/dist/route-evaluation.js +329 -0
- package/dist/row-groups.d.ts +17 -0
- package/dist/row-groups.js +79 -0
- package/dist/row-query.d.ts +62 -0
- package/dist/row-query.js +172 -0
- package/dist/rules.d.ts +30 -0
- package/dist/rules.js +72 -0
- package/dist/run-diagnostics.d.ts +75 -0
- package/dist/run-diagnostics.js +212 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +26 -0
- package/dist/schema.d.ts +17 -0
- package/dist/schema.js +299 -0
- package/dist/search-fetch.d.ts +50 -0
- package/dist/search-fetch.js +264 -0
- package/dist/shape.d.ts +91 -0
- package/dist/shape.js +499 -0
- package/dist/skill-files.d.ts +9 -0
- package/dist/skill-files.js +49 -0
- package/dist/splice-diagnostics.d.ts +44 -0
- package/dist/splice-diagnostics.js +88 -0
- package/dist/splice-measure.d.ts +33 -0
- package/dist/splice-measure.js +55 -0
- package/dist/splice-project.d.ts +125 -0
- package/dist/splice-project.js +348 -0
- package/dist/splice-recording.d.ts +132 -0
- package/dist/splice-recording.js +481 -0
- package/dist/splice.d.ts +181 -0
- package/dist/splice.js +1263 -0
- package/dist/sqlite-checkpoint-store.d.ts +5 -0
- package/dist/sqlite-checkpoint-store.js +91 -0
- package/dist/sqlite-checkpoint-worker.d.ts +1 -0
- package/dist/sqlite-checkpoint-worker.js +115 -0
- package/dist/storage.d.ts +17 -0
- package/dist/storage.js +1 -0
- package/dist/store.d.ts +151 -0
- package/dist/store.js +735 -0
- package/dist/test-difference.d.ts +13 -0
- package/dist/test-difference.js +42 -0
- package/dist/testing.d.ts +122 -0
- package/dist/testing.js +261 -0
- package/dist/text-pages.d.ts +24 -0
- package/dist/text-pages.js +36 -0
- package/dist/tool-discovery.d.ts +59 -0
- package/dist/tool-discovery.js +136 -0
- package/dist/unevaluated.d.ts +7 -0
- package/dist/unevaluated.js +156 -0
- package/dist/v2.d.ts +49 -0
- package/dist/v2.js +413 -0
- package/dist/validate-output.d.ts +3 -0
- package/dist/validate-output.js +73 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/workflow-json.d.ts +8 -0
- package/dist/workflow-json.js +74 -0
- package/docs/AGENT-FRAMEWORKS.md +431 -0
- package/docs/BENCHMARKS.md +43 -0
- package/docs/INTEGRATION-QUICKSTART.md +859 -0
- package/docs/LEARNING-AND-STORAGE.md +393 -0
- package/docs/MCP.md +204 -0
- package/docs/PROJECTS-AND-UPGRADES.md +173 -0
- package/docs/PYTHON-REFERENCE.md +348 -0
- package/docs/PYTHON.md +120 -0
- package/docs/RECORDING-AND-CORRECTIONS.md +205 -0
- package/docs/TESTING.md +259 -0
- package/examples/mcp-app/build.mjs +11 -0
- package/examples/mcp-app/view.mjs +22 -0
- package/examples/quickstart.mjs +43 -0
- package/examples/route-driver.mjs +67 -0
- package/integrations/ai.d.mts +36 -0
- package/integrations/ai.mjs +178 -0
- package/integrations/call-options.mjs +9 -0
- package/integrations/langchain.d.mts +31 -0
- package/integrations/langchain.mjs +114 -0
- package/integrations/managed.mjs +154 -0
- package/integrations/types.d.mts +13 -0
- package/package.json +139 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type ToolListEntry, type ServerRecord, type ToolAnnotations } from "./store.js";
|
|
2
|
+
import type { JsonSchema } from "./schema.js";
|
|
3
|
+
export type ContractSchema = JsonSchema | boolean;
|
|
4
|
+
export interface ContractTool {
|
|
5
|
+
name: string;
|
|
6
|
+
input: ContractSchema;
|
|
7
|
+
output: ContractSchema | null;
|
|
8
|
+
outputSource: "declared" | "learned" | "unknown" | "corrected";
|
|
9
|
+
encodings: ("structured" | "json-text" | "text" | "empty")[];
|
|
10
|
+
observations: number;
|
|
11
|
+
limited: boolean;
|
|
12
|
+
annotations: Omit<ToolAnnotations, "title">;
|
|
13
|
+
}
|
|
14
|
+
export interface ContractSnapshot {
|
|
15
|
+
format: "callshape-contract";
|
|
16
|
+
formatVersion: 1;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
server: {
|
|
19
|
+
name: string;
|
|
20
|
+
version?: string;
|
|
21
|
+
};
|
|
22
|
+
selection: "all" | "subset";
|
|
23
|
+
tools: ContractTool[];
|
|
24
|
+
fingerprint: string;
|
|
25
|
+
/** An explicit application correction, bound into this snapshot's fingerprint. */
|
|
26
|
+
correction?: {
|
|
27
|
+
baseFingerprint: string;
|
|
28
|
+
manifestFingerprint: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export type ChangeSeverity = "breaking" | "additive" | "review";
|
|
32
|
+
export interface ContractChange {
|
|
33
|
+
tool?: string;
|
|
34
|
+
path: string;
|
|
35
|
+
severity: ChangeSeverity;
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ContractComparison {
|
|
39
|
+
server: string;
|
|
40
|
+
status: "unchanged" | "changed";
|
|
41
|
+
changes: ContractChange[];
|
|
42
|
+
truncated: boolean;
|
|
43
|
+
counts: Record<ChangeSeverity, number>;
|
|
44
|
+
note: string;
|
|
45
|
+
}
|
|
46
|
+
export { definitionContract } from "./contract-schema.js";
|
|
47
|
+
/** Internal helper for producing explicitly revised snapshots; parsing still verifies identity. */
|
|
48
|
+
export declare function contractSnapshotFingerprint(snapshot: ContractSnapshot): string;
|
|
49
|
+
export declare function createContractSnapshot(server: ServerRecord, options?: {
|
|
50
|
+
tools?: string[];
|
|
51
|
+
}): ContractSnapshot;
|
|
52
|
+
/** Build a portable declared contract directly from one tools/list page.
|
|
53
|
+
* The application owns catalog pagination, endpoint identity and connections.
|
|
54
|
+
* This function never opens a store, calls tools or infers semantic field matches.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createContractFromCatalog(server: {
|
|
57
|
+
name: string;
|
|
58
|
+
version?: string;
|
|
59
|
+
}, catalog: {
|
|
60
|
+
tools: readonly ToolListEntry[];
|
|
61
|
+
nextCursor?: string;
|
|
62
|
+
}, options?: {
|
|
63
|
+
tools?: string[];
|
|
64
|
+
}): ContractSnapshot;
|
|
65
|
+
/** Parse without executing schemas, fetching refs, connecting to servers, or changing learning. */
|
|
66
|
+
export declare function parseContractSnapshot(source: string | unknown): ContractSnapshot;
|
|
67
|
+
/** Exact canonical changes with conservative labels, not a general JSON Schema subsumption solver.
|
|
68
|
+
* Anything not justified by a simple supported rule requires review. */
|
|
69
|
+
export declare function compareContractSnapshots(baseline: ContractSnapshot, current: ContractSnapshot): ContractComparison;
|
|
70
|
+
export declare function contractCheckFailed(report: ContractComparison, failOn?: "any" | "breaking"): boolean;
|
|
71
|
+
/** Derive a detached subset without changing its schemas or fabricating new observations. */
|
|
72
|
+
export declare function selectContractTools(source: ContractSnapshot, names: string[]): ContractSnapshot;
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
// Portable, reviewable contract baselines. Comparing observations is evidence of change,
|
|
2
|
+
// not proof that an upstream service or every consumer is compatible.
|
|
3
|
+
import { contract, stableHash } from "./drift.js";
|
|
4
|
+
import { toolOutput, newServer, recordToolList, } from "./store.js";
|
|
5
|
+
import { diagnoseTool } from "./doctor.js";
|
|
6
|
+
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
7
|
+
const pointer = (value) => value.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
8
|
+
const isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
9
|
+
import { assertContractJson, definitionContract } from "./contract-schema.js";
|
|
10
|
+
export { definitionContract } from "./contract-schema.js";
|
|
11
|
+
function canonicalLiteral(v) {
|
|
12
|
+
if (Array.isArray(v))
|
|
13
|
+
return v.map(canonicalLiteral);
|
|
14
|
+
if (!isObject(v))
|
|
15
|
+
return v;
|
|
16
|
+
return Object.fromEntries(Object.keys(v)
|
|
17
|
+
.sort(cmp)
|
|
18
|
+
.map((k) => [k, canonicalLiteral(v[k])]));
|
|
19
|
+
}
|
|
20
|
+
function identity(snapshot) {
|
|
21
|
+
return {
|
|
22
|
+
server: snapshot.server,
|
|
23
|
+
selection: snapshot.selection,
|
|
24
|
+
tools: snapshot.tools.map(({ observations: _n, ...tool }) => tool),
|
|
25
|
+
...(snapshot.correction === undefined
|
|
26
|
+
? {}
|
|
27
|
+
: { correction: snapshot.correction }),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** Internal helper for producing explicitly revised snapshots; parsing still verifies identity. */
|
|
31
|
+
export function contractSnapshotFingerprint(snapshot) {
|
|
32
|
+
return stableHash(canonicalLiteral(identity(snapshot)));
|
|
33
|
+
}
|
|
34
|
+
function annotations(v) {
|
|
35
|
+
return Object.fromEntries(["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"]
|
|
36
|
+
.filter((k) => typeof v?.[k] === "boolean")
|
|
37
|
+
.map((k) => [k, v[k]]));
|
|
38
|
+
}
|
|
39
|
+
export function createContractSnapshot(server, options = {}) {
|
|
40
|
+
const names = options.tools ?? Object.keys(server.tools);
|
|
41
|
+
if (new Set(names).size !== names.length ||
|
|
42
|
+
names.some((n) => !Object.hasOwn(server.tools, n)))
|
|
43
|
+
throw new Error("Contract selection must contain distinct, recorded tool names.");
|
|
44
|
+
const tools = [...names].sort(cmp).map((name) => {
|
|
45
|
+
const tool = server.tools[name], out = toolOutput(tool);
|
|
46
|
+
let output = out?.schema
|
|
47
|
+
? out.source === "declared"
|
|
48
|
+
? definitionContract(out.schema)
|
|
49
|
+
: contract(out.schema)
|
|
50
|
+
: out
|
|
51
|
+
? { type: "string" }
|
|
52
|
+
: null;
|
|
53
|
+
if (out?.schema && out.alsoText)
|
|
54
|
+
output = { anyOf: [output, { type: "string" }] };
|
|
55
|
+
if (output !== null && tool.kinds.empty > 0)
|
|
56
|
+
output = { anyOf: [output, { type: "null" }] };
|
|
57
|
+
if (output === null &&
|
|
58
|
+
tool.kinds.empty > 0 &&
|
|
59
|
+
!tool.kinds.structured &&
|
|
60
|
+
!tool.kinds["json-text"] &&
|
|
61
|
+
!tool.kinds.text)
|
|
62
|
+
output = { type: "null" };
|
|
63
|
+
return {
|
|
64
|
+
name,
|
|
65
|
+
input: definitionContract(tool.inputSchema ?? { type: "object" }),
|
|
66
|
+
output: output,
|
|
67
|
+
outputSource: out?.source ?? (output === null ? "unknown" : "learned"),
|
|
68
|
+
encodings: ["structured", "json-text", "text", "empty"].filter((k) => tool.kinds[k] > 0),
|
|
69
|
+
observations: tool.shape.count + tool.kinds.text + tool.kinds.empty,
|
|
70
|
+
limited: diagnoseTool(tool).limited,
|
|
71
|
+
annotations: annotations(tool.annotations),
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
const snapshot = {
|
|
75
|
+
format: "callshape-contract",
|
|
76
|
+
formatVersion: 1,
|
|
77
|
+
createdAt: new Date().toISOString(),
|
|
78
|
+
server: {
|
|
79
|
+
name: server.name,
|
|
80
|
+
...(server.version === undefined ? {} : { version: server.version }),
|
|
81
|
+
},
|
|
82
|
+
selection: options.tools ? "subset" : "all",
|
|
83
|
+
tools,
|
|
84
|
+
};
|
|
85
|
+
const result = {
|
|
86
|
+
...snapshot,
|
|
87
|
+
fingerprint: stableHash(canonicalLiteral(identity(snapshot))),
|
|
88
|
+
};
|
|
89
|
+
assertContractJson(result);
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
/** Build a portable declared contract directly from one tools/list page.
|
|
93
|
+
* The application owns catalog pagination, endpoint identity and connections.
|
|
94
|
+
* This function never opens a store, calls tools or infers semantic field matches.
|
|
95
|
+
*/
|
|
96
|
+
export function createContractFromCatalog(server, catalog, options = {}) {
|
|
97
|
+
if (!server ||
|
|
98
|
+
typeof server.name !== "string" ||
|
|
99
|
+
!server.name ||
|
|
100
|
+
(server.version !== undefined && typeof server.version !== "string") ||
|
|
101
|
+
!catalog ||
|
|
102
|
+
!Array.isArray(catalog.tools))
|
|
103
|
+
throw new Error("A server identity and tools/list catalog are required.");
|
|
104
|
+
const names = new Set();
|
|
105
|
+
for (const tool of catalog.tools) {
|
|
106
|
+
if (!tool ||
|
|
107
|
+
typeof tool.name !== "string" ||
|
|
108
|
+
!tool.name ||
|
|
109
|
+
names.has(tool.name) ||
|
|
110
|
+
!isObject(tool.inputSchema) ||
|
|
111
|
+
(tool.outputSchema !== undefined && !isObject(tool.outputSchema)))
|
|
112
|
+
throw new Error("Catalog tools need distinct names and JSON schemas.");
|
|
113
|
+
names.add(tool.name);
|
|
114
|
+
}
|
|
115
|
+
if (catalog.nextCursor !== undefined && typeof catalog.nextCursor !== "string")
|
|
116
|
+
throw new Error("Catalog nextCursor must be a string when present.");
|
|
117
|
+
const record = newServer(server.name, server.version);
|
|
118
|
+
recordToolList(record, [...catalog.tools]);
|
|
119
|
+
// Parsing also detaches the result from the caller's catalog and checks limits.
|
|
120
|
+
const selection = catalog.nextCursor !== undefined && options.tools === undefined
|
|
121
|
+
? { tools: [...names] } : options;
|
|
122
|
+
return parseContractSnapshot(createContractSnapshot(record, selection));
|
|
123
|
+
}
|
|
124
|
+
/** Parse without executing schemas, fetching refs, connecting to servers, or changing learning. */
|
|
125
|
+
export function parseContractSnapshot(source) {
|
|
126
|
+
if (typeof source === "string" && Buffer.byteLength(source) > 5 * 1024 * 1024)
|
|
127
|
+
throw new Error("Contract snapshot exceeds the 5 MiB limit.");
|
|
128
|
+
let value;
|
|
129
|
+
try {
|
|
130
|
+
value = typeof source === "string" ? JSON.parse(source) : source;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
throw new Error("Contract snapshot is not valid JSON.");
|
|
134
|
+
}
|
|
135
|
+
assertContractJson(value);
|
|
136
|
+
const bad = () => {
|
|
137
|
+
throw new Error("Invalid or unsupported Toolsplice contract snapshot.");
|
|
138
|
+
};
|
|
139
|
+
if (!isObject(value) ||
|
|
140
|
+
value.format !== "callshape-contract" ||
|
|
141
|
+
value.formatVersion !== 1 ||
|
|
142
|
+
typeof value.createdAt !== "string" ||
|
|
143
|
+
!Number.isFinite(Date.parse(value.createdAt)) ||
|
|
144
|
+
!isObject(value.server) ||
|
|
145
|
+
typeof value.server.name !== "string" ||
|
|
146
|
+
(value.server.version !== undefined &&
|
|
147
|
+
typeof value.server.version !== "string") ||
|
|
148
|
+
!["all", "subset"].includes(String(value.selection)) ||
|
|
149
|
+
!Array.isArray(value.tools) ||
|
|
150
|
+
typeof value.fingerprint !== "string")
|
|
151
|
+
return bad();
|
|
152
|
+
const names = new Set();
|
|
153
|
+
if (value.correction !== undefined &&
|
|
154
|
+
(!isObject(value.correction) ||
|
|
155
|
+
Object.keys(value.correction).some((k) => !["baseFingerprint", "manifestFingerprint"].includes(k)) ||
|
|
156
|
+
typeof value.correction.baseFingerprint !== "string" ||
|
|
157
|
+
typeof value.correction.manifestFingerprint !== "string" ||
|
|
158
|
+
!/^[a-f0-9]{64}$/.test(String(value.correction.baseFingerprint)) ||
|
|
159
|
+
!/^[a-f0-9]{64}$/.test(String(value.correction.manifestFingerprint))))
|
|
160
|
+
return bad();
|
|
161
|
+
for (const t of value.tools) {
|
|
162
|
+
if (!isObject(t) ||
|
|
163
|
+
typeof t.name !== "string" ||
|
|
164
|
+
names.has(t.name) ||
|
|
165
|
+
!(isObject(t.input) || typeof t.input === "boolean") ||
|
|
166
|
+
!(t.output === null ||
|
|
167
|
+
isObject(t.output) ||
|
|
168
|
+
typeof t.output === "boolean") ||
|
|
169
|
+
!["declared", "learned", "unknown", "corrected"].includes(String(t.outputSource)) ||
|
|
170
|
+
!Number.isSafeInteger(t.observations) ||
|
|
171
|
+
Number(t.observations) < 0 ||
|
|
172
|
+
typeof t.limited !== "boolean" ||
|
|
173
|
+
!isObject(t.annotations) ||
|
|
174
|
+
!Array.isArray(t.encodings) ||
|
|
175
|
+
new Set(t.encodings).size !== t.encodings.length ||
|
|
176
|
+
t.encodings.some((k) => !["structured", "json-text", "text", "empty"].includes(k)))
|
|
177
|
+
return bad();
|
|
178
|
+
if ((t.outputSource === "unknown") !== (t.output === null))
|
|
179
|
+
return bad();
|
|
180
|
+
if (t.outputSource === "corrected" && value.correction === undefined)
|
|
181
|
+
return bad();
|
|
182
|
+
if (Object.entries(t.annotations).some(([k, v]) => ![
|
|
183
|
+
"readOnlyHint",
|
|
184
|
+
"destructiveHint",
|
|
185
|
+
"idempotentHint",
|
|
186
|
+
"openWorldHint",
|
|
187
|
+
].includes(k) || typeof v !== "boolean"))
|
|
188
|
+
return bad();
|
|
189
|
+
names.add(t.name);
|
|
190
|
+
}
|
|
191
|
+
const snapshot = canonicalLiteral(value);
|
|
192
|
+
if (stableHash(canonicalLiteral(identity(snapshot))) !== snapshot.fingerprint)
|
|
193
|
+
throw new Error("Contract snapshot fingerprint does not match its contents. Regenerate and review the baseline.");
|
|
194
|
+
return snapshot;
|
|
195
|
+
}
|
|
196
|
+
/** Exact canonical changes with conservative labels, not a general JSON Schema subsumption solver.
|
|
197
|
+
* Anything not justified by a simple supported rule requires review. */
|
|
198
|
+
export function compareContractSnapshots(baseline, current) {
|
|
199
|
+
baseline = parseContractSnapshot(baseline);
|
|
200
|
+
current = parseContractSnapshot(current);
|
|
201
|
+
if (baseline.server.name !== current.server.name)
|
|
202
|
+
throw new Error("Cannot compare contracts for different server identities.");
|
|
203
|
+
const changes = [];
|
|
204
|
+
let truncated = false;
|
|
205
|
+
const add = (path, severity, message, tool) => {
|
|
206
|
+
if (changes.length >= 500) {
|
|
207
|
+
truncated = true;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
changes.push({
|
|
211
|
+
...(tool === undefined ? {} : { tool }),
|
|
212
|
+
path,
|
|
213
|
+
severity,
|
|
214
|
+
message,
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
if (baseline.server.version !== current.server.version)
|
|
218
|
+
add("/server/version", "review", "Server version changed; verify this installation's contract.");
|
|
219
|
+
if (baseline.selection !== current.selection)
|
|
220
|
+
add("/selection", "review", "Tool selection scope changed.");
|
|
221
|
+
const old = new Map(baseline.tools.map((t) => [t.name, t])), next = new Map(current.tools.map((t) => [t.name, t]));
|
|
222
|
+
for (const name of [...new Set([...old.keys(), ...next.keys()])].sort(cmp)) {
|
|
223
|
+
const a = old.get(name), b = next.get(name), path = `/tools/${pointer(name)}`;
|
|
224
|
+
if (!a) {
|
|
225
|
+
add(path, "additive", "Tool added.", name);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (!b) {
|
|
229
|
+
add(path, "breaking", "Previously reviewed tool is absent.", name);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
for (const key of ["input", "output"])
|
|
233
|
+
schemaChanges(a[key], b[key], `${path}/${key}`, key, (p, s, m) => add(p, s, m, name));
|
|
234
|
+
for (const key of [
|
|
235
|
+
"outputSource",
|
|
236
|
+
"encodings",
|
|
237
|
+
"limited",
|
|
238
|
+
"annotations",
|
|
239
|
+
]) {
|
|
240
|
+
if (JSON.stringify(a[key]) !== JSON.stringify(b[key]))
|
|
241
|
+
add(`${path}/${key}`, "review", `Tool ${key} changed; check assumptions before continuing.`, name);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
const counts = { breaking: 0, additive: 0, review: 0 };
|
|
245
|
+
for (const c of changes)
|
|
246
|
+
counts[c.severity]++;
|
|
247
|
+
return {
|
|
248
|
+
server: baseline.server.name,
|
|
249
|
+
status: changes.length || truncated ? "changed" : "unchanged",
|
|
250
|
+
changes,
|
|
251
|
+
truncated,
|
|
252
|
+
counts,
|
|
253
|
+
note: "Observed changes are evidence, not upstream guarantees. Review labels are conservative; this is not full consumer-driven contract testing.",
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
export function contractCheckFailed(report, failOn = "any") {
|
|
257
|
+
if (!["any", "breaking"].includes(failOn))
|
|
258
|
+
throw new Error("failOn must be any or breaking.");
|
|
259
|
+
return (report.truncated ||
|
|
260
|
+
(failOn === "any"
|
|
261
|
+
? report.status === "changed"
|
|
262
|
+
: report.counts.breaking > 0 || report.counts.review > 0));
|
|
263
|
+
}
|
|
264
|
+
function schemaChanges(a, b, path, direction, add, complex = false) {
|
|
265
|
+
if (JSON.stringify(a) === JSON.stringify(b))
|
|
266
|
+
return;
|
|
267
|
+
const severity = (narrows) => complex
|
|
268
|
+
? "review"
|
|
269
|
+
: narrows === (direction === "input")
|
|
270
|
+
? "breaking"
|
|
271
|
+
: "additive";
|
|
272
|
+
if (!isObject(a) || !isObject(b)) {
|
|
273
|
+
add(path, "review", "Schema availability, literal, or boolean constraint changed.");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
complex ||= hasComplex(a) || hasComplex(b);
|
|
277
|
+
for (const key of [...new Set([...Object.keys(a), ...Object.keys(b)])].sort(cmp)) {
|
|
278
|
+
const av = a[key], bv = b[key], p = `${path}/${pointer(key)}`;
|
|
279
|
+
if (JSON.stringify(av) === JSON.stringify(bv))
|
|
280
|
+
continue;
|
|
281
|
+
if (key === "properties" &&
|
|
282
|
+
(av === undefined || isObject(av)) &&
|
|
283
|
+
(bv === undefined || isObject(bv))) {
|
|
284
|
+
const aa = av ?? {}, bb = bv ?? {};
|
|
285
|
+
for (const field of [
|
|
286
|
+
...new Set([...Object.keys(aa), ...Object.keys(bb)]),
|
|
287
|
+
].sort(cmp)) {
|
|
288
|
+
const fp = `${p}/${pointer(field)}`;
|
|
289
|
+
if (!Object.hasOwn(aa, field)) {
|
|
290
|
+
const required = Array.isArray(b.required) && b.required.includes(field);
|
|
291
|
+
const safe = !complex &&
|
|
292
|
+
(direction === "input"
|
|
293
|
+
? !required && a.additionalProperties === false
|
|
294
|
+
: a.additionalProperties === undefined ||
|
|
295
|
+
a.additionalProperties === true);
|
|
296
|
+
add(fp, safe ? "additive" : "review", "Property added; required and closed-object constraints may affect callers.");
|
|
297
|
+
}
|
|
298
|
+
else if (!Object.hasOwn(bb, field)) {
|
|
299
|
+
const required = Array.isArray(a.required) && a.required.includes(field);
|
|
300
|
+
add(fp, !complex && direction === "output" && required
|
|
301
|
+
? "breaking"
|
|
302
|
+
: "review", "Property removed from the schema.");
|
|
303
|
+
}
|
|
304
|
+
else
|
|
305
|
+
schemaChanges(aa[field], bb[field], fp, direction, add, complex || hasComplex(a) || hasComplex(b));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
else if (["required", "type", "enum"].includes(key)) {
|
|
309
|
+
const list = (v) => Array.isArray(v) ? v : v === undefined ? [] : [v];
|
|
310
|
+
const aa = list(av).map((v) => JSON.stringify(v)), bb = list(bv).map((v) => JSON.stringify(v));
|
|
311
|
+
const added = bb.some((v) => !aa.includes(v)), removed = aa.some((v) => !bb.includes(v));
|
|
312
|
+
if (key === "required" && !(added && removed))
|
|
313
|
+
add(p, severity(added), "Required property set changed.");
|
|
314
|
+
else if (av !== undefined && bv !== undefined && !(added && removed))
|
|
315
|
+
add(p, severity(removed), "Allowed type or enum set changed.");
|
|
316
|
+
else
|
|
317
|
+
add(p, "review", "Type, enum, or required constraint needs review.");
|
|
318
|
+
}
|
|
319
|
+
else if ([
|
|
320
|
+
"minimum",
|
|
321
|
+
"exclusiveMinimum",
|
|
322
|
+
"minLength",
|
|
323
|
+
"minItems",
|
|
324
|
+
"minProperties",
|
|
325
|
+
"maximum",
|
|
326
|
+
"exclusiveMaximum",
|
|
327
|
+
"maxLength",
|
|
328
|
+
"maxItems",
|
|
329
|
+
"maxProperties",
|
|
330
|
+
].includes(key) &&
|
|
331
|
+
typeof av === "number" &&
|
|
332
|
+
typeof bv === "number") {
|
|
333
|
+
const isMin = key.startsWith("min") || key === "exclusiveMinimum";
|
|
334
|
+
add(p, severity(isMin ? bv > av : bv < av), "Declared bound changed.");
|
|
335
|
+
}
|
|
336
|
+
else if (key === "items" && isObject(av) && isObject(bv))
|
|
337
|
+
schemaChanges(av, bv, p, direction, add, complex || hasComplex(a) || hasComplex(b));
|
|
338
|
+
else
|
|
339
|
+
add(p, "review", "Constraint changed; compatibility requires review.");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function hasComplex(s) {
|
|
343
|
+
return [
|
|
344
|
+
"$ref",
|
|
345
|
+
"$dynamicRef",
|
|
346
|
+
"anyOf",
|
|
347
|
+
"oneOf",
|
|
348
|
+
"allOf",
|
|
349
|
+
"not",
|
|
350
|
+
"if",
|
|
351
|
+
"then",
|
|
352
|
+
"else",
|
|
353
|
+
"dependentSchemas",
|
|
354
|
+
"dependentRequired",
|
|
355
|
+
"dependencies",
|
|
356
|
+
"patternProperties",
|
|
357
|
+
"unevaluatedProperties",
|
|
358
|
+
].some((k) => Object.hasOwn(s, k));
|
|
359
|
+
}
|
|
360
|
+
/** Derive a detached subset without changing its schemas or fabricating new observations. */
|
|
361
|
+
export function selectContractTools(source, names) {
|
|
362
|
+
const snapshot = parseContractSnapshot(source), wanted = new Set(names);
|
|
363
|
+
if (wanted.size !== names.length ||
|
|
364
|
+
names.some((name) => !snapshot.tools.some((t) => t.name === name)))
|
|
365
|
+
throw new Error("Contract selection must contain distinct, recorded tool names.");
|
|
366
|
+
snapshot.tools = snapshot.tools.filter((t) => wanted.has(t.name));
|
|
367
|
+
snapshot.selection = "subset";
|
|
368
|
+
snapshot.fingerprint = stableHash(canonicalLiteral(identity(snapshot)));
|
|
369
|
+
return snapshot;
|
|
370
|
+
}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export { extract, parseJsonText, type Extracted, type ToolResultLike, } from "./extract.js";
|
|
2
|
+
export { decode, invokeTool, ToolError, type ToolCaller, type BindingCallOptions, type DecodeMode, } from "./execution.js";
|
|
3
|
+
export { createContractFromCatalog, createContractSnapshot, parseContractSnapshot, selectContractTools, compareContractSnapshots, contractCheckFailed, type ContractSnapshot, type ContractTool, type ContractSchema, } from "./contracts.js";
|
|
4
|
+
export { createContractCaller, ContractValidationError, type ContractIssue, type ContractCallerOptions, } from "./contract-caller.js";
|
|
5
|
+
export { parseSpliceSpec, preflightSplice, prepareSplice, SpliceError, type SpliceSpec, type SpliceToolOptions, type SpliceBinding, type SpliceReport, type SpliceIssue, type SpliceRunOptions, type SpliceReadOptions, type SpliceMappingOptions, } from "./splice.js";
|
|
6
|
+
export { explainSpliceError, type SpliceExplanation, type SpliceFieldOrigin, } from "./splice-diagnostics.js";
|
|
7
|
+
export { createSpliceRecorder, parseSpliceRecording, replaySpliceRecording, type SpliceRecording, type SpliceRecordingOptions, type SpliceReplayOptions, } from "./splice-recording.js";
|
|
8
|
+
export { parseContractCorrection, applyContractCorrection, type ContractCorrection, type CorrectionFixtureResult, } from "./contract-corrections.js";
|
|
9
|
+
import { type SpliceSpec } from "./splice.js";
|
|
10
|
+
import type { ContractSnapshot } from "./contracts.js";
|
|
11
|
+
/** Generated adapters use the small package unless explicitly overridden. */
|
|
12
|
+
export declare function emitSpliceModule(plan: SpliceSpec, source: ContractSnapshot, target: ContractSnapshot, options?: {
|
|
13
|
+
runtimeImport?: string;
|
|
14
|
+
}): string;
|
|
15
|
+
export { type SpliceRule, type RuleOperand } from "./rules.js";
|
|
16
|
+
export { createMockCaller, mockRecordedCalls, MockCallError, parseSpliceSuite, runSpliceSuite, suiteFromRecording, formatTestJUnit, type MockStep, type SpliceTestCase, type SpliceSuite, type SpliceTestReport } from "./testing.js";
|
|
17
|
+
export { defineSplice, type SpliceDefinition } from "./define.js";
|
|
18
|
+
export { defineLocalTool, type LocalToolDefinition } from "./local-tool.js";
|
|
19
|
+
export { inspectCatalogMapping, type CatalogSetup } from "./catalog-setup.js";
|
|
20
|
+
export { assessSpliceImpact, type SpliceImpactOptions, type SpliceImpactReport } from "./impact.js";
|
|
21
|
+
export { collectToolCatalog, type ToolCatalogPage } from "./catalog.js";
|
|
22
|
+
export { createMcpAppResource, MCP_APP_MIME_TYPE, type McpToolUi, type McpAppResourceOptions } from "./mcp-apps.js";
|
|
23
|
+
export { createMcpPeer, MCP_PROTOCOL_VERSION, type McpExchange, type McpPeerOptions } from "./mcp-peer.js";
|
|
24
|
+
export type { McpWebhookOptions, McpEventOccurrence } from "./mcp-event-delivery.js";
|
|
25
|
+
export { openMcpSkills, openMcpEvents, type McpRequestPeer, type McpPollOptions, type McpEventBatch } from "./mcp-extensions.js";
|
|
26
|
+
export { createMcpServerCard, type McpServerCardOptions } from "./mcp-server-card.js";
|
|
27
|
+
export { PageReadGate, type PageReadGateOptions } from "./page-read-gate.js";
|
|
28
|
+
export { RetryablePageError } from "./read-pages.js";
|
|
29
|
+
export { collectTextPages, textPageJob, type TextPage, type TextPageOptions } from "./text-pages.js";
|
|
30
|
+
export { ResultSession, resultToolsFromMcp, projectTool, type ResultTool, type ResultSelection, type ResultSessionOptions, type ResultForwardRequest, type ResultToolOptions } from "./result-session.js";
|
|
31
|
+
export type { RowGrouping, RowGroup } from "./row-groups.js";
|
|
32
|
+
export { ExpiredPageCursorError, UncertainPageReadError, type PageCheckpoint, type PageOutcome, type PageJob, type PageInspection, type PageAttempt } from "./page-checkpoint.js";
|
|
33
|
+
export { queryRows, queryRowPages, rowPageJob, type RowPage, type RowPageOptions, type RowPredicate, type RowQuery, type RowQueryResult } from "./row-query.js";
|
|
34
|
+
export { cacheReads, type ReadCacheOptions } from "./cache-reads.js";
|
|
35
|
+
export { coalesceReads } from "./coalesce-reads.js";
|
|
36
|
+
export { searchThenFetch, type SearchFetchOptions } from "./search-fetch.js";
|
|
37
|
+
export { discoverTools } from "./tool-discovery.js";
|
|
38
|
+
export * from "./route-evaluation.js";
|
|
39
|
+
export { RunDiagnostics, type DiagnosticEvent, type DiagnosticModelUsage, type TimedDiagnosticEvent } from "./run-diagnostics.js";
|
|
40
|
+
export { readSteps } from "./read-steps.js";
|
|
41
|
+
export { FinalAnswerWaitTimeout } from "./answer-wait.js";
|
|
42
|
+
export { finalAnswerCheckpoint, type FinalAnswerOptions, type DatabaseFinalAnswerOptions, type FinalAnswerStatus } from "./final-answer.js";
|
|
43
|
+
export { postgresFinalAnswerStore, mongoFinalAnswerStore, type FinalAnswerStore, type FinalAnswerRow } from "./final-answer-stores.js";
|
|
44
|
+
export { openSqliteCheckpointStore } from "./sqlite-checkpoint-store.js";
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// The standalone package entry. No SDK, transports, CLI, proxy or PostgreSQL exports.
|
|
2
|
+
export { extract, parseJsonText, } from "./extract.js";
|
|
3
|
+
export { decode, invokeTool, ToolError, } from "./execution.js";
|
|
4
|
+
export { createContractFromCatalog, createContractSnapshot, parseContractSnapshot, selectContractTools, compareContractSnapshots, contractCheckFailed, } from "./contracts.js";
|
|
5
|
+
export { createContractCaller, ContractValidationError, } from "./contract-caller.js";
|
|
6
|
+
export { parseSpliceSpec, preflightSplice, prepareSplice, SpliceError, } from "./splice.js";
|
|
7
|
+
export { explainSpliceError, } from "./splice-diagnostics.js";
|
|
8
|
+
export { createSpliceRecorder, parseSpliceRecording, replaySpliceRecording, } from "./splice-recording.js";
|
|
9
|
+
export { parseContractCorrection, applyContractCorrection, } from "./contract-corrections.js";
|
|
10
|
+
import { emitSpliceModule as emit } from "./splice.js";
|
|
11
|
+
/** Generated adapters use the small package unless explicitly overridden. */
|
|
12
|
+
export function emitSpliceModule(plan, source, target, options = {}) {
|
|
13
|
+
return emit(plan, source, target, {
|
|
14
|
+
runtimeImport: options.runtimeImport ?? "toolsplice-core",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { createMockCaller, mockRecordedCalls, MockCallError, parseSpliceSuite, runSpliceSuite, suiteFromRecording, formatTestJUnit } from "./testing.js";
|
|
18
|
+
export { defineSplice } from "./define.js";
|
|
19
|
+
export { defineLocalTool } from "./local-tool.js";
|
|
20
|
+
export { inspectCatalogMapping } from "./catalog-setup.js";
|
|
21
|
+
export { assessSpliceImpact } from "./impact.js";
|
|
22
|
+
export { collectToolCatalog } from "./catalog.js";
|
|
23
|
+
export { createMcpAppResource, MCP_APP_MIME_TYPE } from "./mcp-apps.js";
|
|
24
|
+
export { createMcpPeer, MCP_PROTOCOL_VERSION } from "./mcp-peer.js";
|
|
25
|
+
export { openMcpSkills, openMcpEvents } from "./mcp-extensions.js";
|
|
26
|
+
export { createMcpServerCard } from "./mcp-server-card.js";
|
|
27
|
+
export { PageReadGate } from "./page-read-gate.js";
|
|
28
|
+
export { RetryablePageError } from "./read-pages.js";
|
|
29
|
+
export { collectTextPages, textPageJob } from "./text-pages.js";
|
|
30
|
+
export { ResultSession, resultToolsFromMcp, projectTool } from "./result-session.js";
|
|
31
|
+
export { ExpiredPageCursorError, UncertainPageReadError } from "./page-checkpoint.js";
|
|
32
|
+
export { queryRows, queryRowPages, rowPageJob } from "./row-query.js";
|
|
33
|
+
export { cacheReads } from "./cache-reads.js";
|
|
34
|
+
export { coalesceReads } from "./coalesce-reads.js";
|
|
35
|
+
export { searchThenFetch } from "./search-fetch.js";
|
|
36
|
+
export { discoverTools } from "./tool-discovery.js";
|
|
37
|
+
export * from "./route-evaluation.js";
|
|
38
|
+
export { RunDiagnostics } from "./run-diagnostics.js";
|
|
39
|
+
export { readSteps } from "./read-steps.js";
|
|
40
|
+
export { FinalAnswerWaitTimeout } from "./answer-wait.js";
|
|
41
|
+
export { finalAnswerCheckpoint } from "./final-answer.js";
|
|
42
|
+
export { postgresFinalAnswerStore, mongoFinalAnswerStore } from "./final-answer-stores.js";
|
|
43
|
+
export { openSqliteCheckpointStore } from "./sqlite-checkpoint-store.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FinalAnswerStore } from "./final-answer-stores.js";
|
|
2
|
+
import type { FinalAnswerStatus } from "./final-answer.js";
|
|
3
|
+
export declare function databaseCheckpoint<T>(store: FinalAnswerStore, job: string, identity: string, check: (value: unknown) => T): {
|
|
4
|
+
inspect: () => Promise<FinalAnswerStatus<T>>;
|
|
5
|
+
run: (work: (save: (value: T) => Promise<T>) => unknown, options?: {
|
|
6
|
+
waitMs?: number;
|
|
7
|
+
}) => Promise<T>;
|
|
8
|
+
waitForResult: (timeoutMs: number, signal?: AbortSignal) => Promise<T>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { answerWaiter, validateWait } from "./answer-wait.js";
|
|
2
|
+
import { jsonFingerprint } from "./workflow-json.js";
|
|
3
|
+
export function databaseCheckpoint(store, job, identity, check) {
|
|
4
|
+
async function inspect() {
|
|
5
|
+
const row = await store.read(job);
|
|
6
|
+
if (row === null)
|
|
7
|
+
return { state: "missing" };
|
|
8
|
+
if (row.identity !== identity)
|
|
9
|
+
throw new Error("Final answer checkpoint identity or format mismatch.");
|
|
10
|
+
if (row.payload === null)
|
|
11
|
+
return { state: "incomplete" };
|
|
12
|
+
if (typeof row.payload !== "string" ||
|
|
13
|
+
Buffer.byteLength(row.payload) > 512 * 1024)
|
|
14
|
+
throw new Error("Invalid final answer checkpoint.");
|
|
15
|
+
const record = JSON.parse(row.payload);
|
|
16
|
+
const answer = check(record.answer);
|
|
17
|
+
if (record.digest !== jsonFingerprint(answer))
|
|
18
|
+
throw new Error("Invalid final answer digest.");
|
|
19
|
+
return { state: "saved", answer };
|
|
20
|
+
}
|
|
21
|
+
const waitForResult = answerWaiter(inspect);
|
|
22
|
+
async function run(work, options) {
|
|
23
|
+
if (options?.waitMs !== undefined)
|
|
24
|
+
validateWait(options.waitMs);
|
|
25
|
+
const cached = await inspect();
|
|
26
|
+
if (cached.state === "saved")
|
|
27
|
+
return cached.answer;
|
|
28
|
+
if (!(await store.claim(job, identity))) {
|
|
29
|
+
if (options?.waitMs !== undefined)
|
|
30
|
+
return waitForResult(options.waitMs);
|
|
31
|
+
const latest = await inspect();
|
|
32
|
+
if (latest.state === "saved")
|
|
33
|
+
return latest.answer;
|
|
34
|
+
throw new Error("Final answer job is claimed without a saved answer. Reconcile before retrying.");
|
|
35
|
+
}
|
|
36
|
+
let open = true;
|
|
37
|
+
async function save(value) {
|
|
38
|
+
if (!open)
|
|
39
|
+
throw new Error("Final answer run has ended.");
|
|
40
|
+
const answer = check(value);
|
|
41
|
+
const digest = jsonFingerprint(answer);
|
|
42
|
+
if (!(await store.complete(job, identity, JSON.stringify({ answer, digest })))) {
|
|
43
|
+
const latest = await inspect();
|
|
44
|
+
if (latest.state !== "saved" ||
|
|
45
|
+
jsonFingerprint(latest.answer) !== digest)
|
|
46
|
+
throw new Error("A different final answer is already saved.");
|
|
47
|
+
}
|
|
48
|
+
return answer;
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
await work(save);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
open = false;
|
|
55
|
+
}
|
|
56
|
+
const result = await inspect();
|
|
57
|
+
if (result.state !== "saved")
|
|
58
|
+
throw new Error("The workflow ended without saving a final answer.");
|
|
59
|
+
return result.answer;
|
|
60
|
+
}
|
|
61
|
+
return { inspect, run, waitForResult };
|
|
62
|
+
}
|