@warlock.js/core 4.4.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (997) hide show
  1. package/CHANGELOG.md +72 -5
  2. package/README.md +47 -11
  3. package/esm/ai/src/agent/agent-input-builder.mjs +132 -0
  4. package/esm/ai/src/agent/agent-input-builder.mjs.map +1 -0
  5. package/esm/ai/src/agent/agent-log-event.mjs +101 -0
  6. package/esm/ai/src/agent/agent-log-event.mjs.map +1 -0
  7. package/esm/ai/src/agent/agent-stream.mjs +82 -0
  8. package/esm/ai/src/agent/agent-stream.mjs.map +1 -0
  9. package/esm/ai/src/agent/agent-to-stream-event.mjs +86 -0
  10. package/esm/ai/src/agent/agent-to-stream-event.mjs.map +1 -0
  11. package/esm/ai/src/agent/agent.mjs +1276 -0
  12. package/esm/ai/src/agent/agent.mjs.map +1 -0
  13. package/esm/ai/src/agent/index.mjs +5 -0
  14. package/esm/ai/src/agent/json-stream-guard.mjs +400 -0
  15. package/esm/ai/src/agent/json-stream-guard.mjs.map +1 -0
  16. package/esm/ai/src/agent/signature.mjs +57 -0
  17. package/esm/ai/src/agent/signature.mjs.map +1 -0
  18. package/esm/ai/src/agent/snapshot.mjs +101 -0
  19. package/esm/ai/src/agent/snapshot.mjs.map +1 -0
  20. package/esm/ai/src/agent/spawn-sub-agent.mjs +68 -0
  21. package/esm/ai/src/agent/spawn-sub-agent.mjs.map +1 -0
  22. package/esm/ai/src/ai.mjs +191 -0
  23. package/esm/ai/src/ai.mjs.map +1 -0
  24. package/esm/ai/src/batch/batch.mjs +198 -0
  25. package/esm/ai/src/batch/batch.mjs.map +1 -0
  26. package/esm/ai/src/batch/index.mjs +3 -0
  27. package/esm/ai/src/batch/run-batch-item.mjs +100 -0
  28. package/esm/ai/src/batch/run-batch-item.mjs.map +1 -0
  29. package/esm/ai/src/batch/run-with-concurrency.mjs +39 -0
  30. package/esm/ai/src/batch/run-with-concurrency.mjs.map +1 -0
  31. package/esm/ai/src/checkpoint/memory.mjs +0 -0
  32. package/esm/ai/src/checkpoint/memory.mjs.map +1 -0
  33. package/esm/ai/src/checkpoint/pg.mjs +265 -0
  34. package/esm/ai/src/checkpoint/pg.mjs.map +1 -0
  35. package/esm/ai/src/checkpoint/redis.mjs +200 -0
  36. package/esm/ai/src/checkpoint/redis.mjs.map +1 -0
  37. package/esm/ai/src/config.mjs +59 -0
  38. package/esm/ai/src/config.mjs.map +1 -0
  39. package/esm/ai/src/contracts/end.type.mjs +47 -0
  40. package/esm/ai/src/contracts/end.type.mjs.map +1 -0
  41. package/esm/ai/src/errors/agent-cancelled-error.mjs +43 -0
  42. package/esm/ai/src/errors/agent-cancelled-error.mjs.map +1 -0
  43. package/esm/ai/src/errors/agent-drift-error.mjs +31 -0
  44. package/esm/ai/src/errors/agent-drift-error.mjs.map +1 -0
  45. package/esm/ai/src/errors/agent-execution-error.mjs +35 -0
  46. package/esm/ai/src/errors/agent-execution-error.mjs.map +1 -0
  47. package/esm/ai/src/errors/agent-max-trips-error.mjs +41 -0
  48. package/esm/ai/src/errors/agent-max-trips-error.mjs.map +1 -0
  49. package/esm/ai/src/errors/ai-error.mjs +68 -0
  50. package/esm/ai/src/errors/ai-error.mjs.map +1 -0
  51. package/esm/ai/src/errors/budget-exceeded-error.mjs +31 -0
  52. package/esm/ai/src/errors/budget-exceeded-error.mjs.map +1 -0
  53. package/esm/ai/src/errors/content-filter-error.mjs +28 -0
  54. package/esm/ai/src/errors/content-filter-error.mjs.map +1 -0
  55. package/esm/ai/src/errors/context-length-exceeded-error.mjs +31 -0
  56. package/esm/ai/src/errors/context-length-exceeded-error.mjs.map +1 -0
  57. package/esm/ai/src/errors/guardrail-violation-error.mjs +41 -0
  58. package/esm/ai/src/errors/guardrail-violation-error.mjs.map +1 -0
  59. package/esm/ai/src/errors/index.mjs +39 -0
  60. package/esm/ai/src/errors/invalid-request-error.mjs +31 -0
  61. package/esm/ai/src/errors/invalid-request-error.mjs.map +1 -0
  62. package/esm/ai/src/errors/max-iterations-error.mjs +32 -0
  63. package/esm/ai/src/errors/max-iterations-error.mjs.map +1 -0
  64. package/esm/ai/src/errors/max-steps-exceeded-error.mjs +21 -0
  65. package/esm/ai/src/errors/max-steps-exceeded-error.mjs.map +1 -0
  66. package/esm/ai/src/errors/orchestrator-cancelled-error.mjs +31 -0
  67. package/esm/ai/src/errors/orchestrator-cancelled-error.mjs.map +1 -0
  68. package/esm/ai/src/errors/orchestrator-config-error.mjs +30 -0
  69. package/esm/ai/src/errors/orchestrator-config-error.mjs.map +1 -0
  70. package/esm/ai/src/errors/orchestrator-drift-error.mjs +37 -0
  71. package/esm/ai/src/errors/orchestrator-drift-error.mjs.map +1 -0
  72. package/esm/ai/src/errors/orchestrator-failed-error.mjs +36 -0
  73. package/esm/ai/src/errors/orchestrator-failed-error.mjs.map +1 -0
  74. package/esm/ai/src/errors/outbound-policy-error.mjs +32 -0
  75. package/esm/ai/src/errors/outbound-policy-error.mjs.map +1 -0
  76. package/esm/ai/src/errors/planner-cancelled-error.mjs +29 -0
  77. package/esm/ai/src/errors/planner-cancelled-error.mjs.map +1 -0
  78. package/esm/ai/src/errors/planner-drift-error.mjs +33 -0
  79. package/esm/ai/src/errors/planner-drift-error.mjs.map +1 -0
  80. package/esm/ai/src/errors/planner-failed-error.mjs +37 -0
  81. package/esm/ai/src/errors/planner-failed-error.mjs.map +1 -0
  82. package/esm/ai/src/errors/planner-plan-invalid-error.mjs +25 -0
  83. package/esm/ai/src/errors/planner-plan-invalid-error.mjs.map +1 -0
  84. package/esm/ai/src/errors/provider-auth-error.mjs +26 -0
  85. package/esm/ai/src/errors/provider-auth-error.mjs.map +1 -0
  86. package/esm/ai/src/errors/provider-error.mjs +42 -0
  87. package/esm/ai/src/errors/provider-error.mjs.map +1 -0
  88. package/esm/ai/src/errors/provider-rate-limit-error.mjs +31 -0
  89. package/esm/ai/src/errors/provider-rate-limit-error.mjs.map +1 -0
  90. package/esm/ai/src/errors/provider-timeout-error.mjs +26 -0
  91. package/esm/ai/src/errors/provider-timeout-error.mjs.map +1 -0
  92. package/esm/ai/src/errors/quota-exceeded-error.mjs +40 -0
  93. package/esm/ai/src/errors/quota-exceeded-error.mjs.map +1 -0
  94. package/esm/ai/src/errors/routing-error.mjs +23 -0
  95. package/esm/ai/src/errors/routing-error.mjs.map +1 -0
  96. package/esm/ai/src/errors/schema-validation-error.mjs +37 -0
  97. package/esm/ai/src/errors/schema-validation-error.mjs.map +1 -0
  98. package/esm/ai/src/errors/step-failed-error.mjs +19 -0
  99. package/esm/ai/src/errors/step-failed-error.mjs.map +1 -0
  100. package/esm/ai/src/errors/supervisor-cancelled-error.mjs +29 -0
  101. package/esm/ai/src/errors/supervisor-cancelled-error.mjs.map +1 -0
  102. package/esm/ai/src/errors/supervisor-drift-error.mjs +30 -0
  103. package/esm/ai/src/errors/supervisor-drift-error.mjs.map +1 -0
  104. package/esm/ai/src/errors/supervisor-failed-error.mjs +43 -0
  105. package/esm/ai/src/errors/supervisor-failed-error.mjs.map +1 -0
  106. package/esm/ai/src/errors/supervisor-routing-error.mjs +39 -0
  107. package/esm/ai/src/errors/supervisor-routing-error.mjs.map +1 -0
  108. package/esm/ai/src/errors/tool-execution-error.mjs +32 -0
  109. package/esm/ai/src/errors/tool-execution-error.mjs.map +1 -0
  110. package/esm/ai/src/errors/workflow-cancelled-error.mjs +23 -0
  111. package/esm/ai/src/errors/workflow-cancelled-error.mjs.map +1 -0
  112. package/esm/ai/src/errors/workflow-drift-error.mjs +24 -0
  113. package/esm/ai/src/errors/workflow-drift-error.mjs.map +1 -0
  114. package/esm/ai/src/errors/workflow-error.mjs +18 -0
  115. package/esm/ai/src/errors/workflow-error.mjs.map +1 -0
  116. package/esm/ai/src/eval/dataset.mjs +112 -0
  117. package/esm/ai/src/eval/dataset.mjs.map +1 -0
  118. package/esm/ai/src/eval/eval-runner.mjs +135 -0
  119. package/esm/ai/src/eval/eval-runner.mjs.map +1 -0
  120. package/esm/ai/src/eval/index.mjs +48 -0
  121. package/esm/ai/src/eval/index.mjs.map +1 -0
  122. package/esm/ai/src/eval/judge-scorer.mjs +87 -0
  123. package/esm/ai/src/eval/judge-scorer.mjs.map +1 -0
  124. package/esm/ai/src/eval/regression.mjs +51 -0
  125. package/esm/ai/src/eval/regression.mjs.map +1 -0
  126. package/esm/ai/src/eval/report-json.mjs +33 -0
  127. package/esm/ai/src/eval/report-json.mjs.map +1 -0
  128. package/esm/ai/src/eval/report-junit.mjs +60 -0
  129. package/esm/ai/src/eval/report-junit.mjs.map +1 -0
  130. package/esm/ai/src/eval/scorers.mjs +101 -0
  131. package/esm/ai/src/eval/scorers.mjs.map +1 -0
  132. package/esm/ai/src/guard/detectors/index.mjs +6 -0
  133. package/esm/ai/src/guard/detectors/injection.mjs +254 -0
  134. package/esm/ai/src/guard/detectors/injection.mjs.map +1 -0
  135. package/esm/ai/src/guard/detectors/moderation.mjs +134 -0
  136. package/esm/ai/src/guard/detectors/moderation.mjs.map +1 -0
  137. package/esm/ai/src/guard/detectors/pii.mjs +199 -0
  138. package/esm/ai/src/guard/detectors/pii.mjs.map +1 -0
  139. package/esm/ai/src/guard/detectors/topic.mjs +99 -0
  140. package/esm/ai/src/guard/detectors/topic.mjs.map +1 -0
  141. package/esm/ai/src/guard/errors.mjs +18 -0
  142. package/esm/ai/src/guard/errors.mjs.map +1 -0
  143. package/esm/ai/src/guard/guard.mjs +209 -0
  144. package/esm/ai/src/guard/guard.mjs.map +1 -0
  145. package/esm/ai/src/guard/guardrail.mjs +22 -0
  146. package/esm/ai/src/guard/guardrail.mjs.map +1 -0
  147. package/esm/ai/src/human/errors.mjs +60 -0
  148. package/esm/ai/src/human/errors.mjs.map +1 -0
  149. package/esm/ai/src/human/human-approval.mjs +170 -0
  150. package/esm/ai/src/human/human-approval.mjs.map +1 -0
  151. package/esm/ai/src/human/policy.mjs +67 -0
  152. package/esm/ai/src/human/policy.mjs.map +1 -0
  153. package/esm/ai/src/human/register.mjs +37 -0
  154. package/esm/ai/src/human/register.mjs.map +1 -0
  155. package/esm/ai/src/human/resume-seed.mjs +53 -0
  156. package/esm/ai/src/human/resume-seed.mjs.map +1 -0
  157. package/esm/ai/src/human/resume.mjs +121 -0
  158. package/esm/ai/src/human/resume.mjs.map +1 -0
  159. package/esm/ai/src/human/stores/index.mjs +5 -0
  160. package/esm/ai/src/human/stores/memory.mjs +91 -0
  161. package/esm/ai/src/human/stores/memory.mjs.map +1 -0
  162. package/esm/ai/src/human/stores/pg.mjs +220 -0
  163. package/esm/ai/src/human/stores/pg.mjs.map +1 -0
  164. package/esm/ai/src/human/stores/redis.mjs +201 -0
  165. package/esm/ai/src/human/stores/redis.mjs.map +1 -0
  166. package/esm/ai/src/image/image-cost.mjs +55 -0
  167. package/esm/ai/src/image/image-cost.mjs.map +1 -0
  168. package/esm/ai/src/image/image.mjs +112 -0
  169. package/esm/ai/src/image/image.mjs.map +1 -0
  170. package/esm/ai/src/image/index.mjs +4 -0
  171. package/esm/ai/src/index.mjs +194 -0
  172. package/esm/ai/src/memory/derive-id.mjs +24 -0
  173. package/esm/ai/src/memory/derive-id.mjs.map +1 -0
  174. package/esm/ai/src/memory/episodic-memory.mjs +106 -0
  175. package/esm/ai/src/memory/episodic-memory.mjs.map +1 -0
  176. package/esm/ai/src/memory/memory.mjs +166 -0
  177. package/esm/ai/src/memory/memory.mjs.map +1 -0
  178. package/esm/ai/src/memory/procedural-memory.mjs +103 -0
  179. package/esm/ai/src/memory/procedural-memory.mjs.map +1 -0
  180. package/esm/ai/src/memory/semantic-memory.mjs +80 -0
  181. package/esm/ai/src/memory/semantic-memory.mjs.map +1 -0
  182. package/esm/ai/src/memory/working-memory.mjs +62 -0
  183. package/esm/ai/src/memory/working-memory.mjs.map +1 -0
  184. package/esm/ai/src/middleware/builtins/budget.mjs +219 -0
  185. package/esm/ai/src/middleware/builtins/budget.mjs.map +1 -0
  186. package/esm/ai/src/middleware/builtins/guardrail.mjs +76 -0
  187. package/esm/ai/src/middleware/builtins/guardrail.mjs.map +1 -0
  188. package/esm/ai/src/middleware/builtins/semantic-cache.mjs +149 -0
  189. package/esm/ai/src/middleware/builtins/semantic-cache.mjs.map +1 -0
  190. package/esm/ai/src/middleware/helpers/compose.mjs +52 -0
  191. package/esm/ai/src/middleware/helpers/compose.mjs.map +1 -0
  192. package/esm/ai/src/middleware/helpers/for-tool.mjs +80 -0
  193. package/esm/ai/src/middleware/helpers/for-tool.mjs.map +1 -0
  194. package/esm/ai/src/middleware/index.mjs +10 -0
  195. package/esm/ai/src/middleware/pipeline.mjs +100 -0
  196. package/esm/ai/src/middleware/pipeline.mjs.map +1 -0
  197. package/esm/ai/src/middleware/utils/extract-user-text.mjs +47 -0
  198. package/esm/ai/src/middleware/utils/extract-user-text.mjs.map +1 -0
  199. package/esm/ai/src/middleware/utils/namespaced-state.mjs +60 -0
  200. package/esm/ai/src/middleware/utils/namespaced-state.mjs.map +1 -0
  201. package/esm/ai/src/mock/index.mjs +4 -0
  202. package/esm/ai/src/mock/mock-agent.mjs +3 -0
  203. package/esm/ai/src/mock/mock-router.mjs +58 -0
  204. package/esm/ai/src/mock/mock-router.mjs.map +1 -0
  205. package/esm/ai/src/model/fallback-model.mjs +218 -0
  206. package/esm/ai/src/model/fallback-model.mjs.map +1 -0
  207. package/esm/ai/src/model/index.mjs +3 -0
  208. package/esm/ai/src/object-stream/index.mjs +4 -0
  209. package/esm/ai/src/object-stream/parse-partial-json.mjs +78 -0
  210. package/esm/ai/src/object-stream/parse-partial-json.mjs.map +1 -0
  211. package/esm/ai/src/object-stream/stream-object.mjs +97 -0
  212. package/esm/ai/src/object-stream/stream-object.mjs.map +1 -0
  213. package/esm/ai/src/observe/index.mjs +4 -0
  214. package/esm/ai/src/observe/observer-registry.mjs +35 -0
  215. package/esm/ai/src/observe/observer-registry.mjs.map +1 -0
  216. package/esm/ai/src/observe/resolve-observers.mjs +73 -0
  217. package/esm/ai/src/observe/resolve-observers.mjs.map +1 -0
  218. package/esm/ai/src/orchestrator/as-tool.mjs +98 -0
  219. package/esm/ai/src/orchestrator/as-tool.mjs.map +1 -0
  220. package/esm/ai/src/orchestrator/checkpoint.mjs +75 -0
  221. package/esm/ai/src/orchestrator/checkpoint.mjs.map +1 -0
  222. package/esm/ai/src/orchestrator/commands.mjs +34 -0
  223. package/esm/ai/src/orchestrator/commands.mjs.map +1 -0
  224. package/esm/ai/src/orchestrator/compaction.mjs +206 -0
  225. package/esm/ai/src/orchestrator/compaction.mjs.map +1 -0
  226. package/esm/ai/src/orchestrator/dispatch.mjs +171 -0
  227. package/esm/ai/src/orchestrator/dispatch.mjs.map +1 -0
  228. package/esm/ai/src/orchestrator/emitter.mjs +85 -0
  229. package/esm/ai/src/orchestrator/emitter.mjs.map +1 -0
  230. package/esm/ai/src/orchestrator/execution.mjs +395 -0
  231. package/esm/ai/src/orchestrator/execution.mjs.map +1 -0
  232. package/esm/ai/src/orchestrator/index.mjs +11 -0
  233. package/esm/ai/src/orchestrator/load.mjs +49 -0
  234. package/esm/ai/src/orchestrator/load.mjs.map +1 -0
  235. package/esm/ai/src/orchestrator/lock.mjs +75 -0
  236. package/esm/ai/src/orchestrator/lock.mjs.map +1 -0
  237. package/esm/ai/src/orchestrator/memory.mjs +141 -0
  238. package/esm/ai/src/orchestrator/memory.mjs.map +1 -0
  239. package/esm/ai/src/orchestrator/orchestrator-stream.mjs +98 -0
  240. package/esm/ai/src/orchestrator/orchestrator-stream.mjs.map +1 -0
  241. package/esm/ai/src/orchestrator/orchestrator.mjs +206 -0
  242. package/esm/ai/src/orchestrator/orchestrator.mjs.map +1 -0
  243. package/esm/ai/src/orchestrator/resume.mjs +74 -0
  244. package/esm/ai/src/orchestrator/resume.mjs.map +1 -0
  245. package/esm/ai/src/orchestrator/session-lock.mjs +83 -0
  246. package/esm/ai/src/orchestrator/session-lock.mjs.map +1 -0
  247. package/esm/ai/src/orchestrator/signature.mjs +120 -0
  248. package/esm/ai/src/orchestrator/signature.mjs.map +1 -0
  249. package/esm/ai/src/orchestrator/window.mjs +56 -0
  250. package/esm/ai/src/orchestrator/window.mjs.map +1 -0
  251. package/esm/ai/src/planner/dag-scheduler.mjs +97 -0
  252. package/esm/ai/src/planner/dag-scheduler.mjs.map +1 -0
  253. package/esm/ai/src/planner/index.mjs +6 -0
  254. package/esm/ai/src/planner/plan-prompt.mjs +31 -0
  255. package/esm/ai/src/planner/plan-prompt.mjs.map +1 -0
  256. package/esm/ai/src/planner/plan-schema.mjs +120 -0
  257. package/esm/ai/src/planner/plan-schema.mjs.map +1 -0
  258. package/esm/ai/src/planner/planner-run.mjs +769 -0
  259. package/esm/ai/src/planner/planner-run.mjs.map +1 -0
  260. package/esm/ai/src/planner/planner.mjs +144 -0
  261. package/esm/ai/src/planner/planner.mjs.map +1 -0
  262. package/esm/ai/src/planner/signature.mjs +27 -0
  263. package/esm/ai/src/planner/signature.mjs.map +1 -0
  264. package/esm/ai/src/planner/snapshot.mjs +95 -0
  265. package/esm/ai/src/planner/snapshot.mjs.map +1 -0
  266. package/esm/ai/src/prompt/errors.mjs +73 -0
  267. package/esm/ai/src/prompt/errors.mjs.map +1 -0
  268. package/esm/ai/src/prompt/index.mjs +4 -0
  269. package/esm/ai/src/prompt/prompt-langfuse-sync.mjs +104 -0
  270. package/esm/ai/src/prompt/prompt-langfuse-sync.mjs.map +1 -0
  271. package/esm/ai/src/prompt/prompt-validate.mjs +170 -0
  272. package/esm/ai/src/prompt/prompt-validate.mjs.map +1 -0
  273. package/esm/ai/src/prompt/prompt.mjs +218 -0
  274. package/esm/ai/src/prompt/prompt.mjs.map +1 -0
  275. package/esm/ai/src/prompts/index.mjs +3 -0
  276. package/esm/ai/src/prompts/prompts-manager.mjs +410 -0
  277. package/esm/ai/src/prompts/prompts-manager.mjs.map +1 -0
  278. package/esm/ai/src/prompts/prompts-validate.mjs +200 -0
  279. package/esm/ai/src/prompts/prompts-validate.mjs.map +1 -0
  280. package/esm/ai/src/rag/as-tool.mjs +48 -0
  281. package/esm/ai/src/rag/as-tool.mjs.map +1 -0
  282. package/esm/ai/src/rag/chunk/chunk.mjs +44 -0
  283. package/esm/ai/src/rag/chunk/chunk.mjs.map +1 -0
  284. package/esm/ai/src/rag/chunk/fixed.mjs +32 -0
  285. package/esm/ai/src/rag/chunk/fixed.mjs.map +1 -0
  286. package/esm/ai/src/rag/chunk/markdown.mjs +75 -0
  287. package/esm/ai/src/rag/chunk/markdown.mjs.map +1 -0
  288. package/esm/ai/src/rag/chunk/recursive.mjs +132 -0
  289. package/esm/ai/src/rag/chunk/recursive.mjs.map +1 -0
  290. package/esm/ai/src/rag/chunk/sentence.mjs +73 -0
  291. package/esm/ai/src/rag/chunk/sentence.mjs.map +1 -0
  292. package/esm/ai/src/rag/hybrid/bm25.mjs +51 -0
  293. package/esm/ai/src/rag/hybrid/bm25.mjs.map +1 -0
  294. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs +29 -0
  295. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs.map +1 -0
  296. package/esm/ai/src/rag/hybrid/rrf.mjs +30 -0
  297. package/esm/ai/src/rag/hybrid/rrf.mjs.map +1 -0
  298. package/esm/ai/src/rag/index.mjs +18 -0
  299. package/esm/ai/src/rag/loaders/errors.mjs +25 -0
  300. package/esm/ai/src/rag/loaders/errors.mjs.map +1 -0
  301. package/esm/ai/src/rag/loaders/index.mjs +7 -0
  302. package/esm/ai/src/rag/loaders/load-html.mjs +138 -0
  303. package/esm/ai/src/rag/loaders/load-html.mjs.map +1 -0
  304. package/esm/ai/src/rag/loaders/load-pdf.mjs +150 -0
  305. package/esm/ai/src/rag/loaders/load-pdf.mjs.map +1 -0
  306. package/esm/ai/src/rag/loaders/load-text.mjs +60 -0
  307. package/esm/ai/src/rag/loaders/load-text.mjs.map +1 -0
  308. package/esm/ai/src/rag/loaders/load-web.mjs +89 -0
  309. package/esm/ai/src/rag/loaders/load-web.mjs.map +1 -0
  310. package/esm/ai/src/rag/rag.mjs +126 -0
  311. package/esm/ai/src/rag/rag.mjs.map +1 -0
  312. package/esm/ai/src/rag/rerank/keyword-reranker.mjs +58 -0
  313. package/esm/ai/src/rag/rerank/keyword-reranker.mjs.map +1 -0
  314. package/esm/ai/src/rag/rerank/llm-reranker.mjs +85 -0
  315. package/esm/ai/src/rag/rerank/llm-reranker.mjs.map +1 -0
  316. package/esm/ai/src/rag/retrieve.mjs +68 -0
  317. package/esm/ai/src/rag/retrieve.mjs.map +1 -0
  318. package/esm/ai/src/rag/store/cache-vector-store.mjs +48 -0
  319. package/esm/ai/src/rag/store/cache-vector-store.mjs.map +1 -0
  320. package/esm/ai/src/rag/store/pg-vector-store.mjs +328 -0
  321. package/esm/ai/src/rag/store/pg-vector-store.mjs.map +1 -0
  322. package/esm/ai/src/rag/transforms/multi-query.mjs +41 -0
  323. package/esm/ai/src/rag/transforms/multi-query.mjs.map +1 -0
  324. package/esm/ai/src/security/index.mjs +5 -0
  325. package/esm/ai/src/security/outbound-policy.mjs +187 -0
  326. package/esm/ai/src/security/outbound-policy.mjs.map +1 -0
  327. package/esm/ai/src/security/private-ip.mjs +48 -0
  328. package/esm/ai/src/security/private-ip.mjs.map +1 -0
  329. package/esm/ai/src/security/redact.mjs +60 -0
  330. package/esm/ai/src/security/redact.mjs.map +1 -0
  331. package/esm/ai/src/serve/serve.mjs +90 -0
  332. package/esm/ai/src/serve/serve.mjs.map +1 -0
  333. package/esm/ai/src/serve/sse.mjs +25 -0
  334. package/esm/ai/src/serve/sse.mjs.map +1 -0
  335. package/esm/ai/src/serve/stream-to-sse.mjs +37 -0
  336. package/esm/ai/src/serve/stream-to-sse.mjs.map +1 -0
  337. package/esm/ai/src/skills/catalog.mjs +140 -0
  338. package/esm/ai/src/skills/catalog.mjs.map +1 -0
  339. package/esm/ai/src/skills/index.mjs +11 -0
  340. package/esm/ai/src/skills/load-skill-tool.mjs +65 -0
  341. package/esm/ai/src/skills/load-skill-tool.mjs.map +1 -0
  342. package/esm/ai/src/skills/save-skill-tool.mjs +65 -0
  343. package/esm/ai/src/skills/save-skill-tool.mjs.map +1 -0
  344. package/esm/ai/src/skills/skills.mjs +109 -0
  345. package/esm/ai/src/skills/skills.mjs.map +1 -0
  346. package/esm/ai/src/skills/sources/directory-source.mjs +108 -0
  347. package/esm/ai/src/skills/sources/directory-source.mjs.map +1 -0
  348. package/esm/ai/src/skills/sources/index.mjs +27 -0
  349. package/esm/ai/src/skills/sources/index.mjs.map +1 -0
  350. package/esm/ai/src/skills/sources/parse-frontmatter.mjs +46 -0
  351. package/esm/ai/src/skills/sources/parse-frontmatter.mjs.map +1 -0
  352. package/esm/ai/src/skills/sources/store-source.mjs +15 -0
  353. package/esm/ai/src/skills/sources/store-source.mjs.map +1 -0
  354. package/esm/ai/src/skills/sources/url-source.mjs +117 -0
  355. package/esm/ai/src/skills/sources/url-source.mjs.map +1 -0
  356. package/esm/ai/src/snapshot/memory.mjs +81 -0
  357. package/esm/ai/src/snapshot/memory.mjs.map +1 -0
  358. package/esm/ai/src/snapshot/pg.mjs +146 -0
  359. package/esm/ai/src/snapshot/pg.mjs.map +1 -0
  360. package/esm/ai/src/snapshot/redis.mjs +101 -0
  361. package/esm/ai/src/snapshot/redis.mjs.map +1 -0
  362. package/esm/ai/src/speech/index.mjs +3 -0
  363. package/esm/ai/src/speech/speech.mjs +122 -0
  364. package/esm/ai/src/speech/speech.mjs.map +1 -0
  365. package/esm/ai/src/supervisor/as-tool.mjs +74 -0
  366. package/esm/ai/src/supervisor/as-tool.mjs.map +1 -0
  367. package/esm/ai/src/supervisor/cancellation.mjs +22 -0
  368. package/esm/ai/src/supervisor/cancellation.mjs.map +1 -0
  369. package/esm/ai/src/supervisor/decide.mjs +272 -0
  370. package/esm/ai/src/supervisor/decide.mjs.map +1 -0
  371. package/esm/ai/src/supervisor/emitter.mjs +47 -0
  372. package/esm/ai/src/supervisor/emitter.mjs.map +1 -0
  373. package/esm/ai/src/supervisor/entries.mjs +206 -0
  374. package/esm/ai/src/supervisor/entries.mjs.map +1 -0
  375. package/esm/ai/src/supervisor/execution.mjs +1921 -0
  376. package/esm/ai/src/supervisor/execution.mjs.map +1 -0
  377. package/esm/ai/src/supervisor/fan-out.mjs +65 -0
  378. package/esm/ai/src/supervisor/fan-out.mjs.map +1 -0
  379. package/esm/ai/src/supervisor/index.mjs +14 -0
  380. package/esm/ai/src/supervisor/router-factory.mjs +141 -0
  381. package/esm/ai/src/supervisor/router-factory.mjs.map +1 -0
  382. package/esm/ai/src/supervisor/router-prompt.mjs +52 -0
  383. package/esm/ai/src/supervisor/router-prompt.mjs.map +1 -0
  384. package/esm/ai/src/supervisor/signature.mjs +89 -0
  385. package/esm/ai/src/supervisor/signature.mjs.map +1 -0
  386. package/esm/ai/src/supervisor/snapshot.mjs +69 -0
  387. package/esm/ai/src/supervisor/snapshot.mjs.map +1 -0
  388. package/esm/ai/src/supervisor/supervisor-stream.mjs +89 -0
  389. package/esm/ai/src/supervisor/supervisor-stream.mjs.map +1 -0
  390. package/esm/ai/src/supervisor/supervisor.mjs +144 -0
  391. package/esm/ai/src/supervisor/supervisor.mjs.map +1 -0
  392. package/esm/ai/src/system-prompt/index.mjs +6 -0
  393. package/esm/ai/src/system-prompt/instruction.mjs +57 -0
  394. package/esm/ai/src/system-prompt/instruction.mjs.map +1 -0
  395. package/esm/ai/src/system-prompt/persona.mjs +57 -0
  396. package/esm/ai/src/system-prompt/persona.mjs.map +1 -0
  397. package/esm/ai/src/system-prompt/render-placeholders.mjs +58 -0
  398. package/esm/ai/src/system-prompt/render-placeholders.mjs.map +1 -0
  399. package/esm/ai/src/system-prompt/system-prompt.mjs +267 -0
  400. package/esm/ai/src/system-prompt/system-prompt.mjs.map +1 -0
  401. package/esm/ai/src/team/gates.mjs +48 -0
  402. package/esm/ai/src/team/gates.mjs.map +1 -0
  403. package/esm/ai/src/team/index.mjs +3 -0
  404. package/esm/ai/src/team/team.mjs +94 -0
  405. package/esm/ai/src/team/team.mjs.map +1 -0
  406. package/esm/ai/src/tool/executable-as-tool.mjs +81 -0
  407. package/esm/ai/src/tool/executable-as-tool.mjs.map +1 -0
  408. package/esm/ai/src/tool/index.mjs +4 -0
  409. package/esm/ai/src/tool/tool.mjs +185 -0
  410. package/esm/ai/src/tool/tool.mjs.map +1 -0
  411. package/esm/ai/src/transcribe/audio-input.mjs +84 -0
  412. package/esm/ai/src/transcribe/audio-input.mjs.map +1 -0
  413. package/esm/ai/src/transcribe/index.mjs +4 -0
  414. package/esm/ai/src/transcribe/transcribe.mjs +127 -0
  415. package/esm/ai/src/transcribe/transcribe.mjs.map +1 -0
  416. package/esm/ai/src/utils/compute-cost.mjs +112 -0
  417. package/esm/ai/src/utils/compute-cost.mjs.map +1 -0
  418. package/esm/ai/src/utils/extract-json-lenient.mjs +97 -0
  419. package/esm/ai/src/utils/extract-json-lenient.mjs.map +1 -0
  420. package/esm/ai/src/utils/extract-json-payload.mjs +39 -0
  421. package/esm/ai/src/utils/extract-json-payload.mjs.map +1 -0
  422. package/esm/ai/src/utils/generate-run-id.mjs +23 -0
  423. package/esm/ai/src/utils/generate-run-id.mjs.map +1 -0
  424. package/esm/ai/src/utils/index.mjs +12 -0
  425. package/esm/ai/src/utils/json-schema.mjs +89 -0
  426. package/esm/ai/src/utils/json-schema.mjs.map +1 -0
  427. package/esm/ai/src/utils/prepare-attachment-part.mjs +232 -0
  428. package/esm/ai/src/utils/prepare-attachment-part.mjs.map +1 -0
  429. package/esm/ai/src/utils/resolve-attachment.mjs +74 -0
  430. package/esm/ai/src/utils/resolve-attachment.mjs.map +1 -0
  431. package/esm/ai/src/utils/run-context.mjs +89 -0
  432. package/esm/ai/src/utils/run-context.mjs.map +1 -0
  433. package/esm/ai/src/utils/safe-json-parse.mjs +22 -0
  434. package/esm/ai/src/utils/safe-json-parse.mjs.map +1 -0
  435. package/esm/ai/src/utils/stamp-report-lineage.mjs +45 -0
  436. package/esm/ai/src/utils/stamp-report-lineage.mjs.map +1 -0
  437. package/esm/ai/src/vcr/cassette-io.mjs +57 -0
  438. package/esm/ai/src/vcr/cassette-io.mjs.map +1 -0
  439. package/esm/ai/src/vcr/errors.mjs +37 -0
  440. package/esm/ai/src/vcr/errors.mjs.map +1 -0
  441. package/esm/ai/src/vcr/hash-request.mjs +118 -0
  442. package/esm/ai/src/vcr/hash-request.mjs.map +1 -0
  443. package/esm/ai/src/vcr/index.mjs +5 -0
  444. package/esm/ai/src/vcr/vcr.mjs +248 -0
  445. package/esm/ai/src/vcr/vcr.mjs.map +1 -0
  446. package/esm/ai/src/workflow/as-tool.mjs +49 -0
  447. package/esm/ai/src/workflow/as-tool.mjs.map +1 -0
  448. package/esm/ai/src/workflow/cancellation.mjs +44 -0
  449. package/esm/ai/src/workflow/cancellation.mjs.map +1 -0
  450. package/esm/ai/src/workflow/emitter.mjs +40 -0
  451. package/esm/ai/src/workflow/emitter.mjs.map +1 -0
  452. package/esm/ai/src/workflow/engine.mjs +363 -0
  453. package/esm/ai/src/workflow/engine.mjs.map +1 -0
  454. package/esm/ai/src/workflow/index.mjs +5 -0
  455. package/esm/ai/src/workflow/retry.mjs +32 -0
  456. package/esm/ai/src/workflow/retry.mjs.map +1 -0
  457. package/esm/ai/src/workflow/router.mjs +56 -0
  458. package/esm/ai/src/workflow/router.mjs.map +1 -0
  459. package/esm/ai/src/workflow/run-scoped-emitter.mjs +32 -0
  460. package/esm/ai/src/workflow/run-scoped-emitter.mjs.map +1 -0
  461. package/esm/ai/src/workflow/signature.mjs +34 -0
  462. package/esm/ai/src/workflow/signature.mjs.map +1 -0
  463. package/esm/ai/src/workflow/snapshot.mjs +77 -0
  464. package/esm/ai/src/workflow/snapshot.mjs.map +1 -0
  465. package/esm/ai/src/workflow/state.mjs +37 -0
  466. package/esm/ai/src/workflow/state.mjs.map +1 -0
  467. package/esm/ai/src/workflow/step-runner.mjs +370 -0
  468. package/esm/ai/src/workflow/step-runner.mjs.map +1 -0
  469. package/esm/ai/src/workflow/step.mjs +37 -0
  470. package/esm/ai/src/workflow/step.mjs.map +1 -0
  471. package/esm/ai/src/workflow/workflow.mjs +122 -0
  472. package/esm/ai/src/workflow/workflow.mjs.map +1 -0
  473. package/esm/ai-openai/src/embedder.mjs +4 -0
  474. package/esm/ai-openai/src/image.mjs +5 -0
  475. package/esm/ai-openai/src/index.mjs +7 -0
  476. package/esm/ai-openai/src/model.mjs +5 -0
  477. package/esm/ai-openai/src/sdk.mjs +9 -0
  478. package/esm/ai-openai/src/speech.mjs +5 -0
  479. package/esm/ai-openai/src/transcription.mjs +6 -0
  480. package/esm/ai-openai/src/utils/index.mjs +5 -0
  481. package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -0
  482. package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
  483. package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
  484. package/esm/cli/commands/dev-server.command.mjs +1 -1
  485. package/esm/cli/commands/dev-server.command.mjs.map +1 -1
  486. package/esm/cli/commands/doctor/checks/config.check.mjs +42 -0
  487. package/esm/cli/commands/doctor/checks/config.check.mjs.map +1 -0
  488. package/esm/cli/commands/doctor/checks/connectors.check.mjs +28 -0
  489. package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -0
  490. package/esm/cli/commands/doctor/checks/health.check.mjs +35 -0
  491. package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -0
  492. package/esm/cli/commands/doctor/checks/index.mjs +25 -0
  493. package/esm/cli/commands/doctor/checks/index.mjs.map +1 -0
  494. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs +90 -0
  495. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -0
  496. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs +69 -0
  497. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs.map +1 -0
  498. package/esm/cli/commands/doctor/checks/routes.check.mjs +30 -0
  499. package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -0
  500. package/esm/cli/commands/doctor/doctor-command.action.mjs +28 -0
  501. package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -0
  502. package/esm/cli/commands/doctor/format-report.mjs +44 -0
  503. package/esm/cli/commands/doctor/format-report.mjs.map +1 -0
  504. package/esm/cli/commands/doctor/run-checks.mjs +50 -0
  505. package/esm/cli/commands/doctor/run-checks.mjs.map +1 -0
  506. package/esm/cli/commands/doctor.command.mjs +29 -0
  507. package/esm/cli/commands/doctor.command.mjs.map +1 -0
  508. package/esm/cli/commands/generate/templates/stubs.mjs +9 -12
  509. package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
  510. package/esm/cli/commands/routes/format-routes-table.mjs +129 -0
  511. package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -0
  512. package/esm/cli/commands/routes/route-row.mjs +92 -0
  513. package/esm/cli/commands/routes/route-row.mjs.map +1 -0
  514. package/esm/cli/commands/routes/routes-command.action.mjs +43 -0
  515. package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -0
  516. package/esm/cli/commands/routes.command.mjs +51 -0
  517. package/esm/cli/commands/routes.command.mjs.map +1 -0
  518. package/esm/cli/commands/seed.command.mjs +5 -0
  519. package/esm/cli/commands/seed.command.mjs.map +1 -1
  520. package/esm/cli/framework-cli-commands.mjs +4 -0
  521. package/esm/cli/framework-cli-commands.mjs.map +1 -1
  522. package/esm/config/config-getter.mjs +5 -5
  523. package/esm/config/config-getter.mjs.map +1 -1
  524. package/esm/config/config-loader.mjs +2 -2
  525. package/esm/config/config-loader.mjs.map +1 -1
  526. package/esm/connectors/access-connector.mjs +2 -2
  527. package/esm/connectors/access-connector.mjs.map +1 -1
  528. package/esm/connectors/ai-connector.d.mts +43 -0
  529. package/esm/connectors/ai-connector.d.mts.map +1 -0
  530. package/esm/connectors/ai-connector.mjs +56 -0
  531. package/esm/connectors/ai-connector.mjs.map +1 -0
  532. package/esm/connectors/cache-connector.d.mts +5 -0
  533. package/esm/connectors/cache-connector.d.mts.map +1 -1
  534. package/esm/connectors/cache-connector.mjs +9 -2
  535. package/esm/connectors/cache-connector.mjs.map +1 -1
  536. package/esm/connectors/connectors-manager.d.mts +6 -2
  537. package/esm/connectors/connectors-manager.d.mts.map +1 -1
  538. package/esm/connectors/connectors-manager.mjs +8 -2
  539. package/esm/connectors/connectors-manager.mjs.map +1 -1
  540. package/esm/connectors/database-connector.mjs +2 -2
  541. package/esm/connectors/database-connector.mjs.map +1 -1
  542. package/esm/connectors/herald-connector.mjs +2 -2
  543. package/esm/connectors/herald-connector.mjs.map +1 -1
  544. package/esm/connectors/http-connector.d.mts.map +1 -1
  545. package/esm/connectors/http-connector.mjs +9 -7
  546. package/esm/connectors/http-connector.mjs.map +1 -1
  547. package/esm/connectors/index.d.mts +1 -0
  548. package/esm/connectors/index.mjs +1 -0
  549. package/esm/connectors/logger-connector.mjs +2 -2
  550. package/esm/connectors/logger-connector.mjs.map +1 -1
  551. package/esm/connectors/mail-connector.mjs +2 -2
  552. package/esm/connectors/mail-connector.mjs.map +1 -1
  553. package/esm/connectors/notifications-connector.mjs +2 -2
  554. package/esm/connectors/notifications-connector.mjs.map +1 -1
  555. package/esm/connectors/socket-connector.d.mts +16 -1
  556. package/esm/connectors/socket-connector.d.mts.map +1 -1
  557. package/esm/connectors/socket-connector.mjs +31 -8
  558. package/esm/connectors/socket-connector.mjs.map +1 -1
  559. package/esm/connectors/storage.connector.d.mts +7 -0
  560. package/esm/connectors/storage.connector.d.mts.map +1 -1
  561. package/esm/connectors/storage.connector.mjs +7 -0
  562. package/esm/connectors/storage.connector.mjs.map +1 -1
  563. package/esm/connectors/types.d.mts +3 -2
  564. package/esm/connectors/types.d.mts.map +1 -1
  565. package/esm/connectors/types.mjs +1 -0
  566. package/esm/connectors/types.mjs.map +1 -1
  567. package/esm/database/index.d.mts +2 -1
  568. package/esm/database/index.mjs +1 -0
  569. package/esm/database/seed-command-action.mjs +44 -4
  570. package/esm/database/seed-command-action.mjs.map +1 -1
  571. package/esm/database/seeds/seed-records-table-migration.mjs +36 -0
  572. package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -0
  573. package/esm/database/seeds/seeder.d.mts +22 -5
  574. package/esm/database/seeds/seeder.d.mts.map +1 -1
  575. package/esm/database/seeds/seeder.errors.d.mts +22 -0
  576. package/esm/database/seeds/seeder.errors.d.mts.map +1 -0
  577. package/esm/database/seeds/seeder.errors.mjs +29 -0
  578. package/esm/database/seeds/seeder.errors.mjs.map +1 -0
  579. package/esm/database/seeds/seeder.mjs.map +1 -1
  580. package/esm/database/seeds/seeders.manager.mjs +90 -11
  581. package/esm/database/seeds/seeders.manager.mjs.map +1 -1
  582. package/esm/database/seeds/types.d.mts +117 -1
  583. package/esm/database/seeds/types.d.mts.map +1 -1
  584. package/esm/database/seeds/utils.mjs +6 -1
  585. package/esm/database/seeds/utils.mjs.map +1 -1
  586. package/esm/dev-server/development-server.mjs +2 -14
  587. package/esm/dev-server/development-server.mjs.map +1 -1
  588. package/esm/dev-server/file-event-handler.mjs +15 -3
  589. package/esm/dev-server/file-event-handler.mjs.map +1 -1
  590. package/esm/dev-server/module-loader.d.mts +12 -0
  591. package/esm/dev-server/module-loader.d.mts.map +1 -1
  592. package/esm/dev-server/module-loader.mjs +30 -2
  593. package/esm/dev-server/module-loader.mjs.map +1 -1
  594. package/esm/generations/add-command.action.mjs +61 -12
  595. package/esm/generations/add-command.action.mjs.map +1 -1
  596. package/esm/generations/stubs.mjs +31 -1
  597. package/esm/generations/stubs.mjs.map +1 -1
  598. package/esm/http/config.mjs +2 -2
  599. package/esm/http/config.mjs.map +1 -1
  600. package/esm/http/createHttpApplication.mjs +2 -2
  601. package/esm/http/createHttpApplication.mjs.map +1 -1
  602. package/esm/http/health.d.mts +14 -0
  603. package/esm/http/health.d.mts.map +1 -1
  604. package/esm/http/health.mjs +16 -0
  605. package/esm/http/health.mjs.map +1 -1
  606. package/esm/http/middleware/cache-response-middleware.d.mts +1 -1
  607. package/esm/http/middleware/cache-response-middleware.d.mts.map +1 -1
  608. package/esm/http/middleware/cache-response-middleware.mjs +15 -6
  609. package/esm/http/middleware/cache-response-middleware.mjs.map +1 -1
  610. package/esm/http/middleware/concurrency-limit.middleware.mjs +2 -0
  611. package/esm/http/middleware/concurrency-limit.middleware.mjs.map +1 -1
  612. package/esm/http/middleware/idempotency.middleware.d.mts.map +1 -1
  613. package/esm/http/middleware/idempotency.middleware.mjs +9 -6
  614. package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
  615. package/esm/http/middleware/inject-request-context.mjs +2 -2
  616. package/esm/http/middleware/inject-request-context.mjs.map +1 -1
  617. package/esm/http/middleware/maintenance.middleware.mjs +6 -5
  618. package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
  619. package/esm/http/plugins.mjs +9 -9
  620. package/esm/http/plugins.mjs.map +1 -1
  621. package/esm/http/request.d.mts +9 -2
  622. package/esm/http/request.d.mts.map +1 -1
  623. package/esm/http/request.mjs +15 -3
  624. package/esm/http/request.mjs.map +1 -1
  625. package/esm/http/response.d.mts +12 -0
  626. package/esm/http/response.d.mts.map +1 -1
  627. package/esm/http/response.mjs +24 -7
  628. package/esm/http/response.mjs.map +1 -1
  629. package/esm/http/server.d.mts.map +1 -1
  630. package/esm/http/server.mjs +4 -4
  631. package/esm/http/server.mjs.map +1 -1
  632. package/esm/index.d.mts +9 -4
  633. package/esm/index.mjs +6 -1
  634. package/esm/node_modules/langfuse/lib/index.mjs +1827 -0
  635. package/esm/node_modules/langfuse/lib/index.mjs.map +1 -0
  636. package/esm/node_modules/langfuse-core/lib/index.mjs +1770 -0
  637. package/esm/node_modules/langfuse-core/lib/index.mjs.map +1 -0
  638. package/esm/node_modules/mustache/mustache.mjs +587 -0
  639. package/esm/node_modules/mustache/mustache.mjs.map +1 -0
  640. package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs +180 -0
  641. package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs.map +1 -0
  642. package/esm/node_modules/openai/auth/workload-identity-auth.mjs +80 -0
  643. package/esm/node_modules/openai/auth/workload-identity-auth.mjs.map +1 -0
  644. package/esm/node_modules/openai/azure.mjs +82 -0
  645. package/esm/node_modules/openai/azure.mjs.map +1 -0
  646. package/esm/node_modules/openai/client.mjs +638 -0
  647. package/esm/node_modules/openai/client.mjs.map +1 -0
  648. package/esm/node_modules/openai/core/api-promise.mjs +75 -0
  649. package/esm/node_modules/openai/core/api-promise.mjs.map +1 -0
  650. package/esm/node_modules/openai/core/error.mjs +110 -0
  651. package/esm/node_modules/openai/core/error.mjs.map +1 -0
  652. package/esm/node_modules/openai/core/pagination.mjs +160 -0
  653. package/esm/node_modules/openai/core/pagination.mjs.map +1 -0
  654. package/esm/node_modules/openai/core/resource.mjs +10 -0
  655. package/esm/node_modules/openai/core/resource.mjs.map +1 -0
  656. package/esm/node_modules/openai/core/streaming.mjs +238 -0
  657. package/esm/node_modules/openai/core/streaming.mjs.map +1 -0
  658. package/esm/node_modules/openai/index.mjs +8 -0
  659. package/esm/node_modules/openai/internal/decoders/line.mjs +91 -0
  660. package/esm/node_modules/openai/internal/decoders/line.mjs.map +1 -0
  661. package/esm/node_modules/openai/internal/detect-platform.mjs +123 -0
  662. package/esm/node_modules/openai/internal/detect-platform.mjs.map +1 -0
  663. package/esm/node_modules/openai/internal/errors.mjs +26 -0
  664. package/esm/node_modules/openai/internal/errors.mjs.map +1 -0
  665. package/esm/node_modules/openai/internal/headers.mjs +65 -0
  666. package/esm/node_modules/openai/internal/headers.mjs.map +1 -0
  667. package/esm/node_modules/openai/internal/parse.mjs +41 -0
  668. package/esm/node_modules/openai/internal/parse.mjs.map +1 -0
  669. package/esm/node_modules/openai/internal/qs/formats.mjs +12 -0
  670. package/esm/node_modules/openai/internal/qs/formats.mjs.map +1 -0
  671. package/esm/node_modules/openai/internal/qs/stringify.mjs +179 -0
  672. package/esm/node_modules/openai/internal/qs/stringify.mjs.map +1 -0
  673. package/esm/node_modules/openai/internal/qs/utils.mjs +65 -0
  674. package/esm/node_modules/openai/internal/qs/utils.mjs.map +1 -0
  675. package/esm/node_modules/openai/internal/request-options.mjs +11 -0
  676. package/esm/node_modules/openai/internal/request-options.mjs.map +1 -0
  677. package/esm/node_modules/openai/internal/shims.mjs +77 -0
  678. package/esm/node_modules/openai/internal/shims.mjs.map +1 -0
  679. package/esm/node_modules/openai/internal/to-file.mjs +63 -0
  680. package/esm/node_modules/openai/internal/to-file.mjs.map +1 -0
  681. package/esm/node_modules/openai/internal/tslib.mjs +16 -0
  682. package/esm/node_modules/openai/internal/tslib.mjs.map +1 -0
  683. package/esm/node_modules/openai/internal/uploads.mjs +94 -0
  684. package/esm/node_modules/openai/internal/uploads.mjs.map +1 -0
  685. package/esm/node_modules/openai/internal/utils/base64.mjs +22 -0
  686. package/esm/node_modules/openai/internal/utils/base64.mjs.map +1 -0
  687. package/esm/node_modules/openai/internal/utils/bytes.mjs +26 -0
  688. package/esm/node_modules/openai/internal/utils/bytes.mjs.map +1 -0
  689. package/esm/node_modules/openai/internal/utils/env.mjs +16 -0
  690. package/esm/node_modules/openai/internal/utils/env.mjs.map +1 -0
  691. package/esm/node_modules/openai/internal/utils/log.mjs +58 -0
  692. package/esm/node_modules/openai/internal/utils/log.mjs.map +1 -0
  693. package/esm/node_modules/openai/internal/utils/path.mjs +62 -0
  694. package/esm/node_modules/openai/internal/utils/path.mjs.map +1 -0
  695. package/esm/node_modules/openai/internal/utils/query.mjs +10 -0
  696. package/esm/node_modules/openai/internal/utils/query.mjs.map +1 -0
  697. package/esm/node_modules/openai/internal/utils/sleep.mjs +6 -0
  698. package/esm/node_modules/openai/internal/utils/sleep.mjs.map +1 -0
  699. package/esm/node_modules/openai/internal/utils/uuid.mjs +18 -0
  700. package/esm/node_modules/openai/internal/utils/uuid.mjs.map +1 -0
  701. package/esm/node_modules/openai/internal/utils/values.mjs +41 -0
  702. package/esm/node_modules/openai/internal/utils/values.mjs.map +1 -0
  703. package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +247 -0
  704. package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -0
  705. package/esm/node_modules/openai/lib/AssistantStream.mjs +472 -0
  706. package/esm/node_modules/openai/lib/AssistantStream.mjs.map +1 -0
  707. package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs +26 -0
  708. package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs.map +1 -0
  709. package/esm/node_modules/openai/lib/ChatCompletionStream.mjs +423 -0
  710. package/esm/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -0
  711. package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +26 -0
  712. package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +1 -0
  713. package/esm/node_modules/openai/lib/EventStream.mjs +163 -0
  714. package/esm/node_modules/openai/lib/EventStream.mjs.map +1 -0
  715. package/esm/node_modules/openai/lib/ResponsesParser.mjs +94 -0
  716. package/esm/node_modules/openai/lib/ResponsesParser.mjs.map +1 -0
  717. package/esm/node_modules/openai/lib/RunnableFunction.mjs +8 -0
  718. package/esm/node_modules/openai/lib/RunnableFunction.mjs.map +1 -0
  719. package/esm/node_modules/openai/lib/Util.mjs +19 -0
  720. package/esm/node_modules/openai/lib/Util.mjs.map +1 -0
  721. package/esm/node_modules/openai/lib/chatCompletionUtils.mjs +11 -0
  722. package/esm/node_modules/openai/lib/chatCompletionUtils.mjs.map +1 -0
  723. package/esm/node_modules/openai/lib/parser.mjs +88 -0
  724. package/esm/node_modules/openai/lib/parser.mjs.map +1 -0
  725. package/esm/node_modules/openai/lib/responses/ResponseStream.mjs +231 -0
  726. package/esm/node_modules/openai/lib/responses/ResponseStream.mjs.map +1 -0
  727. package/esm/node_modules/openai/resources/admin/admin.mjs +15 -0
  728. package/esm/node_modules/openai/resources/admin/admin.mjs.map +1 -0
  729. package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs +81 -0
  730. package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs.map +1 -0
  731. package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs +31 -0
  732. package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs.map +1 -0
  733. package/esm/node_modules/openai/resources/admin/organization/certificates.mjs +153 -0
  734. package/esm/node_modules/openai/resources/admin/organization/certificates.mjs.map +1 -0
  735. package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs +42 -0
  736. package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs.map +1 -0
  737. package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs +106 -0
  738. package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs.map +1 -0
  739. package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs +88 -0
  740. package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs.map +1 -0
  741. package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs +88 -0
  742. package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs.map +1 -0
  743. package/esm/node_modules/openai/resources/admin/organization/invites.mjs +83 -0
  744. package/esm/node_modules/openai/resources/admin/organization/invites.mjs.map +1 -0
  745. package/esm/node_modules/openai/resources/admin/organization/organization.mjs +45 -0
  746. package/esm/node_modules/openai/resources/admin/organization/organization.mjs.map +1 -0
  747. package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs +72 -0
  748. package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs.map +1 -0
  749. package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs +78 -0
  750. package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs.map +1 -0
  751. package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs +46 -0
  752. package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs.map +1 -0
  753. package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs +95 -0
  754. package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs.map +1 -0
  755. package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs +91 -0
  756. package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs.map +1 -0
  757. package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs +45 -0
  758. package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs.map +1 -0
  759. package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs +63 -0
  760. package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs.map +1 -0
  761. package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs +137 -0
  762. package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs.map +1 -0
  763. package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs +51 -0
  764. package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs.map +1 -0
  765. package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs +108 -0
  766. package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs.map +1 -0
  767. package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs +112 -0
  768. package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs.map +1 -0
  769. package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs +106 -0
  770. package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs.map +1 -0
  771. package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs +91 -0
  772. package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs.map +1 -0
  773. package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs +118 -0
  774. package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs.map +1 -0
  775. package/esm/node_modules/openai/resources/admin/organization/roles.mjs +96 -0
  776. package/esm/node_modules/openai/resources/admin/organization/roles.mjs.map +1 -0
  777. package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs +97 -0
  778. package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs.map +1 -0
  779. package/esm/node_modules/openai/resources/admin/organization/usage.mjs +207 -0
  780. package/esm/node_modules/openai/resources/admin/organization/usage.mjs.map +1 -0
  781. package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs +88 -0
  782. package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs.map +1 -0
  783. package/esm/node_modules/openai/resources/admin/organization/users/users.mjs +82 -0
  784. package/esm/node_modules/openai/resources/admin/organization/users/users.mjs.map +1 -0
  785. package/esm/node_modules/openai/resources/audio/audio.mjs +21 -0
  786. package/esm/node_modules/openai/resources/audio/audio.mjs.map +1 -0
  787. package/esm/node_modules/openai/resources/audio/speech.mjs +39 -0
  788. package/esm/node_modules/openai/resources/audio/speech.mjs.map +1 -0
  789. package/esm/node_modules/openai/resources/audio/transcriptions.mjs +22 -0
  790. package/esm/node_modules/openai/resources/audio/transcriptions.mjs.map +1 -0
  791. package/esm/node_modules/openai/resources/audio/translations.mjs +21 -0
  792. package/esm/node_modules/openai/resources/audio/translations.mjs.map +1 -0
  793. package/esm/node_modules/openai/resources/batches.mjs +54 -0
  794. package/esm/node_modules/openai/resources/batches.mjs.map +1 -0
  795. package/esm/node_modules/openai/resources/beta/assistants.mjs +78 -0
  796. package/esm/node_modules/openai/resources/beta/assistants.mjs.map +1 -0
  797. package/esm/node_modules/openai/resources/beta/beta.mjs +24 -0
  798. package/esm/node_modules/openai/resources/beta/beta.mjs.map +1 -0
  799. package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs +18 -0
  800. package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs.map +1 -0
  801. package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs +49 -0
  802. package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs.map +1 -0
  803. package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs +85 -0
  804. package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs.map +1 -0
  805. package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs +21 -0
  806. package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs.map +1 -0
  807. package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs +33 -0
  808. package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs.map +1 -0
  809. package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs +33 -0
  810. package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs.map +1 -0
  811. package/esm/node_modules/openai/resources/beta/threads/messages.mjs +83 -0
  812. package/esm/node_modules/openai/resources/beta/threads/messages.mjs.map +1 -0
  813. package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs +183 -0
  814. package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +1 -0
  815. package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs +45 -0
  816. package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +1 -0
  817. package/esm/node_modules/openai/resources/beta/threads/threads.mjs +101 -0
  818. package/esm/node_modules/openai/resources/beta/threads/threads.mjs.map +1 -0
  819. package/esm/node_modules/openai/resources/chat/chat.mjs +15 -0
  820. package/esm/node_modules/openai/resources/chat/chat.mjs.map +1 -0
  821. package/esm/node_modules/openai/resources/chat/completions/completions.mjs +123 -0
  822. package/esm/node_modules/openai/resources/chat/completions/completions.mjs.map +1 -0
  823. package/esm/node_modules/openai/resources/chat/completions/index.mjs +7 -0
  824. package/esm/node_modules/openai/resources/chat/completions/messages.mjs +35 -0
  825. package/esm/node_modules/openai/resources/chat/completions/messages.mjs.map +1 -0
  826. package/esm/node_modules/openai/resources/chat/index.mjs +5 -0
  827. package/esm/node_modules/openai/resources/completions.mjs +20 -0
  828. package/esm/node_modules/openai/resources/completions.mjs.map +1 -0
  829. package/esm/node_modules/openai/resources/containers/containers.mjs +57 -0
  830. package/esm/node_modules/openai/resources/containers/containers.mjs.map +1 -0
  831. package/esm/node_modules/openai/resources/containers/files/content.mjs +23 -0
  832. package/esm/node_modules/openai/resources/containers/files/content.mjs.map +1 -0
  833. package/esm/node_modules/openai/resources/containers/files/files.mjs +63 -0
  834. package/esm/node_modules/openai/resources/containers/files/files.mjs.map +1 -0
  835. package/esm/node_modules/openai/resources/conversations/conversations.mjs +57 -0
  836. package/esm/node_modules/openai/resources/conversations/conversations.mjs.map +1 -0
  837. package/esm/node_modules/openai/resources/conversations/items.mjs +57 -0
  838. package/esm/node_modules/openai/resources/conversations/items.mjs.map +1 -0
  839. package/esm/node_modules/openai/resources/embeddings.mjs +48 -0
  840. package/esm/node_modules/openai/resources/embeddings.mjs.map +1 -0
  841. package/esm/node_modules/openai/resources/evals/evals.mjs +73 -0
  842. package/esm/node_modules/openai/resources/evals/evals.mjs.map +1 -0
  843. package/esm/node_modules/openai/resources/evals/runs/output-items.mjs +35 -0
  844. package/esm/node_modules/openai/resources/evals/runs/output-items.mjs.map +1 -0
  845. package/esm/node_modules/openai/resources/evals/runs/runs.mjs +72 -0
  846. package/esm/node_modules/openai/resources/evals/runs/runs.mjs.map +1 -0
  847. package/esm/node_modules/openai/resources/files.mjs +111 -0
  848. package/esm/node_modules/openai/resources/files.mjs.map +1 -0
  849. package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs +15 -0
  850. package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs.map +1 -0
  851. package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs +60 -0
  852. package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs.map +1 -0
  853. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs +15 -0
  854. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs.map +1 -0
  855. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs +102 -0
  856. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs.map +1 -0
  857. package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +24 -0
  858. package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +1 -0
  859. package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +34 -0
  860. package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +1 -0
  861. package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +148 -0
  862. package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +1 -0
  863. package/esm/node_modules/openai/resources/fine-tuning/methods.mjs +8 -0
  864. package/esm/node_modules/openai/resources/fine-tuning/methods.mjs.map +1 -0
  865. package/esm/node_modules/openai/resources/graders/grader-models.mjs +8 -0
  866. package/esm/node_modules/openai/resources/graders/grader-models.mjs.map +1 -0
  867. package/esm/node_modules/openai/resources/graders/graders.mjs +15 -0
  868. package/esm/node_modules/openai/resources/graders/graders.mjs.map +1 -0
  869. package/esm/node_modules/openai/resources/images.mjs +46 -0
  870. package/esm/node_modules/openai/resources/images.mjs.map +1 -0
  871. package/esm/node_modules/openai/resources/index.mjs +27 -0
  872. package/esm/node_modules/openai/resources/models.mjs +44 -0
  873. package/esm/node_modules/openai/resources/models.mjs.map +1 -0
  874. package/esm/node_modules/openai/resources/moderations.mjs +23 -0
  875. package/esm/node_modules/openai/resources/moderations.mjs.map +1 -0
  876. package/esm/node_modules/openai/resources/realtime/calls.mjs +79 -0
  877. package/esm/node_modules/openai/resources/realtime/calls.mjs.map +1 -0
  878. package/esm/node_modules/openai/resources/realtime/client-secrets.mjs +39 -0
  879. package/esm/node_modules/openai/resources/realtime/client-secrets.mjs.map +1 -0
  880. package/esm/node_modules/openai/resources/realtime/realtime.mjs +18 -0
  881. package/esm/node_modules/openai/resources/realtime/realtime.mjs.map +1 -0
  882. package/esm/node_modules/openai/resources/responses/input-items.mjs +31 -0
  883. package/esm/node_modules/openai/resources/responses/input-items.mjs.map +1 -0
  884. package/esm/node_modules/openai/resources/responses/input-tokens.mjs +27 -0
  885. package/esm/node_modules/openai/resources/responses/input-tokens.mjs.map +1 -0
  886. package/esm/node_modules/openai/resources/responses/responses.mjs +110 -0
  887. package/esm/node_modules/openai/resources/responses/responses.mjs.map +1 -0
  888. package/esm/node_modules/openai/resources/skills/content.mjs +22 -0
  889. package/esm/node_modules/openai/resources/skills/content.mjs.map +1 -0
  890. package/esm/node_modules/openai/resources/skills/skills.mjs +69 -0
  891. package/esm/node_modules/openai/resources/skills/skills.mjs.map +1 -0
  892. package/esm/node_modules/openai/resources/skills/versions/content.mjs +23 -0
  893. package/esm/node_modules/openai/resources/skills/versions/content.mjs.map +1 -0
  894. package/esm/node_modules/openai/resources/skills/versions/versions.mjs +58 -0
  895. package/esm/node_modules/openai/resources/skills/versions/versions.mjs.map +1 -0
  896. package/esm/node_modules/openai/resources/uploads/parts.mjs +34 -0
  897. package/esm/node_modules/openai/resources/uploads/parts.mjs.map +1 -0
  898. package/esm/node_modules/openai/resources/uploads/uploads.mjs +84 -0
  899. package/esm/node_modules/openai/resources/uploads/uploads.mjs.map +1 -0
  900. package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs +126 -0
  901. package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs.map +1 -0
  902. package/esm/node_modules/openai/resources/vector-stores/files.mjs +147 -0
  903. package/esm/node_modules/openai/resources/vector-stores/files.mjs.map +1 -0
  904. package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs +87 -0
  905. package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs.map +1 -0
  906. package/esm/node_modules/openai/resources/videos.mjs +115 -0
  907. package/esm/node_modules/openai/resources/videos.mjs.map +1 -0
  908. package/esm/node_modules/openai/resources/webhooks/index.mjs +3 -0
  909. package/esm/node_modules/openai/resources/webhooks/webhooks.mjs +69 -0
  910. package/esm/node_modules/openai/resources/webhooks/webhooks.mjs.map +1 -0
  911. package/esm/node_modules/openai/resources/webhooks.mjs +4 -0
  912. package/esm/node_modules/openai/streaming.mjs +3 -0
  913. package/esm/node_modules/openai/version.mjs +6 -0
  914. package/esm/node_modules/openai/version.mjs.map +1 -0
  915. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +37 -1
  916. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
  917. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs +71 -5
  918. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
  919. package/esm/repositories/adapters/cascade/filter-applicator.mjs +17 -3
  920. package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
  921. package/esm/repositories/contracts/index.d.mts +1 -1
  922. package/esm/repositories/contracts/query-builder.contract.d.mts +87 -1
  923. package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
  924. package/esm/repositories/index.d.mts +1 -1
  925. package/esm/repositories/repository.manager.d.mts +110 -2
  926. package/esm/repositories/repository.manager.d.mts.map +1 -1
  927. package/esm/repositories/repository.manager.mjs +207 -25
  928. package/esm/repositories/repository.manager.mjs.map +1 -1
  929. package/esm/router/route-registry.mjs +19 -10
  930. package/esm/router/route-registry.mjs.map +1 -1
  931. package/esm/router/router.d.mts +9 -0
  932. package/esm/router/router.d.mts.map +1 -1
  933. package/esm/router/router.mjs +28 -5
  934. package/esm/router/router.mjs.map +1 -1
  935. package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
  936. package/esm/storage/drivers/cloud-driver.mjs +48 -12
  937. package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
  938. package/esm/storage/drivers/do-spaces-driver.mjs +1 -1
  939. package/esm/storage/drivers/do-spaces-driver.mjs.map +1 -1
  940. package/esm/storage/drivers/local-driver.d.mts +8 -0
  941. package/esm/storage/drivers/local-driver.d.mts.map +1 -1
  942. package/esm/storage/drivers/local-driver.mjs +19 -4
  943. package/esm/storage/drivers/local-driver.mjs.map +1 -1
  944. package/esm/storage/drivers/r2-driver.mjs +1 -1
  945. package/esm/storage/drivers/r2-driver.mjs.map +1 -1
  946. package/esm/storage/drivers/s3-driver.mjs +1 -1
  947. package/esm/storage/drivers/s3-driver.mjs.map +1 -1
  948. package/esm/storage/index.d.mts +4 -1
  949. package/esm/storage/index.mjs +3 -0
  950. package/esm/storage/scoped-storage.d.mts +8 -4
  951. package/esm/storage/scoped-storage.d.mts.map +1 -1
  952. package/esm/storage/scoped-storage.mjs +21 -6
  953. package/esm/storage/scoped-storage.mjs.map +1 -1
  954. package/esm/storage/storage.d.mts +12 -4
  955. package/esm/storage/storage.d.mts.map +1 -1
  956. package/esm/storage/storage.mjs +23 -9
  957. package/esm/storage/storage.mjs.map +1 -1
  958. package/esm/storage/types.d.mts +33 -5
  959. package/esm/storage/types.d.mts.map +1 -1
  960. package/esm/storage/utils/contain-path.d.mts +23 -0
  961. package/esm/storage/utils/contain-path.d.mts.map +1 -0
  962. package/esm/storage/utils/contain-path.mjs +35 -0
  963. package/esm/storage/utils/contain-path.mjs.map +1 -0
  964. package/esm/storage/utils/safe-fetch.d.mts +68 -0
  965. package/esm/storage/utils/safe-fetch.d.mts.map +1 -0
  966. package/esm/storage/utils/safe-fetch.mjs +205 -0
  967. package/esm/storage/utils/safe-fetch.mjs.map +1 -0
  968. package/esm/storage/utils/storage-error.d.mts +35 -0
  969. package/esm/storage/utils/storage-error.d.mts.map +1 -0
  970. package/esm/storage/utils/storage-error.mjs +17 -0
  971. package/esm/storage/utils/storage-error.mjs.map +1 -0
  972. package/esm/use-cases/use-case-pipeline.mjs +4 -1
  973. package/esm/use-cases/use-case-pipeline.mjs.map +1 -1
  974. package/esm/use-cases/use-case.mjs +12 -4
  975. package/esm/use-cases/use-case.mjs.map +1 -1
  976. package/esm/use-cases/use-cases-registry.d.mts +12 -4
  977. package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
  978. package/esm/use-cases/use-cases-registry.mjs +13 -3
  979. package/esm/use-cases/use-cases-registry.mjs.map +1 -1
  980. package/esm/utils/npm-registry.d.mts +1 -1
  981. package/esm/utils/npm-registry.mjs +2 -2
  982. package/esm/utils/npm-registry.mjs.map +1 -1
  983. package/esm/utils/paths.mjs +2 -2
  984. package/esm/utils/paths.mjs.map +1 -1
  985. package/esm/validation/validateAll.mjs +2 -2
  986. package/esm/validation/validateAll.mjs.map +1 -1
  987. package/llms-full.txt +456 -46
  988. package/llms.txt +4 -2
  989. package/package.json +9 -9
  990. package/skills/README.md +65 -0
  991. package/skills/add-connector/SKILL.md +6 -1
  992. package/skills/configure-app/SKILL.md +23 -0
  993. package/skills/health-checks/SKILL.md +13 -0
  994. package/skills/use-repository/SKILL.md +38 -1
  995. package/skills/warlock-doctor/SKILL.md +135 -0
  996. package/skills/warlock-routes/SKILL.md +91 -0
  997. package/skills/write-seeder/SKILL.md +143 -45
