@warlock.js/ai 4.2.10 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/cjs/index.cjs +10151 -4625
  3. package/cjs/index.cjs.map +1 -1
  4. package/cjs/magic-string.es-BtxW4VqG.cjs +1015 -0
  5. package/cjs/magic-string.es-BtxW4VqG.cjs.map +1 -0
  6. package/cjs/matcher-logic-SBnzYohQ.cjs +217 -0
  7. package/cjs/matcher-logic-SBnzYohQ.cjs.map +1 -0
  8. package/cjs/matchers-BBh3gyB-.cjs +13739 -0
  9. package/cjs/matchers-BBh3gyB-.cjs.map +1 -0
  10. package/esm/agent/agent-config.type.d.mts +19 -6
  11. package/esm/agent/agent-config.type.d.mts.map +1 -1
  12. package/esm/agent/agent.d.mts.map +1 -1
  13. package/esm/agent/agent.mjs +17 -6
  14. package/esm/agent/agent.mjs.map +1 -1
  15. package/esm/agent/index.d.mts +2 -1
  16. package/esm/agent/index.mjs +1 -0
  17. package/esm/agent/spawn-sub-agent.d.mts +87 -0
  18. package/esm/agent/spawn-sub-agent.d.mts.map +1 -0
  19. package/esm/agent/spawn-sub-agent.mjs +68 -0
  20. package/esm/agent/spawn-sub-agent.mjs.map +1 -0
  21. package/esm/ai.d.mts +58 -3
  22. package/esm/ai.d.mts.map +1 -1
  23. package/esm/ai.mjs +58 -3
  24. package/esm/ai.mjs.map +1 -1
  25. package/esm/batch/batch.d.mts +43 -0
  26. package/esm/batch/batch.d.mts.map +1 -0
  27. package/esm/batch/batch.mjs +179 -0
  28. package/esm/batch/batch.mjs.map +1 -0
  29. package/esm/batch/batch.type.d.mts +144 -0
  30. package/esm/batch/batch.type.d.mts.map +1 -0
  31. package/esm/batch/index.mjs +3 -0
  32. package/esm/batch/run-batch-item.mjs +100 -0
  33. package/esm/batch/run-batch-item.mjs.map +1 -0
  34. package/esm/batch/run-with-concurrency.mjs +39 -0
  35. package/esm/batch/run-with-concurrency.mjs.map +1 -0
  36. package/esm/checkpoint/index.d.mts +3 -0
  37. package/esm/checkpoint/memory.d.mts +21 -0
  38. package/esm/checkpoint/memory.d.mts.map +1 -0
  39. package/esm/checkpoint/memory.mjs +0 -0
  40. package/esm/checkpoint/memory.mjs.map +1 -0
  41. package/esm/checkpoint/pg.d.mts +37 -0
  42. package/esm/checkpoint/pg.d.mts.map +1 -0
  43. package/esm/checkpoint/pg.mjs +265 -0
  44. package/esm/checkpoint/pg.mjs.map +1 -0
  45. package/esm/checkpoint/redis.d.mts +39 -0
  46. package/esm/checkpoint/redis.d.mts.map +1 -0
  47. package/esm/checkpoint/redis.mjs +200 -0
  48. package/esm/checkpoint/redis.mjs.map +1 -0
  49. package/esm/config.d.mts +61 -14
  50. package/esm/config.d.mts.map +1 -1
  51. package/esm/config.mjs +25 -6
  52. package/esm/config.mjs.map +1 -1
  53. package/esm/contracts/agent/agent.contract.d.mts +43 -0
  54. package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
  55. package/esm/contracts/agent/eval.type.d.mts +143 -0
  56. package/esm/contracts/agent/eval.type.d.mts.map +1 -0
  57. package/esm/contracts/agent/index.d.mts +1 -0
  58. package/esm/contracts/events/supervisor-events.type.d.mts +3 -3
  59. package/esm/contracts/fallback-model.contract.d.mts +65 -0
  60. package/esm/contracts/fallback-model.contract.d.mts.map +1 -0
  61. package/esm/contracts/index.d.mts +32 -12
  62. package/esm/contracts/memory/index.d.mts +4 -0
  63. package/esm/contracts/memory/memory-config.type.d.mts +150 -0
  64. package/esm/contracts/memory/memory-config.type.d.mts.map +1 -0
  65. package/esm/contracts/memory/memory-item.type.d.mts +64 -0
  66. package/esm/contracts/memory/memory-item.type.d.mts.map +1 -0
  67. package/esm/contracts/memory/memory.contract.d.mts +87 -0
  68. package/esm/contracts/memory/memory.contract.d.mts.map +1 -0
  69. package/esm/contracts/memory/recall-options.type.d.mts +33 -0
  70. package/esm/contracts/memory/recall-options.type.d.mts.map +1 -0
  71. package/esm/contracts/middleware/index.d.mts +2 -2
  72. package/esm/contracts/middleware/middleware-context.type.d.mts +42 -2
  73. package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
  74. package/esm/contracts/middleware/middleware.contract.d.mts +46 -2
  75. package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
  76. package/esm/contracts/model.contract.d.mts +63 -2
  77. package/esm/contracts/model.contract.d.mts.map +1 -1
  78. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +91 -0
  79. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -0
  80. package/esm/contracts/orchestrator/index.d.mts +8 -0
  81. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +43 -0
  82. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -0
  83. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +170 -0
  84. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -0
  85. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +118 -0
  86. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -0
  87. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +44 -0
  88. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -0
  89. package/esm/contracts/orchestrator/orchestrator.contract.d.mts +129 -0
  90. package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -0
  91. package/esm/contracts/orchestrator/session.contract.d.mts +26 -0
  92. package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -0
  93. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +89 -0
  94. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -0
  95. package/esm/contracts/planner/index.d.mts +6 -0
  96. package/esm/contracts/planner/planner-capability.type.d.mts +39 -0
  97. package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -0
  98. package/esm/contracts/planner/planner-config.type.d.mts +78 -0
  99. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -0
  100. package/esm/contracts/planner/planner-execute-options.type.d.mts +43 -0
  101. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -0
  102. package/esm/contracts/planner/planner-plan.type.d.mts +48 -0
  103. package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -0
  104. package/esm/contracts/planner/planner-result.type.d.mts +82 -0
  105. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -0
  106. package/esm/contracts/planner/planner.contract.d.mts +60 -0
  107. package/esm/contracts/planner/planner.contract.d.mts.map +1 -0
  108. package/esm/contracts/result/base-report.type.d.mts +7 -2
  109. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  110. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  111. package/esm/contracts/result/index.d.mts +2 -1
  112. package/esm/contracts/result/model-pricing.type.d.mts +10 -0
  113. package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
  114. package/esm/contracts/result/orchestrator-result.type.d.mts +139 -0
  115. package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -0
  116. package/esm/contracts/result/session-send-result.type.d.mts +12 -3
  117. package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
  118. package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
  119. package/esm/contracts/result/usage.type.d.mts +24 -0
  120. package/esm/contracts/result/usage.type.d.mts.map +1 -1
  121. package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
  122. package/esm/contracts/supervisor/dispatch-context.type.d.mts +3 -3
  123. package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
  124. package/esm/contracts/supervisor/index.d.mts +5 -5
  125. package/esm/contracts/supervisor/route-context.type.d.mts +2 -2
  126. package/esm/contracts/supervisor/supervisor-config.type.d.mts +55 -13
  127. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  128. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
  129. package/esm/contracts/supervisor/supervisor.contract.d.mts +9 -2
  130. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
  131. package/esm/contracts/workflow/index.d.mts +2 -2
  132. package/esm/contracts/workflow/workflow.contract.d.mts +28 -7
  133. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  134. package/esm/errors/error-code.type.d.mts +1 -1
  135. package/esm/errors/index.d.mts +7 -0
  136. package/esm/errors/index.mjs +7 -0
  137. package/esm/errors/orchestrator-cancelled-error.d.mts +32 -0
  138. package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -0
  139. package/esm/errors/orchestrator-cancelled-error.mjs +31 -0
  140. package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -0
  141. package/esm/errors/orchestrator-config-error.d.mts +26 -0
  142. package/esm/errors/orchestrator-config-error.d.mts.map +1 -0
  143. package/esm/errors/orchestrator-config-error.mjs +30 -0
  144. package/esm/errors/orchestrator-config-error.mjs.map +1 -0
  145. package/esm/errors/orchestrator-drift-error.d.mts +38 -0
  146. package/esm/errors/orchestrator-drift-error.d.mts.map +1 -0
  147. package/esm/errors/orchestrator-drift-error.mjs +37 -0
  148. package/esm/errors/orchestrator-drift-error.mjs.map +1 -0
  149. package/esm/errors/orchestrator-failed-error.d.mts +33 -0
  150. package/esm/errors/orchestrator-failed-error.d.mts.map +1 -0
  151. package/esm/errors/orchestrator-failed-error.mjs +36 -0
  152. package/esm/errors/orchestrator-failed-error.mjs.map +1 -0
  153. package/esm/errors/planner-cancelled-error.d.mts +33 -0
  154. package/esm/errors/planner-cancelled-error.d.mts.map +1 -0
  155. package/esm/errors/planner-cancelled-error.mjs +29 -0
  156. package/esm/errors/planner-cancelled-error.mjs.map +1 -0
  157. package/esm/errors/planner-failed-error.d.mts +40 -0
  158. package/esm/errors/planner-failed-error.d.mts.map +1 -0
  159. package/esm/errors/planner-failed-error.mjs +37 -0
  160. package/esm/errors/planner-failed-error.mjs.map +1 -0
  161. package/esm/errors/planner-plan-invalid-error.d.mts +21 -0
  162. package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -0
  163. package/esm/errors/planner-plan-invalid-error.mjs +25 -0
  164. package/esm/errors/planner-plan-invalid-error.mjs.map +1 -0
  165. package/esm/eval/eval-runner.d.mts +17 -0
  166. package/esm/eval/eval-runner.d.mts.map +1 -0
  167. package/esm/eval/eval-runner.mjs +121 -0
  168. package/esm/eval/eval-runner.mjs.map +1 -0
  169. package/esm/eval/index.d.mts +29 -0
  170. package/esm/eval/index.d.mts.map +1 -0
  171. package/esm/eval/index.mjs +30 -0
  172. package/esm/eval/index.mjs.map +1 -0
  173. package/esm/eval/judge-scorer.d.mts +21 -0
  174. package/esm/eval/judge-scorer.d.mts.map +1 -0
  175. package/esm/eval/judge-scorer.mjs +87 -0
  176. package/esm/eval/judge-scorer.mjs.map +1 -0
  177. package/esm/eval/scorers.d.mts +50 -0
  178. package/esm/eval/scorers.d.mts.map +1 -0
  179. package/esm/eval/scorers.mjs +101 -0
  180. package/esm/eval/scorers.mjs.map +1 -0
  181. package/esm/index.d.mts +95 -30
  182. package/esm/index.mjs +66 -22
  183. package/esm/memory/derive-id.mjs +24 -0
  184. package/esm/memory/derive-id.mjs.map +1 -0
  185. package/esm/memory/episodic-memory.mjs +106 -0
  186. package/esm/memory/episodic-memory.mjs.map +1 -0
  187. package/esm/memory/index.d.mts +5 -0
  188. package/esm/memory/memory.d.mts +42 -0
  189. package/esm/memory/memory.d.mts.map +1 -0
  190. package/esm/memory/memory.mjs +166 -0
  191. package/esm/memory/memory.mjs.map +1 -0
  192. package/esm/memory/procedural-memory.mjs +103 -0
  193. package/esm/memory/procedural-memory.mjs.map +1 -0
  194. package/esm/memory/semantic-memory.mjs +80 -0
  195. package/esm/memory/semantic-memory.mjs.map +1 -0
  196. package/esm/memory/working-memory.mjs +62 -0
  197. package/esm/memory/working-memory.mjs.map +1 -0
  198. package/esm/middleware/builtins/budget-contract.type.d.mts +126 -0
  199. package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -0
  200. package/esm/middleware/builtins/budget.d.mts +71 -1
  201. package/esm/middleware/builtins/budget.d.mts.map +1 -1
  202. package/esm/middleware/builtins/budget.mjs +119 -4
  203. package/esm/middleware/builtins/budget.mjs.map +1 -1
  204. package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
  205. package/esm/middleware/index.d.mts +2 -1
  206. package/esm/middleware/index.mjs +1 -1
  207. package/esm/middleware/pipeline.d.mts +9 -6
  208. package/esm/middleware/pipeline.d.mts.map +1 -1
  209. package/esm/middleware/pipeline.mjs.map +1 -1
  210. package/esm/mock/index.d.mts +1 -0
  211. package/esm/mock/index.mjs +1 -0
  212. package/esm/mock/mock-router.d.mts +63 -0
  213. package/esm/mock/mock-router.d.mts.map +1 -0
  214. package/esm/mock/mock-router.mjs +58 -0
  215. package/esm/mock/mock-router.mjs.map +1 -0
  216. package/esm/model/fallback-model.d.mts +45 -0
  217. package/esm/model/fallback-model.d.mts.map +1 -0
  218. package/esm/model/fallback-model.mjs +218 -0
  219. package/esm/model/fallback-model.mjs.map +1 -0
  220. package/esm/model/index.d.mts +2 -0
  221. package/esm/model/index.mjs +3 -0
  222. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  223. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  224. package/esm/node_modules/@vitest/expect/dist/index.mjs +1473 -0
  225. package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
  226. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +888 -0
  227. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
  228. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1533 -0
  229. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -0
  230. package/esm/node_modules/@vitest/runner/dist/index.mjs +3 -0
  231. package/esm/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  232. package/esm/node_modules/@vitest/snapshot/dist/index.mjs +922 -0
  233. package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
  234. package/esm/node_modules/@vitest/spy/dist/index.mjs +386 -0
  235. package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
  236. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +82 -0
  237. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -0
  238. package/esm/node_modules/@vitest/utils/dist/diff.mjs +1357 -0
  239. package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
  240. package/esm/node_modules/@vitest/utils/dist/display.mjs +559 -0
  241. package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -0
  242. package/esm/node_modules/@vitest/utils/dist/error.mjs +38 -0
  243. package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
  244. package/esm/node_modules/@vitest/utils/dist/helpers.mjs +181 -0
  245. package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
  246. package/esm/node_modules/@vitest/utils/dist/offset.mjs +27 -0
  247. package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -0
  248. package/esm/node_modules/@vitest/utils/dist/serialize.mjs +77 -0
  249. package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -0
  250. package/esm/node_modules/@vitest/utils/dist/source-map.mjs +374 -0
  251. package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
  252. package/esm/node_modules/@vitest/utils/dist/timers.mjs +37 -0
  253. package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -0
  254. package/esm/node_modules/chai/index.mjs +2973 -0
  255. package/esm/node_modules/chai/index.mjs.map +1 -0
  256. package/esm/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  257. package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  258. package/esm/node_modules/tinyrainbow/dist/index.mjs +87 -0
  259. package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -0
  260. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +6 -0
  261. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -0
  262. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +52 -0
  263. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -0
  264. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +2697 -0
  265. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -0
  266. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +45 -0
  267. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -0
  268. package/esm/orchestrator/as-tool.d.mts +42 -0
  269. package/esm/orchestrator/as-tool.d.mts.map +1 -0
  270. package/esm/orchestrator/as-tool.mjs +98 -0
  271. package/esm/orchestrator/as-tool.mjs.map +1 -0
  272. package/esm/orchestrator/checkpoint.mjs +75 -0
  273. package/esm/orchestrator/checkpoint.mjs.map +1 -0
  274. package/esm/orchestrator/commands.d.mts +38 -0
  275. package/esm/orchestrator/commands.d.mts.map +1 -0
  276. package/esm/orchestrator/commands.mjs +34 -0
  277. package/esm/orchestrator/commands.mjs.map +1 -0
  278. package/esm/orchestrator/compaction.mjs +206 -0
  279. package/esm/orchestrator/compaction.mjs.map +1 -0
  280. package/esm/orchestrator/dispatch.mjs +171 -0
  281. package/esm/orchestrator/dispatch.mjs.map +1 -0
  282. package/esm/orchestrator/emitter-port.type.d.mts +31 -0
  283. package/esm/orchestrator/emitter-port.type.d.mts.map +1 -0
  284. package/esm/orchestrator/emitter.d.mts +56 -0
  285. package/esm/orchestrator/emitter.d.mts.map +1 -0
  286. package/esm/orchestrator/emitter.mjs +85 -0
  287. package/esm/orchestrator/emitter.mjs.map +1 -0
  288. package/esm/orchestrator/engine-context.type.d.mts +56 -0
  289. package/esm/orchestrator/engine-context.type.d.mts.map +1 -0
  290. package/esm/orchestrator/execution.d.mts +116 -0
  291. package/esm/orchestrator/execution.d.mts.map +1 -0
  292. package/esm/orchestrator/execution.mjs +406 -0
  293. package/esm/orchestrator/execution.mjs.map +1 -0
  294. package/esm/orchestrator/index.d.mts +8 -0
  295. package/esm/orchestrator/index.mjs +10 -0
  296. package/esm/orchestrator/load.mjs +49 -0
  297. package/esm/orchestrator/load.mjs.map +1 -0
  298. package/esm/orchestrator/lock.mjs +75 -0
  299. package/esm/orchestrator/lock.mjs.map +1 -0
  300. package/esm/orchestrator/memory.d.mts +84 -0
  301. package/esm/orchestrator/memory.d.mts.map +1 -0
  302. package/esm/orchestrator/memory.mjs +141 -0
  303. package/esm/orchestrator/memory.mjs.map +1 -0
  304. package/esm/orchestrator/orchestrator-stream.d.mts +42 -0
  305. package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -0
  306. package/esm/orchestrator/orchestrator-stream.mjs +98 -0
  307. package/esm/orchestrator/orchestrator-stream.mjs.map +1 -0
  308. package/esm/orchestrator/orchestrator.d.mts +38 -0
  309. package/esm/orchestrator/orchestrator.d.mts.map +1 -0
  310. package/esm/orchestrator/orchestrator.mjs +173 -0
  311. package/esm/orchestrator/orchestrator.mjs.map +1 -0
  312. package/esm/orchestrator/resume.mjs +74 -0
  313. package/esm/orchestrator/resume.mjs.map +1 -0
  314. package/esm/orchestrator/signature.d.mts +40 -0
  315. package/esm/orchestrator/signature.d.mts.map +1 -0
  316. package/esm/orchestrator/signature.mjs +120 -0
  317. package/esm/orchestrator/signature.mjs.map +1 -0
  318. package/esm/orchestrator/window.mjs +56 -0
  319. package/esm/orchestrator/window.mjs.map +1 -0
  320. package/esm/planner/index.d.mts +5 -0
  321. package/esm/planner/index.mjs +6 -0
  322. package/esm/planner/plan-prompt.d.mts +17 -0
  323. package/esm/planner/plan-prompt.d.mts.map +1 -0
  324. package/esm/planner/plan-prompt.mjs +30 -0
  325. package/esm/planner/plan-prompt.mjs.map +1 -0
  326. package/esm/planner/plan-schema.d.mts +27 -0
  327. package/esm/planner/plan-schema.d.mts.map +1 -0
  328. package/esm/planner/plan-schema.mjs +117 -0
  329. package/esm/planner/plan-schema.mjs.map +1 -0
  330. package/esm/planner/planner-run.d.mts +23 -0
  331. package/esm/planner/planner-run.d.mts.map +1 -0
  332. package/esm/planner/planner-run.mjs +344 -0
  333. package/esm/planner/planner-run.mjs.map +1 -0
  334. package/esm/planner/planner.d.mts +37 -0
  335. package/esm/planner/planner.d.mts.map +1 -0
  336. package/esm/planner/planner.mjs +120 -0
  337. package/esm/planner/planner.mjs.map +1 -0
  338. package/esm/planner/signature.d.mts +18 -0
  339. package/esm/planner/signature.d.mts.map +1 -0
  340. package/esm/planner/signature.mjs +27 -0
  341. package/esm/planner/signature.mjs.map +1 -0
  342. package/esm/snapshot/index.d.mts +3 -0
  343. package/esm/snapshot/memory.d.mts +26 -0
  344. package/esm/snapshot/memory.d.mts.map +1 -0
  345. package/esm/snapshot/memory.mjs +81 -0
  346. package/esm/snapshot/memory.mjs.map +1 -0
  347. package/esm/snapshot/pg.d.mts +41 -0
  348. package/esm/snapshot/pg.d.mts.map +1 -0
  349. package/esm/snapshot/pg.mjs +146 -0
  350. package/esm/snapshot/pg.mjs.map +1 -0
  351. package/esm/snapshot/redis.d.mts +42 -0
  352. package/esm/snapshot/redis.d.mts.map +1 -0
  353. package/esm/snapshot/redis.mjs +101 -0
  354. package/esm/snapshot/redis.mjs.map +1 -0
  355. package/esm/supervisor/as-tool.d.mts +0 -6
  356. package/esm/supervisor/as-tool.d.mts.map +1 -1
  357. package/esm/supervisor/as-tool.mjs +0 -6
  358. package/esm/supervisor/as-tool.mjs.map +1 -1
  359. package/esm/supervisor/execution.d.mts +43 -8
  360. package/esm/supervisor/execution.d.mts.map +1 -1
  361. package/esm/supervisor/execution.mjs +66 -16
  362. package/esm/supervisor/execution.mjs.map +1 -1
  363. package/esm/supervisor/fan-out.d.mts +65 -0
  364. package/esm/supervisor/fan-out.d.mts.map +1 -0
  365. package/esm/supervisor/fan-out.mjs +65 -0
  366. package/esm/supervisor/fan-out.mjs.map +1 -0
  367. package/esm/supervisor/index.d.mts +5 -3
  368. package/esm/supervisor/index.mjs +3 -1
  369. package/esm/supervisor/router-factory.d.mts +110 -0
  370. package/esm/supervisor/router-factory.d.mts.map +1 -0
  371. package/esm/supervisor/router-factory.mjs +141 -0
  372. package/esm/supervisor/router-factory.mjs.map +1 -0
  373. package/esm/supervisor/router-prompt.d.mts +1 -1
  374. package/esm/supervisor/snapshot.d.mts +4 -10
  375. package/esm/supervisor/snapshot.d.mts.map +1 -1
  376. package/esm/supervisor/snapshot.mjs +8 -16
  377. package/esm/supervisor/snapshot.mjs.map +1 -1
  378. package/esm/supervisor/supervisor.mjs +1 -0
  379. package/esm/supervisor/supervisor.mjs.map +1 -1
  380. package/esm/system-prompt/index.mjs +6 -0
  381. package/esm/system-prompt/system-prompt.d.mts +51 -3
  382. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  383. package/esm/system-prompt/system-prompt.mjs +52 -6
  384. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  385. package/esm/testing/matcher-logic.d.mts +76 -0
  386. package/esm/testing/matcher-logic.d.mts.map +1 -0
  387. package/esm/testing/matcher-logic.mjs +144 -0
  388. package/esm/testing/matcher-logic.mjs.map +1 -0
  389. package/esm/testing/matchers.d.mts +48 -0
  390. package/esm/testing/matchers.d.mts.map +1 -0
  391. package/esm/testing/matchers.mjs +37 -0
  392. package/esm/testing/matchers.mjs.map +1 -0
  393. package/esm/testing/register-lazy.d.mts +20 -0
  394. package/esm/testing/register-lazy.d.mts.map +1 -0
  395. package/esm/testing/register-lazy.mjs +24 -0
  396. package/esm/testing/register-lazy.mjs.map +1 -0
  397. package/esm/tool/executable-as-tool.d.mts +87 -0
  398. package/esm/tool/executable-as-tool.d.mts.map +1 -0
  399. package/esm/tool/executable-as-tool.mjs +81 -0
  400. package/esm/tool/executable-as-tool.mjs.map +1 -0
  401. package/esm/tool/index.d.mts +2 -1
  402. package/esm/tool/index.mjs +1 -0
  403. package/esm/workflow/as-tool.mjs +0 -6
  404. package/esm/workflow/as-tool.mjs.map +1 -1
  405. package/esm/workflow/engine.mjs +2 -2
  406. package/esm/workflow/snapshot.mjs +13 -7
  407. package/esm/workflow/snapshot.mjs.map +1 -1
  408. package/esm/workflow/step-runner.mjs +1 -1
  409. package/esm/workflow/workflow.mjs +1 -0
  410. package/esm/workflow/workflow.mjs.map +1 -1
  411. package/llms-full.txt +947 -42
  412. package/llms.txt +13 -8
  413. package/package.json +3 -3
  414. package/skills/README.md +25 -5
  415. package/skills/ai-basics/SKILL.md +18 -7
  416. package/skills/ai-dx-helpers/SKILL.md +180 -0
  417. package/skills/attach-ai-middleware/SKILL.md +32 -3
  418. package/skills/handle-ai-errors/SKILL.md +20 -6
  419. package/skills/manage-ai-stores/SKILL.md +127 -0
  420. package/skills/persist-ai-data/SKILL.md +21 -10
  421. package/skills/pick-ai-provider/SKILL.md +46 -12
  422. package/skills/run-ai-agent/SKILL.md +51 -2
  423. package/skills/run-orchestrator/SKILL.md +198 -0
  424. package/skills/run-planner/SKILL.md +68 -0
  425. package/skills/run-supervisor/SKILL.md +47 -2
  426. package/skills/use-ai-memory/SKILL.md +124 -0
  427. package/skills/write-system-prompt/SKILL.md +14 -1
