@warlock.js/ai 4.2.11 → 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,65 @@
1
+ import { AIErrorCode } from "../errors/error-code.type.mjs";
2
+ import { ModelContract } from "./model.contract.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/contracts/fallback-model.contract.d.ts
5
+ /**
6
+ * Predicate deciding whether a thrown error should advance the fallback
7
+ * chain to the next model. Receives the original error verbatim (an
8
+ * `AIError` subclass when the failure came from a provider adapter, or
9
+ * any thrown value otherwise) and returns `true` to fall over, `false`
10
+ * to re-throw immediately.
11
+ *
12
+ * @example
13
+ * fallbackModel([primary, backup], {
14
+ * retryOn: (error) => error instanceof ProviderError,
15
+ * });
16
+ */
17
+ type FallbackRetryPredicate = (error: unknown) => boolean;
18
+ /**
19
+ * Tuning knobs for {@link fallbackModel}. Both forms of `retryOn` are
20
+ * additive over the built-in transient-failure default (rate-limit,
21
+ * timeout, and generic 5xx provider errors); omit it entirely to use
22
+ * that default unchanged.
23
+ */
24
+ type FallbackModelOptions = {
25
+ /**
26
+ * Which failures advance the chain. Either an explicit allow-list of
27
+ * stable {@link AIErrorCode} strings, or a predicate for arbitrary
28
+ * branching. Absent = the built-in transient set
29
+ * (`PROVIDER_RATE_LIMIT`, `PROVIDER_TIMEOUT`, `PROVIDER_ERROR`).
30
+ *
31
+ * Non-transient failures (auth, invalid-request, context-length,
32
+ * content-filter) are NEVER retried by default — falling over on a
33
+ * bad API key or an oversized prompt only burns the budget on every
34
+ * downstream model, since the same input fails identically.
35
+ */
36
+ retryOn?: AIErrorCode[] | FallbackRetryPredicate;
37
+ };
38
+ /**
39
+ * Diagnostic record of one model that the fallback chain tried and that
40
+ * failed with a chain-advancing error. Exposed on the wrapper's
41
+ * `lastAttempts` getter so callers can see exactly which providers were
42
+ * burned before the chain produced a response (or re-threw the final
43
+ * error).
44
+ */
45
+ type FallbackAttempt = {
46
+ /** Model identifier that failed (`ModelContract.name`). */modelName: string; /** Provider the failed model belonged to (`ModelContract.provider`). */
47
+ provider: string; /** The error that triggered the fall-over to the next model. */
48
+ error: unknown;
49
+ };
50
+ /**
51
+ * The `ModelContract` returned by `fallbackModel()`: a fully usable
52
+ * model that additionally exposes which wrapped models failed (and why)
53
+ * during the most recent call.
54
+ */
55
+ interface FallbackModelContract extends ModelContract {
56
+ /**
57
+ * Models that failed with a chain-advancing error during the most
58
+ * recent `complete()` / `stream()` call, in attempt order. Empty when
59
+ * the primary model succeeded outright. Overwritten on each call.
60
+ */
61
+ readonly lastAttempts: FallbackAttempt[];
62
+ }
63
+ //#endregion
64
+ export { FallbackAttempt, FallbackModelContract, FallbackModelOptions, FallbackRetryPredicate };
65
+ //# sourceMappingURL=fallback-model.contract.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback-model.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/fallback-model.contract.ts"],"mappings":";;;;;;AAeA;;;;AAAoD;AAQpD;;;;;KARY,sBAAA,IAA0B,KAAc;;;AAoBF;AAUlD;;;KAtBY,oBAAA;EAwBV;;;;AAIK;AAQP;;;;;;EAxBE,OAAA,GAAU,WAAA,KAAgB,sBAAsB;AAAA;AA8BV;;;;;;;AAAA,KApB5B,eAAA;6DAEV,SAAA;EAEA,QAAA;EAEA,KAAA;AAAA;;;;;;UAQe,qBAAA,SAA8B,aAAa;;;;;;WAMjD,YAAA,EAAc,eAAA;AAAA"}
@@ -18,46 +18,66 @@ import { ExecuteResult } from "./result/execute-result.type.mjs";
18
18
  import { ExecutableContract } from "./executable.contract.mjs";
19
19
  import { StreamEvent, StreamEventBody } from "./stream/stream-event.type.mjs";
20
20
  import { StreamContract } from "./stream/stream.contract.mjs";
21
+ import { EvalCase, EvalCaseResult, EvalJudge, EvalOptions, EvalReport, EvalScore, EvalScorer, EvalScorerContext } from "./agent/eval.type.mjs";
21
22
  import { AgentContract, AgentEventHandler } from "./agent/agent.contract.mjs";
22
23
  import { END, EndSentinel } from "./end.type.mjs";
24
+ import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./result/supervisor-result.type.mjs";
23
25
  import { StepSnapshot } from "./result/step-result.type.mjs";
24
26
  import { WorkflowReport, WorkflowResult } from "./result/workflow-result.type.mjs";
