@warlock.js/ai 4.2.11 → 4.4.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 (432) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/cjs/index.cjs +10155 -4626
  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 +88 -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 +143 -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 +2 -2
  119. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
  120. package/esm/contracts/result/tool-call.type.d.mts +2 -2
  121. package/esm/contracts/result/tool-call.type.d.mts.map +1 -1
  122. package/esm/contracts/result/usage.type.d.mts +24 -0
  123. package/esm/contracts/result/usage.type.d.mts.map +1 -1
  124. package/esm/contracts/result/workflow-result.type.d.mts +1 -1
  125. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
  126. package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
  127. package/esm/contracts/supervisor/dispatch-context.type.d.mts +3 -3
  128. package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
  129. package/esm/contracts/supervisor/index.d.mts +5 -5
  130. package/esm/contracts/supervisor/route-context.type.d.mts +2 -2
  131. package/esm/contracts/supervisor/supervisor-config.type.d.mts +55 -13
  132. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  133. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
  134. package/esm/contracts/supervisor/supervisor.contract.d.mts +9 -2
  135. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
  136. package/esm/contracts/workflow/index.d.mts +2 -2
  137. package/esm/contracts/workflow/workflow.contract.d.mts +28 -7
  138. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  139. package/esm/errors/error-code.type.d.mts +1 -1
  140. package/esm/errors/index.d.mts +7 -0
  141. package/esm/errors/index.mjs +7 -0
  142. package/esm/errors/orchestrator-cancelled-error.d.mts +32 -0
  143. package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -0
  144. package/esm/errors/orchestrator-cancelled-error.mjs +31 -0
  145. package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -0
  146. package/esm/errors/orchestrator-config-error.d.mts +26 -0
  147. package/esm/errors/orchestrator-config-error.d.mts.map +1 -0
  148. package/esm/errors/orchestrator-config-error.mjs +30 -0
  149. package/esm/errors/orchestrator-config-error.mjs.map +1 -0
  150. package/esm/errors/orchestrator-drift-error.d.mts +38 -0
  151. package/esm/errors/orchestrator-drift-error.d.mts.map +1 -0
  152. package/esm/errors/orchestrator-drift-error.mjs +37 -0
  153. package/esm/errors/orchestrator-drift-error.mjs.map +1 -0
  154. package/esm/errors/orchestrator-failed-error.d.mts +33 -0
  155. package/esm/errors/orchestrator-failed-error.d.mts.map +1 -0
  156. package/esm/errors/orchestrator-failed-error.mjs +36 -0
  157. package/esm/errors/orchestrator-failed-error.mjs.map +1 -0
  158. package/esm/errors/planner-cancelled-error.d.mts +33 -0
  159. package/esm/errors/planner-cancelled-error.d.mts.map +1 -0
  160. package/esm/errors/planner-cancelled-error.mjs +29 -0
  161. package/esm/errors/planner-cancelled-error.mjs.map +1 -0
  162. package/esm/errors/planner-failed-error.d.mts +40 -0
  163. package/esm/errors/planner-failed-error.d.mts.map +1 -0
  164. package/esm/errors/planner-failed-error.mjs +37 -0
  165. package/esm/errors/planner-failed-error.mjs.map +1 -0
  166. package/esm/errors/planner-plan-invalid-error.d.mts +21 -0
  167. package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -0
  168. package/esm/errors/planner-plan-invalid-error.mjs +25 -0
  169. package/esm/errors/planner-plan-invalid-error.mjs.map +1 -0
  170. package/esm/eval/eval-runner.d.mts +17 -0
  171. package/esm/eval/eval-runner.d.mts.map +1 -0
  172. package/esm/eval/eval-runner.mjs +121 -0
  173. package/esm/eval/eval-runner.mjs.map +1 -0
  174. package/esm/eval/index.d.mts +29 -0
  175. package/esm/eval/index.d.mts.map +1 -0
  176. package/esm/eval/index.mjs +30 -0
  177. package/esm/eval/index.mjs.map +1 -0
  178. package/esm/eval/judge-scorer.d.mts +21 -0
  179. package/esm/eval/judge-scorer.d.mts.map +1 -0
  180. package/esm/eval/judge-scorer.mjs +87 -0
  181. package/esm/eval/judge-scorer.mjs.map +1 -0
  182. package/esm/eval/scorers.d.mts +50 -0
  183. package/esm/eval/scorers.d.mts.map +1 -0
  184. package/esm/eval/scorers.mjs +101 -0
  185. package/esm/eval/scorers.mjs.map +1 -0
  186. package/esm/index.d.mts +95 -30
  187. package/esm/index.mjs +66 -22
  188. package/esm/memory/derive-id.mjs +24 -0
  189. package/esm/memory/derive-id.mjs.map +1 -0
  190. package/esm/memory/episodic-memory.mjs +106 -0
  191. package/esm/memory/episodic-memory.mjs.map +1 -0
  192. package/esm/memory/index.d.mts +5 -0
  193. package/esm/memory/memory.d.mts +42 -0
  194. package/esm/memory/memory.d.mts.map +1 -0
  195. package/esm/memory/memory.mjs +166 -0
  196. package/esm/memory/memory.mjs.map +1 -0
  197. package/esm/memory/procedural-memory.mjs +103 -0
  198. package/esm/memory/procedural-memory.mjs.map +1 -0
  199. package/esm/memory/semantic-memory.mjs +80 -0
  200. package/esm/memory/semantic-memory.mjs.map +1 -0
  201. package/esm/memory/working-memory.mjs +62 -0
  202. package/esm/memory/working-memory.mjs.map +1 -0
  203. package/esm/middleware/builtins/budget-contract.type.d.mts +126 -0
  204. package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -0
  205. package/esm/middleware/builtins/budget.d.mts +71 -1
  206. package/esm/middleware/builtins/budget.d.mts.map +1 -1
  207. package/esm/middleware/builtins/budget.mjs +119 -4
  208. package/esm/middleware/builtins/budget.mjs.map +1 -1
  209. package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
  210. package/esm/middleware/index.d.mts +2 -1
  211. package/esm/middleware/index.mjs +1 -1
  212. package/esm/middleware/pipeline.d.mts +9 -6
  213. package/esm/middleware/pipeline.d.mts.map +1 -1
  214. package/esm/middleware/pipeline.mjs.map +1 -1
  215. package/esm/mock/index.d.mts +1 -0
  216. package/esm/mock/index.mjs +1 -0
  217. package/esm/mock/mock-router.d.mts +63 -0
  218. package/esm/mock/mock-router.d.mts.map +1 -0
  219. package/esm/mock/mock-router.mjs +58 -0
  220. package/esm/mock/mock-router.mjs.map +1 -0
  221. package/esm/model/fallback-model.d.mts +45 -0
  222. package/esm/model/fallback-model.d.mts.map +1 -0
  223. package/esm/model/fallback-model.mjs +218 -0
  224. package/esm/model/fallback-model.mjs.map +1 -0
  225. package/esm/model/index.d.mts +2 -0
  226. package/esm/model/index.mjs +3 -0
  227. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  228. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  229. package/esm/node_modules/@vitest/expect/dist/index.mjs +1473 -0
  230. package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
  231. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +888 -0
  232. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
  233. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1533 -0
  234. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -0
  235. package/esm/node_modules/@vitest/runner/dist/index.mjs +3 -0
  236. package/esm/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  237. package/esm/node_modules/@vitest/snapshot/dist/index.mjs +922 -0
  238. package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
  239. package/esm/node_modules/@vitest/spy/dist/index.mjs +386 -0
  240. package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
  241. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +82 -0
  242. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -0
  243. package/esm/node_modules/@vitest/utils/dist/diff.mjs +1357 -0
  244. package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
  245. package/esm/node_modules/@vitest/utils/dist/display.mjs +559 -0
  246. package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -0
  247. package/esm/node_modules/@vitest/utils/dist/error.mjs +38 -0
  248. package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
  249. package/esm/node_modules/@vitest/utils/dist/helpers.mjs +181 -0
  250. package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
  251. package/esm/node_modules/@vitest/utils/dist/offset.mjs +27 -0
  252. package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -0
  253. package/esm/node_modules/@vitest/utils/dist/serialize.mjs +77 -0
  254. package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -0
  255. package/esm/node_modules/@vitest/utils/dist/source-map.mjs +374 -0
  256. package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
  257. package/esm/node_modules/@vitest/utils/dist/timers.mjs +37 -0
  258. package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -0
  259. package/esm/node_modules/chai/index.mjs +2973 -0
  260. package/esm/node_modules/chai/index.mjs.map +1 -0
  261. package/esm/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  262. package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  263. package/esm/node_modules/tinyrainbow/dist/index.mjs +87 -0
  264. package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -0
  265. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +6 -0
  266. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -0
  267. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +52 -0
  268. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -0
  269. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +2697 -0
  270. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -0
  271. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +45 -0
  272. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -0
  273. package/esm/orchestrator/as-tool.d.mts +42 -0
  274. package/esm/orchestrator/as-tool.d.mts.map +1 -0
  275. package/esm/orchestrator/as-tool.mjs +98 -0
  276. package/esm/orchestrator/as-tool.mjs.map +1 -0
  277. package/esm/orchestrator/checkpoint.mjs +75 -0
  278. package/esm/orchestrator/checkpoint.mjs.map +1 -0
  279. package/esm/orchestrator/commands.d.mts +38 -0
  280. package/esm/orchestrator/commands.d.mts.map +1 -0
  281. package/esm/orchestrator/commands.mjs +34 -0
  282. package/esm/orchestrator/commands.mjs.map +1 -0
  283. package/esm/orchestrator/compaction.mjs +206 -0
  284. package/esm/orchestrator/compaction.mjs.map +1 -0
  285. package/esm/orchestrator/dispatch.mjs +171 -0
  286. package/esm/orchestrator/dispatch.mjs.map +1 -0
  287. package/esm/orchestrator/emitter-port.type.d.mts +31 -0
  288. package/esm/orchestrator/emitter-port.type.d.mts.map +1 -0
  289. package/esm/orchestrator/emitter.d.mts +56 -0
  290. package/esm/orchestrator/emitter.d.mts.map +1 -0
  291. package/esm/orchestrator/emitter.mjs +85 -0
  292. package/esm/orchestrator/emitter.mjs.map +1 -0
  293. package/esm/orchestrator/engine-context.type.d.mts +56 -0
  294. package/esm/orchestrator/engine-context.type.d.mts.map +1 -0
  295. package/esm/orchestrator/execution.d.mts +116 -0
  296. package/esm/orchestrator/execution.d.mts.map +1 -0
  297. package/esm/orchestrator/execution.mjs +406 -0
  298. package/esm/orchestrator/execution.mjs.map +1 -0
  299. package/esm/orchestrator/index.d.mts +8 -0
  300. package/esm/orchestrator/index.mjs +10 -0
  301. package/esm/orchestrator/load.mjs +49 -0
  302. package/esm/orchestrator/load.mjs.map +1 -0
  303. package/esm/orchestrator/lock.mjs +75 -0
  304. package/esm/orchestrator/lock.mjs.map +1 -0
  305. package/esm/orchestrator/memory.d.mts +84 -0
  306. package/esm/orchestrator/memory.d.mts.map +1 -0
  307. package/esm/orchestrator/memory.mjs +141 -0
  308. package/esm/orchestrator/memory.mjs.map +1 -0
  309. package/esm/orchestrator/orchestrator-stream.d.mts +42 -0
  310. package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -0
  311. package/esm/orchestrator/orchestrator-stream.mjs +98 -0
  312. package/esm/orchestrator/orchestrator-stream.mjs.map +1 -0
  313. package/esm/orchestrator/orchestrator.d.mts +38 -0
  314. package/esm/orchestrator/orchestrator.d.mts.map +1 -0
  315. package/esm/orchestrator/orchestrator.mjs +173 -0
  316. package/esm/orchestrator/orchestrator.mjs.map +1 -0
  317. package/esm/orchestrator/resume.mjs +74 -0
  318. package/esm/orchestrator/resume.mjs.map +1 -0
  319. package/esm/orchestrator/signature.d.mts +40 -0
  320. package/esm/orchestrator/signature.d.mts.map +1 -0
  321. package/esm/orchestrator/signature.mjs +120 -0
  322. package/esm/orchestrator/signature.mjs.map +1 -0
  323. package/esm/orchestrator/window.mjs +56 -0
  324. package/esm/orchestrator/window.mjs.map +1 -0
  325. package/esm/planner/index.d.mts +5 -0
  326. package/esm/planner/index.mjs +6 -0
  327. package/esm/planner/plan-prompt.d.mts +17 -0
  328. package/esm/planner/plan-prompt.d.mts.map +1 -0
  329. package/esm/planner/plan-prompt.mjs +30 -0
  330. package/esm/planner/plan-prompt.mjs.map +1 -0
  331. package/esm/planner/plan-schema.d.mts +27 -0
  332. package/esm/planner/plan-schema.d.mts.map +1 -0
  333. package/esm/planner/plan-schema.mjs +120 -0
  334. package/esm/planner/plan-schema.mjs.map +1 -0
  335. package/esm/planner/planner-run.d.mts +23 -0
  336. package/esm/planner/planner-run.d.mts.map +1 -0
  337. package/esm/planner/planner-run.mjs +344 -0
  338. package/esm/planner/planner-run.mjs.map +1 -0
  339. package/esm/planner/planner.d.mts +37 -0
  340. package/esm/planner/planner.d.mts.map +1 -0
  341. package/esm/planner/planner.mjs +120 -0
  342. package/esm/planner/planner.mjs.map +1 -0
  343. package/esm/planner/signature.d.mts +18 -0
  344. package/esm/planner/signature.d.mts.map +1 -0
  345. package/esm/planner/signature.mjs +27 -0
  346. package/esm/planner/signature.mjs.map +1 -0
  347. package/esm/snapshot/index.d.mts +3 -0
  348. package/esm/snapshot/memory.d.mts +26 -0
  349. package/esm/snapshot/memory.d.mts.map +1 -0
  350. package/esm/snapshot/memory.mjs +81 -0
  351. package/esm/snapshot/memory.mjs.map +1 -0
  352. package/esm/snapshot/pg.d.mts +41 -0
  353. package/esm/snapshot/pg.d.mts.map +1 -0
  354. package/esm/snapshot/pg.mjs +146 -0
  355. package/esm/snapshot/pg.mjs.map +1 -0
  356. package/esm/snapshot/redis.d.mts +42 -0
  357. package/esm/snapshot/redis.d.mts.map +1 -0
  358. package/esm/snapshot/redis.mjs +101 -0
  359. package/esm/snapshot/redis.mjs.map +1 -0
  360. package/esm/supervisor/as-tool.d.mts +0 -6
  361. package/esm/supervisor/as-tool.d.mts.map +1 -1
  362. package/esm/supervisor/as-tool.mjs +0 -6
  363. package/esm/supervisor/as-tool.mjs.map +1 -1
  364. package/esm/supervisor/execution.d.mts +43 -8
  365. package/esm/supervisor/execution.d.mts.map +1 -1
  366. package/esm/supervisor/execution.mjs +66 -16
  367. package/esm/supervisor/execution.mjs.map +1 -1
  368. package/esm/supervisor/fan-out.d.mts +65 -0
  369. package/esm/supervisor/fan-out.d.mts.map +1 -0
  370. package/esm/supervisor/fan-out.mjs +65 -0
  371. package/esm/supervisor/fan-out.mjs.map +1 -0
  372. package/esm/supervisor/index.d.mts +5 -3
  373. package/esm/supervisor/index.mjs +3 -1
  374. package/esm/supervisor/router-factory.d.mts +110 -0
  375. package/esm/supervisor/router-factory.d.mts.map +1 -0
  376. package/esm/supervisor/router-factory.mjs +141 -0
  377. package/esm/supervisor/router-factory.mjs.map +1 -0
  378. package/esm/supervisor/router-prompt.d.mts +1 -1
  379. package/esm/supervisor/snapshot.d.mts +4 -10
  380. package/esm/supervisor/snapshot.d.mts.map +1 -1
  381. package/esm/supervisor/snapshot.mjs +8 -16
  382. package/esm/supervisor/snapshot.mjs.map +1 -1
  383. package/esm/supervisor/supervisor.mjs +1 -0
  384. package/esm/supervisor/supervisor.mjs.map +1 -1
  385. package/esm/system-prompt/index.mjs +6 -0
  386. package/esm/system-prompt/system-prompt.d.mts +51 -3
  387. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  388. package/esm/system-prompt/system-prompt.mjs +52 -6
  389. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  390. package/esm/testing/matcher-logic.d.mts +76 -0
  391. package/esm/testing/matcher-logic.d.mts.map +1 -0
  392. package/esm/testing/matcher-logic.mjs +144 -0
  393. package/esm/testing/matcher-logic.mjs.map +1 -0
  394. package/esm/testing/matchers.d.mts +48 -0
  395. package/esm/testing/matchers.d.mts.map +1 -0
  396. package/esm/testing/matchers.mjs +37 -0
  397. package/esm/testing/matchers.mjs.map +1 -0
  398. package/esm/testing/register-lazy.d.mts +20 -0
  399. package/esm/testing/register-lazy.d.mts.map +1 -0
  400. package/esm/testing/register-lazy.mjs +24 -0
  401. package/esm/testing/register-lazy.mjs.map +1 -0
  402. package/esm/tool/executable-as-tool.d.mts +87 -0
  403. package/esm/tool/executable-as-tool.d.mts.map +1 -0
  404. package/esm/tool/executable-as-tool.mjs +81 -0
  405. package/esm/tool/executable-as-tool.mjs.map +1 -0
  406. package/esm/tool/index.d.mts +2 -1
  407. package/esm/tool/index.mjs +1 -0
  408. package/esm/workflow/as-tool.mjs +0 -6
  409. package/esm/workflow/as-tool.mjs.map +1 -1
  410. package/esm/workflow/engine.mjs +2 -2
  411. package/esm/workflow/snapshot.mjs +13 -7
  412. package/esm/workflow/snapshot.mjs.map +1 -1
  413. package/esm/workflow/step-runner.mjs +1 -1
  414. package/esm/workflow/workflow.mjs +1 -0
  415. package/esm/workflow/workflow.mjs.map +1 -1
  416. package/llms-full.txt +947 -42
  417. package/llms.txt +13 -8
  418. package/package.json +3 -3
  419. package/skills/README.md +25 -5
  420. package/skills/ai-basics/SKILL.md +18 -7
  421. package/skills/ai-dx-helpers/SKILL.md +180 -0
  422. package/skills/attach-ai-middleware/SKILL.md +32 -3
  423. package/skills/handle-ai-errors/SKILL.md +20 -6
  424. package/skills/manage-ai-stores/SKILL.md +127 -0
  425. package/skills/persist-ai-data/SKILL.md +21 -10
  426. package/skills/pick-ai-provider/SKILL.md +46 -12
  427. package/skills/run-ai-agent/SKILL.md +51 -2
  428. package/skills/run-orchestrator/SKILL.md +198 -0
  429. package/skills/run-planner/SKILL.md +68 -0
  430. package/skills/run-supervisor/SKILL.md +47 -2
  431. package/skills/use-ai-memory/SKILL.md +124 -0
  432. package/skills/write-system-prompt/SKILL.md +14 -1