@@ -0,0 +1,60 @@
1
+ import { ExecutableContract } from "../executable.contract.mjs";
2
+ import { PlannerExecuteOptions } from "./planner-execute-options.type.mjs";
3
+ import { PlannerResult } from "./planner-result.type.mjs";
4
+
5
+ //#region ../@warlock.js/ai/src/contracts/planner/planner.contract.d.ts
6
+ /**
7
+ * Runtime handle returned by `ai.planner(config)`.
8
+ *
9
+ * Implements {@link ExecutableContract} alongside `AgentContract`,
10
+ * `WorkflowInstance`, and `SupervisorContract`, so a planner can be
11
+ * dispatched anywhere the framework dispatches an executable — composed
12
+ * as a supervisor intent, an orchestrator capability, or wrapped as a
13
+ * tool for an outer agent.
14
+ *
15
+ * **What it does.** At `execute(goal)` it asks an LLM to GENERATE an
16
+ * ordered plan over the registered capabilities, then executes that
17
+ * plan step-by-step through each capability's own `execute()`,
18
+ * returning the unified `{ data, report, usage, error }` envelope with
19
+ * `report.type === "planner"`. Never throws on runtime failure — errors
20
+ * surface via `result.error`. Authoring-time misconfiguration throws at
21
+ * factory call, not here.
22
+ *
23
+ * @example
24
+ * const research = ai.planner({
25
+ * name: "research-assistant",
26
+ * model: ai.openai.model({ name: "gpt-4o" }),
27
+ * capabilities: [
28
+ * { name: "search", description: "Search the web", executable: searchAgent },
29
+ * { name: "write", description: "Draft a summary", executable: writerAgent },
30
+ * ],
31
+ * });
32
+ *
33
+ * const { data, report, usage, error } = await research.execute(
34
+ * "Summarize the latest on TypeScript 6",
35
+ * );
36
+ *
37
+ * console.log(report.plan?.summary);
38
+ * for (const executed of report.executedSteps) {
39
+ * console.log(executed.step.capability, executed.status);
40
+ * }
41
+ */
42
+ interface PlannerContract<TOutput = unknown> extends ExecutableContract<string, PlannerExecuteOptions<TOutput>, PlannerResult<TOutput>> {
43
+ /** Stable identifier — mirrors the config's `name`. */
44
+ readonly name: string;
45
+ /**
46
+ * Structural fingerprint of the planner definition — name + ordered
47
+ * capability names. Stamped on every report node this planner
48
+ * produces.
49
+ */
50
+ readonly signature: string;
51
+ /**
52
+ * Generate a plan over the configured capabilities and execute it
53
+ * end-to-end. Returns the uniform `{ data, report, usage, error }`
54
+ * shape; runtime failures surface on `result.error`.
55
+ */
56
+ execute(goal: string, options?: PlannerExecuteOptions<TOutput>): Promise<PlannerResult<TOutput>>;
57
+ }
58
+ //#endregion
59
+ export { PlannerContract };
60
+ //# sourceMappingURL=planner.contract.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/planner/planner.contract.ts"],"mappings":";;;;;;;AAwCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBkC;;UAtBjB,eAAA,4BAA2C,kBAAA,SAE1D,qBAAA,CAAsB,OAAA,GACtB,aAAA,CAAc,OAAA;;WAGL,IAAA;;;;;;WAMA,SAAA;;;;;;EAOT,OAAA,CACE,IAAA,UACA,OAAA,GAAU,qBAAA,CAAsB,OAAA,IAC/B,OAAA,CAAQ,aAAA,CAAc,OAAA;AAAA"}
@@ -19,7 +19,7 @@ declare const REPORT_SCHEMA_VERSION = 1;
19
19
  * {@link BaseReport}. Forms a closed union so consumers can narrow on