25
27
  import { ToolConfig, ToolContext, ToolMeta, ToolMode } from "./tool.contract.mjs";
28
+ import { SupervisorInput } from "./supervisor/supervisor-input.type.mjs";
29
+ import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./supervisor/supervisor-snapshot.type.mjs";
30
+ import { PgClientLike, RedisClientLike, SnapshotStore } from "./orchestrator/snapshot-store.contract.mjs";
26
31
  import { NextStepResult } from "./workflow/next-step-result.type.mjs";
27
32
  import { RetryBackoff, RetryConfig } from "./workflow/retry-config.type.mjs";
28
33
  import { WorkflowContext } from "./workflow/workflow-context.type.mjs";
29
34
  import { StepAgentInput, StepDefinition, StepLocalEvents, StepOutputSpec } from "./workflow/step.contract.mjs";
35
+ import { WorkflowSnapshot } from "./workflow/workflow-snapshot.type.mjs";
30
36
  import { WorkflowDefinition, WorkflowEventHandler, WorkflowEventHandlers, WorkflowExecuteOptions, WorkflowInstance, WorkflowResumeOptions, WorkflowRunOptions } from "./workflow/workflow.contract.mjs";
37
+ import { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk, ReasoningEffort } from "./model.contract.mjs";
38
+ import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor/supervisor-execute-options.type.mjs";
39
+ import { MiddlewareState } from "./middleware/middleware-state.type.mjs";
40
+ import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareSupervisorContext, MiddlewareSupervisorRef, MiddlewareToolContext, MiddlewareTripContext } from "./middleware/middleware-context.type.mjs";
41
+ import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareSupervisorHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./middleware/middleware.contract.mjs";
31
42
  import { Placeholders } from "./placeholders.type.mjs";
32
43
  import { InstructionContract, PersonaContract, SystemPromptBlockContract, SystemPromptContract } from "./system-prompt.contract.mjs";
33
- import { Next } from "./supervisor/next.type.mjs";
34
- import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./supervisor/iteration-snapshot.type.mjs";
35
- import { SupervisorInput } from "./supervisor/supervisor-input.type.mjs";
36
- import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./supervisor/evaluate-context.type.mjs";
37
44
  import { RouteContext } from "./supervisor/route-context.type.mjs";
38
45
  import { AckCallback, AckConfig, AckEntry, AckRunEntry } from "./supervisor/ack-entry.type.mjs";
39
46
  import { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue } from "./supervisor/intent-entry.type.mjs";
47
+ import { Next } from "./supervisor/next.type.mjs";
40
48
  import { RouterEntry } from "./supervisor/router-entry.type.mjs";
41
49
  import { SupervisorConfig, SupervisorEventHandler, SupervisorEventHandlers } from "./supervisor/supervisor-config.type.mjs";
42
- import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor/supervisor-execute-options.type.mjs";
43
50
  import { SupervisorStreamEvent } from "./supervisor/supervisor-stream-event.type.mjs";
44
51
  import { SupervisorAsToolOptions, SupervisorContract } from "./supervisor/supervisor.contract.mjs";
45
52
  import { DispatchContext, IntentRunner, IntentRunnerMap } from "./supervisor/dispatch-context.type.mjs";
46
53
  import { ClassifierAgentEntry, ClassifierCallback, ClassifierConfig, ClassifierContext, ClassifierOutput, ClassifierRefineContext, ClassifierRefineResult, ClassifierRunEntry, ClassifierSnapshot } from "./supervisor/classifier-context.type.mjs";
47
- import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./result/supervisor-result.type.mjs";
54
+ import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./supervisor/evaluate-context.type.mjs";
55
+ import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./supervisor/iteration-snapshot.type.mjs";
56
+ import { CompactionResult, OrchestratorAwaitingStatus, OrchestratorReport, OrchestratorReportStatus, OrchestratorReportType, OrchestratorResult, TurnSnapshot } from "./result/orchestrator-result.type.mjs";
48
57
  import { SessionSendResult } from "./result/session-send-result.type.mjs";
49
- import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./supervisor/supervisor-snapshot.type.mjs";
50
58
  import { SupervisorAgentCompletedPayload, SupervisorAgentFailedPayload, SupervisorAgentStartingPayload, SupervisorAgentStreamingPayload, SupervisorCancelledPayload, SupervisorCompletedPayload, SupervisorErrorPayload, SupervisorEvaluateVerdictPayload, SupervisorIterationCompletedPayload, SupervisorIterationStartingPayload, SupervisorRouterDecidedPayload, SupervisorRouterDecidingPayload, SupervisorStartingPayload } from "./events/supervisor-events.type.mjs";
51
59
  import { WorkflowCancelledPayload, WorkflowCompletedPayload, WorkflowErrorPayload, WorkflowLoopWarningPayload, WorkflowStartingPayload, WorkflowStepCompletedPayload, WorkflowStepFailedPayload, WorkflowStepRetryingPayload, WorkflowStepSkippedPayload, WorkflowStepStartingPayload, WorkflowStepStreamingPayload } from "./events/workflow-events.type.mjs";
