@warlock.js/ai 4.2.10 → 4.3.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 (427) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/cjs/index.cjs +10151 -4625
  3. package/cjs/index.cjs.map +1 -1
  4. package/cjs/magic-string.es-BtxW4VqG.cjs +1015 -0
  5. package/cjs/magic-string.es-BtxW4VqG.cjs.map +1 -0
  6. package/cjs/matcher-logic-SBnzYohQ.cjs +217 -0
  7. package/cjs/matcher-logic-SBnzYohQ.cjs.map +1 -0
  8. package/cjs/matchers-BBh3gyB-.cjs +13739 -0
  9. package/cjs/matchers-BBh3gyB-.cjs.map +1 -0
  10. package/esm/agent/agent-config.type.d.mts +19 -6
  11. package/esm/agent/agent-config.type.d.mts.map +1 -1
  12. package/esm/agent/agent.d.mts.map +1 -1
  13. package/esm/agent/agent.mjs +17 -6
  14. package/esm/agent/agent.mjs.map +1 -1
  15. package/esm/agent/index.d.mts +2 -1
  16. package/esm/agent/index.mjs +1 -0
  17. package/esm/agent/spawn-sub-agent.d.mts +87 -0
  18. package/esm/agent/spawn-sub-agent.d.mts.map +1 -0
  19. package/esm/agent/spawn-sub-agent.mjs +68 -0
  20. package/esm/agent/spawn-sub-agent.mjs.map +1 -0
  21. package/esm/ai.d.mts +58 -3
  22. package/esm/ai.d.mts.map +1 -1
  23. package/esm/ai.mjs +58 -3
  24. package/esm/ai.mjs.map +1 -1
  25. package/esm/batch/batch.d.mts +43 -0
  26. package/esm/batch/batch.d.mts.map +1 -0
  27. package/esm/batch/batch.mjs +179 -0
  28. package/esm/batch/batch.mjs.map +1 -0
  29. package/esm/batch/batch.type.d.mts +144 -0
  30. package/esm/batch/batch.type.d.mts.map +1 -0
  31. package/esm/batch/index.mjs +3 -0
  32. package/esm/batch/run-batch-item.mjs +100 -0
  33. package/esm/batch/run-batch-item.mjs.map +1 -0
  34. package/esm/batch/run-with-concurrency.mjs +39 -0
  35. package/esm/batch/run-with-concurrency.mjs.map +1 -0
  36. package/esm/checkpoint/index.d.mts +3 -0
  37. package/esm/checkpoint/memory.d.mts +21 -0
  38. package/esm/checkpoint/memory.d.mts.map +1 -0
  39. package/esm/checkpoint/memory.mjs +0 -0
  40. package/esm/checkpoint/memory.mjs.map +1 -0
  41. package/esm/checkpoint/pg.d.mts +37 -0
  42. package/esm/checkpoint/pg.d.mts.map +1 -0
  43. package/esm/checkpoint/pg.mjs +265 -0
  44. package/esm/checkpoint/pg.mjs.map +1 -0
  45. package/esm/checkpoint/redis.d.mts +39 -0
  46. package/esm/checkpoint/redis.d.mts.map +1 -0
  47. package/esm/checkpoint/redis.mjs +200 -0
  48. package/esm/checkpoint/redis.mjs.map +1 -0
  49. package/esm/config.d.mts +61 -14
  50. package/esm/config.d.mts.map +1 -1
  51. package/esm/config.mjs +25 -6
  52. package/esm/config.mjs.map +1 -1
  53. package/esm/contracts/agent/agent.contract.d.mts +43 -0
  54. package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
  55. package/esm/contracts/agent/eval.type.d.mts +143 -0
  56. package/esm/contracts/agent/eval.type.d.mts.map +1 -0
  57. package/esm/contracts/agent/index.d.mts +1 -0
  58. package/esm/contracts/events/supervisor-events.type.d.mts +3 -3
  59. package/esm/contracts/fallback-model.contract.d.mts +65 -0
  60. package/esm/contracts/fallback-model.contract.d.mts.map +1 -0
  61. package/esm/contracts/index.d.mts +32 -12
  62. package/esm/contracts/memory/index.d.mts +4 -0
  63. package/esm/contracts/memory/memory-config.type.d.mts +150 -0
  64. package/esm/contracts/memory/memory-config.type.d.mts.map +1 -0
  65. package/esm/contracts/memory/memory-item.type.d.mts +64 -0
  66. package/esm/contracts/memory/memory-item.type.d.mts.map +1 -0
  67. package/esm/contracts/memory/memory.contract.d.mts +87 -0
  68. package/esm/contracts/memory/memory.contract.d.mts.map +1 -0
  69. package/esm/contracts/memory/recall-options.type.d.mts +33 -0
  70. package/esm/contracts/memory/recall-options.type.d.mts.map +1 -0
  71. package/esm/contracts/middleware/index.d.mts +2 -2
  72. package/esm/contracts/middleware/middleware-context.type.d.mts +42 -2
  73. package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
  74. package/esm/contracts/middleware/middleware.contract.d.mts +46 -2
  75. package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
  76. package/esm/contracts/model.contract.d.mts +63 -2
  77. package/esm/contracts/model.contract.d.mts.map +1 -1
  78. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +91 -0
  79. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -0
  80. package/esm/contracts/orchestrator/index.d.mts +8 -0
  81. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +43 -0
  82. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -0
  83. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +170 -0
  84. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -0
  85. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +118 -0
  86. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -0
  87. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +44 -0
  88. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -0
  89. package/esm/contracts/orchestrator/orchestrator.contract.d.mts +129 -0
  90. package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -0
  91. package/esm/contracts/orchestrator/session.contract.d.mts +26 -0
  92. package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -0
  93. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +89 -0
  94. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -0
  95. package/esm/contracts/planner/index.d.mts +6 -0
  96. package/esm/contracts/planner/planner-capability.type.d.mts +39 -0
  97. package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -0
  98. package/esm/contracts/planner/planner-config.type.d.mts +78 -0
  99. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -0
  100. package/esm/contracts/planner/planner-execute-options.type.d.mts +43 -0
  101. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -0
  102. package/esm/contracts/planner/planner-plan.type.d.mts +48 -0
  103. package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -0
  104. package/esm/contracts/planner/planner-result.type.d.mts +82 -0
  105. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -0
  106. package/esm/contracts/planner/planner.contract.d.mts +60 -0
  107. package/esm/contracts/planner/planner.contract.d.mts.map +1 -0
  108. package/esm/contracts/result/base-report.type.d.mts +7 -2
  109. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  110. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  111. package/esm/contracts/result/index.d.mts +2 -1
  112. package/esm/contracts/result/model-pricing.type.d.mts +10 -0
  113. package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
  114. package/esm/contracts/result/orchestrator-result.type.d.mts +139 -0
  115. package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -0
  116. package/esm/contracts/result/session-send-result.type.d.mts +12 -3
  117. package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
  118. package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
  119. package/esm/contracts/result/usage.type.d.mts +24 -0
  120. package/esm/contracts/result/usage.type.d.mts.map +1 -1
  121. package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
  122. package/esm/contracts/supervisor/dispatch-context.type.d.mts +3 -3
  123. package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
  124. package/esm/contracts/supervisor/index.d.mts +5 -5
  125. package/esm/contracts/supervisor/route-context.type.d.mts +2 -2
  126. package/esm/contracts/supervisor/supervisor-config.type.d.mts +55 -13
  127. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  128. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
  129. package/esm/contracts/supervisor/supervisor.contract.d.mts +9 -2
  130. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
  131. package/esm/contracts/workflow/index.d.mts +2 -2
  132. package/esm/contracts/workflow/workflow.contract.d.mts +28 -7
  133. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  134. package/esm/errors/error-code.type.d.mts +1 -1
  135. package/esm/errors/index.d.mts +7 -0
  136. package/esm/errors/index.mjs +7 -0
  137. package/esm/errors/orchestrator-cancelled-error.d.mts +32 -0
  138. package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -0
  139. package/esm/errors/orchestrator-cancelled-error.mjs +31 -0
  140. package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -0
  141. package/esm/errors/orchestrator-config-error.d.mts +26 -0
  142. package/esm/errors/orchestrator-config-error.d.mts.map +1 -0
  143. package/esm/errors/orchestrator-config-error.mjs +30 -0
  144. package/esm/errors/orchestrator-config-error.mjs.map +1 -0
  145. package/esm/errors/orchestrator-drift-error.d.mts +38 -0
  146. package/esm/errors/orchestrator-drift-error.d.mts.map +1 -0
  147. package/esm/errors/orchestrator-drift-error.mjs +37 -0
  148. package/esm/errors/orchestrator-drift-error.mjs.map +1 -0
  149. package/esm/errors/orchestrator-failed-error.d.mts +33 -0
  150. package/esm/errors/orchestrator-failed-error.d.mts.map +1 -0
  151. package/esm/errors/orchestrator-failed-error.mjs +36 -0
  152. package/esm/errors/orchestrator-failed-error.mjs.map +1 -0
  153. package/esm/errors/planner-cancelled-error.d.mts +33 -0
  154. package/esm/errors/planner-cancelled-error.d.mts.map +1 -0
  155. package/esm/errors/planner-cancelled-error.mjs +29 -0
  156. package/esm/errors/planner-cancelled-error.mjs.map +1 -0
  157. package/esm/errors/planner-failed-error.d.mts +40 -0
  158. package/esm/errors/planner-failed-error.d.mts.map +1 -0
  159. package/esm/errors/planner-failed-error.mjs +37 -0
  160. package/esm/errors/planner-failed-error.mjs.map +1 -0
  161. package/esm/errors/planner-plan-invalid-error.d.mts +21 -0
  162. package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -0
  163. package/esm/errors/planner-plan-invalid-error.mjs +25 -0
  164. package/esm/errors/planner-plan-invalid-error.mjs.map +1 -0
  165. package/esm/eval/eval-runner.d.mts +17 -0
  166. package/esm/eval/eval-runner.d.mts.map +1 -0
  167. package/esm/eval/eval-runner.mjs +121 -0
  168. package/esm/eval/eval-runner.mjs.map +1 -0
  169. package/esm/eval/index.d.mts +29 -0
  170. package/esm/eval/index.d.mts.map +1 -0
  171. package/esm/eval/index.mjs +30 -0
  172. package/esm/eval/index.mjs.map +1 -0
  173. package/esm/eval/judge-scorer.d.mts +21 -0
  174. package/esm/eval/judge-scorer.d.mts.map +1 -0
  175. package/esm/eval/judge-scorer.mjs +87 -0
  176. package/esm/eval/judge-scorer.mjs.map +1 -0
  177. package/esm/eval/scorers.d.mts +50 -0
  178. package/esm/eval/scorers.d.mts.map +1 -0
  179. package/esm/eval/scorers.mjs +101 -0
  180. package/esm/eval/scorers.mjs.map +1 -0
  181. package/esm/index.d.mts +95 -30
  182. package/esm/index.mjs +66 -22
  183. package/esm/memory/derive-id.mjs +24 -0
  184. package/esm/memory/derive-id.mjs.map +1 -0
  185. package/esm/memory/episodic-memory.mjs +106 -0
  186. package/esm/memory/episodic-memory.mjs.map +1 -0
  187. package/esm/memory/index.d.mts +5 -0
  188. package/esm/memory/memory.d.mts +42 -0
  189. package/esm/memory/memory.d.mts.map +1 -0
  190. package/esm/memory/memory.mjs +166 -0
  191. package/esm/memory/memory.mjs.map +1 -0
  192. package/esm/memory/procedural-memory.mjs +103 -0
  193. package/esm/memory/procedural-memory.mjs.map +1 -0
  194. package/esm/memory/semantic-memory.mjs +80 -0
  195. package/esm/memory/semantic-memory.mjs.map +1 -0
  196. package/esm/memory/working-memory.mjs +62 -0
  197. package/esm/memory/working-memory.mjs.map +1 -0
  198. package/esm/middleware/builtins/budget-contract.type.d.mts +126 -0
  199. package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -0
  200. package/esm/middleware/builtins/budget.d.mts +71 -1
  201. package/esm/middleware/builtins/budget.d.mts.map +1 -1
  202. package/esm/middleware/builtins/budget.mjs +119 -4
  203. package/esm/middleware/builtins/budget.mjs.map +1 -1
  204. package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
  205. package/esm/middleware/index.d.mts +2 -1
  206. package/esm/middleware/index.mjs +1 -1
  207. package/esm/middleware/pipeline.d.mts +9 -6
  208. package/esm/middleware/pipeline.d.mts.map +1 -1
  209. package/esm/middleware/pipeline.mjs.map +1 -1
  210. package/esm/mock/index.d.mts +1 -0
  211. package/esm/mock/index.mjs +1 -0
  212. package/esm/mock/mock-router.d.mts +63 -0
  213. package/esm/mock/mock-router.d.mts.map +1 -0
  214. package/esm/mock/mock-router.mjs +58 -0
  215. package/esm/mock/mock-router.mjs.map +1 -0
  216. package/esm/model/fallback-model.d.mts +45 -0
  217. package/esm/model/fallback-model.d.mts.map +1 -0
  218. package/esm/model/fallback-model.mjs +218 -0
  219. package/esm/model/fallback-model.mjs.map +1 -0
  220. package/esm/model/index.d.mts +2 -0
  221. package/esm/model/index.mjs +3 -0
  222. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  223. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  224. package/esm/node_modules/@vitest/expect/dist/index.mjs +1473 -0
  225. package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
  226. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +888 -0
  227. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
  228. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1533 -0
  229. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -0
  230. package/esm/node_modules/@vitest/runner/dist/index.mjs +3 -0
  231. package/esm/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  232. package/esm/node_modules/@vitest/snapshot/dist/index.mjs +922 -0
  233. package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
  234. package/esm/node_modules/@vitest/spy/dist/index.mjs +386 -0
  235. package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
  236. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +82 -0
  237. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -0
  238. package/esm/node_modules/@vitest/utils/dist/diff.mjs +1357 -0
  239. package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
  240. package/esm/node_modules/@vitest/utils/dist/display.mjs +559 -0
  241. package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -0
  242. package/esm/node_modules/@vitest/utils/dist/error.mjs +38 -0
  243. package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
  244. package/esm/node_modules/@vitest/utils/dist/helpers.mjs +181 -0
  245. package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
  246. package/esm/node_modules/@vitest/utils/dist/offset.mjs +27 -0
  247. package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -0
  248. package/esm/node_modules/@vitest/utils/dist/serialize.mjs +77 -0
  249. package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -0
  250. package/esm/node_modules/@vitest/utils/dist/source-map.mjs +374 -0
  251. package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
  252. package/esm/node_modules/@vitest/utils/dist/timers.mjs +37 -0
  253. package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -0
  254. package/esm/node_modules/chai/index.mjs +2973 -0
  255. package/esm/node_modules/chai/index.mjs.map +1 -0
  256. package/esm/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  257. package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  258. package/esm/node_modules/tinyrainbow/dist/index.mjs +87 -0
  259. package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -0
  260. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +6 -0
  261. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -0
  262. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +52 -0
  263. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -0
  264. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +2697 -0
  265. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -0
  266. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +45 -0
  267. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -0
  268. package/esm/orchestrator/as-tool.d.mts +42 -0
  269. package/esm/orchestrator/as-tool.d.mts.map +1 -0
  270. package/esm/orchestrator/as-tool.mjs +98 -0
  271. package/esm/orchestrator/as-tool.mjs.map +1 -0
  272. package/esm/orchestrator/checkpoint.mjs +75 -0
  273. package/esm/orchestrator/checkpoint.mjs.map +1 -0
  274. package/esm/orchestrator/commands.d.mts +38 -0
  275. package/esm/orchestrator/commands.d.mts.map +1 -0
  276. package/esm/orchestrator/commands.mjs +34 -0
  277. package/esm/orchestrator/commands.mjs.map +1 -0
  278. package/esm/orchestrator/compaction.mjs +206 -0
  279. package/esm/orchestrator/compaction.mjs.map +1 -0
  280. package/esm/orchestrator/dispatch.mjs +171 -0
  281. package/esm/orchestrator/dispatch.mjs.map +1 -0
  282. package/esm/orchestrator/emitter-port.type.d.mts +31 -0
  283. package/esm/orchestrator/emitter-port.type.d.mts.map +1 -0
  284. package/esm/orchestrator/emitter.d.mts +56 -0
  285. package/esm/orchestrator/emitter.d.mts.map +1 -0
  286. package/esm/orchestrator/emitter.mjs +85 -0
  287. package/esm/orchestrator/emitter.mjs.map +1 -0
  288. package/esm/orchestrator/engine-context.type.d.mts +56 -0
  289. package/esm/orchestrator/engine-context.type.d.mts.map +1 -0
  290. package/esm/orchestrator/execution.d.mts +116 -0
  291. package/esm/orchestrator/execution.d.mts.map +1 -0
  292. package/esm/orchestrator/execution.mjs +406 -0
  293. package/esm/orchestrator/execution.mjs.map +1 -0
  294. package/esm/orchestrator/index.d.mts +8 -0
  295. package/esm/orchestrator/index.mjs +10 -0
  296. package/esm/orchestrator/load.mjs +49 -0
  297. package/esm/orchestrator/load.mjs.map +1 -0
  298. package/esm/orchestrator/lock.mjs +75 -0
  299. package/esm/orchestrator/lock.mjs.map +1 -0
  300. package/esm/orchestrator/memory.d.mts +84 -0
  301. package/esm/orchestrator/memory.d.mts.map +1 -0
  302. package/esm/orchestrator/memory.mjs +141 -0
  303. package/esm/orchestrator/memory.mjs.map +1 -0
  304. package/esm/orchestrator/orchestrator-stream.d.mts +42 -0
  305. package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -0
  306. package/esm/orchestrator/orchestrator-stream.mjs +98 -0
  307. package/esm/orchestrator/orchestrator-stream.mjs.map +1 -0
  308. package/esm/orchestrator/orchestrator.d.mts +38 -0
  309. package/esm/orchestrator/orchestrator.d.mts.map +1 -0
  310. package/esm/orchestrator/orchestrator.mjs +173 -0
  311. package/esm/orchestrator/orchestrator.mjs.map +1 -0
  312. package/esm/orchestrator/resume.mjs +74 -0
  313. package/esm/orchestrator/resume.mjs.map +1 -0
  314. package/esm/orchestrator/signature.d.mts +40 -0
  315. package/esm/orchestrator/signature.d.mts.map +1 -0
  316. package/esm/orchestrator/signature.mjs +120 -0
  317. package/esm/orchestrator/signature.mjs.map +1 -0
  318. package/esm/orchestrator/window.mjs +56 -0
  319. package/esm/orchestrator/window.mjs.map +1 -0
  320. package/esm/planner/index.d.mts +5 -0
  321. package/esm/planner/index.mjs +6 -0
  322. package/esm/planner/plan-prompt.d.mts +17 -0
  323. package/esm/planner/plan-prompt.d.mts.map +1 -0
  324. package/esm/planner/plan-prompt.mjs +30 -0
  325. package/esm/planner/plan-prompt.mjs.map +1 -0
  326. package/esm/planner/plan-schema.d.mts +27 -0
  327. package/esm/planner/plan-schema.d.mts.map +1 -0
  328. package/esm/planner/plan-schema.mjs +117 -0
  329. package/esm/planner/plan-schema.mjs.map +1 -0
  330. package/esm/planner/planner-run.d.mts +23 -0
  331. package/esm/planner/planner-run.d.mts.map +1 -0
  332. package/esm/planner/planner-run.mjs +344 -0
  333. package/esm/planner/planner-run.mjs.map +1 -0
  334. package/esm/planner/planner.d.mts +37 -0
  335. package/esm/planner/planner.d.mts.map +1 -0
  336. package/esm/planner/planner.mjs +120 -0
  337. package/esm/planner/planner.mjs.map +1 -0
  338. package/esm/planner/signature.d.mts +18 -0
  339. package/esm/planner/signature.d.mts.map +1 -0
  340. package/esm/planner/signature.mjs +27 -0
  341. package/esm/planner/signature.mjs.map +1 -0
  342. package/esm/snapshot/index.d.mts +3 -0
  343. package/esm/snapshot/memory.d.mts +26 -0
  344. package/esm/snapshot/memory.d.mts.map +1 -0
  345. package/esm/snapshot/memory.mjs +81 -0
  346. package/esm/snapshot/memory.mjs.map +1 -0
  347. package/esm/snapshot/pg.d.mts +41 -0
  348. package/esm/snapshot/pg.d.mts.map +1 -0
  349. package/esm/snapshot/pg.mjs +146 -0
  350. package/esm/snapshot/pg.mjs.map +1 -0
  351. package/esm/snapshot/redis.d.mts +42 -0
  352. package/esm/snapshot/redis.d.mts.map +1 -0
  353. package/esm/snapshot/redis.mjs +101 -0
  354. package/esm/snapshot/redis.mjs.map +1 -0
  355. package/esm/supervisor/as-tool.d.mts +0 -6
  356. package/esm/supervisor/as-tool.d.mts.map +1 -1
  357. package/esm/supervisor/as-tool.mjs +0 -6
  358. package/esm/supervisor/as-tool.mjs.map +1 -1
  359. package/esm/supervisor/execution.d.mts +43 -8
  360. package/esm/supervisor/execution.d.mts.map +1 -1
  361. package/esm/supervisor/execution.mjs +66 -16
  362. package/esm/supervisor/execution.mjs.map +1 -1
  363. package/esm/supervisor/fan-out.d.mts +65 -0
  364. package/esm/supervisor/fan-out.d.mts.map +1 -0
  365. package/esm/supervisor/fan-out.mjs +65 -0
  366. package/esm/supervisor/fan-out.mjs.map +1 -0
  367. package/esm/supervisor/index.d.mts +5 -3
  368. package/esm/supervisor/index.mjs +3 -1
  369. package/esm/supervisor/router-factory.d.mts +110 -0
  370. package/esm/supervisor/router-factory.d.mts.map +1 -0
  371. package/esm/supervisor/router-factory.mjs +141 -0
  372. package/esm/supervisor/router-factory.mjs.map +1 -0
  373. package/esm/supervisor/router-prompt.d.mts +1 -1
  374. package/esm/supervisor/snapshot.d.mts +4 -10
  375. package/esm/supervisor/snapshot.d.mts.map +1 -1
  376. package/esm/supervisor/snapshot.mjs +8 -16
  377. package/esm/supervisor/snapshot.mjs.map +1 -1
  378. package/esm/supervisor/supervisor.mjs +1 -0
  379. package/esm/supervisor/supervisor.mjs.map +1 -1
  380. package/esm/system-prompt/index.mjs +6 -0
  381. package/esm/system-prompt/system-prompt.d.mts +51 -3
  382. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  383. package/esm/system-prompt/system-prompt.mjs +52 -6
  384. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  385. package/esm/testing/matcher-logic.d.mts +76 -0
  386. package/esm/testing/matcher-logic.d.mts.map +1 -0
  387. package/esm/testing/matcher-logic.mjs +144 -0
  388. package/esm/testing/matcher-logic.mjs.map +1 -0
  389. package/esm/testing/matchers.d.mts +48 -0
  390. package/esm/testing/matchers.d.mts.map +1 -0
  391. package/esm/testing/matchers.mjs +37 -0
  392. package/esm/testing/matchers.mjs.map +1 -0
  393. package/esm/testing/register-lazy.d.mts +20 -0
  394. package/esm/testing/register-lazy.d.mts.map +1 -0
  395. package/esm/testing/register-lazy.mjs +24 -0
  396. package/esm/testing/register-lazy.mjs.map +1 -0
  397. package/esm/tool/executable-as-tool.d.mts +87 -0
  398. package/esm/tool/executable-as-tool.d.mts.map +1 -0
  399. package/esm/tool/executable-as-tool.mjs +81 -0
  400. package/esm/tool/executable-as-tool.mjs.map +1 -0
  401. package/esm/tool/index.d.mts +2 -1
  402. package/esm/tool/index.mjs +1 -0
  403. package/esm/workflow/as-tool.mjs +0 -6
  404. package/esm/workflow/as-tool.mjs.map +1 -1
  405. package/esm/workflow/engine.mjs +2 -2
  406. package/esm/workflow/snapshot.mjs +13 -7
  407. package/esm/workflow/snapshot.mjs.map +1 -1
  408. package/esm/workflow/step-runner.mjs +1 -1
  409. package/esm/workflow/workflow.mjs +1 -0
  410. package/esm/workflow/workflow.mjs.map +1 -1
  411. package/llms-full.txt +947 -42
  412. package/llms.txt +13 -8
  413. package/package.json +3 -3
  414. package/skills/README.md +25 -5
  415. package/skills/ai-basics/SKILL.md +18 -7
  416. package/skills/ai-dx-helpers/SKILL.md +180 -0
  417. package/skills/attach-ai-middleware/SKILL.md +32 -3
  418. package/skills/handle-ai-errors/SKILL.md +20 -6
  419. package/skills/manage-ai-stores/SKILL.md +127 -0
  420. package/skills/persist-ai-data/SKILL.md +21 -10
  421. package/skills/pick-ai-provider/SKILL.md +46 -12
  422. package/skills/run-ai-agent/SKILL.md +51 -2
  423. package/skills/run-orchestrator/SKILL.md +198 -0
  424. package/skills/run-planner/SKILL.md +68 -0
  425. package/skills/run-supervisor/SKILL.md +47 -2
  426. package/skills/use-ai-memory/SKILL.md +124 -0
  427. package/skills/write-system-prompt/SKILL.md +14 -1
