toolsplice-core 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -17
- 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/coalesce-reads.d.ts +6 -0
- package/dist/coalesce-reads.js +33 -0
- package/dist/contract-caller.d.ts +2 -1
- package/dist/contract-caller.js +35 -16
- package/dist/contract-schema.d.ts +3 -1
- package/dist/contract-schema.js +34 -4
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.js +5 -1
- package/dist/core.d.ts +31 -1
- package/dist/core.js +27 -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/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/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/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 +1 -0
- package/dist/pattern.js +27 -5
- 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-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/search-fetch.d.ts +50 -0
- package/dist/search-fetch.js +264 -0
- package/dist/skill-files.d.ts +9 -0
- package/dist/skill-files.js +49 -0
- package/dist/splice-diagnostics.d.ts +4 -0
- package/dist/splice-diagnostics.js +24 -16
- package/dist/splice-recording.d.ts +29 -2
- package/dist/splice-recording.js +22 -5
- package/dist/splice.d.ts +98 -1
- package/dist/splice.js +225 -27
- package/dist/sqlite-checkpoint-store.d.ts +5 -0
- package/dist/sqlite-checkpoint-store.js +91 -0
- package/dist/sqlite-checkpoint-worker.js +115 -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/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workflow-json.js +1 -1
- 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 +30 -1
package/README.md
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
# Toolsplice Core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use this Node.js runtime to map one tool's output into another tool's arguments. Supply your own callers. Toolsplice checks the mapping against both contracts and validates the data before dispatch. Core includes offline replay, regression fixtures and typed adapter generation. The full package adds the CLI and MCP client adapters.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```sh
|
|
8
|
+
npm install toolsplice-core@0.0.2
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires Node.js 22 or later and ES modules.
|
|
12
|
+
|
|
13
|
+
## Connect tools from two catalogs
|
|
14
|
+
|
|
15
|
+
Read the catalogs from your authorized MCP clients. The example assumes the document tool returns a `text` field and the note tool accepts `content`. Change the tool names and JSON pointers to match your catalogs.
|
|
8
16
|
|
|
9
|
-
```
|
|
10
|
-
import { createContractFromCatalog, prepareSplice
|
|
17
|
+
```js
|
|
18
|
+
import { createContractFromCatalog, prepareSplice } from "toolsplice-core";
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
20
|
+
const docs = createContractFromCatalog({ name: "docs" }, sourceCatalog);
|
|
21
|
+
const notes = createContractFromCatalog({ name: "notes" }, targetCatalog);
|
|
22
|
+
const handoff = prepareSplice({
|
|
23
|
+
format: "toolsplice-splice", formatVersion: 1,
|
|
24
|
+
source: { server: "docs", tool: "read" },
|
|
25
|
+
target: { server: "notes", tool: "save" },
|
|
26
|
+
bindings: [{ from: "/text", to: "/content" }],
|
|
27
|
+
}, docs, notes);
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
const read: ToolCaller = (request, options) => yourClient.callSource(request, options);
|
|
19
|
-
const write: ToolCaller = (request, options) => yourClient.callTarget(request, options);
|
|
20
|
-
const result = await adapter.run(read, write, input, { allowReview: true });
|
|
29
|
+
const results = await handoff.run(readCaller, saveCaller, { id: "a1" });
|
|
21
30
|
```
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
Both callers accept `{ name, arguments }` and return raw MCP result objects. Review `handoff.report` for incomplete schemas or application rules. If the report requires review, pass `{ allowReview: true }` after checking its assumptions. Runtime checks still apply to each row.
|
|
24
33
|
|
|
25
|
-
|
|
34
|
+
## Test the handoff
|
|
26
35
|
|
|
27
|
-
`
|
|
36
|
+
Use `createMockCaller` to specify an expected tool name, arguments and result. Call `assertDone()` after the test to check that all expected calls occurred. Use `suiteFromRecording` to turn a complete payload recording into an offline regression. Metadata-only recording is the default. Payload fixtures can contain application data and should stay in storage you control.
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
Applications using Vercel AI SDK or LangChain can expose a prepared handoff with the adapters in `toolsplice-core/ai` and `toolsplice-core/langchain`. [Framework guide](https://cdn.jsdelivr.net/npm/toolsplice@0.0.2/docs/AGENT-FRAMEWORKS.md) · [Benchmark results and methodology](https://cdn.jsdelivr.net/npm/toolsplice@0.0.2/docs/BENCHMARKS.md) · [Full Node SDK](https://www.npmjs.com/package/toolsplice)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type BindingCallOptions } from "./execution.js";
|
|
2
|
+
/** Stop awaiting an application callback when its caller aborts. */
|
|
3
|
+
export declare function abortable<T>(action: () => T | PromiseLike<T>, signal?: AbortSignal): Promise<T>;
|
|
4
|
+
export declare function isReadDeadline(error: unknown): boolean;
|
|
5
|
+
/** Apply one optional deadline across application callbacks and propagate caller cancellation. */
|
|
6
|
+
export declare function withCallDeadline<T, O extends BindingCallOptions>(options: O | undefined, message: string, action: (options?: O) => T | PromiseLike<T>): Promise<T>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { bindingOptions } from "./execution.js";
|
|
2
|
+
/** Stop awaiting an application callback when its caller aborts. */
|
|
3
|
+
export async function abortable(action, signal) {
|
|
4
|
+
if (!signal)
|
|
5
|
+
return action();
|
|
6
|
+
signal.throwIfAborted();
|
|
7
|
+
let onAbort;
|
|
8
|
+
const aborted = new Promise((_, reject) => {
|
|
9
|
+
onAbort = () => reject(signal.reason);
|
|
10
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
11
|
+
});
|
|
12
|
+
try {
|
|
13
|
+
return await Promise.race([
|
|
14
|
+
Promise.resolve().then(() => {
|
|
15
|
+
signal.throwIfAborted();
|
|
16
|
+
return action();
|
|
17
|
+
}),
|
|
18
|
+
aborted,
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
signal.removeEventListener("abort", onAbort);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const localDeadlines = new WeakSet();
|
|
26
|
+
export function isReadDeadline(error) {
|
|
27
|
+
return error instanceof DOMException && localDeadlines.has(error);
|
|
28
|
+
}
|
|
29
|
+
function readDeadline(message) {
|
|
30
|
+
const error = new DOMException(message, "TimeoutError");
|
|
31
|
+
localDeadlines.add(error);
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
/** Apply one optional deadline across application callbacks and propagate caller cancellation. */
|
|
35
|
+
export async function withCallDeadline(options, message, action) {
|
|
36
|
+
if (options?.timeoutMs === undefined)
|
|
37
|
+
return abortable(() => action(options), options?.signal);
|
|
38
|
+
const { timeout } = bindingOptions(options);
|
|
39
|
+
const deadline = new AbortController();
|
|
40
|
+
const signal = options.signal
|
|
41
|
+
? AbortSignal.any([options.signal, deadline.signal])
|
|
42
|
+
: deadline.signal;
|
|
43
|
+
const timer = setTimeout(() => deadline.abort(readDeadline(message)), timeout);
|
|
44
|
+
try {
|
|
45
|
+
return await abortable(() => action({ ...options, signal }), signal);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare function literalCount(text: string, literal: string): {
|
|
2
|
+
literal: string;
|
|
3
|
+
count: number;
|
|
4
|
+
complete: boolean;
|
|
5
|
+
caseSensitive: boolean;
|
|
6
|
+
};
|
|
7
|
+
/** A declared Markdown projection scans the complete document, including fenced text for literal counts. */
|
|
8
|
+
export declare function markdownPageFacts(raw: unknown, literal?: string, headingLevel?: number): {
|
|
9
|
+
heading: string | null;
|
|
10
|
+
literal?: string | undefined;
|
|
11
|
+
count?: number | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** Bind only a submitted document URL. Never substitute a provider-reported redirect. */
|
|
14
|
+
export declare function requestedPageUrl(args: Record<string, unknown>): string | undefined;
|
|
15
|
+
export declare function isPageResult(raw: unknown): raw is string | Record<string, unknown>;
|
|
16
|
+
/** Build a bounded, explicitly partial view. All routing inputs stay in the host. */
|
|
17
|
+
export declare function prepareAdaptiveRead(question: string): (raw: unknown, fallbackSize?: number, requestedUrl?: string) => {
|
|
18
|
+
readonly native: false;
|
|
19
|
+
readonly selection: {
|
|
20
|
+
headings?: {
|
|
21
|
+
syntax: string;
|
|
22
|
+
coverage?: string | undefined;
|
|
23
|
+
level: number;
|
|
24
|
+
count: number;
|
|
25
|
+
complete: boolean;
|
|
26
|
+
first?: string | null | undefined;
|
|
27
|
+
last?: string | null | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
occurrences?: {
|
|
30
|
+
literal: string;
|
|
31
|
+
count: number;
|
|
32
|
+
complete: boolean;
|
|
33
|
+
caseSensitive: boolean;
|
|
34
|
+
} | undefined;
|
|
35
|
+
heading?: string | undefined;
|
|
36
|
+
metadata?: {
|
|
37
|
+
[k: string]: unknown;
|
|
38
|
+
} | undefined;
|
|
39
|
+
};
|
|
40
|
+
readonly headingEvidence?: string | undefined;
|
|
41
|
+
readonly value?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
readonly native: true;
|
|
44
|
+
readonly value: unknown;
|
|
45
|
+
readonly selection?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
readonly value?: undefined;
|
|
48
|
+
readonly native: false;
|
|
49
|
+
readonly selection: unknown;
|
|
50
|
+
};
|