20
20
  * the tree without string-matching on `name`.
21
21
  */
22
- type ReportType = "tool" | "callback" | "agent" | "workflow" | "supervisor";
22
+ type ReportType = "tool" | "callback" | "agent" | "workflow" | "supervisor" | "orchestrator" | "batch" | "planner";
23
23
  /**
24
24
  * Terminal status every executable primitive reports. Unified across
25
25
  * tools, agents, workflows, and supervisors so dashboards and
@@ -34,8 +34,13 @@ type ReportType = "tool" | "callback" | "agent" | "workflow" | "supervisor";
34
34
  * iteration cap was hit without an explicit `END` / `satisfied`.
35
35
  * Harmless on non-supervisor reports; keeping it on the shared
36
36
  * union lets consumers write one `switch` for every status.
37
+ * - `"awaiting-input"` — orchestrator-specific NON-terminal status: the
38
+ * session is paused waiting for the next user turn (§15.6). The only
39
+ * non-terminal member of this union; consumers branching on
40
+ * `status === "completed"` must treat it as a session-continues path,
41
+ * not a failure. Harmless on non-orchestrator reports.
37
42
  */
38
- type ReportStatus = "completed" | "failed" | "cancelled" | "max-iterations";
43
+ type ReportStatus = "completed" | "failed" | "cancelled" | "max-iterations" | "awaiting-input";
39
44
  /**
40
45
  * Universal execution report shared by every primitive. Per-primitive
41
46
  * report types extend this with their own domain-specific fields
@@ -1 +1 @@
1
- {"version":3,"file":"base-report.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"mappings":";;;;;;AAcA;;;;AAAkC;AAOlC;;;;cAPa,qBAAA;AA6Bb;;;;AAAwB;AAAxB,KAtBY,UAAA;;;;;;;;;;;;;;;;KAsBA,YAAA;;;;;;;;;;;;;;;AA4GS;;;;;;;;;;KA9ET,UAAA;sFAEV,KAAA;;;;;;;;;;EAUA,WAAA;;;;;;;EAOA,SAAA;EAEA,IAAA;;;;;;;;;;;;EAYA,OAAA;;;;;;;;;;EAUA,SAAA;EAEA,IAAA,EAAM,UAAA;EAEN,MAAA,EAAQ,YAAA;EAER,SAAA;EAEA,OAAA;EAEA,QAAA;EAEA,KAAA,EAAO,KAAA;;;;;;EAMP,QAAA,EAAU,UAAA;;;;;;;;EAQV,QAAA,GAAW,YAAA;;;;;;;;;EASX,mBAAA;AAAA"}
1
+ {"version":3,"file":"base-report.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"mappings":";;;;;;AAcA;;;;AAAkC;AAOlC;;;;cAPa,qBAAA;AAqCb;;;;AAAwB;AAAxB,KA9BY,UAAA;;;;;;;;;;;;;;;;;;;;;KA8BA,YAAA;;;;;;;;;;AA6GS;;;;;;;;;;;;;;;KA9ET,UAAA;sFAEV,KAAA;;;;;;;;;;EAUA,WAAA;;;;;;;EAOA,SAAA;EAEA,IAAA;;;;;;;;;;;;EAYA,OAAA;;;;;;;;;;EAUA,SAAA;EAEA,IAAA,EAAM,UAAA;EAEN,MAAA,EAAQ,YAAA;EAER,SAAA;EAEA,OAAA;EAEA,QAAA;EAEA,KAAA,EAAO,KAAA;;;;;;EAMP,QAAA,EAAU,UAAA;;;;;;;;EAQV,QAAA,GAAW,YAAA;;;;;;;;;EASX,mBAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"base-report.type.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"sourcesContent":["import type { AttemptEntry } from \"./attempt-entry.type\";\nimport type { Usage } from \"./usage.type\";\n\n/**\n * Wire-format version stamped on every root `BaseReport`. Bumped only\n * when we make a BREAKING change to the report shape (field removed,\n * required-ness flipped, semantics changed). Additive changes (new\n * optional fields) do not bump.\n *\n * Panoptic and other downstream consumers branch on this to parse\n * old stored reports with their original-shape rules.\n *\n * Current: **1** — initial Panoptic-readiness shape.\n */\nexport const REPORT_SCHEMA_VERSION = 1;\n\n/**\n * Discriminator for the kind of executable that produced a given\n * {@link BaseReport}. Forms a closed union so consumers can narrow on\n * the tree without string-matching on `name`.\n */\nexport type ReportType =\n | \"tool\"\n | \"callback\"\n | \"agent\"\n | \"workflow\"\n | \"supervisor\";\n\n/**\n * Terminal status every executable primitive reports. Unified across\n * tools, agents, workflows, and supervisors so dashboards and\n * generic traversal helpers don't special-case per primitive.\n *\n * - `\"completed\"` — ran to natural end with a usable result.\n * - `\"failed\"` — aborted mid-run or finished without a usable result\n * (crash, schema failure, max-trips, etc.). The\n * accompanying `error` on the envelope carries the typed cause.\n * - `\"cancelled\"` — caller aborted before completion via `AbortSignal`.\n * - `\"max-iterations\"` — supervisor-specific termination when the\n * iteration cap was hit without an explicit `END` / `satisfied`.\n * Harmless on non-supervisor reports; keeping it on the shared\n * union lets consumers write one `switch` for every status.\n */\nexport type ReportStatus =\n | \"completed\"\n | \"failed\"\n | \"cancelled\"\n | \"max-iterations\";\n\n/**\n * Universal execution report shared by every primitive. Per-primitive\n * report types extend this with their own domain-specific fields\n * (agent trips, workflow steps, supervisor iteration snapshots) while\n * keeping the root fields identical. Recursion happens through\n * {@link BaseReport.children} — any executable this node invoked\n * contributes its own full report here, producing a walkable tree of\n * the entire run.\n *\n * **Usage rollup.** `usage` at every node equals this node's own cost\n * plus the sum of each child's `usage`. Leaves (tools) contribute\n * zero own-cost; composites contribute their direct LLM spend only,\n * with children covering everything delegated.\n *\n * @example\n * function totalCost(report: BaseReport): number {\n * return report.usage.total;\n * }\n *\n * function walk(report: BaseReport, depth = 0): void {\n * console.log(`${\" \".repeat(depth)}${report.type} \"${report.name}\" — ${report.status}`);\n * for (const child of report.children) walk(child, depth + 1);\n * }\n */\nexport type BaseReport = {\n /** Stable id for this execution node. Generated per `execute()`/`invoke()` call. */\n runId: string;\n /**\n * Run-id of the immediate parent execution node, when this node was\n * invoked as part of a larger run (e.g. a tool dispatched by an\n * agent; an agent dispatched by a supervisor; an inner primitive\n * wrapped via `asTool()`). Absent on root nodes.\n *\n * Lets Panoptic and other flat-row consumers reconstruct the tree\n * without traversing `children[]` in memory.\n */\n parentRunId?: string;\n /**\n * Run-id of the top-level execution this node belongs to. Equals\n * `runId` on the root node, and is propagated downward to every\n * descendant. Used to slice flat report tables back into per-run\n * groupings.\n */\n rootRunId: string;\n /** Executable identity — the tool/agent/workflow/supervisor name. */\n name: string;\n /**\n * Dev-curated version string mirrored from the primitive's config\n * (`AgentConfig.version`, `ToolConfig.version`, etc.). Free-form —\n * the framework neither parses nor compares it. Stored verbatim on\n * every report so trip-archive queries can distinguish runs of\n * \"agent X v2.1\" from \"agent X v2.2\" even when name + signature\n * are identical.\n *\n * Stays `undefined` when the dev didn't declare one — never\n * auto-defaulted.\n */\n version?: string;\n /**\n * Caller-supplied identifier that groups multiple `.execute()` calls\n * into one conceptual user session / request. Propagated to every\n * descendant report node so flat queries (\"total spend for session\n * X today\") work without joining the tree.\n *\n * Threaded from `execute()` options on every primitive. Optional —\n * absent when the caller didn't supply one.\n */\n sessionId?: string;\n /** Discriminator for the kind of executable that produced this report. */\n type: ReportType;\n /** Terminal status of this execution. */\n status: ReportStatus;\n /** ISO-8601 wall-clock timestamp when execution began. */\n startedAt: string;\n /** ISO-8601 wall-clock timestamp when execution finished. */\n endedAt: string;\n /** Monotonic duration in milliseconds — `performance.now()` delta. */\n duration: number;\n /** Rolled-up usage: own cost + sum of `children[].usage`. */\n usage: Usage;\n /**\n * Reports of every executable invoked by this node, in invocation\n * order. Empty for leaves (pure tools) and for executables that\n * didn't delegate work.\n */\n children: BaseReport[];\n /**\n * Retry history when middleware (or, for workflow steps, the engine\n * itself) retried this node before it either succeeded or gave up.\n * Absent when zero retries happened — keeps the common-case payload\n * lean. The surviving (final) attempt is NOT duplicated here; its\n * outcome is the report's own `status` / timing.\n */\n attempts?: AttemptEntry[];\n /**\n * Wire-format version of this report shape. Only present on root\n * report nodes — implies the same version for the whole tree.\n * Panoptic / archive consumers branch on this to parse old reports\n * with their original-shape rules.\n *\n * Always equals {@link REPORT_SCHEMA_VERSION} at write time.\n */\n reportSchemaVersion?: number;\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,wBAAwB"}
1
+ {"version":3,"file":"base-report.type.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/base-report.type.ts"],"sourcesContent":["import type { AttemptEntry } from \"./attempt-entry.type\";\nimport type { Usage } from \"./usage.type\";\n\n/**\n * Wire-format version stamped on every root `BaseReport`. Bumped only\n * when we make a BREAKING change to the report shape (field removed,\n * required-ness flipped, semantics changed). Additive changes (new\n * optional fields) do not bump.\n *\n * Panoptic and other downstream consumers branch on this to parse\n * old stored reports with their original-shape rules.\n *\n * Current: **1** — initial Panoptic-readiness shape.\n */\nexport const REPORT_SCHEMA_VERSION = 1;\n\n/**\n * Discriminator for the kind of executable that produced a given\n * {@link BaseReport}. Forms a closed union so consumers can narrow on\n * the tree without string-matching on `name`.\n */\nexport type ReportType =\n | \"tool\"\n | \"callback\"\n | \"agent\"\n | \"workflow\"\n | \"supervisor\"\n | \"orchestrator\"\n | \"batch\"\n | \"planner\";\n\n/**\n * Terminal status every executable primitive reports. Unified across\n * tools, agents, workflows, and supervisors so dashboards and\n * generic traversal helpers don't special-case per primitive.\n *\n * - `\"completed\"` — ran to natural end with a usable result.\n * - `\"failed\"` — aborted mid-run or finished without a usable result\n * (crash, schema failure, max-trips, etc.). The\n * accompanying `error` on the envelope carries the typed cause.\n * - `\"cancelled\"` — caller aborted before completion via `AbortSignal`.\n * - `\"max-iterations\"` — supervisor-specific termination when the\n * iteration cap was hit without an explicit `END` / `satisfied`.\n * Harmless on non-supervisor reports; keeping it on the shared\n * union lets consumers write one `switch` for every status.\n * - `\"awaiting-input\"` — orchestrator-specific NON-terminal status: the\n * session is paused waiting for the next user turn (§15.6). The only\n * non-terminal member of this union; consumers branching on\n * `status === \"completed\"` must treat it as a session-continues path,\n * not a failure. Harmless on non-orchestrator reports.\n */\nexport type ReportStatus =\n | \"completed\"\n | \"failed\"\n | \"cancelled\"\n | \"max-iterations\"\n | \"awaiting-input\";\n\n/**\n * Universal execution report shared by every primitive. Per-primitive\n * report types extend this with their own domain-specific fields\n * (agent trips, workflow steps, supervisor iteration snapshots) while\n * keeping the root fields identical. Recursion happens through\n * {@link BaseReport.children} — any executable this node invoked\n * contributes its own full report here, producing a walkable tree of\n * the entire run.\n *\n * **Usage rollup.** `usage` at every node equals this node's own cost\n * plus the sum of each child's `usage`. Leaves (tools) contribute\n * zero own-cost; composites contribute their direct LLM spend only,\n * with children covering everything delegated.\n *\n * @example\n * function totalCost(report: BaseReport): number {\n * return report.usage.total;\n * }\n *\n * function walk(report: BaseReport, depth = 0): void {\n * console.log(`${\" \".repeat(depth)}${report.type} \"${report.name}\" — ${report.status}`);\n * for (const child of report.children) walk(child, depth + 1);\n * }\n */\nexport type BaseReport = {\n /** Stable id for this execution node. Generated per `execute()`/`invoke()` call. */\n runId: string;\n /**\n * Run-id of the immediate parent execution node, when this node was\n * invoked as part of a larger run (e.g. a tool dispatched by an\n * agent; an agent dispatched by a supervisor; an inner primitive\n * wrapped via `asTool()`). Absent on root nodes.\n *\n * Lets Panoptic and other flat-row consumers reconstruct the tree\n * without traversing `children[]` in memory.\n */\n parentRunId?: string;\n /**\n * Run-id of the top-level execution this node belongs to. Equals\n * `runId` on the root node, and is propagated downward to every\n * descendant. Used to slice flat report tables back into per-run\n * groupings.\n */\n rootRunId: string;\n /** Executable identity — the tool/agent/workflow/supervisor name. */\n name: string;\n /**\n * Dev-curated version string mirrored from the primitive's config\n * (`AgentConfig.version`, `ToolConfig.version`, etc.). Free-form —\n * the framework neither parses nor compares it. Stored verbatim on\n * every report so trip-archive queries can distinguish runs of\n * \"agent X v2.1\" from \"agent X v2.2\" even when name + signature\n * are identical.\n *\n * Stays `undefined` when the dev didn't declare one — never\n * auto-defaulted.\n */\n version?: string;\n /**\n * Caller-supplied identifier that groups multiple `.execute()` calls\n * into one conceptual user session / request. Propagated to every\n * descendant report node so flat queries (\"total spend for session\n * X today\") work without joining the tree.\n *\n * Threaded from `execute()` options on every primitive. Optional —\n * absent when the caller didn't supply one.\n */\n sessionId?: string;\n /** Discriminator for the kind of executable that produced this report. */\n type: ReportType;\n /** Terminal status of this execution. */\n status: ReportStatus;\n /** ISO-8601 wall-clock timestamp when execution began. */\n startedAt: string;\n /** ISO-8601 wall-clock timestamp when execution finished. */\n endedAt: string;\n /** Monotonic duration in milliseconds — `performance.now()` delta. */\n duration: number;\n /** Rolled-up usage: own cost + sum of `children[].usage`. */\n usage: Usage;\n /**\n * Reports of every executable invoked by this node, in invocation\n * order. Empty for leaves (pure tools) and for executables that\n * didn't delegate work.\n */\n children: BaseReport[];\n /**\n * Retry history when middleware (or, for workflow steps, the engine\n * itself) retried this node before it either succeeded or gave up.\n * Absent when zero retries happened — keeps the common-case payload\n * lean. The surviving (final) attempt is NOT duplicated here; its\n * outcome is the report's own `status` / timing.\n */\n attempts?: AttemptEntry[];\n /**\n * Wire-format version of this report shape. Only present on root\n * report nodes — implies the same version for the whole tree.\n * Panoptic / archive consumers branch on this to parse old reports\n * with their original-shape rules.\n *\n * Always equals {@link REPORT_SCHEMA_VERSION} at write time.\n */\n reportSchemaVersion?: number;\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,wBAAwB"}
@@ -8,7 +8,8 @@ import { LLMTrip } from "./llm-trip.type.mjs";
8
8
  import { AgentReport, ExecutionReport, ExecutionStatus } from "./execution-report.type.mjs";
