@warlock.js/ai 4.8.2 → 4.9.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 (1169) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/cjs/index.cjs +263 -241
  3. package/cjs/index.cjs.map +1 -1
  4. package/cjs/{magic-string.es-BtxW4VqG.cjs → magic-string.es-BoSa5xIt.cjs} +3 -3
  5. package/cjs/magic-string.es-BoSa5xIt.cjs.map +1 -0
  6. package/cjs/{matcher-logic-SBnzYohQ.cjs → matcher-logic-07fFOz7r.cjs} +3 -3
  7. package/cjs/matcher-logic-07fFOz7r.cjs.map +1 -0
  8. package/cjs/{matchers-BBh3gyB-.cjs → matchers-DnV47KR_.cjs} +24 -24
  9. package/cjs/matchers-DnV47KR_.cjs.map +1 -0
  10. package/esm/agent/agent-config.type.d.mts +1 -1
  11. package/esm/agent/agent-config.type.d.mts.map +1 -1
  12. package/esm/agent/agent-input-builder.mjs +1 -1
  13. package/esm/agent/agent-input-builder.mjs.map +1 -1
  14. package/esm/agent/agent-log-event.mjs +1 -1
  15. package/esm/agent/agent-log-event.mjs.map +1 -1
  16. package/esm/agent/agent-stream.d.mts +1 -1
  17. package/esm/agent/agent-stream.d.mts.map +1 -1
  18. package/esm/agent/agent-stream.mjs +1 -1
  19. package/esm/agent/agent-stream.mjs.map +1 -1
  20. package/esm/agent/agent-to-stream-event.mjs +1 -1
  21. package/esm/agent/agent-to-stream-event.mjs.map +1 -1
  22. package/esm/agent/agent.d.mts +1 -1
  23. package/esm/agent/agent.d.mts.map +1 -1
  24. package/esm/agent/agent.mjs +1 -1
  25. package/esm/agent/agent.mjs.map +1 -1
  26. package/esm/agent/json-stream-guard.mjs +1 -1
  27. package/esm/agent/json-stream-guard.mjs.map +1 -1
  28. package/esm/agent/judge-config.type.d.mts +1 -1
  29. package/esm/agent/judge-config.type.d.mts.map +1 -1
  30. package/esm/agent/judge-config.type.mjs +1 -1
  31. package/esm/agent/judge-config.type.mjs.map +1 -1
  32. package/esm/agent/signature.mjs +1 -1
  33. package/esm/agent/signature.mjs.map +1 -1
  34. package/esm/agent/snapshot.mjs +1 -1
  35. package/esm/agent/snapshot.mjs.map +1 -1
  36. package/esm/agent/spawn-sub-agent.d.mts +1 -1
  37. package/esm/agent/spawn-sub-agent.d.mts.map +1 -1
  38. package/esm/agent/spawn-sub-agent.mjs +1 -1
  39. package/esm/agent/spawn-sub-agent.mjs.map +1 -1
  40. package/esm/ai.d.mts +1 -1
  41. package/esm/ai.d.mts.map +1 -1
  42. package/esm/ai.mjs +1 -1
  43. package/esm/ai.mjs.map +1 -1
  44. package/esm/batch/batch.d.mts +1 -1
  45. package/esm/batch/batch.d.mts.map +1 -1
  46. package/esm/batch/batch.mjs +1 -1
  47. package/esm/batch/batch.mjs.map +1 -1
  48. package/esm/batch/batch.type.d.mts +1 -1
  49. package/esm/batch/batch.type.d.mts.map +1 -1
  50. package/esm/batch/run-batch-item.mjs +1 -1
  51. package/esm/batch/run-batch-item.mjs.map +1 -1
  52. package/esm/batch/run-with-concurrency.mjs +1 -1
  53. package/esm/batch/run-with-concurrency.mjs.map +1 -1
  54. package/esm/checkpoint/memory.d.mts +1 -1
  55. package/esm/checkpoint/memory.d.mts.map +1 -1
  56. package/esm/checkpoint/memory.mjs +0 -0
  57. package/esm/checkpoint/memory.mjs.map +1 -1
  58. package/esm/checkpoint/pg.d.mts +1 -1
  59. package/esm/checkpoint/pg.d.mts.map +1 -1
  60. package/esm/checkpoint/pg.mjs +1 -1
  61. package/esm/checkpoint/pg.mjs.map +1 -1
  62. package/esm/checkpoint/redis.d.mts +1 -1
  63. package/esm/checkpoint/redis.d.mts.map +1 -1
  64. package/esm/checkpoint/redis.mjs +1 -1
  65. package/esm/checkpoint/redis.mjs.map +1 -1
  66. package/esm/config.d.mts +1 -1
  67. package/esm/config.d.mts.map +1 -1
  68. package/esm/config.mjs +1 -1
  69. package/esm/config.mjs.map +1 -1
  70. package/esm/contracts/agent/agent-options.type.d.mts +1 -1
  71. package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
  72. package/esm/contracts/agent/agent-snapshot.type.d.mts +1 -1
  73. package/esm/contracts/agent/agent-snapshot.type.d.mts.map +1 -1
  74. package/esm/contracts/agent/agent.contract.d.mts +1 -1
  75. package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
  76. package/esm/contracts/agent/eval.type.d.mts +1 -1
  77. package/esm/contracts/agent/eval.type.d.mts.map +1 -1
  78. package/esm/contracts/attachment-policy.type.d.mts +1 -1
  79. package/esm/contracts/attachment-policy.type.d.mts.map +1 -1
  80. package/esm/contracts/attachment.type.d.mts +1 -1
  81. package/esm/contracts/attachment.type.d.mts.map +1 -1
  82. package/esm/contracts/content-part.type.d.mts +1 -1
  83. package/esm/contracts/content-part.type.d.mts.map +1 -1
  84. package/esm/contracts/conversation-message.type.d.mts +1 -1
  85. package/esm/contracts/conversation-message.type.d.mts.map +1 -1
  86. package/esm/contracts/embedder.contract.d.mts +1 -1
  87. package/esm/contracts/embedder.contract.d.mts.map +1 -1
  88. package/esm/contracts/end.type.d.mts +1 -1
  89. package/esm/contracts/end.type.d.mts.map +1 -1
  90. package/esm/contracts/end.type.mjs +1 -1
  91. package/esm/contracts/end.type.mjs.map +1 -1
  92. package/esm/contracts/events/agent-events.type.d.mts +1 -1
  93. package/esm/contracts/events/agent-events.type.d.mts.map +1 -1
  94. package/esm/contracts/events/complete-event.type.d.mts +1 -1
  95. package/esm/contracts/events/complete-event.type.d.mts.map +1 -1
  96. package/esm/contracts/events/event-identity.type.d.mts +1 -1
  97. package/esm/contracts/events/event-identity.type.d.mts.map +1 -1
  98. package/esm/contracts/events/event-map.type.d.mts +1 -1
  99. package/esm/contracts/events/event-map.type.d.mts.map +1 -1
  100. package/esm/contracts/events/supervisor-events.type.d.mts +1 -1
  101. package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
  102. package/esm/contracts/events/usage-event.type.d.mts +1 -1
  103. package/esm/contracts/events/usage-event.type.d.mts.map +1 -1
  104. package/esm/contracts/events/workflow-events.type.d.mts +1 -1
  105. package/esm/contracts/events/workflow-events.type.d.mts.map +1 -1
  106. package/esm/contracts/executable.contract.d.mts +1 -1
  107. package/esm/contracts/executable.contract.d.mts.map +1 -1
  108. package/esm/contracts/fallback-model.contract.d.mts +1 -1
  109. package/esm/contracts/fallback-model.contract.d.mts.map +1 -1
  110. package/esm/contracts/finish-reason.type.d.mts +1 -1
  111. package/esm/contracts/finish-reason.type.d.mts.map +1 -1
  112. package/esm/contracts/image-model.contract.d.mts +1 -1
  113. package/esm/contracts/image-model.contract.d.mts.map +1 -1
  114. package/esm/contracts/memory/memory-config.type.d.mts +1 -1
  115. package/esm/contracts/memory/memory-config.type.d.mts.map +1 -1
  116. package/esm/contracts/memory/memory-item.type.d.mts +1 -1
  117. package/esm/contracts/memory/memory-item.type.d.mts.map +1 -1
  118. package/esm/contracts/memory/memory.contract.d.mts +1 -1
  119. package/esm/contracts/memory/memory.contract.d.mts.map +1 -1
  120. package/esm/contracts/memory/recall-options.type.d.mts +1 -1
  121. package/esm/contracts/memory/recall-options.type.d.mts.map +1 -1
  122. package/esm/contracts/middleware/middleware-context.type.d.mts +1 -1
  123. package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
  124. package/esm/contracts/middleware/middleware-state.type.d.mts +1 -1
  125. package/esm/contracts/middleware/middleware-state.type.d.mts.map +1 -1
  126. package/esm/contracts/middleware/middleware.contract.d.mts +1 -1
  127. package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
  128. package/esm/contracts/model-tool-call-request.type.d.mts +1 -1
  129. package/esm/contracts/model-tool-call-request.type.d.mts.map +1 -1
  130. package/esm/contracts/model.contract.d.mts +9 -1
  131. package/esm/contracts/model.contract.d.mts.map +1 -1
  132. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +1 -1
  133. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -1
  134. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +1 -1
  135. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -1
  136. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +1 -1
  137. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
  138. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +1 -1
  139. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -1
  140. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +1 -1
  141. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -1
  142. package/esm/contracts/orchestrator/orchestrator.contract.d.mts +1 -1
  143. package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -1
  144. package/esm/contracts/orchestrator/session-lock.contract.d.mts +1 -1
  145. package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -1
  146. package/esm/contracts/orchestrator/session.contract.d.mts +1 -1
  147. package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -1
  148. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +1 -1
  149. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -1
  150. package/esm/contracts/placeholders.type.d.mts +1 -1
  151. package/esm/contracts/placeholders.type.d.mts.map +1 -1
  152. package/esm/contracts/planner/planner-capability.type.d.mts +1 -1
  153. package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -1
  154. package/esm/contracts/planner/planner-config.type.d.mts +1 -1
  155. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
  156. package/esm/contracts/planner/planner-execute-options.type.d.mts +1 -1
  157. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
  158. package/esm/contracts/planner/planner-plan.type.d.mts +1 -1
  159. package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -1
  160. package/esm/contracts/planner/planner-result.type.d.mts +1 -1
  161. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
  162. package/esm/contracts/planner/planner-snapshot.type.d.mts +1 -1
  163. package/esm/contracts/planner/planner-snapshot.type.d.mts.map +1 -1
  164. package/esm/contracts/planner/planner.contract.d.mts +1 -1
  165. package/esm/contracts/planner/planner.contract.d.mts.map +1 -1
  166. package/esm/contracts/result/agent-result.type.d.mts +1 -1
  167. package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
  168. package/esm/contracts/result/attempt-entry.type.d.mts +1 -1
  169. package/esm/contracts/result/attempt-entry.type.d.mts.map +1 -1
  170. package/esm/contracts/result/base-report.type.d.mts +1 -1
  171. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  172. package/esm/contracts/result/base-report.type.mjs +1 -1
  173. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  174. package/esm/contracts/result/base-result.type.d.mts +1 -1
  175. package/esm/contracts/result/base-result.type.d.mts.map +1 -1
  176. package/esm/contracts/result/execute-result.type.d.mts +1 -1
  177. package/esm/contracts/result/execute-result.type.d.mts.map +1 -1
  178. package/esm/contracts/result/execution-report.type.d.mts +1 -1
  179. package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
  180. package/esm/contracts/result/llm-trip.type.d.mts +1 -1
  181. package/esm/contracts/result/llm-trip.type.d.mts.map +1 -1
  182. package/esm/contracts/result/model-pricing.type.d.mts +1 -1
  183. package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
  184. package/esm/contracts/result/orchestrator-result.type.d.mts +1 -1
  185. package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -1
  186. package/esm/contracts/result/session-send-result.type.d.mts +1 -1
  187. package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
  188. package/esm/contracts/result/step-result.type.d.mts +12 -2
  189. package/esm/contracts/result/step-result.type.d.mts.map +1 -1
  190. package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
  191. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
  192. package/esm/contracts/result/tool-call.type.d.mts +1 -1
  193. package/esm/contracts/result/tool-call.type.d.mts.map +1 -1
  194. package/esm/contracts/result/usage.type.d.mts +1 -1
  195. package/esm/contracts/result/usage.type.d.mts.map +1 -1
  196. package/esm/contracts/result/workflow-result.type.d.mts +1 -1
  197. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
  198. package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
  199. package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -1
  200. package/esm/contracts/speech-model.contract.d.mts +1 -1
  201. package/esm/contracts/speech-model.contract.d.mts.map +1 -1
  202. package/esm/contracts/stream/stream-event.type.d.mts +1 -1
  203. package/esm/contracts/stream/stream-event.type.d.mts.map +1 -1
  204. package/esm/contracts/stream/stream.contract.d.mts +1 -1
  205. package/esm/contracts/stream/stream.contract.d.mts.map +1 -1
  206. package/esm/contracts/streaming-tool-guard-config.type.d.mts +1 -1
  207. package/esm/contracts/streaming-tool-guard-config.type.d.mts.map +1 -1
  208. package/esm/contracts/supervisor/ack-entry.type.d.mts +1 -1
  209. package/esm/contracts/supervisor/ack-entry.type.d.mts.map +1 -1
  210. package/esm/contracts/supervisor/classifier-context.type.d.mts +1 -1
  211. package/esm/contracts/supervisor/classifier-context.type.d.mts.map +1 -1
  212. package/esm/contracts/supervisor/dispatch-context.type.d.mts +1 -1
  213. package/esm/contracts/supervisor/dispatch-context.type.d.mts.map +1 -1
  214. package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
  215. package/esm/contracts/supervisor/evaluate-context.type.d.mts.map +1 -1
  216. package/esm/contracts/supervisor/intent-entry.type.d.mts +1 -1
  217. package/esm/contracts/supervisor/intent-entry.type.d.mts.map +1 -1
  218. package/esm/contracts/supervisor/iteration-snapshot.type.d.mts +1 -1
  219. package/esm/contracts/supervisor/iteration-snapshot.type.d.mts.map +1 -1
  220. package/esm/contracts/supervisor/next.type.d.mts +1 -1
  221. package/esm/contracts/supervisor/next.type.d.mts.map +1 -1
  222. package/esm/contracts/supervisor/route-context.type.d.mts +1 -1
  223. package/esm/contracts/supervisor/route-context.type.d.mts.map +1 -1
  224. package/esm/contracts/supervisor/router-entry.type.d.mts +1 -1
  225. package/esm/contracts/supervisor/router-entry.type.d.mts.map +1 -1
  226. package/esm/contracts/supervisor/supervisor-config.type.d.mts +1 -1
  227. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  228. package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts +1 -1
  229. package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts.map +1 -1
  230. package/esm/contracts/supervisor/supervisor-input.type.d.mts +1 -1
  231. package/esm/contracts/supervisor/supervisor-input.type.d.mts.map +1 -1
  232. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
  233. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts.map +1 -1
  234. package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts +1 -1
  235. package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts.map +1 -1
  236. package/esm/contracts/supervisor/supervisor.contract.d.mts +1 -1
  237. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
  238. package/esm/contracts/system-prompt.contract.d.mts +1 -1
  239. package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
  240. package/esm/contracts/team/team-config.type.d.mts +1 -1
  241. package/esm/contracts/team/team-config.type.d.mts.map +1 -1
  242. package/esm/contracts/tool.contract.d.mts +1 -1
  243. package/esm/contracts/tool.contract.d.mts.map +1 -1
  244. package/esm/contracts/transcription-model.contract.d.mts +1 -1
  245. package/esm/contracts/transcription-model.contract.d.mts.map +1 -1
  246. package/esm/contracts/workflow/next-step-result.type.d.mts +1 -1
  247. package/esm/contracts/workflow/next-step-result.type.d.mts.map +1 -1
  248. package/esm/contracts/workflow/retry-config.type.d.mts +1 -1
  249. package/esm/contracts/workflow/retry-config.type.d.mts.map +1 -1
  250. package/esm/contracts/workflow/step.contract.d.mts +1 -1
  251. package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
  252. package/esm/contracts/workflow/workflow-context.type.d.mts +1 -1
  253. package/esm/contracts/workflow/workflow-context.type.d.mts.map +1 -1
  254. package/esm/contracts/workflow/workflow-snapshot.type.d.mts +1 -1
  255. package/esm/contracts/workflow/workflow-snapshot.type.d.mts.map +1 -1
  256. package/esm/contracts/workflow/workflow.contract.d.mts +1 -1
  257. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  258. package/esm/errors/agent-cancelled-error.d.mts +1 -1
  259. package/esm/errors/agent-cancelled-error.d.mts.map +1 -1
  260. package/esm/errors/agent-cancelled-error.mjs +1 -1
  261. package/esm/errors/agent-cancelled-error.mjs.map +1 -1
  262. package/esm/errors/agent-drift-error.d.mts +1 -1
  263. package/esm/errors/agent-drift-error.d.mts.map +1 -1
  264. package/esm/errors/agent-drift-error.mjs +1 -1
  265. package/esm/errors/agent-drift-error.mjs.map +1 -1
  266. package/esm/errors/agent-execution-error.d.mts +1 -1
  267. package/esm/errors/agent-execution-error.d.mts.map +1 -1
  268. package/esm/errors/agent-execution-error.mjs +1 -1
  269. package/esm/errors/agent-execution-error.mjs.map +1 -1
  270. package/esm/errors/agent-max-trips-error.d.mts +1 -1
  271. package/esm/errors/agent-max-trips-error.d.mts.map +1 -1
  272. package/esm/errors/agent-max-trips-error.mjs +1 -1
  273. package/esm/errors/agent-max-trips-error.mjs.map +1 -1
  274. package/esm/errors/ai-error.d.mts +1 -1
  275. package/esm/errors/ai-error.d.mts.map +1 -1
  276. package/esm/errors/ai-error.mjs +1 -1
  277. package/esm/errors/ai-error.mjs.map +1 -1
  278. package/esm/errors/budget-exceeded-error.d.mts +1 -1
  279. package/esm/errors/budget-exceeded-error.d.mts.map +1 -1
  280. package/esm/errors/budget-exceeded-error.mjs +1 -1
  281. package/esm/errors/budget-exceeded-error.mjs.map +1 -1
  282. package/esm/errors/content-filter-error.d.mts +1 -1
  283. package/esm/errors/content-filter-error.d.mts.map +1 -1
  284. package/esm/errors/content-filter-error.mjs +1 -1
  285. package/esm/errors/content-filter-error.mjs.map +1 -1
  286. package/esm/errors/context-length-exceeded-error.d.mts +1 -1
  287. package/esm/errors/context-length-exceeded-error.d.mts.map +1 -1
  288. package/esm/errors/context-length-exceeded-error.mjs +1 -1
  289. package/esm/errors/context-length-exceeded-error.mjs.map +1 -1
  290. package/esm/errors/error-category.type.d.mts +1 -1
  291. package/esm/errors/error-category.type.d.mts.map +1 -1
  292. package/esm/errors/error-code.type.d.mts +1 -1
  293. package/esm/errors/error-code.type.d.mts.map +1 -1
  294. package/esm/errors/guardrail-violation-error.d.mts +1 -1
  295. package/esm/errors/guardrail-violation-error.d.mts.map +1 -1
  296. package/esm/errors/guardrail-violation-error.mjs +1 -1
  297. package/esm/errors/guardrail-violation-error.mjs.map +1 -1
  298. package/esm/errors/invalid-request-error.d.mts +1 -1
  299. package/esm/errors/invalid-request-error.d.mts.map +1 -1
  300. package/esm/errors/invalid-request-error.mjs +1 -1
  301. package/esm/errors/invalid-request-error.mjs.map +1 -1
  302. package/esm/errors/max-iterations-error.d.mts +1 -1
  303. package/esm/errors/max-iterations-error.d.mts.map +1 -1
  304. package/esm/errors/max-iterations-error.mjs +1 -1
  305. package/esm/errors/max-iterations-error.mjs.map +1 -1
  306. package/esm/errors/max-steps-exceeded-error.d.mts +1 -1
  307. package/esm/errors/max-steps-exceeded-error.d.mts.map +1 -1
  308. package/esm/errors/max-steps-exceeded-error.mjs +1 -1
  309. package/esm/errors/max-steps-exceeded-error.mjs.map +1 -1
  310. package/esm/errors/orchestrator-cancelled-error.d.mts +1 -1
  311. package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -1
  312. package/esm/errors/orchestrator-cancelled-error.mjs +1 -1
  313. package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -1
  314. package/esm/errors/orchestrator-config-error.d.mts +1 -1
  315. package/esm/errors/orchestrator-config-error.d.mts.map +1 -1
  316. package/esm/errors/orchestrator-config-error.mjs +1 -1
  317. package/esm/errors/orchestrator-config-error.mjs.map +1 -1
  318. package/esm/errors/orchestrator-drift-error.d.mts +1 -1
  319. package/esm/errors/orchestrator-drift-error.d.mts.map +1 -1
  320. package/esm/errors/orchestrator-drift-error.mjs +1 -1
  321. package/esm/errors/orchestrator-drift-error.mjs.map +1 -1
  322. package/esm/errors/orchestrator-failed-error.d.mts +1 -1
  323. package/esm/errors/orchestrator-failed-error.d.mts.map +1 -1
  324. package/esm/errors/orchestrator-failed-error.mjs +1 -1
  325. package/esm/errors/orchestrator-failed-error.mjs.map +1 -1
  326. package/esm/errors/outbound-policy-error.d.mts +1 -1
  327. package/esm/errors/outbound-policy-error.d.mts.map +1 -1
  328. package/esm/errors/outbound-policy-error.mjs +1 -1
  329. package/esm/errors/outbound-policy-error.mjs.map +1 -1
  330. package/esm/errors/planner-cancelled-error.d.mts +1 -1
  331. package/esm/errors/planner-cancelled-error.d.mts.map +1 -1
  332. package/esm/errors/planner-cancelled-error.mjs +1 -1
  333. package/esm/errors/planner-cancelled-error.mjs.map +1 -1
  334. package/esm/errors/planner-drift-error.d.mts +1 -1
  335. package/esm/errors/planner-drift-error.d.mts.map +1 -1
  336. package/esm/errors/planner-drift-error.mjs +1 -1
  337. package/esm/errors/planner-drift-error.mjs.map +1 -1
  338. package/esm/errors/planner-failed-error.d.mts +1 -1
  339. package/esm/errors/planner-failed-error.d.mts.map +1 -1
  340. package/esm/errors/planner-failed-error.mjs +1 -1
  341. package/esm/errors/planner-failed-error.mjs.map +1 -1
  342. package/esm/errors/planner-plan-invalid-error.d.mts +1 -1
  343. package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -1
  344. package/esm/errors/planner-plan-invalid-error.mjs +1 -1
  345. package/esm/errors/planner-plan-invalid-error.mjs.map +1 -1
  346. package/esm/errors/prompt-refinement-error.d.mts +1 -1
  347. package/esm/errors/prompt-refinement-error.d.mts.map +1 -1
  348. package/esm/errors/prompt-refinement-error.mjs +1 -1
  349. package/esm/errors/prompt-refinement-error.mjs.map +1 -1
  350. package/esm/errors/provider-auth-error.d.mts +1 -1
  351. package/esm/errors/provider-auth-error.d.mts.map +1 -1
  352. package/esm/errors/provider-auth-error.mjs +1 -1
  353. package/esm/errors/provider-auth-error.mjs.map +1 -1
  354. package/esm/errors/provider-error.d.mts +1 -1
  355. package/esm/errors/provider-error.d.mts.map +1 -1
  356. package/esm/errors/provider-error.mjs +1 -1
  357. package/esm/errors/provider-error.mjs.map +1 -1
  358. package/esm/errors/provider-rate-limit-error.d.mts +1 -1
  359. package/esm/errors/provider-rate-limit-error.d.mts.map +1 -1
  360. package/esm/errors/provider-rate-limit-error.mjs +1 -1
  361. package/esm/errors/provider-rate-limit-error.mjs.map +1 -1
  362. package/esm/errors/provider-timeout-error.d.mts +1 -1
  363. package/esm/errors/provider-timeout-error.d.mts.map +1 -1
  364. package/esm/errors/provider-timeout-error.mjs +1 -1
  365. package/esm/errors/provider-timeout-error.mjs.map +1 -1
  366. package/esm/errors/quota-exceeded-error.d.mts +1 -1
  367. package/esm/errors/quota-exceeded-error.d.mts.map +1 -1
  368. package/esm/errors/quota-exceeded-error.mjs +1 -1
  369. package/esm/errors/quota-exceeded-error.mjs.map +1 -1
  370. package/esm/errors/routing-error.d.mts +1 -1
  371. package/esm/errors/routing-error.d.mts.map +1 -1
  372. package/esm/errors/routing-error.mjs +1 -1
  373. package/esm/errors/routing-error.mjs.map +1 -1
  374. package/esm/errors/schema-validation-error.d.mts +1 -1
  375. package/esm/errors/schema-validation-error.d.mts.map +1 -1
  376. package/esm/errors/schema-validation-error.mjs +1 -1
  377. package/esm/errors/schema-validation-error.mjs.map +1 -1
  378. package/esm/errors/step-failed-error.d.mts +1 -1
  379. package/esm/errors/step-failed-error.d.mts.map +1 -1
  380. package/esm/errors/step-failed-error.mjs +1 -1
  381. package/esm/errors/step-failed-error.mjs.map +1 -1
  382. package/esm/errors/supervisor-cancelled-error.d.mts +1 -1
  383. package/esm/errors/supervisor-cancelled-error.d.mts.map +1 -1
  384. package/esm/errors/supervisor-cancelled-error.mjs +1 -1
  385. package/esm/errors/supervisor-cancelled-error.mjs.map +1 -1
  386. package/esm/errors/supervisor-drift-error.d.mts +1 -1
  387. package/esm/errors/supervisor-drift-error.d.mts.map +1 -1
  388. package/esm/errors/supervisor-drift-error.mjs +1 -1
  389. package/esm/errors/supervisor-drift-error.mjs.map +1 -1
  390. package/esm/errors/supervisor-failed-error.d.mts +1 -1
  391. package/esm/errors/supervisor-failed-error.d.mts.map +1 -1
  392. package/esm/errors/supervisor-failed-error.mjs +1 -1
  393. package/esm/errors/supervisor-failed-error.mjs.map +1 -1
  394. package/esm/errors/supervisor-routing-error.d.mts +1 -1
  395. package/esm/errors/supervisor-routing-error.d.mts.map +1 -1
  396. package/esm/errors/supervisor-routing-error.mjs +1 -1
  397. package/esm/errors/supervisor-routing-error.mjs.map +1 -1
  398. package/esm/errors/tool-execution-error.d.mts +1 -1
  399. package/esm/errors/tool-execution-error.d.mts.map +1 -1
  400. package/esm/errors/tool-execution-error.mjs +1 -1
  401. package/esm/errors/tool-execution-error.mjs.map +1 -1
  402. package/esm/errors/workflow-cancelled-error.d.mts +1 -1
  403. package/esm/errors/workflow-cancelled-error.d.mts.map +1 -1
  404. package/esm/errors/workflow-cancelled-error.mjs +1 -1
  405. package/esm/errors/workflow-cancelled-error.mjs.map +1 -1
  406. package/esm/errors/workflow-drift-error.d.mts +1 -1
  407. package/esm/errors/workflow-drift-error.d.mts.map +1 -1
  408. package/esm/errors/workflow-drift-error.mjs +1 -1
  409. package/esm/errors/workflow-drift-error.mjs.map +1 -1
  410. package/esm/errors/workflow-error.d.mts +1 -1
  411. package/esm/errors/workflow-error.d.mts.map +1 -1
  412. package/esm/errors/workflow-error.mjs +1 -1
  413. package/esm/errors/workflow-error.mjs.map +1 -1
  414. package/esm/eval/dataset.d.mts +1 -1
  415. package/esm/eval/dataset.d.mts.map +1 -1
  416. package/esm/eval/dataset.mjs +1 -1
  417. package/esm/eval/dataset.mjs.map +1 -1
  418. package/esm/eval/dataset.type.d.mts +1 -1
  419. package/esm/eval/dataset.type.d.mts.map +1 -1
  420. package/esm/eval/eval-runner.d.mts +1 -1
  421. package/esm/eval/eval-runner.d.mts.map +1 -1
  422. package/esm/eval/eval-runner.mjs +1 -1
  423. package/esm/eval/eval-runner.mjs.map +1 -1
  424. package/esm/eval/index.d.mts +1 -1
  425. package/esm/eval/index.d.mts.map +1 -1
  426. package/esm/eval/index.mjs +1 -1
  427. package/esm/eval/index.mjs.map +1 -1
  428. package/esm/eval/judge-scorer.d.mts +1 -1
  429. package/esm/eval/judge-scorer.d.mts.map +1 -1
  430. package/esm/eval/judge-scorer.mjs +1 -1
  431. package/esm/eval/judge-scorer.mjs.map +1 -1
  432. package/esm/eval/regression.d.mts +1 -1
  433. package/esm/eval/regression.d.mts.map +1 -1
  434. package/esm/eval/regression.mjs +1 -1
  435. package/esm/eval/regression.mjs.map +1 -1
  436. package/esm/eval/report-json.d.mts +1 -1
  437. package/esm/eval/report-json.d.mts.map +1 -1
  438. package/esm/eval/report-json.mjs +1 -1
  439. package/esm/eval/report-json.mjs.map +1 -1
  440. package/esm/eval/report-junit.d.mts +1 -1
  441. package/esm/eval/report-junit.d.mts.map +1 -1
  442. package/esm/eval/report-junit.mjs +1 -1
  443. package/esm/eval/report-junit.mjs.map +1 -1
  444. package/esm/eval/scorers.d.mts +1 -1
  445. package/esm/eval/scorers.d.mts.map +1 -1
  446. package/esm/eval/scorers.mjs +1 -1
  447. package/esm/eval/scorers.mjs.map +1 -1
  448. package/esm/guard/contracts/guard-options.type.d.mts +1 -1
  449. package/esm/guard/contracts/guard-options.type.d.mts.map +1 -1
  450. package/esm/guard/contracts/guardrail.contract.d.mts +1 -1
  451. package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -1
  452. package/esm/guard/contracts/openai-client.contract.d.mts +1 -1
  453. package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -1
  454. package/esm/guard/contracts/verdict.type.d.mts +1 -1
  455. package/esm/guard/contracts/verdict.type.d.mts.map +1 -1
  456. package/esm/guard/detectors/injection.d.mts +1 -1
  457. package/esm/guard/detectors/injection.d.mts.map +1 -1
  458. package/esm/guard/detectors/injection.mjs +1 -1
  459. package/esm/guard/detectors/injection.mjs.map +1 -1
  460. package/esm/guard/detectors/moderation.d.mts +1 -1
  461. package/esm/guard/detectors/moderation.d.mts.map +1 -1
  462. package/esm/guard/detectors/moderation.mjs +1 -1
  463. package/esm/guard/detectors/moderation.mjs.map +1 -1
  464. package/esm/guard/detectors/pii.d.mts +1 -1
  465. package/esm/guard/detectors/pii.d.mts.map +1 -1
  466. package/esm/guard/detectors/pii.mjs +1 -1
  467. package/esm/guard/detectors/pii.mjs.map +1 -1
  468. package/esm/guard/detectors/topic.d.mts +1 -1
  469. package/esm/guard/detectors/topic.d.mts.map +1 -1
  470. package/esm/guard/detectors/topic.mjs +1 -1
  471. package/esm/guard/detectors/topic.mjs.map +1 -1
  472. package/esm/guard/errors.d.mts +1 -1
  473. package/esm/guard/errors.d.mts.map +1 -1
  474. package/esm/guard/errors.mjs +1 -1
  475. package/esm/guard/errors.mjs.map +1 -1
  476. package/esm/guard/guard.d.mts +1 -1
  477. package/esm/guard/guard.d.mts.map +1 -1
  478. package/esm/guard/guard.mjs +1 -1
  479. package/esm/guard/guard.mjs.map +1 -1
  480. package/esm/guard/guardrail.d.mts +1 -1
  481. package/esm/guard/guardrail.d.mts.map +1 -1
  482. package/esm/guard/guardrail.mjs +1 -1
  483. package/esm/guard/guardrail.mjs.map +1 -1
  484. package/esm/human/contracts/approval.type.d.mts +1 -1
  485. package/esm/human/contracts/approval.type.d.mts.map +1 -1
  486. package/esm/human/contracts/human-approval.type.d.mts +1 -1
  487. package/esm/human/contracts/human-approval.type.d.mts.map +1 -1
  488. package/esm/human/contracts/interrupt-store.contract.d.mts +1 -1
  489. package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -1
  490. package/esm/human/contracts/resume.type.d.mts +1 -1
  491. package/esm/human/contracts/resume.type.d.mts.map +1 -1
  492. package/esm/human/errors.d.mts +1 -1
  493. package/esm/human/errors.d.mts.map +1 -1
  494. package/esm/human/errors.mjs +1 -1
  495. package/esm/human/errors.mjs.map +1 -1
  496. package/esm/human/human-approval.d.mts +1 -1
  497. package/esm/human/human-approval.d.mts.map +1 -1
  498. package/esm/human/human-approval.mjs +1 -1
  499. package/esm/human/human-approval.mjs.map +1 -1
  500. package/esm/human/policy.d.mts +1 -1
  501. package/esm/human/policy.d.mts.map +1 -1
  502. package/esm/human/policy.mjs +1 -1
  503. package/esm/human/policy.mjs.map +1 -1
  504. package/esm/human/register.mjs +1 -1
  505. package/esm/human/register.mjs.map +1 -1
  506. package/esm/human/resume-seed.mjs +1 -1
  507. package/esm/human/resume-seed.mjs.map +1 -1
  508. package/esm/human/resume.d.mts +1 -1
  509. package/esm/human/resume.d.mts.map +1 -1
  510. package/esm/human/resume.mjs +1 -1
  511. package/esm/human/resume.mjs.map +1 -1
  512. package/esm/human/stores/memory.d.mts +1 -1
  513. package/esm/human/stores/memory.d.mts.map +1 -1
  514. package/esm/human/stores/memory.mjs +1 -1
  515. package/esm/human/stores/memory.mjs.map +1 -1
  516. package/esm/human/stores/pg.d.mts +1 -1
  517. package/esm/human/stores/pg.d.mts.map +1 -1
  518. package/esm/human/stores/pg.mjs +1 -1
  519. package/esm/human/stores/pg.mjs.map +1 -1
  520. package/esm/human/stores/redis.d.mts +1 -1
  521. package/esm/human/stores/redis.d.mts.map +1 -1
  522. package/esm/human/stores/redis.mjs +1 -1
  523. package/esm/human/stores/redis.mjs.map +1 -1
  524. package/esm/image/image-cost.d.mts +1 -1
  525. package/esm/image/image-cost.d.mts.map +1 -1
  526. package/esm/image/image-cost.mjs +1 -1
  527. package/esm/image/image-cost.mjs.map +1 -1
  528. package/esm/image/image.d.mts +1 -1
  529. package/esm/image/image.d.mts.map +1 -1
  530. package/esm/image/image.mjs +1 -1
  531. package/esm/image/image.mjs.map +1 -1
  532. package/esm/memory/derive-id.mjs +1 -1
  533. package/esm/memory/derive-id.mjs.map +1 -1
  534. package/esm/memory/episodic-memory.mjs +1 -1
  535. package/esm/memory/episodic-memory.mjs.map +1 -1
  536. package/esm/memory/memory.d.mts +1 -1
  537. package/esm/memory/memory.d.mts.map +1 -1
  538. package/esm/memory/memory.mjs +1 -1
  539. package/esm/memory/memory.mjs.map +1 -1
  540. package/esm/memory/procedural-memory.mjs +1 -1
  541. package/esm/memory/procedural-memory.mjs.map +1 -1
  542. package/esm/memory/semantic-memory.mjs +1 -1
  543. package/esm/memory/semantic-memory.mjs.map +1 -1
  544. package/esm/memory/working-memory.mjs +1 -1
  545. package/esm/memory/working-memory.mjs.map +1 -1
  546. package/esm/middleware/builtins/budget-contract.type.d.mts +1 -1
  547. package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -1
  548. package/esm/middleware/builtins/budget.d.mts +1 -1
  549. package/esm/middleware/builtins/budget.d.mts.map +1 -1
  550. package/esm/middleware/builtins/budget.mjs +1 -1
  551. package/esm/middleware/builtins/budget.mjs.map +1 -1
  552. package/esm/middleware/builtins/guardrail.d.mts +1 -1
  553. package/esm/middleware/builtins/guardrail.d.mts.map +1 -1
  554. package/esm/middleware/builtins/guardrail.mjs +1 -1
  555. package/esm/middleware/builtins/guardrail.mjs.map +1 -1
  556. package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
  557. package/esm/middleware/builtins/semantic-cache.d.mts.map +1 -1
  558. package/esm/middleware/builtins/semantic-cache.mjs +1 -1
  559. package/esm/middleware/builtins/semantic-cache.mjs.map +1 -1
  560. package/esm/middleware/helpers/compose.d.mts +1 -1
  561. package/esm/middleware/helpers/compose.d.mts.map +1 -1
  562. package/esm/middleware/helpers/compose.mjs +1 -1
  563. package/esm/middleware/helpers/compose.mjs.map +1 -1
  564. package/esm/middleware/helpers/for-tool.d.mts +1 -1
  565. package/esm/middleware/helpers/for-tool.d.mts.map +1 -1
  566. package/esm/middleware/helpers/for-tool.mjs +1 -1
  567. package/esm/middleware/helpers/for-tool.mjs.map +1 -1
  568. package/esm/middleware/pipeline.d.mts +1 -1
  569. package/esm/middleware/pipeline.d.mts.map +1 -1
  570. package/esm/middleware/pipeline.mjs +1 -1
  571. package/esm/middleware/pipeline.mjs.map +1 -1
  572. package/esm/middleware/utils/extract-user-text.d.mts +1 -1
  573. package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
  574. package/esm/middleware/utils/extract-user-text.mjs +1 -1
  575. package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
  576. package/esm/middleware/utils/namespaced-state.d.mts +1 -1
  577. package/esm/middleware/utils/namespaced-state.d.mts.map +1 -1
  578. package/esm/middleware/utils/namespaced-state.mjs +1 -1
  579. package/esm/middleware/utils/namespaced-state.mjs.map +1 -1
  580. package/esm/mock/mock-agent.d.mts +1 -1
  581. package/esm/mock/mock-agent.d.mts.map +1 -1
  582. package/esm/mock/mock-agent.mjs +1 -1
  583. package/esm/mock/mock-agent.mjs.map +1 -1
  584. package/esm/mock/mock-config.type.d.mts +1 -1
  585. package/esm/mock/mock-config.type.d.mts.map +1 -1
  586. package/esm/mock/mock-image-model.d.mts +1 -1
  587. package/esm/mock/mock-image-model.d.mts.map +1 -1
  588. package/esm/mock/mock-image-model.mjs +1 -1
  589. package/esm/mock/mock-image-model.mjs.map +1 -1
  590. package/esm/mock/mock-model.d.mts +1 -1
  591. package/esm/mock/mock-model.d.mts.map +1 -1
  592. package/esm/mock/mock-model.mjs +1 -1
  593. package/esm/mock/mock-model.mjs.map +1 -1
  594. package/esm/mock/mock-router.d.mts +1 -1
  595. package/esm/mock/mock-router.d.mts.map +1 -1
  596. package/esm/mock/mock-router.mjs +1 -1
  597. package/esm/mock/mock-router.mjs.map +1 -1
  598. package/esm/mock/mock-sdk.d.mts +1 -1
  599. package/esm/mock/mock-sdk.d.mts.map +1 -1
  600. package/esm/mock/mock-sdk.mjs +1 -1
  601. package/esm/mock/mock-sdk.mjs.map +1 -1
  602. package/esm/mock/mock-speech-model.d.mts +1 -1
  603. package/esm/mock/mock-speech-model.d.mts.map +1 -1
  604. package/esm/mock/mock-speech-model.mjs +1 -1
  605. package/esm/mock/mock-speech-model.mjs.map +1 -1
  606. package/esm/mock/mock-transcription-model.d.mts +1 -1
  607. package/esm/mock/mock-transcription-model.d.mts.map +1 -1
  608. package/esm/mock/mock-transcription-model.mjs +1 -1
  609. package/esm/mock/mock-transcription-model.mjs.map +1 -1
  610. package/esm/model/fallback-model.d.mts +1 -1
  611. package/esm/model/fallback-model.d.mts.map +1 -1
  612. package/esm/model/fallback-model.mjs +1 -1
  613. package/esm/model/fallback-model.mjs.map +1 -1
  614. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +1 -1
  615. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -1
  616. package/esm/node_modules/@vitest/expect/dist/index.mjs +1 -1
  617. package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -1
  618. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +1 -1
  619. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -1
  620. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1 -1
  621. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -1
  622. package/esm/node_modules/@vitest/snapshot/dist/index.mjs +1 -1
  623. package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -1
  624. package/esm/node_modules/@vitest/spy/dist/index.mjs +1 -1
  625. package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -1
  626. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +1 -1
  627. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -1
  628. package/esm/node_modules/@vitest/utils/dist/diff.mjs +1 -1
  629. package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -1
  630. package/esm/node_modules/@vitest/utils/dist/display.mjs +1 -1
  631. package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -1
  632. package/esm/node_modules/@vitest/utils/dist/error.mjs +1 -1
  633. package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -1
  634. package/esm/node_modules/@vitest/utils/dist/helpers.mjs +1 -1
  635. package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -1
  636. package/esm/node_modules/@vitest/utils/dist/offset.mjs +1 -1
  637. package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -1
  638. package/esm/node_modules/@vitest/utils/dist/serialize.mjs +1 -1
  639. package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -1
  640. package/esm/node_modules/@vitest/utils/dist/source-map.mjs +1 -1
  641. package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -1
  642. package/esm/node_modules/@vitest/utils/dist/timers.mjs +1 -1
  643. package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -1
  644. package/esm/node_modules/chai/index.mjs +1 -1
  645. package/esm/node_modules/chai/index.mjs.map +1 -1
  646. package/esm/node_modules/magic-string/dist/magic-string.es.mjs +1 -1
  647. package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -1
  648. package/esm/node_modules/tinyrainbow/dist/index.mjs +1 -1
  649. package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -1
  650. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +1 -1
  651. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -1
  652. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +1 -1
  653. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -1
  654. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +1 -1
  655. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -1
  656. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +1 -1
  657. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -1
  658. package/esm/object-stream/parse-partial-json.d.mts +1 -1
  659. package/esm/object-stream/parse-partial-json.d.mts.map +1 -1
  660. package/esm/object-stream/parse-partial-json.mjs +1 -1
  661. package/esm/object-stream/parse-partial-json.mjs.map +1 -1
  662. package/esm/object-stream/stream-object.d.mts +1 -1
  663. package/esm/object-stream/stream-object.d.mts.map +1 -1
  664. package/esm/object-stream/stream-object.mjs +1 -1
  665. package/esm/object-stream/stream-object.mjs.map +1 -1
  666. package/esm/observe/observer-registry.d.mts +1 -1
  667. package/esm/observe/observer-registry.d.mts.map +1 -1
  668. package/esm/observe/observer-registry.mjs +1 -1
  669. package/esm/observe/observer-registry.mjs.map +1 -1
  670. package/esm/observe/observer.contract.d.mts +1 -1
  671. package/esm/observe/observer.contract.d.mts.map +1 -1
  672. package/esm/observe/resolve-observers.d.mts +1 -1
  673. package/esm/observe/resolve-observers.d.mts.map +1 -1
  674. package/esm/observe/resolve-observers.mjs +1 -1
  675. package/esm/observe/resolve-observers.mjs.map +1 -1
  676. package/esm/orchestrator/as-tool.d.mts +1 -1
  677. package/esm/orchestrator/as-tool.d.mts.map +1 -1
  678. package/esm/orchestrator/as-tool.mjs +1 -1
  679. package/esm/orchestrator/as-tool.mjs.map +1 -1
  680. package/esm/orchestrator/checkpoint.mjs +1 -1
  681. package/esm/orchestrator/checkpoint.mjs.map +1 -1
  682. package/esm/orchestrator/commands.d.mts +1 -1
  683. package/esm/orchestrator/commands.d.mts.map +1 -1
  684. package/esm/orchestrator/commands.mjs +1 -1
  685. package/esm/orchestrator/commands.mjs.map +1 -1
  686. package/esm/orchestrator/compaction.mjs +1 -1
  687. package/esm/orchestrator/compaction.mjs.map +1 -1
  688. package/esm/orchestrator/dispatch.mjs +1 -1
  689. package/esm/orchestrator/dispatch.mjs.map +1 -1
  690. package/esm/orchestrator/emitter-port.type.d.mts +1 -1
  691. package/esm/orchestrator/emitter-port.type.d.mts.map +1 -1
  692. package/esm/orchestrator/emitter.d.mts +1 -1
  693. package/esm/orchestrator/emitter.d.mts.map +1 -1
  694. package/esm/orchestrator/emitter.mjs +1 -1
  695. package/esm/orchestrator/emitter.mjs.map +1 -1
  696. package/esm/orchestrator/engine-context.type.d.mts +1 -1
  697. package/esm/orchestrator/engine-context.type.d.mts.map +1 -1
  698. package/esm/orchestrator/execution.d.mts +1 -1
  699. package/esm/orchestrator/execution.d.mts.map +1 -1
  700. package/esm/orchestrator/execution.mjs +1 -1
  701. package/esm/orchestrator/execution.mjs.map +1 -1
  702. package/esm/orchestrator/load.mjs +1 -1
  703. package/esm/orchestrator/load.mjs.map +1 -1
  704. package/esm/orchestrator/lock.mjs +1 -1
  705. package/esm/orchestrator/lock.mjs.map +1 -1
  706. package/esm/orchestrator/memory.d.mts +1 -1
  707. package/esm/orchestrator/memory.d.mts.map +1 -1
  708. package/esm/orchestrator/memory.mjs +1 -1
  709. package/esm/orchestrator/memory.mjs.map +1 -1
  710. package/esm/orchestrator/orchestrator-stream.d.mts +1 -1
  711. package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -1
  712. package/esm/orchestrator/orchestrator-stream.mjs +1 -1
  713. package/esm/orchestrator/orchestrator-stream.mjs.map +1 -1
  714. package/esm/orchestrator/orchestrator.d.mts +1 -1
  715. package/esm/orchestrator/orchestrator.d.mts.map +1 -1
  716. package/esm/orchestrator/orchestrator.mjs +1 -1
  717. package/esm/orchestrator/orchestrator.mjs.map +1 -1
  718. package/esm/orchestrator/resume.mjs +1 -1
  719. package/esm/orchestrator/resume.mjs.map +1 -1
  720. package/esm/orchestrator/session-lock.d.mts +1 -1
  721. package/esm/orchestrator/session-lock.d.mts.map +1 -1
  722. package/esm/orchestrator/session-lock.mjs +1 -1
  723. package/esm/orchestrator/session-lock.mjs.map +1 -1
  724. package/esm/orchestrator/signature.d.mts +1 -1
  725. package/esm/orchestrator/signature.d.mts.map +1 -1
  726. package/esm/orchestrator/signature.mjs +1 -1
  727. package/esm/orchestrator/signature.mjs.map +1 -1
  728. package/esm/orchestrator/window.mjs +1 -1
  729. package/esm/orchestrator/window.mjs.map +1 -1
  730. package/esm/planner/dag-scheduler.mjs +1 -1
  731. package/esm/planner/dag-scheduler.mjs.map +1 -1
  732. package/esm/planner/plan-prompt.d.mts +1 -1
  733. package/esm/planner/plan-prompt.d.mts.map +1 -1
  734. package/esm/planner/plan-prompt.mjs +1 -1
  735. package/esm/planner/plan-prompt.mjs.map +1 -1
  736. package/esm/planner/plan-schema.d.mts +1 -1
  737. package/esm/planner/plan-schema.d.mts.map +1 -1
  738. package/esm/planner/plan-schema.mjs +1 -1
  739. package/esm/planner/plan-schema.mjs.map +1 -1
  740. package/esm/planner/planner-run.d.mts +1 -1
  741. package/esm/planner/planner-run.d.mts.map +1 -1
  742. package/esm/planner/planner-run.mjs +1 -1
  743. package/esm/planner/planner-run.mjs.map +1 -1
  744. package/esm/planner/planner.d.mts +1 -1
  745. package/esm/planner/planner.d.mts.map +1 -1
  746. package/esm/planner/planner.mjs +1 -1
  747. package/esm/planner/planner.mjs.map +1 -1
  748. package/esm/planner/signature.d.mts +1 -1
  749. package/esm/planner/signature.d.mts.map +1 -1
  750. package/esm/planner/signature.mjs +1 -1
  751. package/esm/planner/signature.mjs.map +1 -1
  752. package/esm/planner/snapshot.mjs +1 -1
  753. package/esm/planner/snapshot.mjs.map +1 -1
  754. package/esm/prompt/errors.d.mts +1 -1
  755. package/esm/prompt/errors.d.mts.map +1 -1
  756. package/esm/prompt/errors.mjs +1 -1
  757. package/esm/prompt/errors.mjs.map +1 -1
  758. package/esm/prompt/prompt-langfuse-sync.mjs +1 -1
  759. package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -1
  760. package/esm/prompt/prompt-langfuse-sync.type.d.mts +1 -1
  761. package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -1
  762. package/esm/prompt/prompt-validate.mjs +1 -1
  763. package/esm/prompt/prompt-validate.mjs.map +1 -1
  764. package/esm/prompt/prompt.d.mts +1 -1
  765. package/esm/prompt/prompt.d.mts.map +1 -1
  766. package/esm/prompt/prompt.mjs +1 -1
  767. package/esm/prompt/prompt.mjs.map +1 -1
  768. package/esm/prompt/prompt.type.d.mts +1 -1
  769. package/esm/prompt/prompt.type.d.mts.map +1 -1
  770. package/esm/prompts/prompts-manager.contract.d.mts +1 -1
  771. package/esm/prompts/prompts-manager.contract.d.mts.map +1 -1
  772. package/esm/prompts/prompts-manager.d.mts +1 -1
  773. package/esm/prompts/prompts-manager.d.mts.map +1 -1
  774. package/esm/prompts/prompts-manager.mjs +1 -1
  775. package/esm/prompts/prompts-manager.mjs.map +1 -1
  776. package/esm/prompts/prompts-manager.type.d.mts +1 -1
  777. package/esm/prompts/prompts-manager.type.d.mts.map +1 -1
  778. package/esm/prompts/prompts-validate.d.mts +1 -1
  779. package/esm/prompts/prompts-validate.d.mts.map +1 -1
  780. package/esm/prompts/prompts-validate.mjs +0 -0
  781. package/esm/prompts/prompts-validate.mjs.map +1 -1
  782. package/esm/rag/as-tool.mjs +1 -1
  783. package/esm/rag/as-tool.mjs.map +1 -1
  784. package/esm/rag/chunk/chunk.d.mts +1 -1
  785. package/esm/rag/chunk/chunk.d.mts.map +1 -1
  786. package/esm/rag/chunk/chunk.mjs +1 -1
  787. package/esm/rag/chunk/chunk.mjs.map +1 -1
  788. package/esm/rag/chunk/fixed.mjs +1 -1
  789. package/esm/rag/chunk/fixed.mjs.map +1 -1
  790. package/esm/rag/chunk/markdown.mjs +1 -1
  791. package/esm/rag/chunk/markdown.mjs.map +1 -1
  792. package/esm/rag/chunk/recursive.mjs +1 -1
  793. package/esm/rag/chunk/recursive.mjs.map +1 -1
  794. package/esm/rag/chunk/sentence.mjs +1 -1
  795. package/esm/rag/chunk/sentence.mjs.map +1 -1
  796. package/esm/rag/contracts/chunk-options.type.d.mts +1 -1
  797. package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -1
  798. package/esm/rag/contracts/citation.type.d.mts +1 -1
  799. package/esm/rag/contracts/citation.type.d.mts.map +1 -1
  800. package/esm/rag/contracts/rag-config.type.d.mts +1 -1
  801. package/esm/rag/contracts/rag-config.type.d.mts.map +1 -1
  802. package/esm/rag/contracts/rag-document.type.d.mts +1 -1
  803. package/esm/rag/contracts/rag-document.type.d.mts.map +1 -1
  804. package/esm/rag/hybrid/bm25.d.mts +1 -1
  805. package/esm/rag/hybrid/bm25.d.mts.map +1 -1
  806. package/esm/rag/hybrid/bm25.mjs +1 -1
  807. package/esm/rag/hybrid/bm25.mjs.map +1 -1
  808. package/esm/rag/hybrid/hybrid-rank.d.mts +1 -1
  809. package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -1
  810. package/esm/rag/hybrid/hybrid-rank.mjs +1 -1
  811. package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -1
  812. package/esm/rag/hybrid/rrf.d.mts +1 -1
  813. package/esm/rag/hybrid/rrf.d.mts.map +1 -1
  814. package/esm/rag/hybrid/rrf.mjs +1 -1
  815. package/esm/rag/hybrid/rrf.mjs.map +1 -1
  816. package/esm/rag/loaders/errors.d.mts +1 -1
  817. package/esm/rag/loaders/errors.d.mts.map +1 -1
  818. package/esm/rag/loaders/errors.mjs +1 -1
  819. package/esm/rag/loaders/errors.mjs.map +1 -1
  820. package/esm/rag/loaders/load-html.d.mts +1 -1
  821. package/esm/rag/loaders/load-html.d.mts.map +1 -1
  822. package/esm/rag/loaders/load-html.mjs +1 -1
  823. package/esm/rag/loaders/load-html.mjs.map +1 -1
  824. package/esm/rag/loaders/load-pdf.d.mts +1 -1
  825. package/esm/rag/loaders/load-pdf.d.mts.map +1 -1
  826. package/esm/rag/loaders/load-pdf.mjs +1 -1
  827. package/esm/rag/loaders/load-pdf.mjs.map +1 -1
  828. package/esm/rag/loaders/load-text.d.mts +1 -1
  829. package/esm/rag/loaders/load-text.d.mts.map +1 -1
  830. package/esm/rag/loaders/load-text.mjs +1 -1
  831. package/esm/rag/loaders/load-text.mjs.map +1 -1
  832. package/esm/rag/loaders/load-web.d.mts +1 -1
  833. package/esm/rag/loaders/load-web.d.mts.map +1 -1
  834. package/esm/rag/loaders/load-web.mjs +1 -1
  835. package/esm/rag/loaders/load-web.mjs.map +1 -1
  836. package/esm/rag/loaders/loader.type.d.mts +1 -1
  837. package/esm/rag/loaders/loader.type.d.mts.map +1 -1
  838. package/esm/rag/rag.d.mts +1 -1
  839. package/esm/rag/rag.d.mts.map +1 -1
  840. package/esm/rag/rag.mjs +1 -1
  841. package/esm/rag/rag.mjs.map +1 -1
  842. package/esm/rag/rerank/keyword-reranker.d.mts +1 -1
  843. package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -1
  844. package/esm/rag/rerank/keyword-reranker.mjs +1 -1
  845. package/esm/rag/rerank/keyword-reranker.mjs.map +1 -1
  846. package/esm/rag/rerank/llm-reranker.d.mts +1 -1
  847. package/esm/rag/rerank/llm-reranker.d.mts.map +1 -1
  848. package/esm/rag/rerank/llm-reranker.mjs +1 -1
  849. package/esm/rag/rerank/llm-reranker.mjs.map +1 -1
  850. package/esm/rag/rerank/reranker.contract.d.mts +1 -1
  851. package/esm/rag/rerank/reranker.contract.d.mts.map +1 -1
  852. package/esm/rag/retrieve.mjs +1 -1
  853. package/esm/rag/retrieve.mjs.map +1 -1
  854. package/esm/rag/store/cache-vector-store.d.mts +1 -1
  855. package/esm/rag/store/cache-vector-store.d.mts.map +1 -1
  856. package/esm/rag/store/cache-vector-store.mjs +1 -1
  857. package/esm/rag/store/cache-vector-store.mjs.map +1 -1
  858. package/esm/rag/store/pg-vector-store.d.mts +1 -1
  859. package/esm/rag/store/pg-vector-store.d.mts.map +1 -1
  860. package/esm/rag/store/pg-vector-store.mjs +1 -1
  861. package/esm/rag/store/pg-vector-store.mjs.map +1 -1
  862. package/esm/rag/store/vector-store.contract.d.mts +1 -1
  863. package/esm/rag/store/vector-store.contract.d.mts.map +1 -1
  864. package/esm/rag/transforms/multi-query.d.mts +1 -1
  865. package/esm/rag/transforms/multi-query.d.mts.map +1 -1
  866. package/esm/rag/transforms/multi-query.mjs +1 -1
  867. package/esm/rag/transforms/multi-query.mjs.map +1 -1
  868. package/esm/security/outbound-policy.d.mts +1 -1
  869. package/esm/security/outbound-policy.d.mts.map +1 -1
  870. package/esm/security/outbound-policy.mjs +1 -1
  871. package/esm/security/outbound-policy.mjs.map +1 -1
  872. package/esm/security/outbound-policy.type.d.mts +1 -1
  873. package/esm/security/outbound-policy.type.d.mts.map +1 -1
  874. package/esm/security/private-ip.d.mts +1 -1
  875. package/esm/security/private-ip.d.mts.map +1 -1
  876. package/esm/security/private-ip.mjs +1 -1
  877. package/esm/security/private-ip.mjs.map +1 -1
  878. package/esm/security/redact.d.mts +1 -1
  879. package/esm/security/redact.d.mts.map +1 -1
  880. package/esm/security/redact.mjs +1 -1
  881. package/esm/security/redact.mjs.map +1 -1
  882. package/esm/serve/serve.d.mts +1 -1
  883. package/esm/serve/serve.d.mts.map +1 -1
  884. package/esm/serve/serve.mjs +1 -1
  885. package/esm/serve/serve.mjs.map +1 -1
  886. package/esm/serve/sse.d.mts +1 -1
  887. package/esm/serve/sse.d.mts.map +1 -1
  888. package/esm/serve/sse.mjs +1 -1
  889. package/esm/serve/sse.mjs.map +1 -1
  890. package/esm/serve/stream-to-sse.d.mts +1 -1
  891. package/esm/serve/stream-to-sse.d.mts.map +1 -1
  892. package/esm/serve/stream-to-sse.mjs +1 -1
  893. package/esm/serve/stream-to-sse.mjs.map +1 -1
  894. package/esm/skills/catalog.d.mts +1 -1
  895. package/esm/skills/catalog.d.mts.map +1 -1
  896. package/esm/skills/catalog.mjs +1 -1
  897. package/esm/skills/catalog.mjs.map +1 -1
  898. package/esm/skills/contracts/skill-record.type.d.mts +1 -1
  899. package/esm/skills/contracts/skill-record.type.d.mts.map +1 -1
  900. package/esm/skills/contracts/skills-config.type.d.mts +1 -1
  901. package/esm/skills/contracts/skills-config.type.d.mts.map +1 -1
  902. package/esm/skills/contracts/skills-store.contract.d.mts +1 -1
  903. package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -1
  904. package/esm/skills/contracts/skills.contract.d.mts +1 -1
  905. package/esm/skills/contracts/skills.contract.d.mts.map +1 -1
  906. package/esm/skills/load-skill-tool.d.mts +1 -1
  907. package/esm/skills/load-skill-tool.d.mts.map +1 -1
  908. package/esm/skills/load-skill-tool.mjs +1 -1
  909. package/esm/skills/load-skill-tool.mjs.map +1 -1
  910. package/esm/skills/review-gate.d.mts +1 -1
  911. package/esm/skills/review-gate.d.mts.map +1 -1
  912. package/esm/skills/review-gate.mjs +1 -1
  913. package/esm/skills/review-gate.mjs.map +1 -1
  914. package/esm/skills/save-skill-tool.d.mts +1 -1
  915. package/esm/skills/save-skill-tool.d.mts.map +1 -1
  916. package/esm/skills/save-skill-tool.mjs +1 -1
  917. package/esm/skills/save-skill-tool.mjs.map +1 -1
  918. package/esm/skills/skills.d.mts +1 -1
  919. package/esm/skills/skills.d.mts.map +1 -1
  920. package/esm/skills/skills.mjs +1 -1
  921. package/esm/skills/skills.mjs.map +1 -1
  922. package/esm/skills/sources/directory-source.d.mts +1 -1
  923. package/esm/skills/sources/directory-source.d.mts.map +1 -1
  924. package/esm/skills/sources/directory-source.mjs +1 -1
  925. package/esm/skills/sources/directory-source.mjs.map +1 -1
  926. package/esm/skills/sources/index.d.mts +1 -1
  927. package/esm/skills/sources/index.d.mts.map +1 -1
  928. package/esm/skills/sources/index.mjs +1 -1
  929. package/esm/skills/sources/index.mjs.map +1 -1
  930. package/esm/skills/sources/parse-frontmatter.d.mts +1 -1
  931. package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -1
  932. package/esm/skills/sources/parse-frontmatter.mjs +1 -1
  933. package/esm/skills/sources/parse-frontmatter.mjs.map +1 -1
  934. package/esm/skills/sources/store-source.d.mts +1 -1
  935. package/esm/skills/sources/store-source.d.mts.map +1 -1
  936. package/esm/skills/sources/store-source.mjs +1 -1
  937. package/esm/skills/sources/store-source.mjs.map +1 -1
  938. package/esm/skills/sources/url-source.d.mts +1 -1
  939. package/esm/skills/sources/url-source.d.mts.map +1 -1
  940. package/esm/skills/sources/url-source.mjs +1 -1
  941. package/esm/skills/sources/url-source.mjs.map +1 -1
  942. package/esm/skills/store/mock-skills-store.d.mts +1 -1
  943. package/esm/skills/store/mock-skills-store.d.mts.map +1 -1
  944. package/esm/skills/store/mock-skills-store.mjs +1 -1
  945. package/esm/skills/store/mock-skills-store.mjs.map +1 -1
  946. package/esm/skills/store/procedural-skill-store.d.mts +1 -1
  947. package/esm/skills/store/procedural-skill-store.d.mts.map +1 -1
  948. package/esm/skills/store/procedural-skill-store.mjs +1 -1
  949. package/esm/skills/store/procedural-skill-store.mjs.map +1 -1
  950. package/esm/snapshot/memory.d.mts +1 -1
  951. package/esm/snapshot/memory.d.mts.map +1 -1
  952. package/esm/snapshot/memory.mjs +1 -1
  953. package/esm/snapshot/memory.mjs.map +1 -1
  954. package/esm/snapshot/pg.d.mts +1 -1
  955. package/esm/snapshot/pg.d.mts.map +1 -1
  956. package/esm/snapshot/pg.mjs +1 -1
  957. package/esm/snapshot/pg.mjs.map +1 -1
  958. package/esm/snapshot/redis.d.mts +1 -1
  959. package/esm/snapshot/redis.d.mts.map +1 -1
  960. package/esm/snapshot/redis.mjs +1 -1
  961. package/esm/snapshot/redis.mjs.map +1 -1
  962. package/esm/speech/speech.d.mts +1 -1
  963. package/esm/speech/speech.d.mts.map +1 -1
  964. package/esm/speech/speech.mjs +1 -1
  965. package/esm/speech/speech.mjs.map +1 -1
  966. package/esm/supervisor/as-tool.d.mts +1 -1
  967. package/esm/supervisor/as-tool.d.mts.map +1 -1
  968. package/esm/supervisor/as-tool.mjs +1 -1
  969. package/esm/supervisor/as-tool.mjs.map +1 -1
  970. package/esm/supervisor/cancellation.d.mts +1 -1
  971. package/esm/supervisor/cancellation.d.mts.map +1 -1
  972. package/esm/supervisor/cancellation.mjs +1 -1
  973. package/esm/supervisor/cancellation.mjs.map +1 -1
  974. package/esm/supervisor/decide.mjs +1 -1
  975. package/esm/supervisor/decide.mjs.map +1 -1
  976. package/esm/supervisor/emitter.d.mts +1 -1
  977. package/esm/supervisor/emitter.d.mts.map +1 -1
  978. package/esm/supervisor/emitter.mjs +1 -1
  979. package/esm/supervisor/emitter.mjs.map +1 -1
  980. package/esm/supervisor/entries.d.mts +1 -1
  981. package/esm/supervisor/entries.d.mts.map +1 -1
  982. package/esm/supervisor/entries.mjs +1 -1
  983. package/esm/supervisor/entries.mjs.map +1 -1
  984. package/esm/supervisor/execution.d.mts +1 -1
  985. package/esm/supervisor/execution.d.mts.map +1 -1
  986. package/esm/supervisor/execution.mjs +1 -1
  987. package/esm/supervisor/execution.mjs.map +1 -1
  988. package/esm/supervisor/fan-out.d.mts +1 -1
  989. package/esm/supervisor/fan-out.d.mts.map +1 -1
  990. package/esm/supervisor/fan-out.mjs +1 -1
  991. package/esm/supervisor/fan-out.mjs.map +1 -1
  992. package/esm/supervisor/router-factory.d.mts +1 -1
  993. package/esm/supervisor/router-factory.d.mts.map +1 -1
  994. package/esm/supervisor/router-factory.mjs +1 -1
  995. package/esm/supervisor/router-factory.mjs.map +1 -1
  996. package/esm/supervisor/router-prompt.d.mts +1 -1
  997. package/esm/supervisor/router-prompt.d.mts.map +1 -1
  998. package/esm/supervisor/router-prompt.mjs +1 -1
  999. package/esm/supervisor/router-prompt.mjs.map +1 -1
  1000. package/esm/supervisor/signature.d.mts +1 -1
  1001. package/esm/supervisor/signature.d.mts.map +1 -1
  1002. package/esm/supervisor/signature.mjs +1 -1
  1003. package/esm/supervisor/signature.mjs.map +1 -1
  1004. package/esm/supervisor/snapshot.d.mts +1 -1
  1005. package/esm/supervisor/snapshot.d.mts.map +1 -1
  1006. package/esm/supervisor/snapshot.mjs +1 -1
  1007. package/esm/supervisor/snapshot.mjs.map +1 -1
  1008. package/esm/supervisor/supervisor-stream.d.mts +1 -1
  1009. package/esm/supervisor/supervisor-stream.d.mts.map +1 -1
  1010. package/esm/supervisor/supervisor-stream.mjs +1 -1
  1011. package/esm/supervisor/supervisor-stream.mjs.map +1 -1
  1012. package/esm/supervisor/supervisor.d.mts +1 -1
  1013. package/esm/supervisor/supervisor.d.mts.map +1 -1
  1014. package/esm/supervisor/supervisor.mjs +1 -1
  1015. package/esm/supervisor/supervisor.mjs.map +1 -1
  1016. package/esm/system-prompt/instruction.d.mts +1 -1
  1017. package/esm/system-prompt/instruction.d.mts.map +1 -1
  1018. package/esm/system-prompt/instruction.mjs +1 -1
  1019. package/esm/system-prompt/instruction.mjs.map +1 -1
  1020. package/esm/system-prompt/persona.d.mts +1 -1
  1021. package/esm/system-prompt/persona.d.mts.map +1 -1
  1022. package/esm/system-prompt/persona.mjs +1 -1
  1023. package/esm/system-prompt/persona.mjs.map +1 -1
  1024. package/esm/system-prompt/refined-system-prompt.d.mts +1 -1
  1025. package/esm/system-prompt/refined-system-prompt.d.mts.map +1 -1
  1026. package/esm/system-prompt/refined-system-prompt.mjs +1 -1
  1027. package/esm/system-prompt/refined-system-prompt.mjs.map +1 -1
  1028. package/esm/system-prompt/render-placeholders.d.mts +1 -1
  1029. package/esm/system-prompt/render-placeholders.d.mts.map +1 -1
  1030. package/esm/system-prompt/render-placeholders.mjs +1 -1
  1031. package/esm/system-prompt/render-placeholders.mjs.map +1 -1
  1032. package/esm/system-prompt/system-prompt.d.mts +1 -1
  1033. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  1034. package/esm/system-prompt/system-prompt.mjs +1 -1
  1035. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  1036. package/esm/team/gates.mjs +1 -1
  1037. package/esm/team/gates.mjs.map +1 -1
  1038. package/esm/team/team.d.mts +1 -1
  1039. package/esm/team/team.d.mts.map +1 -1
  1040. package/esm/team/team.mjs +1 -1
  1041. package/esm/team/team.mjs.map +1 -1
  1042. package/esm/testing/matcher-logic.d.mts +1 -1
  1043. package/esm/testing/matcher-logic.d.mts.map +1 -1
  1044. package/esm/testing/matcher-logic.mjs +1 -1
  1045. package/esm/testing/matcher-logic.mjs.map +1 -1
  1046. package/esm/testing/matchers.d.mts +1 -1
  1047. package/esm/testing/matchers.d.mts.map +1 -1
  1048. package/esm/testing/matchers.mjs +1 -1
  1049. package/esm/testing/matchers.mjs.map +1 -1
  1050. package/esm/testing/register-lazy.d.mts +1 -1
  1051. package/esm/testing/register-lazy.d.mts.map +1 -1
  1052. package/esm/testing/register-lazy.mjs +1 -1
  1053. package/esm/testing/register-lazy.mjs.map +1 -1
  1054. package/esm/tool/executable-as-tool.d.mts +1 -1
  1055. package/esm/tool/executable-as-tool.d.mts.map +1 -1
  1056. package/esm/tool/executable-as-tool.mjs +1 -1
  1057. package/esm/tool/executable-as-tool.mjs.map +1 -1
  1058. package/esm/tool/tool.d.mts +1 -1
  1059. package/esm/tool/tool.d.mts.map +1 -1
  1060. package/esm/tool/tool.mjs +1 -1
  1061. package/esm/tool/tool.mjs.map +1 -1
  1062. package/esm/transcribe/audio-input.d.mts +1 -1
  1063. package/esm/transcribe/audio-input.d.mts.map +1 -1
  1064. package/esm/transcribe/audio-input.mjs +1 -1
  1065. package/esm/transcribe/audio-input.mjs.map +1 -1
  1066. package/esm/transcribe/transcribe.d.mts +1 -1
  1067. package/esm/transcribe/transcribe.d.mts.map +1 -1
  1068. package/esm/transcribe/transcribe.mjs +1 -1
  1069. package/esm/transcribe/transcribe.mjs.map +1 -1
  1070. package/esm/utils/compute-cost.d.mts +1 -1
  1071. package/esm/utils/compute-cost.d.mts.map +1 -1
  1072. package/esm/utils/compute-cost.mjs +1 -1
  1073. package/esm/utils/compute-cost.mjs.map +1 -1
  1074. package/esm/utils/extract-json-lenient.d.mts +1 -1
  1075. package/esm/utils/extract-json-lenient.d.mts.map +1 -1
  1076. package/esm/utils/extract-json-lenient.mjs +1 -1
  1077. package/esm/utils/extract-json-lenient.mjs.map +1 -1
  1078. package/esm/utils/extract-json-payload.d.mts +1 -1
  1079. package/esm/utils/extract-json-payload.d.mts.map +1 -1
  1080. package/esm/utils/extract-json-payload.mjs +1 -1
  1081. package/esm/utils/extract-json-payload.mjs.map +1 -1
  1082. package/esm/utils/generate-run-id.d.mts +1 -1
  1083. package/esm/utils/generate-run-id.d.mts.map +1 -1
  1084. package/esm/utils/generate-run-id.mjs +1 -1
  1085. package/esm/utils/generate-run-id.mjs.map +1 -1
  1086. package/esm/utils/json-schema.d.mts +1 -1
  1087. package/esm/utils/json-schema.d.mts.map +1 -1
  1088. package/esm/utils/json-schema.mjs +1 -1
  1089. package/esm/utils/json-schema.mjs.map +1 -1
  1090. package/esm/utils/prepare-attachment-part.d.mts +1 -1
  1091. package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
  1092. package/esm/utils/prepare-attachment-part.mjs +1 -1
  1093. package/esm/utils/prepare-attachment-part.mjs.map +1 -1
  1094. package/esm/utils/resolve-attachment.d.mts +1 -1
  1095. package/esm/utils/resolve-attachment.d.mts.map +1 -1
  1096. package/esm/utils/resolve-attachment.mjs +1 -1
  1097. package/esm/utils/resolve-attachment.mjs.map +1 -1
  1098. package/esm/utils/run-context.d.mts +1 -1
  1099. package/esm/utils/run-context.d.mts.map +1 -1
  1100. package/esm/utils/run-context.mjs +1 -1
  1101. package/esm/utils/run-context.mjs.map +1 -1
  1102. package/esm/utils/safe-json-parse.d.mts +1 -1
  1103. package/esm/utils/safe-json-parse.d.mts.map +1 -1
  1104. package/esm/utils/safe-json-parse.mjs +1 -1
  1105. package/esm/utils/safe-json-parse.mjs.map +1 -1
  1106. package/esm/utils/stamp-report-lineage.d.mts +1 -1
  1107. package/esm/utils/stamp-report-lineage.d.mts.map +1 -1
  1108. package/esm/utils/stamp-report-lineage.mjs +1 -1
  1109. package/esm/utils/stamp-report-lineage.mjs.map +1 -1
  1110. package/esm/utils/token-count.d.mts +1 -1
  1111. package/esm/utils/token-count.d.mts.map +1 -1
  1112. package/esm/utils/token-count.mjs +1 -1
  1113. package/esm/utils/token-count.mjs.map +1 -1
  1114. package/esm/vcr/cassette-io.mjs +1 -1
  1115. package/esm/vcr/cassette-io.mjs.map +1 -1
  1116. package/esm/vcr/errors.d.mts +1 -1
  1117. package/esm/vcr/errors.d.mts.map +1 -1
  1118. package/esm/vcr/errors.mjs +1 -1
  1119. package/esm/vcr/errors.mjs.map +1 -1
  1120. package/esm/vcr/hash-request.d.mts +1 -1
  1121. package/esm/vcr/hash-request.d.mts.map +1 -1
  1122. package/esm/vcr/hash-request.mjs +1 -1
  1123. package/esm/vcr/hash-request.mjs.map +1 -1
  1124. package/esm/vcr/vcr.d.mts +1 -1
  1125. package/esm/vcr/vcr.d.mts.map +1 -1
  1126. package/esm/vcr/vcr.mjs +1 -1
  1127. package/esm/vcr/vcr.mjs.map +1 -1
  1128. package/esm/vcr/vcr.type.d.mts +1 -1
  1129. package/esm/vcr/vcr.type.d.mts.map +1 -1
  1130. package/esm/workflow/as-tool.mjs +1 -1
  1131. package/esm/workflow/as-tool.mjs.map +1 -1
  1132. package/esm/workflow/cancellation.mjs +1 -1
  1133. package/esm/workflow/cancellation.mjs.map +1 -1
  1134. package/esm/workflow/emitter.mjs +1 -1
  1135. package/esm/workflow/emitter.mjs.map +1 -1
  1136. package/esm/workflow/engine.mjs +5 -2
  1137. package/esm/workflow/engine.mjs.map +1 -1
  1138. package/esm/workflow/retry.mjs +1 -1
  1139. package/esm/workflow/retry.mjs.map +1 -1
  1140. package/esm/workflow/router.mjs +1 -1
  1141. package/esm/workflow/router.mjs.map +1 -1
  1142. package/esm/workflow/run-scoped-emitter.mjs +1 -1
  1143. package/esm/workflow/run-scoped-emitter.mjs.map +1 -1
  1144. package/esm/workflow/signature.d.mts +1 -1
  1145. package/esm/workflow/signature.d.mts.map +1 -1
  1146. package/esm/workflow/signature.mjs +1 -1
  1147. package/esm/workflow/signature.mjs.map +1 -1
  1148. package/esm/workflow/snapshot.mjs +1 -1
  1149. package/esm/workflow/snapshot.mjs.map +1 -1
  1150. package/esm/workflow/state.mjs +1 -1
  1151. package/esm/workflow/state.mjs.map +1 -1
  1152. package/esm/workflow/step-runner.mjs +25 -6
  1153. package/esm/workflow/step-runner.mjs.map +1 -1
  1154. package/esm/workflow/step.d.mts +1 -1
  1155. package/esm/workflow/step.d.mts.map +1 -1
  1156. package/esm/workflow/step.mjs +1 -1
  1157. package/esm/workflow/step.mjs.map +1 -1
  1158. package/esm/workflow/workflow.d.mts +1 -1
  1159. package/esm/workflow/workflow.d.mts.map +1 -1
  1160. package/esm/workflow/workflow.mjs +1 -1
  1161. package/esm/workflow/workflow.mjs.map +1 -1
  1162. package/llms-full.txt +23 -2
  1163. package/package.json +4 -4
  1164. package/skills/observe-ai-flows/SKILL.md +2 -2
  1165. package/skills/run-ai-workflow/SKILL.md +19 -0
  1166. package/skills/run-supervisor/SKILL.md +2 -0
  1167. package/cjs/magic-string.es-BtxW4VqG.cjs.map +0 -1
  1168. package/cjs/matcher-logic-SBnzYohQ.cjs.map +0 -1
  1169. package/cjs/matchers-BBh3gyB-.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-attachment-part.mjs","names":["resolvePath"],"sources":["../../../../../../../@warlock.js/ai/src/utils/prepare-attachment-part.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { extname, isAbsolute, relative, resolve as resolvePath } from \"node:path\";\nimport type { AttachmentPolicy } from \"../contracts/attachment-policy.type\";\nimport type { Attachment } from \"../contracts/attachment.type\";\nimport type { ContentPart } from \"../contracts/content-part.type\";\nimport { InvalidRequestError, OutboundPolicyError } from \"../errors\";\nimport { fetchTextWithPolicy } from \"../security/outbound-policy\";\nimport { resolveAttachment } from \"./resolve-attachment\";\n\nconst IMAGE_EXTENSIONS_TO_MEDIA_TYPE: Record<string, string> = {\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n};\n\nconst TEXT_EXTENSIONS = new Set([\".txt\"]);\n\nconst AUDIO_EXTENSIONS_TO_MEDIA_TYPE: Record<string, string> = {\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".m4a\": \"audio/mp4\",\n \".ogg\": \"audio/ogg\",\n \".weba\": \"audio/webm\",\n};\n\nconst PDF_EXTENSIONS = new Set([\".pdf\"]);\n\ntype AttachmentKind = \"image\" | \"text\" | \"pdf\" | \"audio\";\n\n/**\n * Convert a user-supplied `Attachment` into a provider-ready\n * `ContentPart` the model adapter can consume without doing any I/O of\n * its own.\n *\n * Kind resolution:\n * - Tagged `{ type: \"image\", source }` / `{ type: \"text\", source }`\n * trusts the caller's intent.\n * - Shorthand (raw string / `StorageFileShape`) infers from the file\n * extension. Image extensions (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`)\n * map to `\"image\"`. `.txt` maps to `\"text\"`. Anything else throws\n * `InvalidRequestError` — silent inference on ambiguous inputs\n * causes silent bugs.\n *\n * Local paths are read from disk; images are base64-encoded inline,\n * text files are read as UTF-8 strings and returned as a `text`\n * `ContentPart`. Remote URLs for image attachments are passed through\n * unchanged; remote URLs for text attachments are fetched so the\n * adapter never needs network access.\n *\n * @example\n * await prepareAttachmentPart(\"./photo.png\");\n * // → { type: \"image\", source: { base64: \"...\", mediaType: \"image/png\" } }\n *\n * @example\n * await prepareAttachmentPart({ type: \"text\", source: \"./notes.txt\" });\n * // → { type: \"text\", text: \"<file contents>\" }\n *\n * **Trust boundary (S1).** Attachment references are often user-controlled,\n * so server-side I/O is policy-gated by `policy` ({@link AttachmentPolicy}):\n * remote text fetches are default-deny and, when enabled, run through the\n * shared `OutboundPolicy` (scheme/host/private-IP/max-bytes/timeout); local\n * reads honor an `allowedRoots` sandbox; bare-string local paths warn\n * (staged deprecation). URL *image* attachments are passed to the provider\n * untouched (never fetched here).\n */\nexport async function prepareAttachmentPart(\n attachment: Attachment,\n policy?: AttachmentPolicy,\n): Promise<ContentPart> {\n const kind = resolveKind(attachment);\n const bareString = typeof attachment === \"string\";\n\n if (kind === \"text\") {\n return prepareTextPart(attachment, policy, bareString);\n }\n\n if (kind === \"image\") {\n return prepareImagePart(attachment, policy, bareString);\n }\n\n return prepareBinaryPart(attachment, kind, policy, bareString);\n}\n\n/**\n * Decide whether the attachment is text or image. Tagged forms win\n * immediately; for shorthand we inspect the extension. Throws if the\n * shorthand doesn't look like anything we recognize.\n */\nfunction resolveKind(attachment: Attachment): AttachmentKind {\n if (isTaggedAttachment(attachment)) {\n return attachment.type;\n }\n\n const path = extractPath(attachment);\n const extension = path ? extname(stripQuery(path)).toLowerCase() : \"\";\n\n if (IMAGE_EXTENSIONS_TO_MEDIA_TYPE[extension]) {\n return \"image\";\n }\n\n if (TEXT_EXTENSIONS.has(extension)) {\n return \"text\";\n }\n\n if (PDF_EXTENSIONS.has(extension)) {\n return \"pdf\";\n }\n\n if (AUDIO_EXTENSIONS_TO_MEDIA_TYPE[extension]) {\n return \"audio\";\n }\n\n throw new InvalidRequestError(\n \"Cannot infer attachment type from input — pass an explicit `{ type: 'image' | 'text' | 'pdf' | 'audio', source: ... }` or use a recognized extension (.png, .jpg, .jpeg, .webp, .gif, .txt, .pdf, .mp3, .wav, .m4a, .ogg, .weba)\",\n );\n}\n\n/**\n * Produce a `pdf` / `audio` ContentPart (A2). URLs pass through; local\n * paths are read and base64-encoded with a media type inferred from the\n * kind (`application/pdf`) or extension (audio); inline base64 passes\n * through. Same `AttachmentPolicy` gating as image/text reads.\n */\nasync function prepareBinaryPart(\n attachment: Attachment,\n kind: \"pdf\" | \"audio\",\n policy: AttachmentPolicy | undefined,\n bareString: boolean,\n): Promise<ContentPart> {\n const resolved = resolveAttachment(attachment);\n\n if (resolved.type === \"url\") {\n return { type: kind, source: { url: resolved.value } };\n }\n\n if (resolved.type === \"base64\") {\n return { type: kind, source: { base64: resolved.value, mediaType: resolved.mediaType } };\n }\n\n const mediaType =\n kind === \"pdf\" ? \"application/pdf\" : inferAudioMediaType(resolved.value);\n\n if (!mediaType) {\n throw new InvalidRequestError(\n `Cannot infer media type for ${kind} path \"${resolved.value}\" — use a recognized extension or pass ` +\n `\\`{ type: '${kind}', source: { base64, mediaType } }\\``,\n { context: { path: resolved.value } },\n );\n }\n\n enforceLocalPathPolicy(resolved.value, bareString, policy);\n const bytes = await readFile(resolved.value);\n\n return { type: kind, source: { base64: bytes.toString(\"base64\"), mediaType } };\n}\n\n/** Infer an audio media type from a path's extension. */\nfunction inferAudioMediaType(path: string): string | undefined {\n return AUDIO_EXTENSIONS_TO_MEDIA_TYPE[extname(stripQuery(path)).toLowerCase()];\n}\n\n/**\n * Produce an `image` ContentPart. URLs pass through; paths are\n * read from disk and base64-encoded with an inferred media type.\n * Inline base64 attachments pass through unchanged.\n */\nasync function prepareImagePart(\n attachment: Attachment,\n policy: AttachmentPolicy | undefined,\n bareString: boolean,\n): Promise<ContentPart> {\n const inferredMediaType = isTaggedAttachment(attachment)\n ? undefined\n : inferImageMediaType(attachment);\n\n const resolved = resolveAttachment(attachment);\n\n if (resolved.type === \"url\") {\n // URL images are handed to the provider as a URL — the provider\n // fetches them, not us — so there's no server-side SSRF surface here.\n return { type: \"image\", source: { url: resolved.value } };\n }\n\n if (resolved.type === \"base64\") {\n return {\n type: \"image\",\n source: { base64: resolved.value, mediaType: resolved.mediaType },\n };\n }\n\n const mediaType = inferredMediaType ?? inferImageMediaType(resolved.value);\n\n if (!mediaType) {\n throw new InvalidRequestError(\n `Cannot infer media type for path \"${resolved.value}\" — use a recognized image extension or pass ` +\n \"`{ type: 'image', source: { base64, mediaType } }`\",\n { context: { path: resolved.value } },\n );\n }\n\n enforceLocalPathPolicy(resolved.value, bareString, policy);\n const bytes = await readFile(resolved.value);\n\n return {\n type: \"image\",\n source: { base64: bytes.toString(\"base64\"), mediaType },\n };\n}\n\n/**\n * Produce a `text` ContentPart. URLs are fetched as UTF-8, paths are\n * read from disk as UTF-8, inline base64 is decoded to UTF-8. The\n * result joins the conversation as an additional text part the model\n * sees before responding.\n */\nasync function prepareTextPart(\n attachment: Attachment,\n policy: AttachmentPolicy | undefined,\n bareString: boolean,\n): Promise<ContentPart> {\n const resolved = resolveAttachment(attachment);\n\n if (resolved.type === \"url\") {\n // Default-deny: a remote text attachment is a server-side fetch of\n // user-controlled input — refuse unless the app explicitly opted in,\n // then run it through the shared OutboundPolicy (scheme/host/private-\n // IP/max-bytes/timeout).\n if (!policy?.allowRemoteFetch) {\n throw new OutboundPolicyError(\n `remote text attachment fetch is disabled by default — set \\`attachmentPolicy.allowRemoteFetch: true\\` (with an \\`outbound\\` policy) to fetch \"${resolved.value}\"`,\n { context: { url: resolved.value } },\n );\n }\n\n const result = await fetchTextWithPolicy(resolved.value, policy.outbound ?? {});\n\n if (!result.ok) {\n throw new InvalidRequestError(\n `Failed to fetch text attachment \"${resolved.value}\" — status ${result.status}`,\n { context: { url: resolved.value, status: result.status } },\n );\n }\n\n return { type: \"text\", text: result.text };\n }\n\n if (resolved.type === \"base64\") {\n const decoded = Buffer.from(resolved.value, \"base64\").toString(\"utf8\");\n\n return { type: \"text\", text: decoded };\n }\n\n enforceLocalPathPolicy(resolved.value, bareString, policy);\n const bytes = await readFile(resolved.value, \"utf8\");\n\n return { type: \"text\", text: bytes };\n}\n\n/** Process-lifetime flag so the bare-string deprecation warns at most once. */\nlet warnedBareLocalPath = false;\n\n/**\n * Enforce the local-file half of {@link AttachmentPolicy} (S1):\n *\n * - **Bare-string local paths** are staged for deprecation. With\n * `allowBareLocalPaths: false` they hard-deny now; otherwise they warn\n * once (outside tests) — the typed `StorageFile.absolutePath` route is\n * the supported way to read a local file.\n * - **`allowedRoots` sandbox** — when set, the resolved path must live\n * inside one of the roots, else the read is refused.\n */\nfunction enforceLocalPathPolicy(\n path: string,\n bareString: boolean,\n policy: AttachmentPolicy | undefined,\n): void {\n if (bareString) {\n if (policy?.allowBareLocalPaths === false) {\n throw new OutboundPolicyError(\n `local file attachment via a bare string path (\"${path}\") is disabled — pass a typed \\`{ type, source: { absolutePath } }\\` StorageFile, or set \\`attachmentPolicy.allowBareLocalPaths: true\\``,\n { context: { path } },\n );\n }\n\n if (!warnedBareLocalPath && !process.env.VITEST && process.env.NODE_ENV !== \"test\") {\n warnedBareLocalPath = true;\n console.warn(\n \"[warlock-ai] reading a local file attachment from a bare string path is deprecated and will be denied by default in a future minor. \" +\n \"Pass a typed `{ type, source: { absolutePath } }` StorageFile and confine reads with `attachmentPolicy.allowedRoots`.\",\n );\n }\n }\n\n const roots = policy?.allowedRoots;\n if (roots && roots.length > 0) {\n const target = resolvePath(path);\n const inside = roots.some(root => {\n const rel = relative(resolvePath(root), target);\n return rel === \"\" || (!rel.startsWith(\"..\") && !isAbsolute(rel));\n });\n\n if (!inside) {\n throw new OutboundPolicyError(\n `local file attachment \"${path}\" is outside the allowed roots`,\n { context: { path, allowedRoots: roots } },\n );\n }\n }\n}\n\nfunction isTaggedAttachment(\n attachment: Attachment,\n): attachment is Extract<Attachment, { type: string }> {\n return (\n typeof attachment === \"object\" &&\n attachment !== null &&\n \"type\" in attachment\n );\n}\n\nfunction inferImageMediaType(input: unknown): string | undefined {\n const path = extractPath(input);\n\n if (!path) {\n return undefined;\n }\n\n const extension = extname(stripQuery(path)).toLowerCase();\n\n return IMAGE_EXTENSIONS_TO_MEDIA_TYPE[extension];\n}\n\nfunction extractPath(input: unknown): string | undefined {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const storage = input as { url?: string; absolutePath?: string };\n return storage.url ?? storage.absolutePath;\n }\n\n return undefined;\n}\n\nfunction stripQuery(path: string): string {\n const queryIndex = path.indexOf(\"?\");\n\n return queryIndex === -1 ? path : path.slice(0, queryIndex);\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,iCAAyD;CAC7D,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;AACV;AAEA,MAAM,kBAAkB,IAAI,IAAI,CAAC,MAAM,CAAC;AAExC,MAAM,iCAAyD;CAC7D,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;AACX;AAEA,MAAM,iBAAiB,IAAI,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCvC,eAAsB,sBACpB,YACA,QACsB;CACtB,MAAM,OAAO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AAY,OAAoC;CACvD,IAAI,OAAO,UAAU,UACnB,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM;EAC/C,MAAM,UAAU;EAChB,OAAO,QAAQ,OAAO,QAAQ;CAChC;AAGF;AAEA,SAAS,WAAW,MAAsB;CACxC,MAAM,aAAa,KAAK,QAAQ,GAAG;CAEnC,OAAO,eAAe,KAAK,OAAO,KAAK,MAAM,GAAG,UAAU;AAC5D"}
