toolsplice 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.
Files changed (137) hide show
  1. package/README.md +62 -330
  2. package/dist/abortable.d.ts +6 -0
  3. package/dist/abortable.js +50 -0
  4. package/dist/adaptive-read.d.ts +50 -0
  5. package/dist/adaptive-read.js +780 -0
  6. package/dist/answer-wait.d.ts +7 -0
  7. package/dist/answer-wait.js +45 -0
  8. package/dist/cache-reads.d.ts +18 -0
  9. package/dist/cache-reads.js +89 -0
  10. package/dist/calibration-ledger.d.ts +37 -0
  11. package/dist/calibration-ledger.js +148 -0
  12. package/dist/calibration-marker.d.ts +4 -0
  13. package/dist/calibration-marker.js +77 -0
  14. package/dist/catalog-setup.d.ts +33 -0
  15. package/dist/catalog-setup.js +89 -0
  16. package/dist/catalog.d.ts +10 -0
  17. package/dist/catalog.js +42 -0
  18. package/dist/checkpoint-files.d.ts +15 -0
  19. package/dist/checkpoint-files.js +99 -0
  20. package/dist/cli.js +545 -14
  21. package/dist/coalesce-reads.d.ts +6 -0
  22. package/dist/coalesce-reads.js +33 -0
  23. package/dist/contract-caller.d.ts +2 -1
  24. package/dist/contract-caller.js +35 -16
  25. package/dist/contract-schema.d.ts +3 -1
  26. package/dist/contract-schema.js +34 -4
  27. package/dist/contracts.d.ts +1 -0
  28. package/dist/contracts.js +5 -1
  29. package/dist/core.d.ts +31 -1
  30. package/dist/core.js +27 -0
  31. package/dist/db-final-answer.d.ts +9 -0
  32. package/dist/db-final-answer.js +62 -0
  33. package/dist/define.d.ts +78 -0
  34. package/dist/define.js +14 -0
  35. package/dist/final-answer-stores.d.ts +71 -0
  36. package/dist/final-answer-stores.js +72 -0
  37. package/dist/final-answer.d.ts +32 -0
  38. package/dist/final-answer.js +104 -0
  39. package/dist/impact.d.ts +48 -0
  40. package/dist/impact.js +71 -0
  41. package/dist/index.d.ts +32 -1
  42. package/dist/index.js +28 -0
  43. package/dist/local-tool.d.ts +18 -0
  44. package/dist/local-tool.js +32 -0
  45. package/dist/mcp-apps.d.ts +53 -0
  46. package/dist/mcp-apps.js +32 -0
  47. package/dist/mcp-event-delivery.d.ts +98 -0
  48. package/dist/mcp-event-delivery.js +211 -0
  49. package/dist/mcp-extensions.d.ts +46 -0
  50. package/dist/mcp-extensions.js +200 -0
  51. package/dist/mcp-peer.d.ts +45 -0
  52. package/dist/mcp-peer.js +207 -0
  53. package/dist/mcp-server-card.d.ts +21 -0
  54. package/dist/mcp-server-card.js +54 -0
  55. package/dist/page-checkpoint.d.ts +71 -0
  56. package/dist/page-checkpoint.js +286 -0
  57. package/dist/page-read-gate.d.ts +15 -0
  58. package/dist/page-read-gate.js +48 -0
  59. package/dist/pattern.d.ts +1 -0
  60. package/dist/pattern.js +27 -5
  61. package/dist/probe.js +6 -19
  62. package/dist/read-pages.d.ts +25 -0
  63. package/dist/read-pages.js +85 -0
  64. package/dist/read-policy.d.ts +6 -0
  65. package/dist/read-policy.js +16 -0
  66. package/dist/read-steps.d.ts +12 -0
  67. package/dist/read-steps.js +36 -0
  68. package/dist/result-session.d.ts +109 -0
  69. package/dist/result-session.js +620 -0
  70. package/dist/route-checkpoint.d.ts +3 -0
  71. package/dist/route-checkpoint.js +80 -0
  72. package/dist/route-driver-cli.d.ts +3 -0
  73. package/dist/route-driver-cli.js +43 -0
  74. package/dist/route-evaluation.d.ts +141 -0
  75. package/dist/route-evaluation.js +329 -0
  76. package/dist/row-groups.d.ts +17 -0
  77. package/dist/row-groups.js +79 -0
  78. package/dist/row-query.d.ts +62 -0
  79. package/dist/row-query.js +172 -0
  80. package/dist/rules.d.ts +30 -0
  81. package/dist/rules.js +72 -0
  82. package/dist/run-diagnostics.d.ts +75 -0
  83. package/dist/run-diagnostics.js +212 -0
  84. package/dist/search-fetch.d.ts +50 -0
  85. package/dist/search-fetch.js +264 -0
  86. package/dist/skill-files.d.ts +9 -0
  87. package/dist/skill-files.js +49 -0
  88. package/dist/splice-diagnostics.d.ts +4 -0
  89. package/dist/splice-diagnostics.js +24 -16
  90. package/dist/splice-measure.d.ts +33 -0
  91. package/dist/splice-measure.js +55 -0
  92. package/dist/splice-project.d.ts +12 -6
  93. package/dist/splice-project.js +72 -20
  94. package/dist/splice-recording.d.ts +29 -2
  95. package/dist/splice-recording.js +22 -5
  96. package/dist/splice.d.ts +98 -1
  97. package/dist/splice.js +225 -27
  98. package/dist/sqlite-checkpoint-store.d.ts +5 -0
  99. package/dist/sqlite-checkpoint-store.js +91 -0
  100. package/dist/sqlite-checkpoint-worker.d.ts +1 -0
  101. package/dist/sqlite-checkpoint-worker.js +115 -0
  102. package/dist/test-difference.d.ts +13 -0
  103. package/dist/test-difference.js +42 -0
  104. package/dist/testing.d.ts +122 -0
  105. package/dist/testing.js +261 -0
  106. package/dist/text-pages.d.ts +24 -0
  107. package/dist/text-pages.js +36 -0
  108. package/dist/tool-discovery.d.ts +59 -0
  109. package/dist/tool-discovery.js +136 -0
  110. package/dist/unevaluated.d.ts +7 -0
  111. package/dist/unevaluated.js +156 -0
  112. package/dist/v2.js +25 -8
  113. package/dist/version.d.ts +1 -1
  114. package/dist/version.js +1 -1
  115. package/dist/workflow-json.js +1 -1
  116. package/docs/AGENT-FRAMEWORKS.md +431 -0
  117. package/docs/BENCHMARKS.md +43 -0
  118. package/docs/INTEGRATION-QUICKSTART.md +859 -0
  119. package/docs/LEARNING-AND-STORAGE.md +393 -0
  120. package/docs/MCP.md +204 -0
  121. package/docs/PROJECTS-AND-UPGRADES.md +67 -9
  122. package/docs/PYTHON-REFERENCE.md +348 -0
  123. package/docs/PYTHON.md +120 -0
  124. package/docs/RECORDING-AND-CORRECTIONS.md +30 -1
  125. package/docs/TESTING.md +259 -0
  126. package/examples/mcp-app/build.mjs +11 -0
  127. package/examples/mcp-app/view.mjs +22 -0
  128. package/examples/quickstart.mjs +43 -0
  129. package/examples/route-driver.mjs +67 -0
  130. package/integrations/ai.d.mts +36 -0
  131. package/integrations/ai.mjs +178 -0
  132. package/integrations/call-options.mjs +9 -0
  133. package/integrations/langchain.d.mts +31 -0
  134. package/integrations/langchain.mjs +114 -0
  135. package/integrations/managed.mjs +154 -0
  136. package/integrations/types.d.mts +13 -0
  137. package/package.json +47 -3
