toolsplice 0.0.0-stage → 0.0.1

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.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +372 -2
  3. package/dist/cli.d.ts +2 -0
  4. package/dist/cli.js +923 -0
  5. package/dist/codegen.d.ts +44 -0
  6. package/dist/codegen.js +479 -0
  7. package/dist/contract-caller.d.ts +22 -0
  8. package/dist/contract-caller.js +307 -0
  9. package/dist/contract-corrections.d.ts +35 -0
  10. package/dist/contract-corrections.js +159 -0
  11. package/dist/contract-schema.d.ts +5 -0
  12. package/dist/contract-schema.js +126 -0
  13. package/dist/contracts.d.ts +71 -0
  14. package/dist/contracts.js +366 -0
  15. package/dist/core.d.ts +14 -0
  16. package/dist/core.js +16 -0
  17. package/dist/doctor.d.ts +22 -0
  18. package/dist/doctor.js +91 -0
  19. package/dist/drift.d.ts +23 -0
  20. package/dist/drift.js +111 -0
  21. package/dist/execution.d.ts +38 -0
  22. package/dist/execution.js +66 -0
  23. package/dist/extract.d.ts +34 -0
  24. package/dist/extract.js +73 -0
  25. package/dist/index.d.ts +20 -0
  26. package/dist/index.js +19 -0
  27. package/dist/ordered-transport.d.ts +12 -0
  28. package/dist/ordered-transport.js +106 -0
  29. package/dist/pattern.d.ts +2 -0
  30. package/dist/pattern.js +32 -0
  31. package/dist/postgres.d.ts +41 -0
  32. package/dist/postgres.js +264 -0
  33. package/dist/probe.d.ts +29 -0
  34. package/dist/probe.js +134 -0
  35. package/dist/proxy.d.ts +40 -0
  36. package/dist/proxy.js +436 -0
  37. package/dist/runtime.d.ts +6 -0
  38. package/dist/runtime.js +26 -0
  39. package/dist/schema.d.ts +17 -0
  40. package/dist/schema.js +299 -0
  41. package/dist/shape.d.ts +91 -0
  42. package/dist/shape.js +499 -0
  43. package/dist/splice-diagnostics.d.ts +40 -0
  44. package/dist/splice-diagnostics.js +80 -0
  45. package/dist/splice-project.d.ts +119 -0
  46. package/dist/splice-project.js +296 -0
  47. package/dist/splice-recording.d.ts +105 -0
  48. package/dist/splice-recording.js +464 -0
  49. package/dist/splice.d.ts +84 -0
  50. package/dist/splice.js +1065 -0
  51. package/dist/storage.d.ts +17 -0
  52. package/dist/storage.js +1 -0
  53. package/dist/store.d.ts +151 -0
  54. package/dist/store.js +735 -0
  55. package/dist/v2.d.ts +49 -0
  56. package/dist/v2.js +396 -0
  57. package/dist/validate-output.d.ts +3 -0
  58. package/dist/validate-output.js +73 -0
  59. package/dist/version.d.ts +1 -0
  60. package/dist/version.js +1 -0
  61. package/dist/workflow-json.d.ts +8 -0
  62. package/dist/workflow-json.js +74 -0
  63. package/docs/PROJECTS-AND-UPGRADES.md +115 -0
  64. package/docs/RECORDING-AND-CORRECTIONS.md +176 -0
  65. package/package.json +95 -4
