@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 +0,0 @@
1
- {"version":3,"file":"human-approval.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/human-approval.ts"],"sourcesContent":["import type { AgentMiddleware } from \"../contracts/middleware/middleware.contract\";\nimport type { MiddlewareToolContext } from \"../contracts/middleware/middleware-context.type\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\nimport type { Usage } from \"../contracts/result/usage.type\";\nimport type { AIError } from \"../errors/ai-error\";\nimport type { ToolInvokeResult } from \"../tool/tool\";\nimport { generateRunId } from \"../utils/generate-run-id\";\nimport type {\n ApprovalDecision,\n ApprovalRequest,\n HumanApprovalOptions,\n PolicyContext,\n} from \"./contracts\";\nimport { ApprovalRejectedError, InterruptSuspendedError } from \"./errors\";\nimport { evaluatePolicy } from \"./policy\";\nimport { takeSeededDecision } from \"./resume-seed\";\n\n/** Default middleware name when {@link HumanApprovalOptions.name} is omitted. */\nconst DEFAULT_NAME = \"human-approval\";\n\n/** Zero usage for a synthetic, no-LLM-spend short-circuit result. */\nconst ZERO_USAGE: Usage = Object.freeze({ input: 0, output: 0, total: 0 });\n\n/**\n * Mutable view of {@link MiddlewareToolContext.request} used only to\n * apply an `edit` decision. The context types `request.input` as\n * `readonly`, but the agent dispatch reads `request.input` (the SAME\n * object) when it invokes the real tool *after* the `tool.before`\n * pipeline returns — so reassigning it here is how an edited-args\n * decision reaches the tool. This narrow local type makes that one\n * deliberate write explicit instead of casting away the whole context.\n */\ninterface MutableToolRequest {\n input: unknown;\n}\n\n/**\n * Derive the read-only {@link PolicyContext} the policy + request are\n * built from out of the wrapping {@link MiddlewareToolContext}.\n */\nfunction toPolicyContext(ctx: MiddlewareToolContext): PolicyContext {\n return {\n toolName: ctx.tool.name,\n toolDescription: ctx.tool.description,\n args: ctx.request.input,\n agentName: ctx.agent.name,\n tripIndex: ctx.tripIndex,\n sessionId: ctx.options?.sessionId,\n };\n}\n\n/**\n * Generate a stable, unique id for a pending interrupt. Shaped\n * `${agentName}.${sessionId ?? \"nosession\"}.${tripIndex}.${random}` so a\n * reviewer can eyeball the originating run, while the trailing random\n * segment guarantees per-call uniqueness even within one trip.\n */\nfunction makeInterruptId(ctx: MiddlewareToolContext): string {\n const session = ctx.options?.sessionId ?? \"nosession\";\n const random = generateRunId(\"interrupt\");\n\n return `${ctx.agent.name}.${session}.${ctx.tripIndex}.${random}`;\n}\n\n/**\n * Build the {@link ApprovalRequest} a human rules on, from the tool\n * context and the policy-derived tags.\n */\nfunction buildRequest(\n ctx: MiddlewareToolContext,\n interruptId: string,\n tags: string[] | undefined,\n): ApprovalRequest {\n return {\n interruptId,\n toolName: ctx.tool.name,\n toolDescription: ctx.tool.description,\n args: ctx.request.input,\n context: {\n agentName: ctx.agent.name,\n tripIndex: ctx.tripIndex,\n sessionId: ctx.options?.sessionId,\n originalInput: ctx.input,\n ...(tags ? { tags } : {}),\n },\n requestedAt: new Date().toISOString(),\n };\n}\n\n/**\n * Synthesize a failed {@link ToolInvokeResult} carrying a typed error.\n *\n * The approval middleware returns this from `tool.before` to\n * **short-circuit** the real tool without throwing: the pipeline treats a\n * defined return as the tool's result, the agent records a failed\n * `ToolCall`, and the model sees `{ error }` on the next trip — exactly\n * the existing tool-error feedback path. Used for both `reject`\n * (`ApprovalRejectedError`) and durable suspend (`InterruptSuspendedError`).\n */\nfunction failedResult(error: AIError, toolName: string): ToolInvokeResult<unknown> {\n const runId = generateRunId(\"tool\");\n const nowIso = new Date().toISOString();\n\n const report: BaseReport = {\n runId,\n rootRunId: runId,\n name: toolName,\n type: \"tool\",\n status: \"failed\",\n startedAt: nowIso,\n endedAt: nowIso,\n duration: 0,\n usage: ZERO_USAGE,\n children: [],\n };\n\n return { error, usage: ZERO_USAGE, report };\n}\n\n/**\n * Human-in-the-loop approval gate for an agent's tool calls — the\n * middleware behind `ai.human.approval(options)`.\n *\n * **Role.** Pauses *before a specific tool call* and routes it to a human\n * who can **approve** (run the real tool unchanged), **reject** (the model\n * sees a typed error and self-corrects), or **edit** (run the tool with\n * reviewer-replaced args). The dangerous subset is chosen by an\n * {@link import(\"./contracts\").InterruptPolicy} (allowlist / denylist /\n * predicate); every other call passes through untouched.\n *\n * **One hook.** Declares only `tool.before`. On each tool dispatch it:\n * 1. evaluates the policy — not gated → returns `void`, the real tool runs;\n * 2. for a gated call, builds an {@link ApprovalRequest} and calls the\n * {@link import(\"./contracts\").ApprovalHandler};\n * 3. applies the returned {@link ApprovalDecision}:\n * - `approve` → returns `void`, the real tool runs;\n * - `reject` → short-circuits a failed `ToolInvokeResult` carrying an\n * {@link ApprovalRejectedError} (the reviewer's `reason` reaches the\n * model);\n * - `edit` → rewrites `ctx.request.input` to the reviewer's args and\n * returns `void`, so the real tool runs with the edited args (schema\n * validation still applies — bad edits surface as a tool error).\n *\n * **Durable mode.** When a `store` is configured and the handler throws\n * {@link InterruptSuspendedError} (after persisting the interrupt\n * out-of-band), the middleware catches its **own** sentinel and\n * short-circuits a failed result carrying it — so the caller reads\n * `result.error.interruptId` and later calls\n * `ai.human.resume(interruptId, decision)`. The middleware **never throws\n * out of the pipeline**: every outcome (skip, approve, reject, edit,\n * suspend) returns normally; only a *handler bug* (a non-sentinel throw)\n * propagates, and even then the agent dispatch funnels it onto\n * `result.error` — `execute()` still never throws.\n *\n * @param options - Policy, handler, optional durable store, optional name.\n * @returns An {@link AgentMiddleware} declaring a single `tool.before` hook.\n *\n * @example\n * const support = ai.agent({\n * model,\n * tools: [refundCustomer],\n * middleware: [\n * humanApproval({\n * policy: { type: \"allowlist\", tools: [\"refundCustomer\"], tags: () => [\"money\"] },\n * handler: async (req) => ui.prompt(req), // { type: \"edit\", args: { amount: 5 } }\n * }),\n * ],\n * });\n */\nexport function humanApproval(options: HumanApprovalOptions): AgentMiddleware {\n const name = options.name ?? DEFAULT_NAME;\n const { policy, handler } = options;\n\n return {\n name,\n tool: {\n async before(\n ctx: MiddlewareToolContext,\n ): Promise<ToolInvokeResult<unknown> | void> {\n const verdict = evaluatePolicy(policy, toPolicyContext(ctx));\n\n // Not gated — let the real tool run unchanged.\n if (!verdict.requiresApproval) {\n return;\n }\n\n const interruptId = makeInterruptId(ctx);\n const request = buildRequest(ctx, interruptId, verdict.tags);\n\n // Durable resume: `ai.human.resume(...)` re-runs this same agent\n // with the human's decision pre-seeded (keyed by agent name). On a\n // hit we replay the seeded decision exactly once and skip the\n // author's handler entirely — the gated call resolves to the\n // ruling instead of pausing again.\n const seeded = takeSeededDecision(ctx.agent.name);\n\n let decision: ApprovalDecision;\n\n if (seeded !== undefined) {\n decision = seeded;\n } else {\n try {\n decision = await handler(request);\n } catch (thrown) {\n // A durable handler signals suspension by throwing our OWN\n // sentinel after persisting the interrupt. Recognize it and\n // short-circuit a failed result carrying it — the caller reads\n // `error.interruptId` and resumes later. Any OTHER throw is a\n // handler bug; re-throw so the agent dispatch funnels it onto\n // `result.error` (we never swallow a bug into silent approval).\n if (thrown instanceof InterruptSuspendedError) {\n return failedResult(thrown, ctx.tool.name);\n }\n\n throw thrown;\n }\n }\n\n if (decision.type === \"approve\") {\n // Run the real tool with the model's original args.\n return;\n }\n\n if (decision.type === \"reject\") {\n const error = new ApprovalRejectedError(\n `Tool call \"${ctx.tool.name}\" rejected by reviewer — ${decision.reason}`,\n { reason: decision.reason, toolName: ctx.tool.name },\n );\n\n return failedResult(error, ctx.tool.name);\n }\n\n // `edit` — rewrite the pending args, then let the real tool run.\n // The agent dispatch reads `request.input` (this same object) when\n // it invokes the tool after this hook returns, so the reassignment\n // takes effect. Bad edits still fail the tool's own schema check.\n (ctx.request as unknown as MutableToolRequest).input = decision.args;\n\n return;\n },\n },\n };\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,eAAe;;AAGrB,MAAM,aAAoB,OAAO,OAAO;CAAE,OAAO;CAAG,QAAQ;CAAG,OAAO;AAAE,CAAC;;;;;AAmBzE,SAAS,gBAAgB,KAA2C;CAClE,OAAO;EACL,UAAU,IAAI,KAAK;EACnB,iBAAiB,IAAI,KAAK;EAC1B,MAAM,IAAI,QAAQ;EAClB,WAAW,IAAI,MAAM;EACrB,WAAW,IAAI;EACf,WAAW,IAAI,SAAS;CAC1B;AACF;;;;;;;AAQA,SAAS,gBAAgB,KAAoC;CAC3D,MAAM,UAAU,IAAI,SAAS,aAAa;CAC1C,MAAM,SAAS,cAAc,WAAW;CAExC,OAAO,GAAG,IAAI,MAAM,KAAK,GAAG,QAAQ,GAAG,IAAI,UAAU,GAAG;AAC1D;;;;;AAMA,SAAS,aACP,KACA,aACA,MACiB;CACjB,OAAO;EACL;EACA,UAAU,IAAI,KAAK;EACnB,iBAAiB,IAAI,KAAK;EAC1B,MAAM,IAAI,QAAQ;EAClB,SAAS;GACP,WAAW,IAAI,MAAM;GACrB,WAAW,IAAI;GACf,WAAW,IAAI,SAAS;GACxB,eAAe,IAAI;GACnB,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EACzB;EACA,8BAAa,IAAI,KAAK,EAAC,CAAC,YAAY;CACtC;AACF;;;;;;;;;;;AAYA,SAAS,aAAa,OAAgB,UAA6C;CACjF,MAAM,QAAQ,cAAc,MAAM;CAClC,MAAM,0BAAS,IAAI,KAAK,EAAC,CAAC,YAAY;CAetC,OAAO;EAAE;EAAO,OAAO;EAAY;GAZjC;GACA,WAAW;GACX,MAAM;GACN,MAAM;GACN,QAAQ;GACR,WAAW;GACX,SAAS;GACT,UAAU;GACV,OAAO;GACP,UAAU,CAAC;EAG2B;CAAE;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,cAAc,SAAgD;CAC5E,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,EAAE,QAAQ,YAAY;CAE5B,OAAO;EACL;EACA,MAAM,EACJ,MAAM,OACJ,KAC2C;GAC3C,MAAM,UAAU,eAAe,QAAQ,gBAAgB,GAAG,CAAC;GAG3D,IAAI,CAAC,QAAQ,kBACX;GAIF,MAAM,UAAU,aAAa,KADT,gBAAgB,GACQ,GAAG,QAAQ,IAAI;GAO3D,MAAM,SAAS,mBAAmB,IAAI,MAAM,IAAI;GAEhD,IAAI;GAEJ,IAAI,WAAW,QACb,WAAW;QAEX,IAAI;IACF,WAAW,MAAM,QAAQ,OAAO;GAClC,SAAS,QAAQ;IAOf,IAAI,kBAAkB,yBACpB,OAAO,aAAa,QAAQ,IAAI,KAAK,IAAI;IAG3C,MAAM;GACR;GAGF,IAAI,SAAS,SAAS,WAEpB;GAGF,IAAI,SAAS,SAAS,UAMpB,OAAO,aAAa,IALF,sBAChB,cAAc,IAAI,KAAK,KAAK,2BAA2B,SAAS,UAChE;IAAE,QAAQ,SAAS;IAAQ,UAAU,IAAI,KAAK;GAAK,CAG7B,GAAG,IAAI,KAAK,IAAI;GAO1C,AAAC,IAAI,QAA0C,QAAQ,SAAS;EAGlE,EACF;CACF;AACF"}
@@ -1,67 +0,0 @@
1
- //#region ../@warlock.js/ai/src/human/policy.ts
2
- /**
3
- * A verdict that lets a call through untouched. Frozen and shared so the
4
- * (common) skip path allocates nothing.
5
- */
6
- const SKIP = Object.freeze({ requiresApproval: false });
7
- /**
8
- * Normalize an author-supplied tags array into the verdict shape — an
9
- * empty array is treated as "no tags" so callers never have to
10
- * distinguish `[]` from `undefined`.
11
- */
12
- function withTags(tags) {
13
- if (tags === void 0 || tags.length === 0) return { requiresApproval: true };
14
- return {
15
- requiresApproval: true,
16
- tags
17
- };
18
- }
19
- /**
20
- * Decide whether a single pending tool call requires human approval —
21
- * the pure core behind the `ai.human.approval` middleware's gate.
22
- *
23
- * **Pure.** No IO, no throwing, no mutation of `policy` or `context`. The
24
- * middleware calls this once per tool dispatch and routes to a human only
25
- * when {@link PolicyVerdict.requiresApproval} is `true`.
26
- *
27
- * **The three rule types** ({@link InterruptPolicy}):
28
- * - `allowlist` — gate the call **only** when its tool name is listed; an
29
- * optional `tags(toolName)` callback derives the verdict tags.
30
- * - `denylist` — gate **every** call **except** the listed tool names;
31
- * the same optional `tags(toolName)` callback applies to the gated
32
- * (non-listed) name.
33
- * - `predicate` — gate the call when `requiresApproval(context)` returns a
34
- * truthy result. A non-empty `string[]` both gates the call **and**
35
- * supplies the verdict tags; `true` gates with no tags; `false` (or an
36
- * **empty** array — "no rule matched") lets the call through.
37
- *
38
- * @param policy - The interrupt policy to evaluate.
39
- * @param context - The read-only view of the pending tool call.
40
- * @returns A {@link PolicyVerdict} — gate-or-skip plus any tags.
41
- *
42
- * @example
43
- * const verdict = evaluatePolicy(
44
- * { type: "allowlist", tools: ["refundCustomer"], tags: () => ["money"] },
45
- * { toolName: "refundCustomer", args: { amount: 50 }, agentName: "support", tripIndex: 0 },
46
- * );
47
- * // → { requiresApproval: true, tags: ["money"] }
48
- */
49
- function evaluatePolicy(policy, context) {
50
- if (policy.type === "allowlist") {
51
- if (!policy.tools.includes(context.toolName)) return SKIP;
52
- return withTags(policy.tags?.(context.toolName));
53
- }
54
- if (policy.type === "denylist") {
55
- if (policy.tools.includes(context.toolName)) return SKIP;
56
- return withTags(policy.tags?.(context.toolName));
57
- }
58
- const outcome = policy.requiresApproval(context);
59
- if (outcome === false) return SKIP;
60
- if (outcome === true) return { requiresApproval: true };
61
- if (outcome.length === 0) return SKIP;
62
- return withTags(outcome);
63
- }
64
-
65
- //#endregion
66
- export { evaluatePolicy };
67
- //# sourceMappingURL=policy.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/policy.ts"],"sourcesContent":["import type { InterruptPolicy, PolicyContext } from \"./contracts\";\n\n/**\n * Verdict of evaluating an {@link InterruptPolicy} against a single\n * pending tool call.\n *\n * - `requiresApproval` — `true` when the call must be routed to a human\n * before the real tool runs; `false` when the policy lets it through\n * untouched.\n * - `tags` — author-supplied labels from the matched rule (e.g.\n * `\"destructive\"`, `\"money\"`), surfaced verbatim on the resulting\n * `ApprovalRequest.context.tags`. Only ever present when\n * `requiresApproval` is `true`; `undefined` when the rule produced no\n * tags.\n */\nexport interface PolicyVerdict {\n /** Whether this tool call must be approved by a human. */\n requiresApproval: boolean;\n\n /** Author-supplied tags from the matched rule, when any. */\n tags?: string[];\n}\n\n/**\n * A verdict that lets a call through untouched. Frozen and shared so the\n * (common) skip path allocates nothing.\n */\nconst SKIP: PolicyVerdict = Object.freeze({ requiresApproval: false });\n\n/**\n * Normalize an author-supplied tags array into the verdict shape — an\n * empty array is treated as \"no tags\" so callers never have to\n * distinguish `[]` from `undefined`.\n */\nfunction withTags(tags: string[] | undefined): PolicyVerdict {\n if (tags === undefined || tags.length === 0) {\n return { requiresApproval: true };\n }\n\n return { requiresApproval: true, tags };\n}\n\n/**\n * Decide whether a single pending tool call requires human approval —\n * the pure core behind the `ai.human.approval` middleware's gate.\n *\n * **Pure.** No IO, no throwing, no mutation of `policy` or `context`. The\n * middleware calls this once per tool dispatch and routes to a human only\n * when {@link PolicyVerdict.requiresApproval} is `true`.\n *\n * **The three rule types** ({@link InterruptPolicy}):\n * - `allowlist` — gate the call **only** when its tool name is listed; an\n * optional `tags(toolName)` callback derives the verdict tags.\n * - `denylist` — gate **every** call **except** the listed tool names;\n * the same optional `tags(toolName)` callback applies to the gated\n * (non-listed) name.\n * - `predicate` — gate the call when `requiresApproval(context)` returns a\n * truthy result. A non-empty `string[]` both gates the call **and**\n * supplies the verdict tags; `true` gates with no tags; `false` (or an\n * **empty** array — \"no rule matched\") lets the call through.\n *\n * @param policy - The interrupt policy to evaluate.\n * @param context - The read-only view of the pending tool call.\n * @returns A {@link PolicyVerdict} — gate-or-skip plus any tags.\n *\n * @example\n * const verdict = evaluatePolicy(\n * { type: \"allowlist\", tools: [\"refundCustomer\"], tags: () => [\"money\"] },\n * { toolName: \"refundCustomer\", args: { amount: 50 }, agentName: \"support\", tripIndex: 0 },\n * );\n * // → { requiresApproval: true, tags: [\"money\"] }\n */\nexport function evaluatePolicy(\n policy: InterruptPolicy,\n context: PolicyContext,\n): PolicyVerdict {\n if (policy.type === \"allowlist\") {\n if (!policy.tools.includes(context.toolName)) {\n return SKIP;\n }\n\n return withTags(policy.tags?.(context.toolName));\n }\n\n if (policy.type === \"denylist\") {\n if (policy.tools.includes(context.toolName)) {\n return SKIP;\n }\n\n return withTags(policy.tags?.(context.toolName));\n }\n\n // Predicate: a truthy result gates the call; a `string[]` doubles as the\n // verdict tags.\n const outcome = policy.requiresApproval(context);\n\n if (outcome === false) {\n return SKIP;\n }\n\n if (outcome === true) {\n return { requiresApproval: true };\n }\n\n // `outcome` is a `string[]`. Per the contract, an EMPTY array means \"no\n // rule matched\" and skips approval; a non-empty array gates the call and\n // doubles as the verdict tags.\n if (outcome.length === 0) {\n return SKIP;\n }\n\n return withTags(outcome);\n}\n"],"mappings":";;;;;AA2BA,MAAM,OAAsB,OAAO,OAAO,EAAE,kBAAkB,MAAM,CAAC;;;;;;AAOrE,SAAS,SAAS,MAA2C;CAC3D,IAAI,SAAS,UAAa,KAAK,WAAW,GACxC,OAAO,EAAE,kBAAkB,KAAK;CAGlC,OAAO;EAAE,kBAAkB;EAAM;CAAK;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,eACd,QACA,SACe;CACf,IAAI,OAAO,SAAS,aAAa;EAC/B,IAAI,CAAC,OAAO,MAAM,SAAS,QAAQ,QAAQ,GACzC,OAAO;EAGT,OAAO,SAAS,OAAO,OAAO,QAAQ,QAAQ,CAAC;CACjD;CAEA,IAAI,OAAO,SAAS,YAAY;EAC9B,IAAI,OAAO,MAAM,SAAS,QAAQ,QAAQ,GACxC,OAAO;EAGT,OAAO,SAAS,OAAO,OAAO,QAAQ,QAAQ,CAAC;CACjD;CAIA,MAAM,UAAU,OAAO,iBAAiB,OAAO;CAE/C,IAAI,YAAY,OACd,OAAO;CAGT,IAAI,YAAY,MACd,OAAO,EAAE,kBAAkB,KAAK;CAMlC,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,OAAO,SAAS,OAAO;AACzB"}
@@ -1,37 +0,0 @@
1
- import { humanApproval } from "./human-approval.mjs";
2
- import { resume } from "./resume.mjs";
3
- import { memory } from "./stores/memory.mjs";
4
- import { pg } from "./stores/pg.mjs";
5
- import { redis } from "./stores/redis.mjs";
6
- import "./stores/index.mjs";
7
-
8
- //#region ../@warlock.js/ai/src/human/register.ts
9
- /**
10
- * The assembled `ai.human.*` namespace — the human-in-the-loop surface
11
- * mounted onto the shared `ai` object in `../ai`.
12
- *
13
- * - `approval(options)` — the `tool.before` approval-gate middleware.
14
- * - `resume(id, decision, options)` — out-of-process durable resume.
15
- * - `interrupt.{memory,pg,redis}()` — the
16
- * {@link import("./contracts").InterruptStore} factories (memory ships
17
- * real; pg/redis lazily import their optional-peer driver).
18
- *
19
- * Declared as a standalone object so `../ai` can spread it onto the `ai`
20
- * literal and pin the `Ai.human` member to this exact shape with no casts.
21
- * Lives here (not inlined into `../ai`) to keep the human factories grouped
22
- * with the rest of the human module and avoid `../ai` reaching into each
23
- * store/middleware file directly.
24
- */
25
- const human = {
26
- approval: humanApproval,
27
- resume,
28
- interrupt: {
29
- memory,
30
- pg,
31
- redis
32
- }
33
- };
34
-
35
- //#endregion
36
- export { human };
37
- //# sourceMappingURL=register.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.mjs","names":["interruptMemory","interruptPg","interruptRedis"],"sources":["../../../../../../../../../@warlock.js/ai/src/human/register.ts"],"sourcesContent":["import { humanApproval } from \"./human-approval\";\nimport { resume } from \"./resume\";\nimport { interruptMemory, interruptPg, interruptRedis } from \"./stores\";\n\n/**\n * The assembled `ai.human.*` namespace — the human-in-the-loop surface\n * mounted onto the shared `ai` object in `../ai`.\n *\n * - `approval(options)` — the `tool.before` approval-gate middleware.\n * - `resume(id, decision, options)` — out-of-process durable resume.\n * - `interrupt.{memory,pg,redis}()` — the\n * {@link import(\"./contracts\").InterruptStore} factories (memory ships\n * real; pg/redis lazily import their optional-peer driver).\n *\n * Declared as a standalone object so `../ai` can spread it onto the `ai`\n * literal and pin the `Ai.human` member to this exact shape with no casts.\n * Lives here (not inlined into `../ai`) to keep the human factories grouped\n * with the rest of the human module and avoid `../ai` reaching into each\n * store/middleware file directly.\n */\nexport const human = {\n approval: humanApproval,\n resume,\n interrupt: {\n memory: interruptMemory,\n pg: interruptPg,\n redis: interruptRedis,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,QAAQ;CACnB,UAAU;CACV;CACA,WAAW;EACDA;EACJC;EACGC;CACT;AACF"}
@@ -1,53 +0,0 @@
1
- //#region ../@warlock.js/ai/src/human/resume-seed.ts
2
- /**
3
- * Process-local registry of decisions pre-seeded for a durable re-run.
4
- *
5
- * **Why it exists.** v1 durable resume re-runs the *same* agent turn with
6
- * the human's decision already in hand (it does **not** rehydrate an
7
- * in-flight supervisor — that is the deferred v2 lift). The agent's
8
- * `ai.human.approval(...)` middleware is baked in at construction, so the
9
- * re-run cannot be handed a different handler. Instead, `ai.human.resume(...)`
10
- * stashes the decision here keyed by the agent name; the approval
11
- * middleware's handler consults the registry **before** calling the
12
- * author's handler and, on a hit, replays the seeded decision exactly once
13
- * — so the gated tool call this time resolves to the human's ruling instead
14
- * of pausing again.
15
- *
16
- * Keyed by agent name (not interrupt id): the re-run produces a *fresh*
17
- * interrupt id (the id embeds a random segment), so the seed must be
18
- * matched to the run, not the prior id. The registry holds at most one
19
- * seeded decision per agent and consumes it on first read, so a second
20
- * gated call in the same re-run falls through to the author's handler.
21
- */
22
- const seededDecisions = /* @__PURE__ */ new Map();
23
- /**
24
- * Stash a decision to be replayed on the next gated tool call of `agentName`.
25
- * Overwrites any prior seed for the same agent (a re-run carries exactly one
26
- * pre-seeded decision).
27
- */
28
- function seedDecision(agentName, decision) {
29
- seededDecisions.set(agentName, decision);
30
- }
31
- /**
32
- * Take (read **and** remove) the seeded decision for `agentName`, or
33
- * `undefined` when none is staged. Consuming on read makes the seed
34
- * one-shot: only the first gated call of a re-run replays it.
35
- */
36
- function takeSeededDecision(agentName) {
37
- const decision = seededDecisions.get(agentName);
38
- if (decision === void 0) return;
39
- seededDecisions.delete(agentName);
40
- return decision;
41
- }
42
- /**
43
- * Drop any staged seed for `agentName` without consuming it as a decision.
44
- * Used to clean up after a re-run that errored before the seeded call fired,
45
- * so a stale seed never leaks into an unrelated later run of the same agent.
46
- */
47
- function clearSeededDecision(agentName) {
48
- seededDecisions.delete(agentName);
49
- }
50
-
51
- //#endregion
52
- export { clearSeededDecision, seedDecision, takeSeededDecision };
53
- //# sourceMappingURL=resume-seed.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resume-seed.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/resume-seed.ts"],"sourcesContent":["import type { ApprovalDecision } from \"./contracts\";\n\n/**\n * Process-local registry of decisions pre-seeded for a durable re-run.\n *\n * **Why it exists.** v1 durable resume re-runs the *same* agent turn with\n * the human's decision already in hand (it does **not** rehydrate an\n * in-flight supervisor — that is the deferred v2 lift). The agent's\n * `ai.human.approval(...)` middleware is baked in at construction, so the\n * re-run cannot be handed a different handler. Instead, `ai.human.resume(...)`\n * stashes the decision here keyed by the agent name; the approval\n * middleware's handler consults the registry **before** calling the\n * author's handler and, on a hit, replays the seeded decision exactly once\n * — so the gated tool call this time resolves to the human's ruling instead\n * of pausing again.\n *\n * Keyed by agent name (not interrupt id): the re-run produces a *fresh*\n * interrupt id (the id embeds a random segment), so the seed must be\n * matched to the run, not the prior id. The registry holds at most one\n * seeded decision per agent and consumes it on first read, so a second\n * gated call in the same re-run falls through to the author's handler.\n */\nconst seededDecisions = new Map<string, ApprovalDecision>();\n\n/**\n * Stash a decision to be replayed on the next gated tool call of `agentName`.\n * Overwrites any prior seed for the same agent (a re-run carries exactly one\n * pre-seeded decision).\n */\nexport function seedDecision(agentName: string, decision: ApprovalDecision): void {\n seededDecisions.set(agentName, decision);\n}\n\n/**\n * Take (read **and** remove) the seeded decision for `agentName`, or\n * `undefined` when none is staged. Consuming on read makes the seed\n * one-shot: only the first gated call of a re-run replays it.\n */\nexport function takeSeededDecision(agentName: string): ApprovalDecision | undefined {\n const decision = seededDecisions.get(agentName);\n\n if (decision === undefined) {\n return undefined;\n }\n\n seededDecisions.delete(agentName);\n\n return decision;\n}\n\n/**\n * Drop any staged seed for `agentName` without consuming it as a decision.\n * Used to clean up after a re-run that errored before the seeded call fired,\n * so a stale seed never leaks into an unrelated later run of the same agent.\n */\nexport function clearSeededDecision(agentName: string): void {\n seededDecisions.delete(agentName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kCAAkB,IAAI,IAA8B;;;;;;AAO1D,SAAgB,aAAa,WAAmB,UAAkC;CAChF,gBAAgB,IAAI,WAAW,QAAQ;AACzC;;;;;;AAOA,SAAgB,mBAAmB,WAAiD;CAClF,MAAM,WAAW,gBAAgB,IAAI,SAAS;CAE9C,IAAI,aAAa,QACf;CAGF,gBAAgB,OAAO,SAAS;CAEhC,OAAO;AACT;;;;;;AAOA,SAAgB,oBAAoB,WAAyB;CAC3D,gBAAgB,OAAO,SAAS;AAClC"}
@@ -1,121 +0,0 @@
1
- import { clearSeededDecision, seedDecision } from "./resume-seed.mjs";
2
-
3
- //#region ../@warlock.js/ai/src/human/resume.ts
4
- /**
5
- * Validate that a decision is a well-formed {@link ApprovalDecision}.
6
- *
7
- * `ai.human.resume(...)` is a public, out-of-process entry point — a
8
- * webhook can hand it anything. Guard the closed `type` union (and the
9
- * per-variant required fields) before applying it, so a malformed payload
10
- * fails loudly here rather than silently mis-driving the re-run.
11
- */
12
- function assertDecision(decision) {
13
- if (decision.type === "approve") return;
14
- if (decision.type === "reject") {
15
- if (typeof decision.reason !== "string") throw new TypeError("ai.human.resume: a 'reject' decision requires a string 'reason'.");
16
- return;
17
- }
18
- if (decision.type === "edit") {
19
- if (!("args" in decision)) throw new TypeError("ai.human.resume: an 'edit' decision requires replacement 'args'.");
20
- return;
21
- }
22
- throw new TypeError(`ai.human.resume: unknown decision type '${decision.type}'. Expected one of: approve, reject, edit.`);
23
- }
24
- /**
25
- * Re-run the agent for a resumed interrupt with the decision pre-seeded.
26
- *
27
- * Stages the decision in the process-local seed registry (keyed by agent
28
- * name), then re-executes the original prompt. The agent's
29
- * `ai.human.approval(...)` middleware consumes the seed on the gated tool
30
- * call — so this time it resolves to the human's ruling instead of pausing
31
- * again. The seed is cleared in a `finally` so a re-run that errors before
32
- * the gated call never leaks a stale seed into a later run.
33
- */
34
- async function rerun(pending, decision, options) {
35
- const { agent } = options;
36
- if (!agent) return {
37
- type: "applied",
38
- interruptId: pending.interruptId,
39
- decision
40
- };
41
- const input = options.input ?? pending.request.context.originalInput ?? "";
42
- seedDecision(agent.name, decision);
43
- try {
44
- const result = await agent.execute(input, options.executeOptions);
45
- return {
46
- type: "applied",
47
- interruptId: pending.interruptId,
48
- decision,
49
- result
50
- };
51
- } finally {
52
- clearSeededDecision(agent.name);
53
- }
54
- }
55
- /**
56
- * Apply a human's decision to a persisted interrupt — the out-of-process
57
- * resume entry point behind `ai.human.resume(interruptId, decision, options)`.
58
- *
59
- * **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the
60
- * {@link PendingInterrupt} from `options.store`, validates the decision,
61
- * deletes the pending record, and (when an `agent` is supplied) re-executes
62
- * the original turn with the decision **pre-seeded**, so the gated tool call
63
- * resolves to the ruling instead of pausing again. It does **not** rehydrate
64
- * an in-flight supervisor — that is the deferred v2 lift.
65
- *
66
- * **Idempotent.** A second resume of an already-resolved (deleted) or
67
- * never-raised interrupt is a no-op: it returns `{ type: "already-resolved" }`
68
- * without re-applying the decision or re-running the turn — mirroring the
69
- * orchestrator resume's drain idempotency. The record is deleted **before**
70
- * the re-run, so even a re-run that itself raises a fresh interrupt cannot
71
- * collide with the one being resolved.
72
- *
73
- * **Two shapes** (see {@link ResumeOptions}):
74
- * - **apply-only** — omit `agent`: load, validate, delete, return
75
- * `{ type: "applied", decision }` for a caller-owned re-drive.
76
- * - **re-run** — pass `agent`: additionally re-execute the turn; the
77
- * {@link import("@warlock.js/ai").AgentResult} rides `result.result`.
78
- *
79
- * @param interruptId - Id of the persisted interrupt to resolve.
80
- * @param decision - The human's ruling (approve / reject / edit).
81
- * @param options - The durable `store` (required) plus optional re-run
82
- * `agent` / `input` / `executeOptions`.
83
- * @returns A {@link ResumeResult} — `"applied"` or idempotent
84
- * `"already-resolved"`.
85
- *
86
- * @example
87
- * // Process B (webhook, hours later) — apply-only:
88
- * const outcome = await ai.human.resume(interruptId, { type: "reject", reason: "Out of policy" }, {
89
- * store,
90
- * });
91
- *
92
- * @example
93
- * // Re-run the turn with the decision pre-seeded:
94
- * const outcome = await ai.human.resume(interruptId, { type: "edit", args: { amount: 5 } }, {
95
- * store,
96
- * agent: support,
97
- * });
98
- * if (outcome.type === "applied" && outcome.result) {
99
- * console.log(outcome.result.text);
100
- * }
101
- */
102
- async function resume(interruptId, decision, options) {
103
- assertDecision(decision);
104
- const { store } = options;
105
- const pending = await store.load(interruptId);
106
- if (pending === void 0 || pending.status !== "pending") return {
107
- type: "already-resolved",
108
- interruptId
109
- };
110
- await store.delete(interruptId);
111
- if (!options.agent) return {
112
- type: "applied",
113
- interruptId,
114
- decision
115
- };
116
- return rerun(pending, decision, options);
117
- }
118
-
119
- //#endregion
120
- export { resume };
121
- //# sourceMappingURL=resume.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resume.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/resume.ts"],"sourcesContent":["import type {\n ApprovalDecision,\n PendingInterrupt,\n ResumeOptions,\n ResumeResult,\n} from \"./contracts\";\nimport { clearSeededDecision, seedDecision } from \"./resume-seed\";\n\n/**\n * Validate that a decision is a well-formed {@link ApprovalDecision}.\n *\n * `ai.human.resume(...)` is a public, out-of-process entry point — a\n * webhook can hand it anything. Guard the closed `type` union (and the\n * per-variant required fields) before applying it, so a malformed payload\n * fails loudly here rather than silently mis-driving the re-run.\n */\nfunction assertDecision(decision: ApprovalDecision): void {\n if (decision.type === \"approve\") {\n return;\n }\n\n if (decision.type === \"reject\") {\n if (typeof decision.reason !== \"string\") {\n throw new TypeError(\n \"ai.human.resume: a 'reject' decision requires a string 'reason'.\",\n );\n }\n\n return;\n }\n\n if (decision.type === \"edit\") {\n if (!(\"args\" in decision)) {\n throw new TypeError(\n \"ai.human.resume: an 'edit' decision requires replacement 'args'.\",\n );\n }\n\n return;\n }\n\n throw new TypeError(\n `ai.human.resume: unknown decision type '${(decision as { type: string }).type}'. Expected one of: approve, reject, edit.`,\n );\n}\n\n/**\n * Re-run the agent for a resumed interrupt with the decision pre-seeded.\n *\n * Stages the decision in the process-local seed registry (keyed by agent\n * name), then re-executes the original prompt. The agent's\n * `ai.human.approval(...)` middleware consumes the seed on the gated tool\n * call — so this time it resolves to the human's ruling instead of pausing\n * again. The seed is cleared in a `finally` so a re-run that errors before\n * the gated call never leaks a stale seed into a later run.\n */\nasync function rerun<TOutput>(\n pending: PendingInterrupt,\n decision: ApprovalDecision,\n options: ResumeOptions<TOutput>,\n): Promise<ResumeResult<TOutput>> {\n const { agent } = options;\n\n // `agent` is guaranteed by the caller (this is only reached on the\n // re-run path), but narrow for the type system.\n if (!agent) {\n return { type: \"applied\", interruptId: pending.interruptId, decision };\n }\n\n const input = options.input ?? pending.request.context.originalInput ?? \"\";\n\n seedDecision(agent.name, decision);\n\n try {\n const result = await agent.execute(input, options.executeOptions);\n\n return {\n type: \"applied\",\n interruptId: pending.interruptId,\n decision,\n result,\n };\n } finally {\n // If the seeded call never fired (the re-run errored early, or the\n // policy no longer gates the tool), drop the stale seed so it cannot\n // leak into an unrelated later run of the same agent.\n clearSeededDecision(agent.name);\n }\n}\n\n/**\n * Apply a human's decision to a persisted interrupt — the out-of-process\n * resume entry point behind `ai.human.resume(interruptId, decision, options)`.\n *\n * **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the\n * {@link PendingInterrupt} from `options.store`, validates the decision,\n * deletes the pending record, and (when an `agent` is supplied) re-executes\n * the original turn with the decision **pre-seeded**, so the gated tool call\n * resolves to the ruling instead of pausing again. It does **not** rehydrate\n * an in-flight supervisor — that is the deferred v2 lift.\n *\n * **Idempotent.** A second resume of an already-resolved (deleted) or\n * never-raised interrupt is a no-op: it returns `{ type: \"already-resolved\" }`\n * without re-applying the decision or re-running the turn — mirroring the\n * orchestrator resume's drain idempotency. The record is deleted **before**\n * the re-run, so even a re-run that itself raises a fresh interrupt cannot\n * collide with the one being resolved.\n *\n * **Two shapes** (see {@link ResumeOptions}):\n * - **apply-only** — omit `agent`: load, validate, delete, return\n * `{ type: \"applied\", decision }` for a caller-owned re-drive.\n * - **re-run** — pass `agent`: additionally re-execute the turn; the\n * {@link import(\"@warlock.js/ai\").AgentResult} rides `result.result`.\n *\n * @param interruptId - Id of the persisted interrupt to resolve.\n * @param decision - The human's ruling (approve / reject / edit).\n * @param options - The durable `store` (required) plus optional re-run\n * `agent` / `input` / `executeOptions`.\n * @returns A {@link ResumeResult} — `\"applied\"` or idempotent\n * `\"already-resolved\"`.\n *\n * @example\n * // Process B (webhook, hours later) — apply-only:\n * const outcome = await ai.human.resume(interruptId, { type: \"reject\", reason: \"Out of policy\" }, {\n * store,\n * });\n *\n * @example\n * // Re-run the turn with the decision pre-seeded:\n * const outcome = await ai.human.resume(interruptId, { type: \"edit\", args: { amount: 5 } }, {\n * store,\n * agent: support,\n * });\n * if (outcome.type === \"applied\" && outcome.result) {\n * console.log(outcome.result.text);\n * }\n */\nexport async function resume<TOutput = unknown>(\n interruptId: string,\n decision: ApprovalDecision,\n options: ResumeOptions<TOutput>,\n): Promise<ResumeResult<TOutput>> {\n assertDecision(decision);\n\n const { store } = options;\n const pending = await store.load(interruptId);\n\n // No live interrupt — already resolved + deleted, or never raised. Never\n // double-apply; never re-run. Idempotent no-op.\n if (pending === undefined || pending.status !== \"pending\") {\n return { type: \"already-resolved\", interruptId };\n }\n\n // Resolve + delete BEFORE the re-run so a re-run that itself raises a new\n // interrupt cannot collide with the one being resolved, and a concurrent\n // resume of the same id sees it gone.\n await store.delete(interruptId);\n\n if (!options.agent) {\n return { type: \"applied\", interruptId, decision };\n }\n\n return rerun(pending, decision, options);\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,eAAe,UAAkC;CACxD,IAAI,SAAS,SAAS,WACpB;CAGF,IAAI,SAAS,SAAS,UAAU;EAC9B,IAAI,OAAO,SAAS,WAAW,UAC7B,MAAM,IAAI,UACR,kEACF;EAGF;CACF;CAEA,IAAI,SAAS,SAAS,QAAQ;EAC5B,IAAI,EAAE,UAAU,WACd,MAAM,IAAI,UACR,kEACF;EAGF;CACF;CAEA,MAAM,IAAI,UACR,2CAA4C,SAA8B,KAAK,2CACjF;AACF;;;;;;;;;;;AAYA,eAAe,MACb,SACA,UACA,SACgC;CAChC,MAAM,EAAE,UAAU;CAIlB,IAAI,CAAC,OACH,OAAO;EAAE,MAAM;EAAW,aAAa,QAAQ;EAAa;CAAS;CAGvE,MAAM,QAAQ,QAAQ,SAAS,QAAQ,QAAQ,QAAQ,iBAAiB;CAExE,aAAa,MAAM,MAAM,QAAQ;CAEjC,IAAI;EACF,MAAM,SAAS,MAAM,MAAM,QAAQ,OAAO,QAAQ,cAAc;EAEhE,OAAO;GACL,MAAM;GACN,aAAa,QAAQ;GACrB;GACA;EACF;CACF,UAAU;EAIR,oBAAoB,MAAM,IAAI;CAChC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,eAAsB,OACpB,aACA,UACA,SACgC;CAChC,eAAe,QAAQ;CAEvB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,MAAM,MAAM,KAAK,WAAW;CAI5C,IAAI,YAAY,UAAa,QAAQ,WAAW,WAC9C,OAAO;EAAE,MAAM;EAAoB;CAAY;CAMjD,MAAM,MAAM,OAAO,WAAW;CAE9B,IAAI,CAAC,QAAQ,OACX,OAAO;EAAE,MAAM;EAAW;EAAa;CAAS;CAGlD,OAAO,MAAM,SAAS,UAAU,OAAO;AACzC"}
@@ -1,5 +0,0 @@
1
- import { memory } from "./memory.mjs";
2
- import { pg } from "./pg.mjs";
3
- import { redis } from "./redis.mjs";
4
-
5
- export { };
@@ -1,91 +0,0 @@
1
- //#region ../@warlock.js/ai/src/human/stores/memory.ts
2
- /**
3
- * In-memory {@link InterruptStore} — pending interrupts held in a
4
- * process-local `Map`, never persisted to disk.
5
- *
6
- * Owns: the `interruptId → {@link PendingInterrupt}` index and the
7
- * last-writer-wins `save` / `load` / `delete` / `list` semantics the
8
- * contract declares. Does NOT own: durability, cross-process sharing, or
9
- * TTL eviction — it is the zero-config default for dev, tests, and
10
- * single-process apps whose approval flow stays interactive (the run
11
- * `await`s the decision in-process and never needs to survive a restart).
12
- * Reach for `ai.human.interrupt.pg()` / `ai.human.interrupt.redis()` when
13
- * a reviewer rules out-of-process, hours later.
14
- *
15
- * Front it with the {@link memory} factory — callers never `new` it.
16
- */
17
- var MemoryInterruptStore = class {
18
- constructor() {
19
- this.interrupts = /* @__PURE__ */ new Map();
20
- }
21
- /**
22
- * Persist a pending interrupt, keyed by its own `interruptId`.
23
- * Overwrites any prior record for the same id — a call has exactly one
24
- * live interrupt, so a re-save replaces rather than appends.
25
- */
26
- async save(record) {
27
- this.interrupts.set(record.interruptId, record);
28
- }
29
- /**
30
- * Return the interrupt for an `interruptId`, or `undefined` when none is
31
- * recorded (never raised, or already resolved + deleted).
32
- */
33
- async load(interruptId) {
34
- return this.interrupts.get(interruptId);
35
- }
36
- /**
37
- * Drop the interrupt for an `interruptId`. Idempotent — deleting an
38
- * absent id is a no-op.
39
- */
40
- async delete(interruptId) {
41
- this.interrupts.delete(interruptId);
42
- }
43
- /**
44
- * List the interrupt ids the store knows, optionally filtered by a
45
- * prefix. Returns a fresh array each call so a caller can mutate it
46
- * freely without touching the backing index.
47
- */
48
- async list(prefix) {
49
- const ids = [...this.interrupts.keys()];
50
- if (prefix === void 0) return ids;
51
- return ids.filter((id) => id.startsWith(prefix));
52
- }
53
- /**
54
- * The memory store has no backing table — there is nothing to migrate.
55
- * Returns an empty string so callers can treat `schema()` uniformly
56
- * across drivers.
57
- */
58
- schema() {
59
- return "";
60
- }
61
- };
62
- /**
63
- * Create an in-memory {@link InterruptStore}. Zero-config — no client, no
64
- * connection. Suitable for dev, tests, and single-process apps whose
65
- * approval flow stays interactive and doesn't need resume across
66
- * restarts.
67
- *
68
- * @example
69
- * import { ai } from "@warlock.js/ai";
70
- *
71
- * const store = ai.human.interrupt.memory();
72
- *
73
- * const agent = ai.agent({
74
- * model,
75
- * tools: [deleteAccount],
76
- * middleware: [
77
- * ai.human.approval({
78
- * policy: { type: "allowlist", tools: ["deleteAccount"] },
79
- * store,
80
- * handler,
81
- * }),
82
- * ],
83
- * });
84
- */
85
- function memory() {
86
- return new MemoryInterruptStore();
87
- }
88
-
89
- //#endregion
90
- export { memory };
91
- //# sourceMappingURL=memory.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/ai/src/human/stores/memory.ts"],"sourcesContent":["import type {\n InterruptStore,\n PendingInterrupt,\n} from \"../contracts/interrupt-store.contract\";\n\n/**\n * In-memory {@link InterruptStore} — pending interrupts held in a\n * process-local `Map`, never persisted to disk.\n *\n * Owns: the `interruptId → {@link PendingInterrupt}` index and the\n * last-writer-wins `save` / `load` / `delete` / `list` semantics the\n * contract declares. Does NOT own: durability, cross-process sharing, or\n * TTL eviction — it is the zero-config default for dev, tests, and\n * single-process apps whose approval flow stays interactive (the run\n * `await`s the decision in-process and never needs to survive a restart).\n * Reach for `ai.human.interrupt.pg()` / `ai.human.interrupt.redis()` when\n * a reviewer rules out-of-process, hours later.\n *\n * Front it with the {@link memory} factory — callers never `new` it.\n */\nclass MemoryInterruptStore implements InterruptStore {\n /** Pending interrupts keyed by their own `interruptId`. */\n private readonly interrupts = new Map<string, PendingInterrupt>();\n\n /**\n * Persist a pending interrupt, keyed by its own `interruptId`.\n * Overwrites any prior record for the same id — a call has exactly one\n * live interrupt, so a re-save replaces rather than appends.\n */\n public async save(record: PendingInterrupt): Promise<void> {\n this.interrupts.set(record.interruptId, record);\n }\n\n /**\n * Return the interrupt for an `interruptId`, or `undefined` when none is\n * recorded (never raised, or already resolved + deleted).\n */\n public async load(\n interruptId: string,\n ): Promise<PendingInterrupt | undefined> {\n return this.interrupts.get(interruptId);\n }\n\n /**\n * Drop the interrupt for an `interruptId`. Idempotent — deleting an\n * absent id is a no-op.\n */\n public async delete(interruptId: string): Promise<void> {\n this.interrupts.delete(interruptId);\n }\n\n /**\n * List the interrupt ids the store knows, optionally filtered by a\n * prefix. Returns a fresh array each call so a caller can mutate it\n * freely without touching the backing index.\n */\n public async list(prefix?: string): Promise<string[]> {\n const ids = [...this.interrupts.keys()];\n\n if (prefix === undefined) {\n return ids;\n }\n\n return ids.filter((id) => id.startsWith(prefix));\n }\n\n /**\n * The memory store has no backing table — there is nothing to migrate.\n * Returns an empty string so callers can treat `schema()` uniformly\n * across drivers.\n */\n public schema(): string {\n return \"\";\n }\n}\n\n/**\n * Create an in-memory {@link InterruptStore}. Zero-config — no client, no\n * connection. Suitable for dev, tests, and single-process apps whose\n * approval flow stays interactive and doesn't need resume across\n * restarts.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * const store = ai.human.interrupt.memory();\n *\n * const agent = ai.agent({\n * model,\n * tools: [deleteAccount],\n * middleware: [\n * ai.human.approval({\n * policy: { type: \"allowlist\", tools: [\"deleteAccount\"] },\n * store,\n * handler,\n * }),\n * ],\n * });\n */\nexport function memory(): InterruptStore {\n return new MemoryInterruptStore();\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,IAAM,uBAAN,MAAqD;;oCAErB,IAAI,IAA8B;;;;;;;CAOhE,MAAa,KAAK,QAAyC;EACzD,KAAK,WAAW,IAAI,OAAO,aAAa,MAAM;CAChD;;;;;CAMA,MAAa,KACX,aACuC;EACvC,OAAO,KAAK,WAAW,IAAI,WAAW;CACxC;;;;;CAMA,MAAa,OAAO,aAAoC;EACtD,KAAK,WAAW,OAAO,WAAW;CACpC;;;;;;CAOA,MAAa,KAAK,QAAoC;EACpD,MAAM,MAAM,CAAC,GAAG,KAAK,WAAW,KAAK,CAAC;EAEtC,IAAI,WAAW,QACb,OAAO;EAGT,OAAO,IAAI,QAAQ,OAAO,GAAG,WAAW,MAAM,CAAC;CACjD;;;;;;CAOA,AAAO,SAAiB;EACtB,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAAyB;CACvC,OAAO,IAAI,qBAAqB;AAClC"}