@@ -0,0 +1,99 @@
1
+ import { hostname } from "node:os";
2
+ import { randomUUID } from "node:crypto";
3
+ import { closeSync, fsyncSync, linkSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync, statSync, } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+ export const checkpointMessages = {
6
+ 41: "Checkpoint belongs to a different evaluation suite or context.",
7
+ 42: "Checkpoint trial is active on this or another host.",
8
+ 43: "The trial was interrupted before its grade was saved. Check recorded usage with evaluate --ledger before using --retry-incomplete.",
9
+ 44: "Invalid calibration checkpoint. Restore an intact copy before resuming.",
10
+ };
11
+ export class CheckpointError extends Error {
12
+ code;
13
+ constructor(code) {
14
+ super(checkpointMessages[code]);
15
+ this.code = code;
16
+ }
17
+ }
18
+ export function hasCode(error, code) {
19
+ return error?.code === code;
20
+ }
21
+ export function syncDirectory(dir) {
22
+ if (process.platform === "win32")
23
+ return;
24
+ const fd = openSync(dir, "r");
25
+ try {
26
+ fsyncSync(fd);
27
+ }
28
+ finally {
29
+ closeSync(fd);
30
+ }
31
+ }
32
+ // Only fully written records become visible. A hard link elects one caller before provider I/O.
33
+ export function publish(path, value, replace = false) {
34
+ const dir = dirname(path);
35
+ const tmp = join(dir, ".trial-" + randomUUID());
36
+ const fd = openSync(tmp, "wx", 0o600);
37
+ try {
38
+ try {
39
+ writeFileSync(fd, JSON.stringify(value));
40
+ fsyncSync(fd);
41
+ }
42
+ finally {
43
+ closeSync(fd);
44
+ }
45
+ if (replace)
46
+ renameSync(tmp, path);
47
+ else {
48
+ try {
49
+ linkSync(tmp, path);
50
+ }
51
+ catch (error) {
52
+ if (hasCode(error, "EEXIST"))
53
+ return false;
54
+ throw error;
55
+ }
56
+ }
57
+ syncDirectory(dir);
58
+ return true;
59
+ }
60
+ finally {
61
+ try {
62
+ unlinkSync(tmp);
63
+ }
64
+ catch (error) {
65
+ if (!hasCode(error, "ENOENT"))
66
+ throw error;
67
+ }
68
+ }
69
+ }
70
+ export function read(path, maxBytes = 8192) {
71
+ try {
72
+ const stat = statSync(path);
73
+ if (!stat.isFile() || stat.size > maxBytes)
74
+ throw new CheckpointError(44);
75
+ const record = JSON.parse(readFileSync(path, "utf8"));
76
+ if (!record || typeof record !== "object" || Array.isArray(record))
77
+ throw new CheckpointError(44);
78
+ return record;
79
+ }
80
+ catch (error) {
81
+ if (hasCode(error, "ENOENT"))
82
+ return undefined;
83
+ throw new CheckpointError(44);
84
+ }
85
+ }
86
+ export function active(record) {
87
+ if (typeof record.host !== "string" || typeof record.pid !== "number" ||
88
+ !Number.isSafeInteger(record.pid) || record.pid < 1 || record.pid > 2147483647)
89
+ throw new CheckpointError(44);
90
+ if (record.host !== hostname())
91
+ return true;
92
+ try {
93
+ process.kill(record.pid, 0);
94
+ return true;
95
+ }
96
+ catch (error) {
97
+ return !hasCode(error, "ESRCH");
98
+ }
99
+ }