@sprinterai/runtime 0.2.0

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 (266) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapters/a2a-adapter.d.ts +24 -0
  3. package/dist/adapters/a2a-adapter.d.ts.map +1 -0
  4. package/dist/adapters/a2a-adapter.js +13 -0
  5. package/dist/adapters/a2a-adapter.js.map +1 -0
  6. package/dist/adapters/http-agent-adapter.d.ts +22 -0
  7. package/dist/adapters/http-agent-adapter.d.ts.map +1 -0
  8. package/dist/adapters/http-agent-adapter.js +13 -0
  9. package/dist/adapters/http-agent-adapter.js.map +1 -0
  10. package/dist/adapters/index.d.ts +9 -0
  11. package/dist/adapters/index.d.ts.map +1 -0
  12. package/dist/adapters/index.js +5 -0
  13. package/dist/adapters/index.js.map +1 -0
  14. package/dist/adapters/mcp-adapter.d.ts +19 -0
  15. package/dist/adapters/mcp-adapter.d.ts.map +1 -0
  16. package/dist/adapters/mcp-adapter.js +13 -0
  17. package/dist/adapters/mcp-adapter.js.map +1 -0
  18. package/dist/adapters/openclaw-adapter.d.ts +20 -0
  19. package/dist/adapters/openclaw-adapter.d.ts.map +1 -0
  20. package/dist/adapters/openclaw-adapter.js +13 -0
  21. package/dist/adapters/openclaw-adapter.js.map +1 -0
  22. package/dist/agent/agent-registry.d.ts +25 -0
  23. package/dist/agent/agent-registry.d.ts.map +1 -0
  24. package/dist/agent/agent-registry.js +42 -0
  25. package/dist/agent/agent-registry.js.map +1 -0
  26. package/dist/agent/agent-registry.test.d.ts +2 -0
  27. package/dist/agent/agent-registry.test.d.ts.map +1 -0
  28. package/dist/agent/agent-registry.test.js +55 -0
  29. package/dist/agent/agent-registry.test.js.map +1 -0
  30. package/dist/agent/agent-resolver.d.ts +41 -0
  31. package/dist/agent/agent-resolver.d.ts.map +1 -0
  32. package/dist/agent/agent-resolver.js +76 -0
  33. package/dist/agent/agent-resolver.js.map +1 -0
  34. package/dist/agent/agent-resolver.test.d.ts +2 -0
  35. package/dist/agent/agent-resolver.test.d.ts.map +1 -0
  36. package/dist/agent/agent-resolver.test.js +116 -0
  37. package/dist/agent/agent-resolver.test.js.map +1 -0
  38. package/dist/agent/delegate.d.ts +14 -0
  39. package/dist/agent/delegate.d.ts.map +1 -0
  40. package/dist/agent/delegate.js +35 -0
  41. package/dist/agent/delegate.js.map +1 -0
  42. package/dist/agent/delegate.test.d.ts +2 -0
  43. package/dist/agent/delegate.test.d.ts.map +1 -0
  44. package/dist/agent/delegate.test.js +64 -0
  45. package/dist/agent/delegate.test.js.map +1 -0
  46. package/dist/agent/execute-agent.d.ts +43 -0
  47. package/dist/agent/execute-agent.d.ts.map +1 -0
  48. package/dist/agent/execute-agent.js +43 -0
  49. package/dist/agent/execute-agent.js.map +1 -0
  50. package/dist/agent/index.d.ts +10 -0
  51. package/dist/agent/index.d.ts.map +1 -0
  52. package/dist/agent/index.js +6 -0
  53. package/dist/agent/index.js.map +1 -0
  54. package/dist/agent/prompt-builder.d.ts +16 -0
  55. package/dist/agent/prompt-builder.d.ts.map +1 -0
  56. package/dist/agent/prompt-builder.js +17 -0
  57. package/dist/agent/prompt-builder.js.map +1 -0
  58. package/dist/agent/prompt-builder.test.d.ts +2 -0
  59. package/dist/agent/prompt-builder.test.d.ts.map +1 -0
  60. package/dist/agent/prompt-builder.test.js +60 -0
  61. package/dist/agent/prompt-builder.test.js.map +1 -0
  62. package/dist/chat/chat-handler.d.ts +63 -0
  63. package/dist/chat/chat-handler.d.ts.map +1 -0
  64. package/dist/chat/chat-handler.js +74 -0
  65. package/dist/chat/chat-handler.js.map +1 -0
  66. package/dist/chat/chat-handler.test.d.ts +2 -0
  67. package/dist/chat/chat-handler.test.d.ts.map +1 -0
  68. package/dist/chat/chat-handler.test.js +112 -0
  69. package/dist/chat/chat-handler.test.js.map +1 -0
  70. package/dist/chat/index.d.ts +4 -0
  71. package/dist/chat/index.d.ts.map +1 -0
  72. package/dist/chat/index.js +3 -0
  73. package/dist/chat/index.js.map +1 -0
  74. package/dist/chat/message-utils.d.ts +26 -0
  75. package/dist/chat/message-utils.d.ts.map +1 -0
  76. package/dist/chat/message-utils.js +65 -0
  77. package/dist/chat/message-utils.js.map +1 -0
  78. package/dist/chat/message-utils.test.d.ts +2 -0
  79. package/dist/chat/message-utils.test.d.ts.map +1 -0
  80. package/dist/chat/message-utils.test.js +85 -0
  81. package/dist/chat/message-utils.test.js.map +1 -0
  82. package/dist/eval/eval-runner.d.ts +22 -0
  83. package/dist/eval/eval-runner.d.ts.map +1 -0
  84. package/dist/eval/eval-runner.js +56 -0
  85. package/dist/eval/eval-runner.js.map +1 -0
  86. package/dist/eval/eval-runner.test.d.ts +2 -0
  87. package/dist/eval/eval-runner.test.d.ts.map +1 -0
  88. package/dist/eval/eval-runner.test.js +89 -0
  89. package/dist/eval/eval-runner.test.js.map +1 -0
  90. package/dist/eval/index.d.ts +4 -0
  91. package/dist/eval/index.d.ts.map +1 -0
  92. package/dist/eval/index.js +3 -0
  93. package/dist/eval/index.js.map +1 -0
  94. package/dist/eval/scorers.d.ts +26 -0
  95. package/dist/eval/scorers.d.ts.map +1 -0
  96. package/dist/eval/scorers.js +76 -0
  97. package/dist/eval/scorers.js.map +1 -0
  98. package/dist/eval/scorers.test.d.ts +2 -0
  99. package/dist/eval/scorers.test.d.ts.map +1 -0
  100. package/dist/eval/scorers.test.js +91 -0
  101. package/dist/eval/scorers.test.js.map +1 -0
  102. package/dist/guardrail/guardrail-pipeline.d.ts +37 -0
  103. package/dist/guardrail/guardrail-pipeline.d.ts.map +1 -0
  104. package/dist/guardrail/guardrail-pipeline.js +63 -0
  105. package/dist/guardrail/guardrail-pipeline.js.map +1 -0
  106. package/dist/guardrail/guardrail-pipeline.test.d.ts +2 -0
  107. package/dist/guardrail/guardrail-pipeline.test.d.ts.map +1 -0
  108. package/dist/guardrail/guardrail-pipeline.test.js +74 -0
  109. package/dist/guardrail/guardrail-pipeline.test.js.map +1 -0
  110. package/dist/guardrail/index.d.ts +3 -0
  111. package/dist/guardrail/index.d.ts.map +1 -0
  112. package/dist/guardrail/index.js +2 -0
  113. package/dist/guardrail/index.js.map +1 -0
  114. package/dist/index.d.ts +46 -0
  115. package/dist/index.d.ts.map +1 -0
  116. package/dist/index.js +39 -0
  117. package/dist/index.js.map +1 -0
  118. package/dist/memory/index.d.ts +4 -0
  119. package/dist/memory/index.d.ts.map +1 -0
  120. package/dist/memory/index.js +3 -0
  121. package/dist/memory/index.js.map +1 -0
  122. package/dist/memory/memory-manager.d.ts +28 -0
  123. package/dist/memory/memory-manager.d.ts.map +1 -0
  124. package/dist/memory/memory-manager.js +34 -0
  125. package/dist/memory/memory-manager.js.map +1 -0
  126. package/dist/memory/memory-prompt.d.ts +10 -0
  127. package/dist/memory/memory-prompt.d.ts.map +1 -0
  128. package/dist/memory/memory-prompt.js +29 -0
  129. package/dist/memory/memory-prompt.js.map +1 -0
  130. package/dist/module/create-runtime.d.ts +65 -0
  131. package/dist/module/create-runtime.d.ts.map +1 -0
  132. package/dist/module/create-runtime.js +75 -0
  133. package/dist/module/create-runtime.js.map +1 -0
  134. package/dist/module/create-runtime.test.d.ts +2 -0
  135. package/dist/module/create-runtime.test.d.ts.map +1 -0
  136. package/dist/module/create-runtime.test.js +144 -0
  137. package/dist/module/create-runtime.test.js.map +1 -0
  138. package/dist/module/index.d.ts +5 -0
  139. package/dist/module/index.d.ts.map +1 -0
  140. package/dist/module/index.js +3 -0
  141. package/dist/module/index.js.map +1 -0
  142. package/dist/module/module-loader.d.ts +32 -0
  143. package/dist/module/module-loader.d.ts.map +1 -0
  144. package/dist/module/module-loader.js +123 -0
  145. package/dist/module/module-loader.js.map +1 -0
  146. package/dist/module/module-loader.test.d.ts +2 -0
  147. package/dist/module/module-loader.test.d.ts.map +1 -0
  148. package/dist/module/module-loader.test.js +96 -0
  149. package/dist/module/module-loader.test.js.map +1 -0
  150. package/dist/scoring/compute-score.d.ts +32 -0
  151. package/dist/scoring/compute-score.d.ts.map +1 -0
  152. package/dist/scoring/compute-score.js +54 -0
  153. package/dist/scoring/compute-score.js.map +1 -0
  154. package/dist/scoring/compute-score.test.d.ts +2 -0
  155. package/dist/scoring/compute-score.test.d.ts.map +1 -0
  156. package/dist/scoring/compute-score.test.js +99 -0
  157. package/dist/scoring/compute-score.test.js.map +1 -0
  158. package/dist/scoring/index.d.ts +3 -0
  159. package/dist/scoring/index.d.ts.map +1 -0
  160. package/dist/scoring/index.js +2 -0
  161. package/dist/scoring/index.js.map +1 -0
  162. package/dist/testing/in-memory-agent-store.d.ts +16 -0
  163. package/dist/testing/in-memory-agent-store.d.ts.map +1 -0
  164. package/dist/testing/in-memory-agent-store.js +37 -0
  165. package/dist/testing/in-memory-agent-store.js.map +1 -0
  166. package/dist/testing/in-memory-agent-store.test.d.ts +2 -0
  167. package/dist/testing/in-memory-agent-store.test.d.ts.map +1 -0
  168. package/dist/testing/in-memory-agent-store.test.js +111 -0
  169. package/dist/testing/in-memory-agent-store.test.js.map +1 -0
  170. package/dist/testing/in-memory-chat-store.d.ts +28 -0
  171. package/dist/testing/in-memory-chat-store.d.ts.map +1 -0
  172. package/dist/testing/in-memory-chat-store.js +87 -0
  173. package/dist/testing/in-memory-chat-store.js.map +1 -0
  174. package/dist/testing/in-memory-entity-store.d.ts +34 -0
  175. package/dist/testing/in-memory-entity-store.d.ts.map +1 -0
  176. package/dist/testing/in-memory-entity-store.js +134 -0
  177. package/dist/testing/in-memory-entity-store.js.map +1 -0
  178. package/dist/testing/in-memory-entity-store.test.d.ts +2 -0
  179. package/dist/testing/in-memory-entity-store.test.d.ts.map +1 -0
  180. package/dist/testing/in-memory-entity-store.test.js +341 -0
  181. package/dist/testing/in-memory-entity-store.test.js.map +1 -0
  182. package/dist/testing/in-memory-memory-store.d.ts +25 -0
  183. package/dist/testing/in-memory-memory-store.d.ts.map +1 -0
  184. package/dist/testing/in-memory-memory-store.js +59 -0
  185. package/dist/testing/in-memory-memory-store.js.map +1 -0
  186. package/dist/testing/in-memory-task-store.d.ts +20 -0
  187. package/dist/testing/in-memory-task-store.d.ts.map +1 -0
  188. package/dist/testing/in-memory-task-store.js +59 -0
  189. package/dist/testing/in-memory-task-store.js.map +1 -0
  190. package/dist/testing/in-memory-tenant-store.d.ts +16 -0
  191. package/dist/testing/in-memory-tenant-store.d.ts.map +1 -0
  192. package/dist/testing/in-memory-tenant-store.js +46 -0
  193. package/dist/testing/in-memory-tenant-store.js.map +1 -0
  194. package/dist/testing/in-memory-tool-store.d.ts +17 -0
  195. package/dist/testing/in-memory-tool-store.d.ts.map +1 -0
  196. package/dist/testing/in-memory-tool-store.js +39 -0
  197. package/dist/testing/in-memory-tool-store.js.map +1 -0
  198. package/dist/testing/index.d.ts +8 -0
  199. package/dist/testing/index.d.ts.map +1 -0
  200. package/dist/testing/index.js +8 -0
  201. package/dist/testing/index.js.map +1 -0
  202. package/dist/tool/ai-bridge.d.ts +13 -0
  203. package/dist/tool/ai-bridge.d.ts.map +1 -0
  204. package/dist/tool/ai-bridge.js +27 -0
  205. package/dist/tool/ai-bridge.js.map +1 -0
  206. package/dist/tool/ai-bridge.test.d.ts +2 -0
  207. package/dist/tool/ai-bridge.test.d.ts.map +1 -0
  208. package/dist/tool/ai-bridge.test.js +40 -0
  209. package/dist/tool/ai-bridge.test.js.map +1 -0
  210. package/dist/tool/entity-tools-factory.d.ts +7 -0
  211. package/dist/tool/entity-tools-factory.d.ts.map +1 -0
  212. package/dist/tool/entity-tools-factory.js +160 -0
  213. package/dist/tool/entity-tools-factory.js.map +1 -0
  214. package/dist/tool/entity-tools-factory.test.d.ts +2 -0
  215. package/dist/tool/entity-tools-factory.test.d.ts.map +1 -0
  216. package/dist/tool/entity-tools-factory.test.js +160 -0
  217. package/dist/tool/entity-tools-factory.test.js.map +1 -0
  218. package/dist/tool/index.d.ts +8 -0
  219. package/dist/tool/index.d.ts.map +1 -0
  220. package/dist/tool/index.js +6 -0
  221. package/dist/tool/index.js.map +1 -0
  222. package/dist/tool/resolve-tools.d.ts +28 -0
  223. package/dist/tool/resolve-tools.d.ts.map +1 -0
  224. package/dist/tool/resolve-tools.js +54 -0
  225. package/dist/tool/resolve-tools.js.map +1 -0
  226. package/dist/tool/resolve-tools.test.d.ts +2 -0
  227. package/dist/tool/resolve-tools.test.d.ts.map +1 -0
  228. package/dist/tool/resolve-tools.test.js +111 -0
  229. package/dist/tool/resolve-tools.test.js.map +1 -0
  230. package/dist/tool/tool-executor.d.ts +30 -0
  231. package/dist/tool/tool-executor.d.ts.map +1 -0
  232. package/dist/tool/tool-executor.js +64 -0
  233. package/dist/tool/tool-executor.js.map +1 -0
  234. package/dist/tool/tool-executor.test.d.ts +2 -0
  235. package/dist/tool/tool-executor.test.d.ts.map +1 -0
  236. package/dist/tool/tool-executor.test.js +105 -0
  237. package/dist/tool/tool-executor.test.js.map +1 -0
  238. package/dist/tool/tool-registry.d.ts +29 -0
  239. package/dist/tool/tool-registry.d.ts.map +1 -0
  240. package/dist/tool/tool-registry.js +59 -0
  241. package/dist/tool/tool-registry.js.map +1 -0
  242. package/dist/tool/tool-registry.test.d.ts +2 -0
  243. package/dist/tool/tool-registry.test.d.ts.map +1 -0
  244. package/dist/tool/tool-registry.test.js +76 -0
  245. package/dist/tool/tool-registry.test.js.map +1 -0
  246. package/dist/workflow/compile.d.ts +17 -0
  247. package/dist/workflow/compile.d.ts.map +1 -0
  248. package/dist/workflow/compile.js +83 -0
  249. package/dist/workflow/compile.js.map +1 -0
  250. package/dist/workflow/compile.test.d.ts +2 -0
  251. package/dist/workflow/compile.test.d.ts.map +1 -0
  252. package/dist/workflow/compile.test.js +154 -0
  253. package/dist/workflow/compile.test.js.map +1 -0
  254. package/dist/workflow/index.d.ts +4 -0
  255. package/dist/workflow/index.d.ts.map +1 -0
  256. package/dist/workflow/index.js +3 -0
  257. package/dist/workflow/index.js.map +1 -0
  258. package/dist/workflow/status.d.ts +21 -0
  259. package/dist/workflow/status.d.ts.map +1 -0
  260. package/dist/workflow/status.js +55 -0
  261. package/dist/workflow/status.js.map +1 -0
  262. package/dist/workflow/status.test.d.ts +2 -0
  263. package/dist/workflow/status.test.d.ts.map +1 -0
  264. package/dist/workflow/status.test.js +176 -0
  265. package/dist/workflow/status.test.js.map +1 -0
  266. package/package.json +100 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Exact match scorer: 1.0 if output === expected, 0.0 otherwise.