@@ -0,0 +1,200 @@
1
+ //#region ../@warlock.js/ai/src/checkpoint/redis.ts
2
+ /**
3
+ * Default key prefix — namespaces the store's keys inside a shared
4
+ * Redis database.
5
+ */
6
+ const DEFAULT_PREFIX = "warlock:orchestrator";
7
+ /**
8
+ * Redis-backed {@link CheckpointStore} (orchestrator.md §8.2).
9
+ *
10
+ * Owns: the per-session append-only document, a per-orchestrator
11
+ * session-id index (so {@link RedisCheckpointStore.list} works without
12
+ * `KEYS`/`SCAN`), the "latest turn wins" load, and the §4-Phase-6
13
+ * retention prune. Does NOT own: durability guarantees beyond Redis's
14
+ * own, the connection lifecycle (the dev passes a client), or the
15
+ * `keepSnapshots` policy (that lives on the orchestrator config).
16
+ *
17
+ * Because {@link RedisClientLike} is intentionally minimal (`get` /
18
+ * `set` / `del` only — §8.4), the store models a session as a single
19
+ * JSON document rather than one Redis key per turn. This keeps every
20
+ * operation a single round-trip and avoids depending on key scanning,
21
+ * at the cost of read-modify-write on `save`. Callers must serialize
22
+ * traffic per `sessionId` anyway (§17 "two turns racing"), so the
23
+ * read-modify-write is safe under that contract.
24
+ *
25
+ * Front it with the {@link redis} factory — callers never `new` it.
26
+ */
27
+ var RedisCheckpointStore = class {
28
+ constructor(options) {
29
+ if (!options || typeof options.client?.get !== "function" || typeof options.client?.set !== "function" || typeof options.client?.del !== "function") throw new TypeError("ai.checkpoint.redis requires a 'client' option implementing { get, set, del } — pass a connected redis client.");
30
+ this.client = options.client;
31
+ this.prefix = options.prefix ?? DEFAULT_PREFIX;
32
+ this.ttl = options.ttl;
33
+ }
34
+ /**
35
+ * Return the latest checkpoint (highest `turn_index`) for a session,
36
+ * or `undefined` when the session has no document. Rows are appended
37
+ * in turn order, so the last element is the latest.
38
+ */
39
+ async load(orchestratorName, sessionId) {
40
+ const document = await this.readSession(orchestratorName, sessionId);
41
+ if (!document || document.rows.length === 0) return;
42
+ return document.rows[document.rows.length - 1];
43
+ }
44
+ /**
45
+ * Append a checkpoint row to its session document, creating the
46
+ * document and indexing the session id on first write. Append-only —
47
+ * an existing `turn_index` is never overwritten; a fresh row is
48
+ * pushed (§4 Phase 6, Q15).
49
+ */
50
+ async save(record) {
51
+ const { orchestrator_name, session_id } = record;
52
+ const document = await this.readSession(orchestrator_name, session_id) ?? { rows: [] };
53
+ document.rows.push(record);
54
+ await this.writeSession(orchestrator_name, session_id, document);
55
+ await this.indexSession(orchestrator_name, session_id);
56
+ }
57
+ /**
58
+ * Drop a session document and de-index its session id.
59
+ */
60
+ async delete(orchestratorName, sessionId) {
61
+ await this.client.del(this.sessionKey(orchestratorName, sessionId));
62
+ await this.deindexSession(orchestratorName, sessionId);
63
+ }
64
+ /**
65
+ * List the session ids known for an orchestrator, optionally filtered
66
+ * by a session-id prefix. Reads the self-maintained index document
67
+ * (§9.3 boot drain).
68
+ */
69
+ async list(orchestratorName, prefix) {
70
+ const index = await this.readIndex(orchestratorName);
71
+ if (prefix === void 0) return [...index.sessionIds];
72
+ return index.sessionIds.filter((sessionId) => sessionId.startsWith(prefix));
73
+ }
74
+ /**
75
+ * Prune retained turns for a session down to the most recent
76
+ * `keepSnapshots` rows (orchestrator.md §4 Phase 6 / §15.2). Drops
77
+ * every row whose `turn_index` is below `(max_turn_index -
78
+ * keepSnapshots)`. The orchestrator calls this synchronously after a
79
+ * successful {@link save} when `keepSnapshots` is a finite number;
80
+ * `"all"` retention skips the call. Additive to the
81
+ * {@link CheckpointStore} contract — the policy stays on the
82
+ * orchestrator and the store only executes the bounded trim.
83
+ */
84
+ async prune(orchestratorName, sessionId, keepSnapshots) {
85
+ if (!Number.isFinite(keepSnapshots) || keepSnapshots < 0) return;
86
+ const document = await this.readSession(orchestratorName, sessionId);
87
+ if (!document || document.rows.length === 0) return;
88
+ const threshold = document.rows[document.rows.length - 1].turn_index - keepSnapshots;
89
+ const kept = document.rows.filter((row) => row.turn_index >= threshold);
90
+ if (kept.length === document.rows.length) return;
91
+ await this.writeSession(orchestratorName, sessionId, { rows: kept });
92
+ }
93
+ /**
94
+ * The Redis store has no relational table — there is nothing to
95
+ * migrate. Returns an empty string so callers can treat `schema()`
96
+ * uniformly across drivers (mirrors the memory store).
97
+ */
98
+ schema() {
99
+ return "";
100
+ }
101
+ /**
102
+ * Set the idle-key TTL (§8.2). Applied on every subsequent write; the
103
+ * store never opens a background timer.
104
+ */
105
+ setOptions(options) {
106
+ this.ttl = options.ttl;
107
+ }
108
+ /**
109
+ * Read and parse a session document, or `undefined` when the key is
110
+ * absent.
111
+ */
112
+ async readSession(orchestratorName, sessionId) {
113
+ const raw = await this.client.get(this.sessionKey(orchestratorName, sessionId));
114
+ if (raw === null) return;
115
+ return JSON.parse(raw);
116
+ }
117
+ /**
118
+ * Serialize and persist a session document, honoring the configured
119
+ * idle TTL when set.
120
+ */
121
+ async writeSession(orchestratorName, sessionId, document) {
122
+ await this.write(this.sessionKey(orchestratorName, sessionId), JSON.stringify(document));
123
+ }
124
+ /**
125
+ * Read and parse the per-orchestrator index document, defaulting to an
126
+ * empty index when absent.
127
+ */
128
+ async readIndex(orchestratorName) {
129
+ const raw = await this.client.get(this.indexKey(orchestratorName));
130
+ if (raw === null) return { sessionIds: [] };
131
+ return JSON.parse(raw);
132
+ }
133
+ /**
134
+ * Add a session id to the per-orchestrator index, no-op when already
135
+ * present.
136
+ */
137
+ async indexSession(orchestratorName, sessionId) {
138
+ const index = await this.readIndex(orchestratorName);
139
+ if (index.sessionIds.includes(sessionId)) return;
140
+ index.sessionIds.push(sessionId);
141
+ await this.write(this.indexKey(orchestratorName), JSON.stringify(index));
142
+ }
143
+ /**
144
+ * Remove a session id from the per-orchestrator index, no-op when
145
+ * absent.
146
+ */
147
+ async deindexSession(orchestratorName, sessionId) {
148
+ const index = await this.readIndex(orchestratorName);
149
+ const next = index.sessionIds.filter((id) => id !== sessionId);
150
+ if (next.length === index.sessionIds.length) return;
151
+ await this.write(this.indexKey(orchestratorName), JSON.stringify({ sessionIds: next }));
152
+ }
153
+ /**
154
+ * Write a key, attaching the `EX` expiry option when an idle TTL is
155
+ * configured. The TTL flows through {@link RedisClientLike.set}'s
156
+ * variadic args as node-redis's `{ EX }` option object.
157
+ */
158
+ async write(key, value) {
159
+ if (this.ttl !== void 0 && this.ttl > 0) {
160
+ await this.client.set(key, value, { EX: this.ttl });
161
+ return;
162
+ }
163
+ await this.client.set(key, value);
164
+ }
165
+ /**
166
+ * Key for a session document — `<prefix>:session:<name>:<sessionId>`.
167
+ */
168
+ sessionKey(orchestratorName, sessionId) {
169
+ return `${this.prefix}:session:${orchestratorName}:${sessionId}`;
170
+ }
171
+ /**
172
+ * Key for a per-orchestrator session-id index —
173
+ * `<prefix>:index:<name>`.
174
+ */
175
+ indexKey(orchestratorName) {
176
+ return `${this.prefix}:index:${orchestratorName}`;
177
+ }
178
+ };
179
+ /**
180
+ * Create a Redis-backed {@link CheckpointStore} (orchestrator.md §8.3).
181
+ * The dev installs `redis` and passes a connected client —
182
+ * `@warlock.js/ai` never imports `redis`. {@link CheckpointStore.schema}
183
+ * returns an empty string; Redis needs no migration.
184
+ *
185
+ * @example
186
+ * import { createClient } from "redis";
187
+ * import { ai } from "@warlock.js/ai";
188
+ *
189
+ * const client = createClient();
190
+ * await client.connect();
191
+ *
192
+ * const store = ai.checkpoint.redis({ client });
193
+ */
194
+ function redis(options) {
195
+ return new RedisCheckpointStore(options);
196
+ }
197
+
198
+ //#endregion
199
+ export { redis };
200
+ //# sourceMappingURL=redis.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/checkpoint/redis.ts"],"sourcesContent":["import type {\n CheckpointRecord,\n CheckpointStore,\n} from \"../contracts/orchestrator/checkpoint-store.contract\";\nimport type { RedisClientLike } from \"../contracts/orchestrator/snapshot-store.contract\";\n\n/**\n * Options for the Redis {@link CheckpointStore} (orchestrator.md §8.3).\n *\n * The dev owns the connection — `@warlock.js/ai` takes no peer dep on\n * `redis` and never opens or closes the client.\n */\nexport type RedisCheckpointOptions = {\n /** An already-connected `redis` client — anything matching {@link RedisClientLike}. */\n client: RedisClientLike;\n /**\n * Key prefix for every key this store writes. Lets one Redis database\n * back multiple stores without collision. Defaults to\n * `warlock:orchestrator`.\n */\n prefix?: string;\n /** Idle-key TTL in seconds. When set, every written key expires after the TTL. */\n ttl?: number;\n};\n\n/**\n * Default key prefix — namespaces the store's keys inside a shared\n * Redis database.\n */\nconst DEFAULT_PREFIX = \"warlock:orchestrator\";\n\n/**\n * Per-session document persisted under one Redis key: the append-only\n * list of {@link CheckpointRecord} rows in turn order, mirroring the\n * Postgres append-only PK shape (§8.6) inside a single JSON value so\n * the store needs only `get`/`set`/`del` from {@link RedisClientLike}.\n */\ntype SessionDocument = {\n rows: CheckpointRecord[];\n};\n\n/**\n * Per-orchestrator index document: the set of live session ids. Kept as\n * a JSON array because {@link RedisClientLike} exposes no `keys` / `scan`\n * — enumeration for the §9.3 boot drain must be self-maintained.\n */\ntype IndexDocument = {\n sessionIds: string[];\n};\n\n/**\n * Redis-backed {@link CheckpointStore} (orchestrator.md §8.2).\n *\n * Owns: the per-session append-only document, a per-orchestrator\n * session-id index (so {@link RedisCheckpointStore.list} works without\n * `KEYS`/`SCAN`), the \"latest turn wins\" load, and the §4-Phase-6\n * retention prune. Does NOT own: durability guarantees beyond Redis's\n * own, the connection lifecycle (the dev passes a client), or the\n * `keepSnapshots` policy (that lives on the orchestrator config).\n *\n * Because {@link RedisClientLike} is intentionally minimal (`get` /\n * `set` / `del` only — §8.4), the store models a session as a single\n * JSON document rather than one Redis key per turn. This keeps every\n * operation a single round-trip and avoids depending on key scanning,\n * at the cost of read-modify-write on `save`. Callers must serialize\n * traffic per `sessionId` anyway (§17 \"two turns racing\"), so the\n * read-modify-write is safe under that contract.\n *\n * Front it with the {@link redis} factory — callers never `new` it.\n */\nclass RedisCheckpointStore implements CheckpointStore {\n /** The dev-supplied redis client. Never disconnected by the store. */\n private readonly client: RedisClientLike;\n\n /** Key prefix namespacing every key this store writes. */\n private readonly prefix: string;\n\n /** Idle-key TTL in seconds, or `undefined` for no expiry. */\n private ttl?: number;\n\n public constructor(options: RedisCheckpointOptions) {\n if (\n !options ||\n typeof options.client?.get !== \"function\" ||\n typeof options.client?.set !== \"function\" ||\n typeof options.client?.del !== \"function\"\n ) {\n throw new TypeError(\n \"ai.checkpoint.redis requires a 'client' option implementing { get, set, del } — pass a connected redis client.\",\n );\n }\n\n this.client = options.client;\n this.prefix = options.prefix ?? DEFAULT_PREFIX;\n this.ttl = options.ttl;\n }\n\n /**\n * Return the latest checkpoint (highest `turn_index`) for a session,\n * or `undefined` when the session has no document. Rows are appended\n * in turn order, so the last element is the latest.\n */\n public async load(\n orchestratorName: string,\n sessionId: string,\n ): Promise<CheckpointRecord | undefined> {\n const document = await this.readSession(orchestratorName, sessionId);\n\n if (!document || document.rows.length === 0) {\n return undefined;\n }\n\n return document.rows[document.rows.length - 1];\n }\n\n /**\n * Append a checkpoint row to its session document, creating the\n * document and indexing the session id on first write. Append-only —\n * an existing `turn_index` is never overwritten; a fresh row is\n * pushed (§4 Phase 6, Q15).\n */\n public async save(record: CheckpointRecord): Promise<void> {\n const { orchestrator_name, session_id } = record;\n\n const document =\n (await this.readSession(orchestrator_name, session_id)) ?? { rows: [] };\n\n document.rows.push(record);\n\n await this.writeSession(orchestrator_name, session_id, document);\n await this.indexSession(orchestrator_name, session_id);\n }\n\n /**\n * Drop a session document and de-index its session id.\n */\n public async delete(\n orchestratorName: string,\n sessionId: string,\n ): Promise<void> {\n await this.client.del(this.sessionKey(orchestratorName, sessionId));\n await this.deindexSession(orchestratorName, sessionId);\n }\n\n /**\n * List the session ids known for an orchestrator, optionally filtered\n * by a session-id prefix. Reads the self-maintained index document\n * (§9.3 boot drain).\n */\n public async list(\n orchestratorName: string,\n prefix?: string,\n ): Promise<string[]> {\n const index = await this.readIndex(orchestratorName);\n\n if (prefix === undefined) {\n return [...index.sessionIds];\n }\n\n return index.sessionIds.filter((sessionId) =>\n sessionId.startsWith(prefix),\n );\n }\n\n /**\n * Prune retained turns for a session down to the most recent\n * `keepSnapshots` rows (orchestrator.md §4 Phase 6 / §15.2). Drops\n * every row whose `turn_index` is below `(max_turn_index -\n * keepSnapshots)`. The orchestrator calls this synchronously after a\n * successful {@link save} when `keepSnapshots` is a finite number;\n * `\"all\"` retention skips the call. Additive to the\n * {@link CheckpointStore} contract — the policy stays on the\n * orchestrator and the store only executes the bounded trim.\n */\n public async prune(\n orchestratorName: string,\n sessionId: string,\n keepSnapshots: number,\n ): Promise<void> {\n if (!Number.isFinite(keepSnapshots) || keepSnapshots < 0) {\n return;\n }\n\n const document = await this.readSession(orchestratorName, sessionId);\n\n if (!document || document.rows.length === 0) {\n return;\n }\n\n const maxTurnIndex = document.rows[document.rows.length - 1].turn_index;\n const threshold = maxTurnIndex - keepSnapshots;\n\n const kept = document.rows.filter((row) => row.turn_index >= threshold);\n\n if (kept.length === document.rows.length) {\n return;\n }\n\n await this.writeSession(orchestratorName, sessionId, { rows: kept });\n }\n\n /**\n * The Redis store has no relational table — there is nothing to\n * migrate. Returns an empty string so callers can treat `schema()`\n * uniformly across drivers (mirrors the memory store).\n */\n public schema(): string {\n return \"\";\n }\n\n /**\n * Set the idle-key TTL (§8.2). Applied on every subsequent write; the\n * store never opens a background timer.\n */\n public setOptions(options: { ttl?: number }): void {\n this.ttl = options.ttl;\n }\n\n /**\n * Read and parse a session document, or `undefined` when the key is\n * absent.\n */\n private async readSession(\n orchestratorName: string,\n sessionId: string,\n ): Promise<SessionDocument | undefined> {\n const raw = await this.client.get(\n this.sessionKey(orchestratorName, sessionId),\n );\n\n if (raw === null) {\n return undefined;\n }\n\n return JSON.parse(raw) as SessionDocument;\n }\n\n /**\n * Serialize and persist a session document, honoring the configured\n * idle TTL when set.\n */\n private async writeSession(\n orchestratorName: string,\n sessionId: string,\n document: SessionDocument,\n ): Promise<void> {\n await this.write(\n this.sessionKey(orchestratorName, sessionId),\n JSON.stringify(document),\n );\n }\n\n /**\n * Read and parse the per-orchestrator index document, defaulting to an\n * empty index when absent.\n */\n private async readIndex(orchestratorName: string): Promise<IndexDocument> {\n const raw = await this.client.get(this.indexKey(orchestratorName));\n\n if (raw === null) {\n return { sessionIds: [] };\n }\n\n return JSON.parse(raw) as IndexDocument;\n }\n\n /**\n * Add a session id to the per-orchestrator index, no-op when already\n * present.\n */\n private async indexSession(\n orchestratorName: string,\n sessionId: string,\n ): Promise<void> {\n const index = await this.readIndex(orchestratorName);\n\n if (index.sessionIds.includes(sessionId)) {\n return;\n }\n\n index.sessionIds.push(sessionId);\n\n await this.write(this.indexKey(orchestratorName), JSON.stringify(index));\n }\n\n /**\n * Remove a session id from the per-orchestrator index, no-op when\n * absent.\n */\n private async deindexSession(\n orchestratorName: string,\n sessionId: string,\n ): Promise<void> {\n const index = await this.readIndex(orchestratorName);\n const next = index.sessionIds.filter((id) => id !== sessionId);\n\n if (next.length === index.sessionIds.length) {\n return;\n }\n\n await this.write(\n this.indexKey(orchestratorName),\n JSON.stringify({ sessionIds: next }),\n );\n }\n\n /**\n * Write a key, attaching the `EX` expiry option when an idle TTL is\n * configured. The TTL flows through {@link RedisClientLike.set}'s\n * variadic args as node-redis's `{ EX }` option object.\n */\n private async write(key: string, value: string): Promise<void> {\n if (this.ttl !== undefined && this.ttl > 0) {\n await this.client.set(key, value, { EX: this.ttl });\n\n return;\n }\n\n await this.client.set(key, value);\n }\n\n /**\n * Key for a session document — `<prefix>:session:<name>:<sessionId>`.\n */\n private sessionKey(orchestratorName: string, sessionId: string): string {\n return `${this.prefix}:session:${orchestratorName}:${sessionId}`;\n }\n\n /**\n * Key for a per-orchestrator session-id index —\n * `<prefix>:index:<name>`.\n */\n private indexKey(orchestratorName: string): string {\n return `${this.prefix}:index:${orchestratorName}`;\n }\n}\n\n/**\n * Create a Redis-backed {@link CheckpointStore} (orchestrator.md §8.3).\n * The dev installs `redis` and passes a connected client —\n * `@warlock.js/ai` never imports `redis`. {@link CheckpointStore.schema}\n * returns an empty string; Redis needs no migration.\n *\n * @example\n * import { createClient } from \"redis\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * const client = createClient();\n * await client.connect();\n *\n * const store = ai.checkpoint.redis({ client });\n */\nexport function redis(options: RedisCheckpointOptions): CheckpointStore {\n return new RedisCheckpointStore(options);\n}\n"],"mappings":";;;;;AA6BA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;AAyCvB,IAAM,uBAAN,MAAsD;CAUpD,AAAO,YAAY,SAAiC;EAClD,IACE,CAAC,WACD,OAAO,QAAQ,QAAQ,QAAQ,cAC/B,OAAO,QAAQ,QAAQ,QAAQ,cAC/B,OAAO,QAAQ,QAAQ,QAAQ,YAE/B,MAAM,IAAI,UACR,gHACF;EAGF,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ,UAAU;EAChC,KAAK,MAAM,QAAQ;CACrB;;;;;;CAOA,MAAa,KACX,kBACA,WACuC;EACvC,MAAM,WAAW,MAAM,KAAK,YAAY,kBAAkB,SAAS;EAEnE,IAAI,CAAC,YAAY,SAAS,KAAK,WAAW,GACxC;EAGF,OAAO,SAAS,KAAK,SAAS,KAAK,SAAS;CAC9C;;;;;;;CAQA,MAAa,KAAK,QAAyC;EACzD,MAAM,EAAE,mBAAmB,eAAe;EAE1C,MAAM,WACH,MAAM,KAAK,YAAY,mBAAmB,UAAU,KAAM,EAAE,MAAM,CAAC,EAAE;EAExE,SAAS,KAAK,KAAK,MAAM;EAEzB,MAAM,KAAK,aAAa,mBAAmB,YAAY,QAAQ;EAC/D,MAAM,KAAK,aAAa,mBAAmB,UAAU;CACvD;;;;CAKA,MAAa,OACX,kBACA,WACe;EACf,MAAM,KAAK,OAAO,IAAI,KAAK,WAAW,kBAAkB,SAAS,CAAC;EAClE,MAAM,KAAK,eAAe,kBAAkB,SAAS;CACvD;;;;;;CAOA,MAAa,KACX,kBACA,QACmB;EACnB,MAAM,QAAQ,MAAM,KAAK,UAAU,gBAAgB;EAEnD,IAAI,WAAW,QACb,OAAO,CAAC,GAAG,MAAM,UAAU;EAG7B,OAAO,MAAM,WAAW,QAAQ,cAC9B,UAAU,WAAW,MAAM,CAC7B;CACF;;;;;;;;;;;CAYA,MAAa,MACX,kBACA,WACA,eACe;EACf,IAAI,CAAC,OAAO,SAAS,aAAa,KAAK,gBAAgB,GACrD;EAGF,MAAM,WAAW,MAAM,KAAK,YAAY,kBAAkB,SAAS;EAEnE,IAAI,CAAC,YAAY,SAAS,KAAK,WAAW,GACxC;EAIF,MAAM,YADe,SAAS,KAAK,SAAS,KAAK,SAAS,EAAE,CAAC,aAC5B;EAEjC,MAAM,OAAO,SAAS,KAAK,QAAQ,QAAQ,IAAI,cAAc,SAAS;EAEtE,IAAI,KAAK,WAAW,SAAS,KAAK,QAChC;EAGF,MAAM,KAAK,aAAa,kBAAkB,WAAW,EAAE,MAAM,KAAK,CAAC;CACrE;;;;;;CAOA,AAAO,SAAiB;EACtB,OAAO;CACT;;;;;CAMA,AAAO,WAAW,SAAiC;EACjD,KAAK,MAAM,QAAQ;CACrB;;;;;CAMA,MAAc,YACZ,kBACA,WACsC;EACtC,MAAM,MAAM,MAAM,KAAK,OAAO,IAC5B,KAAK,WAAW,kBAAkB,SAAS,CAC7C;EAEA,IAAI,QAAQ,MACV;EAGF,OAAO,KAAK,MAAM,GAAG;CACvB;;;;;CAMA,MAAc,aACZ,kBACA,WACA,UACe;EACf,MAAM,KAAK,MACT,KAAK,WAAW,kBAAkB,SAAS,GAC3C,KAAK,UAAU,QAAQ,CACzB;CACF;;;;;CAMA,MAAc,UAAU,kBAAkD;EACxE,MAAM,MAAM,MAAM,KAAK,OAAO,IAAI,KAAK,SAAS,gBAAgB,CAAC;EAEjE,IAAI,QAAQ,MACV,OAAO,EAAE,YAAY,CAAC,EAAE;EAG1B,OAAO,KAAK,MAAM,GAAG;CACvB;;;;;CAMA,MAAc,aACZ,kBACA,WACe;EACf,MAAM,QAAQ,MAAM,KAAK,UAAU,gBAAgB;EAEnD,IAAI,MAAM,WAAW,SAAS,SAAS,GACrC;EAGF,MAAM,WAAW,KAAK,SAAS;EAE/B,MAAM,KAAK,MAAM,KAAK,SAAS,gBAAgB,GAAG,KAAK,UAAU,KAAK,CAAC;CACzE;;;;;CAMA,MAAc,eACZ,kBACA,WACe;EACf,MAAM,QAAQ,MAAM,KAAK,UAAU,gBAAgB;EACnD,MAAM,OAAO,MAAM,WAAW,QAAQ,OAAO,OAAO,SAAS;EAE7D,IAAI,KAAK,WAAW,MAAM,WAAW,QACnC;EAGF,MAAM,KAAK,MACT,KAAK,SAAS,gBAAgB,GAC9B,KAAK,UAAU,EAAE,YAAY,KAAK,CAAC,CACrC;CACF;;;;;;CAOA,MAAc,MAAM,KAAa,OAA8B;EAC7D,IAAI,KAAK,QAAQ,UAAa,KAAK,MAAM,GAAG;GAC1C,MAAM,KAAK,OAAO,IAAI,KAAK,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;GAElD;EACF;EAEA,MAAM,KAAK,OAAO,IAAI,KAAK,KAAK;CAClC;;;;CAKA,AAAQ,WAAW,kBAA0B,WAA2B;EACtE,OAAO,GAAG,KAAK,OAAO,WAAW,iBAAiB,GAAG;CACvD;;;;;CAMA,AAAQ,SAAS,kBAAkC;EACjD,OAAO,GAAG,KAAK,OAAO,SAAS;CACjC;AACF;;;;;;;;;;;;;;;;AAiBA,SAAgB,MAAM,SAAkD;CACtE,OAAO,IAAI,qBAAqB,OAAO;AACzC"}
package/esm/config.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { SnapshotStore } from "./contracts/orchestrator/snapshot-store.contract.mjs";
2
+ import { CheckpointStore } from "./contracts/orchestrator/checkpoint-store.contract.mjs";
1
3
  import { CacheDriver } from "@warlock.js/cache";