@@ -0,0 +1,232 @@
1
+ import { InvalidRequestError } from "../errors/invalid-request-error.mjs";
2
+ import { OutboundPolicyError } from "../errors/outbound-policy-error.mjs";
3
+ import "../errors/index.mjs";
4
+ import { fetchTextWithPolicy } from "../security/outbound-policy.mjs";
5
+ import { resolveAttachment } from "./resolve-attachment.mjs";
6
+ import { extname, isAbsolute, relative, resolve } from "node:path";
7
+ import { readFile } from "node:fs/promises";
8
+
9
+ //#region ../@warlock.js/ai/src/utils/prepare-attachment-part.ts
10
+ const IMAGE_EXTENSIONS_TO_MEDIA_TYPE = {
11
+ ".png": "image/png",
12
+ ".jpg": "image/jpeg",
13
+ ".jpeg": "image/jpeg",
14
+ ".webp": "image/webp",
15
+ ".gif": "image/gif"
16
+ };
17
+ const TEXT_EXTENSIONS = new Set([".txt"]);
18
+ const AUDIO_EXTENSIONS_TO_MEDIA_TYPE = {
19
+ ".mp3": "audio/mpeg",
20
+ ".wav": "audio/wav",
21
+ ".m4a": "audio/mp4",
22
+ ".ogg": "audio/ogg",
23
+ ".weba": "audio/webm"
24
+ };
25
+ const PDF_EXTENSIONS = new Set([".pdf"]);
26
+ /**
27
+ * Convert a user-supplied `Attachment` into a provider-ready
28
+ * `ContentPart` the model adapter can consume without doing any I/O of
29
+ * its own.
30
+ *
31
+ * Kind resolution:
32
+ * - Tagged `{ type: "image", source }` / `{ type: "text", source }`
33
+ * trusts the caller's intent.
34
+ * - Shorthand (raw string / `StorageFileShape`) infers from the file
35
+ * extension. Image extensions (`.png`/`.jpg`/`.jpeg`/`.webp`/`.gif`)
36
+ * map to `"image"`. `.txt` maps to `"text"`. Anything else throws
37
+ * `InvalidRequestError` — silent inference on ambiguous inputs
38
+ * causes silent bugs.
39
+ *
40
+ * Local paths are read from disk; images are base64-encoded inline,
41
+ * text files are read as UTF-8 strings and returned as a `text`
42
+ * `ContentPart`. Remote URLs for image attachments are passed through
43
+ * unchanged; remote URLs for text attachments are fetched so the
44
+ * adapter never needs network access.
45
+ *
46
+ * @example
47
+ * await prepareAttachmentPart("./photo.png");
48
+ * // → { type: "image", source: { base64: "...", mediaType: "image/png" } }
49
+ *
50
+ * @example
51
+ * await prepareAttachmentPart({ type: "text", source: "./notes.txt" });
52
+ * // → { type: "text", text: "<file contents>" }
53
+ *
54
+ * **Trust boundary (S1).** Attachment references are often user-controlled,
55
+ * so server-side I/O is policy-gated by `policy` ({@link AttachmentPolicy}):
56
+ * remote text fetches are default-deny and, when enabled, run through the
57
+ * shared `OutboundPolicy` (scheme/host/private-IP/max-bytes/timeout); local
58
+ * reads honor an `allowedRoots` sandbox; bare-string local paths warn
59
+ * (staged deprecation). URL *image* attachments are passed to the provider
60
+ * untouched (never fetched here).
61
+ */
62
+ async function prepareAttachmentPart(attachment, policy) {
63
+ const kind = resolveKind(attachment);
64
+ const bareString = typeof attachment === "string";
65
+ if (kind === "text") return prepareTextPart(attachment, policy, bareString);
66
+ if (kind === "image") return prepareImagePart(attachment, policy, bareString);
67
+ return prepareBinaryPart(attachment, kind, policy, bareString);
68
+ }
69
+ /**
70
+ * Decide whether the attachment is text or image. Tagged forms win
71
+ * immediately; for shorthand we inspect the extension. Throws if the
72
+ * shorthand doesn't look like anything we recognize.
73
+ */
74
+ function resolveKind(attachment) {
75
+ if (isTaggedAttachment(attachment)) return attachment.type;
76
+ const path = extractPath(attachment);
77
+ const extension = path ? extname(stripQuery(path)).toLowerCase() : "";
78
+ if (IMAGE_EXTENSIONS_TO_MEDIA_TYPE[extension]) return "image";
79
+ if (TEXT_EXTENSIONS.has(extension)) return "text";
80
+ if (PDF_EXTENSIONS.has(extension)) return "pdf";
81
+ if (AUDIO_EXTENSIONS_TO_MEDIA_TYPE[extension]) return "audio";
82
+ throw new InvalidRequestError("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)");
83
+ }
84
+ /**
85
+ * Produce a `pdf` / `audio` ContentPart (A2). URLs pass through; local
86
+ * paths are read and base64-encoded with a media type inferred from the
87
+ * kind (`application/pdf`) or extension (audio); inline base64 passes
88
+ * through. Same `AttachmentPolicy` gating as image/text reads.
89
+ */
90
+ async function prepareBinaryPart(attachment, kind, policy, bareString) {
91
+ const resolved = resolveAttachment(attachment);
92
+ if (resolved.type === "url") return {
93
+ type: kind,
94
+ source: { url: resolved.value }
95
+ };
96
+ if (resolved.type === "base64") return {
97
+ type: kind,
98
+ source: {
99
+ base64: resolved.value,
100
+ mediaType: resolved.mediaType
101
+ }
102
+ };
103
+ const mediaType = kind === "pdf" ? "application/pdf" : inferAudioMediaType(resolved.value);
104
+ if (!mediaType) throw new InvalidRequestError(`Cannot infer media type for ${kind} path "${resolved.value}" — use a recognized extension or pass \`{ type: '${kind}', source: { base64, mediaType } }\``, { context: { path: resolved.value } });
105
+ enforceLocalPathPolicy(resolved.value, bareString, policy);
106
+ return {
107
+ type: kind,
108
+ source: {
109
+ base64: (await readFile(resolved.value)).toString("base64"),
110
+ mediaType
111
+ }
112
+ };
113
+ }
114
+ /** Infer an audio media type from a path's extension. */
115
+ function inferAudioMediaType(path) {
116
+ return AUDIO_EXTENSIONS_TO_MEDIA_TYPE[extname(stripQuery(path)).toLowerCase()];
117
+ }
118
+ /**
119
+ * Produce an `image` ContentPart. URLs pass through; paths are
120
+ * read from disk and base64-encoded with an inferred media type.
121
+ * Inline base64 attachments pass through unchanged.
122
+ */
123
+ async function prepareImagePart(attachment, policy, bareString) {
124
+ const inferredMediaType = isTaggedAttachment(attachment) ? void 0 : inferImageMediaType(attachment);
125
+ const resolved = resolveAttachment(attachment);
126
+ if (resolved.type === "url") return {
127
+ type: "image",
128
+ source: { url: resolved.value }
129
+ };
130
+ if (resolved.type === "base64") return {
131
+ type: "image",
132
+ source: {
133
+ base64: resolved.value,
134
+ mediaType: resolved.mediaType
135
+ }
136
+ };
137
+ const mediaType = inferredMediaType ?? inferImageMediaType(resolved.value);
138
+ if (!mediaType) throw new InvalidRequestError(`Cannot infer media type for path "${resolved.value}" — use a recognized image extension or pass \`{ type: 'image', source: { base64, mediaType } }\``, { context: { path: resolved.value } });
139
+ enforceLocalPathPolicy(resolved.value, bareString, policy);
140
+ return {
141
+ type: "image",
142
+ source: {
143
+ base64: (await readFile(resolved.value)).toString("base64"),
144
+ mediaType
145
+ }
146
+ };
147
+ }
148
+ /**
149
+ * Produce a `text` ContentPart. URLs are fetched as UTF-8, paths are
150
+ * read from disk as UTF-8, inline base64 is decoded to UTF-8. The
151
+ * result joins the conversation as an additional text part the model
152
+ * sees before responding.
153
+ */
154
+ async function prepareTextPart(attachment, policy, bareString) {
155
+ const resolved = resolveAttachment(attachment);
156
+ if (resolved.type === "url") {
157
+ if (!policy?.allowRemoteFetch) throw new OutboundPolicyError(`remote text attachment fetch is disabled by default — set \`attachmentPolicy.allowRemoteFetch: true\` (with an \`outbound\` policy) to fetch "${resolved.value}"`, { context: { url: resolved.value } });
158
+ const result = await fetchTextWithPolicy(resolved.value, policy.outbound ?? {});
159
+ if (!result.ok) throw new InvalidRequestError(`Failed to fetch text attachment "${resolved.value}" — status ${result.status}`, { context: {
160
+ url: resolved.value,
161
+ status: result.status
162
+ } });
163
+ return {
164
+ type: "text",
165
+ text: result.text
166
+ };
167
+ }
168
+ if (resolved.type === "base64") return {
169
+ type: "text",
170
+ text: Buffer.from(resolved.value, "base64").toString("utf8")
171
+ };
172
+ enforceLocalPathPolicy(resolved.value, bareString, policy);
173
+ return {
174
+ type: "text",
175
+ text: await readFile(resolved.value, "utf8")
176
+ };
177
+ }
178
+ /** Process-lifetime flag so the bare-string deprecation warns at most once. */
179
+ let warnedBareLocalPath = false;
180
+ /**
181
+ * Enforce the local-file half of {@link AttachmentPolicy} (S1):
182
+ *
183
+ * - **Bare-string local paths** are staged for deprecation. With
184
+ * `allowBareLocalPaths: false` they hard-deny now; otherwise they warn
185
+ * once (outside tests) — the typed `StorageFile.absolutePath` route is
186
+ * the supported way to read a local file.
187
+ * - **`allowedRoots` sandbox** — when set, the resolved path must live
188
+ * inside one of the roots, else the read is refused.
189
+ */
190
+ function enforceLocalPathPolicy(path, bareString, policy) {
191
+ if (bareString) {
192
+ if (policy?.allowBareLocalPaths === false) throw new OutboundPolicyError(`local file attachment via a bare string path ("${path}") is disabled — pass a typed \`{ type, source: { absolutePath } }\` StorageFile, or set \`attachmentPolicy.allowBareLocalPaths: true\``, { context: { path } });
193
+ if (!warnedBareLocalPath && !process.env.VITEST && process.env.NODE_ENV !== "test") {
194
+ warnedBareLocalPath = true;
195
+ console.warn("[warlock-ai] reading a local file attachment from a bare string path is deprecated and will be denied by default in a future minor. Pass a typed `{ type, source: { absolutePath } }` StorageFile and confine reads with `attachmentPolicy.allowedRoots`.");
196
+ }
197
+ }
198
+ const roots = policy?.allowedRoots;
199
+ if (roots && roots.length > 0) {
200
+ const target = resolve(path);
201
+ if (!roots.some((root) => {
202
+ const rel = relative(resolve(root), target);
203
+ return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
204
+ })) throw new OutboundPolicyError(`local file attachment "${path}" is outside the allowed roots`, { context: {
205
+ path,
206
+ allowedRoots: roots
207
+ } });
208
+ }
209
+ }
210
+ function isTaggedAttachment(attachment) {
211
+ return typeof attachment === "object" && attachment !== null && "type" in attachment;
212
+ }
213
+ function inferImageMediaType(input) {
214
+ const path = extractPath(input);
215
+ if (!path) return;
216
+ return IMAGE_EXTENSIONS_TO_MEDIA_TYPE[extname(stripQuery(path)).toLowerCase()];
217
+ }
218
+ function extractPath(input) {
219
+ if (typeof input === "string") return input;
220
+ if (typeof input === "object" && input !== null) {
221
+ const storage = input;
222
+ return storage.url ?? storage.absolutePath;
223
+ }
224
+ }
225
+ function stripQuery(path) {
226
+ const queryIndex = path.indexOf("?");
227
+ return queryIndex === -1 ? path : path.slice(0, queryIndex);
228
+ }
229
+
230
+ //#endregion
231
+ export { prepareAttachmentPart };
232
+ //# sourceMappingURL=prepare-attachment-part.mjs.map
@@ -0,0 +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,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,UAAU;AAC/D;;;;;;AAOA,SAAS,YAAY,YAAwC;CAC3D,IAAI,mBAAmB,UAAU,GAC/B,OAAO,WAAW;CAGpB,MAAM,OAAO,YAAY,UAAU;CACnC,MAAM,YAAY,OAAO,QAAQ,WAAW,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI;CAEnE,IAAI,+BAA+B,YACjC,OAAO;CAGT,IAAI,gBAAgB,IAAI,SAAS,GAC/B,OAAO;CAGT,IAAI,eAAe,IAAI,SAAS,GAC9B,OAAO;CAGT,IAAI,+BAA+B,YACjC,OAAO;CAGT,MAAM,IAAI,oBACR,kOACF;AACF;;;;;;;AAQA,eAAe,kBACb,YACA,MACA,QACA,YACsB;CACtB,MAAM,WAAW,kBAAkB,UAAU;CAE7C,IAAI,SAAS,SAAS,OACpB,OAAO;EAAE,MAAM;EAAM,QAAQ,EAAE,KAAK,SAAS,MAAM;CAAE;CAGvD,IAAI,SAAS,SAAS,UACpB,OAAO;EAAE,MAAM;EAAM,QAAQ;GAAE,QAAQ,SAAS;GAAO,WAAW,SAAS;EAAU;CAAE;CAGzF,MAAM,YACJ,SAAS,QAAQ,oBAAoB,oBAAoB,SAAS,KAAK;CAEzE,IAAI,CAAC,WACH,MAAM,IAAI,oBACR,+BAA+B,KAAK,SAAS,SAAS,MAAM,oDAC5C,KAAK,uCACrB,EAAE,SAAS,EAAE,MAAM,SAAS,MAAM,EAAE,CACtC;CAGF,uBAAuB,SAAS,OAAO,YAAY,MAAM;CAGzD,OAAO;EAAE,MAAM;EAAM,QAAQ;GAAE,SAAQ,MAFnB,SAAS,SAAS,KAAK,EAEC,CAAC,SAAS,QAAQ;GAAG;EAAU;CAAE;AAC/E;;AAGA,SAAS,oBAAoB,MAAkC;CAC7D,OAAO,+BAA+B,QAAQ,WAAW,IAAI,CAAC,CAAC,CAAC,YAAY;AAC9E;;;;;;AAOA,eAAe,iBACb,YACA,QACA,YACsB;CACtB,MAAM,oBAAoB,mBAAmB,UAAU,IACnD,SACA,oBAAoB,UAAU;CAElC,MAAM,WAAW,kBAAkB,UAAU;CAE7C,IAAI,SAAS,SAAS,OAGpB,OAAO;EAAE,MAAM;EAAS,QAAQ,EAAE,KAAK,SAAS,MAAM;CAAE;CAG1D,IAAI,SAAS,SAAS,UACpB,OAAO;EACL,MAAM;EACN,QAAQ;GAAE,QAAQ,SAAS;GAAO,WAAW,SAAS;EAAU;CAClE;CAGF,MAAM,YAAY,qBAAqB,oBAAoB,SAAS,KAAK;CAEzE,IAAI,CAAC,WACH,MAAM,IAAI,oBACR,qCAAqC,SAAS,MAAM,oGAEpD,EAAE,SAAS,EAAE,MAAM,SAAS,MAAM,EAAE,CACtC;CAGF,uBAAuB,SAAS,OAAO,YAAY,MAAM;CAGzD,OAAO;EACL,MAAM;EACN,QAAQ;GAAE,SAAQ,MAJA,SAAS,SAAS,KAAK,EAIlB,CAAC,SAAS,QAAQ;GAAG;EAAU;CACxD;AACF;;;;;;;AAQA,eAAe,gBACb,YACA,QACA,YACsB;CACtB,MAAM,WAAW,kBAAkB,UAAU;CAE7C,IAAI,SAAS,SAAS,OAAO;EAK3B,IAAI,CAAC,QAAQ,kBACX,MAAM,IAAI,oBACR,iJAAiJ,SAAS,MAAM,IAChK,EAAE,SAAS,EAAE,KAAK,SAAS,MAAM,EAAE,CACrC;EAGF,MAAM,SAAS,MAAM,oBAAoB,SAAS,OAAO,OAAO,YAAY,CAAC,CAAC;EAE9E,IAAI,CAAC,OAAO,IACV,MAAM,IAAI,oBACR,oCAAoC,SAAS,MAAM,aAAa,OAAO,UACvE,EAAE,SAAS;GAAE,KAAK,SAAS;GAAO,QAAQ,OAAO;EAAO,EAAE,CAC5D;EAGF,OAAO;GAAE,MAAM;GAAQ,MAAM,OAAO;EAAK;CAC3C;CAEA,IAAI,SAAS,SAAS,UAGpB,OAAO;EAAE,MAAM;EAAQ,MAFP,OAAO,KAAK,SAAS,OAAO,QAAQ,CAAC,CAAC,SAAS,MAE5B;CAAE;CAGvC,uBAAuB,SAAS,OAAO,YAAY,MAAM;CAGzD,OAAO;EAAE,MAAM;EAAQ,MAAM,MAFT,SAAS,SAAS,OAAO,MAAM;CAEhB;AACrC;;AAGA,IAAI,sBAAsB;;;;;;;;;;;AAY1B,SAAS,uBACP,MACA,YACA,QACM;CACN,IAAI,YAAY;EACd,IAAI,QAAQ,wBAAwB,OAClC,MAAM,IAAI,oBACR,kDAAkD,KAAK,0IACvD,EAAE,SAAS,EAAE,KAAK,EAAE,CACtB;EAGF,IAAI,CAAC,uBAAuB,CAAC,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,QAAQ;GAClF,sBAAsB;GACtB,QAAQ,KACN,2PAEF;EACF;CACF;CAEA,MAAM,QAAQ,QAAQ;CACtB,IAAI,SAAS,MAAM,SAAS,GAAG;EAC7B,MAAM,SAASA,QAAY,IAAI;EAM/B,IAAI,CALW,MAAM,MAAK,SAAQ;GAChC,MAAM,MAAM,SAASA,QAAY,IAAI,GAAG,MAAM;GAC9C,OAAO,QAAQ,MAAO,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG;EAChE,CAEU,GACR,MAAM,IAAI,oBACR,0BAA0B,KAAK,iCAC/B,EAAE,SAAS;GAAE;GAAM,cAAc;EAAM,EAAE,CAC3C;CAEJ;AACF;AAEA,SAAS,mBACP,YACqD;CACrD,OACE,OAAO,eAAe,YACtB,eAAe,QACf,UAAU;AAEd;AAEA,SAAS,oBAAoB,OAAoC;CAC/D,MAAM,OAAO,YAAY,KAAK;CAE9B,IAAI,CAAC,MACH;CAKF,OAAO,+BAFW,QAAQ,WAAW,IAAI,CAAC,CAAC,CAAC,YAEE;AAChD;AAEA,SAAS,YAAY,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"}
@@ -0,0 +1,74 @@
1
+ import { InvalidRequestError } from "../errors/invalid-request-error.mjs";
2
+ import "../errors/index.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/utils/resolve-attachment.ts
5
+ const REMOTE_URL_PATTERN = /^https?:\/\//i;
6
+ /**
7
+ * Normalize a user-supplied `Attachment` (or bare `AttachmentSource`)
8
+ * into a `ResolvedAttachment` the agent can hand to file-reading code
9
+ * without re-discriminating the input variant.
10
+ *
11
+ * Resolution rules:
12
+ * - `{ base64, mediaType }` → `{ type: "base64", value, mediaType }`.
13
+ * - `StorageFileShape` (`{ url?, absolutePath? }`) → `absolutePath` wins
14
+ * over `url` when both are present (prefer the local file over an extra
15
+ * remote hop). Absolute path becomes `{ type: "path" }`; url becomes
16
+ * `{ type: "url" }`.
17
+ * - String starting with `http://` / `https://` → `{ type: "url" }`.
18
+ * - Any other string → `{ type: "path" }`.
19
+ * - Tagged `{ type: "image" | "text", source }` → recurses into `source`.
20
+ *
21
+ * Throws `InvalidRequestError` on obviously invalid input (empty
22
+ * string, storage object with neither url nor absolutePath, missing
23
+ * source field).
24
+ *
25
+ * @example
26
+ * resolveAttachment("https://cdn.example.com/doc.pdf");
27
+ * // → { type: "url", value: "https://cdn.example.com/doc.pdf" }
28
+ *
29
+ * @example
30
+ * resolveAttachment({ type: "image", source: "/tmp/x.png" });
31
+ * // → { type: "path", value: "/tmp/x.png" }
32
+ */
33
+ function resolveAttachment(attachment) {
34
+ if (typeof attachment === "object" && attachment !== null && "type" in attachment) return resolveSource(attachment.source);
35
+ return resolveSource(attachment);
36
+ }
37
+ function resolveSource(source) {
38
+ if (typeof source === "string") {
39
+ if (!source) throw new InvalidRequestError("Cannot resolve empty attachment string");
40
+ if (REMOTE_URL_PATTERN.test(source)) return {
41
+ type: "url",
42
+ value: source
43
+ };
44
+ return {
45
+ type: "path",
46
+ value: source
47
+ };
48
+ }
49
+ if ("url" in source || "absolutePath" in source) {
50
+ const storage = source;
51
+ if (storage.absolutePath) return {
52
+ type: "path",
53
+ value: storage.absolutePath
54
+ };
55
+ if (storage.url) return {
56
+ type: "url",
57
+ value: storage.url
58
+ };
59
+ throw new InvalidRequestError("Storage attachment has neither url nor absolutePath");
60
+ }
61
+ if ("base64" in source) {
62
+ if (!source.base64 || !source.mediaType) throw new InvalidRequestError("Inline attachment requires both `base64` and `mediaType`");
63
+ return {
64
+ type: "base64",
65
+ value: source.base64,
66
+ mediaType: source.mediaType
67
+ };
68
+ }
69
+ throw new InvalidRequestError("Unrecognized attachment source — expected a string path/URL, a StorageFile, or `{ base64, mediaType }`");
70
+ }
71
+
72
+ //#endregion
73
+ export { resolveAttachment };
74
+ //# sourceMappingURL=resolve-attachment.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,89 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+
3
+ //#region ../@warlock.js/ai/src/utils/run-context.ts
4
+ /**
5
+ * Process-wide async-local store holding the current {@link RunFrame}.
6
+ * A single shared instance so a frame installed by the supervisor is
7
+ * visible to an agent running several `await`s deep inside a callback,
8
+ * across module boundaries. Empty (returns `undefined`) outside any
9
+ * orchestration callback — standalone `agent.execute()` is unaffected.
10
+ */
11
+ const runFrameStore = new AsyncLocalStorage();
12
+ /**
13
+ * A second async-local flag set whenever execution is nested inside a
14
+ * parent capture — by BOTH {@link withRunFrame} (ambient capture) and
15
+ * {@link withoutRunFrame} (explicit parent capture, which clears the frame).
16
+ * Lets the `observeAll` gate skip self-routing a nested run regardless of
17
+ * which capture path its parent uses — the parent already captures it.
18
+ */
19
+ const nestedStore = new AsyncLocalStorage();
20
+ /**
21
+ * Run `fn` with `frame` installed as the ambient {@link RunFrame} for
22
+ * the entire async subtree it spawns. Restores the previous frame (or
23
+ * none) when `fn` settles. Returns whatever `fn` returns.
24
+ *
25
+ * Nesting is natural: a callback that itself dispatches a nested
26
+ * supervisor installs a fresh frame for the inner run, and the inner
27
+ * frame shadows the outer one for the inner subtree only — exactly the
28
+ * tree shape the report models.
29
+ */
30
+ function withRunFrame(frame, fn) {
31
+ return nestedStore.run(true, () => runFrameStore.run(frame, fn));
32
+ }
33
+ /**
34
+ * Run `fn` with NO ambient {@link RunFrame} installed for its async
35
+ * subtree, restoring the previous frame when `fn` settles. Used by the
36
+ * supervisor's EXPLICIT capture paths (`ctx.run(...)` /
37
+ * `ctx.intents.X.execute()`) — those already push the child report onto
38
+ * the callback's `children[]` themselves, so the child must NOT also
39
+ * self-capture via the ambient frame (which would double-count it).
40
+ */
41
+ function withoutRunFrame(fn) {
42
+ return nestedStore.run(true, () => runFrameStore.run(void 0, fn));
43
+ }
44
+ /**
45
+ * `true` when execution is nested inside a parent capture — set by
46
+ * {@link withRunFrame} (ambient) or {@link withoutRunFrame} (explicit). Read
47
+ * by the observe-all gate so a nested run, which its parent already captures
48
+ * into the trace tree, is not also self-routed as a standalone top-level
49
+ * trace. `false` for a standalone (root) run.
50
+ */
51
+ function isNestedRun() {
52
+ return nestedStore.getStore() === true;
53
+ }
54
+ /**
55
+ * Capture a freshly-built child `report` onto the current ambient
56
+ * {@link RunFrame} when one is installed. Pushes the report onto the
57
+ * frame's `sink` so it nests under the enclosing node, and rewrites the
58
+ * report's lineage (`rootRunId`, `parentRunId`, `sessionId`) to the
59
+ * frame's — mirroring how `step.agent` / `ctx.run` capture child
60
+ * reports explicitly, but driven ambiently.
61
+ *
62
+ * No-op (returns `false`) when no frame is installed — a standalone
63
+ * `agent.execute()` keeps its self-root untouched. Returns `true` when
64
+ * the report was captured so the caller can suppress its own terminal
65
+ * lineage stamp if needed.
66
+ *
67
+ * The lineage rewrite is intentionally shallow on the root + deep on
68
+ * descendants would double-stamp; callers pass the already-lineage-
69
+ * stamped subtree (self-root), and this relinks only the root's
70
+ * `rootRunId` / `parentRunId` / `sessionId`. Descendants already carry
71
+ * the child's own self-root as their `rootRunId`; the enclosing
72
+ * primitive's terminal `stampReportLineage` pass (run once on the
73
+ * outer tree) rewrites the whole subtree to the true outer root. This
74
+ * keeps capture cheap and defers the single authoritative relink to
75
+ * the outer build.
76
+ */
77
+ function captureChildReport(report) {
78
+ const frame = runFrameStore.getStore();
79
+ if (!frame) return false;
80
+ report.parentRunId = frame.parentRunId;
81
+ report.rootRunId = frame.rootRunId;
82
+ if (frame.sessionId !== void 0) report.sessionId = frame.sessionId;
83
+ frame.sink.push(report);
84
+ return true;
85
+ }
86
+
87
+ //#endregion
88
+ export { captureChildReport, isNestedRun, withRunFrame, withoutRunFrame };
89
+ //# sourceMappingURL=run-context.mjs.map
@@ -0,0 +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;;;;;;;;AAmBA,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"}
@@ -0,0 +1,22 @@
1
+ //#region ../@warlock.js/ai/src/utils/safe-json-parse.ts
2
+ /**
3
+ * Parse a JSON string, returning a caller-supplied fallback when the input
4
+ * is empty or malformed instead of throwing. Useful at provider boundaries
5
+ * where tool-call arguments may arrive as `null`, `""`, or partial JSON
6
+ * during streaming — callers want a safe default, not an exception.
7
+ *
8
+ * @example
9
+ * const args = safeJsonParse<Record<string, unknown>>(toolCall.function.arguments, {});
10
+ */
11
+ function safeJsonParse(data, defaultValue) {
12
+ if (!data) return defaultValue;
13
+ try {
14
+ return JSON.parse(data);
15
+ } catch {
16
+ return defaultValue;
17
+ }
18
+ }
19
+
20
+ //#endregion
21
+ export { safeJsonParse };
22
+ //# sourceMappingURL=safe-json-parse.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,45 @@
1
+ //#region ../@warlock.js/ai/src/utils/stamp-report-lineage.ts
2
+ /**
3
+ * Walk a freshly-built report tree and stamp lineage fields onto
4
+ * every node:
5
+ *
6
+ * - `rootRunId` — rewritten to `stamp.rootRunId` everywhere. Composite
7
+ * children built by inner primitives carry their own self-root; this
8
+ * walk overrides it so the outer root wins (single coherent run id
9
+ * across the whole tree).
10
+ * - `parentRunId` — root node gets `stamp.parentRunId`; descendants
11
+ * derive theirs from each parent's own `runId`.
12
+ * - `sessionId` — propagated when provided.
13
+ * - `reportSchemaVersion` — stamped only on the root (the value is the
14
+ * same for the whole tree; storing it on every node would waste
15
+ * space).
16
+ *
17
+ * Designed to run ONCE per top-level `buildResult` call. Each
18
+ * primitive's executor invokes this on the assembled root report just
19
+ * before returning; nested primitives produced their own subtree with
20
+ * a self-root, and this pass relinks everything to the outer caller's
21
+ * lineage.
22
+ *
23
+ * Mutates the report in place — internal use only, before the report
24
+ * is exposed via `result.report`.
25
+ *
26
+ * @example
27
+ * const root = this.buildBareReport();
28
+ * stampReportLineage(root, { rootRunId: this.runId, sessionId: this.options?.sessionId });
29
+ * return { ..., report: root };
30
+ */
31
+ function stampReportLineage(root, stamp) {
32
+ root.reportSchemaVersion = 1;
33
+ walk(root, stamp.rootRunId, stamp.parentRunId, stamp.sessionId);
34
+ }
35
+ function walk(node, rootRunId, parentRunId, sessionId) {
36
+ node.rootRunId = rootRunId;
37
+ if (parentRunId !== void 0) node.parentRunId = parentRunId;
38
+ else delete node.parentRunId;
39
+ if (sessionId !== void 0) node.sessionId = sessionId;
40
+ for (const child of node.children) walk(child, rootRunId, node.runId, sessionId);
41
+ }
42
+
43
+ //#endregion
44
+ export { stampReportLineage };
45
+ //# sourceMappingURL=stamp-report-lineage.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,57 @@
1
+ //#region ../@warlock.js/ai/src/vcr/cassette-io.ts
2
+ let fsModule;
3
+ /**
4
+ * Resolve `node:fs/promises` once and memoize it.
5
+ */
6
+ async function loadFs() {
7
+ if (!fsModule) fsModule = await import("node:fs/promises");
8
+ return fsModule;
9
+ }
10
+ /**
11
+ * Build a fresh, empty cassette for a model identity. Used when the path
12
+ * does not exist yet (first record run).
13
+ */
14
+ function emptyCassette(model, provider) {
15
+ return {
16
+ version: 1,
17
+ model,
18
+ provider,
19
+ entries: []
20
+ };
21
+ }
22
+ /**
23
+ * Load a cassette from disk. Returns a fresh empty cassette (not an error)
24
+ * when the file does not exist — the common first-record case. Any other I/O
25
+ * or parse failure rejects so corruption is never silently swallowed.
26
+ */
27
+ async function loadCassette(path, model, provider) {
28
+ const fs = await loadFs();
29
+ let raw;
30
+ try {
31
+ raw = await fs.readFile(path, "utf8");
32
+ } catch (error) {
33
+ if (error.code === "ENOENT") return emptyCassette(model, provider);
34
+ throw error;
35
+ }
36
+ const parsed = JSON.parse(raw);
37
+ return {
38
+ version: 1,
39
+ model: parsed.model ?? model,
40
+ provider: parsed.provider ?? provider,
41
+ entries: Array.isArray(parsed.entries) ? parsed.entries : []
42
+ };
43
+ }
44
+ /**
45
+ * Write a cassette to disk as pretty-printed JSON, creating the parent
46
+ * directory if needed so a brand-new `./cassettes/foo.json` path just works.
47
+ */
48
+ async function saveCassette(path, cassette) {
49
+ const fs = await loadFs();
50
+ const dir = (await import("node:path")).dirname(path);
51
+ if (dir && dir !== "." && dir !== path) await fs.mkdir(dir, { recursive: true });
52
+ await fs.writeFile(path, JSON.stringify(cassette, void 0, 2), "utf8");
53
+ }
54
+
55
+ //#endregion
56
+ export { emptyCassette, loadCassette, saveCassette };
57
+ //# sourceMappingURL=cassette-io.mjs.map
@@ -0,0 +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"}
@@ -0,0 +1,37 @@
1
+ import { AIError } from "../errors/ai-error.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/vcr/errors.ts
4
+ /**
5
+ * Thrown when a `vcr(model, { mode: "replay" })` call finds no cassette
6
+ * entry matching the request hash.
7
+ *
8
+ * **The whole point of deterministic tests.** VCR in `replay` mode never
9
+ * falls back to a live provider call on a miss — that would silently
10
+ * re-introduce network/non-determinism into a test that asked for the
11
+ * opposite. Instead it throws this error so the run fails loud, telling
12
+ * the developer to re-record the cassette (run once in `record`/`auto`).
13
+ *
14
+ * Extends {@link AIError} directly (not `ProviderError`) — a cassette miss
15
+ * is a harness/config failure, not a provider failure.
16
+ *
17
+ * @example
18
+ * try {
19
+ * await vcrModel.complete(messages);
20
+ * } catch (error) {
21
+ * if (error instanceof VcrCassetteMissError) {
22
+ * console.error("Re-record the cassette:", error.path);
23
+ * }
24
+ * }
25
+ */
26
+ var VcrCassetteMissError = class extends AIError {
27
+ constructor(message, options) {
28
+ super("VCR_CASSETTE_MISS", message, options);
29
+ this.name = "VcrCassetteMissError";
30
+ this.requestHash = options?.requestHash;
31
+ this.path = options?.path;
32
+ }
33
+ };
34
+
35
+ //#endregion
36
+ export { VcrCassetteMissError };
37
+ //# sourceMappingURL=errors.mjs.map