9
9
  import { AgentResult } from "./agent-result.type.mjs";
10
10
  import { ExecuteResult } from "./execute-result.type.mjs";
11
+ import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./supervisor-result.type.mjs";
11
12
  import { StepSnapshot } from "./step-result.type.mjs";
12
13
  import { WorkflowReport, WorkflowResult } from "./workflow-result.type.mjs";
13
- import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./supervisor-result.type.mjs";
14
+ import { CompactionResult, OrchestratorAwaitingStatus, OrchestratorReport, OrchestratorReportStatus, OrchestratorReportType, OrchestratorResult, TurnSnapshot } from "./orchestrator-result.type.mjs";
14
15
  import { SessionSendResult } from "./session-send-result.type.mjs";
@@ -45,6 +45,16 @@ type ModelPricing = {
45
45
  * does not. Falls back to `output` when undefined.
46
46
  */
47
47
  cachedOutput?: number;
48
+ /**
49
+ * USD per 1M reasoning/thinking tokens (`Usage.reasoningTokens`), for
50
+ * providers that price reasoning above the standard output rate.
51
+ * Falls back to `output` when undefined — the common case, since most
52
+ * providers bill reasoning tokens at the output rate.
53
+ *
54
+ * @example
55
+ * const pricing: ModelPricing = { input: 0.15, output: 0.6, reasoning: 0.6 };
56
+ */
57
+ reasoning?: number;
48
58
  };