@@ -1,8 +1,9 @@
1
1
  import { AIError } from "../../errors/ai-error.mjs";
2
2
  import { AgentResult } from "../result/agent-result.type.mjs";
3
+ import { SupervisorResult } from "../result/supervisor-result.type.mjs";
3
4
  import { ToolInvokeResult } from "../../tool/tool.mjs";
4
- import { MiddlewareExecuteContext, MiddlewareToolContext, MiddlewareTripContext } from "./middleware-context.type.mjs";
5
5
  import { ModelResponse } from "../model.contract.mjs";
6
+ import { MiddlewareExecuteContext, MiddlewareSupervisorContext, MiddlewareToolContext, MiddlewareTripContext } from "./middleware-context.type.mjs";
6
7
 
7
8
  //#region ../@warlock.js/ai/src/contracts/middleware/middleware.contract.d.ts
8
9
  /**
@@ -59,6 +60,38 @@ type AgentMiddlewareToolHooks = {
59
60
  after?(ctx: MiddlewareToolContext, result: ToolInvokeResult<unknown>): void | ToolInvokeResult<unknown> | Promise<void | ToolInvokeResult<unknown>>;
60
61
  onError?(ctx: MiddlewareToolContext, error: AIError): void | ToolInvokeResult<unknown> | Promise<void | ToolInvokeResult<unknown>>;
61
62
  };
63
+ /**
64
+ * `supervisor`-level hook map. Wraps the entire `supervisor.execute()`
65
+ * / `.stream()` / `.resume()` run — the supervisor-level peer of
66
+ * `AgentMiddlewareExecuteHooks`. Fires once per run, around the whole
67
+ * iteration loop and final result assembly.
68
+ *
69
+ * - `before` — fires once at the start of the run, before the first
70
+ * routing decision. Throw to abort the whole supervisor run before
71
+ * any iteration executes (cross-run budget pre-check, hard deny on
72
+ * a ctx flag). Return a `SupervisorResult` to short-circuit the run
73
+ * entirely with that result (run-level cache hit, fixture replay).
74
+ * - `after` — fires once at the end of a successful run with the
75
+ * final `SupervisorResult`. Optional return value replaces the
76
+ * result. Does not fire when the run threw before producing a
77
+ * result — use `onError` for that path. (A run that completed with
78
+ * `result.error` populated is still a "successful" return here, the
79
+ * same as agent-level `execute.after`.)
80
+ * - `onError`— fires once when the run threw before a result could be
81
+ * assembled. Optional `SupervisorResult` return recovers: the engine
82
+ * treats it as the real outcome and clears the error. `void` /
83
+ * omitted rethrow.
84
+ *
85
+ * **Type independence.** Like every other level, supervisor hooks are
86
+ * never generic over the supervisor's `TOutput` — a budget or audit
87
+ * middleware must be reusable across every supervisor in the app, so
88
+ * hooks see `SupervisorResult<unknown>`.
89
+ */
90
+ type AgentMiddlewareSupervisorHooks = {
91
+ before?(ctx: MiddlewareSupervisorContext): void | SupervisorResult<unknown> | Promise<void | SupervisorResult<unknown>>;
92
+ after?(ctx: MiddlewareSupervisorContext, result: SupervisorResult<unknown>): void | SupervisorResult<unknown> | Promise<void | SupervisorResult<unknown>>;
93
+ onError?(ctx: MiddlewareSupervisorContext, error: AIError): void | SupervisorResult<unknown> | Promise<void | SupervisorResult<unknown>>;
94
+ };
62
95
  /**
63
96
  * Agent-level middleware — a composable interceptor that wraps agent
64
97
  * execution at one or more of three granularities: the whole
@@ -134,7 +167,18 @@ type AgentMiddleware = {
134
167
  execute?: AgentMiddlewareExecuteHooks;
135
168
  trip?: AgentMiddlewareTripHooks;
136
169
  tool?: AgentMiddlewareToolHooks;
170
+ /**
171
+ * Optional `supervisor`-level hook map — wraps an entire
172
+ * `supervisor.execute()` run, the supervisor-level peer of
173
+ * `execute`. Only fires when the middleware is registered on a
174
+ * supervisor (`ai.supervisor({ middleware: [...] })`); it is inert on
175
+ * a plain agent, exactly as `execute` / `trip` / `tool` are inert on
176
+ * a supervisor that never reaches the agent pipeline. A single
177
+ * middleware object may declare both `execute` and `supervisor` to
178
+ * cover both authoring surfaces.
179
+ */
180
+ supervisor?: AgentMiddlewareSupervisorHooks;
137
181
  };