52
60
  import { AgentEventMap, SupervisorEventMap, WorkflowEventMap } from "./events/event-map.type.mjs";
53
61
  import { StreamingToolGuardConfig } from "./streaming-tool-guard-config.type.mjs";
54
62
  import { AgentExecuteOptions } from "./agent/agent-options.type.mjs";
55
63
  import { EmbedderConfig, EmbedderContract, EmbeddingBatchResult, EmbeddingResult, EmbeddingUsage } from "./embedder.contract.mjs";
56
- import { MiddlewareState } from "./middleware/middleware-state.type.mjs";
57
- import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareToolContext, MiddlewareTripContext } from "./middleware/middleware-context.type.mjs";
58
- import { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk } from "./model.contract.mjs";
59
- import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./middleware/middleware.contract.mjs";
64
+ import { MemoryItem, MemoryTier, RecalledMemory } from "./memory/memory-item.type.mjs";
65
+ import { RecallOptions } from "./memory/recall-options.type.mjs";
66
+ import { MemoryContract } from "./memory/memory.contract.mjs";
67
+ import { MemoryConfig, SemanticMemoryConfig } from "./memory/memory-config.type.mjs";
68
+ import { CheckpointRecord, CheckpointStore } from "./orchestrator/checkpoint-store.contract.mjs";
69
+ import { OrchestratorCommands } from "./orchestrator/orchestrator-commands.type.mjs";
70
+ import { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "./orchestrator/orchestrator-event.type.mjs";
71
+ import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "./orchestrator/orchestrator-execute-options.type.mjs";
72
+ import { OrchestratorAsToolOptions, OrchestratorContract, OrchestratorSessionScope, SessionContextOverrides } from "./orchestrator/orchestrator.contract.mjs";
73
+ import { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig } from "./orchestrator/orchestrator-config.type.mjs";
74
+ import { SessionContract } from "./orchestrator/session.contract.mjs";
75
+ import { PlannerCapability } from "./planner/planner-capability.type.mjs";
76
+ import { PlannerConfig } from "./planner/planner-config.type.mjs";
77
+ import { PlannerExecuteOptions } from "./planner/planner-execute-options.type.mjs";
78
+ import { PlannerPlan, PlannerStep } from "./planner/planner-plan.type.mjs";
79
+ import { PlannerReport, PlannerReportType, PlannerResult, PlannerStepSnapshot } from "./planner/planner-result.type.mjs";
80
+ import { PlannerContract } from "./planner/planner.contract.mjs";
60
81
  import { ModelConfig, SDKAdapterContract } from "./sdk-adapter.contract.mjs";
61
- import { WorkflowSnapshot } from "./workflow/workflow-snapshot.type.mjs";
62
82
  import { CompleteEvent } from "./events/complete-event.type.mjs";
63
83
  import { UsageEvent } from "./events/usage-event.type.mjs";
@@ -0,0 +1,4 @@
1
+ import { MemoryItem, MemoryTier, RecalledMemory } from "./memory-item.type.mjs";
2
+ import { RecallOptions } from "./recall-options.type.mjs";
3
+ import { MemoryContract } from "./memory.contract.mjs";
4
+ import { MemoryConfig, SemanticMemoryConfig } from "./memory-config.type.mjs";
@@ -0,0 +1,150 @@
1
+ import { EmbedderContract } from "../embedder.contract.mjs";
2
+ import { MemoryTier } from "./memory-item.type.mjs";
3
+ import { CacheDriver } from "@warlock.js/cache";
4
+
5
+ //#region ../@warlock.js/ai/src/contracts/memory/memory-config.type.d.ts
6
+ /**
7
+ * Semantic-tier wiring for `memory(config)`.
8
+ *
9
+ * Mirrors the `semanticCache` middleware's delegation model: memory does
10
+ * NOT implement similarity search itself — it stores embeddings in a
11
+ * `@warlock.js/cache` driver and retrieves them via the driver's native
12
+ * `.similar()`. Supply the embedder that turns text into vectors and the
13
+ * store that indexes them.
14
+ *
15
+ * Dev / test environments pass `new MemoryCacheDriver()` (zero config,
16
+ * O(N) scan). Production picks a driver with a real ANN index — `pg`
17
+ * with pgvector, `redis` with RediSearch. Drivers without similarity
18
+ * support throw `CacheUnsupportedError` from `set({ vector })` /
19
+ * `similar()`.
20
+ */
21
+ type SemanticMemoryConfig = {
22
+ /** Embedder used to vectorize remembered text and recall queries. */embedder: EmbedderContract;
23
+ /**
24
+ * Vector-capable cache driver from `@warlock.js/cache`. Falls back to
25
+ * `ai.config({ defaultStore })` when omitted; the factory throws at
26
+ * construction when neither is available.
27
+ */
28
+ store?: CacheDriver<any, any>;
29
+ /**
30
+ * Namespace prefix applied to every key the semantic tier writes. Lets
31
+ * multiple memory instances share one driver without collision.
32
+ * Default `"ai.memory"`.
33
+ */
34
+ namespace?: string;
35
+ };
36
+ /**
37
+ * Episodic-tier wiring for `memory(config)`.
38
+ *
39
+ * Like the semantic tier, episodic memory is embedder-backed and stores
40
+ * its vectors in a `@warlock.js/cache` driver — it adds a per-entry
41
+ * timestamp and blends **recency** into the recall score so recent
42
+ * episodes outrank stale ones at equal similarity.
43
+ */
44
+ type EpisodicMemoryConfig = {
45
+ /** Embedder used to vectorize remembered episodes and recall queries. */embedder: EmbedderContract;
46
+ /**
47
+ * Vector-capable cache driver. Falls back to `ai.config({ defaultStore })`
48
+ * when omitted; the factory throws at construction when neither exists.
49
+ */
50
+ store?: CacheDriver<any, any>;
51
+ /**
52
+ * Namespace prefix for every key this tier writes. Default
53
+ * `"ai.memory.episodic"`. Keep distinct from sibling tiers when sharing
54
+ * one driver.
55
+ */
56
+ namespace?: string;
57
+ /**
58
+ * How much recency counts versus similarity in the blended score, in
59
+ * `[0, 1]`. `0` = pure similarity (semantic-style); higher favors
60
+ * recent episodes. Default `0.3`.
61
+ */
62
+ recencyWeight?: number;
63
+ /**
64
+ * Age at which an episode's recency contribution halves, in
65
+ * milliseconds. Default 7 days. Larger = slower decay.
66
+ */
67
+ halfLifeMs?: number;
68
+ /**
69
+ * Clock used to stamp + age episodes. Defaults to `Date.now`. Override
70
+ * for deterministic tests or replay.
71
+ */
72
+ now?: () => number;
73
+ };
74
+ /**
75
+ * Procedural-tier wiring for `memory(config)`.
76
+ *
77
+ * Embedder-backed like the semantic tier, but blends **reinforcement**
78
+ * into the recall score: re-remembering a procedure increments its use
79
+ * count, so well-worn procedures outrank one-offs at equal similarity.
80
+ */
81
+ type ProceduralMemoryConfig = {
82
+ /** Embedder used to vectorize remembered procedures and recall queries. */embedder: EmbedderContract;
83
+ /**
84
+ * Vector-capable cache driver. Falls back to `ai.config({ defaultStore })`
85
+ * when omitted; the factory throws at construction when neither exists.
86
+ */
87
+ store?: CacheDriver<any, any>;
88
+ /**
89
+ * Namespace prefix for every key this tier writes. Default
90
+ * `"ai.memory.procedural"`. Keep distinct from sibling tiers when
91
+ * sharing one driver.
92
+ */
93
+ namespace?: string;
94
+ /**
95
+ * How much reinforcement counts versus similarity in the blended score,
96
+ * in `[0, 1]`. `0` = pure similarity; higher favors well-used
97
+ * procedures. Default `0.3`.
98
+ */
99
+ reinforcementWeight?: number;
100
+ };
101
+ /**
102
+ * Configuration for the `memory(config)` factory.
103
+ *
104
+ * At least one tier must be enabled. The working tier is on by default
105
+ * (`working: true`); the semantic, episodic, and procedural tiers each
106
+ * activate only when their config is supplied. Enabling neither is a
107
+ * construction-time error — a memory with no tiers can't store or recall
108
+ * anything.
109
+ */
110
+ type MemoryConfig = {
111
+ /** Stable identifier — used in logs and as the working-tier scope key. */name?: string;
112
+ /**
113
+ * Enable the in-run working tier. Default `true`. Set `false` to build
114
+ * a semantic-only memory.
115
+ */
116
+ working?: boolean;
117
+ /**
118
+ * Enable + wire the semantic recall tier. Omit for a working-only
119
+ * memory.
120
+ */
121
+ semantic?: SemanticMemoryConfig;
122
+ /**
123
+ * Enable + wire the episodic tier — durable, recency-blended recall of
124
+ * timestamped events. Omit to leave it off.
125
+ */
126
+ episodic?: EpisodicMemoryConfig;
127
+ /**
128
+ * Enable + wire the procedural tier — durable, reinforcement-blended
129
+ * recall of learned how-tos. Omit to leave it off.
130
+ */
131
+ procedural?: ProceduralMemoryConfig;
132
+ /**
133
+ * Tier a `remember(...)` item lands in when it doesn't name its own
134
+ * `tier`. Default `"working"`. Must reference an enabled tier.
135
+ */
136
+ defaultTier?: MemoryTier;
137
+ /**
138
+ * Default number of memories `recall(...)` returns when the call
139
+ * doesn't override `k`. Default `5`.
140
+ */
141
+ k?: number;
142
+ /**
143
+ * Default minimum semantic similarity for a recall hit, in `[0, 1]`.
144
+ * Default `0.7`. Ignored by the working tier.
145
+ */
146
+ threshold?: number;
147
+ };
148
+ //#endregion
149
+ export { EpisodicMemoryConfig, MemoryConfig, ProceduralMemoryConfig, SemanticMemoryConfig };
150
+ //# sourceMappingURL=memory-config.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-config.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/memory/memory-config.type.ts"],"mappings":";;;;;;;AAmBA;;;;;;;;;;AAcW;AAWX;;KAzBY,oBAAA;EAgCS,qEA9BnB,QAAA,EAAU,gBAAA;EAyBA;;;;;EAnBV,KAAA,GAAQ,WAAW;EA8CnB;;AAAG;AAUL;;EAlDE,SAAA;AAAA;;;;;;;;AAqEmB;KA1DT,oBAAA;EAsEY,yEApEtB,QAAA,EAAU,gBAAA;EAgFC;;;;EA3EX,KAAA,GAAQ,WAAW;EA0FK;;;;;EApFxB,SAAA;EA0EW;;;;;EApEX,aAAA;EAwFA;;AAAS;;EAnFT,UAAA;;;;;EAKA,GAAA;AAAA;;;;;;;;KAUU,sBAAA;6EAEV,QAAA,EAAU,gBAAA;;;;;EAKV,KAAA,GAAQ,WAAW;;;;;;EAMnB,SAAA;;;;;;EAMA,mBAAA;AAAA;;;;;;;;;;KAYU,YAAA;4EAEV,IAAA;;;;;EAKA,OAAA;;;;;EAKA,QAAA,GAAW,oBAAA;;;;;EAKX,QAAA,GAAW,oBAAA;;;;;EAKX,UAAA,GAAa,sBAAA;;;;;EAKb,WAAA,GAAc,UAAA;;;;;EAKd,CAAA;;;;;EAKA,SAAA;AAAA"}
@@ -0,0 +1,64 @@
1
+ //#region ../@warlock.js/ai/src/contracts/memory/memory-item.type.d.ts
2
+ /**
3
+ * The four memory tiers shipped in 4.3.0.
4
+ *
5
+ * - `"working"` — in-run scratch the orchestrator threads across turns.
6
+ * Volatile, unscored, retrieved in insertion order (recency proxy).
7
+ * - `"semantic"` — durable *facts*, stored as embeddings in a
8
+ * `@warlock.js/cache` driver, retrieved by cosine similarity.
9
+ * - `"episodic"` — durable *events*: a timestamped log retrieved by
10
+ * similarity **blended with recency**, so recent episodes outrank stale
11
+ * ones at equal relevance.
12
+ * - `"procedural"` — durable *how-tos*: learned procedures retrieved by
13
+ * similarity **blended with reinforcement**, so a procedure remembered
14
+ * (re-affirmed) more often outranks a one-off at equal relevance.
15
+ *
16
+ * `working` + `semantic` need no extra wiring (semantic needs an embedder
17
+ * + store); `episodic` and `procedural` are embedder-backed like
18
+ * semantic. Decay / forgetting (TTL-based relevance falloff, eviction)
19
+ * remains DEFERRED. The union widened from the v1 `working | semantic`
20
+ * pair to add the two new tiers — a non-breaking change, since every
21
+ * prior value is still valid.
22
+ */
23
+ type MemoryTier = "working" | "semantic" | "episodic" | "procedural";
24
+ /**
25
+ * A single unit a caller hands to `memory.remember(...)`.
26
+ *
27
+ * `text` is the only required field — it is what gets embedded for the
28
+ * semantic tier and what is surfaced back on recall. `tier` selects the
29
+ * destination; omit it to fall back to the factory's `defaultTier`.
30
+ *
31
+ * `id` lets a caller address an entry for later overwrite / dedup. When
32
+ * absent the factory derives a stable id from the text so re-remembering
33
+ * identical text updates in place rather than duplicating.
34
+ *
35
+ * `metadata` is an opaque bag round-tripped verbatim onto the recalled
36
+ * memory — use it for source ids, timestamps, tags, or anything the
37
+ * consumer wants back alongside the text.
38
+ */
39
+ type MemoryItem = {
40
+ /** Natural-language content. Embedded for semantic recall; surfaced verbatim on retrieval. */text: string; /** Destination tier. Defaults to the factory's `defaultTier` when omitted. */
41
+ tier?: MemoryTier; /** Caller-owned identifier for overwrite / dedup. Derived from `text` when omitted. */
42
+ id?: string; /** Opaque metadata round-tripped onto the recalled memory unchanged. */
43
+ metadata?: Record<string, unknown>;
44
+ };
45
+ /**
46
+ * A memory returned from `memory.recall(...)`, carrying the relevance
47
+ * `score` the retrieval assigned it.
48
+ *
49
+ * `score` is in `[0, 1]` for every tier so a consumer can sort a mixed
50
+ * recall set on one field without special-casing the tier: cosine
51
+ * similarity for `semantic`, a recency proxy for `working` (most-recent =
52
+ * 1), similarity blended with recency for `episodic`, and similarity
53
+ * blended with reinforcement for `procedural`.
54
+ */
55
+ type RecalledMemory = {
56
+ /** Stable id of the stored memory. */id: string; /** The remembered text, surfaced for injection into context. */
57
+ text: string; /** Which tier produced this hit. */
58
+ tier: MemoryTier; /** Relevance in `[0, 1]` — cosine similarity (semantic) or recency proxy (working). */
59
+ score: number; /** Opaque metadata stored alongside the memory, returned verbatim. */
60
+ metadata?: Record<string, unknown>;
61
+ };
62
+ //#endregion
63
+ export { MemoryItem, MemoryTier, RecalledMemory };
64
+ //# sourceMappingURL=memory-item.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-item.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/memory/memory-item.type.ts"],"mappings":";;AAqBA;;;;AAAsB;AAiBtB;;;;;;;;;;;AAQmB;AAanB;;;KAtCY,UAAA;;;;;;;;;AAgDO;;;;;;;KA/BP,UAAA;gGAEV,IAAA;EAEA,IAAA,GAAO,UAAA;EAEP,EAAA;EAEA,QAAA,GAAW,MAAM;AAAA;;;;;;;;;;;KAaP,cAAA;wCAEV,EAAA;EAEA,IAAA;EAEA,IAAA,EAAM,UAAA;EAEN,KAAA;EAEA,QAAA,GAAW,MAAM;AAAA"}
@@ -0,0 +1,87 @@
1
+ import { MemoryItem, MemoryTier, RecalledMemory } from "./memory-item.type.mjs";
2
+ import { RecallOptions } from "./recall-options.type.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/contracts/memory/memory.contract.d.ts
5
+ /**
6
+ * Provider-neutral contract for an agent memory store (memory core M1).
7
+ *
8
+ * **Role.** A single store that holds and retrieves what an agent /
9
+ * orchestrator should remember across turns. Four tiers ship in 4.3.0:
10
+ *
11
+ * - **working** — in-run scratch the orchestrator threads across turns
12
+ * of one session. Volatile, unscored, recalled in insertion order.
13
+ * - **semantic** — durable *facts* stored as embeddings in a
14
+ * `@warlock.js/cache` driver, retrieved by cosine similarity via the
15
+ * driver's `.similar()` (the same delegation the `semanticCache`
16
+ * middleware uses).
17
+ * - **episodic** — durable *events*: a timestamped log retrieved by
18
+ * similarity blended with recency, so recent episodes outrank stale
19
+ * ones at equal relevance.
20
+ * - **procedural** — durable *how-tos*: learned procedures retrieved by
21
+ * similarity blended with reinforcement, so a procedure re-affirmed
22
+ * more often outranks a one-off.
23
+ *
24
+ * `recall()` returns {@link RecalledMemory}[] — scored entries the
25
+ * caller injects into the model context (system prefix, a synthesized
26
+ * "what you remember" block, etc.). Memory never mutates the prompt
27
+ * itself; surfacing the recalled text is the consumer's call so the
28
+ * injection point stays explicit.
29
+ *
30
+ * **Still deferred.** Decay / forgetting (TTL-based relevance falloff,
31
+ * eviction policies) is not yet implemented; the four tiers above are the
32
+ * full 4.3.0 surface. The `episodic` and `procedural` tiers were added in
33
+ * 4.3.0 as a non-breaking widening of the {@link MemoryTier} union.
34
+ *
35
+ * Front it with the `memory(config)` factory — callers never `new` an
36
+ * implementation.
37
+ *
38
+ * @example
39
+ * import { ai } from "@warlock.js/ai";
40
+ * import { MemoryCacheDriver } from "@warlock.js/cache";
41
+ *
42
+ * const store = new MemoryCacheDriver();
43
+ * store.setOptions({});
44
+ *
45
+ * const mem = ai.memory({
46
+ * semantic: {
47
+ * embedder: openai.embedder({ name: "text-embedding-3-small" }),
48
+ * store,
49
+ * },
50
+ * });
51
+ *
52
+ * await mem.remember({ text: "User prefers metric units.", tier: "semantic" });
53
+ * const hits = await mem.recall("which units does the user like?", { k: 3 });
54
+ */
55
+ interface MemoryContract {
56
+ /** Stable identifier — surfaced in logs and used as the working-tier scope key. */
57
+ readonly name: string;
58
+ /**
59
+ * Store one or more memories. Each item lands in its own `tier` (or
60
+ * the factory's `defaultTier` when unset). Items addressed to the
61
+ * semantic tier are embedded and indexed; working-tier items are
62
+ * appended to the in-run buffer.
63
+ *
64
+ * Re-remembering an item whose id (explicit or text-derived) already
65
+ * exists overwrites it in place rather than duplicating.
66
+ */
67
+ remember(items: MemoryItem | MemoryItem[]): Promise<void>;
68
+ /**
69
+ * Retrieve the memories most relevant to `query`, scored and ordered
70
+ * by descending relevance. Queries every enabled tier by default;
71
+ * `options.tier` narrows to one. `options.k` caps the result count,
72
+ * `options.threshold` raises the semantic-similarity floor.
73
+ *
74
+ * Returns an empty array when nothing clears the threshold — never
75
+ * throws on "no hits".
76
+ */
77
+ recall(query: string, options?: RecallOptions): Promise<RecalledMemory[]>;
78
+ /**
79
+ * Forget memories. With no argument, clears every tier. With a `tier`,
80
+ * clears just that tier — e.g. `clear("working")` at the end of a
81
+ * session while leaving durable semantic recall intact.
82
+ */
83
+ clear(tier?: MemoryTier): Promise<void>;
84
+ }
85
+ //#endregion
86
+ export { MemoryContract };
87
+ //# sourceMappingURL=memory.contract.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/memory/memory.contract.ts"],"mappings":";;;;;;AAqDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BmC;;;;;;;;;;;;;;;;;;UA/BlB,cAAA;;WAEN,IAAA;;;;;;;;;;EAWT,QAAA,CAAS,KAAA,EAAO,UAAA,GAAa,UAAA,KAAe,OAAA;;;;;;;;;;EAW5C,MAAA,CAAO,KAAA,UAAe,OAAA,GAAU,aAAA,GAAgB,OAAA,CAAQ,cAAA;;;;;;EAOxD,KAAA,CAAM,IAAA,GAAO,UAAA,GAAa,OAAA;AAAA"}
@@ -0,0 +1,33 @@
1
+ import { MemoryTier } from "./memory-item.type.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/contracts/memory/recall-options.type.d.ts
4
+ /**
5
+ * Options for `memory.recall(query, options?)`.
6
+ *
7
+ * All fields are optional — the common call is `recall("some query")`,
8
+ * which uses the factory-configured `k` and threshold against every
9
+ * configured tier.
10
+ */
11
+ type RecallOptions = {
12
+ /**
13
+ * Maximum number of memories to return. Overrides the factory's `k`
14
+ * for this call. The result is the top-`k` across whichever tiers are
15
+ * queried, ordered by descending `score`.
16
+ */
17
+ k?: number;
18
+ /**
19
+ * Restrict recall to a single tier. Omit to query every tier the
20
+ * factory was configured with (working first, then semantic) and
21
+ * merge the results.
22
+ */
23
+ tier?: MemoryTier;
24
+ /**
25
+ * Minimum semantic similarity for a hit, in `[0, 1]`. Overrides the
26
+ * factory's `threshold` for this call. Ignored by the working tier,
27
+ * which has no vector index.
28
+ */
29
+ threshold?: number;
30
+ };
31
+ //#endregion
32
+ export { RecallOptions };
33
+ //# sourceMappingURL=recall-options.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall-options.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/memory/recall-options.type.ts"],"mappings":";;;;;AASA;;;;;KAAY,aAAA;EAYH;;;AAME;;EAZT,CAAA;;;;;;EAMA,IAAA,GAAO,UAAU;;;;;;EAMjB,SAAA;AAAA"}
@@ -1,3 +1,3 @@
1
1
  import { MiddlewareState } from "./middleware-state.type.mjs";
2
- import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareToolContext, MiddlewareTripContext } from "./middleware-context.type.mjs";
3
- import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./middleware.contract.mjs";
2
+ import { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareSupervisorContext, MiddlewareSupervisorRef, MiddlewareToolContext, MiddlewareTripContext } from "./middleware-context.type.mjs";
3
+ import { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareSupervisorHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks } from "./middleware.contract.mjs";
@@ -1,8 +1,10 @@
1
1
  import { ModelToolCallRequest } from "../model-tool-call-request.type.mjs";