2
4
 
3
5
  //#region ../@warlock.js/ai/src/config.d.ts
@@ -24,15 +26,19 @@ import { CacheDriver } from "@warlock.js/cache";
24
26
  */
25
27
  type AIConfig = {
26
28
  /**
27
- * Default store used by every consumer that supports persistence
28
- * but didn't supply its own `store` / `snapshotStore`. Most
29
- * realistic deployments back resume snapshots, semantic cache, and
30
- * future memory primitives with the same driver — declaring it
31
- * once here removes the repetition.
29
+ * Default `@warlock.js/cache` driver for cache-backed consumers that
30
+ * didn't supply their own `store` currently the `semanticCache`
31
+ * middleware's vector store. Declaring it once here removes the
32
+ * repetition across middleware declarations.
32
33
  *
33
- * Per-declaration overrides (`SupervisorConfig.snapshotStore`,
34
- * `semanticCache({ store })`) win when supplied. Set this once at
35
- * app boot, *after* you've constructed your driver.
34
+ * NOT the snapshot-persistence fallback anymore. Supervisor /
35
+ * workflow / orchestrator resume snapshots resolve through
36
+ * {@link AIConfig.defaultSnapshotStore} (a {@link SnapshotStore}),
37
+ * never this driver.
38
+ *
39
+ * Per-declaration overrides (`semanticCache({ store })`) win when
40
+ * supplied. Set this once at app boot, *after* you've constructed
41
+ * your driver.
36
42
  *
37
43
  * @example
38
44
  * import { cache } from "@warlock.js/cache";
@@ -43,6 +49,32 @@ type AIConfig = {
43
49
  * });
44
50
  */
45
51
  defaultStore?: CacheDriver<any, any>;
52
+ /**
53
+ * Default {@link CheckpointStore} for every orchestrator that didn't
54
+ * supply its own `checkpointStore` (orchestrator.md §15.2). Holds
55
+ * durable session state — `state`, `turn_index`, drift `signature`,
56
+ * compaction locks. Per-orchestrator `checkpointStore` wins when
57
+ * supplied. Set once at app boot.
58
+ *
59
+ * @example
60
+ * import { ai } from "@warlock.js/ai";
61
+ *
62
+ * ai.config({ defaultCheckpointStore: ai.checkpoint.memory() });
63
+ */
64
+ defaultCheckpointStore?: CheckpointStore;
65
+ /**
66
+ * Default {@link SnapshotStore} for every orchestrator that didn't
67
+ * supply its own `snapshotStore` (orchestrator.md §15.2). Holds the
68
+ * internal supervisor run state used to resume an interrupted
69
+ * `iterate: true` turn. Per-orchestrator `snapshotStore` wins when
70
+ * supplied. Set once at app boot.
71
+ *
72
+ * @example
73
+ * import { ai } from "@warlock.js/ai";
74
+ *
75
+ * ai.config({ defaultSnapshotStore: ai.snapshot.memory() });
76
+ */
77
+ defaultSnapshotStore?: SnapshotStore;
46
78
  };