138
182
  //#endregion
139
- export { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks };
183
+ export { AgentMiddleware, AgentMiddlewareExecuteHooks, AgentMiddlewareSupervisorHooks, AgentMiddlewareToolHooks, AgentMiddlewareTripHooks };
140
184
  //# sourceMappingURL=middleware.contract.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/middleware/middleware.contract.ts"],"mappings":";;;;;;;;;;AAuBA;;;;;;;;;;KAAY,2BAAA;EACV,MAAA,EAAQ,GAAA,EAAK,wBAAA,UAAkC,OAAA;EAC/C,KAAA,EACE,GAAA,EAAK,wBAAA,EACL,MAAA,EAAQ,WAAA,mBACA,WAAA,YAAuB,OAAA,QAAe,WAAA;EAChD,OAAA,EACE,GAAA,EAAK,wBAAA,EACL,KAAA,EAAO,OAAA,UACC,WAAA,YAAuB,OAAA,QAAe,WAAA;AAAA;;;;;;;;;;;;;;KAgBtC,wBAAA;EACV,MAAA,EACE,GAAA,EAAK,qBAAA,UACG,aAAA,GAAgB,OAAA,QAAe,aAAA;EACzC,KAAA,EACE,GAAA,EAAK,qBAAA,EACL,QAAA,EAAU,aAAA,UACF,aAAA,GAAgB,OAAA,QAAe,aAAA;EACzC,OAAA,EACE,GAAA,EAAK,qBAAA,EACL,KAAA,EAAO,OAAA,UACC,aAAA,GAAgB,OAAA,QAAe,aAAA;AAAA;;;;;;AA3BkB;AAgB7D;;;;;;;KA2BY,wBAAA;EACV,MAAA,EACE,GAAA,EAAK,qBAAA,UAGH,gBAAA,YACA,OAAA,QAAe,gBAAA;EACnB,KAAA,EACE,GAAA,EAAK,qBAAA,EACL,MAAA,EAAQ,gBAAA,mBAGN,gBAAA,YACA,OAAA,QAAe,gBAAA;EACnB,OAAA,EACE,GAAA,EAAK,qBAAA,EACL,KAAA,EAAO,OAAA,UAGL,gBAAA,YACA,OAAA,QAAe,gBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AApCmC;AAgBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkFY,eAAA;EAzER;;;;;EA+EF,IAAA;EAzEE;;;;;EA+EF,GAAA;EACA,OAAA,GAAU,2BAAA;EACV,IAAA,GAAO,wBAAA;EACP,IAAA,GAAO,wBAAA;AAAA"}