3
+ * Compares JSON stringified values for deep equality.
4
+ */
5
+ export const exactMatch = {
6
+ name: "exact-match",
7
+ description: "Returns 1.0 if output exactly matches expected, 0.0 otherwise.",
8
+ score: async ({ output, expected }) => {
9
+ if (expected === undefined)
10
+ return 0;
11
+ return JSON.stringify(output) === JSON.stringify(expected) ? 1.0 : 0.0;
12
+ },
13
+ };
14
+ /**
15
+ * Fuzzy text match scorer: compares strings case-insensitively after trimming.
16
+ * Returns a score based on substring containment.
17
+ * 1.0 = exact match, 0.5 = one contains the other, 0.0 = no match.
18
+ */
19
+ export const fuzzyMatch = {
20
+ name: "fuzzy-match",
21
+ description: "Case-insensitive text comparison with partial matching.",
22
+ score: async ({ output, expected }) => {
23
+ if (expected === undefined)
24
+ return 0;
25
+ const outputStr = String(output).toLowerCase().trim();
26
+ const expectedStr = String(expected).toLowerCase().trim();
27
+ if (outputStr === expectedStr)
28
+ return 1.0;
29
+ if (outputStr.includes(expectedStr) || expectedStr.includes(outputStr)) {
30
+ return 0.5;
31
+ }
32
+ return 0.0;
33
+ },
34
+ };
35
+ /**
36
+ * Numeric closeness scorer: returns 1.0 if values are equal,
37
+ * decreasing as the difference increases relative to expected.
38
+ * Uses formula: 1 - min(|output - expected| / |expected|, 1)
39
+ */
40
+ export const numericCloseness = {
41
+ name: "numeric-closeness",
42
+ description: "Scores numeric output by closeness to expected value.",
43
+ score: async ({ output, expected }) => {
44
+ const outNum = Number(output);
45
+ const expNum = Number(expected);
46
+ if (isNaN(outNum) || isNaN(expNum))
47
+ return 0;
48
+ if (expNum === 0)
49
+ return outNum === 0 ? 1.0 : 0.0;
50
+ const ratio = Math.abs(outNum - expNum) / Math.abs(expNum);
51
+ return Math.max(0, 1 - ratio);
52
+ },
53
+ };
54
+ /**
55
+ * Contains scorer: checks if the output string contains the expected string.
56
+ * Useful for checking if an agent mentioned specific keywords.
57
+ */
58
+ export const contains = {
59
+ name: "contains",
60
+ description: "Returns 1.0 if output contains expected as substring.",
61
+ score: async ({ output, expected }) => {
62
+ if (expected === undefined)
63
+ return 0;
64
+ const outputStr = String(output).toLowerCase();
65
+ const expectedStr = String(expected).toLowerCase();
66
+ return outputStr.includes(expectedStr) ? 1.0 : 0.0;
67
+ },
68
+ };
69
+ /** All built-in scorers. */
70
+ export const BUILT_IN_SCORERS = [
71
+ exactMatch,
72
+ fuzzyMatch,
73
+ numericCloseness,
74
+ contains,
75
+ ];
76
+ //# sourceMappingURL=scorers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorers.js","sourceRoot":"","sources":["../../src/eval/scorers.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAe;IACpC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,gEAAgE;IAC7E,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;QACpC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACzE,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAe;IACpC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,yDAAyD;IACtE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;QACpC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;Q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E,uDAAuD;IACpE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE;QACpC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACrD,CAAC;CACF,CAAC;AAEF,4BAA4B;AAC5B,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC5C,UAAU;IACV,UAAU;IACV,gBAAgB;IAChB,QAAQ;CACT,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=scorers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorers.test.d.ts","sourceRoot":"","sources":["../../src/eval/scorers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,91 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { exactMatch, fuzzyMatch, numericCloseness, contains } from './scorers';
3
+ describe('exactMatch', () => {
4
+ it('returns 1.0 for identical strings', async () => {
5
+ expect(await exactMatch.score({ input: '', output: 'hello', expected: 'hello' })).toBe(1.0);
6
+ });
7
+ it('returns 0.0 for different strings', async () => {
8
+ expect(await exactMatch.score({ input: '', output: 'hello', expected: 'world' })).toBe(0.0);
9
+ });
10
+ it('returns 1.0 for identical objects', async () => {
11
+ expect(await exactMatch.score({
12
+ input: '',
13
+ output: { a: 1 },
14
+ expected: { a: 1 },
15
+ })).toBe(1.0);
16
+ });
17
+ it('returns 0.0 when expected is undefined', async () => {
18
+ expect(await exactMatch.score({ input: '', output: 'test' })).toBe(0.0);
19
+ });
20
+ });
21
+ describe('fuzzyMatch', () => {
22
+ it('returns 1.0 for exact match (case insensitive)', async () => {
23
+ expect(await fuzzyMatch.score({ input: '', output: 'Hello', expected: 'hello' })).toBe(1.0);
24
+ });
25
+ it('returns 0.5 for substring containment', async () => {
26
+ expect(await fuzzyMatch.score({
27
+ input: '',
28
+ output: 'hello world',
29
+ expected: 'hello',
30
+ })).toBe(0.5);
31
+ });
32
+ it('returns 0.0 for no match', async () => {
33
+ expect(await fuzzyMatch.score({ input: '', output: 'abc', expected: 'xyz' })).toBe(0.0);
34
+ });
35
+ });
36
+ describe('numericCloseness', () => {
37
+ it('returns 1.0 for exact match', async () => {
38
+ expect(await numericCloseness.score({ input: '', output: 10, expected: 10 })).toBe(1.0);
39
+ });
40
+ it('returns close to 1 for small difference', async () => {
41
+ const score = await numericCloseness.score({
42
+ input: '',
43
+ output: 9.5,
44
+ expected: 10,
45
+ });
46
+ expect(score).toBeCloseTo(0.95, 2);
47
+ });
48
+ it('returns 0 for very large difference', async () => {
49
+ const score = await numericCloseness.score({
50
+ input: '',
51
+ output: 100,
52
+ expected: 10,
53
+ });
54
+ expect(score).toBe(0);
55
+ });
56
+ it('handles zero expected', async () => {
57
+ expect(await numericCloseness.score({ input: '', output: 0, expected: 0 })).toBe(1.0);
58
+ expect(await numericCloseness.score({ input: '', output: 5, expected: 0 })).toBe(0.0);
59
+ });
60
+ it('returns 0 for non-numeric values', async () => {
61
+ expect(await numericCloseness.score({
62
+ input: '',
63
+ output: 'abc',
64
+ expected: 10,
65
+ })).toBe(0);
66
+ });
67
+ });
68
+ describe('contains', () => {
69
+ it('returns 1.0 when output contains expected', async () => {
70
+ expect(await contains.score({
71
+ input: '',
72
+ output: 'The answer is 42',
73
+ expected: '42',
74
+ })).toBe(1.0);
75
+ });
76
+ it('returns 0.0 when output does not contain expected', async () => {
77
+ expect(await contains.score({
78
+ input: '',
79
+ output: 'no match here',
80
+ expected: 'xyz',
81
+ })).toBe(0.0);
82
+ });
83
+ it('is case insensitive', async () => {
84
+ expect(await contains.score({
85
+ input: '',
86
+ output: 'HELLO world',
87
+ expected: 'hello',
88
+ })).toBe(1.0);
89
+ });
90
+ });
91
+ //# sourceMappingURL=scorers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorers.test.js","sourceRoot":"","sources":["../../src/eval/scorers.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/E,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,CACJ,MAAM,UAAU,CAAC,KAAK,CAAC;YACrB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;YAChB,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;SACnB,CAAC,CACH,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KA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EAAE;YACT,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,EAAE;SACb,CAAC,CACH,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,CACJ,MAAM,QAAQ,CAAC,KAAK,CAAC;YACnB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,kBAAkB;YAC1B,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACjE,MAAM,CACJ,MAAM,QAAQ,CAAC,KAAK,CAAC;YACnB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,eAAe;YACvB,QAAQ,EAAE,KAAK;SAChB,CAAC,CACH,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,CACJ,MAAM,QAAQ,CAAC,KAAK,CAAC;YACnB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,aAAa;YACrB,QAAQ,EAAE,OAAO;SAClB,CAAC,CACH,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { GuardrailResult, InputGuardrail, OutputGuardrail, GuardrailConfig } from "@sprinterai/core";
2
+ /** Result of running all guardrails. */
3
+ export interface GuardrailPipelineResult {
4
+ passed: boolean;
5
+ results: Array<{
6
+ name: string;
7
+ result: GuardrailResult;
8
+ }>;
9
+ /** First failing guardrail's reason, if any. */
10
+ failReason?: string;
11
+ }
12
+ /**
13
+ * Run input guardrails on a message before sending to the agent.
14
+ * All guardrails must pass for the pipeline to pass.
15
+ */
16
+ export declare function runInputGuardrails(guardrails: InputGuardrail[], content: string, metadata?: Record<string, unknown>): Promise<GuardrailPipelineResult>;
17
+ /**
18
+ * Run output guardrails on agent output.
19
+ * All guardrails must pass for the pipeline to pass.
20
+ */
21
+ export declare function runOutputGuardrails(guardrails: OutputGuardrail[], content: string, metadata?: Record<string, unknown>): Promise<GuardrailPipelineResult>;
22
+ /**
23
+ * Run the full guardrail pipeline: input guardrails, then output guardrails.
24
+ * Returns combined results.
25
+ */
26
+ export declare function runGuardrails(config: GuardrailConfig, input: {
27
+ content: string;
28
+ metadata?: Record<string, unknown>;
29
+ }, output: {
30
+ content: string;
31
+ metadata?: Record<string, unknown>;
32
+ }): Promise<{
33
+ inputResult: GuardrailPipelineResult;
34
+ outputResult: GuardrailPipelineResult;
35
+ passed: boolean;
36
+ }>;
37
+ //# sourceMappingURL=guardrail-pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail-pipeline.d.ts","sourceRoot":"","sources":["../../src/guardrail/guardrail-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,wCAAwC;AACxC,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,eAAe,CAAC;KACzB,CAAC,CAAC;IACH,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,cAAc,EAAE,EAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,uBAAuB,CAAC,CAiBlC;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,eAAe,EAAE,EAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,uBAAuB,CAAC,CAiBlC;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAC9D,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC9D,OAAO,CAAC;IACT,WAAW,EAAE,uBAAuB,CAAC;IACrC,YAAY,EAAE,uBAAuB,CAAC;IACtC,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC,CA8BD"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Run input guardrails on a message before sending to the agent.
3
+ * All guardrails must pass for the pipeline to pass.
4
+ */
5
+ export async function runInputGuardrails(guardrails, content, metadata) {
6
+ const results = [];
7
+ for (const guard of guardrails) {
8
+ const result = await guard.check({ content, metadata });
9
+ results.push({ name: guard.name, result });
10
+ if (!result.passed) {
11
+ return {
12
+ passed: false,
13
+ results,
14
+ failReason: result.reason ?? `Input guardrail "${guard.name}" failed`,
15
+ };
16
+ }
17
+ }
18
+ return { passed: true, results };
19
+ }
20
+ /**
21
+ * Run output guardrails on agent output.
22
+ * All guardrails must pass for the pipeline to pass.
23
+ */
24
+ export async function runOutputGuardrails(guardrails, content, metadata) {
25
+ const results = [];
26
+ for (const guard of guardrails) {
27
+ const result = await guard.check({ content, metadata });
28
+ results.push({ name: guard.name, result });
29
+ if (!result.passed) {
30
+ return {
31
+ passed: false,
32
+ results,
33
+ failReason: result.reason ?? `Output guardrail "${guard.name}" failed`,
34
+ };
35
+ }
36
+ }
37
+ return { passed: true, results };
38
+ }
39
+ /**
40
+ * Run the full guardrail pipeline: input guardrails, then output guardrails.
41
+ * Returns combined results.
42
+ */
43
+ export async function runGuardrails(config, input, output) {
44
+ const inputResult = config.inputGuardrails
45
+ ? await runInputGuardrails(config.inputGuardrails, input.content, input.metadata)
46
+ : { passed: true, results: [] };
47
+ if (!inputResult.passed) {
48
+ return {
49
+ inputResult,
50
+ outputResult: { passed: true, results: [] },
51
+ passed: false,
52
+ };
53
+ }
54
+ const outputResult = config.outputGuardrails
55
+ ? await runOutputGuardrails(config.outputGuardrails, output.content, output.metadata)
56
+ : { passed: true, results: [] };
57
+ return {
58
+ inputResult,
59
+ outputResult,
60
+ passed: inputResult.passed && outputResult.passed,
61
+ };
62
+ }
63
+ //# sourceMappingURL=guardrail-pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail-pipeline.js","sourceRoot":"","sources":["../../src/guardrail/guardrail-pipeline.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,UAA4B,EAC5B,OAAe,EACf,QAAkC;IAElC,MAAM,OAAO,GAAuC,EAAE,CAAC;IAEvD,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO;gBACL,MAAM,EAAE,KAAK;gBACb,OAAO;gBACP,UAAU,EAAE,MAAM,CAAC,MAAM,IAAI,oBAAoB,KAAK,CAAC,IAAI,UAAU;aACtE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAA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AAC,gBAAgB;QAC1C,CAAC,CAAC,MAAM,mBAAmB,CACvB,MAAM,CAAC,gBAAgB,EACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,CAChB;QACH,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAElC,OAAO;QACL,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM;KAClD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=guardrail-pipeline.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail-pipeline.test.d.ts","sourceRoot":"","sources":["../../src/guardrail/guardrail-pipeline.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,74 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { runInputGuardrails, runOutputGuardrails, runGuardrails } from './guardrail-pipeline';
3
+ const passingGuard = {
4
+ name: 'pass-guard',
5
+ check: async () => ({ passed: true }),
6
+ };
7
+ const failingGuard = {
8
+ name: 'fail-guard',
9
+ check: async () => ({ passed: false, reason: 'Content blocked' }),
10
+ };
11
+ const lengthGuard = {
12
+ name: 'length-guard',
13
+ description: 'Checks output is not too long',
14
+ check: async ({ content }) => ({
15
+ passed: content.length <= 100,
16
+ reason: content.length > 100 ? 'Output too long' : undefined,
17
+ }),
18
+ };
19
+ describe('runInputGuardrails', () => {
20
+ it('passes when all guardrails pass', async () => {
21
+ const result = await runInputGuardrails([passingGuard, passingGuard], 'hello');
22
+ expect(result.passed).toBe(true);
23
+ expect(result.results).toHaveLength(2);
24
+ });
25
+ it('fails on first failing guardrail', async () => {
26
+ const result = await runInputGuardrails([passingGuard, failingGuard], 'hello');
27
+ expect(result.passed).toBe(false);
28
+ expect(result.failReason).toBe('Content blocked');
29
+ expect(result.results).toHaveLength(2);
30
+ });
31
+ it('handles empty guardrail list', async () => {
32
+ const result = await runInputGuardrails([], 'hello');
33
+ expect(result.passed).toBe(true);
34
+ expect(result.results).toHaveLength(0);
35
+ });
36
+ });
37
+ describe('runOutputGuardrails', () => {
38
+ it('passes when output is short enough', async () => {
39
+ const result = await runOutputGuardrails([lengthGuard], 'short');
40
+ expect(result.passed).toBe(true);
41
+ });
42
+ it('fails when output is too long', async () => {
43
+ const longContent = 'a'.repeat(101);
44
+ const result = await runOutputGuardrails([lengthGuard], longContent);
45
+ expect(result.passed).toBe(false);
46
+ expect(result.failReason).toBe('Output too long');
47
+ });
48
+ });
49
+ describe('runGuardrails', () => {
50
+ it('runs both input and output guardrails', async () => {
51
+ const result = await runGuardrails({
52
+ inputGuardrails: [passingGuard],
53
+ outputGuardrails: [lengthGuard],
54
+ }, { content: 'input' }, { content: 'output' });
55
+ expect(result.passed).toBe(true);
56
+ expect(result.inputResult.passed).toBe(true);
57
+ expect(result.outputResult.passed).toBe(true);
58
+ });
59
+ it('short-circuits when input guardrail fails', async () => {
60
+ const result = await runGuardrails({
61
+ inputGuardrails: [failingGuard],
62
+ outputGuardrails: [lengthGuard],
63
+ }, { content: 'blocked' }, { content: 'output' });
64
+ expect(result.passed).toBe(false);
65
+ expect(result.inputResult.passed).toBe(false);
66
+ // Output guardrails were not run
67
+ expect(result.outputResult.results).toHaveLength(0);
68
+ });
69
+ it('handles no guardrails configured', async () => {
70
+ const result = await runGuardrails({}, { content: 'input' }, { content: 'output' });
71
+ expect(result.passed).toBe(true);
72
+ });
73
+ });
74
+ //# sourceMappingURL=guardrail-pipeline.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail-pipeline.test.js","sourceRoot":"","sources":["../../src/guardrail/guardrail-pipeline.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE9F,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E,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { runInputGuardrails, runOutputGuardrails, runGuardrails, } from "./guardrail-pipeline";
2
+ export type { GuardrailPipelineResult } from "./guardrail-pipeline";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guardrail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { runInputGuardrails, runOutputGuardrails, runGuardrails, } from "./guardrail-pipeline";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guardrail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,46 @@
1
+ export { InMemoryEntityStore, InMemoryAgentStore, InMemoryChatStore, InMemoryTenantStore, InMemoryToolStore, InMemoryTaskStore, InMemoryMemoryStore, } from "./testing";
2
+ export { ToolRegistry } from "./tool";
3
+ export { toAITool, toAIToolSet } from "./tool";
4
+ export { executeTool } from "./tool";
5
+ export type { ExecuteToolOptions, ExecuteToolResult } from "./tool";
6
+ export { createEntityTools } from "./tool";
7
+ export { resolveAgentTools } from "./tool";
8
+ export type { ResolveToolsOptions } from "./tool";
9
+ export { buildAgentPrompt } from "./agent";
10
+ export type { PromptSection } from "./agent";
11
+ export { AgentRegistry } from "./agent";
12
+ export { resolveAgent } from "./agent";
13
+ export type { ResolvedAgent, ResolveAgentOptions } from "./agent";
14
+ export { executeAgentStream, executeAgentGenerate } from "./agent";
15
+ export type { ExecuteAgentConfig, ExecuteAgentResult, AgentStreamResult, } from "./agent";
16
+ export { createDelegateToAgentTool } from "./agent";
17
+ export type { CreateDelegateToolOptions } from "./agent";
18
+ export { createChatRouteHandler } from "./chat";
19
+ export type { ChatHandlerConfig, ChatRequest, ChatHandler, ChatContext, } from "./chat";
20
+ export { validateMessage, sanitizeContent, extractTextFromParts, toAIMessages, } from "./chat";
21
+ export { compileEntityWorkflowDefinition, getWorkflowLayers } from "./workflow";
22
+ export { computeWorkflowProgress, deriveWorkflowStatus } from "./workflow";
23
+ export type { WorkflowProgress } from "./workflow";
24
+ export { computeResponseScore, mean, median, min, max, aggregateScores, } from "./scoring";
25
+ export type { ScoreAggregation } from "./scoring";
26
+ export { loadModules } from "./module";
27
+ export type { LoadedModules } from "./module";
28
+ export { createPlatformRuntime } from "./module";
29
+ export type { PlatformRuntimeConfig, PlatformRuntime, RuntimeStores, } from "./module";
30
+ export { discoverMCPTools } from "./adapters";
31
+ export type { MCPAdapterConfig } from "./adapters";
32
+ export { createA2AAgent } from "./adapters";
33
+ export type { A2AAdapterConfig } from "./adapters";
34
+ export { createOpenClawModel } from "./adapters";
35
+ export type { OpenClawAdapterConfig } from "./adapters";
36
+ export { createHTTPAgent } from "./adapters";
37
+ export type { HTTPAgentAdapterConfig } from "./adapters";
38
+ export { exactMatch, fuzzyMatch, numericCloseness, contains, BUILT_IN_SCORERS, } from "./eval";
39
+ export { runEval } from "./eval";
40
+ export type { EvalTarget, RunEvalOptions } from "./eval";
41
+ export { loadMemories } from "./memory";
42
+ export type { MemoryLoadContext, LoadedMemories } from "./memory";
43
+ export { buildMemoryPrompt } from "./memory";
44
+ export { runInputGuardrails, runOutputGuardrails, runGuardrails, } from "./guardrail";
45
+ export type { GuardrailPipelineResult } from "./guardrail";
46
+ //# s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AACjC,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ // ─── Testing (InMemory Stores) ──────────────────────────────
2
+ export { InMemoryEntityStore, InMemoryAgentStore, InMemoryChatStore, InMemoryTenantStore, InMemoryToolStore, InMemoryTaskStore, InMemoryMemoryStore, } from "./testing";
3
+ // ─── Tool System ────────────────────────────────────────────
4
+ export { ToolRegistry } from "./tool";
5
+ export { toAITool, toAIToolSet } from "./tool";
6
+ export { executeTool } from "./tool";
7
+ export { createEntityTools } from "./tool";
8
+ export { resolveAgentTools } from "./tool";
9
+ // ─── Agent System ───────────────────────────────────────────
10
+ export { buildAgentPrompt } from "./agent";
11
+ export { AgentRegistry } from "./agent";
12
+ export { resolveAgent } from "./agent";
13
+ export { executeAgentStream, executeAgentGenerate } from "./agent";
14
+ export { createDelegateToAgentTool } from "./agent";
15
+ // ─── Chat ───────────────────────────────────────────────────
16
+ export { createChatRouteHandler } from "./chat";
17
+ export { validateMessage, sanitizeContent, extractTextFromParts, toAIMessages, } from "./chat";
18
+ // ─── Workflow ───────────────────────────────────────────────
19
+ export { compileEntityWorkflowDefinition, getWorkflowLayers } from "./workflow";
20
+ export { computeWorkflowProgress, deriveWorkflowStatus } from "./workflow";
21
+ // ─── Scoring ────────────────────────────────────────────────
22
+ export { computeResponseScore, mean, median, min, max, aggregateScores, } from "./scoring";
23
+ // ─── Module System ──────────────────────────────────────────
24
+ export { loadModules } from "./module";
25
+ export { createPlatformRuntime } from "./module";
26
+ // ─── Adapters ───────────────────────────────────────────────
27
+ export { discoverMCPTools } from "./adapters";
28
+ export { createA2AAgent } from "./adapters";
29
+ export { createOpenClawModel } from "./adapters";
30
+ export { createHTTPAgent } from "./adapters";
31
+ // ─── Eval ───────────────────────────────────────────────────
32
+ export { exactMatch, fuzzyMatch, numericCloseness, contains, BUILT_IN_SCORERS, } from "./eval";
33
+ export { runEval } from "./eval";
34
+ // ─── Memory ─────────────────────────────────────────────────
35
+ export { loadMemories } from "./memory";
36
+ export { buildMemoryPrompt } from "./memory";
37
+ // ─── Guardrails ─────────────────────────────────────────────
38
+ export { runInputGuardrails, runOutputGuardrails, runGuardrails, } from "./guardrail";
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAEnB,+DAA+D;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAG3C,+DAA+D;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAMnE,OAAO,EAAE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oadedMemories } from "./memory-manager";
3
+ export { buildMemoryPrompt } from "./memory-prompt";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { loadMemories } from "./memory-manager";
2
+ export { buildMemoryPrompt } from "./memory-prompt";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { MemoryStore, UserMemory, AgentMemoryConfig } from "@sprinterai/core";
2
+ /** Context for memory loading. */
3
+ export interface MemoryLoadContext {
4
+ userId: string;
5
+ chatId?: string;
6
+ currentQuery?: string;
7
+ config?: AgentMemoryConfig;
8
+ }
9
+ /** All memories loaded for prompt injection. */
10
+ export interface LoadedMemories {
11
+ /** Explicit user memories (corrections, preferences). */
12
+ userMemories: UserMemory[];
13
+ /** Semantically similar past memories. */
14
+ semanticMemories: UserMemory[];
15
+ }
16
+ /**
17
+ * Load memories from the store for prompt injection.
18
+ *
19
+ * 4-layer memory system:
20
+ * 1. History — conversation history (handled by chat, not here)
21
+ * 2. Semantic — vector-indexed long-term memory
22
+ * 3. Working — ephemeral scratchpad (handled by caller)
23
+ * 4. Context — tenant-level corrections (handled by caller)
24
+ *
25
+ * This function handles layers 1 (user memories) and 2 (semantic search).
26
+ */
27
+ export declare function loadMemories(store: MemoryStore, context: MemoryLoadContext): Promise<LoadedMemories>;
28
+ //# sourceMappingURL=memory-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-manager.d.ts","sourceRoot":"","sources":["../../src/memory/memory-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAG1B,kCAAkC;AAClC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,YAAY,EAAE,UAAU,EAAE,CAAC;IAC3B,0CAA0C;IAC1C,gBAAgB,EAAE,UAAU,EAAE,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,cAAc,CAAC,CAwBzB"}
@@ -0,0 +1,34 @@
1
+ import { MAX_MEMORIES_FOR_PROMPT } from "@sprinterai/core";
2
+ /**
3
+ * Load memories from the store for prompt injection.
4
+ *
5
+ * 4-layer memory system:
6
+ * 1. History — conversation history (handled by chat, not here)
7
+ * 2. Semantic — vector-indexed long-term memory
8
+ * 3. Working — ephemeral scratchpad (handled by caller)
9
+ * 4. Context — tenant-level corrections (handled by caller)
10
+ *
11
+ * This function handles layers 1 (user memories) and 2 (semantic search).
12
+ */
13
+ export async function loadMemories(store, context) {
14
+ const config = context.config ?? {
15
+ semanticEnabled: true,
16
+ semanticTopK: 5,
17
+ };
18
+ const limit = MAX_MEMORIES_FOR_PROMPT;
19
+ // Load user's explicit memories
20
+ const userMemories = await store.getUserMemories(context.userId, {
21
+ limit,
22
+ source: "user",
23
+ });
24
+ // Load semantic memories if enabled and we have a query
25
+ let semanticMemories = [];
26
+ if (config.semanticEnabled && context.currentQuery) {
27
+ semanticMemories = await store.searchSimilarMessages(context.currentQuery, {
28
+ userId: context.userId,
29
+ limit: config.semanticTopK ?? 5,
30
+ });
31
+ }
32
+ return { userMemories, semanticMemories };
33
+ }
34
+ //# sourceMappingURL=memory-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-manager.js","sourceRoot":"","sources":["../../src/memory/memory-manager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAkB3D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAkB,EAClB,OAA0B;IAE1B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI;QAC/B,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,CAAC;KAChB,CAAC;IAEF,MAAM,KAAK,GAAG,uBAAuB,CAAC;IAEtC,gCAAgC;IAChC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE;QAC/D,KAAK;QACL,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IAEH,wDAAwD;IACxD,IAAI,gBAAgB,GAAiB,EAAE,CAAC;IACxC,IAAI,MAAM,CAAC,eAAe,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACnD,gBAAgB,GAAG,MAAM,KAAK,CAAC,qBAAqB,CAAC,OAAO,CAAC,YAAY,EAAE;YACzE,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,KAAK,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC;SAChC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { UserMemory } from '@sprinterai/core';
2
+ import type { PromptSection } from '../agent/prompt-builder';
3
+ /**
4
+ * Build a prompt section from loaded memories.
5
+ *
6
+ * Formats memories as a bullet list for injection into the system prompt.
7
+ * Returns a PromptSection that can be composed with other sections.
8
+ */
9
+ export declare function buildMemoryPrompt(userMemories: UserMemory[], semanticMemories: UserMemory[]): PromptSection | null;
10
+ //# sourceMappingURL=memory-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-prompt.d.ts","sourceRoot":"","sources":["../../src/memory/memory-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,UAAU,EAAE,EAC1B,gBAAgB,EAAE,UAAU,EAAE,GAC7B,aAAa,GAAG,IAAI,CAwBtB"}