47
79
  /**
48
80
  * Set or extend process-wide AI configuration. Merges over existing
@@ -67,13 +99,28 @@ declare function setAIConfig(partial: Partial<AIConfig>): AIConfig;
67
99
  */
68
100
  declare function getAIConfig(): AIConfig;
69
101
  /**
70
- * Resolve the effective store for a consumer that didn't receive an
71
- * explicit one. Returns the global `defaultStore` if set, otherwise
72
- * `undefined`. Consumers decide whether `undefined` is fatal (semantic
73
- * cache: yes, throws) or a no-op (snapshot persistence: yes, just
74
- * skips).
102
+ * Resolve the effective `@warlock.js/cache` driver for a cache-backed
103
+ * consumer that didn't receive an explicit one. Returns the global
104
+ * `defaultStore` if set, otherwise `undefined`. The semantic-cache
105
+ * middleware treats `undefined` as fatal and throws. Snapshot
106
+ * persistence no longer consults this — it resolves through
107
+ * {@link resolveDefaultSnapshotStore}.
75
108
  */
76
109
  declare function resolveDefaultStore(): CacheDriver<any, any> | undefined;
110
+ /**
111
+ * Resolve the global default {@link CheckpointStore} for an
112
+ * orchestrator that didn't receive an explicit `checkpointStore`.
113
+ * Returns `undefined` when none is configured — the orchestrator
114
+ * factory decides whether that's fatal.
115
+ */
116
+ declare function resolveDefaultCheckpointStore(): CheckpointStore | undefined;
117
+ /**
118
+ * Resolve the global default {@link SnapshotStore} for an orchestrator
119
+ * that didn't receive an explicit `snapshotStore`. Returns `undefined`
120
+ * when none is configured — the orchestrator factory decides whether
121
+ * that's fatal (it is, when `iterate: true`).
122
+ */
123
+ declare function resolveDefaultSnapshotStore(): SnapshotStore | undefined;
77
124
  //#endregion