2
2
  import { Message } from "../conversation-message.type.mjs";
3
3
  import { ToolMode } from "../tool.contract.mjs";
4
- import { AgentExecuteOptions } from "../agent/agent-options.type.mjs";
4
+ import { SupervisorInput } from "../supervisor/supervisor-input.type.mjs";
5
+ import { SupervisorExecuteOptions } from "../supervisor/supervisor-execute-options.type.mjs";
5
6
  import { MiddlewareState } from "./middleware-state.type.mjs";
7
+ import { AgentExecuteOptions } from "../agent/agent-options.type.mjs";
6
8
 
7
9
  //#region ../@warlock.js/ai/src/contracts/middleware/middleware-context.type.d.ts
8
10
  /**
@@ -94,6 +96,44 @@ type MiddlewareToolContext = MiddlewareTripContext & {
94
96
  };
95
97
  readonly request: ModelToolCallRequest;
96
98
  };
99
+ /**
100
+ * Minimal identity shape of the supervisor a `supervisor`-level
101
+ * middleware is wrapping. Middleware never mutates the supervisor
102
+ * itself, so it sees only the fields it can usefully branch on — the
103
+ * stable `name` (logs, per-supervisor allow-lists) and the structural
104
+ * `signature` (cache-key namespacing, drift-aware observability).
105
+ */
106
+ type MiddlewareSupervisorRef = {
107
+ readonly name: string;
108
+ readonly signature: string;
109
+ };
110
+ /**
111
+ * Context passed to the `supervisor`-level middleware phase — fires
112
+ * once around the entire `supervisor.execute()` / `.stream()` /
113
+ * `.resume()` run, wrapping the iteration loop and final assembly.
114
+ *
115
+ * **Role.** The supervisor-level peer of {@link MiddlewareExecuteContext}.
116
+ * Gives middleware the stable identity of the run (supervisor, input,
117
+ * options) and a shared-state bag scoped to this one run. Anything
118
+ * cumulative across the whole supervisor lifecycle lives here:
119
+ * cross-iteration budgets, per-session rate-limit counters, audit
120
+ * correlation ids.
121
+ *
122
+ * Deliberately NOT an extension of {@link MiddlewareExecuteContext} —
123
+ * a supervisor has no single model, and its `input` is the wider
124
+ * `SupervisorInput` union (`string | Record<string, unknown>`), so the
125
+ * shapes diverge. The `state` bag is a fresh `Map` per run, matching
126
+ * the agent-level isolation guarantee.
127
+ *
128
+ * All fields are `readonly`; mutations go through `ctx.state`.
129
+ */
130
+ type MiddlewareSupervisorContext = {
131
+ readonly supervisor: MiddlewareSupervisorRef;
132
+ readonly input: SupervisorInput;
133
+ readonly options: SupervisorExecuteOptions | undefined;
134
+ readonly state: MiddlewareState;
135
+ readonly signal?: AbortSignal;
136
+ };
97
137
  //#endregion