1
+ {"version":3,"file":"middleware.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/middleware/middleware.contract.ts"],"mappings":";;;;;;;;;;;AAyBA;;;;;;;;;;KAAY,2BAAA;EACV,MAAA,EAAQ,GAAA,EAAK,wBAAA,UAAkC,OAAA;EAC/C,KAAA,EACE,GAAA,EAAK,wBAAA,EACL,MAAA,EAAQ,WAAA,mBACA,WAAA,YAAuB,OAAA,QAAe,WAAA;EA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O,wBAAA;EACP,IAAA,GAAO,wBAAA;EAhFP;;;;;;;;;AAGqE;EAwFrE,UAAA,GAAa,8BAAA;AAAA"}
@@ -39,9 +39,43 @@ type ModelCallOptions = {
39
39
  * `signal.aborted` flips. Adapters without support may ignore it;
40
40
  * the agent still honors the signal at trip boundaries regardless.
41
41
  */
42
- signal?: AbortSignal; /** Additional provider-specific options */
42
+ signal?: AbortSignal;
43
+ /**
44
+ * Reasoning / thinking-effort control for reasoning-capable models.
45
+ * `effort` maps to OpenAI `reasoning_effort`; `maxTokens` caps the
46
+ * Anthropic extended-thinking budget. Adapters whose
47
+ * `capabilities.reasoning` is absent/false ignore this rather than
48
+ * forwarding unsupported params. Absent = provider default.
49
+ *
50
+ * @example
51
+ * await model.complete(messages, { reasoning: { effort: "high" } });
52
+ */
53
+ reasoning?: {
54
+ effort?: ReasoningEffort;
55
+ maxTokens?: number;
56
+ };
57
+ /**
58
+ * Vendor-neutral prompt-cache WRITE breakpoint hint. Adapters with
59
+ * `capabilities.promptCaching` translate `breakpoints` into provider
60
+ * cache markers (Anthropic `cache_control`); others ignore it.
61
+ * Read-side accounting (`Usage.cachedTokens`) works without this — it
62
+ * only controls WRITE placement. Absent = provider default (no
63
+ * explicit breakpoints).
64
+ *
65
+ * @example
66
+ * await model.complete(messages, { cacheControl: { breakpoints: 1 } });
67
+ */
68
+ cacheControl?: {
69
+ breakpoints?: number;
70
+ }; /** Additional provider-specific options */
43
71
  [key: string]: unknown;
44
72
  };
73
+ /**
74
+ * Reasoning/thinking-effort levels for reasoning-capable models. Maps to
75
+ * the provider-native control (OpenAI `reasoning_effort`); adapters
76
+ * without reasoning support ignore it.
77
+ */
78
+ type ReasoningEffort = "low" | "medium" | "high";
45
79
  /**
46
80
  * Declarative feature flags a `ModelContract` may expose so the agent can
47
81
  * short-circuit redundant work when the provider already enforces a
@@ -68,6 +102,33 @@ type ModelCapabilities = {
68
102
  * dropping them at the wire layer.
69
103
  */
70
104
  vision?: boolean;
105
+ /**
106
+ * True when the adapter exposes provider reasoning / extended-thinking
107
+ * and forwards `ModelCallOptions.reasoning`. When false/absent the
108
+ * agent ignores reasoning options rather than sending unsupported
109
+ * params to the provider.
110
+ */
111
+ reasoning?: boolean;
112
+ /**
113
+ * True when the adapter honors `ModelCallOptions.cacheControl` write
114
+ * breakpoints and reports `Usage.cachedTokens` / `Usage.cacheWriteTokens`.
115
+ * When false/absent the agent skips emitting cache breakpoints.
116
+ */
117
+ promptCaching?: boolean;
118
+ /**
119
+ * True when the adapter accepts audio `ContentPart` input. When
120
+ * false/absent and the caller passes audio attachments, the agent
121
+ * throws upfront rather than dropping them at the wire layer (mirrors
122
+ * `vision`).
123
+ */
124
+ audio?: boolean;
125
+ /**
126
+ * True when the adapter accepts PDF / document `ContentPart` input.
127
+ * When false/absent and the caller passes PDF attachments, the agent
128
+ * throws upfront rather than dropping them at the wire layer (mirrors
129
+ * `vision`).
130
+ */
131
+ pdf?: boolean;
71
132
  };