@@ -0,0 +1,464 @@
1
+ import { VERSION } from "./version.js";
2
+ import { parseContractSnapshot, selectContractTools, compareContractSnapshots, } from "./contracts.js";
3
+ import { prepareSplice, parseSpliceSpec, SpliceError, } from "./splice.js";
4
+ import { explainSpliceError } from "./splice-diagnostics.js";
5
+ import { copyJson, jsonFingerprint, jsonObject, JSON_LIMIT, parseWorkflowJson, escapePointer, pointerParts, replaceOwnPointer, } from "./workflow-json.js";
6
+ const CREDENTIAL_KEYS = [
7
+ "password",
8
+ "authorization",
9
+ "apikey",
10
+ "api_key",
11
+ "access_token",
12
+ "refresh_token",
13
+ "token",
14
+ "secret",
15
+ "client_secret",
16
+ ];
17
+ const MARKER = "__TOOLSPLICE_REDACTED__";
18
+ const hashRecording = (recording) => {
19
+ const { fingerprint: _fingerprint, ...body } = recording;
20
+ return jsonFingerprint(body);
21
+ };
22
+ export function createSpliceRecorder(plan, source, target, options = {}) {
23
+ const spec = parseSpliceSpec(plan), s = selectContractTools(source, [spec.source.tool]), t = selectContractTools(target, [spec.target.tool]);
24
+ const prepared = prepareSplice(spec, s, t), capture = options.capture ?? "metadata", maxBytes = options.maxBytes ?? JSON_LIMIT;
25
+ if (!["metadata", "payloads"].includes(capture) ||
26
+ !Number.isSafeInteger(maxBytes) ||
27
+ maxBytes < 1024 ||
28
+ maxBytes > JSON_LIMIT)
29
+ throw new Error("Invalid recording capture policy or byte limit.");
30
+ for (const values of [options.redactKeys, options.redactValues])
31
+ if (values !== undefined &&
32
+ (!Array.isArray(values) ||
33
+ values.length > 64 ||
34
+ values.some((v) => typeof v !== "string" || !v || v.length > 2048)))
35
+ throw new Error("Redaction policies require at most 64 bounded nonempty strings.");
36
+ const keys = new Set([
37
+ ...CREDENTIAL_KEYS,
38
+ ...(options.redactKeys ?? []).map((k) => k.toLowerCase()),
39
+ ]);
40
+ const secrets = [...(options.redactValues ?? [])];
41
+ let state = "new";
42
+ let capturedBytes = 0;
43
+ const recording = {
44
+ format: "toolsplice-recording",
45
+ formatVersion: 1,
46
+ createdAt: new Date().toISOString(),
47
+ toolspliceVersion: VERSION,
48
+ capture,
49
+ complete: true,
50
+ planFingerprint: jsonFingerprint(spec),
51
+ allowReview: false,
52
+ cancellationObserved: false,
53
+ calls: [],
54
+ outcome: {
55
+ status: "failed",
56
+ stage: "unknown",
57
+ completedTargets: 0,
58
+ issues: [],
59
+ },
60
+ diagnostics: [],
61
+ redactions: [],
62
+ fingerprint: "",
63
+ };
64
+ const captureValue = (value) => {
65
+ try {
66
+ const copy = copyJson(value, maxBytes);
67
+ capturedBytes += Buffer.byteLength(JSON.stringify(copy));
68
+ if (capturedBytes > maxBytes)
69
+ throw new Error("Capture budget exceeded.");
70
+ return copy;
71
+ }
72
+ catch {
73
+ recording.complete = false;
74
+ if (!recording.diagnostics.includes("payload-not-recorded"))
75
+ recording.diagnostics.push("payload-not-recorded");
76
+ return undefined;
77
+ }
78
+ };
79
+ const wrap = (side, caller) => async (request, callOptions) => {
80
+ const entry = {
81
+ side,
82
+ name: request.name,
83
+ outcome: "threw",
84
+ durationMs: 0,
85
+ };
86
+ if (capture === "payloads")
87
+ entry.arguments = captureValue(request.arguments);
88
+ recording.calls.push(entry);
89
+ const started = Date.now();
90
+ try {
91
+ const result = await caller(request, callOptions);
92
+ entry.outcome = "returned";
93
+ if (capture === "payloads")
94
+ entry.result = captureValue(result);
95
+ return result;
96
+ }
97
+ finally {
98
+ entry.durationMs = Math.max(0, Date.now() - started);
99
+ }
100
+ };
101
+ const run = async (sourceCaller, targetCaller, input, runOptions = {}) => {
102
+ if (state !== "new")
103
+ throw new Error("A recorder captures one run; create another recorder for concurrent or subsequent runs.");
104
+ state = "running";
105
+ recording.allowReview = runOptions.allowReview === true;
106
+ if (capture === "payloads") {
107
+ recording.plan = captureValue(spec);
108
+ recording.sourceContract = captureValue(s);
109
+ recording.targetContract = captureValue(t);
110
+ const saved = captureValue(input);
111
+ if (saved !== undefined)
112
+ recording.input = saved;
113
+ if (runOptions.context !== undefined) {
114
+ const context = captureValue(runOptions.context);
115
+ if (context !== undefined)
116
+ recording.context = context;
117
+ }
118
+ }
119
+ try {
120
+ const result = await prepared.run(wrap("source", sourceCaller), wrap("target", targetCaller), input, runOptions);
121
+ let resultFingerprint;
122
+ try {
123
+ resultFingerprint = jsonFingerprint(result);
124
+ }
125
+ catch {
126
+ recording.complete = false;
127
+ recording.diagnostics.push("payload-not-recorded");
128
+ }
129
+ recording.outcome = {
130
+ status: "succeeded",
131
+ ...(resultFingerprint === undefined ? {} : { resultFingerprint }),
132
+ };
133
+ return result;
134
+ }
135
+ catch (error) {
136
+ recording.outcome =
137
+ error instanceof SpliceError
138
+ ? {
139
+ status: "failed",
140
+ stage: error.stage,
141
+ completedTargets: error.completedTargets,
142
+ issues: error.issues.map((i) => ({ code: i.code, path: i.path })),
143
+ }
144
+ : {
145
+ status: "failed",
146
+ stage: "unknown",
147
+ completedTargets: 0,
148
+ issues: [],
149
+ };
150
+ throw error;
151
+ }
152
+ finally {
153
+ recording.cancellationObserved = runOptions.signal?.aborted ?? false;
154
+ state = "finished";
155
+ }
156
+ };
157
+ const snapshot = () => {
158
+ if (state !== "finished")
159
+ throw new Error("Recording is available only after the run settles.");
160
+ // Undefined capture fields are omitted; the raw caller result itself is never modified.
161
+ const detached = JSON.parse(JSON.stringify(recording));
162
+ const redactions = [];
163
+ const redact = (value, path) => {
164
+ if (typeof value === "string" &&
165
+ secrets.some((secret) => value.includes(secret))) {
166
+ redactions.push(path);
167
+ return MARKER;
168
+ }
169
+ if (Array.isArray(value))
170
+ return value.map((v, i) => redact(v, `${path}/${i}`));
171
+ if (!jsonObject(value))
172
+ return value;
173
+ if (Object.keys(value).some((key) => secrets.some((secret) => key.includes(secret)))) {
174
+ redactions.push(path);
175
+ return MARKER;
176
+ }
177
+ return Object.fromEntries(Object.entries(value).map(([key, v]) => {
178
+ const next = `${path}/${escapePointer(key)}`;
179
+ if (keys.has(key.toLowerCase())) {
180
+ redactions.push(next);
181
+ return [key, MARKER];
182
+ }
183
+ return [key, redact(v, next)];
184
+ }));
185
+ };
186
+ // Artifact structure is fixed; redact application-owned data, not envelope keys/diagnostic metadata.
187
+ for (const key of [
188
+ "plan",
189
+ "sourceContract",
190
+ "targetContract",
191
+ "input",
192
+ "context",
193
+ ])
194
+ if (Object.hasOwn(detached, key))
195
+ detached[key] = redact(detached[key], `/${key}`);
196
+ for (const [i, call] of detached.calls.entries())
197
+ for (const key of ["arguments", "result"])
198
+ if (Object.hasOwn(call, key))
199
+ call[key] = redact(call[key], `/calls/${i}/${key}`);
200
+ detached.redactions = redactions;
201
+ try {
202
+ copyJson(detached, maxBytes);
203
+ }
204
+ catch {
205
+ detached.complete = false;
206
+ detached.diagnostics.push("recording-byte-limit");
207
+ delete detached.plan;
208
+ delete detached.sourceContract;
209
+ delete detached.targetContract;
210
+ delete detached.input;
211
+ delete detached.context;
212
+ for (const call of detached.calls) {
213
+ delete call.arguments;
214
+ delete call.result;
215
+ }
216
+ detached.redactions = [];
217
+ }
218
+ detached.fingerprint = hashRecording(detached);
219
+ return copyJson(detached, maxBytes);
220
+ };
221
+ return { report: prepared.report, run, snapshot };
222
+ }
223
+ export function parseSpliceRecording(input) {
224
+ const r = parseWorkflowJson(input);
225
+ const bad = () => {
226
+ throw new Error("Invalid or unsupported splice recording.");
227
+ };
228
+ if (!jsonObject(r) ||
229
+ r.format !== "toolsplice-recording" ||
230
+ r.formatVersion !== 1 ||
231
+ typeof r.createdAt !== "string" ||
232
+ !Number.isFinite(Date.parse(r.createdAt)) ||
233
+ typeof r.toolspliceVersion !== "string" ||
234
+ !r.toolspliceVersion ||
235
+ !["metadata", "payloads"].includes(String(r.capture)) ||
236
+ typeof r.complete !== "boolean" ||
237
+ typeof r.allowReview !== "boolean" ||
238
+ typeof r.cancellationObserved !== "boolean" ||
239
+ typeof r.planFingerprint !== "string" ||
240
+ !/^[a-f0-9]{64}$/.test(r.planFingerprint) ||
241
+ !Array.isArray(r.calls) ||
242
+ r.calls.length > 1001 ||
243
+ !Array.isArray(r.redactions) ||
244
+ r.redactions.some((p) => typeof p !== "string") ||
245
+ !Array.isArray(r.diagnostics) ||
246
+ r.diagnostics.some((d) => !["payload-not-recorded", "recording-byte-limit"].includes(String(d))) ||
247
+ !jsonObject(r.outcome) ||
248
+ !["succeeded", "failed"].includes(String(r.outcome.status)) ||
249
+ typeof r.fingerprint !== "string")
250
+ return bad();
251
+ for (const c of r.calls) {
252
+ if (!jsonObject(c) ||
253
+ !["source", "target"].includes(String(c.side)) ||
254
+ typeof c.name !== "string" ||
255
+ !["returned", "threw"].includes(String(c.outcome)) ||
256
+ typeof c.durationMs !== "number" ||
257
+ c.durationMs < 0)
258
+ return bad();
259
+ }
260
+ if (r.outcome.status === "failed" &&
261
+ (![
262
+ "preflight",
263
+ "context",
264
+ "source",
265
+ "mapping",
266
+ "target",
267
+ "unknown",
268
+ ].includes(String(r.outcome.stage)) ||
269
+ !Number.isSafeInteger(r.outcome.completedTargets) ||
270
+ Number(r.outcome.completedTargets) < 0 ||
271
+ !Array.isArray(r.outcome.issues) ||
272
+ r.outcome.issues.some((i) => !jsonObject(i) ||
273
+ typeof i.code !== "string" ||
274
+ typeof i.path !== "string")))
275
+ return bad();
276
+ if (r.outcome.status === "succeeded" &&
277
+ r.outcome.resultFingerprint !== undefined &&
278
+ (typeof r.outcome.resultFingerprint !== "string" ||
279
+ !/^[a-f0-9]{64}$/.test(r.outcome.resultFingerprint)))
280
+ return bad();
281
+ const redactions = r.redactions;
282
+ if (new Set(redactions).size !== redactions.length)
283
+ return bad();
284
+ for (const path of redactions) {
285
+ const parts = pointerParts(path);
286
+ if (![
287
+ "plan",
288
+ "sourceContract",
289
+ "targetContract",
290
+ "input",
291
+ "context",
292
+ ].includes(parts[0]) &&
293
+ !(parts[0] === "calls" &&
294
+ /^(0|[1-9]\d*)$/.test(parts[1]) &&
295
+ ["arguments", "result"].includes(parts[2])))
296
+ return bad();
297
+ let value = r;
298
+ for (const key of parts) {
299
+ if (!value || typeof value !== "object" || !Object.hasOwn(value, key))
300
+ return bad();
301
+ value = value[key];
302
+ }
303
+ if (value !== MARKER)
304
+ return bad();
305
+ }
306
+ const result = r;
307
+ if (hashRecording(result) !== result.fingerprint)
308
+ throw new Error("Recording fingerprint does not match its contents.");
309
+ return result;
310
+ }
311
+ /** Shared artifact loader for replay and explicit project scaffolding. No writes or connections. */
312
+ export function loadReplayFixture(input, options = {}) {
313
+ const recording = parseSpliceRecording(input), restored = recording.redactions.length > 0;
314
+ if (recording.capture !== "payloads" || !recording.complete)
315
+ throw new Error("Replay needs a complete payload recording; metadata or dropped payloads cannot be replayed.");
316
+ const replacements = options.restorations ?? {};
317
+ if (!jsonObject(replacements) ||
318
+ Object.keys(replacements).length !== recording.redactions.length ||
319
+ recording.redactions.some((p) => !Object.hasOwn(replacements, p)))
320
+ throw new Error("Every redacted path requires an explicit private restoration; no other paths can be replaced.");
321
+ for (const path of recording.redactions)
322
+ replaceOwnPointer(recording, path, copyJson(replacements[path]));
323
+ const spec = parseSpliceSpec(recording.plan), s = parseContractSnapshot(recording.sourceContract), t = parseContractSnapshot(recording.targetContract);
324
+ if (jsonFingerprint(spec) !== recording.planFingerprint)
325
+ throw new Error("Restored plan does not match its recorded fingerprint.");
326
+ if (!Object.hasOwn(recording, "input"))
327
+ throw new Error("Recording has no captured workflow input.");
328
+ return { recording, restored, spec, source: s, target: t };
329
+ }
330
+ /** No live caller or connection can be supplied. Saved responses are consumed strictly in order. */
331
+ export async function replaySpliceRecording(input, options = {}) {
332
+ const { recording, restored, spec, source: originalSource, target: originalTarget, } = loadReplayFixture(input, options);
333
+ const candidate = (value, original, tool) => {
334
+ if (value === undefined)
335
+ return original;
336
+ const parsed = parseContractSnapshot(value);
337
+ if (parsed.server.name !== original.server.name)
338
+ throw new Error("Candidate contract must use the recorded server identity.");
339
+ return selectContractTools(parsed, parsed.tools.some((t) => t.name === tool) ? [tool] : []);
340
+ };
341
+ const s = candidate(options.sourceContract, originalSource, spec.source.tool), t = candidate(options.targetContract, originalTarget, spec.target.tool), checkingUpgrade = options.sourceContract !== undefined ||
342
+ options.targetContract !== undefined;
343
+ const missing = !s.tools.some((tool) => tool.name === spec.source.tool)
344
+ ? "source"
345
+ : !t.tools.some((tool) => tool.name === spec.target.tool)
346
+ ? "target"
347
+ : undefined;
348
+ let consumed = 0, mismatch = false;
349
+ const caller = (side) => async (request) => {
350
+ const saved = recording.calls[consumed];
351
+ if (!saved ||
352
+ saved.side !== side ||
353
+ saved.name !== request.name ||
354
+ !saved.arguments ||
355
+ jsonFingerprint(saved.arguments) !== jsonFingerprint(request.arguments)) {
356
+ mismatch = true;
357
+ throw new Error("Recorded call sequence or arguments differ from replay.");
358
+ }
359
+ consumed++;
360
+ if (saved.outcome === "threw")
361
+ throw new Error("Simulated recorded transport failure; original exception was not retained.");
362
+ if (!Object.hasOwn(saved, "result")) {
363
+ mismatch = true;
364
+ throw new Error("Recorded response is absent.");
365
+ }
366
+ return copyJson(saved.result);
367
+ };
368
+ let outcome, result, explanation;
369
+ try {
370
+ if (missing)
371
+ throw new SpliceError("preflight", 0, undefined, [
372
+ {
373
+ severity: "error",
374
+ code: "candidate-tool-missing",
375
+ path: `/${missing}`,
376
+ message: "The candidate catalog no longer contains the selected tool.",
377
+ },
378
+ ]);
379
+ const prepared = prepareSplice(spec, s, t);
380
+ result = await prepared.run(caller("source"), caller("target"), recording.input, {
381
+ allowReview: options.allowReview ?? recording.allowReview,
382
+ ...(Object.hasOwn(recording, "context")
383
+ ? { context: recording.context }
384
+ : {}),
385
+ });
386
+ outcome = {
387
+ status: "succeeded",
388
+ resultFingerprint: jsonFingerprint(result),
389
+ };
390
+ }
391
+ catch (error) {
392
+ outcome =
393
+ error instanceof SpliceError
394
+ ? {
395
+ status: "failed",
396
+ stage: error.stage,
397
+ completedTargets: error.completedTargets,
398
+ issues: error.issues.map((i) => ({ code: i.code, path: i.path })),
399
+ }
400
+ : {
401
+ status: "failed",
402
+ stage: "unknown",
403
+ completedTargets: 0,
404
+ issues: [],
405
+ };
406
+ if (error instanceof SpliceError)
407
+ explanation = explainSpliceError(spec, error);
408
+ }
409
+ const matched = !mismatch &&
410
+ consumed === recording.calls.length &&
411
+ jsonFingerprint(outcome) === jsonFingerprint(recording.outcome);
412
+ const upgradeStatus = recording.outcome.status !== "succeeded" ||
413
+ recording.cancellationObserved ||
414
+ recording.calls.some((call) => call.outcome === "threw")
415
+ ? "inconclusive"
416
+ : matched
417
+ ? "passed"
418
+ : "failed";
419
+ return {
420
+ matched,
421
+ recordedOutcome: copyJson(recording.outcome),
422
+ ...(checkingUpgrade
423
+ ? {
424
+ upgrade: {
425
+ status: upgradeStatus,
426
+ source: compareContractSnapshots(originalSource, s),
427
+ target: compareContractSnapshots(originalTarget, t),
428
+ fingerprints: {
429
+ recordedSource: originalSource.fingerprint,
430
+ candidateSource: s.fingerprint,
431
+ recordedTarget: originalTarget.fingerprint,
432
+ candidateTarget: t.fingerprint,
433
+ },
434
+ note: "This checks the captured case only. A previously failed or cancelled run cannot establish successful upgrade compatibility.",
435
+ },
436
+ }
437
+ : {}),
438
+ mode: restored ? "restored-fixture" : "saved-fixture",
439
+ networkCalls: 0,
440
+ consumedCalls: consumed,
441
+ recordedCalls: recording.calls.length,
442
+ outcome,
443
+ ...(result === undefined ? {} : { result }),
444
+ ...(explanation ? { explanation } : {}),
445
+ caveats: [
446
+ "Replay tests saved data and current guards; it does not establish live provider behavior or committed side effects.",
447
+ ...(recording.cancellationObserved
448
+ ? [
449
+ "Cancellation timing is not reproduced; a saved response may replay differently.",
450
+ ]
451
+ : []),
452
+ ...(recording.calls.some((c) => c.outcome === "threw")
453
+ ? [
454
+ "Transport exceptions are simulated without their original messages or causes.",
455
+ ]
456
+ : []),
457
+ ...(restored
458
+ ? [
459
+ "Restoration values are supplied by the application; their authenticity is not certified.",
460
+ ]
461
+ : []),
462
+ ],
463
+ };
464
+ }
@@ -0,0 +1,84 @@
1
+ import { type ContractSchema, type ContractSnapshot } from "./contracts.js";
2
+ import { type BindingCallOptions, type ToolCaller } from "./execution.js";
3
+ export interface SpliceEndpoint {
4
+ server: string;
5
+ tool: string;
6
+ }
7
+ export type SpliceBinding = {
8
+ to: string;
9
+ from: string;
10
+ } | {
11
+ to: string;
12
+ value: unknown;
13
+ } | {
14
+ to: string;
15
+ fromContext: string;
16
+ };
17
+ export interface SpliceSpec {
18
+ format: "toolsplice-splice";
19
+ formatVersion: 1;
20
+ source: SpliceEndpoint & {
21
+ path?: string;
22
+ parseJson?: boolean;
23
+ /** Consumer requirement on the selected/parsed value, before forEach. */
24
+ valueSchema?: ContractSchema;
25
+ expect?: {
26
+ path: string;
27
+ equals: unknown;
28
+ }[];
29
+ };
30
+ target: SpliceEndpoint & {
31
+ /** Reject duplicate destination-key tuples within this batch, before any target call. */
32
+ uniqueBy?: string[];
33
+ };
34
+ forEach?: boolean;
35
+ maxItems?: number;
36
+ /** UTF-8 JSON bytes of the final result array; default 5 MiB, maximum 64 MiB. */
37
+ maxResultBytes?: number;
38
+ bindings: SpliceBinding[];
39
+ /** Application-supplied values, validated before any source call. */
40
+ contextSchema?: Record<string, unknown>;
41
+ }
42
+ export interface SpliceIssue {
43
+ severity: "error" | "warning";
44
+ code: string;
45
+ path: string;
46
+ message: string;
47
+ }
48
+ export interface SpliceReport {
49
+ status: "ready" | "review" | "blocked";
50
+ source: SpliceEndpoint;
51
+ target: SpliceEndpoint;
52
+ issues: SpliceIssue[];
53
+ maxTargetCalls: number;
54
+ maxResultBytes: number;
55
+ fingerprints: {
56
+ source: string;
57
+ target: string;
58
+ plan: string;
59
+ };
60
+ note: string;
61
+ }
62
+ export interface SpliceMappingOptions {
63
+ context?: unknown;
64
+ }
65
+ export interface SpliceRunOptions extends BindingCallOptions, SpliceMappingOptions {
66
+ /** Explicitly allow uncertain static checks; runtime validation still applies to every row. */
67
+ allowReview?: boolean;
68
+ }
69
+ export declare class SpliceError extends Error {
70
+ readonly stage: "preflight" | "context" | "source" | "mapping" | "target";
71
+ readonly completedTargets: number;
72
+ readonly issues: SpliceIssue[];
73
+ constructor(stage: "preflight" | "context" | "source" | "mapping" | "target", completedTargets: number, cause?: unknown, details?: SpliceIssue[]);
74
+ }
75
+ export declare function parseSpliceSpec(source: string | unknown): SpliceSpec;
76
+ export declare function preflightSplice(plan: SpliceSpec, source: ContractSnapshot, target: ContractSnapshot): SpliceReport;
77
+ export declare function prepareSplice(plan: SpliceSpec, source: ContractSnapshot, target: ContractSnapshot): {
78
+ report: SpliceReport;
79
+ mapOutput: (output: unknown, options?: SpliceMappingOptions) => Promise<Record<string, unknown>[]>;
80
+ run: (sourceCaller: ToolCaller, targetCaller: ToolCaller, args: unknown, options?: SpliceRunOptions) => Promise<unknown[]>;
81
+ };
82
+ export declare function emitSpliceModule(plan: SpliceSpec, source: ContractSnapshot, target: ContractSnapshot, options?: {
83
+ runtimeImport?: string;
84
+ }): string;