78
- export { AIConfig, getAIConfig, resolveDefaultStore, setAIConfig };
125
+ export { AIConfig, getAIConfig, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig };
79
126
  //# sourceMappingURL=config.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"mappings":";;;;;AAuBA;;;;AAoB4B;AAoB5B;;;;;;;;;;;;;AAAiE;KAxCrD,QAAA;EAkDe;;;AAAY;AAWvC;;;;AAAkD;;;;;;;;;;;EAzChD,YAAA,GAAe,WAAW;AAAA;;;;;;;;;;;;;;;;iBAoBZ,WAAA,CAAY,OAAA,EAAS,OAAA,CAAQ,QAAA,IAAY,QAAA;;;;;;iBAUzC,WAAA,IAAe,QAAQ;;;;;;;;iBAWvB,mBAAA,IAAuB,WAAW"}
1
+ {"version":3,"file":"config.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"mappings":";;;;;;;AAyBA;;;;;;;;;;;;;;;AAoDsC;AAoBtC;;;KAxEY,QAAA;EAwEyB;;;;;;;;;AAA4B;AAUjE;;;;AAAuC;AAYvC;;;;AAAkD;AAUlD;;;EAhFE,YAAA,GAAe,WAAA;EAgF+C;AAUhE;;;;AAA4D;;;;;;;EA5E1D,sBAAA,GAAyB,eAAA;;;;;;;;;;;;;EAczB,oBAAA,GAAuB,aAAA;AAAA;;;;;;;;;;;;;;;;iBAoBT,WAAA,CAAY,OAAA,EAAS,OAAA,CAAQ,QAAA,IAAY,QAAA;;;;;;iBAUzC,WAAA,IAAe,QAAQ;;;;;;;;;iBAYvB,mBAAA,IAAuB,WAAW;;;;;;;iBAUlC,6BAAA,IAAiC,eAAe;;;;;;;iBAUhD,2BAAA,IAA+B,aAAa"}
package/esm/config.mjs CHANGED
@@ -28,16 +28,35 @@ function getAIConfig() {
28
28
  return { ...aiConfig };
29
29
  }
30
30
  /**
31
- * Resolve the effective store for a consumer that didn't receive an
32
- * explicit one. Returns the global `defaultStore` if set, otherwise
33
- * `undefined`. Consumers decide whether `undefined` is fatal (semantic
34
- * cache: yes, throws) or a no-op (snapshot persistence: yes, just
35
- * skips).
31
+ * Resolve the effective `@warlock.js/cache` driver for a cache-backed
32
+ * consumer that didn't receive an explicit one. Returns the global
33
+ * `defaultStore` if set, otherwise `undefined`. The semantic-cache
34
+ * middleware treats `undefined` as fatal and throws. Snapshot
35
+ * persistence no longer consults this — it resolves through
36
+ * {@link resolveDefaultSnapshotStore}.
36
37
  */
37
38
  function resolveDefaultStore() {
38
39
  return aiConfig.defaultStore;
39
40
  }
41
+ /**
42
+ * Resolve the global default {@link CheckpointStore} for an
43
+ * orchestrator that didn't receive an explicit `checkpointStore`.
44
+ * Returns `undefined` when none is configured — the orchestrator
45
+ * factory decides whether that's fatal.
46
+ */
47
+ function resolveDefaultCheckpointStore() {
48
+ return aiConfig.defaultCheckpointStore;
49
+ }
50
+ /**
51
+ * Resolve the global default {@link SnapshotStore} for an orchestrator
52
+ * that didn't receive an explicit `snapshotStore`. Returns `undefined`
53
+ * when none is configured — the orchestrator factory decides whether
54
+ * that's fatal (it is, when `iterate: true`).
55
+ */
56
+ function resolveDefaultSnapshotStore() {
57
+ return aiConfig.defaultSnapshotStore;
58
+ }
40
59
 
41
60
  //#endregion
42
- export { getAIConfig, resolveDefaultStore, setAIConfig };
61
+ export { getAIConfig, resolveDefaultCheckpointStore, resolveDefaultSnapshotStore, resolveDefaultStore, setAIConfig };
43
62
  //# sourceMappingURL=config.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\n\n/**\n * Process-wide `@warlock.js/ai` configuration. **Intentionally tiny.**\n * Lives here only for genuinely cross-cutting defaults that would\n * otherwise force users to wire the same value into every consumer.\n *\n * **What lives here.** A field earns a slot only when it satisfies\n * all three:\n * 1. Multiple unrelated consumers need the same value.\n * 2. The value is infrastructure (drivers, clients, pools), not\n * behavior (kill-switches, mode flags).\n * 3. Per-call override doesn't make sense for the use case.\n *\n * **What does NOT live here.** Logger config (use\n * `@warlock.js/logger` directly). Per-primitive feature flags\n * (live on the relevant config type). Anything that's really one\n * consumer's concern (lives on that consumer).\n *\n * Phase 3.2 deliberately removed the previous `configureAI()` bag\n * because it was growing unbounded. Treat new fields here with the\n * same suspicion.\n */\nexport type AIConfig = {\n /**\n * Default store used by every consumer that supports persistence\n * but didn't supply its own `store` / `snapshotStore`. Most\n * realistic deployments back resume snapshots, semantic cache, and\n * future memory primitives with the same driver declaring it\n * once here removes the repetition.\n *\n * Per-declaration overrides (`SupervisorConfig.snapshotStore`,\n * `semanticCache({ store })`) win when supplied. Set this once at\n * app boot, *after* you've constructed your driver.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({\n * defaultStore: cache.driver(\"redis\", { client: redisClient }),\n * });\n */\n defaultStore?: CacheDriver<any, any>;\n};\n\nconst aiConfig: AIConfig = {};\n\n/**\n * Set or extend process-wide AI configuration. Merges over existing\n * values — fields not present in `partial` keep whatever was set\n * before (or stay unset). Call once at app boot, before constructing\n * any agent / supervisor / middleware that should pick up the\n * defaults.\n *\n * Returns the merged config so callers can verify what landed.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultStore: cache.driver(\"redis\", { client }) });\n */\nexport function setAIConfig(partial: Partial<AIConfig>): AIConfig {\n Object.assign(aiConfig, partial);\n return { ...aiConfig };\n}\n\n/**\n * Read the current AI config snapshot. Returns a shallow copy so\n * callers can't accidentally mutate the source of truth. Used\n * internally by consumers to resolve their `defaultStore` fallback.\n */\nexport function getAIConfig(): AIConfig {\n return { ...aiConfig };\n}\n\n/**\n * Resolve the effective store for a consumer that didn't receive an\n * explicit one. Returns the global `defaultStore` if set, otherwise\n * `undefined`. Consumers decide whether `undefined` is fatal (semantic\n * cache: yes, throws) or a no-op (snapshot persistence: yes, just\n * skips).\n */\nexport function resolveDefaultStore(): CacheDriver<any, any> | undefined {\n return aiConfig.defaultStore;\n}\n"],"mappings":";AA8CA,MAAM,WAAqB,CAAC;;;;;;;;;;;;;;;;AAiB5B,SAAgB,YAAY,SAAsC;CAChE,OAAO,OAAO,UAAU,OAAO;CAC/B,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;AAOA,SAAgB,cAAwB;CACtC,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;;;AASA,SAAgB,sBAAyD;CACvE,OAAO,SAAS;AAClB"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../../../../../../@warlock.js/ai/src/config.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\nimport type { CheckpointStore } from \"./contracts/orchestrator/checkpoint-store.contract\";\nimport type { SnapshotStore } from \"./contracts/orchestrator/snapshot-store.contract\";\n\n/**\n * Process-wide `@warlock.js/ai` configuration. **Intentionally tiny.**\n * Lives here only for genuinely cross-cutting defaults that would\n * otherwise force users to wire the same value into every consumer.\n *\n * **What lives here.** A field earns a slot only when it satisfies\n * all three:\n * 1. Multiple unrelated consumers need the same value.\n * 2. The value is infrastructure (drivers, clients, pools), not\n * behavior (kill-switches, mode flags).\n * 3. Per-call override doesn't make sense for the use case.\n *\n * **What does NOT live here.** Logger config (use\n * `@warlock.js/logger` directly). Per-primitive feature flags\n * (live on the relevant config type). Anything that's really one\n * consumer's concern (lives on that consumer).\n *\n * Phase 3.2 deliberately removed the previous `configureAI()` bag\n * because it was growing unbounded. Treat new fields here with the\n * same suspicion.\n */\nexport type AIConfig = {\n /**\n * Default `@warlock.js/cache` driver for cache-backed consumers that\n * didn't supply their own `store` currently the `semanticCache`\n * middleware's vector store. Declaring it once here removes the\n * repetition across middleware declarations.\n *\n * NOT the snapshot-persistence fallback anymore. Supervisor /\n * workflow / orchestrator resume snapshots resolve through\n * {@link AIConfig.defaultSnapshotStore} (a {@link SnapshotStore}),\n * never this driver.\n *\n * Per-declaration overrides (`semanticCache({ store })`) win when\n * supplied. Set this once at app boot, *after* you've constructed\n * your driver.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({\n * defaultStore: cache.driver(\"redis\", { client: redisClient }),\n * });\n */\n defaultStore?: CacheDriver<any, any>;\n\n /**\n * Default {@link CheckpointStore} for every orchestrator that didn't\n * supply its own `checkpointStore` (orchestrator.md §15.2). Holds\n * durable session state — `state`, `turn_index`, drift `signature`,\n * compaction locks. Per-orchestrator `checkpointStore` wins when\n * supplied. Set once at app boot.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultCheckpointStore: ai.checkpoint.memory() });\n */\n defaultCheckpointStore?: CheckpointStore;\n\n /**\n * Default {@link SnapshotStore} for every orchestrator that didn't\n * supply its own `snapshotStore` (orchestrator.md §15.2). Holds the\n * internal supervisor run state used to resume an interrupted\n * `iterate: true` turn. Per-orchestrator `snapshotStore` wins when\n * supplied. Set once at app boot.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultSnapshotStore: ai.snapshot.memory() });\n */\n defaultSnapshotStore?: SnapshotStore;\n};\n\nconst aiConfig: AIConfig = {};\n\n/**\n * Set or extend process-wide AI configuration. Merges over existing\n * values — fields not present in `partial` keep whatever was set\n * before (or stay unset). Call once at app boot, before constructing\n * any agent / supervisor / middleware that should pick up the\n * defaults.\n *\n * Returns the merged config so callers can verify what landed.\n *\n * @example\n * import { cache } from \"@warlock.js/cache\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * ai.config({ defaultStore: cache.driver(\"redis\", { client }) });\n */\nexport function setAIConfig(partial: Partial<AIConfig>): AIConfig {\n Object.assign(aiConfig, partial);\n return { ...aiConfig };\n}\n\n/**\n * Read the current AI config snapshot. Returns a shallow copy so\n * callers can't accidentally mutate the source of truth. Used\n * internally by consumers to resolve their `defaultStore` fallback.\n */\nexport function getAIConfig(): AIConfig {\n return { ...aiConfig };\n}\n\n/**\n * Resolve the effective `@warlock.js/cache` driver for a cache-backed\n * consumer that didn't receive an explicit one. Returns the global\n * `defaultStore` if set, otherwise `undefined`. The semantic-cache\n * middleware treats `undefined` as fatal and throws. Snapshot\n * persistence no longer consults this it resolves through\n * {@link resolveDefaultSnapshotStore}.\n */\nexport function resolveDefaultStore(): CacheDriver<any, any> | undefined {\n return aiConfig.defaultStore;\n}\n\n/**\n * Resolve the global default {@link CheckpointStore} for an\n * orchestrator that didn't receive an explicit `checkpointStore`.\n * Returns `undefined` when none is configured — the orchestrator\n * factory decides whether that's fatal.\n */\nexport function resolveDefaultCheckpointStore(): CheckpointStore | undefined {\n return aiConfig.defaultCheckpointStore;\n}\n\n/**\n * Resolve the global default {@link SnapshotStore} for an orchestrator\n * that didn't receive an explicit `snapshotStore`. Returns `undefined`\n * when none is configured — the orchestrator factory decides whether\n * that's fatal (it is, when `iterate: true`).\n */\nexport function resolveDefaultSnapshotStore(): SnapshotStore | undefined {\n return aiConfig.defaultSnapshotStore;\n}\n"],"mappings":";AAgFA,MAAM,WAAqB,CAAC;;;;;;;;;;;;;;;;AAiB5B,SAAgB,YAAY,SAAsC;CAChE,OAAO,OAAO,UAAU,OAAO;CAC/B,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;AAOA,SAAgB,cAAwB;CACtC,OAAO,EAAE,GAAG,SAAS;AACvB;;;;;;;;;AAUA,SAAgB,sBAAyD;CACvE,OAAO,SAAS;AAClB;;;;;;;AAQA,SAAgB,gCAA6D;CAC3E,OAAO,SAAS;AAClB;;;;;;;AAQA,SAAgB,8BAAyD;CACvE,OAAO,SAAS;AAClB"}
@@ -1,6 +1,7 @@
1
1
  import { AgentResult } from "../result/agent-result.type.mjs";
2
2
  import { ExecutableContract } from "../executable.contract.mjs";
3
3
  import { StreamContract } from "../stream/stream.contract.mjs";
4
+ import { EvalOptions, EvalReport } from "./eval.type.mjs";
4
5
  import { AgentEventMap } from "../events/event-map.type.mjs";
5
6
  import { AgentExecuteOptions } from "./agent-options.type.mjs";
6
7
 
@@ -86,6 +87,48 @@ interface AgentContract<TOutput = unknown> extends ExecutableContract<string, Ag
86
87
  * never registered or was already removed.
87
88
  */
88
89
  off<K extends keyof AgentEventMap>(event: K, handler: AgentEventHandler<K>): void;
90
+ /**
91
+ * Run a suite of evaluation cases against this agent and return an
92
+ * aggregate {@link EvalReport}. Each case runs through
93
+ * `execute(input)`; the result is scored by the resolved scorers —
94
+ * a per-case `scorers` override, else the suite `scorers`, else the
95
+ * suite `judge` (LLM-as-judge). A case passes only when every scorer
96
+ * passes and the agent did not error.
97
+ *
98
+ * Never throws on a case-level failure — failures surface on the
99
+ * report (`report.passed`, per-case `passed`) and via the
100
+ * `onFailure` callback. Throws at author time only when a case can
101
+ * resolve neither a scorer nor a judge.
102
+ *
103
+ * @example
104
+ * const report = await myAgent.eval({
105
+ * cases: [
106
+ * { name: "capital", input: "Capital of Egypt?", expected: "Cairo" },
107
+ * ],
108
+ * scorers: [ai.eval.exact()],
109
+ * });
110
+ *
111
+ * expect(report.passed).toBe(true);
112
+ *
113
+ * @example
114
+ * // LLM-as-judge
115
+ * const report = await myAgent.eval({
116
+ * cases: [{ name: "tone", input: "Comfort an upset user." }],
117
+ * judge: { agent: judgeAgent, rubric: "Score 1.0 only if empathetic." },
118
+ * });
119
+ *
120
+ * @typeParam TEval - Output type the eval cases/scorers are written
121
+ * against. Defaults to the agent's own `TOutput`, so normal calls
122
+ * stay fully typed. Exposed as a method-level generic (rather than
123
+ * pinned to the interface's `TOutput`) so that the `eval` surface —
124
+ * which references `TOutput` invariantly through the per-case
125
+ * `output` schema — does not make `AgentContract<TOutput>` itself
126
+ * invariant. That keeps a concretely-typed agent (e.g.
127
+ * `AgentContract<RouterOutput>`) assignable to an
128
+ * `AgentContract<unknown>` slot such as the supervisor's `router`,
129
+ * `intents`, and `classifier`.
130
+ */
131
+ eval<TEval = TOutput>(options: EvalOptions<TEval>): Promise<EvalReport<TEval>>;
89
132
  }