72
133
  /**
73
134
  * Full response from a non-streaming model call.
@@ -160,5 +221,5 @@ interface ModelContract {
160
221
  stream(messages: Message[], options?: ModelCallOptions): AsyncIterable<ModelStreamChunk>;
161
222
  }
162
223
  //#endregion
163
- export { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk };
224
+ export { ModelCallOptions, ModelCapabilities, ModelContract, ModelResponse, ModelStreamChunk, ReasoningEffort };
164
225
  //# sourceMappingURL=model.contract.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.contract.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/model.contract.ts"],"mappings":";;;;;;;;;;AAqBA;;;;;;;;;;;;KAAY,gBAAA;EACV,WAAA;EACA,SAAA,WAkBS;EAhBT,KAAA,GAAQ,UAAA;EAkBI;AAAA;AAad;;;;AAeQ;AAaR;EAlDE,cAAA,GAAiB,MAAA;;;;;;;EAOjB,MAAA,GAAS,WAAA,EA6CT;EAAA,CA3CC,GAAA;AAAA;;;;;AA8C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;;;;;;;KAYA,iBAAA;EAuFgD;AAAA;AAgB5D;;;;EAhGE,gBAAA;EA2HmB;;;;;;;EAnHnB,MAAA;EAwHsE;;;;;;EAjHtE,SAAA;EAuGmB;;;;;EAjGnB,aAAA;EAsG2D;;;;;;EA/F3D,KAAA;EAoGyD;;;AAA8B;;;EA7FvF,GAAA;AAAA;;;;;;;;;;;KAaU,aAAA;EACV,OAAA;EACA,YAAA,EAAc,YAAA;EACd,KAAA,EAAO,KAAA;EAEP,SAAA,GAAY,oBAAA;AAAA;;;;;;;;;;KAYF,gBAAA;EACN,IAAA;EAAe,OAAA;AAAA;EAEf,IAAA;EACA,EAAA;EACA,IAAA;EACA,KAAA;;;;;;;EAOA,gBAAA,GAAmB,MAAA;AAAA;EAEnB,IAAA;EAAc,YAAA,EAAc,YAAA;EAAc,KAAA,EAAO,KAAA;AAAA;;;;;;;;;;;;;;;UAgBtC,aAAA;;WAEN,IAAA;;WAEA,QAAA;;;;;;WAMA,YAAA,GAAe,iBAAA;;;;;;;;;;;WAYf,OAAA,GAAU,YAAA;;;;EAKnB,QAAA,CAAS,QAAA,EAAU,OAAA,IAAW,OAAA,GAAU,gBAAA,GAAmB,OAAA,CAAQ,aAAA;;;;EAKnE,MAAA,CAAO,QAAA,EAAU,OAAA,IAAW,OAAA,GAAU,gBAAA,GAAmB,aAAA,CAAc,gBAAA;AAAA"}
@@ -0,0 +1,91 @@
1
+ //#region ../@warlock.js/ai/src/contracts/orchestrator/checkpoint-store.contract.d.ts
2
+ /**
3
+ * A single persisted orchestrator session checkpoint. One row is
4
+ * written per settled turn — the primary key is
5
+ * `(orchestrator_name, session_id, turn_index)`, append-only from v1
6
+ * (orchestrator.md §8.2 / §8.6). The latest row (highest
7
+ * `turn_index`) is the live session state.
8
+ *
9
+ * All fields are JSON-serializable. `state` is `unknown` because its
10
+ * shape is the orchestrator's `TState`, validated upstream — the store
11
+ * only round-trips it.
12
+ *
13
+ * Naming follows the on-disk DDL columns verbatim (snake_case) so the
14
+ * record maps 1:1 onto the reference table in orchestrator.md §8.6 and
15
+ * the pg driver can read/write it without a field-rename layer.
16
+ */
17
+ type CheckpointRecord = {
18
+ /** Orchestrator definition name — first PK segment, partitions sessions across orchestrators. */orchestrator_name: string; /** Caller-owned session identifier — second PK segment. */
19
+ session_id: string; /** Monotonic turn counter — third PK segment; the row with the highest value is live. */
20
+ turn_index: number; /** Post-merge session accumulator. JSON-serializable; shape is the orchestrator's `TState`. */
21
+ state: unknown; /** Summary of the turn's dispatch decision — a single intent, a fan-out list, or `null` on a turn that routed nowhere. */
22
+ last_route: string | string[] | null; /** Structural fingerprint of the orchestrator definition at write time; compared on load for drift detection. */
23
+ signature: string; /** Informational `config.version` tag, or `null` when unset. Metadata only — never drives behavior. */
24
+ version: string | null; /** Exclusive turn index through which compaction has been applied, or `null` when no compaction has landed. */
25
+ summarized_through: number | null; /** ISO timestamp when a compaction lock was taken, or `null` when no lock is held. */
26
+ lock_acquired_at: string | null; /** ISO timestamp when the compaction lock expires, or `null` when no lock is held. */
27
+ lock_expires_at: string | null; /** ISO timestamp written server-side when the row was persisted. */
28
+ saved_at: string;
29
+ };
30
+ /**
31
+ * Durable store for orchestrator session state (orchestrator.md §8.2).
32
+ *
33
+ * Owns the checkpoint rows that let `ai.orchestrator()` rehydrate a
34
+ * session across calls: `state`, `turn_index`, drift `signature`,
35
+ * `version`, `last_route`, compaction progress, and lock metadata.
36
+ * Distinct from {@link import("./snapshot-store.contract").SnapshotStore},
37
+ * which persists the per-turn internal supervisor run for
38
+ * `iterate: true` mid-turn resume.
39
+ *
40
+ * Implementations: `ai.checkpoint.{memory,pg,redis}()`. The memory
41
+ * impl ships in v1; pg/redis follow. Schema is never auto-migrated —
42
+ * {@link CheckpointStore.schema} returns a DDL string the dev runs
43
+ * through their own migration tool (§8.5).
44
+ */
45
+ interface CheckpointStore {
46
+ /**
47
+ * Load the latest checkpoint (highest `turn_index`) for a session,
48
+ * or `undefined` for a brand-new session the store has never seen.
49
+ */
50
+ load(orchestratorName: string, sessionId: string): Promise<CheckpointRecord | undefined>;
51
+ /**
52
+ * Persist a fresh checkpoint row. Append-only — never overwrites a
53
+ * prior `turn_index`. The key is derived from
54
+ * `(orchestrator_name, session_id, turn_index)` on the record.
55
+ */
56
+ save(record: CheckpointRecord): Promise<void>;
57
+ /**
58
+ * Delete every checkpoint row for a session, ending it.
59
+ */
60
+ delete(orchestratorName: string, sessionId: string): Promise<void>;
61
+ /**
62
+ * List the session ids known for an orchestrator, optionally
63
+ * filtered by a session-id prefix. Used by the production boot-drain
64
+ * loop (§9.3). Optional — stores that can't enumerate omit it.
65
+ */
66
+ list?(orchestratorName: string, prefix?: string): Promise<string[]>;
67
+ /**
68
+ * Drop every row for a session whose `turn_index` is strictly below
69
+ * `keepBeforeTurnIndex`, honoring `keepSnapshots` retention (§4 Phase
70
+ * 6, Q20). Called after each settled turn's save. Optional — stores
71
+ * that prune in their own dialect (or never prune) omit it; the engine
72
+ * skips pruning when it is absent.
73
+ */
74
+ prune?(orchestratorName: string, sessionId: string, keepBeforeTurnIndex: number): Promise<void>;
75
+ /**
76
+ * Return the DDL string for this store's backing table. The dev runs
77
+ * it through their migration tool; the framework never auto-migrates
78
+ * (§8.5).
79
+ */
80
+ schema(): string;
81
+ /**
82
+ * Optional idle-TTL knob. Stores that support row expiry honor it;
83
+ * others may no-op.
84
+ */
85
+ setOptions?(options: {
86
+ ttl?: number;
87
+ }): void;
88
+ }
89
+ //#endregion
90
+ export { CheckpointRecord, CheckpointStore };
91
+ //# sourceMappingURL=checkpoint-store.contract.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkpoint-store.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/checkpoint-store.contract.ts"],"mappings":";;AAeA;;;;;;;;;;;;;;KAAY,gBAAA;EAsBF,iGApBR,iBAAA,UAsCe;EApCf,UAAA;EAEA,UAAA,UA0CG;EAxCH,KAAA,WA+CgC;EA7ChC,UAAA,4BAyDkD;EAvDlD,SAAA,UAoEU;EAlEV,OAAA,iBA+BA;EA7BA,kBAAA,iBA+BE;EA7BF,gBAAA,iBA8BW;EA5BX,eAAA,iBAmCa;EAjCb,QAAA;AAAA;;;;;;;;;;;;;;;;UAkBe,eAAA;EAqDH;;AAAyB;;EAhDrC,IAAA,CACE,gBAAA,UACA,SAAA,WACC,OAAA,CAAQ,gBAAA;;;;;;EAOX,IAAA,CAAK,MAAA,EAAQ,gBAAA,GAAmB,OAAA;;;;EAKhC,MAAA,CAAO,gBAAA,UAA0B,SAAA,WAAoB,OAAA;;;;;;EAOrD,IAAA,EAAM,gBAAA,UAA0B,MAAA,YAAkB,OAAA;;;;;;;;EASlD,KAAA,EACE,gBAAA,UACA,SAAA,UACA,mBAAA,WACC,OAAA;;;;;;EAOH,MAAA;;;;;EAMA,UAAA,EAAY,OAAA;IAAW,GAAA;EAAA;AAAA"}
@@ -0,0 +1,8 @@
1
+ import { PgClientLike, RedisClientLike, SnapshotStore } from "./snapshot-store.contract.mjs";
2
+ import { CheckpointRecord, CheckpointStore } from "./checkpoint-store.contract.mjs";
3
+ import { OrchestratorCommands } from "./orchestrator-commands.type.mjs";
4
+ import { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "./orchestrator-event.type.mjs";
5
+ import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "./orchestrator-execute-options.type.mjs";
6
+ import { OrchestratorAsToolOptions, OrchestratorContract, OrchestratorSessionScope, SessionContextOverrides } from "./orchestrator.contract.mjs";
7
+ import { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig } from "./orchestrator-config.type.mjs";
8
+ import { SessionContract } from "./session.contract.mjs";
@@ -0,0 +1,43 @@
1
+ import { Message } from "../conversation-message.type.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/contracts/orchestrator/orchestrator-commands.type.d.ts
4
+ /**
5
+ * Typed command surface for `orchestrator.command(name, args)` (design
6
+ * §11). Each key is a command name; its value declares the command's
7
+ * `args` and `result` shapes so the contract's `command<K>` method is
8
+ * fully typed against the map.
9
+ *
10
+ * v1 ships exactly one built-in command, `compact`. v2 user commands
11
+ * attach via module augmentation of this type — declaring additional
12
+ * keys in a consumer's own `.d.ts` widens the map without a framework
13
+ * release.
14
+ *
15
+ * @example
16
+ * const result = await orchestrator.command("compact", {
17
+ * sessionId,
18
+ * history,
19
+ * });
20
+ * // result: { summary, replacesFromIndex, replacesToIndex }
21
+ */
22
+ type OrchestratorCommands = {
23
+ /**
24
+ * Force a manual compaction of the supplied session history outside
25
+ * the automatic post-turn trigger. `result` is structurally
26
+ * identical to `CompactionResult` (kept per the literal §11 shape).
27
+ */
28
+ compact: {
29
+ args: {
30
+ sessionId: string;
31
+ history: Message[];
32
+ signal?: AbortSignal;
33
+ };
34
+ result: {
35
+ summary: Message;
36
+ replacesFromIndex: number;
37
+ replacesToIndex: number;
38
+ };
39
+ };
40
+ };
41
+ //#endregion
42
+ export { OrchestratorCommands };
43
+ //# sourceMappingURL=orchestrator-commands.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator-commands.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/orchestrator-commands.type.ts"],"mappings":";;;;;AAoBA;;;;;;;;;;;;;;;;KAAY,oBAAA;EASG;;;;AAEM;EALnB,OAAA;IACE,IAAA;MAAQ,SAAA;MAAmB,OAAA,EAAS,OAAA;MAAW,MAAA,GAAS,WAAA;IAAA;IACxD,MAAA;MACE,OAAA,EAAS,OAAA;MACT,iBAAA;MACA,eAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,170 @@
1
+ import { Message } from "../conversation-message.type.mjs";
2
+ import { AgentContract } from "../agent/agent.contract.mjs";
3
+ import { SnapshotStore } from "./snapshot-store.contract.mjs";
4
+ import { ModelContract } from "../model.contract.mjs";
5
+ import { SystemPromptContract } from "../system-prompt.contract.mjs";
6
+ import { RouteContext } from "../supervisor/route-context.type.mjs";
7
+ import { SupervisorIntentValue } from "../supervisor/intent-entry.type.mjs";
8
+ import { Next } from "../supervisor/next.type.mjs";
9
+ import { RouterEntry } from "../supervisor/router-entry.type.mjs";
10
+ import { EvaluateContext, EvaluateResult } from "../supervisor/evaluate-context.type.mjs";
11
+ import { CompactionResult } from "../result/orchestrator-result.type.mjs";
12
+ import { MemoryTier } from "../memory/memory-item.type.mjs";
13
+ import { MemoryContract } from "../memory/memory.contract.mjs";
14
+ import { CheckpointStore } from "./checkpoint-store.contract.mjs";
15
+ import { OrchestratorEventHandlers } from "./orchestrator-event.type.mjs";
16
+ import { StandardSchemaV1 } from "@standard-schema/spec";
17
+
18
+ //#region ../@warlock.js/ai/src/contracts/orchestrator/orchestrator-config.type.d.ts
19
+ /**
20
+ * Object form of `OrchestratorConfig.summarize` (design §12.4) — the
21
+ * automatic post-turn compaction policy. Fires after `afterTurns`,
22
+ * keeps the most recent `keep` messages, and summarizes the rest with
23
+ * `summarizer`. `onCompact` lets the dev apply the produced summary to
24
+ * their own message store; `lock` bounds how long a turn waits on the
25
+ * compaction lock before failing open.
26
+ */
27
+ type SummarizeConfig = {
28
+ /** Trigger compaction once the turn count crosses this threshold. */afterTurns?: number; /** Number of most-recent messages to keep verbatim (not summarized). Default 8. */
29
+ keep?: number; /** Model used to produce the summary. Defaults to the orchestrator's own model. */
30
+ summarizer?: ModelContract;
31
+ /**
32
+ * Applies the produced compaction to the dev's message store. When
33
+ * supplied the orchestrator does not surface `result.compaction` for
34
+ * the dev to apply manually.
35
+ */
36
+ onCompact?: (compaction: CompactionResult, ctx: {
37
+ sessionId: string;
38
+ }) => Promise<void> | void; /** Compaction-lock tuning. `maxWait` caps the per-turn wait in ms. */
39
+ lock?: {
40
+ maxWait?: number;
41
+ };
42
+ };
43
+ /**
44
+ * Callback form of `OrchestratorConfig.summarize` (design §12.4). Full
45
+ * control: receives the session history, returns the compaction result
46
+ * directly. Use when the built-in `SummarizeConfig` policy is too
47
+ * coarse.
48
+ */
49
+ type SummarizeCallback = (history: Message[]) => Promise<CompactionResult> | CompactionResult;
50
+ /**
51
+ * Per-turn memory wiring for `OrchestratorConfig.memory` (memory core
52
+ * M2). The `store` is the {@link MemoryContract} the orchestrator
53
+ * recalls from before each dispatch and remembers into after each turn
54
+ * settles. `recall` tunes the pre-dispatch recall (how many memories,
55
+ * the similarity floor, an optional single-tier restriction); `remember`
56
+ * toggles whether the turn outcome is written back. When `recall.k` is 0
57
+ * the orchestrator skips recall entirely (write-only memory); when
58
+ * `remember` is `false` it recalls but never writes (read-only memory).
59
+ *
60
+ * The recalled memories are injected into the request-scoped `context`
61
+ * bag under the `injectKey` (default `"memories"`) so every route /
62
+ * router / evaluate / dispatch callback reads them at
63
+ * `ctx.context[injectKey]` — memory never mutates the prompt itself, the
64
+ * surfacing point stays explicit (the same contract `MemoryContract`
65
+ * documents).
66
+ */
67
+ type OrchestratorMemoryConfig = {
68
+ /** The memory store recalled-from before dispatch and remembered-into after. */store: MemoryContract;
69
+ /**
70
+ * Pre-dispatch recall tuning. `k` caps the injected count (0 disables
71
+ * recall — write-only memory); `threshold` raises the semantic
72
+ * similarity floor; `tier` restricts recall to a single tier. Omit for
73
+ * the memory's own configured defaults.
74
+ */
75
+ recall?: {
76
+ k?: number;
77
+ threshold?: number;
78
+ tier?: MemoryTier;
79
+ };
80
+ /**
81
+ * Write the settled turn outcome back into memory after a clean turn.
82
+ * Default `true`. Set `false` for a read-only memory that recalls but
83
+ * never accumulates. Cancelled / failed turns never remember (they
84
+ * revert — §17), regardless of this flag.
85
+ */
86
+ remember?: boolean;
87
+ /**
88
+ * Tier the remembered turn outcome lands in. Omit to use the memory's
89
+ * own `defaultTier`. Pass `"semantic"` to durably accumulate turns for
90
+ * later cross-session recall.
91
+ */
92
+ rememberTier?: MemoryTier;
93
+ /**
94
+ * Key the recalled memories are injected under inside the per-turn
95
+ * `context` bag. Callbacks read them at `ctx.context[injectKey]` as a
96
+ * `RecalledMemory[]`. Default `"memories"`.
97
+ */
98
+ injectKey?: string;
99
+ };
100
+ /**
101
+ * Factory config for `ai.orchestrator(config)` (design §15.2).
102
+ *
103
+ * The "what runs" fields (`intents`, `route` / `router`, `evaluate`,
104
+ * `state`, `output`, `initialAgent`, `maxIterations`) are the
105
+ * supervisor's surface spread directly — the orchestrator builds the
106
+ * supervisor lazily per turn and delegates to it. The remaining fields
107
+ * are orchestrator-specific: session-scoped history windowing,
108
+ * compaction, snapshot retention, and the two durable stores.
109
+ *
110
+ * `TState` defaults to `TOutput` for the common case where the working
111
+ * session state IS the output shape. `TIntents` captures the literal
112
+ * intent map so `ctx.intents.<TAB>` autocompletes against real keys.
113
+ *
114
+ * @example
115
+ * const supportBot = ai.orchestrator<SessionState>({
116
+ * name: "refund-support",
117
+ * intents: { classify, lookup, process, compose },
118
+ * route: (ctx) => (ctx.iteration === 0 ? "classify" : END),
119
+ * iterate: true,
120
+ * historyWindow: { router: 5, agents: 20 },
121
+ * checkpointStore: ai.checkpoint.pg({ client: pg }),
122
+ * snapshotStore: ai.snapshot.pg({ client: pg }),
123
+ * });
124
+ */
125
+ type OrchestratorConfig<TOutput, TState = TOutput, TIntents extends Record<string, SupervisorIntentValue> = Record<string, SupervisorIntentValue>> = {
126
+ /** Stable identifier — used in logs, events, checkpoints, signature. */name: string; /** Dev-curated version string. Metadata only (§10.2) — never parsed. */
127
+ version?: string; /** Prepended to the router agent's system prompt (router mode only). */
128
+ systemPrompt?: SystemPromptContract | string; /** Dispatchable units keyed by intent name (supervisor surface). */
129
+ intents: TIntents; /** Deterministic per-turn dispatch. Mutually exclusive with `router`. */
130
+ route?: (ctx: RouteContext<TState>) => Next | Promise<Next>; /** LLM-driven dispatch. Mutually exclusive with `route`. */
131
+ router?: AgentContract<unknown> | RouterEntry<TState>; /** Retrospective per-turn verdict callback. */
132
+ evaluate?: (ctx: EvaluateContext<TState>) => EvaluateResult | Promise<EvaluateResult>; /** Initial seed for the session-state accumulator. */
133
+ state?: TState; /** Final-state schema; validated before populating `result.data`. */
134
+ output?: StandardSchemaV1<TOutput>; /** Dispatch this intent on turn 0, skipping the first route/router call. */
135
+ initialAgent?: string; /** Hard cap on in-turn iterations — only consulted when `iterate: true`. Default 10. */
136
+ maxIterations?: number;
137
+ /**
138
+ * Delegate each turn to a real internal supervisor for in-turn
139
+ * iteration. Default `false` — single dispatch per turn. Requires
140
+ * `snapshotStore` (or `ai.config({ defaultSnapshotStore })`) when set.
141
+ */
142
+ iterate?: boolean;
143
+ /**
144
+ * Per-role history windowing applied to the dev-supplied history
145
+ * before each turn. A number keeps the last N messages; a callback
146
+ * takes full control of the slice.
147
+ */
148
+ historyWindow?: {
149
+ router?: number | ((messages: Message[]) => Message[]);
150
+ agents?: number | ((messages: Message[]) => Message[]);
151
+ }; /** Automatic post-turn compaction policy (§12). */
152
+ summarize?: SummarizeConfig | SummarizeCallback; /** Number of turn snapshots to retain per session. Default 100. */
153
+ keepSnapshots?: number | "all"; /** Durable session-state store. Falls back to `ai.config({ defaultCheckpointStore })`. */
154
+ checkpointStore?: CheckpointStore; /** Internal-supervisor snapshot store. Required when `iterate: true`. */
155
+ snapshotStore?: SnapshotStore;
156
+ /**
157
+ * Optional per-turn memory (memory core M2). When set, the
158
+ * orchestrator recalls relevant memories for the turn input and injects
159
+ * them into the dispatch context (`ctx.context[injectKey]`) before
160
+ * routing, then remembers the settled turn outcome afterward. Omit for
161
+ * the existing behavior — orchestrators without memory are unchanged.
162
+ * Accepts a bare {@link MemoryContract} (recall + remember with
163
+ * defaults) or an {@link OrchestratorMemoryConfig} for finer control.
164
+ */
165
+ memory?: MemoryContract | OrchestratorMemoryConfig; /** Definition-level event handlers — tier 1 of the 3-tier model. */
166
+ on?: OrchestratorEventHandlers;
167
+ };
168
+ //#endregion
169
+ export { OrchestratorConfig, OrchestratorMemoryConfig, SummarizeCallback, SummarizeConfig };
170
+ //# sourceMappingURL=orchestrator-config.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"or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WAJA;EAMA,aAAA;EAJA;;;;;EAWA,OAAA;EAMA;;;;;EAAA,aAAA;IACE,MAAA,cAAoB,QAAA,EAAU,OAAA,OAAc,OAAA;IAC5C,MAAA,cAAoB,QAAA,EAAU,OAAA,OAAc,OAAA;EAAA,GAG9C;EAAA,SAAA,GAAY,eAAA,GAAkB,iBAAA,EAAA;EAE9B,aAAA,mBAGA;EAAA,eAAA,GAAkB,eAAA,EAElB;EAAA,aAAA,GAAgB,aAAA;EAUhB;;;;;;AAG8B;;;EAH9B,MAAA,GAAS,cAAA,GAAiB,wBAAA;EAG1B,EAAA,GAAK,yBAAA;AAAA"}
@@ -0,0 +1,118 @@
1
+ import { EventIdentity } from "../events/event-identity.type.mjs";
2
+ import { CompactionResult } from "../result/orchestrator-result.type.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/contracts/orchestrator/orchestrator-event.type.d.ts
5
+ /**
6
+ * Per-turn lifecycle event payloads emitted under the `orchestrator.*`
7
+ * namespace (design §14). Three-tier subscription — definition,
8
+ * instance, per-call — fires in that order on every emission, mirroring
9
+ * the supervisor + workflow model.
10
+ *
11
+ * Child events (`supervisor.*` / `agent.*`) bubble up UNMODIFIED under
12
+ * their own identity (§14.2) and are intentionally NOT folded into this
13
+ * map — subscribers filter the bubbled stream by namespace. This map
14
+ * carries only the orchestrator's own session-scoped events.
15
+ *
16
+ * Until the shared `contracts/events` taxonomy grows an
17
+ * `orchestrator.*` slice, this local map is the source of truth for the
18
+ * orchestrator `on`/`off`/`stream` surface; it is structured to be
19
+ * promoted into `contracts/events/event-map.type.ts` later without a
20
+ * shape change (Q14 event taxonomy is a v1 design item; see §14).
21
+ */
22
+ type OrchestratorEventMap = {
23
+ /** Turn N begins (before phase 1). */"orchestrator.turn.starting": {
24
+ sessionId: string;
25
+ turnIndex: number;
26
+ }; /** Phase 1 — checkpoint loaded (or seeded empty on first call). */
27
+ "orchestrator.session.loaded": {
28
+ sessionId: string;
29
+ turnIndex: number;
30
+ found: boolean;
31
+ }; /** Phase 2 — drift signature compared against the loaded checkpoint. */
32
+ "orchestrator.drift.checked": {
33
+ sessionId: string;
34
+ signature: string;
35
+ drifted: boolean;
36
+ }; /** Phase 3 — waiting on the compaction lock (only when locked). */
37
+ "orchestrator.lock.waiting": {
38
+ sessionId: string;
39
+ waitedMs: number;
40
+ }; /** Phase 4 — history windowed for router + agents. */
41
+ "orchestrator.history.windowed": {
42
+ sessionId: string;
43
+ messageCount: number;
44
+ }; /** Phase 5 — route/router produced a dispatch decision. */
45
+ "orchestrator.turn.routed": {
46
+ sessionId: string;
47
+ turnIndex: number;
48
+ source: "route" | "router" | "intent.next";
49
+ raw: unknown;
50
+ }; /** Per-token streaming during the dispatched primitive's run. */
51
+ "orchestrator.turn.streaming": {
52
+ sessionId: string;
53
+ delta: string;
54
+ }; /** Phase 6 — checkpoint row written for the settled turn. */
55
+ "orchestrator.checkpoint.persisted": {
56
+ sessionId: string;
57
+ turnIndex: number;
58
+ }; /** Phase 7 — compaction trigger fired (only when triggered). */
59
+ "orchestrator.compaction.suggested": {
60
+ sessionId: string;
61
+ compaction: CompactionResult;
62
+ }; /** Phase 7 — `onCompact` ran successfully and the summary applied. */
63
+ "orchestrator.compaction.applied": {
64
+ sessionId: string;
65
+ compaction: CompactionResult;
66
+ };
67
+ /**
68
+ * Phase 7 — the summarizer or `onCompact` threw; compaction was skipped
69
+ * for this turn and the session keeps running with unchanged history
70
+ * (§4 Phase 7 skip-and-log). `phase` distinguishes which step failed.
71
+ */
72
+ "orchestrator.compaction.failed": {
73
+ sessionId: string;
74
+ phase: "summarize" | "onCompact";
75
+ error: unknown;
76
+ }; /** Terminal — turn ran to a usable result. */
77
+ "orchestrator.turn.completed": {
78
+ sessionId: string;
79
+ turnIndex: number;
80
+ }; /** Terminal — turn failed; the typed cause rides on the result. */
81
+ "orchestrator.turn.failed": {
82
+ sessionId: string;
83
+ turnIndex: number;
84
+ }; /** Terminal — caller aborted the turn via `AbortSignal`. */
85
+ "orchestrator.turn.cancelled": {
86
+ sessionId: string;
87
+ turnIndex: number;
88
+ }; /** Non-terminal — session paused waiting for the next user turn (§15.6). */
89
+ "orchestrator.turn.awaiting-input": {
90
+ sessionId: string;
91
+ turnIndex: number;
92
+ };
93
+ };
94
+ /**
95
+ * Discriminated union of every orchestrator event, each tagged with a
96
+ * `type` literal and carrying its payload plus run `EventIdentity`.
97
+ * This is the `TEvent` parameter for `orchestrator.stream()`.
98
+ */
99
+ type OrchestratorEvent = { [K in keyof OrchestratorEventMap]: {
100
+ type: K;
101
+ } & OrchestratorEventMap[K] & EventIdentity }[keyof OrchestratorEventMap];
102
+ /** Every legal orchestrator event name. */
103
+ type OrchestratorEventName = keyof OrchestratorEventMap;
104
+ /**
105
+ * Handler for a single orchestrator event. Receives the event's typed
106
+ * payload (identity-injected centrally by the orchestrator's `emit`);
107
+ * return value is ignored.
108
+ */
109
+ type OrchestratorEventHandler<K extends OrchestratorEventName> = (payload: OrchestratorEventMap[K] & EventIdentity) => void;
110
+ /**
111
+ * Definition / instance / per-call handler bag — tier surface accepted
112
+ * by `OrchestratorConfig.on` and the per-call `options.on`. Mirrors
113
+ * `SupervisorEventHandlers`.
114
+ */
115
+ type OrchestratorEventHandlers = Partial<{ [K in OrchestratorEventName]: OrchestratorEventHandler<K> }>;
116
+ //#endregion
117
+ export { OrchestratorEvent, OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName };
118
+ //# sourceMappingURL=orchestrator-event.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator-event.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/orchestrator/orchestrator-event.type.ts"],"mappings":";;;;;;AAoBA;;;;;;;;;;;;;;;KAAY,oBAAA;EAgBqB,sCAd/B,4BAAA;IAAgC,SAAA;IAAmB,SAAA;EAAA,GAkBnD;EAhBA,6BAAA;IACE,SAAA;IACA,SAAA;IACA,KAAA;EAAA,GAoB+B;EAjBjC,4BAAA;I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