49
59
  //#endregion
50
60
  export { ModelPricing };
@@ -1 +1 @@
1
- {"version":3,"file":"model-pricing.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/model-pricing.type.ts"],"mappings":";;AA+BA;;;;;;;;;AAgBc;;;;;;;;;;;;;;;;;;;;;KAhBF,YAAA;iCAEV,KAAA;EAEA,MAAA;;;;;;EAMA,WAAA;;;;;;EAMA,YAAA;AAAA"}
1
+ {"version":3,"file":"model-pricing.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/model-pricing.type.ts"],"mappings":";;AA+BA;;;;;;;;;;AA0BW;;;;;;;;;;;;;;;;;;;;KA1BC,YAAA;iCAEV,KAAA;EAEA,MAAA;;;;;;EAMA,WAAA;;;;;;EAMA,YAAA;;;;;;;;;;EAUA,SAAA;AAAA"}
@@ -0,0 +1,139 @@
1
+ import { Message } from "../conversation-message.type.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+ import { BaseReport, ReportStatus } from "./base-report.type.mjs";
4
+ import { ExecuteResult } from "./execute-result.type.mjs";
5
+ import { SupervisorInput } from "../supervisor/supervisor-input.type.mjs";
6
+ import { EvaluateResult } from "../supervisor/evaluate-context.type.mjs";
7
+ import { AgentBranchSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
8
+
9
+ //#region ../@warlock.js/ai/src/contracts/result/orchestrator-result.type.d.ts
10
+ /**
11
+ * Discriminator literal the orchestrator stamps onto its report's
12
+ * `type` field (design §15.5). Now a member of the shared
13
+ * {@link ReportType} closed union in `base-report.type.ts`, so
14
+ * {@link OrchestratorReport} narrows `type` against the shared union
15
+ * directly rather than overriding it.
16
+ */
17
+ type OrchestratorReportType = "orchestrator";
18
+ /**
19
+ * Non-terminal status the orchestrator adds on top of the shared
20
+ * {@link ReportStatus} union — the session is paused waiting for the
21
+ * next user turn (design §15.6, Q9). This is the only non-terminal
22
+ * status across the unified result tree, and is now a member of the
23
+ * shared {@link ReportStatus} union in `base-report.type.ts`.
24
+ */
25
+ type OrchestratorAwaitingStatus = "awaiting-input";
26
+ /**
27
+ * Combined status surface for an orchestrator report — every terminal
28
+ * {@link ReportStatus} plus the non-terminal `"awaiting-input"`.
29
+ * Consumers branching on `status === "completed"` must explicitly
30
+ * handle `"awaiting-input"` as a session-continues path, not a failure
31
+ * (§15.6, §18.10).
32
+ */
33
+ type OrchestratorReportStatus = ReportStatus | OrchestratorAwaitingStatus;
34
+ /**
35
+ * The result of compacting (summarizing) a slice of session history
36
+ * (design §12, §15.5). Carries the replacement summary message plus the
37
+ * inclusive index range it replaces, so a dev-owned message store can
38
+ * apply the compaction deterministically.
39
+ *
40
+ * Structurally identical to `OrchestratorCommands["compact"]["result"]`
41
+ * — both are kept per the literal §11 / §15.5 spec shapes.
42
+ */
43
+ type CompactionResult = {
44
+ /** The summary message that replaces the compacted range. */summary: Message; /** Inclusive start index (in the dev's history array) of the replaced range. */
45
+ replacesFromIndex: number; /** Inclusive end index of the replaced range. */
46
+ replacesToIndex: number;
47
+ };
48
+ /**
49
+ * One turn's forensic record on {@link OrchestratorReport.turns}.
50
+ * Mirrors the supervisor's `IterationSnapshot.result` shape so a turn
51
+ * reads uniformly whether it dispatched one agent (`iterate: false`) or
52
+ * delegated to an internal supervisor (`iterate: true`).
53
+ *
54
+ * Frozen (`Readonly`) so consumers can pass snapshots across async
55
+ * boundaries without defensive cloning. `state` is the post-merge,
56
+ * JSON-serializable session state at the end of the turn.
57
+ */
58
+ type TurnSnapshot = Readonly<{
59
+ /** Zero-indexed turn number. */turn: number; /** The user input that opened this turn. */
60
+ input: SupervisorInput; /** Where the dispatch decision came from and its raw value. */
61
+ decision: {
62
+ source: "route" | "router" | "intent.next";
63
+ raw: unknown;
64
+ reasoning?: string;
65
+ }; /** Per-branch dispatch records keyed by intent (mirrors supervisor). */
66
+ result: Record<string, AgentBranchSnapshot>; /** Post-merge session state — JSON-serializable. */
67
+ state: unknown; /** Evaluate verdict, if `evaluate` ran this turn. */
68
+ evaluate?: EvaluateResult;
69
+ startedAt: string;
70
+ endedAt: string;
71
+ duration: number;
72
+ usage: Usage;
73
+ /**
74
+ * The dispatched primitive's full report tree — the internal
75
+ * supervisor's report when `iterate: true`, the direct agent's report
76
+ * when `iterate: false`.
77
+ */
78
+ childReport?: BaseReport;
79
+ }>;
80
+ /**
81
+ * Session-scoped execution report for a single orchestrator turn
82
+ * (design §15.5). Extends {@link BaseReport} with session identity, the
83
+ * turn index, the drift signature, and the per-turn history on
84
+ * `turns[]`.
85
+ *
86
+ * `children[]` carries ONLY the current turn's dispatched primitive
87
+ * reports (Q9). Full session history lives on `turns[]`; walkers that
88
+ * recurse via `children[]` will NOT reach prior turns — intentional.
89
+ *
90
+ * @remarks
91
+ * `type` and `status` narrow the shared {@link BaseReport} fields to
92
+ * the orchestrator-specific literals. Both `"orchestrator"` and
93
+ * `"awaiting-input"` are now members of the shared {@link ReportType} /
94
+ * {@link ReportStatus} unions, so this inherits {@link BaseReport}
95
+ * directly and re-declares the two fields as compatible narrowings.
96
+ */
97
+ type OrchestratorReport = BaseReport & {
98
+ type: OrchestratorReportType;
99
+ status: OrchestratorReportStatus;
100
+ sessionId: string;
101
+ turnIndex: number; /** Orchestrator-scope drift signature (§10.1). */
102
+ signature: string;
103
+ version?: string; /** Current turn + (optionally) prior turns, bounded by `keepSnapshots`. */
104
+ turns: TurnSnapshot[];
105
+ };
106
+ /**
107
+ * Per-turn result returned by `orchestrator.execute()` and resolved by
108
+ * `orchestrator.stream().result` (design §15.5). Extends the unified
109
+ * {@link ExecuteResult} envelope with the session id, the turn index,
110
+ * an optional compaction record, and the orchestrator report.
111
+ *
112
+ * Narrow on `report.type` / `report.status` (not a top-level
113
+ * discriminant string) and read typed `data` for the turn's output.
114
+ *
115
+ * @example
116
+ * const result = await orchestrator.execute(message, { sessionId, history });
117
+ *
118
+ * if (result.error) {
119
+ * logger.error(result.error.code, { sessionId: result.sessionId });
120
+ * return;
121
+ * }
122
+ *
123
+ * if (result.report.status === "awaiting-input") {
124
+ * // session continues — prompt the user for the next turn
125
+ * }
126
+ *
127
+ * if (result.compaction) {
128
+ * await myMessageStore.applyCompaction(result.sessionId, result.compaction);
129
+ * }
130
+ */
131
+ type OrchestratorResult<TOutput = unknown> = ExecuteResult<TOutput> & {
132
+ sessionId: string;
133
+ turnIndex: number;
134
+ compaction?: CompactionResult;
135
+ report: OrchestratorReport;
136
+ };
137
+ //#endregion
138
+ export { CompactionResult, OrchestratorAwaitingStatus, OrchestratorReport, OrchestratorReportStatus, OrchestratorReportType, OrchestratorResult, TurnSnapshot };
139
+ //# sourceMappingURL=orchestrator-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator-result.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/orchestrator-result.type.ts"],"mappings":";;;;;;;;;;;AAeA;;;;AAAkC;KAAtB,sBAAA;;;;AAS0B;AAStC;;;KATY,0BAAA;AASoE;AAWhF;;;;;;AAXgF,KAApE,wBAAA,GAA2B,YAAA,GAAe,0BAA0B;;;AAiB/D;AAajB;;;;;;KAnBY,gBAAA;EAuCH,6DArCP,OAAA,EAAS,OAAO,EAiBS;EAfzB,iBAAA,UAeiC;EAbjC,eAAA;AAAA;;;;;;;;;;;KAaU,YAAA,GAAe,QAAA;EAgBd,gCAdX,IAAA,UAgBA;EAdA,KAAA,EAAO,eAAA,EAgBP;EAdA,QAAA;IACE,MAAA;IACA,GAAA;IACA,SAAA;EAAA,GAqCQ;EAlCV,MAAA,EAAQ,MAAA,SAAe,mBAAA;EAEvB,KAAA,WAiCM;EA/BN,QAAA,GAAW,cAAA;EACX,SAAA;EACA,OAAA;EACA,QAAA;EACA,KAAA,EAAO,KAAA;EA2BP;;;;;EArBA,WAAA,GAAc,UAAA;AAAA;;;;;AA6BK;AA4BrB;;;;;;;;;;;;KArCY,kBAAA,GAAqB,UAAA;EAC/B,IAAA,EAAM,sBAAA;EACN,MAAA,EAAQ,wBAAA;EACR,SAAA;EACA,SAAA,UAqCQ;EAnCR,SAAA;EACA,OAAA;EAEA,KAAA,EAAO,YAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BG,kBAAA,sBAAwC,aAAA,CAAc,OAAA;EAChE,SAAA;EACA,SAAA;EACA,UAAA,GAAa,gBAAA;EACb,MAAA,EAAQ,kBAAA;AAAA"}
@@ -1,13 +1,22 @@
1
1
  import { AIError } from "../../errors/ai-error.mjs";
2
2
  import { Usage } from "./usage.type.mjs";
3
3
  import { AgentResult } from "./agent-result.type.mjs";
4
- import { WorkflowResult } from "./workflow-result.type.mjs";
5
4
  import { SupervisorResult } from "./supervisor-result.type.mjs";
5
+ import { WorkflowResult } from "./workflow-result.type.mjs";
6
6
 
7
7
  //#region ../@warlock.js/ai/src/contracts/result/session-send-result.type.d.ts
8
8
  /**
9
- * Result returned by SessionContract.send().
10
- * Narrows executionResult by checking the `type` discriminant.
9
+ * Result returned by `SessionContract.send()`.
10
+ * Narrows `executionResult` by checking the `type` discriminant.
11
+ *
12
+ * @deprecated Obsolete v2 forward-declaration. The locked v1
13
+ * orchestrator's per-turn result is `OrchestratorResult<TOutput>` — see
14
+ * `./orchestrator-result.type`. It extends the unified
15
+ * {@link ExecuteResult} envelope (`data` / `error` / `usage` / `report`)
16
+ * and adds `sessionId` / `turnIndex` / optional `compaction`, narrowing
17
+ * via `report.type` / `report.status` rather than the `response` /
18
+ * `done` / `executionResult` fields here. Retained unchanged for one
19
+ * minor for non-breaking compatibility; do not use in new code.
11
20
  *
12
21
  * @example
13
22
  * const result = await session.send("Analyze this dataset");
@@ -1 +1 @@
1
- {"version":3,"file":"session-send-result.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/session-send-result.type.ts"],"mappings":";;;;;;;;;AAkBA;;;;;;;;;;KAAY,iBAAA;EAIV,iDAFA,QAAA,UAIQ;EAFR,IAAA,WAKI;EAHJ,KAAA,GAAQ,OAAA,EAKJ;EAHJ,eAAA,EACI,WAAA,YACA,gBAAA,YACA,cAAA,WAEG;EAAP,KAAA,EAAO,KAAA;AAAA"}
1
+ {"version":3,"file":"session-send-result.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/session-send-result.type.ts"],"mappings":";;;;;;;;;AA2BA;;;;;;;;;;;;;;;;;;;KAAY,iBAAA;EAaE,iDAXZ,QAAA;EAEA,IAAA;EAEA,KAAA,GAAQ,OAAA;EAER,eAAA,EACI,WAAA,YACA,gBAAA,YACA,cAAA;EAEJ,KAAA,EAAO,KAAA;AAAA"}
@@ -1,7 +1,7 @@
1
1
  import { BaseResult } from "./base-result.type.mjs";
2
2
  import { BaseReport } from "./base-report.type.mjs";
3
- import { AckSnapshot, IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
4
3
  import { ClassifierSnapshot } from "../supervisor/classifier-context.type.mjs";
4
+ import { AckSnapshot, IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
5
5
 
6
6
  //#region ../@warlock.js/ai/src/contracts/result/supervisor-result.type.d.ts
7
7
  /**
@@ -31,6 +31,30 @@ type Usage = {
31
31
  * providers that don't report cache hits leave this undefined.
32
32
  */
33
33
  cachedTokens?: number;
34
+ /**
35
+ * Subset of `output` the provider attributes to internal reasoning /
36
+ * thinking before the visible answer (OpenAI reasoning models'
37
+ * `completion_tokens_details.reasoning_tokens`, Anthropic
38
+ * extended-thinking tokens). Counted within `output` for billing
39
+ * unless the provider prices it separately (see
40
+ * `ModelPricing.reasoning`). Optional — undefined when the provider
41
+ * doesn't report a reasoning channel.
42
+ *
43
+ * @example
44
+ * const usage: Usage = { input: 150, output: 320, total: 470, reasoningTokens: 180 };
45
+ */
46
+ reasoningTokens?: number;
47
+ /**
48
+ * Number of input tokens WRITTEN to the provider's prompt cache on
49
+ * this call (Anthropic `cache_creation_input_tokens`). Distinct from
50
+ * `cachedTokens`, which counts read hits. Bills at
51
+ * `ModelPricing.cachedOutput` when set. Optional — undefined for
52
+ * providers/calls with no cache write.
53
+ *
54
+ * @example
55
+ * const usage: Usage = { input: 150, output: 320, total: 470, cacheWriteTokens: 64 };
56
+ */
57
+ cacheWriteTokens?: number;
34
58
  /**
35
59
  * Cost breakdown in USD, computed at emit time from `tokens × pricing[model]`
36
60
  * when the model adapter declared a `ModelPricing`. Same shape as
@@ -1 +1 @@
1
- {"version":3,"file":"usage.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/usage.type.ts"],"mappings":";;;;;AAsBA;;;;;;;;;;;AAgCqB;;;;;;;KAhCT,KAAA;wEAEV,KAAA;EAEA,MAAA;EAEA,KAAA;;;;;;EAMA,YAAA;;;;;;;;;;;;;;;;;;;;EAoBA,IAAA,GAAO,YAAY;AAAA"}
1
+ {"version":3,"file":"usage.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/result/usage.type.ts"],"mappings":";;;;;AAsBA;;;;;;;;;;;;;AAwDqB;;;;;KAxDT,KAAA;wEAEV,KAAA;EAEA,MAAA;EAEA,KAAA;;;;;;EAMA,YAAA;;;;;;;;;;;;;EAaA,eAAA;;;;;;;;;;;EAWA,gBAAA;;;;;;;;;;;;;;;;;;;;EAoBA,IAAA,GAAO,YAAY;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ModelPricing } from "./result/model-pricing.type.mjs";
2
- import { EmbedderConfig, EmbedderContract } from "./embedder.contract.mjs";
3
2
  import { ModelContract } from "./model.contract.mjs";
3
+ import { EmbedderConfig, EmbedderContract } from "./embedder.contract.mjs";
4
4
 
5
5
  //#region ../@warlock.js/ai/src/contracts/sdk-adapter.contract.d.ts
6
6
  /**
@@ -2,14 +2,14 @@ import { Message } from "../conversation-message.type.mjs";
2
2
  import { AgentResult } from "../result/agent-result.type.mjs";
3
3
  import { StreamContract } from "../stream/stream.contract.mjs";
4
4
  import { AgentContract } from "../agent/agent.contract.mjs";
5
+ import { SupervisorResult } from "../result/supervisor-result.type.mjs";
5
6
  import { WorkflowResult } from "../result/workflow-result.type.mjs";
6
7
  import { WorkflowInstance, WorkflowRunOptions } from "../workflow/workflow.contract.mjs";
7
- import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
8
- import { SupervisorIntentValue } from "./intent-entry.type.mjs";
9
8
  import { SupervisorExecuteOptions } from "./supervisor-execute-options.type.mjs";
9
+ import { SupervisorIntentValue } from "./intent-entry.type.mjs";
10
10
  import { SupervisorContract } from "./supervisor.contract.mjs";
11
11
  import { ClassifierSnapshot } from "./classifier-context.type.mjs";
12
- import { SupervisorResult } from "../result/supervisor-result.type.mjs";
12
+ import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
13
13
  import { AgentExecuteOptions } from "../agent/agent-options.type.mjs";
14
14
 
15
15
  //#region ../@warlock.js/ai/src/contracts/supervisor/dispatch-context.type.d.ts
@@ -1,9 +1,9 @@
1
1
  import { Message } from "../conversation-message.type.mjs";
2
2
  import { AIError } from "../../errors/ai-error.mjs";
3
3
  import { Usage } from "../result/usage.type.mjs";
4
- import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
5
4
  import { SupervisorInput } from "./supervisor-input.type.mjs";
6
5
  import { ClassifierSnapshot } from "./classifier-context.type.mjs";
6
+ import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
7
7
 
8
8
  //#region ../@warlock.js/ai/src/contracts/supervisor/evaluate-context.type.d.ts
9
9
  /**
@@ -1,16 +1,16 @@
1
1
  import { END, EndSentinel } from "../end.type.mjs";
2
- import { Next } from "./next.type.mjs";
3
- import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./iteration-snapshot.type.mjs";
4
2
  import { SupervisorInput } from "./supervisor-input.type.mjs";
5
- import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./evaluate-context.type.mjs";
3
+ import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./supervisor-snapshot.type.mjs";
4
+ import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor-execute-options.type.mjs";
6
5
  import { RouteContext } from "./route-context.type.mjs";
7
6
  import { AckCallback, AckConfig, AckEntry, AckRunEntry } from "./ack-entry.type.mjs";
8
7
  import { DispatchRawResult, IntentCallback, IntentEntry, IntentRunEntry, SupervisorIntentValue } from "./intent-entry.type.mjs";
8
+ import { Next } from "./next.type.mjs";
9
9
  import { RouterEntry } from "./router-entry.type.mjs";
10
10
  import { SupervisorConfig, SupervisorEventHandler, SupervisorEventHandlers } from "./supervisor-config.type.mjs";
11
- import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor-execute-options.type.mjs";
12
11
  import { SupervisorStreamEvent } from "./supervisor-stream-event.type.mjs";
13
12
  import { SupervisorAsToolOptions, SupervisorContract } from "./supervisor.contract.mjs";
14
13
  import { DispatchContext, IntentRunner, IntentRunnerMap } from "./dispatch-context.type.mjs";
15
14
  import { ClassifierAgentEntry, ClassifierCallback, ClassifierConfig, ClassifierContext, ClassifierOutput, ClassifierRefineContext, ClassifierRefineResult, ClassifierRunEntry, ClassifierSnapshot } from "./classifier-context.type.mjs";
16
- import { SupervisorSnapshot, SupervisorSnapshotStatus } from "./supervisor-snapshot.type.mjs";
15
+ import { EvaluateBranchResult, EvaluateContext, EvaluateResult } from "./evaluate-context.type.mjs";
16
+ import { AckSnapshot, AgentBranchSnapshot, DecisionSource, IterationDecision, IterationSnapshot } from "./iteration-snapshot.type.mjs";
@@ -1,8 +1,8 @@
1
1
  import { Message } from "../conversation-message.type.mjs";
2
- import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
3
2
  import { SupervisorInput } from "./supervisor-input.type.mjs";
4
- import { EvaluateResult } from "./evaluate-context.type.mjs";
5
3
  import { ClassifierSnapshot } from "./classifier-context.type.mjs";
4
+ import { EvaluateResult } from "./evaluate-context.type.mjs";
5
+ import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
6
6
 
7
7
  //#region ../@warlock.js/ai/src/contracts/supervisor/route-context.type.d.ts
8
8
  /**
@@ -1,16 +1,18 @@
1
1
  import { Message } from "../conversation-message.type.mjs";
2
2
  import { AgentContract } from "../agent/agent.contract.mjs";
3
+ import { SupervisorInput } from "./supervisor-input.type.mjs";
4
+ import { SnapshotStore } from "../orchestrator/snapshot-store.contract.mjs";
5
+ import { AgentMiddleware } from "../middleware/middleware.contract.mjs";
3
6
  import { SystemPromptContract } from "../system-prompt.contract.mjs";
4
- import { Next } from "./next.type.mjs";
5
- import { EvaluateContext, EvaluateResult } from "./evaluate-context.type.mjs";
6
7
  import { RouteContext } from "./route-context.type.mjs";
7
8
  import { AckConfig } from "./ack-entry.type.mjs";
8
9
  import { SupervisorIntentValue } from "./intent-entry.type.mjs";
10
+ import { Next } from "./next.type.mjs";
9
11
  import { RouterEntry } from "./router-entry.type.mjs";
10
12
  import { ClassifierConfig } from "./classifier-context.type.mjs";
13
+ import { EvaluateContext, EvaluateResult } from "./evaluate-context.type.mjs";
11
14
  import { SupervisorEventMap } from "../events/event-map.type.mjs";
12
15
  import { StandardSchemaV1 } from "@standard-schema/spec";
13
- import { CacheDriver } from "@warlock.js/cache";
14
16
 
15
17
  //#region ../@warlock.js/ai/src/contracts/supervisor/supervisor-config.type.d.ts
16
18
  /**
@@ -54,7 +56,7 @@ type SupervisorEventHandlers = Partial<{ [K in keyof SupervisorEventMap]: Superv
54
56
  * ctx.state.response ? { satisfied: true } : undefined,
55
57
  * maxIterations: 6,
56
58
  * output: v.object({ response: v.string(), refund: v.boolean() }),
57
- * snapshotStore: cache.driver("redis", { client }),
59
+ * snapshotStore: ai.snapshot.redis({ client }),
58
60
  * });
59
61
  */
60
62
  type SupervisorConfig<TOutput = unknown, TState = TOutput, TIntents extends Record<string, SupervisorIntentValue> = Record<string, SupervisorIntentValue>, TArtifacts = Record<string, unknown>> = {
@@ -68,6 +70,18 @@ type SupervisorConfig<TOutput = unknown, TState = TOutput, TIntents extends Reco
68
70
  * independent.
69
71
  */
70
72
  version?: string;
73
+ /**
74
+ * Opt-in Standard Schema describing this supervisor's input. Purely
75
+ * additive — when set, the supervisor can be dropped straight into an
76
+ * agent's `tools: []` array WITHOUT calling `.asTool()`: the runtime
77
+ * derives the LLM tool manifest from `name` + the resolved
78
+ * description + this schema and dispatches through `execute()`. Omit
79
+ * it and `.asTool()` (which takes its own `inputSchema`) remains the
80
+ * way to expose the supervisor as a tool. Not enforced by the
81
+ * supervisor runtime itself — `execute()` still accepts the raw
82
+ * `SupervisorInput` union.
83
+ */
84
+ inputSchema?: StandardSchemaV1<SupervisorInput>;
71
85
  /**
72
86
  * Prepended to the router agent's own system prompt (router mode
73
87
  * only). Does not touch child agents' system prompts — they stay
@@ -205,17 +219,18 @@ type SupervisorConfig<TOutput = unknown, TState = TOutput, TIntents extends Reco
205
219
  */
206
220
  output?: StandardSchemaV1<TOutput>;
207
221
  /**
208
- * Optional durable store enabling `supervisor.resume(runId)`.
209
- * Snapshots are written after every iteration settles plus once
210
- * more at final completion / cancel / fail. Accepts any
211
- * `@warlock.js/cache` driver `MemoryCacheDriver` for dev/tests,
212
- * `RedisCacheDriver` / `PgCacheDriver` for production.
213
- *
214
- * Falls back to `ai.config({ defaultStore })` when omitted. When
215
- * neither is set, `resume()` throws and snapshot writes silently
222
+ * Optional durable {@link SnapshotStore} enabling
223
+ * `supervisor.resume(runId)`. Snapshots are written after every
224
+ * iteration settles plus once more at final completion / cancel /
225
+ * fail. Construct with `ai.snapshot.{memory,pg,redis}()`
226
+ * `ai.snapshot.memory()` for dev/tests, `ai.snapshot.redis()` /
227
+ * `ai.snapshot.pg()` for production.
228
+ *
229
+ * Falls back to `ai.config({ defaultSnapshotStore })` when omitted.
230
+ * When neither is set, `resume()` throws and snapshot writes silently
216
231
  * skip (current behavior preserved).
217
232
  */
218
- snapshotStore?: CacheDriver<any, any>;
233
+ snapshotStore?: SnapshotStore;
219
234
  /**
220
235
  * Definition-level event handlers — tier 1 of the 3-tier model.
221
236
  * Fire on every run of this supervisor, before instance and
@@ -327,6 +342,33 @@ type SupervisorConfig<TOutput = unknown, TState = TOutput, TIntents extends Reco
327
342
  * }),
328
343
  */
329
344
  artifactsSchema?: StandardSchemaV1<TArtifacts>;
345
+ /**
346
+ * Supervisor-level middleware — fires the optional `supervisor` hook
347
+ * map (`before` / `after` / `onError`) of each `AgentMiddleware`
348
+ * once around the entire `execute()` / `stream()` / `resume()` run,
349
+ * the supervisor-level peer of an agent's `execute`-level middleware.
350
+ *
351
+ * Same onion semantics as the agent pipeline: `before` runs top-down
352
+ * (return a `SupervisorResult` to short-circuit the whole run, throw
353
+ * to abort it), `after` / `onError` run bottom-up (return a
354
+ * `SupervisorResult` to replace / recover). A middleware without a
355
+ * `supervisor` hook map is skipped — so the same builtin objects
356
+ * (budget, guardrail, …) can be registered here and on agents,
357
+ * declaring whichever level applies.
358
+ *
359
+ * Each middleware needs a unique `name` (the `ctx.state` namespace);
360
+ * the supervisor does not re-validate the array — register the same
361
+ * objects you validated for the agents.
362
+ *
363
+ * @example
364
+ * ai.supervisor({
365
+ * name: "support",
366
+ * router,
367
+ * intents: { ... },
368
+ * middleware: [auditTrail],
369
+ * });
370
+ */
371
+ middleware?: AgentMiddleware[];
330
372
  /**
331
373
  * Per-iteration merger for the artifacts bag (Phase 5 /
332
374
  * decisions §35). When omitted the framework auto-spreads:
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor-config.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;AAkBA;;KAAY,sBAAA,iBAAuC,kBAAA,KACjD,OAAA,EAAS,kBAAA,CAAmB,CAAA;AAAA,KAGlB,uBAAA,GAA0B,OAAA,eACxB,kBAAA,GAAqB,sBAAA,CAAuB,CAAA;;;;;;;;;AAJ1B;AAGhC;;;;;;;;;;;;;;;AAC2D;AAyC3D;;;;;;;;;;;;;KAAY,gBAAA,6BAED,OAAA,mBACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAAe,qBAAA,gBAC3D,MAAA;EA0FqB,sEAvFlC,IAAA;EA6Fc;;;;;;;;EAnFd,OAAA;EA0G8D;;;;;EAnG9D,YAAA,GAAe,oBAAA;EAkLC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA3IhB,IAAA,YAAgB,oBAAA;EAqC8B;;;;;;;;;;;;;;;;;;;EAhB9C,OAAA,GAAU,OAAA;EAoGV;;;;;;;;EA1FA,MAAA,GAAS,aAAA,YAAyB,WAAA,CAAY,MAAA;EA2K5C;;;;EArKF,KAAA,IAAS,GAAA,EAAK,YAAA,CAAa,MAAA,MAAY,IAAA,GAAO,OAAA,CAAQ,IAAA;EAgMnB;;;;;;;;AAwBiC;;EA5MpE,OAAA,EAAS,QAAA;;;;;;;;;;EAWT,QAAA,IAAY,GAAA,EAAK,eAAA,CAAgB,MAAA,MAAY,cAAA,GAAiB,OAAA,CAAQ,cAAA;;;;;;;;;;;;;;;;EAiBtE,KAAA,GAAQ,MAAA;;;;;EAMR,aAAA;;;;;EAMA,YAAA;;;;;;;;;;;EAYA,MAAA,GAAS,gBAAA,CAAiB,OAAA;;;;;;;;;;;;EAa1B,aAAA,GAAgB,WAAA;;;;;;EAOhB,EAAA,GAAK,uBAAA;;;;;;;;;;;;;;;;;EAkBL,GAAA,GAAM,SAAA,CAAU,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwChB,UAAA,GAAa,gBAAA,CAAiB,MAAA;;;;;;;;;;;;;;;;;;;;;;EAsB9B,aAAA;IACE,MAAA;IACA,MAAA;IACA,GAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;EAyBF,eAAA,GAAkB,gBAAA,CAAiB,UAAA;;;;;;;;;;;;;;;;;;;;;;;EAwBnC,iBAAA,IAAqB,KAAA,EAAO,MAAA,EAAQ,SAAA,EAAW,UAAA,KAAe,MAAA;AAAA"}
1
+ {"version":3,"file":"supervisor-config.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/contracts/supervisor/supervisor-config.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA;;KAAY,sBAAA,iBAAuC,kBAAA,KACjD,OAAA,EAAS,kBAAA,CAAmB,CAAA;AAAA,KAGlB,uBAAA,GAA0B,OAAA,eACxB,kBAAA,GAAqB,sBAAA,CAAuB,CAAA;;;;;;;;;AAJ1B;AAGhC;;;;;;;;;;;;;;;AAC2D;AAyC3D;;;;;;;;;;;;;KAAY,gBAAA,6BAED,OAAA,mBACQ,MAAA,SAAe,qBAAA,IAAyB,MAAA,SAAe,qBAAA,gBAC3D,MAAA;EAuGJ,sEApGT,IAAA;EAoGkC;;;;;;;;EA1FlC,OAAA;EAuH6C;;;;;;;;;;;EA1G7C,WAAA,GAAc,gBAAA,CAAiB,eAAA;EAoRI;;;;;EA7QnC,YAAA,GAAe,oBAAA;EAiUqD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA1RpE,IAAA,YAAgB,oBAAA;EA4DiB;;;;;;;;;;;;;;;;;;;EAvCjC,OAAA,GAAU,OAAA;EA+JG;;;;;;;;EArJb,MAAA,GAAS,aAAA,YAAyB,WAAA,CAAY,MAAA;EAmO9C;;;;EA7NA,KAAA,IAAS,GAAA,EAAK,YAAA,CAAa,MAAA,MAAY,IAAA,GAAO,OAAA,CAAQ,IAAA;EAqPP;;;;AAAqB;;;;;;EAzOpE,OAAA,EAAS,QAAA;;;;;;;;;;EAWT,QAAA,IAAY,GAAA,EAAK,eAAA,CAAgB,MAAA,MAAY,cAAA,GAAiB,OAAA,CAAQ,cAAA;;;;;;;;;;;;;;;;EAiBtE,KAAA,GAAQ,MAAA;;;;;EAMR,aAAA;;;;;EAMA,YAAA;;;;;;;;;;;EAYA,MAAA,GAAS,gBAAA,CAAiB,OAAA;;;;;;;;;;;;;EAc1B,aAAA,GAAgB,aAAA;;;;;;EAOhB,EAAA,GAAK,uBAAA;;;;;;;;;;;;;;;;;EAkBL,GAAA,GAAM,SAAA,CAAU,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwChB,UAAA,GAAa,gBAAA,CAAiB,MAAA;;;;;;;;;;;;;;;;;;;;;;EAsB9B,aAAA;IACE,MAAA;IACA,MAAA;IACA,GAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;EAyBF,eAAA,GAAkB,gBAAA,CAAiB,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BnC,UAAA,GAAa,eAAA;;;;;;;;;;;;;;;;;;;;;;;EAwBb,iBAAA,IAAqB,KAAA,EAAO,MAAA,EAAQ,SAAA,EAAW,UAAA,KAAe,MAAA;AAAA"}
@@ -1,5 +1,5 @@
1
- import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
2
1
  import { SupervisorInput } from "./supervisor-input.type.mjs";
2
+ import { IterationSnapshot } from "./iteration-snapshot.type.mjs";
3
3
 
4
4
  //#region ../@warlock.js/ai/src/contracts/supervisor/supervisor-snapshot.type.d.ts
5
5
  /**
@@ -1,11 +1,11 @@
1
1
  import { ExecutableContract } from "../executable.contract.mjs";
2
2
  import { StreamContract } from "../stream/stream.contract.mjs";
3
+ import { SupervisorResult } from "../result/supervisor-result.type.mjs";
3
4
  import { ToolContract } from "../../tool/tool.mjs";
4
5
  import { SupervisorInput } from "./supervisor-input.type.mjs";
5
- import { SupervisorEventHandler } from "./supervisor-config.type.mjs";
6
6
  import { SupervisorExecuteOptions, SupervisorResumeOptions } from "./supervisor-execute-options.type.mjs";
7
+ import { SupervisorEventHandler } from "./supervisor-config.type.mjs";
7
8
  import { SupervisorStreamEvent } from "./supervisor-stream-event.type.mjs";
8
- import { SupervisorResult } from "../result/supervisor-result.type.mjs";
9
9
  import { SupervisorEventMap } from "../events/event-map.type.mjs";
10
10
  import { StandardSchemaV1 } from "@standard-schema/spec";
11
11
 
@@ -68,6 +68,13 @@ type SupervisorAsToolOptions<TToolInput> = {
68
68
  interface SupervisorContract<TOutput = unknown> extends ExecutableContract<SupervisorInput, SupervisorExecuteOptions, SupervisorResult<TOutput>> {
69
69
  /** Stable identifier — mirrors the config's `name`. */
70
70
  readonly name: string;
71
+ /**
72
+ * Mirrors {@link SupervisorConfig.inputSchema} when set — lets the
73
+ * agent tool-collection path auto-adapt this supervisor into a
74
+ * `ToolContract` (manifest derived from name + this schema) when it
75
+ * appears in `tools: []` without `.asTool()`.
76
+ */
77
+ readonly inputSchema?: StandardSchemaV1<SupervisorInput>;
71
78
  /**
72
79
  * Structural fingerprint of the supervisor definition — agent
73
80
  * keys + their resolved descriptions + router identity (if set) +