98
- export { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareToolContext, MiddlewareTripContext };
138
+ export { MiddlewareAgentRef, MiddlewareExecuteContext, MiddlewareModelRef, MiddlewareSupervisorContext, MiddlewareSupervisorRef, MiddlewareToolContext, MiddlewareTripContext };
99
139
  //# sourceMappingURL=middleware-context.type.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware-context.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/middleware/middleware-context.type.ts"],"mappings":";;;;;;;;;AAYA;;;;KAAY,kBAAA;EAAA,SACD,IAAA;EAAA,SACA,WAAW;AAAA;;AAWH;AAgBnB;;;;KAlBY,kBAAA;EAAA,SACD,IAAA;EAAA,SACA,QAAQ;AAAA;;;;;;;;;;;;;;KAgBP,wBAAA;EAAA,SACD,KAAA,EAAO,kBAAA;EAAA,SACP,KAAA,EAAO,kBAAA;EAAA,SACP,KAAA;EAAA,SACA,OAAA,EAAS,mBAAA;EAAA,SACT,KAAA,EAAO,eAAA;EAAA,SACP,MAAA,GAAS,WAAA;AAAA;;;;;;;;;AAkBsB;AAiB1C;;;;KAnBY,qBAAA,GAAwB,wBAAA;EAAA,SACzB,SAAA;EAAA,SACA,QAAA,EAAU,aAAA,CAAc,OAAA;AAAA;;;;;;;;;;AAgCK;;;;;KAf5B,qBAAA,GAAwB,qBAAA;EAAA,SACzB,IAAA;IAAA,SACE,IAAA;IAAA,SACA,WAAA;;;;;;;;;;aAUA,IAAA,GAAO,QAAA;EAAA;EAAA,SAET,OAAA,EAAS,oBAAA;AAAA"}
