toolsplice-core 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.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -2
  3. package/dist/abortable.d.ts +6 -0
  4. package/dist/abortable.js +50 -0
  5. package/dist/adaptive-read.d.ts +50 -0
  6. package/dist/adaptive-read.js +780 -0
  7. package/dist/answer-wait.d.ts +7 -0
  8. package/dist/answer-wait.js +45 -0
  9. package/dist/cache-reads.d.ts +18 -0
  10. package/dist/cache-reads.js +89 -0
  11. package/dist/calibration-ledger.d.ts +37 -0
  12. package/dist/calibration-ledger.js +148 -0
  13. package/dist/calibration-marker.d.ts +4 -0
  14. package/dist/calibration-marker.js +77 -0
  15. package/dist/catalog-setup.d.ts +33 -0
  16. package/dist/catalog-setup.js +89 -0
  17. package/dist/catalog.d.ts +10 -0
  18. package/dist/catalog.js +42 -0
  19. package/dist/checkpoint-files.d.ts +15 -0
  20. package/dist/checkpoint-files.js +99 -0
  21. package/dist/coalesce-reads.d.ts +6 -0
  22. package/dist/coalesce-reads.js +33 -0
  23. package/dist/codegen.d.ts +44 -0
  24. package/dist/codegen.js +479 -0
  25. package/dist/contract-caller.d.ts +23 -0
  26. package/dist/contract-caller.js +326 -0
  27. package/dist/contract-corrections.d.ts +35 -0
  28. package/dist/contract-corrections.js +159 -0
  29. package/dist/contract-schema.d.ts +7 -0
  30. package/dist/contract-schema.js +156 -0
  31. package/dist/contracts.d.ts +72 -0
  32. package/dist/contracts.js +370 -0
  33. package/dist/core.d.ts +44 -0
  34. package/dist/core.js +43 -0
  35. package/dist/db-final-answer.d.ts +9 -0
  36. package/dist/db-final-answer.js +62 -0
  37. package/dist/define.d.ts +78 -0
  38. package/dist/define.js +14 -0
  39. package/dist/doctor.d.ts +22 -0
  40. package/dist/doctor.js +91 -0
  41. package/dist/drift.d.ts +23 -0
  42. package/dist/drift.js +111 -0
  43. package/dist/execution.d.ts +38 -0
  44. package/dist/execution.js +66 -0
  45. package/dist/extract.d.ts +34 -0
  46. package/dist/extract.js +73 -0
  47. package/dist/final-answer-stores.d.ts +71 -0
  48. package/dist/final-answer-stores.js +72 -0
  49. package/dist/final-answer.d.ts +32 -0
  50. package/dist/final-answer.js +104 -0
  51. package/dist/impact.d.ts +48 -0
  52. package/dist/impact.js +71 -0
  53. package/dist/local-tool.d.ts +18 -0
  54. package/dist/local-tool.js +32 -0
  55. package/dist/mcp-apps.d.ts +53 -0
  56. package/dist/mcp-apps.js +32 -0
  57. package/dist/mcp-event-delivery.d.ts +98 -0
  58. package/dist/mcp-event-delivery.js +211 -0
  59. package/dist/mcp-extensions.d.ts +46 -0
  60. package/dist/mcp-extensions.js +200 -0
  61. package/dist/mcp-peer.d.ts +45 -0
  62. package/dist/mcp-peer.js +207 -0
  63. package/dist/mcp-server-card.d.ts +21 -0
  64. package/dist/mcp-server-card.js +54 -0
  65. package/dist/page-checkpoint.d.ts +71 -0
  66. package/dist/page-checkpoint.js +286 -0
  67. package/dist/page-read-gate.d.ts +15 -0
  68. package/dist/page-read-gate.js +48 -0
  69. package/dist/pattern.d.ts +3 -0
  70. package/dist/pattern.js +54 -0
  71. package/dist/read-pages.d.ts +25 -0
  72. package/dist/read-pages.js +85 -0
  73. package/dist/read-policy.d.ts +6 -0
  74. package/dist/read-policy.js +16 -0
  75. package/dist/read-steps.d.ts +12 -0
  76. package/dist/read-steps.js +36 -0
  77. package/dist/result-session.d.ts +109 -0
  78. package/dist/result-session.js +620 -0
  79. package/dist/route-checkpoint.d.ts +3 -0
  80. package/dist/route-checkpoint.js +80 -0
  81. package/dist/route-evaluation.d.ts +141 -0
  82. package/dist/route-evaluation.js +329 -0
  83. package/dist/row-groups.d.ts +17 -0
  84. package/dist/row-groups.js +79 -0
  85. package/dist/row-query.d.ts +62 -0
  86. package/dist/row-query.js +172 -0
  87. package/dist/rules.d.ts +30 -0
  88. package/dist/rules.js +72 -0
  89. package/dist/run-diagnostics.d.ts +75 -0
  90. package/dist/run-diagnostics.js +212 -0
  91. package/dist/schema.d.ts +17 -0
  92. package/dist/schema.js +299 -0
  93. package/dist/search-fetch.d.ts +50 -0
  94. package/dist/search-fetch.js +264 -0
  95. package/dist/shape.d.ts +91 -0
  96. package/dist/shape.js +499 -0
  97. package/dist/skill-files.d.ts +9 -0
  98. package/dist/skill-files.js +49 -0
  99. package/dist/splice-diagnostics.d.ts +44 -0
  100. package/dist/splice-diagnostics.js +88 -0
  101. package/dist/splice-recording.d.ts +132 -0
  102. package/dist/splice-recording.js +481 -0
  103. package/dist/splice.d.ts +181 -0
  104. package/dist/splice.js +1263 -0
  105. package/dist/sqlite-checkpoint-store.d.ts +5 -0
  106. package/dist/sqlite-checkpoint-store.js +91 -0
  107. package/dist/sqlite-checkpoint-worker.js +115 -0
  108. package/dist/store.d.ts +151 -0
  109. package/dist/store.js +735 -0
  110. package/dist/test-difference.d.ts +13 -0
  111. package/dist/test-difference.js +42 -0
  112. package/dist/testing.d.ts +122 -0
  113. package/dist/testing.js +261 -0
  114. package/dist/text-pages.d.ts +24 -0
  115. package/dist/text-pages.js +36 -0
  116. package/dist/tool-discovery.d.ts +59 -0
  117. package/dist/tool-discovery.js +136 -0
  118. package/dist/unevaluated.d.ts +7 -0
  119. package/dist/unevaluated.js +156 -0
  120. package/dist/version.d.ts +1 -0
  121. package/dist/version.js +1 -0
  122. package/dist/workflow-json.d.ts +8 -0
  123. package/dist/workflow-json.js +74 -0
  124. package/integrations/ai.d.mts +36 -0
  125. package/integrations/ai.mjs +178 -0
  126. package/integrations/call-options.mjs +9 -0
  127. package/integrations/langchain.d.mts +31 -0
  128. package/integrations/langchain.mjs +114 -0
  129. package/integrations/managed.mjs +154 -0
  130. package/integrations/types.d.mts +13 -0
  131. package/package.json +57 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 toolsplice contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # Toolsplice Core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+
5
+ ## Install
6
+
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.
16
+
17
+ ```js
18
+ import { createContractFromCatalog, prepareSplice } from "toolsplice-core";
19
+
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);
28
+
29
+ const results = await handoff.run(readCaller, saveCaller, { id: "a1" });
30
+ ```
31
+
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.
33
+
34
+ ## Test the handoff
35
+
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.
37
+
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
+ };