@warlock.js/core 4.8.0 → 4.8.1

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 (769) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/esm/connectors/ai-connector.mjs +1 -1
  3. package/package.json +12 -9
  4. package/esm/ai/src/agent/agent-input-builder.mjs +0 -133
  5. package/esm/ai/src/agent/agent-input-builder.mjs.map +0 -1
  6. package/esm/ai/src/agent/agent-log-event.mjs +0 -101
  7. package/esm/ai/src/agent/agent-log-event.mjs.map +0 -1
  8. package/esm/ai/src/agent/agent-stream.mjs +0 -82
  9. package/esm/ai/src/agent/agent-stream.mjs.map +0 -1
  10. package/esm/ai/src/agent/agent-to-stream-event.mjs +0 -86
  11. package/esm/ai/src/agent/agent-to-stream-event.mjs.map +0 -1
  12. package/esm/ai/src/agent/agent.mjs +0 -1276
  13. package/esm/ai/src/agent/agent.mjs.map +0 -1
  14. package/esm/ai/src/agent/index.mjs +0 -5
  15. package/esm/ai/src/agent/json-stream-guard.mjs +0 -400
  16. package/esm/ai/src/agent/json-stream-guard.mjs.map +0 -1
  17. package/esm/ai/src/agent/signature.mjs +0 -57
  18. package/esm/ai/src/agent/signature.mjs.map +0 -1
  19. package/esm/ai/src/agent/snapshot.mjs +0 -101
  20. package/esm/ai/src/agent/snapshot.mjs.map +0 -1
  21. package/esm/ai/src/agent/spawn-sub-agent.mjs +0 -68
  22. package/esm/ai/src/agent/spawn-sub-agent.mjs.map +0 -1
  23. package/esm/ai/src/ai.mjs +0 -191
  24. package/esm/ai/src/ai.mjs.map +0 -1
  25. package/esm/ai/src/batch/batch.mjs +0 -198
  26. package/esm/ai/src/batch/batch.mjs.map +0 -1
  27. package/esm/ai/src/batch/index.mjs +0 -3
  28. package/esm/ai/src/batch/run-batch-item.mjs +0 -100
  29. package/esm/ai/src/batch/run-batch-item.mjs.map +0 -1
  30. package/esm/ai/src/batch/run-with-concurrency.mjs +0 -39
  31. package/esm/ai/src/batch/run-with-concurrency.mjs.map +0 -1
  32. package/esm/ai/src/checkpoint/memory.mjs +0 -0
  33. package/esm/ai/src/checkpoint/memory.mjs.map +0 -1
  34. package/esm/ai/src/checkpoint/pg.mjs +0 -265
  35. package/esm/ai/src/checkpoint/pg.mjs.map +0 -1
  36. package/esm/ai/src/checkpoint/redis.mjs +0 -200
  37. package/esm/ai/src/checkpoint/redis.mjs.map +0 -1
  38. package/esm/ai/src/config.mjs +0 -59
  39. package/esm/ai/src/config.mjs.map +0 -1
  40. package/esm/ai/src/contracts/end.type.mjs +0 -47
  41. package/esm/ai/src/contracts/end.type.mjs.map +0 -1
  42. package/esm/ai/src/errors/agent-cancelled-error.mjs +0 -43
  43. package/esm/ai/src/errors/agent-cancelled-error.mjs.map +0 -1
  44. package/esm/ai/src/errors/agent-drift-error.mjs +0 -31
  45. package/esm/ai/src/errors/agent-drift-error.mjs.map +0 -1
  46. package/esm/ai/src/errors/agent-execution-error.mjs +0 -35
  47. package/esm/ai/src/errors/agent-execution-error.mjs.map +0 -1
  48. package/esm/ai/src/errors/agent-max-trips-error.mjs +0 -41
  49. package/esm/ai/src/errors/agent-max-trips-error.mjs.map +0 -1
  50. package/esm/ai/src/errors/ai-error.mjs +0 -68
  51. package/esm/ai/src/errors/ai-error.mjs.map +0 -1
  52. package/esm/ai/src/errors/budget-exceeded-error.mjs +0 -31
  53. package/esm/ai/src/errors/budget-exceeded-error.mjs.map +0 -1
  54. package/esm/ai/src/errors/content-filter-error.mjs +0 -28
  55. package/esm/ai/src/errors/content-filter-error.mjs.map +0 -1
  56. package/esm/ai/src/errors/context-length-exceeded-error.mjs +0 -31
  57. package/esm/ai/src/errors/context-length-exceeded-error.mjs.map +0 -1
  58. package/esm/ai/src/errors/guardrail-violation-error.mjs +0 -41
  59. package/esm/ai/src/errors/guardrail-violation-error.mjs.map +0 -1
  60. package/esm/ai/src/errors/index.mjs +0 -40
  61. package/esm/ai/src/errors/invalid-request-error.mjs +0 -31
  62. package/esm/ai/src/errors/invalid-request-error.mjs.map +0 -1
  63. package/esm/ai/src/errors/max-iterations-error.mjs +0 -32
  64. package/esm/ai/src/errors/max-iterations-error.mjs.map +0 -1
  65. package/esm/ai/src/errors/max-steps-exceeded-error.mjs +0 -21
  66. package/esm/ai/src/errors/max-steps-exceeded-error.mjs.map +0 -1
  67. package/esm/ai/src/errors/orchestrator-cancelled-error.mjs +0 -31
  68. package/esm/ai/src/errors/orchestrator-cancelled-error.mjs.map +0 -1
  69. package/esm/ai/src/errors/orchestrator-config-error.mjs +0 -30
  70. package/esm/ai/src/errors/orchestrator-config-error.mjs.map +0 -1
  71. package/esm/ai/src/errors/orchestrator-drift-error.mjs +0 -37
  72. package/esm/ai/src/errors/orchestrator-drift-error.mjs.map +0 -1
  73. package/esm/ai/src/errors/orchestrator-failed-error.mjs +0 -36
  74. package/esm/ai/src/errors/orchestrator-failed-error.mjs.map +0 -1
  75. package/esm/ai/src/errors/outbound-policy-error.mjs +0 -32
  76. package/esm/ai/src/errors/outbound-policy-error.mjs.map +0 -1
  77. package/esm/ai/src/errors/planner-cancelled-error.mjs +0 -29
  78. package/esm/ai/src/errors/planner-cancelled-error.mjs.map +0 -1
  79. package/esm/ai/src/errors/planner-drift-error.mjs +0 -33
  80. package/esm/ai/src/errors/planner-drift-error.mjs.map +0 -1
  81. package/esm/ai/src/errors/planner-failed-error.mjs +0 -37
  82. package/esm/ai/src/errors/planner-failed-error.mjs.map +0 -1
  83. package/esm/ai/src/errors/planner-plan-invalid-error.mjs +0 -25
  84. package/esm/ai/src/errors/planner-plan-invalid-error.mjs.map +0 -1
  85. package/esm/ai/src/errors/prompt-refinement-error.mjs +0 -27
  86. package/esm/ai/src/errors/prompt-refinement-error.mjs.map +0 -1
  87. package/esm/ai/src/errors/provider-auth-error.mjs +0 -26
  88. package/esm/ai/src/errors/provider-auth-error.mjs.map +0 -1
  89. package/esm/ai/src/errors/provider-error.mjs +0 -42
  90. package/esm/ai/src/errors/provider-error.mjs.map +0 -1
  91. package/esm/ai/src/errors/provider-rate-limit-error.mjs +0 -31
  92. package/esm/ai/src/errors/provider-rate-limit-error.mjs.map +0 -1
  93. package/esm/ai/src/errors/provider-timeout-error.mjs +0 -26
  94. package/esm/ai/src/errors/provider-timeout-error.mjs.map +0 -1
  95. package/esm/ai/src/errors/quota-exceeded-error.mjs +0 -40
  96. package/esm/ai/src/errors/quota-exceeded-error.mjs.map +0 -1
  97. package/esm/ai/src/errors/routing-error.mjs +0 -23
  98. package/esm/ai/src/errors/routing-error.mjs.map +0 -1
  99. package/esm/ai/src/errors/schema-validation-error.mjs +0 -37
  100. package/esm/ai/src/errors/schema-validation-error.mjs.map +0 -1
  101. package/esm/ai/src/errors/step-failed-error.mjs +0 -19
  102. package/esm/ai/src/errors/step-failed-error.mjs.map +0 -1
  103. package/esm/ai/src/errors/supervisor-cancelled-error.mjs +0 -29
  104. package/esm/ai/src/errors/supervisor-cancelled-error.mjs.map +0 -1
  105. package/esm/ai/src/errors/supervisor-drift-error.mjs +0 -30
  106. package/esm/ai/src/errors/supervisor-drift-error.mjs.map +0 -1
  107. package/esm/ai/src/errors/supervisor-failed-error.mjs +0 -43
  108. package/esm/ai/src/errors/supervisor-failed-error.mjs.map +0 -1
  109. package/esm/ai/src/errors/supervisor-routing-error.mjs +0 -39
  110. package/esm/ai/src/errors/supervisor-routing-error.mjs.map +0 -1
  111. package/esm/ai/src/errors/tool-execution-error.mjs +0 -32
  112. package/esm/ai/src/errors/tool-execution-error.mjs.map +0 -1
  113. package/esm/ai/src/errors/workflow-cancelled-error.mjs +0 -23
  114. package/esm/ai/src/errors/workflow-cancelled-error.mjs.map +0 -1
  115. package/esm/ai/src/errors/workflow-drift-error.mjs +0 -24
  116. package/esm/ai/src/errors/workflow-drift-error.mjs.map +0 -1
  117. package/esm/ai/src/errors/workflow-error.mjs +0 -18
  118. package/esm/ai/src/errors/workflow-error.mjs.map +0 -1
  119. package/esm/ai/src/eval/dataset.mjs +0 -112
  120. package/esm/ai/src/eval/dataset.mjs.map +0 -1
  121. package/esm/ai/src/eval/eval-runner.mjs +0 -135
  122. package/esm/ai/src/eval/eval-runner.mjs.map +0 -1
  123. package/esm/ai/src/eval/index.mjs +0 -48
  124. package/esm/ai/src/eval/index.mjs.map +0 -1
  125. package/esm/ai/src/eval/judge-scorer.mjs +0 -87
  126. package/esm/ai/src/eval/judge-scorer.mjs.map +0 -1
  127. package/esm/ai/src/eval/regression.mjs +0 -51
  128. package/esm/ai/src/eval/regression.mjs.map +0 -1
  129. package/esm/ai/src/eval/report-json.mjs +0 -33
  130. package/esm/ai/src/eval/report-json.mjs.map +0 -1
  131. package/esm/ai/src/eval/report-junit.mjs +0 -60
  132. package/esm/ai/src/eval/report-junit.mjs.map +0 -1
  133. package/esm/ai/src/eval/scorers.mjs +0 -101
  134. package/esm/ai/src/eval/scorers.mjs.map +0 -1
  135. package/esm/ai/src/guard/detectors/index.mjs +0 -6
  136. package/esm/ai/src/guard/detectors/injection.mjs +0 -254
  137. package/esm/ai/src/guard/detectors/injection.mjs.map +0 -1
  138. package/esm/ai/src/guard/detectors/moderation.mjs +0 -134
  139. package/esm/ai/src/guard/detectors/moderation.mjs.map +0 -1
  140. package/esm/ai/src/guard/detectors/pii.mjs +0 -199
  141. package/esm/ai/src/guard/detectors/pii.mjs.map +0 -1
  142. package/esm/ai/src/guard/detectors/topic.mjs +0 -99
  143. package/esm/ai/src/guard/detectors/topic.mjs.map +0 -1
  144. package/esm/ai/src/guard/errors.mjs +0 -18
  145. package/esm/ai/src/guard/errors.mjs.map +0 -1
  146. package/esm/ai/src/guard/guard.mjs +0 -209
  147. package/esm/ai/src/guard/guard.mjs.map +0 -1
  148. package/esm/ai/src/guard/guardrail.mjs +0 -22
  149. package/esm/ai/src/guard/guardrail.mjs.map +0 -1
  150. package/esm/ai/src/human/errors.mjs +0 -60
  151. package/esm/ai/src/human/errors.mjs.map +0 -1
  152. package/esm/ai/src/human/human-approval.mjs +0 -170
  153. package/esm/ai/src/human/human-approval.mjs.map +0 -1
  154. package/esm/ai/src/human/policy.mjs +0 -67
  155. package/esm/ai/src/human/policy.mjs.map +0 -1
  156. package/esm/ai/src/human/register.mjs +0 -37
  157. package/esm/ai/src/human/register.mjs.map +0 -1
  158. package/esm/ai/src/human/resume-seed.mjs +0 -53
  159. package/esm/ai/src/human/resume-seed.mjs.map +0 -1
  160. package/esm/ai/src/human/resume.mjs +0 -121
  161. package/esm/ai/src/human/resume.mjs.map +0 -1
  162. package/esm/ai/src/human/stores/index.mjs +0 -5
  163. package/esm/ai/src/human/stores/memory.mjs +0 -91
  164. package/esm/ai/src/human/stores/memory.mjs.map +0 -1
  165. package/esm/ai/src/human/stores/pg.mjs +0 -220
  166. package/esm/ai/src/human/stores/pg.mjs.map +0 -1
  167. package/esm/ai/src/human/stores/redis.mjs +0 -201
  168. package/esm/ai/src/human/stores/redis.mjs.map +0 -1
  169. package/esm/ai/src/image/image-cost.mjs +0 -55
  170. package/esm/ai/src/image/image-cost.mjs.map +0 -1
  171. package/esm/ai/src/image/image.mjs +0 -112
  172. package/esm/ai/src/image/image.mjs.map +0 -1
  173. package/esm/ai/src/image/index.mjs +0 -4
  174. package/esm/ai/src/index.mjs +0 -196
  175. package/esm/ai/src/memory/derive-id.mjs +0 -24
  176. package/esm/ai/src/memory/derive-id.mjs.map +0 -1
  177. package/esm/ai/src/memory/episodic-memory.mjs +0 -106
  178. package/esm/ai/src/memory/episodic-memory.mjs.map +0 -1
  179. package/esm/ai/src/memory/memory.mjs +0 -166
  180. package/esm/ai/src/memory/memory.mjs.map +0 -1
  181. package/esm/ai/src/memory/procedural-memory.mjs +0 -103
  182. package/esm/ai/src/memory/procedural-memory.mjs.map +0 -1
  183. package/esm/ai/src/memory/semantic-memory.mjs +0 -80
  184. package/esm/ai/src/memory/semantic-memory.mjs.map +0 -1
  185. package/esm/ai/src/memory/working-memory.mjs +0 -62
  186. package/esm/ai/src/memory/working-memory.mjs.map +0 -1
  187. package/esm/ai/src/middleware/builtins/budget.mjs +0 -219
  188. package/esm/ai/src/middleware/builtins/budget.mjs.map +0 -1
  189. package/esm/ai/src/middleware/builtins/guardrail.mjs +0 -76
  190. package/esm/ai/src/middleware/builtins/guardrail.mjs.map +0 -1
  191. package/esm/ai/src/middleware/builtins/semantic-cache.mjs +0 -149
  192. package/esm/ai/src/middleware/builtins/semantic-cache.mjs.map +0 -1
  193. package/esm/ai/src/middleware/helpers/compose.mjs +0 -52
  194. package/esm/ai/src/middleware/helpers/compose.mjs.map +0 -1
  195. package/esm/ai/src/middleware/helpers/for-tool.mjs +0 -80
  196. package/esm/ai/src/middleware/helpers/for-tool.mjs.map +0 -1
  197. package/esm/ai/src/middleware/index.mjs +0 -10
  198. package/esm/ai/src/middleware/pipeline.mjs +0 -100
  199. package/esm/ai/src/middleware/pipeline.mjs.map +0 -1
  200. package/esm/ai/src/middleware/utils/extract-user-text.mjs +0 -47
  201. package/esm/ai/src/middleware/utils/extract-user-text.mjs.map +0 -1
  202. package/esm/ai/src/middleware/utils/namespaced-state.mjs +0 -60
  203. package/esm/ai/src/middleware/utils/namespaced-state.mjs.map +0 -1
  204. package/esm/ai/src/mock/index.mjs +0 -4
  205. package/esm/ai/src/mock/mock-agent.mjs +0 -3
  206. package/esm/ai/src/mock/mock-router.mjs +0 -58
  207. package/esm/ai/src/mock/mock-router.mjs.map +0 -1
  208. package/esm/ai/src/model/fallback-model.mjs +0 -218
  209. package/esm/ai/src/model/fallback-model.mjs.map +0 -1
  210. package/esm/ai/src/model/index.mjs +0 -3
  211. package/esm/ai/src/object-stream/index.mjs +0 -4
  212. package/esm/ai/src/object-stream/parse-partial-json.mjs +0 -78
  213. package/esm/ai/src/object-stream/parse-partial-json.mjs.map +0 -1
  214. package/esm/ai/src/object-stream/stream-object.mjs +0 -97
  215. package/esm/ai/src/object-stream/stream-object.mjs.map +0 -1
  216. package/esm/ai/src/observe/index.mjs +0 -4
  217. package/esm/ai/src/observe/observer-registry.mjs +0 -35
  218. package/esm/ai/src/observe/observer-registry.mjs.map +0 -1
  219. package/esm/ai/src/observe/resolve-observers.mjs +0 -73
  220. package/esm/ai/src/observe/resolve-observers.mjs.map +0 -1
  221. package/esm/ai/src/orchestrator/as-tool.mjs +0 -98
  222. package/esm/ai/src/orchestrator/as-tool.mjs.map +0 -1
  223. package/esm/ai/src/orchestrator/checkpoint.mjs +0 -75
  224. package/esm/ai/src/orchestrator/checkpoint.mjs.map +0 -1
  225. package/esm/ai/src/orchestrator/commands.mjs +0 -34
  226. package/esm/ai/src/orchestrator/commands.mjs.map +0 -1
  227. package/esm/ai/src/orchestrator/compaction.mjs +0 -206
  228. package/esm/ai/src/orchestrator/compaction.mjs.map +0 -1
  229. package/esm/ai/src/orchestrator/dispatch.mjs +0 -171
  230. package/esm/ai/src/orchestrator/dispatch.mjs.map +0 -1
  231. package/esm/ai/src/orchestrator/emitter.mjs +0 -85
  232. package/esm/ai/src/orchestrator/emitter.mjs.map +0 -1
  233. package/esm/ai/src/orchestrator/execution.mjs +0 -395
  234. package/esm/ai/src/orchestrator/execution.mjs.map +0 -1
  235. package/esm/ai/src/orchestrator/index.mjs +0 -11
  236. package/esm/ai/src/orchestrator/load.mjs +0 -49
  237. package/esm/ai/src/orchestrator/load.mjs.map +0 -1
  238. package/esm/ai/src/orchestrator/lock.mjs +0 -75
  239. package/esm/ai/src/orchestrator/lock.mjs.map +0 -1
  240. package/esm/ai/src/orchestrator/memory.mjs +0 -141
  241. package/esm/ai/src/orchestrator/memory.mjs.map +0 -1
  242. package/esm/ai/src/orchestrator/orchestrator-stream.mjs +0 -98
  243. package/esm/ai/src/orchestrator/orchestrator-stream.mjs.map +0 -1
  244. package/esm/ai/src/orchestrator/orchestrator.mjs +0 -206
  245. package/esm/ai/src/orchestrator/orchestrator.mjs.map +0 -1
  246. package/esm/ai/src/orchestrator/resume.mjs +0 -74
  247. package/esm/ai/src/orchestrator/resume.mjs.map +0 -1
  248. package/esm/ai/src/orchestrator/session-lock.mjs +0 -83
  249. package/esm/ai/src/orchestrator/session-lock.mjs.map +0 -1
  250. package/esm/ai/src/orchestrator/signature.mjs +0 -120
  251. package/esm/ai/src/orchestrator/signature.mjs.map +0 -1
  252. package/esm/ai/src/orchestrator/window.mjs +0 -56
  253. package/esm/ai/src/orchestrator/window.mjs.map +0 -1
  254. package/esm/ai/src/planner/dag-scheduler.mjs +0 -97
  255. package/esm/ai/src/planner/dag-scheduler.mjs.map +0 -1
  256. package/esm/ai/src/planner/index.mjs +0 -6
  257. package/esm/ai/src/planner/plan-prompt.mjs +0 -31
  258. package/esm/ai/src/planner/plan-prompt.mjs.map +0 -1
  259. package/esm/ai/src/planner/plan-schema.mjs +0 -120
  260. package/esm/ai/src/planner/plan-schema.mjs.map +0 -1
  261. package/esm/ai/src/planner/planner-run.mjs +0 -769
  262. package/esm/ai/src/planner/planner-run.mjs.map +0 -1
  263. package/esm/ai/src/planner/planner.mjs +0 -144
  264. package/esm/ai/src/planner/planner.mjs.map +0 -1
  265. package/esm/ai/src/planner/signature.mjs +0 -27
  266. package/esm/ai/src/planner/signature.mjs.map +0 -1
  267. package/esm/ai/src/planner/snapshot.mjs +0 -95
  268. package/esm/ai/src/planner/snapshot.mjs.map +0 -1
  269. package/esm/ai/src/prompt/errors.mjs +0 -73
  270. package/esm/ai/src/prompt/errors.mjs.map +0 -1
  271. package/esm/ai/src/prompt/index.mjs +0 -4
  272. package/esm/ai/src/prompt/prompt-langfuse-sync.mjs +0 -104
  273. package/esm/ai/src/prompt/prompt-langfuse-sync.mjs.map +0 -1
  274. package/esm/ai/src/prompt/prompt-validate.mjs +0 -170
  275. package/esm/ai/src/prompt/prompt-validate.mjs.map +0 -1
  276. package/esm/ai/src/prompt/prompt.mjs +0 -218
  277. package/esm/ai/src/prompt/prompt.mjs.map +0 -1
  278. package/esm/ai/src/prompts/index.mjs +0 -3
  279. package/esm/ai/src/prompts/prompts-manager.mjs +0 -410
  280. package/esm/ai/src/prompts/prompts-manager.mjs.map +0 -1
  281. package/esm/ai/src/prompts/prompts-validate.mjs +0 -0
  282. package/esm/ai/src/prompts/prompts-validate.mjs.map +0 -1
  283. package/esm/ai/src/rag/as-tool.mjs +0 -48
  284. package/esm/ai/src/rag/as-tool.mjs.map +0 -1
  285. package/esm/ai/src/rag/chunk/chunk.mjs +0 -44
  286. package/esm/ai/src/rag/chunk/chunk.mjs.map +0 -1
  287. package/esm/ai/src/rag/chunk/fixed.mjs +0 -32
  288. package/esm/ai/src/rag/chunk/fixed.mjs.map +0 -1
  289. package/esm/ai/src/rag/chunk/markdown.mjs +0 -75
  290. package/esm/ai/src/rag/chunk/markdown.mjs.map +0 -1
  291. package/esm/ai/src/rag/chunk/recursive.mjs +0 -132
  292. package/esm/ai/src/rag/chunk/recursive.mjs.map +0 -1
  293. package/esm/ai/src/rag/chunk/sentence.mjs +0 -73
  294. package/esm/ai/src/rag/chunk/sentence.mjs.map +0 -1
  295. package/esm/ai/src/rag/hybrid/bm25.mjs +0 -51
  296. package/esm/ai/src/rag/hybrid/bm25.mjs.map +0 -1
  297. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs +0 -29
  298. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs.map +0 -1
  299. package/esm/ai/src/rag/hybrid/rrf.mjs +0 -30
  300. package/esm/ai/src/rag/hybrid/rrf.mjs.map +0 -1
  301. package/esm/ai/src/rag/index.mjs +0 -18
  302. package/esm/ai/src/rag/loaders/errors.mjs +0 -25
  303. package/esm/ai/src/rag/loaders/errors.mjs.map +0 -1
  304. package/esm/ai/src/rag/loaders/index.mjs +0 -7
  305. package/esm/ai/src/rag/loaders/load-html.mjs +0 -138
  306. package/esm/ai/src/rag/loaders/load-html.mjs.map +0 -1
  307. package/esm/ai/src/rag/loaders/load-pdf.mjs +0 -150
  308. package/esm/ai/src/rag/loaders/load-pdf.mjs.map +0 -1
  309. package/esm/ai/src/rag/loaders/load-text.mjs +0 -60
  310. package/esm/ai/src/rag/loaders/load-text.mjs.map +0 -1
  311. package/esm/ai/src/rag/loaders/load-web.mjs +0 -89
  312. package/esm/ai/src/rag/loaders/load-web.mjs.map +0 -1
  313. package/esm/ai/src/rag/rag.mjs +0 -126
  314. package/esm/ai/src/rag/rag.mjs.map +0 -1
  315. package/esm/ai/src/rag/rerank/keyword-reranker.mjs +0 -58
  316. package/esm/ai/src/rag/rerank/keyword-reranker.mjs.map +0 -1
  317. package/esm/ai/src/rag/rerank/llm-reranker.mjs +0 -85
  318. package/esm/ai/src/rag/rerank/llm-reranker.mjs.map +0 -1
  319. package/esm/ai/src/rag/retrieve.mjs +0 -68
  320. package/esm/ai/src/rag/retrieve.mjs.map +0 -1
  321. package/esm/ai/src/rag/store/cache-vector-store.mjs +0 -48
  322. package/esm/ai/src/rag/store/cache-vector-store.mjs.map +0 -1
  323. package/esm/ai/src/rag/store/pg-vector-store.mjs +0 -328
  324. package/esm/ai/src/rag/store/pg-vector-store.mjs.map +0 -1
  325. package/esm/ai/src/rag/transforms/multi-query.mjs +0 -41
  326. package/esm/ai/src/rag/transforms/multi-query.mjs.map +0 -1
  327. package/esm/ai/src/security/index.mjs +0 -5
  328. package/esm/ai/src/security/outbound-policy.mjs +0 -187
  329. package/esm/ai/src/security/outbound-policy.mjs.map +0 -1
  330. package/esm/ai/src/security/private-ip.mjs +0 -48
  331. package/esm/ai/src/security/private-ip.mjs.map +0 -1
  332. package/esm/ai/src/security/redact.mjs +0 -60
  333. package/esm/ai/src/security/redact.mjs.map +0 -1
  334. package/esm/ai/src/serve/serve.mjs +0 -90
  335. package/esm/ai/src/serve/serve.mjs.map +0 -1
  336. package/esm/ai/src/serve/sse.mjs +0 -25
  337. package/esm/ai/src/serve/sse.mjs.map +0 -1
  338. package/esm/ai/src/serve/stream-to-sse.mjs +0 -37
  339. package/esm/ai/src/serve/stream-to-sse.mjs.map +0 -1
  340. package/esm/ai/src/skills/catalog.mjs +0 -140
  341. package/esm/ai/src/skills/catalog.mjs.map +0 -1
  342. package/esm/ai/src/skills/index.mjs +0 -11
  343. package/esm/ai/src/skills/load-skill-tool.mjs +0 -65
  344. package/esm/ai/src/skills/load-skill-tool.mjs.map +0 -1
  345. package/esm/ai/src/skills/save-skill-tool.mjs +0 -65
  346. package/esm/ai/src/skills/save-skill-tool.mjs.map +0 -1
  347. package/esm/ai/src/skills/skills.mjs +0 -109
  348. package/esm/ai/src/skills/skills.mjs.map +0 -1
  349. package/esm/ai/src/skills/sources/directory-source.mjs +0 -108
  350. package/esm/ai/src/skills/sources/directory-source.mjs.map +0 -1
  351. package/esm/ai/src/skills/sources/index.mjs +0 -27
  352. package/esm/ai/src/skills/sources/index.mjs.map +0 -1
  353. package/esm/ai/src/skills/sources/parse-frontmatter.mjs +0 -46
  354. package/esm/ai/src/skills/sources/parse-frontmatter.mjs.map +0 -1
  355. package/esm/ai/src/skills/sources/store-source.mjs +0 -15
  356. package/esm/ai/src/skills/sources/store-source.mjs.map +0 -1
  357. package/esm/ai/src/skills/sources/url-source.mjs +0 -117
  358. package/esm/ai/src/skills/sources/url-source.mjs.map +0 -1
  359. package/esm/ai/src/snapshot/memory.mjs +0 -81
  360. package/esm/ai/src/snapshot/memory.mjs.map +0 -1
  361. package/esm/ai/src/snapshot/pg.mjs +0 -146
  362. package/esm/ai/src/snapshot/pg.mjs.map +0 -1
  363. package/esm/ai/src/snapshot/redis.mjs +0 -101
  364. package/esm/ai/src/snapshot/redis.mjs.map +0 -1
  365. package/esm/ai/src/speech/index.mjs +0 -3
  366. package/esm/ai/src/speech/speech.mjs +0 -122
  367. package/esm/ai/src/speech/speech.mjs.map +0 -1
  368. package/esm/ai/src/supervisor/as-tool.mjs +0 -74
  369. package/esm/ai/src/supervisor/as-tool.mjs.map +0 -1
  370. package/esm/ai/src/supervisor/cancellation.mjs +0 -22
  371. package/esm/ai/src/supervisor/cancellation.mjs.map +0 -1
  372. package/esm/ai/src/supervisor/decide.mjs +0 -272
  373. package/esm/ai/src/supervisor/decide.mjs.map +0 -1
  374. package/esm/ai/src/supervisor/emitter.mjs +0 -47
  375. package/esm/ai/src/supervisor/emitter.mjs.map +0 -1
  376. package/esm/ai/src/supervisor/entries.mjs +0 -206
  377. package/esm/ai/src/supervisor/entries.mjs.map +0 -1
  378. package/esm/ai/src/supervisor/execution.mjs +0 -1921
  379. package/esm/ai/src/supervisor/execution.mjs.map +0 -1
  380. package/esm/ai/src/supervisor/fan-out.mjs +0 -65
  381. package/esm/ai/src/supervisor/fan-out.mjs.map +0 -1
  382. package/esm/ai/src/supervisor/index.mjs +0 -14
  383. package/esm/ai/src/supervisor/router-factory.mjs +0 -141
  384. package/esm/ai/src/supervisor/router-factory.mjs.map +0 -1
  385. package/esm/ai/src/supervisor/router-prompt.mjs +0 -52
  386. package/esm/ai/src/supervisor/router-prompt.mjs.map +0 -1
  387. package/esm/ai/src/supervisor/signature.mjs +0 -89
  388. package/esm/ai/src/supervisor/signature.mjs.map +0 -1
  389. package/esm/ai/src/supervisor/snapshot.mjs +0 -69
  390. package/esm/ai/src/supervisor/snapshot.mjs.map +0 -1
  391. package/esm/ai/src/supervisor/supervisor-stream.mjs +0 -89
  392. package/esm/ai/src/supervisor/supervisor-stream.mjs.map +0 -1
  393. package/esm/ai/src/supervisor/supervisor.mjs +0 -144
  394. package/esm/ai/src/supervisor/supervisor.mjs.map +0 -1
  395. package/esm/ai/src/system-prompt/index.mjs +0 -7
  396. package/esm/ai/src/system-prompt/instruction.mjs +0 -57
  397. package/esm/ai/src/system-prompt/instruction.mjs.map +0 -1
  398. package/esm/ai/src/system-prompt/persona.mjs +0 -57
  399. package/esm/ai/src/system-prompt/persona.mjs.map +0 -1
  400. package/esm/ai/src/system-prompt/refined-system-prompt.mjs +0 -461
  401. package/esm/ai/src/system-prompt/refined-system-prompt.mjs.map +0 -1
  402. package/esm/ai/src/system-prompt/render-placeholders.mjs +0 -58
  403. package/esm/ai/src/system-prompt/render-placeholders.mjs.map +0 -1
  404. package/esm/ai/src/system-prompt/system-prompt.mjs +0 -286
  405. package/esm/ai/src/system-prompt/system-prompt.mjs.map +0 -1
  406. package/esm/ai/src/team/gates.mjs +0 -48
  407. package/esm/ai/src/team/gates.mjs.map +0 -1
  408. package/esm/ai/src/team/index.mjs +0 -3
  409. package/esm/ai/src/team/team.mjs +0 -94
  410. package/esm/ai/src/team/team.mjs.map +0 -1
  411. package/esm/ai/src/tool/executable-as-tool.mjs +0 -81
  412. package/esm/ai/src/tool/executable-as-tool.mjs.map +0 -1
  413. package/esm/ai/src/tool/index.mjs +0 -4
  414. package/esm/ai/src/tool/tool.mjs +0 -185
  415. package/esm/ai/src/tool/tool.mjs.map +0 -1
  416. package/esm/ai/src/transcribe/audio-input.mjs +0 -84
  417. package/esm/ai/src/transcribe/audio-input.mjs.map +0 -1
  418. package/esm/ai/src/transcribe/index.mjs +0 -4
  419. package/esm/ai/src/transcribe/transcribe.mjs +0 -127
  420. package/esm/ai/src/transcribe/transcribe.mjs.map +0 -1
  421. package/esm/ai/src/utils/compute-cost.mjs +0 -112
  422. package/esm/ai/src/utils/compute-cost.mjs.map +0 -1
  423. package/esm/ai/src/utils/extract-json-lenient.mjs +0 -97
  424. package/esm/ai/src/utils/extract-json-lenient.mjs.map +0 -1
  425. package/esm/ai/src/utils/extract-json-payload.mjs +0 -39
  426. package/esm/ai/src/utils/extract-json-payload.mjs.map +0 -1
  427. package/esm/ai/src/utils/generate-run-id.mjs +0 -23
  428. package/esm/ai/src/utils/generate-run-id.mjs.map +0 -1
  429. package/esm/ai/src/utils/index.mjs +0 -12
  430. package/esm/ai/src/utils/json-schema.mjs +0 -89
  431. package/esm/ai/src/utils/json-schema.mjs.map +0 -1
  432. package/esm/ai/src/utils/prepare-attachment-part.mjs +0 -232
  433. package/esm/ai/src/utils/prepare-attachment-part.mjs.map +0 -1
  434. package/esm/ai/src/utils/resolve-attachment.mjs +0 -74
  435. package/esm/ai/src/utils/resolve-attachment.mjs.map +0 -1
  436. package/esm/ai/src/utils/run-context.mjs +0 -89
  437. package/esm/ai/src/utils/run-context.mjs.map +0 -1
  438. package/esm/ai/src/utils/safe-json-parse.mjs +0 -22
  439. package/esm/ai/src/utils/safe-json-parse.mjs.map +0 -1
  440. package/esm/ai/src/utils/stamp-report-lineage.mjs +0 -45
  441. package/esm/ai/src/utils/stamp-report-lineage.mjs.map +0 -1
  442. package/esm/ai/src/vcr/cassette-io.mjs +0 -57
  443. package/esm/ai/src/vcr/cassette-io.mjs.map +0 -1
  444. package/esm/ai/src/vcr/errors.mjs +0 -37
  445. package/esm/ai/src/vcr/errors.mjs.map +0 -1
  446. package/esm/ai/src/vcr/hash-request.mjs +0 -118
  447. package/esm/ai/src/vcr/hash-request.mjs.map +0 -1
  448. package/esm/ai/src/vcr/index.mjs +0 -5
  449. package/esm/ai/src/vcr/vcr.mjs +0 -248
  450. package/esm/ai/src/vcr/vcr.mjs.map +0 -1
  451. package/esm/ai/src/workflow/as-tool.mjs +0 -49
  452. package/esm/ai/src/workflow/as-tool.mjs.map +0 -1
  453. package/esm/ai/src/workflow/cancellation.mjs +0 -44
  454. package/esm/ai/src/workflow/cancellation.mjs.map +0 -1
  455. package/esm/ai/src/workflow/emitter.mjs +0 -40
  456. package/esm/ai/src/workflow/emitter.mjs.map +0 -1
  457. package/esm/ai/src/workflow/engine.mjs +0 -363
  458. package/esm/ai/src/workflow/engine.mjs.map +0 -1
  459. package/esm/ai/src/workflow/index.mjs +0 -5
  460. package/esm/ai/src/workflow/retry.mjs +0 -32
  461. package/esm/ai/src/workflow/retry.mjs.map +0 -1
  462. package/esm/ai/src/workflow/router.mjs +0 -56
  463. package/esm/ai/src/workflow/router.mjs.map +0 -1
  464. package/esm/ai/src/workflow/run-scoped-emitter.mjs +0 -32
  465. package/esm/ai/src/workflow/run-scoped-emitter.mjs.map +0 -1
  466. package/esm/ai/src/workflow/signature.mjs +0 -34
  467. package/esm/ai/src/workflow/signature.mjs.map +0 -1
  468. package/esm/ai/src/workflow/snapshot.mjs +0 -77
  469. package/esm/ai/src/workflow/snapshot.mjs.map +0 -1
  470. package/esm/ai/src/workflow/state.mjs +0 -37
  471. package/esm/ai/src/workflow/state.mjs.map +0 -1
  472. package/esm/ai/src/workflow/step-runner.mjs +0 -370
  473. package/esm/ai/src/workflow/step-runner.mjs.map +0 -1
  474. package/esm/ai/src/workflow/step.mjs +0 -37
  475. package/esm/ai/src/workflow/step.mjs.map +0 -1
  476. package/esm/ai/src/workflow/workflow.mjs +0 -122
  477. package/esm/ai/src/workflow/workflow.mjs.map +0 -1
  478. package/esm/ai-openai/src/embedder.mjs +0 -4
  479. package/esm/ai-openai/src/image.mjs +0 -5
  480. package/esm/ai-openai/src/index.mjs +0 -7
  481. package/esm/ai-openai/src/model.mjs +0 -5
  482. package/esm/ai-openai/src/sdk.mjs +0 -9
  483. package/esm/ai-openai/src/speech.mjs +0 -5
  484. package/esm/ai-openai/src/transcription.mjs +0 -6
  485. package/esm/ai-openai/src/utils/index.mjs +0 -5
  486. package/esm/ai-openai/src/utils/to-openai-messages.mjs +0 -3
  487. package/esm/ai-openai/src/utils/to-openai-tools.mjs +0 -3
  488. package/esm/ai-openai/src/utils/wrap-openai-error.mjs +0 -4
  489. package/esm/node_modules/langfuse/lib/index.mjs +0 -1827
  490. package/esm/node_modules/langfuse/lib/index.mjs.map +0 -1
  491. package/esm/node_modules/langfuse-core/lib/index.mjs +0 -1770
  492. package/esm/node_modules/langfuse-core/lib/index.mjs.map +0 -1
  493. package/esm/node_modules/mustache/mustache.mjs +0 -587
  494. package/esm/node_modules/mustache/mustache.mjs.map +0 -1
  495. package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs +0 -180
  496. package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs.map +0 -1
  497. package/esm/node_modules/openai/auth/workload-identity-auth.mjs +0 -80
  498. package/esm/node_modules/openai/auth/workload-identity-auth.mjs.map +0 -1
  499. package/esm/node_modules/openai/azure.mjs +0 -82
  500. package/esm/node_modules/openai/azure.mjs.map +0 -1
  501. package/esm/node_modules/openai/client.mjs +0 -638
  502. package/esm/node_modules/openai/client.mjs.map +0 -1
  503. package/esm/node_modules/openai/core/api-promise.mjs +0 -75
  504. package/esm/node_modules/openai/core/api-promise.mjs.map +0 -1
  505. package/esm/node_modules/openai/core/error.mjs +0 -110
  506. package/esm/node_modules/openai/core/error.mjs.map +0 -1
  507. package/esm/node_modules/openai/core/pagination.mjs +0 -160
  508. package/esm/node_modules/openai/core/pagination.mjs.map +0 -1
  509. package/esm/node_modules/openai/core/resource.mjs +0 -10
  510. package/esm/node_modules/openai/core/resource.mjs.map +0 -1
  511. package/esm/node_modules/openai/core/streaming.mjs +0 -238
  512. package/esm/node_modules/openai/core/streaming.mjs.map +0 -1
  513. package/esm/node_modules/openai/index.mjs +0 -8
  514. package/esm/node_modules/openai/internal/decoders/line.mjs +0 -91
  515. package/esm/node_modules/openai/internal/decoders/line.mjs.map +0 -1
  516. package/esm/node_modules/openai/internal/detect-platform.mjs +0 -123
  517. package/esm/node_modules/openai/internal/detect-platform.mjs.map +0 -1
  518. package/esm/node_modules/openai/internal/errors.mjs +0 -26
  519. package/esm/node_modules/openai/internal/errors.mjs.map +0 -1
  520. package/esm/node_modules/openai/internal/headers.mjs +0 -65
  521. package/esm/node_modules/openai/internal/headers.mjs.map +0 -1
  522. package/esm/node_modules/openai/internal/parse.mjs +0 -41
  523. package/esm/node_modules/openai/internal/parse.mjs.map +0 -1
  524. package/esm/node_modules/openai/internal/qs/formats.mjs +0 -12
  525. package/esm/node_modules/openai/internal/qs/formats.mjs.map +0 -1
  526. package/esm/node_modules/openai/internal/qs/stringify.mjs +0 -179
  527. package/esm/node_modules/openai/internal/qs/stringify.mjs.map +0 -1
  528. package/esm/node_modules/openai/internal/qs/utils.mjs +0 -65
  529. package/esm/node_modules/openai/internal/qs/utils.mjs.map +0 -1
  530. package/esm/node_modules/openai/internal/request-options.mjs +0 -11
  531. package/esm/node_modules/openai/internal/request-options.mjs.map +0 -1
  532. package/esm/node_modules/openai/internal/shims.mjs +0 -77
  533. package/esm/node_modules/openai/internal/shims.mjs.map +0 -1
  534. package/esm/node_modules/openai/internal/to-file.mjs +0 -63
  535. package/esm/node_modules/openai/internal/to-file.mjs.map +0 -1
  536. package/esm/node_modules/openai/internal/tslib.mjs +0 -16
  537. package/esm/node_modules/openai/internal/tslib.mjs.map +0 -1
  538. package/esm/node_modules/openai/internal/uploads.mjs +0 -94
  539. package/esm/node_modules/openai/internal/uploads.mjs.map +0 -1
  540. package/esm/node_modules/openai/internal/utils/base64.mjs +0 -22
  541. package/esm/node_modules/openai/internal/utils/base64.mjs.map +0 -1
  542. package/esm/node_modules/openai/internal/utils/bytes.mjs +0 -26
  543. package/esm/node_modules/openai/internal/utils/bytes.mjs.map +0 -1
  544. package/esm/node_modules/openai/internal/utils/env.mjs +0 -16
  545. package/esm/node_modules/openai/internal/utils/env.mjs.map +0 -1
  546. package/esm/node_modules/openai/internal/utils/log.mjs +0 -58
  547. package/esm/node_modules/openai/internal/utils/log.mjs.map +0 -1
  548. package/esm/node_modules/openai/internal/utils/path.mjs +0 -62
  549. package/esm/node_modules/openai/internal/utils/path.mjs.map +0 -1
  550. package/esm/node_modules/openai/internal/utils/query.mjs +0 -10
  551. package/esm/node_modules/openai/internal/utils/query.mjs.map +0 -1
  552. package/esm/node_modules/openai/internal/utils/sleep.mjs +0 -6
  553. package/esm/node_modules/openai/internal/utils/sleep.mjs.map +0 -1
  554. package/esm/node_modules/openai/internal/utils/uuid.mjs +0 -18
  555. package/esm/node_modules/openai/internal/utils/uuid.mjs.map +0 -1
  556. package/esm/node_modules/openai/internal/utils/values.mjs +0 -41
  557. package/esm/node_modules/openai/internal/utils/values.mjs.map +0 -1
  558. package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +0 -247
  559. package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +0 -1
  560. package/esm/node_modules/openai/lib/AssistantStream.mjs +0 -472
  561. package/esm/node_modules/openai/lib/AssistantStream.mjs.map +0 -1
  562. package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs +0 -26
  563. package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs.map +0 -1
  564. package/esm/node_modules/openai/lib/ChatCompletionStream.mjs +0 -423
  565. package/esm/node_modules/openai/lib/ChatCompletionStream.mjs.map +0 -1
  566. package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +0 -26
  567. package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +0 -1
  568. package/esm/node_modules/openai/lib/EventStream.mjs +0 -163
  569. package/esm/node_modules/openai/lib/EventStream.mjs.map +0 -1
  570. package/esm/node_modules/openai/lib/ResponsesParser.mjs +0 -94
  571. package/esm/node_modules/openai/lib/ResponsesParser.mjs.map +0 -1
  572. package/esm/node_modules/openai/lib/RunnableFunction.mjs +0 -8
  573. package/esm/node_modules/openai/lib/RunnableFunction.mjs.map +0 -1
  574. package/esm/node_modules/openai/lib/Util.mjs +0 -19
  575. package/esm/node_modules/openai/lib/Util.mjs.map +0 -1
  576. package/esm/node_modules/openai/lib/chatCompletionUtils.mjs +0 -11
  577. package/esm/node_modules/openai/lib/chatCompletionUtils.mjs.map +0 -1
  578. package/esm/node_modules/openai/lib/parser.mjs +0 -88
  579. package/esm/node_modules/openai/lib/parser.mjs.map +0 -1
  580. package/esm/node_modules/openai/lib/responses/ResponseStream.mjs +0 -231
  581. package/esm/node_modules/openai/lib/responses/ResponseStream.mjs.map +0 -1
  582. package/esm/node_modules/openai/resources/admin/admin.mjs +0 -15
  583. package/esm/node_modules/openai/resources/admin/admin.mjs.map +0 -1
  584. package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs +0 -81
  585. package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs.map +0 -1
  586. package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs +0 -31
  587. package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs.map +0 -1
  588. package/esm/node_modules/openai/resources/admin/organization/certificates.mjs +0 -153
  589. package/esm/node_modules/openai/resources/admin/organization/certificates.mjs.map +0 -1
  590. package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs +0 -42
  591. package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs.map +0 -1
  592. package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs +0 -106
  593. package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs.map +0 -1
  594. package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs +0 -88
  595. package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs.map +0 -1
  596. package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs +0 -88
  597. package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs.map +0 -1
  598. package/esm/node_modules/openai/resources/admin/organization/invites.mjs +0 -83
  599. package/esm/node_modules/openai/resources/admin/organization/invites.mjs.map +0 -1
  600. package/esm/node_modules/openai/resources/admin/organization/organization.mjs +0 -45
  601. package/esm/node_modules/openai/resources/admin/organization/organization.mjs.map +0 -1
  602. package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs +0 -72
  603. package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs.map +0 -1
  604. package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs +0 -78
  605. package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs.map +0 -1
  606. package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs +0 -46
  607. package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs.map +0 -1
  608. package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs +0 -95
  609. package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs.map +0 -1
  610. package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs +0 -91
  611. package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs.map +0 -1
  612. package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs +0 -45
  613. package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs.map +0 -1
  614. package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs +0 -63
  615. package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs.map +0 -1
  616. package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs +0 -137
  617. package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs.map +0 -1
  618. package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs +0 -51
  619. package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs.map +0 -1
  620. package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs +0 -108
  621. package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs.map +0 -1
  622. package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs +0 -112
  623. package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs.map +0 -1
  624. package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs +0 -106
  625. package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs.map +0 -1
  626. package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs +0 -91
  627. package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs.map +0 -1
  628. package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs +0 -118
  629. package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs.map +0 -1
  630. package/esm/node_modules/openai/resources/admin/organization/roles.mjs +0 -96
  631. package/esm/node_modules/openai/resources/admin/organization/roles.mjs.map +0 -1
  632. package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs +0 -97
  633. package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs.map +0 -1
  634. package/esm/node_modules/openai/resources/admin/organization/usage.mjs +0 -207
  635. package/esm/node_modules/openai/resources/admin/organization/usage.mjs.map +0 -1
  636. package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs +0 -88
  637. package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs.map +0 -1
  638. package/esm/node_modules/openai/resources/admin/organization/users/users.mjs +0 -82
  639. package/esm/node_modules/openai/resources/admin/organization/users/users.mjs.map +0 -1
  640. package/esm/node_modules/openai/resources/audio/audio.mjs +0 -21
  641. package/esm/node_modules/openai/resources/audio/audio.mjs.map +0 -1
  642. package/esm/node_modules/openai/resources/audio/speech.mjs +0 -39
  643. package/esm/node_modules/openai/resources/audio/speech.mjs.map +0 -1
  644. package/esm/node_modules/openai/resources/audio/transcriptions.mjs +0 -22
  645. package/esm/node_modules/openai/resources/audio/transcriptions.mjs.map +0 -1
  646. package/esm/node_modules/openai/resources/audio/translations.mjs +0 -21
  647. package/esm/node_modules/openai/resources/audio/translations.mjs.map +0 -1
  648. package/esm/node_modules/openai/resources/batches.mjs +0 -54
  649. package/esm/node_modules/openai/resources/batches.mjs.map +0 -1
  650. package/esm/node_modules/openai/resources/beta/assistants.mjs +0 -78
  651. package/esm/node_modules/openai/resources/beta/assistants.mjs.map +0 -1
  652. package/esm/node_modules/openai/resources/beta/beta.mjs +0 -24
  653. package/esm/node_modules/openai/resources/beta/beta.mjs.map +0 -1
  654. package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs +0 -18
  655. package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs.map +0 -1
  656. package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs +0 -49
  657. package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs.map +0 -1
  658. package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs +0 -85
  659. package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs.map +0 -1
  660. package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs +0 -21
  661. package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs.map +0 -1
  662. package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs +0 -33
  663. package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs.map +0 -1
  664. package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs +0 -33
  665. package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs.map +0 -1
  666. package/esm/node_modules/openai/resources/beta/threads/messages.mjs +0 -83
  667. package/esm/node_modules/openai/resources/beta/threads/messages.mjs.map +0 -1
  668. package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs +0 -183
  669. package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +0 -1
  670. package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs +0 -45
  671. package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +0 -1
  672. package/esm/node_modules/openai/resources/beta/threads/threads.mjs +0 -101
  673. package/esm/node_modules/openai/resources/beta/threads/threads.mjs.map +0 -1
  674. package/esm/node_modules/openai/resources/chat/chat.mjs +0 -15
  675. package/esm/node_modules/openai/resources/chat/chat.mjs.map +0 -1
  676. package/esm/node_modules/openai/resources/chat/completions/completions.mjs +0 -123
  677. package/esm/node_modules/openai/resources/chat/completions/completions.mjs.map +0 -1
  678. package/esm/node_modules/openai/resources/chat/completions/index.mjs +0 -7
  679. package/esm/node_modules/openai/resources/chat/completions/messages.mjs +0 -35
  680. package/esm/node_modules/openai/resources/chat/completions/messages.mjs.map +0 -1
  681. package/esm/node_modules/openai/resources/chat/index.mjs +0 -5
  682. package/esm/node_modules/openai/resources/completions.mjs +0 -20
  683. package/esm/node_modules/openai/resources/completions.mjs.map +0 -1
  684. package/esm/node_modules/openai/resources/containers/containers.mjs +0 -57
  685. package/esm/node_modules/openai/resources/containers/containers.mjs.map +0 -1
  686. package/esm/node_modules/openai/resources/containers/files/content.mjs +0 -23
  687. package/esm/node_modules/openai/resources/containers/files/content.mjs.map +0 -1
  688. package/esm/node_modules/openai/resources/containers/files/files.mjs +0 -63
  689. package/esm/node_modules/openai/resources/containers/files/files.mjs.map +0 -1
  690. package/esm/node_modules/openai/resources/conversations/conversations.mjs +0 -57
  691. package/esm/node_modules/openai/resources/conversations/conversations.mjs.map +0 -1
  692. package/esm/node_modules/openai/resources/conversations/items.mjs +0 -57
  693. package/esm/node_modules/openai/resources/conversations/items.mjs.map +0 -1
  694. package/esm/node_modules/openai/resources/embeddings.mjs +0 -48
  695. package/esm/node_modules/openai/resources/embeddings.mjs.map +0 -1
  696. package/esm/node_modules/openai/resources/evals/evals.mjs +0 -73
  697. package/esm/node_modules/openai/resources/evals/evals.mjs.map +0 -1
  698. package/esm/node_modules/openai/resources/evals/runs/output-items.mjs +0 -35
  699. package/esm/node_modules/openai/resources/evals/runs/output-items.mjs.map +0 -1
  700. package/esm/node_modules/openai/resources/evals/runs/runs.mjs +0 -72
  701. package/esm/node_modules/openai/resources/evals/runs/runs.mjs.map +0 -1
  702. package/esm/node_modules/openai/resources/files.mjs +0 -111
  703. package/esm/node_modules/openai/resources/files.mjs.map +0 -1
  704. package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs +0 -15
  705. package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs.map +0 -1
  706. package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs +0 -60
  707. package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs.map +0 -1
  708. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs +0 -15
  709. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs.map +0 -1
  710. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs +0 -102
  711. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs.map +0 -1
  712. package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +0 -24
  713. package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +0 -1
  714. package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +0 -34
  715. package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +0 -1
  716. package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +0 -148
  717. package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +0 -1
  718. package/esm/node_modules/openai/resources/fine-tuning/methods.mjs +0 -8
  719. package/esm/node_modules/openai/resources/fine-tuning/methods.mjs.map +0 -1
  720. package/esm/node_modules/openai/resources/graders/grader-models.mjs +0 -8
  721. package/esm/node_modules/openai/resources/graders/grader-models.mjs.map +0 -1
  722. package/esm/node_modules/openai/resources/graders/graders.mjs +0 -15
  723. package/esm/node_modules/openai/resources/graders/graders.mjs.map +0 -1
  724. package/esm/node_modules/openai/resources/images.mjs +0 -46
  725. package/esm/node_modules/openai/resources/images.mjs.map +0 -1
  726. package/esm/node_modules/openai/resources/index.mjs +0 -27
  727. package/esm/node_modules/openai/resources/models.mjs +0 -44
  728. package/esm/node_modules/openai/resources/models.mjs.map +0 -1
  729. package/esm/node_modules/openai/resources/moderations.mjs +0 -23
  730. package/esm/node_modules/openai/resources/moderations.mjs.map +0 -1
  731. package/esm/node_modules/openai/resources/realtime/calls.mjs +0 -79
  732. package/esm/node_modules/openai/resources/realtime/calls.mjs.map +0 -1
  733. package/esm/node_modules/openai/resources/realtime/client-secrets.mjs +0 -39
  734. package/esm/node_modules/openai/resources/realtime/client-secrets.mjs.map +0 -1
  735. package/esm/node_modules/openai/resources/realtime/realtime.mjs +0 -18
  736. package/esm/node_modules/openai/resources/realtime/realtime.mjs.map +0 -1
  737. package/esm/node_modules/openai/resources/responses/input-items.mjs +0 -31
  738. package/esm/node_modules/openai/resources/responses/input-items.mjs.map +0 -1
  739. package/esm/node_modules/openai/resources/responses/input-tokens.mjs +0 -27
  740. package/esm/node_modules/openai/resources/responses/input-tokens.mjs.map +0 -1
  741. package/esm/node_modules/openai/resources/responses/responses.mjs +0 -110
  742. package/esm/node_modules/openai/resources/responses/responses.mjs.map +0 -1
  743. package/esm/node_modules/openai/resources/skills/content.mjs +0 -22
  744. package/esm/node_modules/openai/resources/skills/content.mjs.map +0 -1
  745. package/esm/node_modules/openai/resources/skills/skills.mjs +0 -69
  746. package/esm/node_modules/openai/resources/skills/skills.mjs.map +0 -1
  747. package/esm/node_modules/openai/resources/skills/versions/content.mjs +0 -23
  748. package/esm/node_modules/openai/resources/skills/versions/content.mjs.map +0 -1
  749. package/esm/node_modules/openai/resources/skills/versions/versions.mjs +0 -58
  750. package/esm/node_modules/openai/resources/skills/versions/versions.mjs.map +0 -1
  751. package/esm/node_modules/openai/resources/uploads/parts.mjs +0 -34
  752. package/esm/node_modules/openai/resources/uploads/parts.mjs.map +0 -1
  753. package/esm/node_modules/openai/resources/uploads/uploads.mjs +0 -84
  754. package/esm/node_modules/openai/resources/uploads/uploads.mjs.map +0 -1
  755. package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs +0 -126
  756. package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs.map +0 -1
  757. package/esm/node_modules/openai/resources/vector-stores/files.mjs +0 -147
  758. package/esm/node_modules/openai/resources/vector-stores/files.mjs.map +0 -1
  759. package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs +0 -87
  760. package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs.map +0 -1
  761. package/esm/node_modules/openai/resources/videos.mjs +0 -115
  762. package/esm/node_modules/openai/resources/videos.mjs.map +0 -1
  763. package/esm/node_modules/openai/resources/webhooks/index.mjs +0 -3
  764. package/esm/node_modules/openai/resources/webhooks/webhooks.mjs +0 -69
  765. package/esm/node_modules/openai/resources/webhooks/webhooks.mjs.map +0 -1
  766. package/esm/node_modules/openai/resources/webhooks.mjs +0 -4
  767. package/esm/node_modules/openai/streaming.mjs +0 -3
  768. package/esm/node_modules/openai/version.mjs +0 -6
  769. package/esm/node_modules/openai/version.mjs.map +0 -1