1
+ {"version":3,"file":"middleware-context.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/middleware/middleware-context.type.ts"],"mappings":";;;;;;;;;;;AAcA;;;;KAAY,kBAAA;EAAA,SACD,IAAA;EAAA,SACA,WAAW;AAAA;;AAWH;AAgBnB;;;;KAlBY,kBAAA;EAAA,SACD,IAAA;EAAA,SACA,QAAQ;AAAA;;;;;;;;;;;;;;KAgBP,wBAAA;EAAA,SACD,KAAA,EAAO,kBAAA;EAAA,SACP,KAAA,EAAO,kBAAA;EAAA,SACP,KAAA;EAAA,SACA,OAAA,EAAS,mBAAA;EAAA,SACT,KAAA,EAAO,eAAA;EAAA,SACP,MAAA,GAAS,WAAA;AAAA;;;;;;;;;AAkBsB;AAiB1C;;;;KAnBY,qBAAA,GAAwB,wBAAA;EAAA,SACzB,SAAA;EAAA,SACA,QAAA,EAAU,aAAA,CAAc,OAAA;AAAA;;;;;;;;;;AAgCK;AAUxC;;;;KAzBY,qBAAA,GAAwB,qBAAA;EAAA,SACzB,IAAA;IAAA,SACE,IAAA;IAAA,SACA,WAAA;IAgDU;;;;;;;;;IAAA,SAtCV,IAAA,GAAO,QAAA;EAAA;EAAA,SAET,OAAA,EAAS,oBAAA;AAAA;;;;;;AAwCW;;KA9BnB,uBAAA;EAAA,SACD,IAAA;EAAA,SACA,SAAS;AAAA;;;;;;;;;;;;;;;;;;;;;KAuBR,2BAAA;EAAA,SACD,UAAA,EAAY,uBAAA;EAAA,SACZ,KAAA,EAAO,eAAA;EAAA,SACP,OAAA,EAAS,wBAAA;EAAA,SACT,KAAA,EAAO,eAAA;EAAA,SACP,MAAA,GAAS,WAAA;AAAA"}