1
+ {"version":3,"file":"prepare-attachment-part.mjs","names":["resolvePath"],"sources":["../../../../../../../ai/src/utils/prepare-attachment-part.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { extname, isAbsolute, relative, resolve as resolvePath } from \"node:path\";\nimport type { AttachmentPolicy } from \"../contracts/attachment-policy.type\";\nimport type { Attachment } from \"../contracts/attachment.type\";\nimport type { ContentPart } from \"../contracts/content-part.type\";\nimport { InvalidRequestError, OutboundPolicyError } from \"../errors\";\nimport { fetchTextWithPolicy } from \"../security/outbound-policy\";\nimport { resolveAttachment } from \"./resolve-attachment\";\n\nconst IMAGE_EXTENSIONS_TO_MEDIA_TYPE: Record<string, string> = {\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".gif\": \"image/gif\",\n};\n\nconst TEXT_EXTENSIONS = new Set([\".txt\"]);\n\nconst AUDIO_EXTENSIONS_TO_MEDIA_TYPE: Record<string, string> = {\n \".mp3\": \"audio/mpeg\",\n \".wav\": \"audio/wav\",\n \".m4a\": \"audio/mp4\",\n \".ogg\": \"audio/ogg\",\n \".weba\": \"audio/webm\",\n};\n\nconst PDF_EXTENSIONS = new Set([\".pdf\"]);\n\ntype AttachmentKind = \"image\" | \"text\" | \"pdf\" | \"audio\";\n\n/**\n * Convert a user-supplied `Attachment` into a provider-ready\n * `ContentPart` the model adapter can consume without doing any I/O of\n * its own.\n *\n * Kind resolution:\n * - Tagged `{ type: \"image\", source }` / `{ type: \"text\", source }`\n * trusts the caller's intent.\n * - Shorthand (raw string / `StorageFileShape`) infers from the file\n * extension. Image extensions (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`)\n * map to `\"image\"`. `.txt` maps to `\"text\"`. Anything else throws\n * `InvalidRequestError` — silent inference on ambiguous inputs\n * causes silent bugs.\n *\n * Local paths are read from disk; images are base64-encoded inline,\n * text files are read as UTF-8 strings and returned as a `text`\n * `ContentPart`. Remote URLs for image attachments are passed through\n * unchanged; remote URLs for text attachments are fetched so the\n * adapter never needs network access.\n *\n * @example\n * await prepareAttachmentPart(\"./photo.png\");\n * // → { type: \"image\", source: { base64: \"...\", mediaType: \"image/png\" } }\n *\n * @example\n * await prepareAttachmentPart({ type: \"text\", source: \"./notes.txt\" });\n * // → { type: \"text\", text: \"<file contents>\" }\n *\n * **Trust boundary (S1).** Attachment references are often user-controlled,\n * so server-side I/O is policy-gated by `policy` ({@link AttachmentPolicy}):\n * remote text fetches are default-deny and, when enabled, run through the\n * shared `OutboundPolicy` (scheme/host/private-IP/max-bytes/timeout); local\n * reads honor an `allowedRoots` sandbox; bare-string local paths warn\n * (staged deprecation). URL *image* attachments are passed to the provider\n * untouched (never fetched here).\n */\nexport async function prepareAttachmentPart(\n attachment: Attachment,\n policy?: AttachmentPolicy,\n): Promise<ContentPart> {\n const kind = resolveKind(attachment);\n const bareString = typeof attachment === \"string\";\n\n if (kind === \"text\") {\n return prepareTextPart(attachment, policy, bareString);\n }\n\n if (kind === \"image\") {\n return prepareImagePart(attachment, policy, bareString);\n }\n\n return prepareBinaryPart(attachment, kind, policy, bareString);\n}\n\n/**\n * Decide whether the attachment is text or image. Tagged forms win\n * immediately; for shorthand we inspect the extension. Throws if the\n * shorthand doesn't look like anything we recognize.\n */\nfunction resolveKind(attachment: Attachment): AttachmentKind {\n if (isTaggedAttachment(attachment)) {\n return attachment.type;\n }\n\n const path = extractPath(attachment);\n const extension = path ? extname(stripQuery(path)).toLowerCase() : \"\";\n\n if (IMAGE_EXTENSIONS_TO_MEDIA_TYPE[extension]) {\n return \"image\";\n }\n\n if (TEXT_EXTENSIONS.has(extension)) {\n return \"text\";\n }\n\n if (PDF_EXTENSIONS.has(extension)) {\n return \"pdf\";\n }\n\n if (AUDIO_EXTENSIONS_TO_MEDIA_TYPE[extension]) {\n return \"audio\";\n }\n\n throw new InvalidRequestError(\n \"Cannot infer attachment type from input — pass an explicit `{ type: 'image' | 'text' | 'pdf' | 'audio', source: ... }` or use a recognized extension (.png, .jpg, .jpeg, .webp, .gif, .txt, .pdf, .mp3, .wav, .m4a, .ogg, .weba)\",\n );\n}\n\n/**\n * Produce a `pdf` / `audio` ContentPart (A2). URLs pass through; local\n * paths are read and base64-encoded with a media type inferred from the\n * kind (`application/pdf`) or extension (audio); inline base64 passes\n * through. Same `AttachmentPolicy` gating as image/text reads.\n */\nasync function prepareBinaryPart(\n attachment: Attachment,\n kind: \"pdf\" | \"audio\",\n policy: AttachmentPolicy | undefined,\n bareString: boolean,\n): Promise<ContentPart> {\n const resolved = resolveAttachment(attachment);\n\n if (resolved.type === \"url\") {\n return { type: kind, source: { url: resolved.value } };\n }\n\n if (resolved.type === \"base64\") {\n return { type: kind, source: { base64: resolved.value, mediaType: resolved.mediaType } };\n }\n\n const mediaType =\n kind === \"pdf\" ? \"application/pdf\" : inferAudioMediaType(resolved.value);\n\n if (!mediaType) {\n throw new InvalidRequestError(\n `Cannot infer media type for ${kind} path \"${resolved.value}\" — use a recognized extension or pass ` +\n `\\`{ type: '${kind}', source: { base64, mediaType } }\\``,\n { context: { path: resolved.value } },\n );\n }\n\n enforceLocalPathPolicy(resolved.value, bareString, policy);\n const bytes = await readFile(resolved.value);\n\n return { type: kind, source: { base64: bytes.toString(\"base64\"), mediaType } };\n}\n\n/** Infer an audio media type from a path's extension. */\nfunction inferAudioMediaType(path: string): string | undefined {\n return AUDIO_EXTENSIONS_TO_MEDIA_TYPE[extname(stripQuery(path)).toLowerCase()];\n}\n\n/**\n * Produce an `image` ContentPart. URLs pass through; paths are\n * read from disk and base64-encoded with an inferred media type.\n * Inline base64 attachments pass through unchanged.\n */\nasync function prepareImagePart(\n attachment: Attachment,\n policy: AttachmentPolicy | undefined,\n bareString: boolean,\n): Promise<ContentPart> {\n const inferredMediaType = isTaggedAttachment(attachment)\n ? undefined\n : inferImageMediaType(attachment);\n\n const resolved = resolveAttachment(attachment);\n\n if (resolved.type === \"url\") {\n // URL images are handed to the provider as a URL — the provider\n // fetches them, not us — so there's no server-side SSRF surface here.\n return { type: \"image\", source: { url: resolved.value } };\n }\n\n if (resolved.type === \"base64\") {\n return {\n type: \"image\",\n source: { base64: resolved.value, mediaType: resolved.mediaType },\n };\n }\n\n const mediaType = inferredMediaType ?? inferImageMediaType(resolved.value);\n\n if (!mediaType) {\n throw new InvalidRequestError(\n `Cannot infer media type for path \"${resolved.value}\" — use a recognized image extension or pass ` +\n \"`{ type: 'image', source: { base64, mediaType } }`\",\n { context: { path: resolved.value } },\n );\n }\n\n enforceLocalPathPolicy(resolved.value, bareString, policy);\n const bytes = await readFile(resolved.value);\n\n return {\n type: \"image\",\n source: { base64: bytes.toString(\"base64\"), mediaType },\n };\n}\n\n/**\n * Produce a `text` ContentPart. URLs are fetched as UTF-8, paths are\n * read from disk as UTF-8, inline base64 is decoded to UTF-8. The\n * result joins the conversation as an additional text part the model\n * sees before responding.\n */\nasync function prepareTextPart(\n attachment: Attachment,\n policy: AttachmentPolicy | undefined,\n bareString: boolean,\n): Promise<ContentPart> {\n const resolved = resolveAttachment(attachment);\n\n if (resolved.type === \"url\") {\n // Default-deny: a remote text attachment is a server-side fetch of\n // user-controlled input — refuse unless the app explicitly opted in,\n // then run it through the shared OutboundPolicy (scheme/host/private-\n // IP/max-bytes/timeout).\n if (!policy?.allowRemoteFetch) {\n throw new OutboundPolicyError(\n `remote text attachment fetch is disabled by default — set \\`attachmentPolicy.allowRemoteFetch: true\\` (with an \\`outbound\\` policy) to fetch \"${resolved.value}\"`,\n { context: { url: resolved.value } },\n );\n }\n\n const result = await fetchTextWithPolicy(resolved.value, policy.outbound ?? {});\n\n if (!result.ok) {\n throw new InvalidRequestError(\n `Failed to fetch text attachment \"${resolved.value}\" — status ${result.status}`,\n { context: { url: resolved.value, status: result.status } },\n );\n }\n\n return { type: \"text\", text: result.text };\n }\n\n if (resolved.type === \"base64\") {\n const decoded = Buffer.from(resolved.value, \"base64\").toString(\"utf8\");\n\n return { type: \"text\", text: decoded };\n }\n\n enforceLocalPathPolicy(resolved.value, bareString, policy);\n const bytes = await readFile(resolved.value, \"utf8\");\n\n return { type: \"text\", text: bytes };\n}\n\n/** Process-lifetime flag so the bare-string deprecation warns at most once. */\nlet warnedBareLocalPath = false;\n\n/**\n * Enforce the local-file half of {@link AttachmentPolicy} (S1):\n *\n * - **Bare-string local paths** are staged for deprecation. With\n * `allowBareLocalPaths: false` they hard-deny now; otherwise they warn\n * once (outside tests) — the typed `StorageFile.absolutePath` route is\n * the supported way to read a local file.\n * - **`allowedRoots` sandbox** — when set, the resolved path must live\n * inside one of the roots, else the read is refused.\n */\nfunction enforceLocalPathPolicy(\n path: string,\n bareString: boolean,\n policy: AttachmentPolicy | undefined,\n): void {\n if (bareString) {\n if (policy?.allowBareLocalPaths === false) {\n throw new OutboundPolicyError(\n `local file attachment via a bare string path (\"${path}\") is disabled — pass a typed \\`{ type, source: { absolutePath } }\\` StorageFile, or set \\`attachmentPolicy.allowBareLocalPaths: true\\``,\n { context: { path } },\n );\n }\n\n if (!warnedBareLocalPath && !process.env.VITEST && process.env.NODE_ENV !== \"test\") {\n warnedBareLocalPath = true;\n console.warn(\n \"[warlock-ai] reading a local file attachment from a bare string path is deprecated and will be denied by default in a future minor. \" +\n \"Pass a typed `{ type, source: { absolutePath } }` StorageFile and confine reads with `attachmentPolicy.allowedRoots`.\",\n );\n }\n }\n\n const roots = policy?.allowedRoots;\n if (roots && roots.length > 0) {\n const target = resolvePath(path);\n const inside = roots.some(root => {\n const rel = relative(resolvePath(root), target);\n return rel === \"\" || (!rel.startsWith(\"..\") && !isAbsolute(rel));\n });\n\n if (!inside) {\n throw new OutboundPolicyError(\n `local file attachment \"${path}\" is outside the allowed roots`,\n { context: { path, allowedRoots: roots } },\n );\n }\n }\n}\n\nfunction isTaggedAttachment(\n attachment: Attachment,\n): attachment is Extract<Attachment, { type: string }> {\n return (\n typeof attachment === \"object\" &&\n attachment !== null &&\n \"type\" in attachment\n );\n}\n\nfunction inferImageMediaType(input: unknown): string | undefined {\n const path = extractPath(input);\n\n if (!path) {\n return undefined;\n }\n\n const extension = extname(stripQuery(path)).toLowerCase();\n\n return IMAGE_EXTENSIONS_TO_MEDIA_TYPE[extension];\n}\n\nfunction extractPath(input: unknown): string | undefined {\n if (typeof input === \"string\") {\n return input;\n }\n\n if (typeof input === \"object\" && input !== null) {\n const storage = input as { url?: string; absolutePath?: string };\n return storage.url ?? storage.absolutePath;\n }\n\n return undefined;\n}\n\nfunction stripQuery(path: string): string {\n const queryIndex = path.indexOf(\"?\");\n\n return queryIndex === -1 ? path : path.slice(0, queryIndex);\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,iCAAyD;CAC7D,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;AACV;AAEA,MAAM,kBAAkB,IAAI,IAAI,CAAC,MAAM,CAAC;AAExC,MAAM,iCAAyD;CAC7D,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;AACX;AAEA,MAAM,iBAAiB,IAAI,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCvC,eAAsB,sBACpB,YACA,QACsB;CACtB,MAAM,OAAO,YAAY,UAAU;CACnC,MAAM,aAAa,OAAO,eAAe;CAEzC,IAAI,SAAS,QACX,OAAO,gBAAgB,YAAY,QAAQ,UAAU;CAGvD,IAAI,SAAS,SACX,OAAO,iBAAiB,YAAY,QAAQ,UAAU;CAGxD,OAAO,kBAAkB,YAAY,MAAM,QAAQ,UA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,QAAQ,GAAG;CAEnC,OAAO,eAAe,KAAK,OAAO,KAAK,MAAM,GAAG,UAAU;AAC5D"}
@@ -1,6 +1,6 @@
1
1
  import { Attachment, ResolvedAttachment } from "../contracts/attachment.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/utils/resolve-attachment.d.ts
3
+ //#region ../ai/src/utils/resolve-attachment.d.ts
4
4
  /**
5
5
  * Normalize a user-supplied `Attachment` (or bare `AttachmentSource`)
6
6
  * into a `ResolvedAttachment` the agent can hand to file-reading code
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-attachment.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/resolve-attachment.ts"],"mappings":";;;;;AAoCA;;;;;;;;AAA6E;;;;;;;;;;;;;;;;;iBAA7D,iBAAA,CAAkB,UAAA,EAAY,UAAA,GAAa,kBAAkB"}
1
+ {"version":3,"file":"resolve-attachment.d.mts","names":[],"sources":["../../../../../../../ai/src/utils/resolve-attachment.ts"],"mappings":";;;;;AAoCA;;;;;;;;AAA6E;;;;;;;;;;;;;;;;;iBAA7D,iBAAA,CAAkB,UAAA,EAAY,UAAA,GAAa,kBAAkB"}
@@ -1,7 +1,7 @@
1
1
  import { InvalidRequestError } from "../errors/invalid-request-error.mjs";
2
2
  import "../errors/index.mjs";
3
3
 
4
- //#region ../@warlock.js/ai/src/utils/resolve-attachment.ts
4
+ //#region ../ai/src/utils/resolve-attachment.ts
5
5
  const REMOTE_URL_PATTERN = /^https?:\/\//i;
6
6
  /**
7
7
  * Normalize a user-supplied `Attachment` (or bare `AttachmentSource`)
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-attachment.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/resolve-attachment.ts"],"sourcesContent":["import type {\n Attachment,\n AttachmentSource,\n ResolvedAttachment,\n} from \"../contracts/attachment.type\";\nimport { InvalidRequestError } from \"../errors\";\n\nconst REMOTE_URL_PATTERN = /^https?:\\/\\//i;\n\n/**\n * Normalize a user-supplied `Attachment` (or bare `AttachmentSource`)\n * into a `ResolvedAttachment` the agent can hand to file-reading code\n * without re-discriminating the input variant.\n *\n * Resolution rules:\n * - `{ base64, mediaType }` → `{ type: \"base64\", value, mediaType }`.\n * - `StorageFileShape` (`{ url?, absolutePath? }`) → `absolutePath` wins\n * over `url` when both are present (prefer the local file over an extra\n * remote hop). Absolute path becomes `{ type: \"path\" }`; url becomes\n * `{ type: \"url\" }`.\n * - String starting with `http://` / `https://` → `{ type: \"url\" }`.\n * - Any other string → `{ type: \"path\" }`.\n * - Tagged `{ type: \"image\" | \"text\", source }` → recurses into `source`.\n *\n * Throws `InvalidRequestError` on obviously invalid input (empty\n * string, storage object with neither url nor absolutePath, missing\n * source field).\n *\n * @example\n * resolveAttachment(\"https://cdn.example.com/doc.pdf\");\n * // → { type: \"url\", value: \"https://cdn.example.com/doc.pdf\" }\n *\n * @example\n * resolveAttachment({ type: \"image\", source: \"/tmp/x.png\" });\n * // → { type: \"path\", value: \"/tmp/x.png\" }\n */\nexport function resolveAttachment(attachment: Attachment): ResolvedAttachment {\n if (\n typeof attachment === \"object\" &&\n attachment !== null &&\n \"type\" in attachment\n ) {\n return resolveSource(attachment.source);\n }\n\n return resolveSource(attachment);\n}\n\nfunction resolveSource(source: AttachmentSource): ResolvedAttachment {\n if (typeof source === \"string\") {\n if (!source) {\n throw new InvalidRequestError(\"Cannot resolve empty attachment string\");\n }\n\n if (REMOTE_URL_PATTERN.test(source)) {\n return { type: \"url\", value: source };\n }\n\n return { type: \"path\", value: source };\n }\n\n // StorageFile objects (from @warlock.js/core) can expose a `base64`\n // property alongside `url` / `absolutePath`. Check storage shape\n // first so we don't treat a StorageFile as an inline-bytes payload.\n if (\"url\" in source || \"absolutePath\" in source) {\n const storage = source as { url?: string; absolutePath?: string };\n\n if (storage.absolutePath) {\n return { type: \"path\", value: storage.absolutePath };\n }\n\n if (storage.url) {\n return { type: \"url\", value: storage.url };\n }\n\n throw new InvalidRequestError(\n \"Storage attachment has neither url nor absolutePath\",\n );\n }\n\n if (\"base64\" in source) {\n if (!source.base64 || !source.mediaType) {\n throw new InvalidRequestError(\n \"Inline attachment requires both `base64` and `mediaType`\",\n );\n }\n\n return {\n type: \"base64\",\n value: source.base64,\n mediaType: source.mediaType,\n };\n }\n\n throw new InvalidRequestError(\n \"Unrecognized attachment source — expected a string path/URL, a StorageFile, or `{ base64, mediaType }`\",\n );\n}\n"],"mappings":";;;;AAOA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B3B,SAAgB,kBAAkB,YAA4C;CAC5E,IACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU,YAEV,OAAO,cAAc,WAAW,MAAM;CAGxC,OAAO,cAAc,UAAU;AACjC;AAEA,SAAS,cAAc,QAA8C;CACnE,IAAI,OAAO,WAAW,UAAU;EAC9B,IAAI,CAAC,QACH,MAAM,IAAI,oBAAoB,wCAAwC;EAGxE,IAAI,mBAAmB,KAAK,MAAM,GAChC,OAAO;GAAE,MAAM;GAAO,OAAO;EAAO;EAGtC,OAAO;GAAE,MAAM;GAAQ,OAAO;EAAO;CACvC;CAKA,IAAI,SAAS,UAAU,kBAAkB,QAAQ;EAC/C,MAAM,UAAU;EAEhB,IAAI,QAAQ,cACV,OAAO;GAAE,MAAM;GAAQ,OAAO,QAAQ;EAAa;EAGrD,IAAI,QAAQ,KACV,OAAO;GAAE,MAAM;GAAO,OAAO,QAAQ;EAAI;EAG3C,MAAM,IAAI,oBACR,qDACF;CACF;CAEA,IAAI,YAAY,QAAQ;EACtB,IAAI,CAAC,OAAO,UAAU,CAAC,OAAO,WAC5B,MAAM,IAAI,oBACR,0DACF;EAGF,OAAO;GACL,MAAM;GACN,OAAO,OAAO;GACd,WAAW,OAAO;EACpB;CACF;CAEA,MAAM,IAAI,oBACR,wGACF;AACF"}
1
+ {"version":3,"file":"resolve-attachment.mjs","names":[],"sources":["../../../../../../../ai/src/utils/resolve-attachment.ts"],"sourcesContent":["import type {\n Attachment,\n AttachmentSource,\n ResolvedAttachment,\n} from \"../contracts/attachment.type\";\nimport { InvalidRequestError } from \"../errors\";\n\nconst REMOTE_URL_PATTERN = /^https?:\\/\\//i;\n\n/**\n * Normalize a user-supplied `Attachment` (or bare `AttachmentSource`)\n * into a `ResolvedAttachment` the agent can hand to file-reading code\n * without re-discriminating the input variant.\n *\n * Resolution rules:\n * - `{ base64, mediaType }` → `{ type: \"base64\", value, mediaType }`.\n * - `StorageFileShape` (`{ url?, absolutePath? }`) → `absolutePath` wins\n * over `url` when both are present (prefer the local file over an extra\n * remote hop). Absolute path becomes `{ type: \"path\" }`; url becomes\n * `{ type: \"url\" }`.\n * - String starting with `http://` / `https://` → `{ type: \"url\" }`.\n * - Any other string → `{ type: \"path\" }`.\n * - Tagged `{ type: \"image\" | \"text\", source }` → recurses into `source`.\n *\n * Throws `InvalidRequestError` on obviously invalid input (empty\n * string, storage object with neither url nor absolutePath, missing\n * source field).\n *\n * @example\n * resolveAttachment(\"https://cdn.example.com/doc.pdf\");\n * // → { type: \"url\", value: \"https://cdn.example.com/doc.pdf\" }\n *\n * @example\n * resolveAttachment({ type: \"image\", source: \"/tmp/x.png\" });\n * // → { type: \"path\", value: \"/tmp/x.png\" }\n */\nexport function resolveAttachment(attachment: Attachment): ResolvedAttachment {\n if (\n typeof attachment === \"object\" &&\n attachment !== null &&\n \"type\" in attachment\n ) {\n return resolveSource(attachment.source);\n }\n\n return resolveSource(attachment);\n}\n\nfunction resolveSource(source: AttachmentSource): ResolvedAttachment {\n if (typeof source === \"string\") {\n if (!source) {\n throw new InvalidRequestError(\"Cannot resolve empty attachment string\");\n }\n\n if (REMOTE_URL_PATTERN.test(source)) {\n return { type: \"url\", value: source };\n }\n\n return { type: \"path\", value: source };\n }\n\n // StorageFile objects (from @warlock.js/core) can expose a `base64`\n // property alongside `url` / `absolutePath`. Check storage shape\n // first so we don't treat a StorageFile as an inline-bytes payload.\n if (\"url\" in source || \"absolutePath\" in source) {\n const storage = source as { url?: string; absolutePath?: string };\n\n if (storage.absolutePath) {\n return { type: \"path\", value: storage.absolutePath };\n }\n\n if (storage.url) {\n return { type: \"url\", value: storage.url };\n }\n\n throw new InvalidRequestError(\n \"Storage attachment has neither url nor absolutePath\",\n );\n }\n\n if (\"base64\" in source) {\n if (!source.base64 || !source.mediaType) {\n throw new InvalidRequestError(\n \"Inline attachment requires both `base64` and `mediaType`\",\n );\n }\n\n return {\n type: \"base64\",\n value: source.base64,\n mediaType: source.mediaType,\n };\n }\n\n throw new InvalidRequestError(\n \"Unrecognized attachment source — expected a string path/URL, a StorageFile, or `{ base64, mediaType }`\",\n );\n}\n"],"mappings":";;;;AAOA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B3B,SAAgB,kBAAkB,YAA4C;CAC5E,IACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU,YAEV,OAAO,cAAc,WAAW,MAAM;CAGxC,OAAO,cAAc,UAAU;AACjC;AAEA,SAAS,cAAc,QAA8C;CACnE,IAAI,OAAO,WAAW,UAAU;EAC9B,IAAI,CAAC,QACH,MAAM,IAAI,oBAAoB,wCAAwC;EAGxE,IAAI,mBAAmB,KAAK,MAAM,GAChC,OAAO;GAAE,MAAM;GAAO,OAAO;EAAO;EAGtC,OAAO;GAAE,MAAM;GAAQ,OAAO;EAAO;CACvC;CAKA,IAAI,SAAS,UAAU,kBAAkB,QAAQ;EAC/C,MAAM,UAAU;EAEhB,IAAI,QAAQ,cACV,OAAO;GAAE,MAAM;GAAQ,OAAO,QAAQ;EAAa;EAGrD,IAAI,QAAQ,KACV,OAAO;GAAE,MAAM;GAAO,OAAO,QAAQ;EAAI;EAG3C,MAAM,IAAI,oBACR,qDACF;CACF;CAEA,IAAI,YAAY,QAAQ;EACtB,IAAI,CAAC,OAAO,UAAU,CAAC,OAAO,WAC5B,MAAM,IAAI,oBACR,0DACF;EAGF,OAAO;GACL,MAAM;GACN,OAAO,OAAO;GACd,WAAW,OAAO;EACpB;CACF;CAEA,MAAM,IAAI,oBACR,wGACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { BaseReport } from "../contracts/result/base-report.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/utils/run-context.d.ts
3
+ //#region ../ai/src/utils/run-context.d.ts
4
4
  /**
5
5
  * The ambient run frame an executable reads when it finishes building
6
6
  * its report. When present, a child execution (an `agent.execute()`,
@@ -1 +1 @@
1
- {"version":3,"file":"run-context.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/run-context.ts"],"mappings":";;;;;AAgBA;;;;;;;;;;AAsBW;KAtBC,QAAA;EAqDgB;;;;EAhD1B,IAAA,EAAM,UAAU;EAgD8C;;;;;EA1C9D,SAAA;EA0C+C;;;AAAe;AAYhE;EAhDE,WAAA;EAgD6B;;;;EA3C7B,SAAA;AAAA;;AA2CgD;AAUlD;;;;AAA2C;AAsC3C;;;iBA5DgB,YAAA,IAAgB,KAAA,EAAO,QAAA,EAAU,EAAA,QAAU,CAAA,GAAI,CAAA;AA4DV;;;;;;;;AAAA,iBAhDrC,eAAA,IAAmB,EAAA,QAAU,CAAA,GAAI,CAAC;;;;;;;iBAUlC,eAAA,IAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;iBAsC3B,kBAAA,CAAmB,MAAkB,EAAV,UAAU"}
1
+ {"version":3,"file":"run-context.d.mts","names":[],"sources":["../../../../../../../ai/src/utils/run-context.ts"],"mappings":";;;;;AAgBA;;;;;;;;;;AAsBW;KAtBC,QAAA;EAqDgB;;;;EAhD1B,IAAA,EAAM,UAAU;EAgD8C;;;;;EA1C9D,SAAA;EA0C+C;;;AAAe;AAYhE;EAhDE,WAAA;EAgD6B;;;;EA3C7B,SAAA;AAAA;;AA2CgD;AAUlD;;;;AAA2C;AAsC3C;;;iBA5DgB,YAAA,IAAgB,KAAA,EAAO,QAAA,EAAU,EAAA,QAAU,CAAA,GAAI,CAAA;AA4DV;;;;;;;;AAAA,iBAhDrC,eAAA,IAAmB,EAAA,QAAU,CAAA,GAAI,CAAC;;;;;;;iBAUlC,eAAA,IAAmB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;iBAsC3B,kBAAA,CAAmB,MAAkB,EAAV,UAAU"}
@@ -1,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
 
3
- //#region ../@warlock.js/ai/src/utils/run-context.ts
3
+ //#region ../ai/src/utils/run-context.ts
4
4
  /**
5
5
  * Process-wide async-local store holding the current {@link RunFrame}.
6
6
  * A single shared instance so a frame installed by the supervisor is
@@ -1 +1 @@
1
- {"version":3,"file":"run-context.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/run-context.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\n\n/**\n * The ambient run frame an executable reads when it finishes building\n * its report. When present, a child execution (an `agent.execute()`,\n * `workflow.execute()`, `supervisor.execute()` call) auto-attaches its\n * report to `sink` and inherits the frame's `rootRunId` / `sessionId`\n * lineage — so reports nest under the enclosing run with NO manual id\n * threading by the dev.\n *\n * Installed by orchestration primitives (supervisor / orchestrator /\n * team) around the synchronous + async body of an intent's callback,\n * so any agent the callback invokes directly — `agent.execute(...)`\n * rather than `ctx.run(...)` — still lands in the trace tree.\n */\nexport type RunFrame = {\n /**\n * The `children[]` array of the enclosing report node. A child\n * execution pushes its assembled report here on completion.\n */\n sink: BaseReport[];\n /**\n * The outermost run-id this subtree belongs to. Propagated onto the\n * child report's `rootRunId` so flat-row consumers group it with the\n * enclosing run.\n */\n rootRunId: string;\n /**\n * Run-id of the enclosing node (the immediate parent of any child\n * captured through this frame). Stamped onto the child's\n * `parentRunId`.\n */\n parentRunId: string;\n /**\n * Session identifier propagated onto the captured child's subtree.\n * `undefined` when the enclosing run had none.\n */\n sessionId?: string;\n};\n\n/**\n * Process-wide async-local store holding the current {@link RunFrame}.\n * A single shared instance so a frame installed by the supervisor is\n * visible to an agent running several `await`s deep inside a callback,\n * across module boundaries. Empty (returns `undefined`) outside any\n * orchestration callback — standalone `agent.execute()` is unaffected.\n */\nconst runFrameStore = new AsyncLocalStorage<RunFrame | undefined>();\n\n/**\n * A second async-local flag set whenever execution is nested inside a\n * parent capture — by BOTH {@link withRunFrame} (ambient capture) and\n * {@link withoutRunFrame} (explicit parent capture, which clears the frame).\n * Lets the `observeAll` gate skip self-routing a nested run regardless of\n * which capture path its parent uses — the parent already captures it.\n */\nconst nestedStore = new AsyncLocalStorage<boolean>();\n\n/**\n * Run `fn` with `frame` installed as the ambient {@link RunFrame} for\n * the entire async subtree it spawns. Restores the previous frame (or\n * none) when `fn` settles. Returns whatever `fn` returns.\n *\n * Nesting is natural: a callback that itself dispatches a nested\n * supervisor installs a fresh frame for the inner run, and the inner\n * frame shadows the outer one for the inner subtree only — exactly the\n * tree shape the report models.\n */\nexport function withRunFrame<T>(frame: RunFrame, fn: () => T): T {\n return nestedStore.run(true, () => runFrameStore.run(frame, fn));\n}\n\n/**\n * Run `fn` with NO ambient {@link RunFrame} installed for its async\n * subtree, restoring the previous frame when `fn` settles. Used by the\n * supervisor's EXPLICIT capture paths (`ctx.run(...)` /\n * `ctx.intents.X.execute()`) — those already push the child report onto\n * the callback's `children[]` themselves, so the child must NOT also\n * self-capture via the ambient frame (which would double-count it).\n */\nexport function withoutRunFrame<T>(fn: () => T): T {\n return nestedStore.run(true, () => runFrameStore.run(undefined, fn));\n}\n\n/**\n * Read the current ambient {@link RunFrame}, or `undefined` when no\n * orchestration callback is on the stack. An executable calls this at\n * report-build time: a present frame means \"you were invoked inside a\n * callback — attach yourself to its tree\".\n */\nexport function currentRunFrame(): RunFrame | undefined {\n return runFrameStore.getStore();\n}\n\n/**\n * `true` when execution is nested inside a parent capture — set by\n * {@link withRunFrame} (ambient) or {@link withoutRunFrame} (explicit). Read\n * by the observe-all gate so a nested run, which its parent already captures\n * into the trace tree, is not also self-routed as a standalone top-level\n * trace. `false` for a standalone (root) run.\n */\nexport function isNestedRun(): boolean {\n return nestedStore.getStore() === true;\n}\n\n/**\n * Capture a freshly-built child `report` onto the current ambient\n * {@link RunFrame} when one is installed. Pushes the report onto the\n * frame's `sink` so it nests under the enclosing node, and rewrites the\n * report's lineage (`rootRunId`, `parentRunId`, `sessionId`) to the\n * frame's — mirroring how `step.agent` / `ctx.run` capture child\n * reports explicitly, but driven ambiently.\n *\n * No-op (returns `false`) when no frame is installed — a standalone\n * `agent.execute()` keeps its self-root untouched. Returns `true` when\n * the report was captured so the caller can suppress its own terminal\n * lineage stamp if needed.\n *\n * The lineage rewrite is intentionally shallow on the root + deep on\n * descendants would double-stamp; callers pass the already-lineage-\n * stamped subtree (self-root), and this relinks only the root's\n * `rootRunId` / `parentRunId` / `sessionId`. Descendants already carry\n * the child's own self-root as their `rootRunId`; the enclosing\n * primitive's terminal `stampReportLineage` pass (run once on the\n * outer tree) rewrites the whole subtree to the true outer root. This\n * keeps capture cheap and defers the single authoritative relink to\n * the outer build.\n */\nexport function captureChildReport(report: BaseReport): boolean {\n const frame = runFrameStore.getStore();\n\n if (!frame) {\n return false;\n }\n\n report.parentRunId = frame.parentRunId;\n report.rootRunId = frame.rootRunId;\n\n if (frame.sessionId !== undefined) {\n report.sessionId = frame.sessionId;\n }\n\n frame.sink.push(report);\n\n return true;\n}\n"],"mappings":";;;;;;;;;;AAgDA,MAAM,gBAAgB,IAAI,kBAAwC;;;;;;;;AASlE,MAAM,cAAc,IAAI,kBAA2B;;;;;;;;;;;AAYnD,SAAgB,aAAgB,OAAiB,IAAgB;CAC/D,OAAO,YAAY,IAAI,YAAY,cAAc,IAAI,OAAO,EAAE,CAAC;AACjE;;;;;;;;;AAUA,SAAgB,gBAAmB,IAAgB;CACjD,OAAO,YAAY,IAAI,YAAY,cAAc,IAAI,QAAW,EAAE,CAAC;AACrE;;;;;;;AAQA,SAAgB,kBAAwC;CACtD,OAAO,cAAc,SAAS;AAChC;;;;;;;;AASA,SAAgB,cAAuB;CACrC,OAAO,YAAY,SAAS,MAAM;AACpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,mBAAmB,QAA6B;CAC9D,MAAM,QAAQ,cAAc,SAAS;CAErC,IAAI,CAAC,OACH,OAAO;CAGT,OAAO,cAAc,MAAM;CAC3B,OAAO,YAAY,MAAM;CAEzB,IAAI,MAAM,cAAc,QACtB,OAAO,YAAY,MAAM;CAG3B,MAAM,KAAK,KAAK,MAAM;CAEtB,OAAO;AACT"}
1
+ {"version":3,"file":"run-context.mjs","names":[],"sources":["../../../../../../../ai/src/utils/run-context.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\n\n/**\n * The ambient run frame an executable reads when it finishes building\n * its report. When present, a child execution (an `agent.execute()`,\n * `workflow.execute()`, `supervisor.execute()` call) auto-attaches its\n * report to `sink` and inherits the frame's `rootRunId` / `sessionId`\n * lineage — so reports nest under the enclosing run with NO manual id\n * threading by the dev.\n *\n * Installed by orchestration primitives (supervisor / orchestrator /\n * team) around the synchronous + async body of an intent's callback,\n * so any agent the callback invokes directly — `agent.execute(...)`\n * rather than `ctx.run(...)` — still lands in the trace tree.\n */\nexport type RunFrame = {\n /**\n * The `children[]` array of the enclosing report node. A child\n * execution pushes its assembled report here on completion.\n */\n sink: BaseReport[];\n /**\n * The outermost run-id this subtree belongs to. Propagated onto the\n * child report's `rootRunId` so flat-row consumers group it with the\n * enclosing run.\n */\n rootRunId: string;\n /**\n * Run-id of the enclosing node (the immediate parent of any child\n * captured through this frame). Stamped onto the child's\n * `parentRunId`.\n */\n parentRunId: string;\n /**\n * Session identifier propagated onto the captured child's subtree.\n * `undefined` when the enclosing run had none.\n */\n sessionId?: string;\n};\n\n/**\n * Process-wide async-local store holding the current {@link RunFrame}.\n * A single shared instance so a frame installed by the supervisor is\n * visible to an agent running several `await`s deep inside a callback,\n * across module boundaries. Empty (returns `undefined`) outside any\n * orchestration callback — standalone `agent.execute()` is unaffected.\n */\nconst runFrameStore = new AsyncLocalStorage<RunFrame | undefined>();\n\n/**\n * A second async-local flag set whenever execution is nested inside a\n * parent capture — by BOTH {@link withRunFrame} (ambient capture) and\n * {@link withoutRunFrame} (explicit parent capture, which clears the frame).\n * Lets the `observeAll` gate skip self-routing a nested run regardless of\n * which capture path its parent uses — the parent already captures it.\n */\nconst nestedStore = new AsyncLocalStorage<boolean>();\n\n/**\n * Run `fn` with `frame` installed as the ambient {@link RunFrame} for\n * the entire async subtree it spawns. Restores the previous frame (or\n * none) when `fn` settles. Returns whatever `fn` returns.\n *\n * Nesting is natural: a callback that itself dispatches a nested\n * supervisor installs a fresh frame for the inner run, and the inner\n * frame shadows the outer one for the inner subtree only — exactly the\n * tree shape the report models.\n */\nexport function withRunFrame<T>(frame: RunFrame, fn: () => T): T {\n return nestedStore.run(true, () => runFrameStore.run(frame, fn));\n}\n\n/**\n * Run `fn` with NO ambient {@link RunFrame} installed for its async\n * subtree, restoring the previous frame when `fn` settles. Used by the\n * supervisor's EXPLICIT capture paths (`ctx.run(...)` /\n * `ctx.intents.X.execute()`) — those already push the child report onto\n * the callback's `children[]` themselves, so the child must NOT also\n * self-capture via the ambient frame (which would double-count it).\n */\nexport function withoutRunFrame<T>(fn: () => T): T {\n return nestedStore.run(true, () => runFrameStore.run(undefined, fn));\n}\n\n/**\n * Read the current ambient {@link RunFrame}, or `undefined` when no\n * orchestration callback is on the stack. An executable calls this at\n * report-build time: a present frame means \"you were invoked inside a\n * callback — attach yourself to its tree\".\n */\nexport function currentRunFrame(): RunFrame | undefined {\n return runFrameStore.getStore();\n}\n\n/**\n * `true` when execution is nested inside a parent capture — set by\n * {@link withRunFrame} (ambient) or {@link withoutRunFrame} (explicit). Read\n * by the observe-all gate so a nested run, which its parent already captures\n * into the trace tree, is not also self-routed as a standalone top-level\n * trace. `false` for a standalone (root) run.\n */\nexport function isNestedRun(): boolean {\n return nestedStore.getStore() === true;\n}\n\n/**\n * Capture a freshly-built child `report` onto the current ambient\n * {@link RunFrame} when one is installed. Pushes the report onto the\n * frame's `sink` so it nests under the enclosing node, and rewrites the\n * report's lineage (`rootRunId`, `parentRunId`, `sessionId`) to the\n * frame's — mirroring how `step.agent` / `ctx.run` capture child\n * reports explicitly, but driven ambiently.\n *\n * No-op (returns `false`) when no frame is installed — a standalone\n * `agent.execute()` keeps its self-root untouched. Returns `true` when\n * the report was captured so the caller can suppress its own terminal\n * lineage stamp if needed.\n *\n * The lineage rewrite is intentionally shallow on the root + deep on\n * descendants would double-stamp; callers pass the already-lineage-\n * stamped subtree (self-root), and this relinks only the root's\n * `rootRunId` / `parentRunId` / `sessionId`. Descendants already carry\n * the child's own self-root as their `rootRunId`; the enclosing\n * primitive's terminal `stampReportLineage` pass (run once on the\n * outer tree) rewrites the whole subtree to the true outer root. This\n * keeps capture cheap and defers the single authoritative relink to\n * the outer build.\n */\nexport function captureChildReport(report: BaseReport): boolean {\n const frame = runFrameStore.getStore();\n\n if (!frame) {\n return false;\n }\n\n report.parentRunId = frame.parentRunId;\n report.rootRunId = frame.rootRunId;\n\n if (frame.sessionId !== undefined) {\n report.sessionId = frame.sessionId;\n }\n\n frame.sink.push(report);\n\n return true;\n}\n"],"mappings":";;;;;;;;;;AAgDA,MAAM,gBAAgB,IAAI,kBAAwC;;;;;;;;AASlE,MAAM,cAAc,IAAI,kBAA2B;;;;;;;;;;;AAYnD,SAAgB,aAAgB,OAAiB,IAAgB;CAC/D,OAAO,YAAY,IAAI,YAAY,cAAc,IAAI,OAAO,EAAE,CAAC;AACjE;;;;;;;;;AAUA,SAAgB,gBAAmB,IAAgB;CACjD,OAAO,YAAY,IAAI,YAAY,cAAc,IAAI,QAAW,EAAE,CAAC;AACrE;;;;;;;AAQA,SAAgB,kBAAwC;CACtD,OAAO,cAAc,SAAS;AAChC;;;;;;;;AASA,SAAgB,cAAuB;CACrC,OAAO,YAAY,SAAS,MAAM;AACpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,mBAAmB,QAA6B;CAC9D,MAAM,QAAQ,cAAc,SAAS;CAErC,IAAI,CAAC,OACH,OAAO;CAGT,OAAO,cAAc,MAAM;CAC3B,OAAO,YAAY,MAAM;CAEzB,IAAI,MAAM,cAAc,QACtB,OAAO,YAAY,MAAM;CAG3B,MAAM,KAAK,KAAK,MAAM;CAEtB,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/utils/safe-json-parse.d.ts
1
+ //#region ../ai/src/utils/safe-json-parse.d.ts
2
2
  /**
3
3
  * Parse a JSON string, returning a caller-supplied fallback when the input
4
4
  * is empty or malformed instead of throwing. Useful at provider boundaries
@@ -1 +1 @@
1
- {"version":3,"file":"safe-json-parse.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/safe-json-parse.ts"],"mappings":";;AASA;;;;;;;;iBAAgB,aAAA,SACd,IAAA,6BACA,YAAA,EAAc,MAAA,GACb,MAAM"}
1
+ {"version":3,"file":"safe-json-parse.d.mts","names":[],"sources":["../../../../../../../ai/src/utils/safe-json-parse.ts"],"mappings":";;AASA;;;;;;;;iBAAgB,aAAA,SACd,IAAA,6BACA,YAAA,EAAc,MAAA,GACb,MAAM"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/utils/safe-json-parse.ts
1
+ //#region ../ai/src/utils/safe-json-parse.ts
2
2
  /**
3
3
  * Parse a JSON string, returning a caller-supplied fallback when the input
4
4
  * is empty or malformed instead of throwing. Useful at provider boundaries
@@ -1 +1 @@
1
- {"version":3,"file":"safe-json-parse.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/safe-json-parse.ts"],"sourcesContent":["/**\n * Parse a JSON string, returning a caller-supplied fallback when the input\n * is empty or malformed instead of throwing. Useful at provider boundaries\n * where tool-call arguments may arrive as `null`, `\"\"`, or partial JSON\n * during streaming — callers want a safe default, not an exception.\n *\n * @example\n * const args = safeJsonParse<Record<string, unknown>>(toolCall.function.arguments, {});\n */\nexport function safeJsonParse<TValue>(\n data: string | null | undefined,\n defaultValue: TValue,\n): TValue {\n if (!data) {\n return defaultValue;\n }\n\n try {\n return JSON.parse(data) as TValue;\n } catch {\n return defaultValue;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,cACd,MACA,cACQ;CACR,IAAI,CAAC,MACH,OAAO;CAGT,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"safe-json-parse.mjs","names":[],"sources":["../../../../../../../ai/src/utils/safe-json-parse.ts"],"sourcesContent":["/**\n * Parse a JSON string, returning a caller-supplied fallback when the input\n * is empty or malformed instead of throwing. Useful at provider boundaries\n * where tool-call arguments may arrive as `null`, `\"\"`, or partial JSON\n * during streaming — callers want a safe default, not an exception.\n *\n * @example\n * const args = safeJsonParse<Record<string, unknown>>(toolCall.function.arguments, {});\n */\nexport function safeJsonParse<TValue>(\n data: string | null | undefined,\n defaultValue: TValue,\n): TValue {\n if (!data) {\n return defaultValue;\n }\n\n try {\n return JSON.parse(data) as TValue;\n } catch {\n return defaultValue;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,cACd,MACA,cACQ;CACR,IAAI,CAAC,MACH,OAAO;CAGT,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { BaseReport } from "../contracts/result/base-report.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/utils/stamp-report-lineage.d.ts
3
+ //#region ../ai/src/utils/stamp-report-lineage.d.ts
4
4
  /**
5
5
  * Options for {@link stampReportLineage}. Every field is optional —
6
6
  * the caller supplies whichever pieces it knows. Missing pieces are
@@ -1 +1 @@
1
- {"version":3,"file":"stamp-report-lineage.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/stamp-report-lineage.ts"],"mappings":";;;;;AAQA;;;KAAY,YAAA;EAOV;;;;AAWS;AAgCX;EA3CE,SAAA;;;;;;EAMA,WAAA;EAqCsE;AAAA;;;EAhCtE,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCc,kBAAA,CAAmB,IAAA,EAAM,UAAA,EAAY,KAAA,EAAO,YAAY"}
1
+ {"version":3,"file":"stamp-report-lineage.d.mts","names":[],"sources":["../../../../../../../ai/src/utils/stamp-report-lineage.ts"],"mappings":";;;;;AAQA;;;KAAY,YAAA;EAOV;;;;AAWS;AAgCX;EA3CE,SAAA;;;;;;EAMA,WAAA;EAqCsE;AAAA;;;EAhCtE,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCc,kBAAA,CAAmB,IAAA,EAAM,UAAA,EAAY,KAAA,EAAO,YAAY"}
@@ -1,6 +1,6 @@
1
1
  import { REPORT_SCHEMA_VERSION } from "../contracts/result/base-report.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/utils/stamp-report-lineage.ts
3
+ //#region ../ai/src/utils/stamp-report-lineage.ts
4
4
  /**
5
5
  * Walk a freshly-built report tree and stamp lineage fields onto
6
6
  * every node:
@@ -1 +1 @@
1
- {"version":3,"file":"stamp-report-lineage.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/stamp-report-lineage.ts"],"sourcesContent":["import type { BaseReport } from \"../contracts/result/base-report.type\";\nimport { REPORT_SCHEMA_VERSION } from \"../contracts/result/base-report.type\";\n\n/**\n * Options for {@link stampReportLineage}. Every field is optional —\n * the caller supplies whichever pieces it knows. Missing pieces are\n * left untouched (existing values on the report survive).\n */\nexport type LineageStamp = {\n /**\n * The outermost run-id this subtree belongs to. When set, EVERY\n * node in the subtree gets its `rootRunId` rewritten to this\n * value — overrides any inner self-roots produced by nested\n * `buildResult` calls.\n */\n rootRunId: string;\n /**\n * Run-id of the immediate parent of THIS subtree's top node. Each\n * descendant's `parentRunId` is then derived from its own walk\n * position (its parent's `runId`).\n */\n parentRunId?: string;\n /**\n * Caller-supplied session identifier — propagates to every node in\n * the subtree. Skipped when undefined.\n */\n sessionId?: string;\n};\n\n/**\n * Walk a freshly-built report tree and stamp lineage fields onto\n * every node:\n *\n * - `rootRunId` — rewritten to `stamp.rootRunId` everywhere. Composite\n * children built by inner primitives carry their own self-root; this\n * walk overrides it so the outer root wins (single coherent run id\n * across the whole tree).\n * - `parentRunId` — root node gets `stamp.parentRunId`; descendants\n * derive theirs from each parent's own `runId`.\n * - `sessionId` — propagated when provided.\n * - `reportSchemaVersion` — stamped only on the root (the value is the\n * same for the whole tree; storing it on every node would waste\n * space).\n *\n * Designed to run ONCE per top-level `buildResult` call. Each\n * primitive's executor invokes this on the assembled root report just\n * before returning; nested primitives produced their own subtree with\n * a self-root, and this pass relinks everything to the outer caller's\n * lineage.\n *\n * Mutates the report in place — internal use only, before the report\n * is exposed via `result.report`.\n *\n * @example\n * const root = this.buildBareReport();\n * stampReportLineage(root, { rootRunId: this.runId, sessionId: this.options?.sessionId });\n * return { ..., report: root };\n */\nexport function stampReportLineage(root: BaseReport, stamp: LineageStamp): void {\n root.reportSchemaVersion = REPORT_SCHEMA_VERSION;\n\n walk(root, stamp.rootRunId, stamp.parentRunId, stamp.sessionId);\n}\n\nfunction walk(node: BaseReport, rootRunId: string, parentRunId?: string, sessionId?: string): void {\n node.rootRunId = rootRunId;\n\n if (parentRunId !== undefined) {\n node.parentRunId = parentRunId;\n } else {\n delete node.parentRunId;\n }\n\n if (sessionId !== undefined) {\n node.sessionId = sessionId;\n }\n\n for (const child of node.children) {\n walk(child, rootRunId, node.runId, sessionId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,mBAAmB,MAAkB,OAA2B;CAC9E,KAAK;CAEL,KAAK,MAAM,MAAM,WAAW,MAAM,aAAa,MAAM,SAAS;AAChE;AAEA,SAAS,KAAK,MAAkB,WAAmB,aAAsB,WAA0B;CACjG,KAAK,YAAY;CAEjB,IAAI,gBAAgB,QAClB,KAAK,cAAc;MAEnB,OAAO,KAAK;CAGd,IAAI,cAAc,QAChB,KAAK,YAAY;CAGnB,KAAK,MAAM,SAAS,KAAK,UACvB,KAAK,OAAO,WAAW,KAAK,OAAO,SAAS;AAEhD"}
1
+ {"version":3,"file":"stamp-report-lineage.mjs","names":[],"sources":["../../../../../../../ai/src/utils/stamp-report-lineage.ts"],"sourcesContent":["import type { BaseReport } from \"../contracts/result/base-report.type\";\nimport { REPORT_SCHEMA_VERSION } from \"../contracts/result/base-report.type\";\n\n/**\n * Options for {@link stampReportLineage}. Every field is optional —\n * the caller supplies whichever pieces it knows. Missing pieces are\n * left untouched (existing values on the report survive).\n */\nexport type LineageStamp = {\n /**\n * The outermost run-id this subtree belongs to. When set, EVERY\n * node in the subtree gets its `rootRunId` rewritten to this\n * value — overrides any inner self-roots produced by nested\n * `buildResult` calls.\n */\n rootRunId: string;\n /**\n * Run-id of the immediate parent of THIS subtree's top node. Each\n * descendant's `parentRunId` is then derived from its own walk\n * position (its parent's `runId`).\n */\n parentRunId?: string;\n /**\n * Caller-supplied session identifier — propagates to every node in\n * the subtree. Skipped when undefined.\n */\n sessionId?: string;\n};\n\n/**\n * Walk a freshly-built report tree and stamp lineage fields onto\n * every node:\n *\n * - `rootRunId` — rewritten to `stamp.rootRunId` everywhere. Composite\n * children built by inner primitives carry their own self-root; this\n * walk overrides it so the outer root wins (single coherent run id\n * across the whole tree).\n * - `parentRunId` — root node gets `stamp.parentRunId`; descendants\n * derive theirs from each parent's own `runId`.\n * - `sessionId` — propagated when provided.\n * - `reportSchemaVersion` — stamped only on the root (the value is the\n * same for the whole tree; storing it on every node would waste\n * space).\n *\n * Designed to run ONCE per top-level `buildResult` call. Each\n * primitive's executor invokes this on the assembled root report just\n * before returning; nested primitives produced their own subtree with\n * a self-root, and this pass relinks everything to the outer caller's\n * lineage.\n *\n * Mutates the report in place — internal use only, before the report\n * is exposed via `result.report`.\n *\n * @example\n * const root = this.buildBareReport();\n * stampReportLineage(root, { rootRunId: this.runId, sessionId: this.options?.sessionId });\n * return { ..., report: root };\n */\nexport function stampReportLineage(root: BaseReport, stamp: LineageStamp): void {\n root.reportSchemaVersion = REPORT_SCHEMA_VERSION;\n\n walk(root, stamp.rootRunId, stamp.parentRunId, stamp.sessionId);\n}\n\nfunction walk(node: BaseReport, rootRunId: string, parentRunId?: string, sessionId?: string): void {\n node.rootRunId = rootRunId;\n\n if (parentRunId !== undefined) {\n node.parentRunId = parentRunId;\n } else {\n delete node.parentRunId;\n }\n\n if (sessionId !== undefined) {\n node.sessionId = sessionId;\n }\n\n for (const child of node.children) {\n walk(child, rootRunId, node.runId, sessionId);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,mBAAmB,MAAkB,OAA2B;CAC9E,KAAK;CAEL,KAAK,MAAM,MAAM,WAAW,MAAM,aAAa,MAAM,SAAS;AAChE;AAEA,SAAS,KAAK,MAAkB,WAAmB,aAAsB,WAA0B;CACjG,KAAK,YAAY;CAEjB,IAAI,gBAAgB,QAClB,KAAK,cAAc;MAEnB,OAAO,KAAK;CAGd,IAAI,cAAc,QAChB,KAAK,YAAY;CAGnB,KAAK,MAAM,SAAS,KAAK,UACvB,KAAK,OAAO,WAAW,KAAK,OAAO,SAAS;AAEhD"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/utils/token-count.d.ts
1
+ //#region ../ai/src/utils/token-count.d.ts
2
2
  /**
3
3
  * Approximate the number of tokens in a string.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"token-count.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/token-count.ts"],"mappings":";;AAUA;;;;AAAkD;;;;;iBAAlC,qBAAA,CAAsB,IAAY"}
1
+ {"version":3,"file":"token-count.d.mts","names":[],"sources":["../../../../../../../ai/src/utils/token-count.ts"],"mappings":";;AAUA;;;;AAAkD;;;;;iBAAlC,qBAAA,CAAsB,IAAY"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/utils/token-count.ts
1
+ //#region ../ai/src/utils/token-count.ts
2
2
  /**
3
3
  * Approximate the number of tokens in a string.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"token-count.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/utils/token-count.ts"],"sourcesContent":["/**\n * Approximate the number of tokens in a string.\n *\n * Uses the ~4-characters-per-token heuristic, which is accurate enough for\n * GPT-4 family models and most English text. Use this when a real tokenizer\n * (tiktoken, etc.) isn't available or would add native dependencies.\n *\n * @example\n * const tokens = approximateTokenCount(\"Hello, world!\"); // 4\n */\nexport function approximateTokenCount(text: string): number {\n return Math.ceil(text.length / 4);\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,sBAAsB,MAAsB;CAC1D,OAAO,KAAK,KAAK,KAAK,SAAS,CAAC;AAClC"}
1
+ {"version":3,"file":"token-count.mjs","names":[],"sources":["../../../../../../../ai/src/utils/token-count.ts"],"sourcesContent":["/**\n * Approximate the number of tokens in a string.\n *\n * Uses the ~4-characters-per-token heuristic, which is accurate enough for\n * GPT-4 family models and most English text. Use this when a real tokenizer\n * (tiktoken, etc.) isn't available or would add native dependencies.\n *\n * @example\n * const tokens = approximateTokenCount(\"Hello, world!\"); // 4\n */\nexport function approximateTokenCount(text: string): number {\n return Math.ceil(text.length / 4);\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,sBAAsB,MAAsB;CAC1D,OAAO,KAAK,KAAK,KAAK,SAAS,CAAC;AAClC"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/vcr/cassette-io.ts
1
+ //#region ../ai/src/vcr/cassette-io.ts
2
2
  let fsModule;
3
3
  /**
4
4
  * Resolve `node:fs/promises` once and memoize it.
@@ -1 +1 @@
1
- {"version":3,"file":"cassette-io.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/cassette-io.ts"],"sourcesContent":["import type { Cassette } from \"./vcr.type\";\n\n/**\n * Lazily-resolved `node:fs/promises` module. VCR cassette I/O only touches\n * disk on construct (load) and on `save()` — keeping the import lazy means\n * importing the `vcr` factory never eagerly pulls `node:fs`, which keeps the\n * surface usable in non-node bundles that never call a disk path.\n */\ntype FsPromises = typeof import(\"node:fs/promises\");\n\nlet fsModule: FsPromises | undefined;\n\n/**\n * Resolve `node:fs/promises` once and memoize it.\n */\nasync function loadFs(): Promise<FsPromises> {\n if (!fsModule) {\n fsModule = await import(\"node:fs/promises\");\n }\n\n return fsModule;\n}\n\n/**\n * Build a fresh, empty cassette for a model identity. Used when the path\n * does not exist yet (first record run).\n */\nexport function emptyCassette(model: string, provider: string): Cassette {\n return {\n version: 1,\n model,\n provider,\n entries: [],\n };\n}\n\n/**\n * Load a cassette from disk. Returns a fresh empty cassette (not an error)\n * when the file does not exist — the common first-record case. Any other I/O\n * or parse failure rejects so corruption is never silently swallowed.\n */\nexport async function loadCassette(\n path: string,\n model: string,\n provider: string,\n): Promise<Cassette> {\n const fs = await loadFs();\n\n let raw: string;\n\n try {\n raw = await fs.readFile(path, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return emptyCassette(model, provider);\n }\n\n throw error;\n }\n\n const parsed = JSON.parse(raw) as Cassette;\n\n return {\n version: 1,\n model: parsed.model ?? model,\n provider: parsed.provider ?? provider,\n entries: Array.isArray(parsed.entries) ? parsed.entries : [],\n };\n}\n\n/**\n * Write a cassette to disk as pretty-printed JSON, creating the parent\n * directory if needed so a brand-new `./cassettes/foo.json` path just works.\n */\nexport async function saveCassette(path: string, cassette: Cassette): Promise<void> {\n const fs = await loadFs();\n const nodePath = await import(\"node:path\");\n const dir = nodePath.dirname(path);\n\n if (dir && dir !== \".\" && dir !== path) {\n await fs.mkdir(dir, { recursive: true });\n }\n\n await fs.writeFile(path, JSON.stringify(cassette, undefined, 2), \"utf8\");\n}\n"],"mappings":";AAUA,IAAI;;;;AAKJ,eAAe,SAA8B;CAC3C,IAAI,CAAC,UACH,WAAW,MAAM,OAAO;CAG1B,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,OAAe,UAA4B;CACvE,OAAO;EACL,SAAS;EACT;EACA;EACA,SAAS,CAAC;CACZ;AACF;;;;;;AAOA,eAAsB,aACpB,MACA,OACA,UACmB;CACnB,MAAM,KAAK,MAAM,OAAO;CAExB,IAAI;CAEJ,IAAI;EACF,MAAM,MAAM,GAAG,SAAS,MAAM,MAAM;CACtC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAC5C,OAAO,cAAc,OAAO,QAAQ;EAGtC,MAAM;CACR;CAEA,MAAM,SAAS,KAAK,MAAM,GAAG;CAE7B,OAAO;EACL,SAAS;EACT,OAAO,OAAO,SAAS;EACvB,UAAU,OAAO,YAAY;EAC7B,SAAS,MAAM,QAAQ,OAAO,OAAO,IAAI,OAAO,UAAU,CAAC;CAC7D;AACF;;;;;AAMA,eAAsB,aAAa,MAAc,UAAmC;CAClF,MAAM,KAAK,MAAM,OAAO;CAExB,MAAM,OAAM,MADW,OAAO,aACV,CAAC,QAAQ,IAAI;CAEjC,IAAI,OAAO,QAAQ,OAAO,QAAQ,MAChC,MAAM,GAAG,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;CAGzC,MAAM,GAAG,UAAU,MAAM,KAAK,UAAU,UAAU,QAAW,CAAC,GAAG,MAAM;AACzE"}
1
+ {"version":3,"file":"cassette-io.mjs","names":[],"sources":["../../../../../../../ai/src/vcr/cassette-io.ts"],"sourcesContent":["import type { Cassette } from \"./vcr.type\";\n\n/**\n * Lazily-resolved `node:fs/promises` module. VCR cassette I/O only touches\n * disk on construct (load) and on `save()` — keeping the import lazy means\n * importing the `vcr` factory never eagerly pulls `node:fs`, which keeps the\n * surface usable in non-node bundles that never call a disk path.\n */\ntype FsPromises = typeof import(\"node:fs/promises\");\n\nlet fsModule: FsPromises | undefined;\n\n/**\n * Resolve `node:fs/promises` once and memoize it.\n */\nasync function loadFs(): Promise<FsPromises> {\n if (!fsModule) {\n fsModule = await import(\"node:fs/promises\");\n }\n\n return fsModule;\n}\n\n/**\n * Build a fresh, empty cassette for a model identity. Used when the path\n * does not exist yet (first record run).\n */\nexport function emptyCassette(model: string, provider: string): Cassette {\n return {\n version: 1,\n model,\n provider,\n entries: [],\n };\n}\n\n/**\n * Load a cassette from disk. Returns a fresh empty cassette (not an error)\n * when the file does not exist — the common first-record case. Any other I/O\n * or parse failure rejects so corruption is never silently swallowed.\n */\nexport async function loadCassette(\n path: string,\n model: string,\n provider: string,\n): Promise<Cassette> {\n const fs = await loadFs();\n\n let raw: string;\n\n try {\n raw = await fs.readFile(path, \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return emptyCassette(model, provider);\n }\n\n throw error;\n }\n\n const parsed = JSON.parse(raw) as Cassette;\n\n return {\n version: 1,\n model: parsed.model ?? model,\n provider: parsed.provider ?? provider,\n entries: Array.isArray(parsed.entries) ? parsed.entries : [],\n };\n}\n\n/**\n * Write a cassette to disk as pretty-printed JSON, creating the parent\n * directory if needed so a brand-new `./cassettes/foo.json` path just works.\n */\nexport async function saveCassette(path: string, cassette: Cassette): Promise<void> {\n const fs = await loadFs();\n const nodePath = await import(\"node:path\");\n const dir = nodePath.dirname(path);\n\n if (dir && dir !== \".\" && dir !== path) {\n await fs.mkdir(dir, { recursive: true });\n }\n\n await fs.writeFile(path, JSON.stringify(cassette, undefined, 2), \"utf8\");\n}\n"],"mappings":";AAUA,IAAI;;;;AAKJ,eAAe,SAA8B;CAC3C,IAAI,CAAC,UACH,WAAW,MAAM,OAAO;CAG1B,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,OAAe,UAA4B;CACvE,OAAO;EACL,SAAS;EACT;EACA;EACA,SAAS,CAAC;CACZ;AACF;;;;;;AAOA,eAAsB,aACpB,MACA,OACA,UACmB;CACnB,MAAM,KAAK,MAAM,OAAO;CAExB,IAAI;CAEJ,IAAI;EACF,MAAM,MAAM,GAAG,SAAS,MAAM,MAAM;CACtC,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAC5C,OAAO,cAAc,OAAO,QAAQ;EAGtC,MAAM;CACR;CAEA,MAAM,SAAS,KAAK,MAAM,GAAG;CAE7B,OAAO;EACL,SAAS;EACT,OAAO,OAAO,SAAS;EACvB,UAAU,OAAO,YAAY;EAC7B,SAAS,MAAM,QAAQ,OAAO,OAAO,IAAI,OAAO,UAAU,CAAC;CAC7D;AACF;;;;;AAMA,eAAsB,aAAa,MAAc,UAAmC;CAClF,MAAM,KAAK,MAAM,OAAO;CAExB,MAAM,OAAM,MADW,OAAO,aACV,CAAC,QAAQ,IAAI;CAEjC,IAAI,OAAO,QAAQ,OAAO,QAAQ,MAChC,MAAM,GAAG,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;CAGzC,MAAM,GAAG,UAAU,MAAM,KAAK,UAAU,UAAU,QAAW,CAAC,GAAG,MAAM;AACzE"}
@@ -1,6 +1,6 @@
1
1
  import { AIError, AIErrorOptions } from "../errors/ai-error.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/vcr/errors.d.ts
3
+ //#region ../ai/src/vcr/errors.d.ts
4
4
  /**
5
5
  * Payload for {@link VcrCassetteMissError}. Carries the looked-up request
6
6
  * hash and the cassette path so a failing CI run names exactly which call
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/errors.ts"],"mappings":";;;;AAQA;;;;KAAY,2BAAA,GAA8B,cAAc;EAEtD,yEAAA,WAAA,WAEI;EAAJ,IAAA;AAAA;;;;;;;;;;;;AA6ByE;;;;;;;;;;;cAJ9D,oBAAA,SAA6B,OAAO;EAAA,SAC/B,WAAA;EAAA,SACA,IAAA;cAEG,OAAA,UAAiB,OAAA,GAAU,2BAAA;AAAA"}
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../../../../../../../ai/src/vcr/errors.ts"],"mappings":";;;;AAQA;;;;KAAY,2BAAA,GAA8B,cAAc;EAEtD,yEAAA,WAAA,WAEI;EAAJ,IAAA;AAAA;;;;;;;;;;;;AA6ByE;;;;;;;;;;;cAJ9D,oBAAA,SAA6B,OAAO;EAAA,SAC/B,WAAA;EAAA,SACA,IAAA;cAEG,OAAA,UAAiB,OAAA,GAAU,2BAAA;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { AIError } from "../errors/ai-error.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/vcr/errors.ts
3
+ //#region ../ai/src/vcr/errors.ts
4
4
  /**
5
5
  * Thrown when a `vcr(model, { mode: "replay" })` call finds no cassette
6
6
  * entry matching the request hash.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/errors.ts"],"sourcesContent":["import { AIError } from \"../errors/ai-error\";\nimport type { AIErrorOptions } from \"../errors/ai-error\";\n\n/**\n * Payload for {@link VcrCassetteMissError}. Carries the looked-up request\n * hash and the cassette path so a failing CI run names exactly which call\n * was not recorded.\n */\nexport type VcrCassetteMissErrorOptions = AIErrorOptions & {\n /** The normalized request hash that found no matching cassette entry. */\n requestHash?: string;\n /** Cassette file path the lookup ran against. */\n path?: string;\n};\n\n/**\n * Thrown when a `vcr(model, { mode: \"replay\" })` call finds no cassette\n * entry matching the request hash.\n *\n * **The whole point of deterministic tests.** VCR in `replay` mode never\n * falls back to a live provider call on a miss — that would silently\n * re-introduce network/non-determinism into a test that asked for the\n * opposite. Instead it throws this error so the run fails loud, telling\n * the developer to re-record the cassette (run once in `record`/`auto`).\n *\n * Extends {@link AIError} directly (not `ProviderError`) — a cassette miss\n * is a harness/config failure, not a provider failure.\n *\n * @example\n * try {\n * await vcrModel.complete(messages);\n * } catch (error) {\n * if (error instanceof VcrCassetteMissError) {\n * console.error(\"Re-record the cassette:\", error.path);\n * }\n * }\n */\nexport class VcrCassetteMissError extends AIError {\n public readonly requestHash?: string;\n public readonly path?: string;\n\n public constructor(message: string, options?: VcrCassetteMissErrorOptions) {\n super(\"VCR_CASSETTE_MISS\", message, options);\n this.name = \"VcrCassetteMissError\";\n this.requestHash = options?.requestHash;\n this.path = options?.path;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,uBAAb,cAA0C,QAAQ;CAIhD,AAAO,YAAY,SAAiB,SAAuC;EACzE,MAAM,qBAAqB,SAAS,OAAO;EAC3C,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS;EAC5B,KAAK,OAAO,SAAS;CACvB;AACF"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../../ai/src/vcr/errors.ts"],"sourcesContent":["import { AIError } from \"../errors/ai-error\";\nimport type { AIErrorOptions } from \"../errors/ai-error\";\n\n/**\n * Payload for {@link VcrCassetteMissError}. Carries the looked-up request\n * hash and the cassette path so a failing CI run names exactly which call\n * was not recorded.\n */\nexport type VcrCassetteMissErrorOptions = AIErrorOptions & {\n /** The normalized request hash that found no matching cassette entry. */\n requestHash?: string;\n /** Cassette file path the lookup ran against. */\n path?: string;\n};\n\n/**\n * Thrown when a `vcr(model, { mode: \"replay\" })` call finds no cassette\n * entry matching the request hash.\n *\n * **The whole point of deterministic tests.** VCR in `replay` mode never\n * falls back to a live provider call on a miss — that would silently\n * re-introduce network/non-determinism into a test that asked for the\n * opposite. Instead it throws this error so the run fails loud, telling\n * the developer to re-record the cassette (run once in `record`/`auto`).\n *\n * Extends {@link AIError} directly (not `ProviderError`) — a cassette miss\n * is a harness/config failure, not a provider failure.\n *\n * @example\n * try {\n * await vcrModel.complete(messages);\n * } catch (error) {\n * if (error instanceof VcrCassetteMissError) {\n * console.error(\"Re-record the cassette:\", error.path);\n * }\n * }\n */\nexport class VcrCassetteMissError extends AIError {\n public readonly requestHash?: string;\n public readonly path?: string;\n\n public constructor(message: string, options?: VcrCassetteMissErrorOptions) {\n super(\"VCR_CASSETTE_MISS\", message, options);\n this.name = \"VcrCassetteMissError\";\n this.requestHash = options?.requestHash;\n this.path = options?.path;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAa,uBAAb,cAA0C,QAAQ;CAIhD,AAAO,YAAY,SAAiB,SAAuC;EACzE,MAAM,qBAAqB,SAAS,OAAO;EAC3C,KAAK,OAAO;EACZ,KAAK,cAAc,SAAS;EAC5B,KAAK,OAAO,SAAS;CACvB;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { Message } from "../contracts/conversation-message.type.mjs";
2
2
  import { ModelCallOptions } from "../contracts/model.contract.mjs";
3
3
 
4
- //#region ../@warlock.js/ai/src/vcr/hash-request.d.ts
4
+ //#region ../ai/src/vcr/hash-request.d.ts
5
5
  /**
6
6
  * Default `ModelCallOptions` fields folded into the request hash. These are
7
7
  * the inputs that materially change the model's output; everything else
@@ -1 +1 @@
1
- {"version":3,"file":"hash-request.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/hash-request.ts"],"mappings":";;;;;;AAUA;;;;cAAa,oBAAA;AAiJb;;;;;;;;;;AAGuD;;;AAHvD,iBAAgB,WAAA,CACd,QAAA,EAAU,OAAA,IACV,OAAA,GAAU,gBAAgB,EAC1B,WAAA"}
1
+ {"version":3,"file":"hash-request.d.mts","names":[],"sources":["../../../../../../../ai/src/vcr/hash-request.ts"],"mappings":";;;;;;AAUA;;;;cAAa,oBAAA;AAiJb;;;;;;;;;;AAGuD;;;AAHvD,iBAAgB,WAAA,CACd,QAAA,EAAU,OAAA,IACV,OAAA,GAAU,gBAAgB,EAC1B,WAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/vcr/hash-request.ts
1
+ //#region ../ai/src/vcr/hash-request.ts
2
2
  /**
3
3
  * Default `ModelCallOptions` fields folded into the request hash. These are
4
4
  * the inputs that materially change the model's output; everything else
@@ -1 +1 @@
1
- {"version":3,"file":"hash-request.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/hash-request.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type { ModelCallOptions } from \"../contracts/model.contract\";\nimport type { ToolConfig } from \"../contracts/tool.contract\";\n\n/**\n * Default `ModelCallOptions` fields folded into the request hash. These are\n * the inputs that materially change the model's output; everything else\n * (notably `signal` and unknown provider keys) is excluded so an otherwise\n * identical logical call still matches its recording.\n */\nexport const DEFAULT_HASH_OPTIONS: readonly string[] = [\n \"temperature\",\n \"maxTokens\",\n \"responseSchema\",\n \"tools\",\n \"reasoning\",\n];\n\n/**\n * Reduce a tool to the parts the model actually conditions on: its name,\n * description, and the *shape* of its input schema. Two tools that differ\n * only by object identity (a fresh schema instance per import) hash\n * identically; a real contract change (renamed field, new description)\n * invalidates the recording.\n *\n * The input schema is fingerprinted structurally — a Standard Schema is an\n * opaque object, so we serialize its enumerable own keys rather than\n * attempting to read its internals.\n */\nfunction fingerprintTool(tool: ToolConfig<unknown, unknown>): unknown {\n return {\n name: tool.name,\n description: tool.description,\n input: tool.input ? schemaShape(tool.input) : undefined,\n };\n}\n\n/**\n * Produce a stable, JSON-safe fingerprint of an arbitrary schema object.\n * Records only the structural skeleton (own enumerable keys, recursively)\n * so harmless instance differences don't perturb the hash while a genuine\n * structural change does.\n */\nfunction schemaShape(value: unknown, depth = 0): unknown {\n if (depth > 6 || value === null || typeof value !== \"object\") {\n return typeof value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => schemaShape(item, depth + 1));\n }\n\n const out: Record<string, unknown> = {};\n\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n out[key] = schemaShape((value as Record<string, unknown>)[key], depth + 1);\n }\n\n return out;\n}\n\n/**\n * Pick the hashable subset of `options`, normalizing `tools` into their\n * name+description+schema-shape fingerprint. `signal` and any field not in\n * `hashOptions` are dropped.\n */\nfunction pickOptions(\n options: ModelCallOptions | undefined,\n hashOptions: readonly string[],\n): Record<string, unknown> {\n if (!options) {\n return {};\n }\n\n const picked: Record<string, unknown> = {};\n\n for (const key of hashOptions) {\n const value = options[key];\n\n if (value === undefined) {\n continue;\n }\n\n if (key === \"tools\" && Array.isArray(value)) {\n picked[key] = (value as ToolConfig<unknown, unknown>[]).map(fingerprintTool);\n continue;\n }\n\n picked[key] = value;\n }\n\n return picked;\n}\n\n/**\n * Recursively sort object keys so two logically-equal payloads serialize to\n * byte-identical JSON regardless of property insertion order.\n */\nfunction canonicalize(value: unknown): unknown {\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(canonicalize);\n }\n\n const out: Record<string, unknown> = {};\n\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n out[key] = canonicalize((value as Record<string, unknown>)[key]);\n }\n\n return out;\n}\n\n/**\n * Non-cryptographic 53-bit string hash (FNV-style, cyrb53). Deterministic\n * across runs and platforms; collision-resistant enough for a per-cassette\n * keyspace. Returned as a base-36 string.\n */\nfunction hashString(input: string): string {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n\n for (let i = 0; i < input.length; i++) {\n const ch = input.charCodeAt(i);\n\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n const combined = 4294967296 * (2097151 & h2) + (h1 >>> 0);\n\n return combined.toString(36);\n}\n\n/**\n * Compute the stable VCR request hash for a model call.\n *\n * The hash covers the full `messages` array plus the picked, normalized\n * `options` subset (see {@link DEFAULT_HASH_OPTIONS}). Inputs are\n * canonicalized (recursive key sort) before serialization so property order\n * never affects the result. `signal` and unknown provider keys are excluded.\n *\n * @example\n * const a = hashRequest(messages, { temperature: 0.2 });\n * const b = hashRequest(messages, { temperature: 0.2, signal });\n * // a === b — signal is excluded.\n */\nexport function hashRequest(\n messages: Message[],\n options?: ModelCallOptions,\n hashOptions: readonly string[] = DEFAULT_HASH_OPTIONS,\n): string {\n const payload = canonicalize({\n messages,\n options: pickOptions(options, hashOptions),\n });\n\n return hashString(JSON.stringify(payload));\n}\n"],"mappings":";;;;;;;AAUA,MAAa,uBAA0C;CACrD;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;AAaA,SAAS,gBAAgB,MAA6C;CACpE,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,OAAO,KAAK,QAAQ,YAAY,KAAK,KAAK,IAAI;CAChD;AACF;;;;;;;AAQA,SAAS,YAAY,OAAgB,QAAQ,GAAY;CACvD,IAAI,QAAQ,KAAK,UAAU,QAAQ,OAAO,UAAU,UAClD,OAAO,OAAO;CAGhB,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,SAAS,YAAY,MAAM,QAAQ,CAAC,CAAC;CAGzD,MAAM,MAA+B,CAAC;CAEtC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAgC,CAAC,CAAC,KAAK,GACnE,IAAI,OAAO,YAAa,MAAkC,MAAM,QAAQ,CAAC;CAG3E,OAAO;AACT;;;;;;AAOA,SAAS,YACP,SACA,aACyB;CACzB,IAAI,CAAC,SACH,OAAO,CAAC;CAGV,MAAM,SAAkC,CAAC;CAEzC,KAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,QAAQ,QAAQ;EAEtB,IAAI,UAAU,QACZ;EAGF,IAAI,QAAQ,WAAW,MAAM,QAAQ,KAAK,GAAG;GAC3C,OAAO,OAAQ,MAAyC,IAAI,eAAe;GAC3E;EACF;EAEA,OAAO,OAAO;CAChB;CAEA,OAAO;AACT;;;;;AAMA,SAAS,aAAa,OAAyB;CAC7C,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,YAAY;CAG/B,MAAM,MAA+B,CAAC;CAEtC,KAAK,MAAM,OAAO,OAAO,KAAK,KAAgC,CAAC,CAAC,KAAK,GACnE,IAAI,OAAO,aAAc,MAAkC,IAAI;CAGjE,OAAO;AACT;;;;;;AAOA,SAAS,WAAW,OAAuB;CACzC,IAAI,KAAK;CACT,IAAI,KAAK;CAET,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,KAAK,MAAM,WAAW,CAAC;EAE7B,KAAK,KAAK,KAAK,KAAK,IAAI,UAAU;EAClC,KAAK,KAAK,KAAK,KAAK,IAAI,UAAU;CACpC;CAEA,KAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAC3C,MAAM,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAC5C,KAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAC3C,MAAM,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAI5C,QAFiB,cAAc,UAAU,OAAO,OAAO,GAExC,CAAC,SAAS,EAAE;AAC7B;;;;;;;;;;;;;;AAeA,SAAgB,YACd,UACA,SACA,cAAiC,sBACzB;CACR,MAAM,UAAU,aAAa;EAC3B;EACA,SAAS,YAAY,SAAS,WAAW;CAC3C,CAAC;CAED,OAAO,WAAW,KAAK,UAAU,OAAO,CAAC;AAC3C"}
1
+ {"version":3,"file":"hash-request.mjs","names":[],"sources":["../../../../../../../ai/src/vcr/hash-request.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type { ModelCallOptions } from \"../contracts/model.contract\";\nimport type { ToolConfig } from \"../contracts/tool.contract\";\n\n/**\n * Default `ModelCallOptions` fields folded into the request hash. These are\n * the inputs that materially change the model's output; everything else\n * (notably `signal` and unknown provider keys) is excluded so an otherwise\n * identical logical call still matches its recording.\n */\nexport const DEFAULT_HASH_OPTIONS: readonly string[] = [\n \"temperature\",\n \"maxTokens\",\n \"responseSchema\",\n \"tools\",\n \"reasoning\",\n];\n\n/**\n * Reduce a tool to the parts the model actually conditions on: its name,\n * description, and the *shape* of its input schema. Two tools that differ\n * only by object identity (a fresh schema instance per import) hash\n * identically; a real contract change (renamed field, new description)\n * invalidates the recording.\n *\n * The input schema is fingerprinted structurally — a Standard Schema is an\n * opaque object, so we serialize its enumerable own keys rather than\n * attempting to read its internals.\n */\nfunction fingerprintTool(tool: ToolConfig<unknown, unknown>): unknown {\n return {\n name: tool.name,\n description: tool.description,\n input: tool.input ? schemaShape(tool.input) : undefined,\n };\n}\n\n/**\n * Produce a stable, JSON-safe fingerprint of an arbitrary schema object.\n * Records only the structural skeleton (own enumerable keys, recursively)\n * so harmless instance differences don't perturb the hash while a genuine\n * structural change does.\n */\nfunction schemaShape(value: unknown, depth = 0): unknown {\n if (depth > 6 || value === null || typeof value !== \"object\") {\n return typeof value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => schemaShape(item, depth + 1));\n }\n\n const out: Record<string, unknown> = {};\n\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n out[key] = schemaShape((value as Record<string, unknown>)[key], depth + 1);\n }\n\n return out;\n}\n\n/**\n * Pick the hashable subset of `options`, normalizing `tools` into their\n * name+description+schema-shape fingerprint. `signal` and any field not in\n * `hashOptions` are dropped.\n */\nfunction pickOptions(\n options: ModelCallOptions | undefined,\n hashOptions: readonly string[],\n): Record<string, unknown> {\n if (!options) {\n return {};\n }\n\n const picked: Record<string, unknown> = {};\n\n for (const key of hashOptions) {\n const value = options[key];\n\n if (value === undefined) {\n continue;\n }\n\n if (key === \"tools\" && Array.isArray(value)) {\n picked[key] = (value as ToolConfig<unknown, unknown>[]).map(fingerprintTool);\n continue;\n }\n\n picked[key] = value;\n }\n\n return picked;\n}\n\n/**\n * Recursively sort object keys so two logically-equal payloads serialize to\n * byte-identical JSON regardless of property insertion order.\n */\nfunction canonicalize(value: unknown): unknown {\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map(canonicalize);\n }\n\n const out: Record<string, unknown> = {};\n\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n out[key] = canonicalize((value as Record<string, unknown>)[key]);\n }\n\n return out;\n}\n\n/**\n * Non-cryptographic 53-bit string hash (FNV-style, cyrb53). Deterministic\n * across runs and platforms; collision-resistant enough for a per-cassette\n * keyspace. Returned as a base-36 string.\n */\nfunction hashString(input: string): string {\n let h1 = 0xdeadbeef;\n let h2 = 0x41c6ce57;\n\n for (let i = 0; i < input.length; i++) {\n const ch = input.charCodeAt(i);\n\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n const combined = 4294967296 * (2097151 & h2) + (h1 >>> 0);\n\n return combined.toString(36);\n}\n\n/**\n * Compute the stable VCR request hash for a model call.\n *\n * The hash covers the full `messages` array plus the picked, normalized\n * `options` subset (see {@link DEFAULT_HASH_OPTIONS}). Inputs are\n * canonicalized (recursive key sort) before serialization so property order\n * never affects the result. `signal` and unknown provider keys are excluded.\n *\n * @example\n * const a = hashRequest(messages, { temperature: 0.2 });\n * const b = hashRequest(messages, { temperature: 0.2, signal });\n * // a === b — signal is excluded.\n */\nexport function hashRequest(\n messages: Message[],\n options?: ModelCallOptions,\n hashOptions: readonly string[] = DEFAULT_HASH_OPTIONS,\n): string {\n const payload = canonicalize({\n messages,\n options: pickOptions(options, hashOptions),\n });\n\n return hashString(JSON.stringify(payload));\n}\n"],"mappings":";;;;;;;AAUA,MAAa,uBAA0C;CACrD;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;AAaA,SAAS,gBAAgB,MAA6C;CACpE,OAAO;EACL,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,OAAO,KAAK,QAAQ,YAAY,KAAK,KAAK,IAAI;CAChD;AACF;;;;;;;AAQA,SAAS,YAAY,OAAgB,QAAQ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AC3C,MAAM,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAC5C,KAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAC3C,MAAM,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;CAI5C,QAFiB,cAAc,UAAU,OAAO,OAAO,GAExC,CAAC,SAAS,EAAE;AAC7B;;;;;;;;;;;;;;AAeA,SAAgB,YACd,UACA,SACA,cAAiC,sBACzB;CACR,MAAM,UAAU,aAAa;EAC3B;EACA,SAAS,YAAY,SAAS,WAAW;CAC3C,CAAC;CAED,OAAO,WAAW,KAAK,UAAU,OAAO,CAAC;AAC3C"}
package/esm/vcr/vcr.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ModelContract } from "../contracts/model.contract.mjs";
2
2
  import { VcrModel, VcrOptions } from "./vcr.type.mjs";
3
3
 
4
- //#region ../@warlock.js/ai/src/vcr/vcr.d.ts
4
+ //#region ../ai/src/vcr/vcr.d.ts
5
5
  /**
6
6
  * Wrap any `ModelContract` in a record/replay decorator backed by a JSON
7
7
  * cassette on disk.
@@ -1 +1 @@
1
- {"version":3,"file":"vcr.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/vcr.ts"],"mappings":";;;;;;AA8UA;;;;;;;;;;;;;;AAAwE;;;;;;;;iBAAxD,GAAA,CAAI,KAAA,EAAO,aAAA,EAAe,OAAA,EAAS,UAAA,GAAa,QAAA"}
1
+ {"version":3,"file":"vcr.d.mts","names":[],"sources":["../../../../../../../ai/src/vcr/vcr.ts"],"mappings":";;;;;;AA8UA;;;;;;;;;;;;;;AAAwE;;;;;;;;iBAAxD,GAAA,CAAI,KAAA,EAAO,aAAA,EAAe,OAAA,EAAS,UAAA,GAAa,QAAA"}
package/esm/vcr/vcr.mjs CHANGED
@@ -3,7 +3,7 @@ import { emptyCassette, loadCassette, saveCassette } from "./cassette-io.mjs";
3
3
  import { VcrCassetteMissError } from "./errors.mjs";
4
4
  import { DEFAULT_HASH_OPTIONS, hashRequest } from "./hash-request.mjs";
5
5
 
6
- //#region ../@warlock.js/ai/src/vcr/vcr.ts
6
+ //#region ../ai/src/vcr/vcr.ts
7
7
  /**
8
8
  * Internal decorator that wraps an inner `ModelContract`, intercepting only
9
9
  * `complete()`/`stream()` and delegating every identity getter to the inner
@@ -1 +1 @@
1
- {"version":3,"file":"vcr.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/vcr.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type {\n ModelCallOptions,\n ModelCapabilities,\n ModelContract,\n ModelResponse,\n ModelStreamChunk,\n} from \"../contracts/model.contract\";\nimport type { ModelPricing } from \"../contracts/result/model-pricing.type\";\nimport { redact } from \"../security/redact\";\nimport { emptyCassette, loadCassette, saveCassette } from \"./cassette-io\";\nimport { VcrCassetteMissError } from \"./errors\";\nimport { DEFAULT_HASH_OPTIONS, hashRequest } from \"./hash-request\";\nimport type { Cassette, CassetteEntry, VcrMode, VcrModel, VcrOptions } from \"./vcr.type\";\n\n/**\n * Internal decorator that wraps an inner `ModelContract`, intercepting only\n * `complete()`/`stream()` and delegating every identity getter to the inner\n * model. Drives the record/replay state machine over a single in-memory\n * {@link Cassette}.\n *\n * **Why a class.** It holds mutable per-instance state (the loaded cassette,\n * the dirty flag, the load promise) behind a stable `ModelContract` surface;\n * the public API is the `vcr()` factory, never `new`.\n */\nclass Vcr implements VcrModel {\n private readonly mode: VcrMode;\n private readonly path: string;\n private readonly hashOptions: readonly string[];\n\n /** Loaded + newly recorded entries. Mutated in place as we record. */\n private loadedCassette: Cassette;\n\n /** Set when an entry is recorded so `save()` knows there's work to flush. */\n private dirty = false;\n\n /** One-shot lazy load of the on-disk cassette, shared across calls. */\n private loadPromise: Promise<void> | undefined;\n\n /** Persisted-body privacy controls (S2). */\n private readonly recordRequest: NonNullable<VcrOptions[\"recordRequest\"]>;\n private readonly redactRequestHook: VcrOptions[\"redactRequest\"];\n private readonly redactResponseHook: VcrOptions[\"redactResponse\"];\n private readonly redactErrorHook: VcrOptions[\"redactError\"];\n\n /** Verbatim-recording warning fires at most once per instance. */\n private warnedVerbatim = false;\n\n public constructor(\n private readonly inner: ModelContract,\n options: VcrOptions,\n ) {\n this.path = options.path;\n this.mode = options.mode ?? \"auto\";\n this.hashOptions = options.hashOptions ?? DEFAULT_HASH_OPTIONS;\n this.recordRequest = options.recordRequest ?? \"verbatim\";\n this.redactRequestHook = options.redactRequest;\n this.redactResponseHook = options.redactResponse;\n this.redactErrorHook = options.redactError;\n this.loadedCassette = emptyCassette(inner.name, inner.provider);\n }\n\n /** Inner model identifier — delegated verbatim. */\n public get name(): string {\n return this.inner.name;\n }\n\n /** Inner provider — delegated verbatim. */\n public get provider(): string {\n return this.inner.provider;\n }\n\n /** Inner capability flags — delegated verbatim. */\n public get capabilities(): ModelCapabilities | undefined {\n return this.inner.capabilities;\n }\n\n /** Inner pricing — delegated verbatim so cost accounting is unchanged. */\n public get pricing(): ModelPricing | undefined {\n return this.inner.pricing;\n }\n\n /** Loaded/recorded cassette, exposed for assertions. */\n public get cassette(): Cassette {\n return this.loadedCassette;\n }\n\n /**\n * Load the on-disk cassette exactly once. Pure `record` mode skips the\n * read — it always writes fresh — but the in-memory cassette still starts\n * empty so a record run never accidentally replays a stale entry.\n */\n private async ensureLoaded(): Promise<void> {\n if (this.loadPromise) {\n return this.loadPromise;\n }\n\n this.loadPromise =\n this.mode === \"record\"\n ? Promise.resolve()\n : (async () => {\n this.loadedCassette = await loadCassette(\n this.path,\n this.inner.name,\n this.inner.provider,\n );\n })();\n\n return this.loadPromise;\n }\n\n /** Find a recorded entry whose hash matches the current request. */\n private findEntry(hash: string): CassetteEntry | undefined {\n return this.loadedCassette.entries.find((entry) => entry.requestHash === hash);\n }\n\n /** Re-throw a recorded error by reconstructing a plain `Error`. */\n private throwRecordedError(entry: CassetteEntry): never {\n const error = new Error(entry.error?.message ?? \"Recorded error\");\n\n error.name = entry.error?.name ?? \"Error\";\n\n throw error;\n }\n\n /**\n * Non-streaming call. In `replay` a miss throws; in `auto`/`record` a miss\n * calls the inner model and records the outcome (response or error).\n */\n public async complete(messages: Message[], options?: ModelCallOptions): Promise<ModelResponse> {\n await this.ensureLoaded();\n\n const hash = hashRequest(messages, options, this.hashOptions);\n\n if (this.mode !== \"record\") {\n const entry = this.findEntry(hash);\n\n if (entry) {\n if (entry.error) {\n this.throwRecordedError(entry);\n }\n\n if (entry.response) {\n return entry.response;\n }\n }\n\n if (this.mode === \"replay\") {\n throw new VcrCassetteMissError(\n `No cassette entry for this request (model \"${this.inner.name}\", hash ${hash}).`,\n { requestHash: hash, path: this.path },\n );\n }\n }\n\n try {\n const response = await this.inner.complete(messages, options);\n\n this.record({ requestHash: hash, request: { messages, options }, response });\n\n return response;\n } catch (error) {\n this.record({\n requestHash: hash,\n request: { messages, options },\n error: { name: (error as Error).name, message: (error as Error).message },\n });\n\n throw error;\n }\n }\n\n /**\n * Streaming call. On replay the stored `chunks` are re-yielded in order\n * (reproducing the `delta`/`tool-call`/`done` sequence) or the stored\n * error is re-thrown. On record the inner stream is buffered into\n * `chunks[]` while being re-emitted, then recorded once exhausted.\n */\n public async *stream(\n messages: Message[],\n options?: ModelCallOptions,\n ): AsyncIterable<ModelStreamChunk> {\n await this.ensureLoaded();\n\n const hash = hashRequest(messages, options, this.hashOptions);\n\n if (this.mode !== \"record\") {\n const entry = this.findEntry(hash);\n\n if (entry) {\n if (entry.error) {\n this.throwRecordedError(entry);\n }\n\n if (entry.chunks) {\n for (const chunk of entry.chunks) {\n yield chunk;\n }\n\n return;\n }\n }\n\n if (this.mode === \"replay\") {\n throw new VcrCassetteMissError(\n `No cassette entry for this request (model \"${this.inner.name}\", hash ${hash}).`,\n { requestHash: hash, path: this.path },\n );\n }\n }\n\n const chunks: ModelStreamChunk[] = [];\n\n try {\n for await (const chunk of this.inner.stream(messages, options)) {\n chunks.push(chunk);\n\n yield chunk;\n }\n } catch (error) {\n this.record({\n requestHash: hash,\n request: { messages, options },\n error: { name: (error as Error).name, message: (error as Error).message },\n });\n\n throw error;\n }\n\n this.record({ requestHash: hash, request: { messages, options }, chunks });\n }\n\n /**\n * Append an entry to the in-memory cassette and mark it dirty, applying\n * the configured request/response/error redaction first (S2). Pure\n * `replay` never reaches this path, so no replay run is ever dirtied.\n */\n private record(entry: CassetteEntry): void {\n this.loadedCassette.entries.push(this.applyRedaction(entry));\n this.dirty = true;\n this.maybeWarnVerbatim();\n }\n\n /**\n * Apply the persisted-body privacy controls to an entry before it is\n * stored. The request body follows `recordRequest`; response/error\n * redactors are applied only when supplied. Replay matching is by the\n * recomputed hash (kept verbatim), so none of this affects replay.\n */\n private applyRedaction(entry: CassetteEntry): CassetteEntry {\n const out: CassetteEntry = {\n requestHash: entry.requestHash,\n request: entry.request,\n };\n\n if (this.recordRequest === \"hash-only\") {\n out.request = { messages: [] };\n } else if (this.recordRequest === \"redacted\") {\n out.request = this.redactRequestHook\n ? this.redactRequestHook(entry.request)\n : redact(entry.request);\n }\n\n if (entry.response) {\n out.response = this.redactResponseHook\n ? this.redactResponseHook(entry.response)\n : entry.response;\n }\n if (entry.chunks) {\n out.chunks = entry.chunks;\n }\n if (entry.error) {\n out.error = this.redactErrorHook\n ? this.redactErrorHook(entry.error)\n : entry.error;\n }\n\n return out;\n }\n\n /**\n * Warn once (outside tests) when the cassette is recording verbatim\n * request bodies — they may carry prompts, tool args, and PII, so the\n * file is not safe to commit until sanitized.\n */\n private maybeWarnVerbatim(): void {\n if (this.warnedVerbatim || this.recordRequest !== \"verbatim\") return;\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") return;\n\n this.warnedVerbatim = true;\n console.warn(\n `[warlock-ai] VCR is recording verbatim request bodies to \"${this.path}\" — prompts, tool args, and any PII are stored unredacted. ` +\n 'Sanitize before committing, or set recordRequest: \"redacted\" | \"hash-only\".',\n );\n }\n\n /**\n * Flush newly recorded entries to `path`. No-op when nothing was recorded\n * (pure replay, or a record/auto run that only ever hit cached entries).\n */\n public async save(): Promise<void> {\n if (!this.dirty) {\n return;\n }\n\n await saveCassette(this.path, this.loadedCassette);\n this.dirty = false;\n }\n}\n\n/**\n * Wrap any `ModelContract` in a record/replay decorator backed by a JSON\n * cassette on disk.\n *\n * **What it does.** Intercepts only `complete()`/`stream()` — the single\n * seam every agent trip funnels through — and delegates `name`, `provider`,\n * `capabilities`, and `pricing` to the inner model untouched. On a call it\n * computes a stable hash over `{ messages, picked options }` and, depending\n * on `mode`:\n *\n * - **`record`** — always calls the inner model and appends a cassette entry.\n * - **`replay`** — returns the matching entry (or re-yields its chunks /\n * re-throws its error); a miss throws `VcrCassetteMissError`, never a live\n * call.\n * - **`auto`** (default) — replays a hit, records a miss.\n *\n * Composes *below* `fallbackModel` and works with any adapter because it\n * depends only on `ModelContract`. Call `save()` to flush new entries.\n *\n * @example\n * const model = vcr(liveModel, { path: \"./cassettes/support.json\" });\n * const response = await model.complete(messages);\n * await model.save(); // first run records; later runs replay deterministically.\n */\nexport function vcr(model: ModelContract, options: VcrOptions): VcrModel {\n return new Vcr(model, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,IAAM,MAAN,MAA8B;CAuB5B,AAAO,YACL,AAAiB,OACjB,SACA;EAFiB;eAfH;wBAYS;EAMvB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO,QAAQ,QAAQ;EAC5B,KAAK,cAAc,QAAQ,eAAe;EAC1C,KAAK,gBAAgB,QAAQ,iBAAiB;EAC9C,KAAK,oBAAoB,QAAQ;EACjC,KAAK,qBAAqB,QAAQ;EAClC,KAAK,kBAAkB,QAAQ;EAC/B,KAAK,iBAAiB,cAAc,MAAM,MAAM,MAAM,QAAQ;CAChE;;CAGA,IAAW,OAAe;EACxB,OAAO,KAAK,MAAM;CACpB;;CAGA,IAAW,WAAmB;EAC5B,OAAO,KAAK,MAAM;CACpB;;CAGA,IAAW,eAA8C;EACvD,OAAO,KAAK,MAAM;CACpB;;CAGA,IAAW,UAAoC;EAC7C,OAAO,KAAK,M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AkB,YAChC,IAAI,UAAU,KAAK,oBACf,KAAK,kBAAkB,MAAM,OAAO,IACpC,OAAO,MAAM,OAAO;EAG1B,IAAI,MAAM,UACR,IAAI,WAAW,KAAK,qBAChB,KAAK,mBAAmB,MAAM,QAAQ,IACtC,MAAM;EAEZ,IAAI,MAAM,QACR,IAAI,SAAS,MAAM;EAErB,IAAI,MAAM,OACR,IAAI,QAAQ,KAAK,kBACb,KAAK,gBAAgB,MAAM,KAAK,IAChC,MAAM;EAGZ,OAAO;CACT;;;;;;CAOA,AAAQ,oBAA0B;EAChC,IAAI,KAAK,kBAAkB,KAAK,kBAAkB,YAAY;EAC9D,IAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,QAAQ;EAE3D,KAAK,iBAAiB;EACtB,QAAQ,KACN,6DAA6D,KAAK,KAAK,uIAEzE;CACF;;;;;CAMA,MAAa,OAAsB;EACjC,IAAI,CAAC,KAAK,OACR;EAGF,MAAM,aAAa,KAAK,MAAM,KAAK,cAAc;EACjD,KAAK,QAAQ;CACf;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,IAAI,OAAsB,SAA+B;CACvE,OAAO,IAAI,IAAI,OAAO,OAAO;AAC/B"}
1
+ {"version":3,"file":"vcr.mjs","names":[],"sources":["../../../../../../../ai/src/vcr/vcr.ts"],"sourcesContent":["import type { Message } from \"../contracts/conversation-message.type\";\nimport type {\n ModelCallOptions,\n ModelCapabilities,\n ModelContract,\n ModelResponse,\n ModelStreamChunk,\n} from \"../contracts/model.contract\";\nimport type { ModelPricing } from \"../contracts/result/model-pricing.type\";\nimport { redact } from \"../security/redact\";\nimport { emptyCassette, loadCassette, saveCassette } from \"./cassette-io\";\nimport { VcrCassetteMissError } from \"./errors\";\nimport { DEFAULT_HASH_OPTIONS, hashRequest } from \"./hash-request\";\nimport type { Cassette, CassetteEntry, VcrMode, VcrModel, VcrOptions } from \"./vcr.type\";\n\n/**\n * Internal decorator that wraps an inner `ModelContract`, intercepting only\n * `complete()`/`stream()` and delegating every identity getter to the inner\n * model. Drives the record/replay state machine over a single in-memory\n * {@link Cassette}.\n *\n * **Why a class.** It holds mutable per-instance state (the loaded cassette,\n * the dirty flag, the load promise) behind a stable `ModelContract` surface;\n * the public API is the `vcr()` factory, never `new`.\n */\nclass Vcr implements VcrModel {\n private readonly mode: VcrMode;\n private readonly path: string;\n private readonly hashOptions: readonly string[];\n\n /** Loaded + newly recorded entries. Mutated in place as we record. */\n private loadedCassette: Cassette;\n\n /** Set when an entry is recorded so `save()` knows there's work to flush. */\n private dirty = false;\n\n /** One-shot lazy load of the on-disk cassette, shared across calls. */\n private loadPromise: Promise<void> | undefined;\n\n /** Persisted-body privacy controls (S2). */\n private readonly recordRequest: NonNullable<VcrOptions[\"recordRequest\"]>;\n private readonly redactRequestHook: VcrOptions[\"redactRequest\"];\n private readonly redactResponseHook: VcrOptions[\"redactResponse\"];\n private readonly redactErrorHook: VcrOptions[\"redactError\"];\n\n /** Verbatim-recording warning fires at most once per instance. */\n private warnedVerbatim = false;\n\n public constructor(\n private readonly inner: ModelContract,\n options: VcrOptions,\n ) {\n this.path = options.path;\n this.mode = options.mode ?? \"auto\";\n this.hashOptions = options.hashOptions ?? DEFAULT_HASH_OPTIONS;\n this.recordRequest = options.recordRequest ?? \"verbatim\";\n this.redactRequestHook = options.redactRequest;\n this.redactResponseHook = options.redactResponse;\n this.redactErrorHook = options.redactError;\n this.loadedCassette = emptyCassette(inner.name, inner.provider);\n }\n\n /** Inner model identifier — delegated verbatim. */\n public get name(): string {\n return this.inner.name;\n }\n\n /** Inner provider — delegated verbatim. */\n public get provider(): string {\n return this.inner.provider;\n }\n\n /** Inner capability flags — delegated verbatim. */\n public get capabilities(): ModelCapabilities | undefined {\n return this.inner.capabilities;\n }\n\n /** Inner pricing — delegated verbatim so cost accounting is unchanged. */\n public get pricing(): ModelPricing | undefined {\n return this.inner.pricing;\n }\n\n /** Loaded/recorded cassette, exposed for assertions. */\n public get cassette(): Cassette {\n return this.loadedCassette;\n }\n\n /**\n * Load the on-disk cassette exactly once. Pure `record` mode skips the\n * read — it always writes fresh — but the in-memory cassette still starts\n * empty so a record run never accidentally replays a stale entry.\n */\n private async ensureLoaded(): Promise<void> {\n if (this.loadPromise) {\n return this.loadPromise;\n }\n\n this.loadPromise =\n this.mode === \"record\"\n ? Promise.resolve()\n : (async () => {\n this.loadedCassette = await loadCassette(\n this.path,\n this.inner.name,\n this.inner.provider,\n );\n })();\n\n return this.loadPromise;\n }\n\n /** Find a recorded entry whose hash matches the current request. */\n private findEntry(hash: string): CassetteEntry | undefined {\n return this.loadedCassette.entries.find((entry) => entry.requestHash === hash);\n }\n\n /** Re-throw a recorded error by reconstructing a plain `Error`. */\n private throwRecordedError(entry: CassetteEntry): never {\n const error = new Error(entry.error?.message ?? \"Recorded error\");\n\n error.name = entry.error?.name ?? \"Error\";\n\n throw error;\n }\n\n /**\n * Non-streaming call. In `replay` a miss throws; in `auto`/`record` a miss\n * calls the inner model and records the outcome (response or error).\n */\n public async complete(messages: Message[], options?: ModelCallOptions): Promise<ModelResponse> {\n await this.ensureLoaded();\n\n const hash = hashRequest(messages, options, this.hashOptions);\n\n if (this.mode !== \"record\") {\n const entry = this.findEntry(hash);\n\n if (entry) {\n if (entry.error) {\n this.throwRecordedError(entry);\n }\n\n if (entry.response) {\n return entry.response;\n }\n }\n\n if (this.mode === \"replay\") {\n throw new VcrCassetteMissError(\n `No cassette entry for this request (model \"${this.inner.name}\", hash ${hash}).`,\n { requestHash: hash, path: this.path },\n );\n }\n }\n\n try {\n const response = await this.inner.complete(messages, options);\n\n this.record({ requestHash: hash, request: { messages, options }, response });\n\n return response;\n } catch (error) {\n this.record({\n requestHash: hash,\n request: { messages, options },\n error: { name: (error as Error).name, message: (error as Error).message },\n });\n\n throw error;\n }\n }\n\n /**\n * Streaming call. On replay the stored `chunks` are re-yielded in order\n * (reproducing the `delta`/`tool-call`/`done` sequence) or the stored\n * error is re-thrown. On record the inner stream is buffered into\n * `chunks[]` while being re-emitted, then recorded once exhausted.\n */\n public async *stream(\n messages: Message[],\n options?: ModelCallOptions,\n ): AsyncIterable<ModelStreamChunk> {\n await this.ensureLoaded();\n\n const hash = hashRequest(messages, options, this.hashOptions);\n\n if (this.mode !== \"record\") {\n const entry = this.findEntry(hash);\n\n if (entry) {\n if (entry.error) {\n this.throwRecordedError(entry);\n }\n\n if (entry.chunks) {\n for (const chunk of entry.chunks) {\n yield chunk;\n }\n\n return;\n }\n }\n\n if (this.mode === \"replay\") {\n throw new VcrCassetteMissError(\n `No cassette entry for this request (model \"${this.inner.name}\", hash ${hash}).`,\n { requestHash: hash, path: this.path },\n );\n }\n }\n\n const chunks: ModelStreamChunk[] = [];\n\n try {\n for await (const chunk of this.inner.stream(messages, options)) {\n chunks.push(chunk);\n\n yield chunk;\n }\n } catch (error) {\n this.record({\n requestHash: hash,\n request: { messages, options },\n error: { name: (error as Error).name, message: (error as Error).message },\n });\n\n throw error;\n }\n\n this.record({ requestHash: hash, request: { messages, options }, chunks });\n }\n\n /**\n * Append an entry to the in-memory cassette and mark it dirty, applying\n * the configured request/response/error redaction first (S2). Pure\n * `replay` never reaches this path, so no replay run is ever dirtied.\n */\n private record(entry: CassetteEntry): void {\n this.loadedCassette.entries.push(this.applyRedaction(entry));\n this.dirty = true;\n this.maybeWarnVerbatim();\n }\n\n /**\n * Apply the persisted-body privacy controls to an entry before it is\n * stored. The request body follows `recordRequest`; response/error\n * redactors are applied only when supplied. Replay matching is by the\n * recomputed hash (kept verbatim), so none of this affects replay.\n */\n private applyRedaction(entry: CassetteEntry): CassetteEntry {\n const out: CassetteEntry = {\n requestHash: entry.requestHash,\n request: entry.request,\n };\n\n if (this.recordRequest === \"hash-only\") {\n out.request = { messages: [] };\n } else if (this.recordRequest === \"redacted\") {\n out.request = this.redactRequestHook\n ? this.redactRequestHook(entry.request)\n : redact(entry.request);\n }\n\n if (entry.response) {\n out.response = this.redactResponseHook\n ? this.redactResponseHook(entry.response)\n : entry.response;\n }\n if (entry.chunks) {\n out.chunks = entry.chunks;\n }\n if (entry.error) {\n out.error = this.redactErrorHook\n ? this.redactErrorHook(entry.error)\n : entry.error;\n }\n\n return out;\n }\n\n /**\n * Warn once (outside tests) when the cassette is recording verbatim\n * request bodies — they may carry prompts, tool args, and PII, so the\n * file is not safe to commit until sanitized.\n */\n private maybeWarnVerbatim(): void {\n if (this.warnedVerbatim || this.recordRequest !== \"verbatim\") return;\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") return;\n\n this.warnedVerbatim = true;\n console.warn(\n `[warlock-ai] VCR is recording verbatim request bodies to \"${this.path}\" — prompts, tool args, and any PII are stored unredacted. ` +\n 'Sanitize before committing, or set recordRequest: \"redacted\" | \"hash-only\".',\n );\n }\n\n /**\n * Flush newly recorded entries to `path`. No-op when nothing was recorded\n * (pure replay, or a record/auto run that only ever hit cached entries).\n */\n public async save(): Promise<void> {\n if (!this.dirty) {\n return;\n }\n\n await saveCassette(this.path, this.loadedCassette);\n this.dirty = false;\n }\n}\n\n/**\n * Wrap any `ModelContract` in a record/replay decorator backed by a JSON\n * cassette on disk.\n *\n * **What it does.** Intercepts only `complete()`/`stream()` — the single\n * seam every agent trip funnels through — and delegates `name`, `provider`,\n * `capabilities`, and `pricing` to the inner model untouched. On a call it\n * computes a stable hash over `{ messages, picked options }` and, depending\n * on `mode`:\n *\n * - **`record`** — always calls the inner model and appends a cassette entry.\n * - **`replay`** — returns the matching entry (or re-yields its chunks /\n * re-throws its error); a miss throws `VcrCassetteMissError`, never a live\n * call.\n * - **`auto`** (default) — replays a hit, records a miss.\n *\n * Composes *below* `fallbackModel` and works with any adapter because it\n * depends only on `ModelContract`. Call `save()` to flush new entries.\n *\n * @example\n * const model = vcr(liveModel, { path: \"./cassettes/support.json\" });\n * const response = await model.complete(messages);\n * await model.save(); // first run records; later runs replay deterministically.\n */\nexport function vcr(model: ModelContract, options: VcrOptions): VcrModel {\n return new Vcr(model, options);\n}\n"],"mappings":";;;;;;;;;;;;;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;AA0BA,SAAgB,IAAI,OAAsB,SAA+B;CACvE,OAAO,IAAI,IAAI,OAAO,OAAO;AAC/B"}
@@ -1,7 +1,7 @@
1
1
  import { Message } from "../contracts/conversation-message.type.mjs";
2
2
  import { ModelCallOptions, ModelContract, ModelResponse, ModelStreamChunk } from "../contracts/model.contract.mjs";
3
3
 
4
- //#region ../@warlock.js/ai/src/vcr/vcr.type.d.ts
4
+ //#region ../ai/src/vcr/vcr.type.d.ts
5
5
  /**
6
6
  * Record/replay mode for a {@link VcrModel}.
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"vcr.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/vcr/vcr.type.ts"],"mappings":";;;;;;AAmBA;;;;AAAmB;AASnB;;;;KATY,OAAA;;;;;;;;KASA,aAAA;EASR,yEAPF,WAAA;EAUA;;;;EALA,OAAA;IACE,QAAA,EAAU,OAAA;IACV,OAAA,GAAU,gBAAA;EAAA,GASH;EANT,QAAA,GAAW,aAAA,EAcO;EAZlB,MAAA,GAAS,gBAAA,IAoBa;EAlBtB,KAAA;IACE,IAAA;IACA,OAAA;EAAA;AAAA;;AAgBoB;AAMxB;;KAdY,QAAA;EAkBH,sEAhBP,OAAA,KAgDY;EA9CZ,KAAA,UA+CuC;EA7CvC,QAAA,UAmD8C;EAjD9C,OAAA,EAAS,aAAa;AAAA;;;;KAMZ,UAAA;EA4BV,yEA1BA,IAAA,UAiCE;EA/BF,IAAA,GAAO,OAAA;EAgCL;;;;;;;EAxBF,WAAA;EA+B4B;;;;;;;;;;AAInB;AASX;;;;EA5BE,aAAA;EAgCmB;;;;;EA1BnB,aAAA,IAAiB,OAAA;IACf,QAAA,EAAU,OAAA;IACV,OAAA,GAAU,gBAAA;EAAA;IACJ,QAAA,EAAU,OAAA;IAAW,OAAA,GAAU,gBAAA;EAAA;;;;;;EAMvC,cAAA,IAAkB,QAAA,EAAU,aAAA,KAAkB,aAAA;EAE9C,WAAA,IAAe,KAAA;IAAS,IAAA;IAAc,OAAA;EAAA;IACpC,IAAA;IACA,OAAA;EAAA;AAAA;;;;;;KASQ,QAAA,GAAW,aAAA;sEAErB,IAAA,IAAQ,OAAA;WAEC,QAAA,EAAU,QAAA;AAAA"}
1
+ {"version":3,"file":"vcr.type.d.mts","names":[],"sources":["../../../../../../../ai/src/vcr/vcr.type.ts"],"mappings":";;;;;;AAmBA;;;;AAAmB;AASnB;;;;KATY,OAAA;;;;;;;;KASA,aAAA;EASR,yEAPF,WAAA;EAUA;;;;EALA,OAAA;IACE,QAAA,EAAU,OAAA;IACV,OAAA,GAAU,gBAAA;EAAA,GASH;EANT,QAAA,GAAW,aAAA,EAcO;EAZlB,MAAA,GAAS,gBAAA,IAoBa;EAlBtB,KAAA;IACE,IAAA;IACA,OAAA;EAAA;AAAA;;AAgBoB;AAMxB;;KAdY,QAAA;EAkBH,sEAhBP,OAAA,KAgDY;EA9CZ,KAAA,UA+CuC;EA7CvC,QAAA,UAmD8C;EAjD9C,OAAA,EAAS,aAAa;AAAA;;;;KAMZ,UAAA;EA4BV,yEA1BA,IAAA,UAiCE;EA/BF,IAAA,GAAO,OAAA;EAgCL;;;;;;;EAxBF,WAAA;EA+B4B;;;;;;;;;;AAInB;AASX;;;;EA5BE,aAAA;EAgCmB;;;;;EA1BnB,aAAA,IAAiB,OAAA;IACf,QAAA,EAAU,OAAA;IACV,OAAA,GAAU,gBAAA;EAAA;IACJ,QAAA,EAAU,OAAA;IAAW,OAAA,GAAU,gBAAA;EAAA;;;;;;EAMvC,cAAA,IAAkB,QAAA,EAAU,aAAA,KAAkB,aAAA;EAE9C,WAAA,IAAe,KAAA;IAAS,IAAA;IAAc,OAAA;EAAA;IACpC,IAAA;IACA,OAAA;EAAA;AAAA;;;;;;KASQ,QAAA,GAAW,aAAA;sEAErB,IAAA,IAAQ,OAAA;WAEC,QAAA,EAAU,QAAA;AAAA"}
@@ -2,7 +2,7 @@ import { WorkflowError } from "../errors/workflow-error.mjs";
2
2
  import "../errors/index.mjs";
3
3
  import { compositeAsTool } from "../tool/tool.mjs";
4
4
 
5
- //#region ../@warlock.js/ai/src/workflow/as-tool.ts
5
+ //#region ../ai/src/workflow/as-tool.ts
6
6
  /**
7
7
  * Wrap a `WorkflowInstance` as a `ToolContract` so an agent can invoke
8
8
  * it inside its tool-call loop. Closes the agent-calls-workflow
@@ -1 +1 @@
1
- {"version":3,"file":"as-tool.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/workflow/as-tool.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { WorkflowInstance } from \"../contracts/workflow/workflow.contract\";\nimport { WorkflowError } from \"../errors\";\nimport { compositeAsTool, type ToolContract } from \"../tool/tool\";\n\n/**\n * Wrap a `WorkflowInstance` as a `ToolContract` so an agent can invoke\n * it inside its tool-call loop. Closes the agent-calls-workflow\n * composition gap.\n *\n * Behavior:\n * - Tool `name` mirrors `workflow.name` — workflows without a name throw\n * `WorkflowError` at wrap time (the agent surface needs a stable id).\n * - Tool `input` is the supplied `inputSchema`; the validated value is\n * forwarded straight to `workflow.execute(input)`.\n * - On `result.error`, the workflow error is wrapped in\n * `ToolExecutionError` with `cause` set to the original\n * `WorkflowError` subclass — the agent's tool-call loop sees a\n * uniform error class regardless of which primitive failed.\n *\n * @example\n * const wf = workflow({ name: \"triage\", steps: [...] });\n * const triageTool = asTool(wf, {\n * description: \"Run the support-ticket triage flow\",\n * inputSchema: ticketSchema,\n * });\n * const a = ai.agent({ model, tools: [triageTool] });\n */\nexport function asTool<TInput, TOutput, TToolInput = TInput>(\n workflowInstance: WorkflowInstance<TInput, TOutput>,\n options: {\n description?: string;\n inputSchema: StandardSchemaV1<TToolInput>;\n },\n): ToolContract<TToolInput, TOutput> {\n if (!workflowInstance.name || typeof workflowInstance.name !== \"string\") {\n throw new WorkflowError(\n \"workflow.asTool(): workflow must have a `name` to be wrapped as a tool\",\n );\n }\n\n return compositeAsTool<TToolInput, TOutput>({\n name: workflowInstance.name,\n description: options.description ?? `Invoke workflow \"${workflowInstance.name}\" as a tool.`,\n input: options.inputSchema,\n execute: async (input, ctx) => {\n // Relay the outer agent's cancellation signal so cancelling the\n // parent aborts this nested workflow run (C2).\n const result = await workflowInstance.execute(\n input as unknown as TInput,\n ctx?.signal ? { signal: ctx.signal } : undefined,\n );\n\n if (result.error) {\n // Throw the workflow error so the surrounding wrapper catches\n // it and produces a `ToolExecutionError` with `cause` pointing\n // back at the original `WorkflowError` subclass — keeps the\n // agent's tool-call loop seeing one uniform error class\n // regardless of which primitive failed.\n throw result.error;\n }\n\n return {\n data: result.data as TOutput,\n usage: result.usage,\n report: result.report,\n };\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,OACd,kBACA,SAImC;CACnC,IAAI,CAAC,iBAAiB,QAAQ,OAAO,iBAAiB,SAAS,UAC7D,MAAM,IAAI,cACR,wEACF;CAGF,OAAO,gBAAqC;EAC1C,MAAM,iBAAiB;EACvB,aAAa,QAAQ,eAAe,oBAAoB,iBAAiB,KAAK;EAC9E,OAAO,QAAQ;EACf,SAAS,OAAO,OAAO,QAAQ;GAG7B,MAAM,SAAS,MAAM,iBAAiB,QACpC,OACA,KAAK,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,MACzC;GAEA,IAAI,OAAO,OAMT,MAAM,OAAO;GAGf,OAAO;IACL,MAAM,OAAO;IACb,OAAO,OAAO;IACd,QAAQ,OAAO;GACjB;EACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"as-tool.mjs","names":[],"sources":["../../../../../../../ai/src/workflow/as-tool.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { WorkflowInstance } from \"../contracts/workflow/workflow.contract\";\nimport { WorkflowError } from \"../errors\";\nimport { compositeAsTool, type ToolContract } from \"../tool/tool\";\n\n/**\n * Wrap a `WorkflowInstance` as a `ToolContract` so an agent can invoke\n * it inside its tool-call loop. Closes the agent-calls-workflow\n * composition gap.\n *\n * Behavior:\n * - Tool `name` mirrors `workflow.name` — workflows without a name throw\n * `WorkflowError` at wrap time (the agent surface needs a stable id).\n * - Tool `input` is the supplied `inputSchema`; the validated value is\n * forwarded straight to `workflow.execute(input)`.\n * - On `result.error`, the workflow error is wrapped in\n * `ToolExecutionError` with `cause` set to the original\n * `WorkflowError` subclass — the agent's tool-call loop sees a\n * uniform error class regardless of which primitive failed.\n *\n * @example\n * const wf = workflow({ name: \"triage\", steps: [...] });\n * const triageTool = asTool(wf, {\n * description: \"Run the support-ticket triage flow\",\n * inputSchema: ticketSchema,\n * });\n * const a = ai.agent({ model, tools: [triageTool] });\n */\nexport function asTool<TInput, TOutput, TToolInput = TInput>(\n workflowInstance: WorkflowInstance<TInput, TOutput>,\n options: {\n description?: string;\n inputSchema: StandardSchemaV1<TToolInput>;\n },\n): ToolContract<TToolInput, TOutput> {\n if (!workflowInstance.name || typeof workflowInstance.name !== \"string\") {\n throw new WorkflowError(\n \"workflow.asTool(): workflow must have a `name` to be wrapped as a tool\",\n );\n }\n\n return compositeAsTool<TToolInput, TOutput>({\n name: workflowInstance.name,\n description: options.description ?? `Invoke workflow \"${workflowInstance.name}\" as a tool.`,\n input: options.inputSchema,\n execute: async (input, ctx) => {\n // Relay the outer agent's cancellation signal so cancelling the\n // parent aborts this nested workflow run (C2).\n const result = await workflowInstance.execute(\n input as unknown as TInput,\n ctx?.signal ? { signal: ctx.signal } : undefined,\n );\n\n if (result.error) {\n // Throw the workflow error so the surrounding wrapper catches\n // it and produces a `ToolExecutionError` with `cause` pointing\n // back at the original `WorkflowError` subclass — keeps the\n // agent's tool-call loop seeing one uniform error class\n // regardless of which primitive failed.\n throw result.error;\n }\n\n return {\n data: result.data as TOutput,\n usage: result.usage,\n report: result.report,\n };\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,OACd,kBACA,SAImC;CACnC,IAAI,CAAC,iBAAiB,QAAQ,OAAO,iBAAiB,SAAS,UAC7D,MAAM,IAAI,cACR,wEACF;CAGF,OAAO,gBAAqC;EAC1C,MAAM,iBAAiB;EACvB,aAAa,QAAQ,eAAe,oBAAoB,iBAAiB,KAAK;EAC9E,OAAO,QAAQ;EACf,SAAS,OAAO,OAAO,QAAQ;GAG7B,MAAM,SAAS,MAAM,iBAAiB,QACpC,OACA,KAAK,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,MACzC;GAEA,IAAI,OAAO,OAMT,MAAM,OAAO;GAGf,OAAO;IACL,MAAM,OAAO;IACb,OAAO,OAAO;IACd,QAAQ,OAAO;GACjB;EACF;CACF,CAAC;AACH"}
@@ -1,7 +1,7 @@
1
1
  import { WorkflowCancelledError } from "../errors/workflow-cancelled-error.mjs";
2
2
  import "../errors/index.mjs";
3
3
 
4
- //#region ../@warlock.js/ai/src/workflow/cancellation.ts
4
+ //#region ../ai/src/workflow/cancellation.ts
5
5
  /**
6
6
  * Build a `WorkflowCancelledError` from an `AbortSignal`, extracting
7
7
  * a human-readable reason from `signal.reason` (string | Error | any).