@@ -1,98 +0,0 @@
1
- import { SupervisorFailedError } from "../errors/supervisor-failed-error.mjs";
2
- import "../errors/index.mjs";
3
- import { generateRunId } from "../utils/generate-run-id.mjs";
4
- import { compositeAsTool } from "../tool/tool.mjs";
5
-
6
- //#region ../@warlock.js/ai/src/orchestrator/as-tool.ts
7
- /**
8
- * Wrap an {@link OrchestratorContract} as a {@link ToolContract} so an
9
- * outer agent can invoke it from its tool-call loop (design §13).
10
- * Mirrors `supervisor.asTool()` — same `compositeAsTool` composition and
11
- * error normalization — and adds `sessionScope`.
12
- *
13
- * The boundary is OPAQUE (§13, §18.6): the parent's `signal` / `context`
14
- * / events do NOT auto-forward. Anything the wrapped orchestrator needs
15
- * per call must ride on the tool's `inputSchema` payload.
16
- *
17
- * Session continuity:
18
- * - `"fresh"` (default) — each invocation gets a brand-new `sessionId`
19
- * (a generated id) and empty history; the session lives only for this
20
- * tool call. The whole validated payload is forwarded as the
21
- * orchestrator's `execute(input)` argument.
22
- * - `"shared"` — the parent supplies `sessionId` (and optionally
23
- * `history`) inside the validated payload; the orchestrator
24
- * participates in that session. The remaining payload fields are
25
- * forwarded as `execute(input)`. A missing/blank `sessionId` throws
26
- * {@link SupervisorFailedError}.
27
- *
28
- * On `result.error`, the typed orchestrator error is thrown so the tool
29
- * wrapper produces a `ToolExecutionError` with `cause` preserved — the
30
- * outer agent sees one uniform error class.
31
- *
32
- * @example
33
- * const support = ai.orchestrator({ name: "refund-support", intents });
34
- * const supportTool = support.asTool({
35
- * name: "handle_refund",
36
- * description: "Handle a refund conversation end-to-end.",
37
- * inputSchema: v.object({ message: v.string() }),
38
- * });
39
- * const concierge = ai.agent({ model, tools: [supportTool] });
40
- */
41
- function asTool(orchestrator, options) {
42
- if (!orchestrator.name || typeof orchestrator.name !== "string") throw new SupervisorFailedError("orchestrator.asTool(): orchestrator must have a `name` to be wrapped as a tool");
43
- const sessionScope = options.sessionScope ?? "fresh";
44
- return compositeAsTool({
45
- name: options.name ?? orchestrator.name,
46
- description: options.description ?? `Invoke orchestrator "${orchestrator.name}" as a tool.`,
47
- input: options.inputSchema,
48
- execute: async (input) => {
49
- const { sessionId, history, executeInput } = resolveSession(sessionScope, input);
50
- const result = await orchestrator.execute(executeInput, {
51
- sessionId,
52
- history
53
- });
54
- if (result.error) throw result.error;
55
- return {
56
- data: result.data,
57
- usage: result.usage,
58
- report: result.report
59
- };
60
- }
61
- });
62
- }
63
- /**
64
- * Resolve the per-call `sessionId`, `history`, and the `execute(input)`
65
- * argument from the validated tool payload, according to `sessionScope`.
66
- */
67
- function resolveSession(sessionScope, input) {
68
- if (sessionScope === "fresh") return {
69
- sessionId: generateRunId("session"),
70
- history: [],
71
- executeInput: coerceInput(input)
72
- };
73
- const payload = typeof input === "object" && input !== null ? input : {};
74
- if (typeof payload.sessionId !== "string" || payload.sessionId.length === 0) throw new SupervisorFailedError("orchestrator.asTool(): sessionScope \"shared\" requires a `sessionId` string in the tool input payload");
75
- const { sessionId, history, ...rest } = payload;
76
- return {
77
- sessionId,
78
- history: Array.isArray(history) ? history : [],
79
- executeInput: coerceInput(rest)
80
- };
81
- }
82
- /**
83
- * Coerce a tool-input value into the `SupervisorInput` shape the
84
- * orchestrator's `execute()` accepts (`string | Record<string,
85
- * unknown>`). Strings and plain objects pass through; everything else
86
- * is JSON-stringified so the orchestrator receives a predictable input
87
- * regardless of how the outer agent shaped its call.
88
- */
89
- function coerceInput(value) {
90
- if (typeof value === "string") return value;
91
- if (typeof value === "object" && value !== null) return value;
92
- if (value === void 0 || value === null) return "";
93
- return String(value);
94
- }
95
-
96
- //#endregion
97
- export { asTool };
98
- //# sourceMappingURL=as-tool.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"as-tool.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/orchestrator/as-tool.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type {\n OrchestratorAsToolOptions,\n OrchestratorContract,\n} from \"../contracts/orchestrator/orchestrator.contract\";\nimport type { SupervisorInput } from \"../contracts/supervisor/supervisor-input.type\";\nimport { SupervisorFailedError } from \"../errors\";\nimport { compositeAsTool, type ToolContract } from \"../tool/tool\";\nimport { generateRunId } from \"../utils/generate-run-id\";\n\n/**\n * Shape the orchestrator looks for inside the validated tool input when\n * `sessionScope: \"shared\"` — the parent must thread the session id (and\n * optionally the prior history) through the tool's `inputSchema`\n * payload, since the boundary is opaque (§13). Everything else on the\n * payload becomes the orchestrator's `execute(input)` argument.\n */\ntype SharedScopePayload = {\n sessionId?: unknown;\n history?: unknown;\n [key: string]: unknown;\n};\n\n/**\n * Wrap an {@link OrchestratorContract} as a {@link ToolContract} so an\n * outer agent can invoke it from its tool-call loop (design §13).\n * Mirrors `supervisor.asTool()` — same `compositeAsTool` composition and\n * error normalization — and adds `sessionScope`.\n *\n * The boundary is OPAQUE (§13, §18.6): the parent's `signal` / `context`\n * / events do NOT auto-forward. Anything the wrapped orchestrator needs\n * per call must ride on the tool's `inputSchema` payload.\n *\n * Session continuity:\n * - `\"fresh\"` (default) — each invocation gets a brand-new `sessionId`\n * (a generated id) and empty history; the session lives only for this\n * tool call. The whole validated payload is forwarded as the\n * orchestrator's `execute(input)` argument.\n * - `\"shared\"` — the parent supplies `sessionId` (and optionally\n * `history`) inside the validated payload; the orchestrator\n * participates in that session. The remaining payload fields are\n * forwarded as `execute(input)`. A missing/blank `sessionId` throws\n * {@link SupervisorFailedError}.\n *\n * On `result.error`, the typed orchestrator error is thrown so the tool\n * wrapper produces a `ToolExecutionError` with `cause` preserved — the\n * outer agent sees one uniform error class.\n *\n * @example\n * const support = ai.orchestrator({ name: \"refund-support\", intents });\n * const supportTool = support.asTool({\n * name: \"handle_refund\",\n * description: \"Handle a refund conversation end-to-end.\",\n * inputSchema: v.object({ message: v.string() }),\n * });\n * const concierge = ai.agent({ model, tools: [supportTool] });\n */\nexport function asTool<TOutput, TState, TToolInput>(\n orchestrator: OrchestratorContract<TOutput, TState>,\n options: OrchestratorAsToolOptions<TToolInput>,\n): ToolContract<TToolInput, TOutput> {\n if (!orchestrator.name || typeof orchestrator.name !== \"string\") {\n throw new SupervisorFailedError(\n \"orchestrator.asTool(): orchestrator must have a `name` to be wrapped as a tool\",\n );\n }\n\n const sessionScope = options.sessionScope ?? \"fresh\";\n\n return compositeAsTool<TToolInput, TOutput>({\n name: options.name ?? orchestrator.name,\n description:\n options.description ??\n `Invoke orchestrator \"${orchestrator.name}\" as a tool.`,\n input: options.inputSchema,\n execute: async (input) => {\n const { sessionId, history, executeInput } = resolveSession(\n sessionScope,\n input,\n );\n\n const result = await orchestrator.execute(executeInput, {\n sessionId,\n history,\n });\n\n if (result.error) {\n // Surface the typed orchestrator error — the outer ToolContract\n // wraps it as a ToolExecutionError with `cause` preserved.\n throw result.error;\n }\n\n return {\n data: result.data as TOutput,\n usage: result.usage,\n report: result.report,\n };\n },\n });\n}\n\n/**\n * Resolve the per-call `sessionId`, `history`, and the `execute(input)`\n * argument from the validated tool payload, according to `sessionScope`.\n */\nfunction resolveSession(\n sessionScope: \"fresh\" | \"shared\",\n input: unknown,\n): { sessionId: string; history: Message[]; executeInput: SupervisorInput } {\n if (sessionScope === \"fresh\") {\n return {\n sessionId: generateRunId(\"session\"),\n history: [],\n executeInput: coerceInput(input),\n };\n }\n\n const payload = (\n typeof input === \"object\" && input !== null ? input : {}\n ) as SharedScopePayload;\n\n if (typeof payload.sessionId !== \"string\" || payload.sessionId.length === 0) {\n throw new SupervisorFailedError(\n 'orchestrator.asTool(): sessionScope \"shared\" requires a `sessionId` string in the tool input payload',\n );\n }\n\n const { sessionId, history, ...rest } = payload;\n\n return {\n sessionId,\n history: Array.isArray(history) ? (history as Message[]) : [],\n executeInput: coerceInput(rest),\n };\n}\n\n/**\n * Coerce a tool-input value into the `SupervisorInput` shape the\n * orchestrator's `execute()` accepts (`string | Record<string,\n * unknown>`). Strings and plain objects pass through; everything else\n * is JSON-stringified so the orchestrator receives a predictable input\n * regardless of how the outer agent shaped its call.\n */\nfunction coerceInput(value: unknown): SupervisorInput {\n if (typeof value === \"string\") {\n return value;\n }\n\n if (typeof value === \"object\" && value !== null) {\n return value as Record<string, unknown>;\n }\n\n if (value === undefined || value === null) {\n return \"\";\n }\n\n return String(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,OACd,cACA,SACmC;CACnC,IAAI,CAAC,aAAa,QAAQ,OAAO,aAAa,SAAS,UACrD,MAAM,IAAI,sBACR,gFACF;CAGF,MAAM,eAAe,QAAQ,gBAAgB;CAE7C,OAAO,gBAAqC;EAC1C,MAAM,QAAQ,QAAQ,aAAa;EACnC,aACE,QAAQ,eACR,wBAAwB,aAAa,KAAK;EAC5C,OAAO,QAAQ;EACf,SAAS,OAAO,UAAU;GACxB,MAAM,EAAE,WAAW,SAAS,iBAAiB,eAC3C,cACA,KACF;GAEA,MAAM,SAAS,MAAM,aAAa,QAAQ,cAAc;IACtD;IACA;GACF,CAAC;GAED,IAAI,OAAO,OAGT,MAAM,OAAO;GAGf,OAAO;IACL,MAAM,OAAO;IACb,OAAO,OAAO;IACd,QAAQ,OAAO;GACjB;EACF;CACF,CAAC;AACH;;;;;AAMA,SAAS,eACP,cACA,OAC0E;CAC1E,IAAI,iBAAiB,SACnB,OAAO;EACL,WAAW,cAAc,SAAS;EAClC,SAAS,CAAC;EACV,cAAc,YAAY,KAAK;CACjC;CAGF,MAAM,UACJ,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,CAAC;CAGzD,IAAI,OAAO,QAAQ,cAAc,YAAY,QAAQ,UAAU,WAAW,GACxE,MAAM,IAAI,sBACR,wGACF;CAGF,MAAM,EAAE,WAAW,SAAS,GAAG,SAAS;CAExC,OAAO;EACL;EACA,SAAS,MAAM,QAAQ,OAAO,IAAK,UAAwB,CAAC;EAC5D,cAAc,YAAY,IAAI;CAChC;AACF;;;;;;;;AASA,SAAS,YAAY,OAAiC;CACpD,IAAI,OAAO,UAAU,UACnB,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAGT,IAAI,UAAU,UAAa,UAAU,MACnC,OAAO;CAGT,OAAO,OAAO,KAAK;AACrB"}
@@ -1,75 +0,0 @@
1
- //#region ../@warlock.js/ai/src/orchestrator/checkpoint.ts
2
- /** Framework default for snapshot retention per session (§4 Phase 6). */
3
- const DEFAULT_KEEP_SNAPSHOTS = 100;
4
- /**
5
- * Summarize a supervisor dispatch decision into the `last_route`
6
- * checkpoint column (§4 Phase 6). A bare string passes through; a
7
- * fan-out array passes through; the `END` sentinel and anything else
8
- * collapse to `null` (the turn routed nowhere worth recording).
9
- */
10
- function summarizeRoute(next) {
11
- if (typeof next === "string") return next === "__warlock:end__" ? null : next;
12
- if (Array.isArray(next)) return next;
13
- return null;
14
- }
15
- /**
16
- * Phase 6 — persist checkpoint (orchestrator.md §3 / §4 Phase 6).
17
- * Writes a fresh append-only row at `turn_index = N` carrying the
18
- * post-merge `state`, the current `signature` (read by the next call's
19
- * Phase 2), the informational `version`, the dispatch `last_route`, and
20
- * the carried-forward `summarized_through`. Lock columns are written
21
- * `null` here — they are populated only by an in-flight Phase 7
22
- * compaction.
23
- *
24
- * Emits `orchestrator.checkpoint.persisted` after the row lands, then
25
- * prunes to `keepSnapshots` (default 100; `"all"` opts out) — §4 Phase
26
- * 6 pruning (Q20). Pruning runs only when the store exposes the
27
- * optional `prune` hook (memory/pg/redis own their own pruning); when
28
- * absent the write still succeeds.
29
- *
30
- * Returns the persisted record so the engine can fold it into the
31
- * turn's report.
32
- */
33
- async function persistCheckpoint(params) {
34
- const { ctx, sessionId, turnIndex, state, lastRoute, summarizedThrough } = params;
35
- const record = {
36
- orchestrator_name: ctx.config.name,
37
- session_id: sessionId,
38
- turn_index: turnIndex,
39
- state,
40
- last_route: lastRoute,
41
- signature: ctx.signature,
42
- version: ctx.config.version ?? null,
43
- summarized_through: summarizedThrough,
44
- lock_acquired_at: null,
45
- lock_expires_at: null,
46
- saved_at: (/* @__PURE__ */ new Date()).toISOString()
47
- };
48
- await ctx.checkpointStore.save(record);
49
- ctx.emitter.emit("orchestrator.checkpoint.persisted", {
50
- sessionId,
51
- turnIndex
52
- });
53
- await prune(ctx, sessionId, turnIndex);
54
- return record;
55
- }
56
- /**
57
- * Prune session rows older than `max_turn_index - keepSnapshots` (§4
58
- * Phase 6). Synchronous-after-save; opted out with
59
- * `keepSnapshots: "all"`. Delegated to an optional store-side `prune`
60
- * hook so each driver implements deletion in its own dialect — the
61
- * engine never reaches into store internals.
62
- */
63
- async function prune(ctx, sessionId, latestTurnIndex) {
64
- const keep = ctx.config.keepSnapshots ?? 100;
65
- if (keep === "all") return;
66
- const store = ctx.checkpointStore;
67
- if (typeof store.prune !== "function") return;
68
- const keepBeforeTurnIndex = latestTurnIndex - keep + 1;
69
- if (keepBeforeTurnIndex <= 0) return;
70
- await store.prune(ctx.config.name, sessionId, keepBeforeTurnIndex);
71
- }
72
-
73
- //#endregion
74
- export { persistCheckpoint, summarizeRoute };
75
- //# sourceMappingURL=checkpoint.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkpoint.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/orchestrator/checkpoint.ts"],"sourcesContent":["import type { CheckpointRecord } from \"../contracts/orchestrator/checkpoint-store.contract\";\nimport type { Next } from \"../contracts/supervisor/next.type\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\n\n/** Framework default for snapshot retention per session (§4 Phase 6). */\nexport const DEFAULT_KEEP_SNAPSHOTS = 100;\n\n/** Fields the engine supplies to build a fresh checkpoint row. */\nexport type PersistParams<TState> = {\n ctx: OrchestratorEngineContext<unknown, TState>;\n sessionId: string;\n turnIndex: number;\n state: unknown;\n /** Dispatch decision summary — a single intent, fan-out list, or null. */\n lastRoute: string | string[] | null;\n /** Carried forward from the loaded checkpoint (compaction progress). */\n summarizedThrough: number | null;\n};\n\n/**\n * Summarize a supervisor dispatch decision into the `last_route`\n * checkpoint column (§4 Phase 6). A bare string passes through; a\n * fan-out array passes through; the `END` sentinel and anything else\n * collapse to `null` (the turn routed nowhere worth recording).\n */\nexport function summarizeRoute(next: Next | undefined): string | string[] | null {\n if (typeof next === \"string\") {\n return next === \"__warlock:end__\" ? null : next;\n }\n\n if (Array.isArray(next)) {\n return next;\n }\n\n return null;\n}\n\n/**\n * Phase 6 — persist checkpoint (orchestrator.md §3 / §4 Phase 6).\n * Writes a fresh append-only row at `turn_index = N` carrying the\n * post-merge `state`, the current `signature` (read by the next call's\n * Phase 2), the informational `version`, the dispatch `last_route`, and\n * the carried-forward `summarized_through`. Lock columns are written\n * `null` here — they are populated only by an in-flight Phase 7\n * compaction.\n *\n * Emits `orchestrator.checkpoint.persisted` after the row lands, then\n * prunes to `keepSnapshots` (default 100; `\"all\"` opts out) — §4 Phase\n * 6 pruning (Q20). Pruning runs only when the store exposes the\n * optional `prune` hook (memory/pg/redis own their own pruning); when\n * absent the write still succeeds.\n *\n * Returns the persisted record so the engine can fold it into the\n * turn's report.\n */\nexport async function persistCheckpoint<TState>(\n params: PersistParams<TState>,\n): Promise<CheckpointRecord> {\n const { ctx, sessionId, turnIndex, state, lastRoute, summarizedThrough } = params;\n\n const record: CheckpointRecord = {\n orchestrator_name: ctx.config.name,\n session_id: sessionId,\n turn_index: turnIndex,\n state,\n last_route: lastRoute,\n signature: ctx.signature,\n version: ctx.config.version ?? null,\n summarized_through: summarizedThrough,\n lock_acquired_at: null,\n lock_expires_at: null,\n saved_at: new Date().toISOString(),\n };\n\n await ctx.checkpointStore.save(record);\n\n ctx.emitter.emit(\"orchestrator.checkpoint.persisted\", {\n sessionId,\n turnIndex,\n });\n\n await prune(ctx, sessionId, turnIndex);\n\n return record;\n}\n\n/**\n * Prune session rows older than `max_turn_index - keepSnapshots` (§4\n * Phase 6). Synchronous-after-save; opted out with\n * `keepSnapshots: \"all\"`. Delegated to an optional store-side `prune`\n * hook so each driver implements deletion in its own dialect — the\n * engine never reaches into store internals.\n */\nasync function prune<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n latestTurnIndex: number,\n): Promise<void> {\n const keep = ctx.config.keepSnapshots ?? DEFAULT_KEEP_SNAPSHOTS;\n\n if (keep === \"all\") {\n return;\n }\n\n const store = ctx.checkpointStore as {\n prune?: (\n orchestratorName: string,\n sessionId: string,\n keepBeforeTurnIndex: number,\n ) => Promise<void>;\n };\n\n if (typeof store.prune !== \"function\") {\n return;\n }\n\n const keepBeforeTurnIndex = latestTurnIndex - keep + 1;\n\n if (keepBeforeTurnIndex <= 0) {\n return;\n }\n\n await store.prune(ctx.config.name, sessionId, keepBeforeTurnIndex);\n}\n"],"mappings":";;AAKA,MAAa,yBAAyB;;;;;;;AAoBtC,SAAgB,eAAe,MAAkD;CAC/E,IAAI,OAAO,SAAS,UAClB,OAAO,SAAS,oBAAoB,OAAO;CAG7C,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO;CAGT,OAAO;AACT;;;;;;;;;;;;;;;;;;;AAoBA,eAAsB,kBACpB,QAC2B;CAC3B,MAAM,EAAE,KAAK,WAAW,WAAW,OAAO,WAAW,sBAAsB;CAE3E,MAAM,SAA2B;EAC/B,mBAAmB,IAAI,OAAO;EAC9B,YAAY;EACZ,YAAY;EACZ;EACA,YAAY;EACZ,WAAW,IAAI;EACf,SAAS,IAAI,OAAO,WAAW;EAC/B,oBAAoB;EACpB,kBAAkB;EAClB,iBAAiB;EACjB,2BAAU,IAAI,KAAK,EAAC,CAAC,YAAY;CACnC;CAEA,MAAM,IAAI,gBAAgB,KAAK,MAAM;CAErC,IAAI,QAAQ,KAAK,qCAAqC;EACpD;EACA;CACF,CAAC;CAED,MAAM,MAAM,KAAK,WAAW,SAAS;CAErC,OAAO;AACT;;;;;;;;AASA,eAAe,MACb,KACA,WACA,iBACe;CACf,MAAM,OAAO,IAAI,OAAO;CAExB,IAAI,SAAS,OACX;CAGF,MAAM,QAAQ,IAAI;CAQlB,IAAI,OAAO,MAAM,UAAU,YACzB;CAGF,MAAM,sBAAsB,kBAAkB,OAAO;CAErD,IAAI,uBAAuB,GACzB;CAGF,MAAM,MAAM,MAAM,IAAI,OAAO,MAAM,WAAW,mBAAmB;AACnE"}
@@ -1,34 +0,0 @@
1
- import { SupervisorFailedError } from "../errors/supervisor-failed-error.mjs";
2
- import "../errors/index.mjs";
3
-
4
- //#region ../@warlock.js/ai/src/orchestrator/commands.ts
5
- /**
6
- * Build the typed `command(name, args)` dispatcher backing
7
- * {@link import("../contracts/orchestrator/orchestrator.contract").OrchestratorContract.command}
8
- * (design §11). Looks the command up in the supplied handler bag and
9
- * forwards `args`, preserving the discriminated `OrchestratorCommands`
10
- * typing end to end.
11
- *
12
- * v1 ships exactly one built-in command, `compact`. v2 user commands
13
- * attach via module augmentation of `OrchestratorCommands`; the
14
- * dispatcher widens with the map automatically, and an unregistered
15
- * command throws {@link SupervisorFailedError} rather than silently
16
- * resolving `undefined`.
17
- *
18
- * @example
19
- * const command = createCommandDispatcher({
20
- * compact: (args) => runCompaction(args),
21
- * });
22
- * const result = await command("compact", { sessionId, history });
23
- */
24
- function createCommandDispatcher(handlers) {
25
- return function command(name, args) {
26
- const handler = handlers[name];
27
- if (typeof handler !== "function") throw new SupervisorFailedError(`orchestrator.command(): unknown command "${String(name)}"`);
28
- return handler(args);
29
- };
30
- }
31
-
32
- //#endregion
33
- export { createCommandDispatcher };
34
- //# sourceMappingURL=commands.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commands.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/orchestrator/commands.ts"],"sourcesContent":["import type { OrchestratorCommands } from \"../contracts/orchestrator/orchestrator-commands.type\";\nimport { SupervisorFailedError } from \"../errors\";\n\n/**\n * Per-command handler bag — one async runner per key of\n * {@link OrchestratorCommands}. The orchestrator factory supplies the\n * `compact` runner (which delegates to the shared compaction code path,\n * §11) so this module owns command ROUTING only, never the compaction\n * logic itself.\n *\n * Typed against the same discriminated map the public `command<K>`\n * method uses, so a registered handler's `args` / result line up with\n * the contract with no casting at the call site.\n */\nexport type OrchestratorCommandHandlers = {\n [K in keyof OrchestratorCommands]: (\n args: OrchestratorCommands[K][\"args\"],\n ) => Promise<OrchestratorCommands[K][\"result\"]>;\n};\n\n/**\n * Build the typed `command(name, args)` dispatcher backing\n * {@link import(\"../contracts/orchestrator/orchestrator.contract\").OrchestratorContract.command}\n * (design §11). Looks the command up in the supplied handler bag and\n * forwards `args`, preserving the discriminated `OrchestratorCommands`\n * typing end to end.\n *\n * v1 ships exactly one built-in command, `compact`. v2 user commands\n * attach via module augmentation of `OrchestratorCommands`; the\n * dispatcher widens with the map automatically, and an unregistered\n * command throws {@link SupervisorFailedError} rather than silently\n * resolving `undefined`.\n *\n * @example\n * const command = createCommandDispatcher({\n * compact: (args) => runCompaction(args),\n * });\n * const result = await command(\"compact\", { sessionId, history });\n */\nexport function createCommandDispatcher(handlers: OrchestratorCommandHandlers) {\n return function command<K extends keyof OrchestratorCommands>(\n name: K,\n args: OrchestratorCommands[K][\"args\"],\n ): Promise<OrchestratorCommands[K][\"result\"]> {\n const handler = handlers[name];\n\n if (typeof handler !== \"function\") {\n throw new SupervisorFailedError(\n `orchestrator.command(): unknown command \"${String(name)}\"`,\n );\n }\n\n return handler(args);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBAAwB,UAAuC;CAC7E,OAAO,SAAS,QACd,MACA,MAC4C;EAC5C,MAAM,UAAU,SAAS;EAEzB,IAAI,OAAO,YAAY,YACrB,MAAM,IAAI,sBACR,4CAA4C,OAAO,IAAI,EAAE,EAC3D;EAGF,OAAO,QAAQ,IAAI;CACrB;AACF"}
@@ -1,206 +0,0 @@
1
- import { DEFAULT_LOCK_MAX_WAIT } from "./lock.mjs";
2
-
3
- //#region ../@warlock.js/ai/src/orchestrator/compaction.ts
4
- /**
5
- * Most-recent messages kept verbatim when `summarize.keep` is omitted.
6
- * Defaulting to 0 would compact the entire history into one memo (losing
7
- * the live tail every turn), so the object form keeps a small recent
8
- * window by default — matching the canonical doc examples (`keep: 8`).
9
- */
10
- const DEFAULT_COMPACTION_KEEP = 8;
11
- /** Whether the configured `summarize` is the fully-pluggable callback form. */
12
- function isCallbackForm(summarize) {
13
- return typeof summarize === "function";
14
- }
15
- /**
16
- * Decide whether Phase 7 compaction should fire this turn (orchestrator
17
- * .md §4 Phase 7 / §12.1). v1 trigger is count-based:
18
- * `summarize.afterTurns` fires once `turnIndex >= afterTurns`. The
19
- * callback form has no threshold and never auto-fires — it is driven
20
- * exclusively by `command("compact")` (the manual path). Returns false
21
- * when `summarize` is unset.
22
- */
23
- function shouldCompact(ctx, turnIndex) {
24
- const summarize = ctx.config.summarize;
25
- if (summarize === void 0 || isCallbackForm(summarize)) return false;
26
- const afterTurns = summarize.afterTurns;
27
- return afterTurns !== void 0 && turnIndex >= afterTurns;
28
- }
29
- /**
30
- * Run the configured summarizer against the session history and build
31
- * a {@link CompactionResult} (§12.2 step 2–3). Three resolution paths:
32
- *
33
- * - callback form — `summarize(history)` returns the result directly.
34
- * - config + `summarizer` model — summarize the slice (history minus
35
- * the most-recent `keep`) into one synthetic memo turn.
36
- * - config without a `summarizer` — produce a trivial degenerate memo
37
- * (no model available); the dev is expected to supply a summarizer
38
- * for real compaction. The range still reflects the kept tail.
39
- */
40
- async function produceCompaction(summarize, history) {
41
- if (isCallbackForm(summarize)) return summarize(history);
42
- const keep = summarize.keep ?? 8;
43
- const replacesFromIndex = 0;
44
- const replacesToIndex = Math.max(-1, history.length - keep - 1);
45
- return {
46
- summary: {
47
- role: "system",
48
- content: await summarizeSlice(summarize, history.slice(0, replacesToIndex + 1))
49
- },
50
- replacesFromIndex,
51
- replacesToIndex
52
- };
53
- }
54
- /**
55
- * Summarize a slice of history into text. Uses the configured
56
- * `summarizer` model when present (a single non-streaming completion);
57
- * otherwise returns a placeholder memo. The summarizer is intentionally
58
- * the cheap model — never the specialists (§12.4).
59
- */
60
- async function summarizeSlice(summarize, slice) {
61
- if (slice.length === 0) return "";
62
- if (!summarize.summarizer) return `Summary of ${slice.length} prior message(s).`;
63
- const transcript = slice.map((message) => `${message.role}: ${stringifyContent(message.content)}`).join("\n");
64
- return (await summarize.summarizer.complete([{
65
- role: "system",
66
- content: "Summarize the following conversation slice into a concise memo that preserves the facts, decisions, and open threads a later turn would need. Reply with the memo only."
67
- }, {
68
- role: "user",
69
- content: transcript
70
- }])).content;
71
- }
72
- /** Coerce a message's content into a flat string for the summarizer prompt. */
73
- function stringifyContent(content) {
74
- if (typeof content === "string") return content;
75
- return JSON.stringify(content);
76
- }
77
- /**
78
- * Phase 7 — post-turn compaction (orchestrator.md §3 / §4 Phase 7 /
79
- * §12.2). Runs AFTER the turn settles; never blocks the caller's
80
- * resolution path beyond this phase.
81
- *
82
- * Acquires the cooperative session lock (writes `lock_acquired_at` /
83
- * `lock_expires_at` onto a fresh row), runs the summarizer, builds the
84
- * compaction, then either invokes `summarize.onCompact` (framework-
85
- * driven apply) or surfaces the compaction on the result for the dev to
86
- * apply. Releases the lock on settle. Emits
87
- * `orchestrator.compaction.suggested` always,
88
- * `orchestrator.compaction.applied` only when `onCompact` succeeded, and
89
- * `orchestrator.compaction.failed` (carrying the thrown `error` and the
90
- * `phase` that failed) when the summarizer or `onCompact` throws.
91
- *
92
- * Retry policy is skip-and-log (§4 Phase 7): a summarizer failure
93
- * leaves the session running with unchanged history — the engine
94
- * treats a thrown summarizer / `onCompact` as "no compaction this
95
- * turn", emits `orchestrator.compaction.failed`, and returns `undefined`
96
- * (summarizer) or surfaces the unapplied compaction (`onCompact`).
97
- */
98
- async function runCompaction(ctx, sessionId, history) {
99
- const summarize = ctx.config.summarize;
100
- if (summarize === void 0) return;
101
- await acquireCompactionLock(ctx, sessionId);
102
- try {
103
- const compaction = await produceCompaction(summarize, history);
104
- ctx.emitter.emit("orchestrator.compaction.suggested", {
105
- sessionId,
106
- compaction
107
- });
108
- const onCompact = isCallbackForm(summarize) ? void 0 : summarize.onCompact;
109
- if (!onCompact) return {
110
- compaction,
111
- applied: false
112
- };
113
- try {
114
- await onCompact(compaction, { sessionId });
115
- ctx.emitter.emit("orchestrator.compaction.applied", {
116
- sessionId,
117
- compaction
118
- });
119
- return {
120
- compaction,
121
- applied: true
122
- };
123
- } catch (error) {
124
- ctx.emitter.emit("orchestrator.compaction.failed", {
125
- sessionId,
126
- phase: "onCompact",
127
- error
128
- });
129
- return {
130
- compaction,
131
- applied: false
132
- };
133
- }
134
- } catch (error) {
135
- ctx.emitter.emit("orchestrator.compaction.failed", {
136
- sessionId,
137
- phase: "summarize",
138
- error
139
- });
140
- return;
141
- } finally {
142
- await releaseCompactionLock(ctx, sessionId);
143
- }
144
- }
145
- /**
146
- * Run a manual compaction for `command("compact", ...)` (§11 / §12.1).
147
- * Same code path as the post-turn trigger but driven on demand against
148
- * the supplied history, returning the raw {@link CompactionResult}. The
149
- * callback form is honored; the config form without a `summarizer`
150
- * produces the degenerate memo. Does not apply `onCompact` — the
151
- * command surface returns the compaction for the caller to handle.
152
- */
153
- async function runManualCompaction(ctx, history) {
154
- const summarize = ctx.config.summarize;
155
- if (summarize === void 0) return {
156
- summary: {
157
- role: "system",
158
- content: `Summary of ${history.length} message(s).`
159
- },
160
- replacesFromIndex: 0,
161
- replacesToIndex: Math.max(-1, history.length - 1)
162
- };
163
- return produceCompaction(summarize, history);
164
- }
165
- /** Resolve the lock TTL from the summarize config (config form only). */
166
- function resolveLockMaxWait(ctx) {
167
- const summarize = ctx.config.summarize;
168
- if (summarize === void 0 || isCallbackForm(summarize)) return DEFAULT_LOCK_MAX_WAIT;
169
- return summarize.lock?.maxWait ?? 3e4;
170
- }
171
- /**
172
- * Write the cooperative compaction lock onto a fresh checkpoint row
173
- * (§12.2 step 1). The lock lives on the latest persisted row; we load
174
- * it, stamp the lock columns, and re-save (append-only) so the next
175
- * turn's Phase 3 observes it.
176
- */
177
- async function acquireCompactionLock(ctx, sessionId) {
178
- const latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);
179
- if (!latest) return;
180
- const now = Date.now();
181
- const maxWait = resolveLockMaxWait(ctx);
182
- await ctx.checkpointStore.save({
183
- ...latest,
184
- lock_acquired_at: new Date(now).toISOString(),
185
- lock_expires_at: new Date(now + maxWait).toISOString(),
186
- saved_at: new Date(now).toISOString()
187
- });
188
- }
189
- /**
190
- * Clear the compaction lock columns (§12.2 step 6) by re-saving the
191
- * latest row with the lock fields nulled.
192
- */
193
- async function releaseCompactionLock(ctx, sessionId) {
194
- const latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);
195
- if (!latest) return;
196
- await ctx.checkpointStore.save({
197
- ...latest,
198
- lock_acquired_at: null,
199
- lock_expires_at: null,
200
- saved_at: (/* @__PURE__ */ new Date()).toISOString()
201
- });
202
- }
203
-
204
- //#endregion
205
- export { runCompaction, runManualCompaction, shouldCompact };
206
- //# sourceMappingURL=compaction.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compaction.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/orchestrator/compaction.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type {\n SummarizeCallback,\n SummarizeConfig,\n} from \"../contracts/orchestrator/orchestrator-config.type\";\nimport type { CompactionResult } from \"../contracts/result/orchestrator-result.type\";\nimport type { OrchestratorEngineContext } from \"./engine-context.type\";\nimport { DEFAULT_LOCK_MAX_WAIT } from \"./lock\";\n\n/**\n * Most-recent messages kept verbatim when `summarize.keep` is omitted.\n * Defaulting to 0 would compact the entire history into one memo (losing\n * the live tail every turn), so the object form keeps a small recent\n * window by default — matching the canonical doc examples (`keep: 8`).\n */\nexport const DEFAULT_COMPACTION_KEEP = 8;\n\n/** Whether the configured `summarize` is the fully-pluggable callback form. */\nfunction isCallbackForm(\n summarize: SummarizeConfig | SummarizeCallback | undefined,\n): summarize is SummarizeCallback {\n return typeof summarize === \"function\";\n}\n\n/**\n * Decide whether Phase 7 compaction should fire this turn (orchestrator\n * .md §4 Phase 7 / §12.1). v1 trigger is count-based:\n * `summarize.afterTurns` fires once `turnIndex >= afterTurns`. The\n * callback form has no threshold and never auto-fires — it is driven\n * exclusively by `command(\"compact\")` (the manual path). Returns false\n * when `summarize` is unset.\n */\nexport function shouldCompact(\n ctx: OrchestratorEngineContext,\n turnIndex: number,\n): boolean {\n const summarize = ctx.config.summarize;\n\n if (summarize === undefined || isCallbackForm(summarize)) {\n return false;\n }\n\n const afterTurns = summarize.afterTurns;\n\n return afterTurns !== undefined && turnIndex >= afterTurns;\n}\n\n/** Result of a Phase-7 run — what the engine folds into the turn. */\nexport type CompactionOutcome = {\n /** The produced compaction, surfaced on `result.compaction`. */\n compaction: CompactionResult;\n /**\n * Whether `summarize.onCompact` ran AND succeeded — when true the\n * engine advances `summarized_through` to `replacesToIndex` (§12.2\n * step 4); when false it leaves it unchanged (§12.2 step 5).\n */\n applied: boolean;\n};\n\n/**\n * Run the configured summarizer against the session history and build\n * a {@link CompactionResult} (§12.2 step 2–3). Three resolution paths:\n *\n * - callback form — `summarize(history)` returns the result directly.\n * - config + `summarizer` model — summarize the slice (history minus\n * the most-recent `keep`) into one synthetic memo turn.\n * - config without a `summarizer` — produce a trivial degenerate memo\n * (no model available); the dev is expected to supply a summarizer\n * for real compaction. The range still reflects the kept tail.\n */\nasync function produceCompaction(\n summarize: SummarizeConfig | SummarizeCallback,\n history: Message[],\n): Promise<CompactionResult> {\n if (isCallbackForm(summarize)) {\n return summarize(history);\n }\n\n const keep = summarize.keep ?? DEFAULT_COMPACTION_KEEP;\n const replacesFromIndex = 0;\n const replacesToIndex = Math.max(-1, history.length - keep - 1);\n const slice = history.slice(0, replacesToIndex + 1);\n\n const summaryText = await summarizeSlice(summarize, slice);\n\n return {\n summary: { role: \"system\", content: summaryText },\n replacesFromIndex,\n replacesToIndex,\n };\n}\n\n/**\n * Summarize a slice of history into text. Uses the configured\n * `summarizer` model when present (a single non-streaming completion);\n * otherwise returns a placeholder memo. The summarizer is intentionally\n * the cheap model — never the specialists (§12.4).\n */\nasync function summarizeSlice(\n summarize: SummarizeConfig,\n slice: Message[],\n): Promise<string> {\n if (slice.length === 0) {\n return \"\";\n }\n\n if (!summarize.summarizer) {\n return `Summary of ${slice.length} prior message(s).`;\n }\n\n const transcript = slice\n .map((message) => `${message.role}: ${stringifyContent(message.content)}`)\n .join(\"\\n\");\n\n const response = await summarize.summarizer.complete([\n {\n role: \"system\",\n content:\n \"Summarize the following conversation slice into a concise memo \" +\n \"that preserves the facts, decisions, and open threads a later \" +\n \"turn would need. Reply with the memo only.\",\n },\n { role: \"user\", content: transcript },\n ]);\n\n return response.content;\n}\n\n/** Coerce a message's content into a flat string for the summarizer prompt. */\nfunction stringifyContent(content: Message[\"content\"]): string {\n if (typeof content === \"string\") {\n return content;\n }\n\n return JSON.stringify(content);\n}\n\n/**\n * Phase 7 — post-turn compaction (orchestrator.md §3 / §4 Phase 7 /\n * §12.2). Runs AFTER the turn settles; never blocks the caller's\n * resolution path beyond this phase.\n *\n * Acquires the cooperative session lock (writes `lock_acquired_at` /\n * `lock_expires_at` onto a fresh row), runs the summarizer, builds the\n * compaction, then either invokes `summarize.onCompact` (framework-\n * driven apply) or surfaces the compaction on the result for the dev to\n * apply. Releases the lock on settle. Emits\n * `orchestrator.compaction.suggested` always,\n * `orchestrator.compaction.applied` only when `onCompact` succeeded, and\n * `orchestrator.compaction.failed` (carrying the thrown `error` and the\n * `phase` that failed) when the summarizer or `onCompact` throws.\n *\n * Retry policy is skip-and-log (§4 Phase 7): a summarizer failure\n * leaves the session running with unchanged history — the engine\n * treats a thrown summarizer / `onCompact` as \"no compaction this\n * turn\", emits `orchestrator.compaction.failed`, and returns `undefined`\n * (summarizer) or surfaces the unapplied compaction (`onCompact`).\n */\nexport async function runCompaction<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n history: Message[],\n): Promise<CompactionOutcome | undefined> {\n const summarize = ctx.config.summarize;\n\n if (summarize === undefined) {\n return undefined;\n }\n\n await acquireCompactionLock(ctx, sessionId);\n\n try {\n const compaction = await produceCompaction(summarize, history);\n\n ctx.emitter.emit(\"orchestrator.compaction.suggested\", {\n sessionId,\n compaction,\n });\n\n const onCompact = isCallbackForm(summarize) ? undefined : summarize.onCompact;\n\n if (!onCompact) {\n return { compaction, applied: false };\n }\n\n try {\n await onCompact(compaction, { sessionId });\n\n ctx.emitter.emit(\"orchestrator.compaction.applied\", {\n sessionId,\n compaction,\n });\n\n return { compaction, applied: true };\n } catch (error) {\n // onCompact threw — surface the compaction for the dev to apply,\n // leave summarized_through unchanged (§12.2 step 4 failure path).\n ctx.emitter.emit(\"orchestrator.compaction.failed\", {\n sessionId,\n phase: \"onCompact\",\n error,\n });\n\n return { compaction, applied: false };\n }\n } catch (error) {\n // Summarizer failed — skip-and-log; session keeps running unchanged.\n ctx.emitter.emit(\"orchestrator.compaction.failed\", {\n sessionId,\n phase: \"summarize\",\n error,\n });\n\n return undefined;\n } finally {\n await releaseCompactionLock(ctx, sessionId);\n }\n}\n\n/**\n * Run a manual compaction for `command(\"compact\", ...)` (§11 / §12.1).\n * Same code path as the post-turn trigger but driven on demand against\n * the supplied history, returning the raw {@link CompactionResult}. The\n * callback form is honored; the config form without a `summarizer`\n * produces the degenerate memo. Does not apply `onCompact` — the\n * command surface returns the compaction for the caller to handle.\n */\nexport async function runManualCompaction<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n history: Message[],\n): Promise<CompactionResult> {\n const summarize = ctx.config.summarize;\n\n if (summarize === undefined) {\n // No summarize policy configured — produce a degenerate memo over\n // the full supplied history so the command always resolves.\n return {\n summary: { role: \"system\", content: `Summary of ${history.length} message(s).` },\n replacesFromIndex: 0,\n replacesToIndex: Math.max(-1, history.length - 1),\n };\n }\n\n return produceCompaction(summarize, history);\n}\n\n/** Resolve the lock TTL from the summarize config (config form only). */\nfunction resolveLockMaxWait(ctx: OrchestratorEngineContext): number {\n const summarize = ctx.config.summarize;\n\n if (summarize === undefined || isCallbackForm(summarize)) {\n return DEFAULT_LOCK_MAX_WAIT;\n }\n\n return summarize.lock?.maxWait ?? DEFAULT_LOCK_MAX_WAIT;\n}\n\n/**\n * Write the cooperative compaction lock onto a fresh checkpoint row\n * (§12.2 step 1). The lock lives on the latest persisted row; we load\n * it, stamp the lock columns, and re-save (append-only) so the next\n * turn's Phase 3 observes it.\n */\nasync function acquireCompactionLock<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n): Promise<void> {\n const latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);\n\n if (!latest) {\n return;\n }\n\n const now = Date.now();\n const maxWait = resolveLockMaxWait(ctx as OrchestratorEngineContext);\n\n await ctx.checkpointStore.save({\n ...latest,\n lock_acquired_at: new Date(now).toISOString(),\n lock_expires_at: new Date(now + maxWait).toISOString(),\n saved_at: new Date(now).toISOString(),\n });\n}\n\n/**\n * Clear the compaction lock columns (§12.2 step 6) by re-saving the\n * latest row with the lock fields nulled.\n */\nasync function releaseCompactionLock<TState>(\n ctx: OrchestratorEngineContext<unknown, TState>,\n sessionId: string,\n): Promise<void> {\n const latest = await ctx.checkpointStore.load(ctx.config.name, sessionId);\n\n if (!latest) {\n return;\n }\n\n await ctx.checkpointStore.save({\n ...latest,\n lock_acquired_at: null,\n lock_expires_at: null,\n saved_at: new Date().toISOString(),\n });\n}\n"],"mappings":";;;;;;;;;AAeA,MAAa,0BAA0B;;AAGvC,SAAS,eACP,WACgC;CAChC,OAAO,OAAO,cAAc;AAC9B;;;;;;;;;AAUA,SAAgB,cACd,KACA,WACS;CACT,MAAM,YAAY,IAAI,OAAO;CAE7B,IAAI,cAAc,UAAa,eAAe,SAAS,GACrD,OAAO;CAGT,MAAM,aAAa,UAAU;CAE7B,OAAO,eAAe,UAAa,aAAa;AAClD;;;;;;;;;;;;AAyBA,eAAe,kBACb,WACA,SAC2B;CAC3B,IAAI,eAAe,SAAS,GAC1B,OAAO,UAAU,OAAO;CAG1B,MAAM,OAAO,UAAU;CACvB,MAAM,oBAAoB;CAC1B,MAAM,kBAAkB,KAAK,IAAI,IAAI,QAAQ,SAAS,OAAO,CAAC;CAK9D,OAAO;EACL,SAAS;GAAE,MAAM;GAAU,SAAS,MAHZ,eAAe,WAF3B,QAAQ,MAAM,GAAG,kBAAkB,CAEO,CAAC;EAGP;EAChD;EACA;CACF;AACF;;;;;;;AAQA,eAAe,eACb,WACA,OACiB;CACjB,IAAI,MAAM,WAAW,GACnB,OAAO;CAGT,IAAI,CAAC,UAAU,YACb,OAAO,cAAc,MAAM,OAAO;CAGpC,MAAM,aAAa,MAChB,KAAK,YAAY,GAAG,QAAQ,KAAK,IAAI,iBAAiB,QAAQ,OAAO,GAAG,CAAC,CACzE,KAAK,IAAI;CAaZ,QAAO,MAXgB,UAAU,WAAW,SAAS,CACnD;EACE,MAAM;EACN,SACE;CAGJ,GACA;EAAE,MAAM;EAAQ,SAAS;CAAW,CACtC,CAAC,EAEc,CAAC;AAClB;;AAGA,SAAS,iBAAiB,SAAqC;CAC7D,IAAI,OAAO,YAAY,UACrB,OAAO;CAGT,OAAO,KAAK,UAAU,OAAO;AAC/B;;;;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,cACpB,KACA,WACA,SACwC;CACxC,MAAM,YAAY,IAAI,OAAO;CAE7B,IAAI,cAAc,QAChB;CAGF,MAAM,sBAAsB,KAAK,SAAS;CAE1C,IAAI;EACF,MAAM,aAAa,MAAM,kBAAkB,WAAW,OAAO;EAE7D,IAAI,QAAQ,KAAK,qCAAqC;GACpD;GACA;EACF,CAAC;EAED,MAAM,YAAY,eAAe,SAAS,IAAI,SAAY,UAAU;EAEpE,IAAI,CAAC,WACH,OAAO;GAAE;GAAY,SAAS;EAAM;EAGtC,IAAI;GACF,MAAM,UAAU,YAAY,EAAE,UAAU,CAAC;GAEzC,IAAI,QAAQ,KAAK,mCAAmC;IAClD;IACA;GACF,CAAC;GAED,OAAO;IAAE;IAAY,SAAS;GAAK;EACrC,SAAS,OAAO;GAGd,IAAI,QAAQ,KAAK,kCAAkC;IACjD;IACA,OAAO;IACP;GACF,CAAC;GAED,OAAO;IAAE;IAAY,SAAS;GAAM;EACtC;CACF,SAAS,OAAO;EAEd,IAAI,QAAQ,KAAK,kCAAkC;GACjD;GACA,OAAO;GACP;EACF,CAAC;EAED;CACF,UAAU;EACR,MAAM,sBAAsB,KAAK,SAAS;CAC5C;AACF;;;;;;;;;AAUA,eAAsB,oBACpB,KACA,SAC2B;CAC3B,MAAM,YAAY,IAAI,OAAO;CAE7B,IAAI,cAAc,QAGhB,OAAO;EACL,SAAS;GAAE,MAAM;GAAU,SAAS,cAAc,QAAQ,OAAO;EAAc;EAC/E,mBAAmB;EACnB,iBAAiB,KAAK,IAAI,IAAI,QAAQ,SAAS,CAAC;CAClD;CAGF,OAAO,kBAAkB,WAAW,OAAO;AAC7C;;AAGA,SAAS,mBAAmB,KAAwC;CAClE,MAAM,YAAY,IAAI,OAAO;CAE7B,IAAI,cAAc,UAAa,eAAe,SAAS,GACrD,OAAO;CAGT,OAAO,UAAU,MAAM;AACzB;;;;;;;AAQA,eAAe,sBACb,KACA,WACe;CACf,MAAM,SAAS,MAAM,IAAI,gBAAgB,KAAK,IAAI,OAAO,MAAM,SAAS;CAExE,IAAI,CAAC,QACH;CAGF,MAAM,MAAM,KAAK,IAAI;CACrB,MAAM,UAAU,mBAAmB,GAAgC;CAEnE,MAAM,IAAI,gBAAgB,KAAK;EAC7B,GAAG;EACH,kBAAkB,IAAI,KAAK,GAAG,CAAC,CAAC,YAAY;EAC5C,iBAAiB,IAAI,KAAK,MAAM,OAAO,CAAC,CAAC,YAAY;EACrD,UAAU,IAAI,KAAK,GAAG,CAAC,CAAC,YAAY;CACtC,CAAC;AACH;;;;;AAMA,eAAe,sBACb,KACA,WACe;CACf,MAAM,SAAS,MAAM,IAAI,gBAAgB,KAAK,IAAI,OAAO,MAAM,SAAS;CAExE,IAAI,CAAC,QACH;CAGF,MAAM,IAAI,gBAAgB,KAAK;EAC7B,GAAG;EACH,kBAAkB;EAClB,iBAAiB;EACjB,2BAAU,IAAI,KAAK,EAAC,CAAC,YAAY;CACnC,CAAC;AACH"}
@@ -1,171 +0,0 @@
1
- import { supervisor } from "../supervisor/supervisor.mjs";
2
-
3
- //#region ../@warlock.js/ai/src/orchestrator/dispatch.ts
4
- /**
5
- * Derive the deterministic supervisor `runId` for an `iterate: true`
6
- * turn (orchestrator.md §5 Phase 5 / §10.2 / §18.7):
7
- * `${sessionId}.${version ?? "unversioned"}.${turnIndex}`. No base64,
8
- * no hashing — the `sessionId` is the dev's responsibility to make
9
- * unique. Deploying a new `version` cleanly partitions in-flight runs
10
- * across deploys so old runIds never collide with new ones.
11
- */
12
- function deriveRunId(sessionId, version, turnIndex) {
13
- return `${sessionId}.${version ?? "unversioned"}.${turnIndex}`;
14
- }
15
- /**
16
- * Build the internal supervisor config by spreading the orchestrator's
17
- * supervisor-surface fields (orchestrator.md §1 / §5 Phase 5) and
18
- * seeding `state` from the session-state seed.
19
- *
20
- * `iterate: false` caps `maxIterations` at 1 — a single dispatch per
21
- * turn ("the supervisor's Phase A + Phase B once, no iteration loop" —
22
- * §5). `iterate: true` keeps the configured `maxIterations` (default
23
- * 10) and wires the `snapshotStore` for mid-turn resume.
24
- *
25
- * The orchestrator DELEGATES to the existing supervisor — it never
26
- * reimplements dispatch / route / evaluate / strip-merge logic.
27
- */
28
- function buildSupervisorConfig(ctx, seedState, iterate, snapshotStore) {
29
- const config = ctx.config;
30
- return {
31
- name: config.name,
32
- version: config.version,
33
- systemPrompt: config.systemPrompt,
34
- intents: config.intents,
35
- route: config.route,
36
- router: config.router,
37
- evaluate: config.evaluate,
38
- state: seedState,
39
- output: config.output,
40
- initialAgent: config.initialAgent,
41
- maxIterations: iterate ? config.maxIterations : 1,
42
- historyWindow: config.historyWindow ? {
43
- router: toNumber(config.historyWindow.router),
44
- agents: toNumber(config.historyWindow.agents)
45
- } : void 0,
46
- snapshotStore: iterate ? snapshotStore : void 0
47
- };
48
- }
49
- /**
50
- * The supervisor's `historyWindow` tiers accept only numbers; the
51
- * orchestrator's accept a number OR a slicer callback. The callback
52
- * form is already applied at the orchestrator level (Phase 4), so any
53
- * non-number here has already done its slicing — drop it for the
54
- * supervisor (which sees the pre-sliced history) by returning
55
- * `undefined`.
56
- */
57
- function toNumber(value) {
58
- return typeof value === "number" ? value : void 0;
59
- }
60
- /**
61
- * Build the forensic {@link TurnSnapshot} for the dispatched turn from
62
- * the supervisor's result. Mirrors the supervisor's `IterationSnapshot`
63
- * shape (§15.5) so a turn reads uniformly whether one agent ran
64
- * (`iterate: false`) or the internal supervisor iterated
65
- * (`iterate: true`). The terminal iteration's branch records and
66
- * decision are lifted onto the turn; the supervisor's full report tree
67
- * becomes the turn's `childReport`.
68
- */
69
- function buildTurnSnapshot(input, turnIndex, result, state) {
70
- const report = result.report;
71
- const snapshots = report.snapshots;
72
- const terminal = snapshots.length > 0 ? snapshots[snapshots.length - 1] : void 0;
73
- const decisionSource = mapDecisionSource(terminal?.decision.source);
74
- return Object.freeze({
75
- turn: turnIndex,
76
- input,
77
- decision: {
78
- source: decisionSource,
79
- raw: terminal?.decision.next ?? null,
80
- reasoning: terminal?.decision.reasoning
81
- },
82
- result: terminal?.result ?? {},
83
- state,
84
- evaluate: terminal?.evaluateVerdict,
85
- startedAt: report.startedAt,
86
- endedAt: report.endedAt,
87
- duration: report.duration,
88
- usage: report.usage,
89
- childReport: report
90
- });
91
- }
92
- /**
93
- * Map the supervisor's `DecisionSource` onto the narrower turn-snapshot
94
- * decision source (§15.5 — `"route" | "router" | "intent.next"`). The
95
- * supervisor's `initialAgent` / `classifier` first-turn sources collapse
96
- * to `"intent.next"` (a non-route/router origin) at the orchestrator
97
- * layer, which only distinguishes the three coarse decision origins.
98
- */
99
- function mapDecisionSource(source) {
100
- if (source === "route" || source === "router") return source;
101
- return "intent.next";
102
- }
103
- /**
104
- * Phase 5 — dispatch turn (orchestrator.md §3 / §4 Phase 5).
105
- *
106
- * Constructs a fresh internal supervisor seeded from the session state,
107
- * then:
108
- *
109
- * - `iterate: false` — runs a single dispatch (`maxIterations: 1`).
110
- * - `iterate: true` — runs the full supervisor with a deterministic
111
- * `runId`, resuming an in-flight run when the `SnapshotStore` already
112
- * has one for that `runId` (§5 step 5).
113
- *
114
- * The supervisor's final state replaces the session state (§5 — replace
115
- * semantics). The supervisor is never kept alive across turns
116
- * (single-call lifecycle invariant — §18.8).
117
- */
118
- async function dispatchTurn(params) {
119
- const { ctx, sessionId, input, seedState, turnIndex, history, context, signal } = params;
120
- const iterate = ctx.config.iterate === true;
121
- const sup = supervisor(buildSupervisorConfig(ctx, seedState, iterate, ctx.snapshotStore));
122
- let result;
123
- if (iterate) {
124
- const runId = deriveRunId(sessionId, ctx.config.version, turnIndex);
125
- const inFlight = ctx.snapshotStore ? await ctx.snapshotStore.load(runId) : void 0;
126
- if (inFlight && inFlight.status === "running") result = await sup.resume(runId, {
127
- context,
128
- signal,
129
- history,
130
- sessionId
131
- });
132
- else result = await sup.execute(input, {
133
- runId,
134
- context,
135
- signal,
136
- history,
137
- sessionId
138
- });
139
- } else result = await sup.execute(input, {
140
- context,
141
- signal,
142
- history,
143
- sessionId
144
- });
145
- const state = deriveFinalState(result, seedState);
146
- const turnSnapshot = buildTurnSnapshot(input, turnIndex, result, state);
147
- return {
148
- result,
149
- state,
150
- turnSnapshot
151
- };
152
- }
153
- /**
154
- * Derive the post-turn session state from the supervisor result.
155
- * Prefers the terminal iteration's accumulated `state`; falls back to
156
- * the validated `data` (when an `output` schema reshaped it), then to
157
- * the seed when the run produced neither (e.g. it terminated before
158
- * dispatching anything). Replace semantics — the supervisor is the
159
- * authority on state evolution within its loop (§5).
160
- */
161
- function deriveFinalState(result, seedState) {
162
- const snapshots = result.report.snapshots;
163
- const terminal = snapshots.length > 0 ? snapshots[snapshots.length - 1] : void 0;
164
- if (terminal && terminal.state !== void 0) return terminal.state;
165
- if (result.data !== void 0) return result.data;
166
- return seedState;
167
- }
168
-
169
- //#endregion
170
- export { deriveRunId, dispatchTurn };
171
- //# sourceMappingURL=dispatch.mjs.map