90
133
  //#endregion
91
134
  export { AgentContract, AgentEventHandler };
@@ -1 +1 @@
1
- {"version":3,"file":"agent.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/agent/agent.contract.ts"],"mappings":";;;;;;;;;AAUA;;KAAY,iBAAA,iBAAkC,aAAA,KAC5C,OAAA,EAAS,aAAA,CAAc,CAAA;;;;;;;;;;;;AAAE;AAyC3B;;;;;;;;;;;;;;;;;;;;;;;;;;UAAiB,aAAA,4BAAyC,kBAAA,SAExD,mBAAA,CAAoB,OAAA,GACpB,WAAA,CAAY,OAAA;EAAZ;;;;;;;;EAAA,SAUS,IAAA;EAmBP;;;;;EAAA,SAbO,WAAA;EAqBU;;;;;EAAA,SAfV,WAAA;EAwBT;;;;EAnBA,MAAA,CACE,KAAA,UACA,OAAA,GAAU,mBAAA,CAAoB,OAAA,IAC7B,cAAA,CAAe,WAAA,CAAY,OAAA;EAkBnB;;;;AAAoB;EAX/B,EAAA,iBAAmB,aAAA,EACjB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,iBAAA,CAAkB,CAAA;;;;;EAO7B,GAAA,iBAAoB,aAAA,EAClB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,iBAAA,CAAkB,CAAA;AAAA"}
1
+ {"version":3,"file":"agent.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/agent/agent.contract.ts"],"mappings":";;;;;;;;;;AAWA;;KAAY,iBAAA,iBAAkC,aAAA,KAC5C,OAAA,EAAS,aAAA,CAAc,CAAA;;;;;;;;;;;;AAAE;AAyC3B;;;;;;;;;;;;;;;;;;;;;;;;;;UAAiB,aAAA,4BAAyC,kBAAA,SAExD,mBAAA,CAAoB,OAAA,GACpB,WAAA,CAAY,OAAA;EAH8D;;;;;;;;EAAA,SAajE,IAAA;EAMA;;;;;EAAA,SAAA,WAAA;EAaP;;;;;EAAA,SAPO,WAAA;EAeU;;;;EAVnB,MAAA,CACE,KAAA,UACA,OAAA,GAAU,mBAAA,CAAoB,OAAA,IAC7B,cAAA,CAAe,WAAA,CAAY,OAAA;EAS5B;;;;;EAFF,EAAA,iBAAmB,aAAA,EACjB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,iBAAA,CAAkB,CAAA;EASlB;;;;EAFX,GAAA,iBAAoB,aAAA,EAClB,KAAA,EAAO,CAAA,EACP,OAAA,EAAS,iBAAA,CAAkB,CAAA;EA4ChB;;;;;;;;AAA+D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA5E,IAAA,SAAa,OAAA,EAAS,OAAA,EAAS,WAAA,CAAY,KAAA,IAAS,OAAA,CAAQ,UAAA,CAAW,KAAA;AAAA"}
@@ -0,0 +1,143 @@
1
+ import { AgentResult } from "../result/agent-result.type.mjs";
2
+ import { AgentContract } from "./agent.contract.mjs";
3
+ import { AgentExecuteOptions } from "./agent-options.type.mjs";
4
+
5
+ //#region ../@warlock.js/ai/src/contracts/agent/eval.type.d.ts
6
+ /**
7
+ * Outcome the scorer assigns to a single case. `score` is a normalized
8
+ * `0..1` quality signal; `passed` is the boolean gate the suite asserts
9
+ * on. A scorer may set `passed` independently of `score` (e.g. a hard
10
+ * threshold) — when it returns only a `score`, the runner derives
11
+ * `passed` from `score >= passThreshold`.
12
+ */
13
+ type EvalScore = {
14
+ /** Normalized quality signal in `[0, 1]`. */score: number;
15
+ /**
16
+ * Whether this case counts as a pass. When omitted the runner
17
+ * derives it from `score >= passThreshold`.
18
+ */
19
+ passed?: boolean; /** Optional human-readable explanation surfaced in the report. */
20
+ reason?: string;
21
+ };
22
+ /**
23
+ * Context handed to a {@link EvalScorer} for one case. Carries the
24
+ * case definition, the agent's actual result, and the parsed output /
25
+ * raw text shortcuts so a scorer never has to re-narrow the result
26
+ * union.
27
+ */
28
+ type EvalScorerContext<TOutput = unknown> = {
29
+ /** The case currently being scored. */case: EvalCase<TOutput>; /** The full `AgentResult` produced by running the case input. */
30
+ result: AgentResult<TOutput>; /** Shortcut for `result.data` — the parsed structured output, if any. */
31
+ output?: TOutput; /** Shortcut for `result.text` — the raw final-trip text. */
32
+ text?: string;
33
+ };
34
+ /**
35
+ * Scorer for a single eval case. Returns an {@link EvalScore} (sync or
36
+ * async). Three built-in scorers ship via the `ai.eval` namespace:
37
+ * `exactScorer`, `predicateScorer`, and `judgeScorer` (LLM-as-judge).
38
+ * Custom scorers implement this signature directly.
39
+ */
40
+ type EvalScorer<TOutput = unknown> = (context: EvalScorerContext<TOutput>) => EvalScore | Promise<EvalScore>;
41
+ /**
42
+ * A single evaluation case. `input` is the prompt fed to the agent;
43
+ * `expected` is the optional reference answer exact / judge scorers
44
+ * compare against. `scorers` overrides the suite-level scorer list for
45
+ * this case only; `options` overrides the per-call execute options.
46
+ */
47
+ type EvalCase<TOutput = unknown> = {
48
+ /** Stable identifier for the case — surfaced in the report. */name: string; /** Prompt fed to `agent.execute(input)`. */
49
+ input: string;
50
+ /**
51
+ * Reference answer the default scorers compare against. Free-form —
52
+ * a string for text comparison, a structured value for output
53
+ * comparison, or omitted when the scorer is purely predicate-based.
54
+ */
55
+ expected?: unknown; /** Per-case scorer override. Falls back to the suite `scorers`. */
56
+ scorers?: EvalScorer<TOutput>[]; /** Per-case execute-options override merged over the suite default. */
57
+ options?: AgentExecuteOptions<TOutput>;
58
+ };
59
+ /**
60
+ * LLM-as-judge configuration. When supplied to `agent.eval`, the
61
+ * judge agent scores every case that has no explicit `scorers`. The
62
+ * judge receives the case input, the expected reference (if any), and
63
+ * the actual output, and returns a `{ score, passed?, reason? }`
64
+ * verdict.
65
+ *
66
+ * `agent` must be name-bearing and configured with an output schema
67
+ * matching the judge verdict shape — the runner extracts `score` /
68
+ * `passed` / `reason` from `result.data`, falling back to parsing the
69
+ * raw text when no schema is set.
70
+ */
71
+ type EvalJudge = {
72
+ /** The judge agent. Runs once per case scored by the judge. */agent: AgentContract<unknown>;
73
+ /**
74
+ * Optional rubric prepended to the judge prompt — the criteria the
75
+ * judge grades against ("score 1.0 only if the answer cites a
76
+ * source", etc.).
77
+ */
78
+ rubric?: string;
79
+ /**
80
+ * Score at or above which the judge verdict counts as a pass when
81
+ * the judge returns only a numeric score. Defaults to the suite
82
+ * `passThreshold`.
83
+ */
84
+ passThreshold?: number;
85
+ };
86
+ /**
87
+ * Options for `agent.eval`.
88
+ *
89
+ * `cases` is the suite; `scorers` is the default scorer list applied
90
+ * to every case lacking its own; `judge` enables LLM-as-judge scoring
91
+ * for cases with neither. At least one of `scorers` / `judge` must be
92
+ * resolvable per case or the runner throws at author time.
93
+ */
94
+ type EvalOptions<TOutput = unknown> = {
95
+ /** The evaluation cases to run. */cases: EvalCase<TOutput>[]; /** Default scorers applied to every case without its own `scorers`. */
96
+ scorers?: EvalScorer<TOutput>[]; /** LLM-as-judge fallback for cases with no scorers. */
97
+ judge?: EvalJudge;
98
+ /**
99
+ * Score at or above which a case passes when a scorer returns only a
100
+ * numeric `score` (no explicit `passed`). Defaults to `0.5`.
101
+ */
102
+ passThreshold?: number;
103
+ /**
104
+ * Fired once per failing case, after it is scored. Receives the
105
+ * full case result so suites can log, snapshot, or accumulate
106
+ * failures. Errors thrown here are swallowed so a reporting bug
107
+ * cannot abort the run.
108
+ */
109
+ onFailure?: (caseResult: EvalCaseResult<TOutput>) => void | Promise<void>; /** Execute-options applied to every case (merged under per-case `options`). */
110
+ executeOptions?: AgentExecuteOptions<TOutput>;
111
+ };
112
+ /**
113
+ * Per-case outcome in an {@link EvalReport}. Bundles the case, the
114
+ * agent result, the resolved scores, and the case-level pass/fail
115
+ * verdict (the AND of every scorer's `passed`).
116
+ */
117
+ type EvalCaseResult<TOutput = unknown> = {
118
+ /** The case that produced this result. */case: EvalCase<TOutput>; /** The full agent result for the case input. */
119
+ result: AgentResult<TOutput>; /** Every scorer's verdict, in scorer order. */
120
+ scores: EvalScore[]; /** Mean of `scores[].score` — the case's aggregate quality signal. */
121
+ score: number; /** `true` only when EVERY scorer passed and the agent did not error. */
122
+ passed: boolean; /** Wall-clock duration of the case run in milliseconds. */
123
+ duration: number;
124
+ };
125
+ /**
126
+ * Aggregate report returned by `agent.eval`. Summarizes pass rate and
127
+ * mean score across the suite and carries every per-case result for
128
+ * drill-down. Assertion-friendly: `expect(report.passed).toBe(true)`.
129
+ */
130
+ type EvalReport<TOutput = unknown> = {
131
+ /** Name of the agent under evaluation. */agentName: string; /** Total number of cases run. */
132
+ total: number; /** Number of cases that passed. */
133
+ passedCount: number; /** Number of cases that failed. */
134
+ failedCount: number; /** `passedCount / total` in `[0, 1]`. */
135
+ passRate: number; /** Mean of every case's aggregate `score`. */
136
+ meanScore: number; /** `true` only when every case passed. */
137
+ passed: boolean; /** Per-case results in suite order. */
138
+ cases: EvalCaseResult<TOutput>[]; /** Total wall-clock duration of the whole suite in milliseconds. */
139
+ duration: number;
140
+ };
141
+ //#endregion
142
+ export { EvalCase, EvalCaseResult, EvalJudge, EvalOptions, EvalReport, EvalScore, EvalScorer, EvalScorerContext };
143
+ //# sourceMappingURL=eval.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/agent/eval.type.ts"],"mappings":";;;;;;;AAWA;;;;;KAAY,SAAA;EASV,6CAPA,KAAA;EAOM;AASR;;;EAXE,MAAA,YAaM;EAXN,MAAA;AAAA;;;;;;;KASU,iBAAA;EAIV,uCAFA,IAAA,EAAM,QAAA,CAAS,OAAA,GAEK;EAApB,MAAA,EAAQ,WAAA,CAAY,OAAA,GAEX;EAAT,MAAA,GAAS,OAAA,EAEL;EAAJ,IAAA;AAAA;;;;;;;KASU,UAAA,uBACV,OAAA,EAAS,iBAAA,CAAkB,OAAA,MACxB,SAAA,GAAY,OAAA,CAAQ,SAAA;;;;;;;KAQb,QAAA;EARK,+DAUf,IAAA,UAVgC;EAYhC,KAAA;EAJU;;;;;EAUV,QAAA,YAIU;EAFV,OAAA,GAAU,UAAA,CAAW,OAAA,KAEQ;EAA7B,OAAA,GAAU,mBAAA,CAAoB,OAAA;AAAA;;;;;;;;;;AAAO;AAevC;;KAAY,SAAA;EAEU,+DAApB,KAAA,EAAO,aAAa;EAAb;;;;AAYM;EANb,MAAA;EAiBqB;;;;;EAXrB,aAAA;AAAA;;;;;;;;;KAWU,WAAA;EAEH,mCAAP,KAAA,EAAO,QAAA,CAAS,OAAA,KAEhB;EAAA,OAAA,GAAU,UAAA,CAAW,OAAA,KAAA;EAErB,KAAA,GAAQ,SAAA;EAAA;;;;EAKR,aAAA;EAOa;;;;;;EAAb,SAAA,IAAa,UAAA,EAAY,cAAA,CAAe,OAAA,aAAoB,OAAA,QAUlD;EARV,cAAA,GAAiB,mBAAA,CAAoB,OAAA;AAAA;;;;;;KAQ3B,cAAA;EAMO,0CAJjB,IAAA,EAAM,QAAA,CAAS,OAAA,GAAf;EAEA,MAAA,EAAQ,WAAA,CAAY,OAAA,GAFL;EAIf,MAAA,EAAQ,SAAA,IAFA;EAIR,KAAA,UAFA;EAIA,MAAA,WAFA;EAIA,QAAA;AAAA;;AAAQ;AAQV;;;KAAY,UAAA;EAAW,0CAErB,SAAA,UAEA;EAAA,KAAA,UAIA;EAFA,WAAA,UAMA;EAJA,WAAA,UAQA;EANA,QAAA,UAMsB;EAJtB,SAAA,UAMQ;EAJR,MAAA;EAEA,KAAA,EAAO,cAAc,CAAC,OAAA;EAEtB,QAAA;AAAA"}
@@ -1,2 +1,3 @@
1
+ import { EvalCase, EvalCaseResult, EvalJudge, EvalOptions, EvalReport, EvalScore, EvalScorer, EvalScorerContext } from "./eval.type.mjs";
1
2
  import { AgentContract, AgentEventHandler } from "./agent.contract.mjs";
2
3
  import { AgentExecuteOptions } from "./agent-options.type.mjs";
@@ -1,10 +1,10 @@
1
1
  import { AIError } from "../../errors/ai-error.mjs";
2
2
  import { Usage } from "../result/usage.type.mjs";
3
- import { Next } from "../supervisor/next.type.mjs";
4
- import { IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
3
+ import { SupervisorResult } from "../result/supervisor-result.type.mjs";
5
4
  import { SupervisorInput } from "../supervisor/supervisor-input.type.mjs";
5
+ import { Next } from "../supervisor/next.type.mjs";
6
6
  import { EvaluateResult } from "../supervisor/evaluate-context.type.mjs";
7
- import { SupervisorResult } from "../result/supervisor-result.type.mjs";
7
+ import { IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
8
8
  //#region ../@warlock.js/ai/src/contracts/events/supervisor-events.type.d.ts
9
9
  /** Fires once at the start of every `supervisor.execute()` call. */
10
10
  type SupervisorStartingPayload = {