@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,328 @@
1
+ //#region ../@warlock.js/ai/src/rag/store/pg-vector-store.ts
2
+ /**
3
+ * Default backing table — provisions the store with no extra config when
4
+ * the dev runs {@link VectorStore.schema | ensureSchema} through their
5
+ * migration tool.
6
+ */
7
+ const DEFAULT_TABLE = "warlock_ai_rag_vectors";
8
+ /** Default embedding width baked into the DDL (OpenAI `text-embedding-3-small`). */
9
+ const DEFAULT_DIMENSIONS = 1536;
10
+ /** Default `ivfflat` list count when that index strategy is chosen. */
11
+ const DEFAULT_IVFFLAT_LISTS = 100;
12
+ /**
13
+ * Allowed characters in a Postgres identifier (table name). The table name
14
+ * is interpolated into DDL/DML, so anything outside this conservative
15
+ * ASCII subset is rejected — interpolating an arbitrary string would be a
16
+ * SQL-injection footgun (mirrors the snapshot / human-interrupt pg stores
17
+ * and `@warlock.js/cache`'s `PgCacheDriver`).
18
+ */
19
+ const SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
20
+ /**
21
+ * Module specifier for the optional `pg` driver. Held in a `string`
22
+ * variable so the dynamic `import()` is not statically resolved at compile
23
+ * time — `pg` is an optional peer that need not be installed for this
24
+ * package to type-check or for a cache-only consumer to run.
25
+ */
26
+ const PG_MODULE = "pg";
27
+ /**
28
+ * Curated install string surfaced (at use time) when a `connectionString`
29
+ * is configured but the optional `pg` driver is absent. Never thrown at
30
+ * import — a cache-only consumer must be able to load this module.
31
+ */
32
+ const PG_INSTALL_INSTRUCTIONS = `
33
+ The @warlock.js/ai Postgres vector store requires the pg package and a
34
+ Postgres database with the pgvector extension. Install the driver with:
35
+
36
+ npm install pg
37
+
38
+ Or with your preferred package manager:
39
+
40
+ pnpm add pg
41
+ yarn add pg
42
+ `.trim();
43
+ /**
44
+ * Lazily import `pg` and return a `Pool` built from `connectionString`. A
45
+ * bare `catch` rethrows the curated install string — a missing optional
46
+ * peer surfaces as actionable guidance, never a raw resolution error.
47
+ */
48
+ async function buildPgClient(connectionString) {
49
+ let sdk;
50
+ try {
51
+ sdk = await import(PG_MODULE);
52
+ } catch {
53
+ throw new Error(PG_INSTALL_INSTRUCTIONS);
54
+ }
55
+ return new sdk.Pool({ connectionString });
56
+ }
57
+ /**
58
+ * Serialize a JS `number[]` to the pgvector text literal: `[1,2,3]`.
59
+ * pgvector accepts a vector either as this bracketed literal or via a
60
+ * typed parameter; passing the literal string + an explicit `::vector`
61
+ * cast keeps the store driver-agnostic (no dependency on a registered
62
+ * `pg` type parser).
63
+ *
64
+ * Non-finite components (`NaN` / `±Infinity`) are rejected — pgvector
65
+ * stores only finite floats, and silently coercing them would corrupt the
66
+ * index. The check is cheap relative to the embed call that produced the
67
+ * vector.
68
+ *
69
+ * @example
70
+ * vectorLiteral([1, 0.5, -2]); // "[1,0.5,-2]"
71
+ */
72
+ function vectorLiteral(vector) {
73
+ let literal = "[";
74
+ for (let index = 0; index < vector.length; index++) {
75
+ const component = vector[index];
76
+ if (!Number.isFinite(component)) throw new TypeError(`pgVectorStore: embedding component at index ${index} is not finite (${component}); pgvector stores only finite floats.`);
77
+ if (index > 0) literal += ",";
78
+ literal += String(component);
79
+ }
80
+ return literal + "]";
81
+ }
82
+ /**
83
+ * Coerce a `value` JSONB column back into the stored payload. node-postgres
84
+ * parses `JSONB` into a JS value already, but some pool wrappers hand back
85
+ * the raw string — be defensive across both (mirrors the snapshot store's
86
+ * `parsePayload`).
87
+ */
88
+ function parseValue(value) {
89
+ if (typeof value === "string") return JSON.parse(value);
90
+ return value;
91
+ }
92
+ /**
93
+ * Coerce a pgvector cosine **distance** (`<=>`, in `[0, 2]`, 0 = identical)
94
+ * into the cosine **similarity** score the {@link VectorStore} contract
95
+ * declares (`[0, 1]`, 1 = identical). `pg` returns the computed distance
96
+ * column as a string for `double precision`; parse then map `1 - distance`,
97
+ * clamped to `[0, 1]` so a tiny floating-point overshoot never yields a
98
+ * score just outside the contract's range.
99
+ */
100
+ function distanceToScore(distance) {
101
+ const score = 1 - (typeof distance === "string" ? Number(distance) : distance);
102
+ if (score < 0) return 0;
103
+ if (score > 1) return 1;
104
+ return score;
105
+ }
106
+ /**
107
+ * Postgres + pgvector-backed {@link VectorStore} — one durable row per
108
+ * indexed chunk, keyed by the RAG pipeline's dotted `key`
109
+ * (`ai.rag.<name>.<sourceId>.<chunkIndex>`), with the chunk payload in a
110
+ * `value` JSONB column and the embedding in a `vector` column.
111
+ *
112
+ * Owns: the three RAG vector operations against a pgvector index —
113
+ * `upsert` (INSERT … ON CONFLICT DO UPDATE), `query` (cosine
114
+ * `ORDER BY embedding <=> $vec` with a `threshold` floor + optional `tags`
115
+ * overlap filter, capped at `topK`), and `removeNamespace` (prefix DELETE).
116
+ * Also emits the reference DDL via {@link PgVectorStore.schema} (alias
117
+ * {@link PgVectorStore.ensureSchema}).
118
+ *
119
+ * Does NOT own: the connection lifecycle (a dev-supplied `client` is never
120
+ * closed; a store-built `Pool` from a `connectionString` is also left open
121
+ * for the process to reuse) or schema migration — the dev runs the DDL
122
+ * through their own tool; the framework never auto-migrates.
123
+ *
124
+ * Front it with the {@link pgVectorStore} factory — callers never `new` it.
125
+ */
126
+ var PgVectorStore = class {
127
+ constructor(options) {
128
+ const table = options.table ?? DEFAULT_TABLE;
129
+ if (!SAFE_IDENTIFIER.test(table)) throw new TypeError(`pgVectorStore: invalid table name '${table}'. Allowed: [A-Za-z_][A-Za-z0-9_]*.`);
130
+ this.table = table;
131
+ this.dimensions = options.dimensions ?? DEFAULT_DIMENSIONS;
132
+ this.index = options.index ?? "hnsw";
133
+ this.ivfflatLists = options.ivfflatLists ?? DEFAULT_IVFFLAT_LISTS;
134
+ if (options.client) {
135
+ if (typeof options.client.query !== "function") throw new TypeError("pgVectorStore requires a 'client' option implementing { query(text, params) } — pass a pg.Pool or pg.Client.");
136
+ this.clientPromise = Promise.resolve(options.client);
137
+ return;
138
+ }
139
+ if (options.connectionString) {
140
+ this.clientPromise = buildPgClient(options.connectionString);
141
+ return;
142
+ }
143
+ throw new TypeError("pgVectorStore requires either a 'client' or a 'connectionString' option.");
144
+ }
145
+ /**
146
+ * Resolve the backing client, surfacing the lazy `pg` import's curated
147
+ * install string on the first call that needs it.
148
+ */
149
+ client() {
150
+ return this.clientPromise;
151
+ }
152
+ /**
153
+ * Index `value` under `key` with its embedding `vector`. Upserts on the
154
+ * `key` primary key — re-indexing the same chunk overwrites its payload,
155
+ * embedding, and tags rather than appending a duplicate row. Optional
156
+ * `tags` ride a `text[]` column so {@link query} can restrict the
157
+ * candidate set with an array-overlap filter.
158
+ *
159
+ * The embedding is sent as a pgvector text literal (`$3`) cast to
160
+ * `::vector`, so the store needs no registered `pg` type parser. `tags`
161
+ * defaults to an empty array (never `NULL`) to keep the overlap filter's
162
+ * `&&` semantics simple.
163
+ */
164
+ async upsert(key, value, vector, tags) {
165
+ await (await this.client()).query(`INSERT INTO ${this.table} (key, value, embedding, tags)
166
+ VALUES ($1, $2::jsonb, $3::vector, $4::text[])
167
+ ON CONFLICT (key) DO UPDATE
168
+ SET value = EXCLUDED.value,
169
+ embedding = EXCLUDED.embedding,
170
+ tags = EXCLUDED.tags`, [
171
+ key,
172
+ JSON.stringify(value),
173
+ vectorLiteral(vector),
174
+ tags ?? []
175
+ ]);
176
+ }
177
+ /**
178
+ * Return the cosine-nearest rows to `vector`, mapped to the contract's
179
+ * `{ key, value, score }` shape. The SQL:
180
+ *
181
+ * - computes `embedding <=> $1::vector` (cosine **distance**) once, aliased
182
+ * `distance`, and `ORDER BY` it ascending (nearest first);
183
+ * - applies the `threshold` floor as `distance <= 1 - threshold`
184
+ * (similarity `>=` threshold), so the default `0.5` floor maps to a
185
+ * `<= 0.5` distance bound — the filter runs in SQL, not in JS, so a
186
+ * below-floor row never crosses the wire;
187
+ * - when `tags` are given, restricts to rows whose `tags` array overlaps
188
+ * the requested set via `tags && $tags::text[]` (one-of semantics,
189
+ * matching the cache store);
190
+ * - caps the result at `topK` with `LIMIT`.
191
+ *
192
+ * The returned `score` is `1 - distance`, clamped to `[0, 1]`, so callers
193
+ * see the same cosine-similarity scale the cache store emits.
194
+ */
195
+ async query(vector, options) {
196
+ const client = await this.client();
197
+ const params = [vectorLiteral(vector), options.topK];
198
+ const conditions = [];
199
+ if (options.threshold !== void 0) {
200
+ params.push(1 - options.threshold);
201
+ conditions.push(`(embedding <=> $1::vector) <= $${params.length}`);
202
+ }
203
+ if (options.tags !== void 0 && options.tags.length > 0) {
204
+ params.push(options.tags);
205
+ conditions.push(`tags && $${params.length}::text[]`);
206
+ }
207
+ const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
208
+ const { rows } = await client.query(`SELECT key, value, (embedding <=> $1::vector) AS distance
209
+ FROM ${this.table}
210
+ ${where}
211
+ ORDER BY embedding <=> $1::vector
212
+ LIMIT $2`, params);
213
+ return rows.map((row) => ({
214
+ key: row.key,
215
+ value: parseValue(row.value),
216
+ score: distanceToScore(row.distance)
217
+ }));
218
+ }
219
+ /**
220
+ * Drop every entry written under `namespace`. The RAG pipeline keys
221
+ * chunks as `<namespace>.<sourceId>.<chunkIndex>`, so a row belongs to
222
+ * the namespace when its `key` equals it OR begins with `<namespace>.`
223
+ * — deleting `ai.rag.docs` must not also catch `ai.rag.docs2`. The `_`
224
+ * and `%` LIKE wildcards in the namespace are escaped so a namespace
225
+ * that happens to contain them is matched literally.
226
+ */
227
+ async removeNamespace(namespace) {
228
+ const client = await this.client();
229
+ const escaped = namespace.replace(/\\/g, "\\\\").replace(/_/g, "\\_").replace(/%/g, "\\%");
230
+ await client.query(`DELETE FROM ${this.table}
231
+ WHERE key = $1 OR key LIKE $2 ESCAPE '\\'`, [namespace, `${escaped}.%`]);
232
+ }
233
+ /**
234
+ * Return the reference migration DDL for this store's backing table,
235
+ * interpolating the configured table name, embedding width, and ANN
236
+ * index strategy. The dev runs it once through their migration tool —
237
+ * the framework never auto-migrates.
238
+ *
239
+ * The emitted statements:
240
+ * 1. `CREATE EXTENSION IF NOT EXISTS vector;` — enables pgvector (needs
241
+ * a superuser or a role with `CREATE` on the database the first time).
242
+ * 2. `CREATE TABLE IF NOT EXISTS <table> (key TEXT PRIMARY KEY, value
243
+ * JSONB NOT NULL, embedding vector(<dimensions>) NOT NULL, tags
244
+ * text[] NOT NULL DEFAULT '{}');`
245
+ * 3. A GIN index on `tags` so the array-overlap filter stays sargable.
246
+ * 4. The chosen ANN index over `embedding` using `vector_cosine_ops`:
247
+ * - `"hnsw"` → `USING hnsw (embedding vector_cosine_ops)`;
248
+ * - `"ivfflat"` → `USING ivfflat (embedding vector_cosine_ops)
249
+ * WITH (lists = <ivfflatLists>)`;
250
+ * - `"none"` → emitted as a comment (exact scan, no ANN index).
251
+ *
252
+ * @example
253
+ * const store = pgVectorStore({ client: pool, dimensions: 1536 });
254
+ * await pool.query(store.ensureSchema());
255
+ */
256
+ schema() {
257
+ const lines = [
258
+ `CREATE EXTENSION IF NOT EXISTS vector;`,
259
+ `CREATE TABLE IF NOT EXISTS ${this.table} (`,
260
+ ` key TEXT PRIMARY KEY,`,
261
+ ` value JSONB NOT NULL,`,
262
+ ` embedding vector(${this.dimensions}) NOT NULL,`,
263
+ ` tags TEXT[] NOT NULL DEFAULT '{}'`,
264
+ `);`,
265
+ `CREATE INDEX IF NOT EXISTS idx_${this.table}_tags`,
266
+ ` ON ${this.table} USING gin (tags);`
267
+ ];
268
+ if (this.index === "hnsw") lines.push(`CREATE INDEX IF NOT EXISTS idx_${this.table}_embedding`, ` ON ${this.table} USING hnsw (embedding vector_cosine_ops);`);
269
+ else if (this.index === "ivfflat") lines.push(`CREATE INDEX IF NOT EXISTS idx_${this.table}_embedding`, ` ON ${this.table} USING ivfflat (embedding vector_cosine_ops)`, ` WITH (lists = ${this.ivfflatLists});`);
270
+ else lines.push(`-- No ANN index requested (index: "none"): cosine queries fall back`, `-- to an exact sequential scan, which is correct but linear in rows.`);
271
+ return lines.join("\n");
272
+ }
273
+ /**
274
+ * Alias for {@link PgVectorStore.schema} — reads more naturally in a
275
+ * migration script (`await pool.query(store.ensureSchema())`). Returns
276
+ * the identical DDL string; it does NOT execute anything against the
277
+ * database (the store never auto-migrates).
278
+ */
279
+ ensureSchema() {
280
+ return this.schema();
281
+ }
282
+ };
283
+ /**
284
+ * Create a Postgres + pgvector-backed {@link VectorStore} for the RAG
285
+ * pipeline. Either pass a live `pg.Pool` / `pg.Client` (`{ client }`) —
286
+ * `@warlock.js/ai` never imports `pg` in that case — or a
287
+ * `{ connectionString }` and let the store lazily `import("pg")` to build
288
+ * its own pool. When `pg` is not installed, a curated install string
289
+ * surfaces on first use, never at import.
290
+ *
291
+ * Run {@link PgVectorStoreInstance.ensureSchema} through your migration
292
+ * tool once before use (it enables the `vector` extension, creates the
293
+ * table, and builds the tag + ANN indexes); the store never auto-migrates.
294
+ *
295
+ * Index and query MUST use the same embedding model — the `vector(N)`
296
+ * column width is fixed at table-creation time from `dimensions`.
297
+ *
298
+ * @example
299
+ * import { Pool } from "pg";
300
+ * import { ai } from "@warlock.js/ai";
301
+ *
302
+ * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
303
+ * const store = ai.rag.pgVectorStore({ client: pool, dimensions: 1536 });
304
+ *
305
+ * // Once, via your migration tooling:
306
+ * // await pool.query(store.ensureSchema());
307
+ *
308
+ * const kb = ai.rag({
309
+ * name: "docs",
310
+ * embedder: openai.embedder({ name: "text-embedding-3-small" }),
311
+ * store,
312
+ * });
313
+ *
314
+ * @example
315
+ * // Let the store build its own pool from a connection string:
316
+ * const store = ai.rag.pgVectorStore({
317
+ * connectionString: process.env.DATABASE_URL,
318
+ * index: "ivfflat",
319
+ * ivfflatLists: 200,
320
+ * });
321
+ */
322
+ function pgVectorStore(options) {
323
+ return new PgVectorStore(options);
324
+ }
325
+
326
+ //#endregion
327
+ export { pgVectorStore, vectorLiteral };
328
+ //# sourceMappingURL=pg-vector-store.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg-vector-store.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/ai/src/rag/store/pg-vector-store.ts"],"sourcesContent":["import type { VectorStore } from \"./vector-store.contract\";\n\n/**\n * Minimal `pg`-compatible client surface the Postgres {@link VectorStore}\n * depends on. Both `pg.Pool` and `pg.Client` satisfy it — the store only\n * ever calls `query`.\n *\n * `@warlock.js/ai` takes **no** hard dependency on `pg`; the dev installs\n * it (an optional peer) and passes the client in. Structurally identical\n * to the snapshot / human-interrupt stores' `PgClientLike`, so a single\n * pool can back the orchestrator checkpoint/snapshot tables, the\n * interrupt table, and this vectors table alike.\n */\nexport interface PgClientLike {\n query(text: string, params?: unknown[]): Promise<{ rows: unknown[] }>;\n}\n\n/**\n * Options for the Postgres {@link VectorStore}.\n *\n * Two mutually-supportive ways to supply the connection (mirroring\n * `ai.human.interrupt.pg`):\n * - **`client`** — pass an already-built `pg.Pool` / `pg.Client` (anything\n * satisfying {@link PgClientLike}). The store only ever calls `query`\n * and never opens or closes it; one pool can back several stores.\n * - **`connectionString`** — let the store lazily `import(\"pg\")` and build\n * its own `Pool`. `@warlock.js/ai` takes **no** hard dependency on\n * `pg` (an optional peer); when it is absent the store throws a curated\n * install string at first use, never a raw module-resolution stack trace\n * at import.\n *\n * Exactly one of the two must be present.\n */\nexport interface PgVectorStoreOptions {\n /** An already-built `pg.Pool` / `pg.Client` — anything matching {@link PgClientLike}. */\n client?: PgClientLike;\n\n /** Connection string the store passes to a lazily-imported `pg.Pool`. */\n connectionString?: string;\n\n /**\n * Backing table name. Defaults to `warlock_ai_rag_vectors`. Must be a\n * safe SQL identifier — it is interpolated into DDL/DML.\n */\n table?: string;\n\n /**\n * Embedding dimensionality used in the `CREATE TABLE` DDL emitted by\n * {@link VectorStore.schema | ensureSchema}. Defaults to `1536`\n * (OpenAI `text-embedding-3-small`). The column is declared\n * `vector(N)`; queries and upserts never re-state it, so an existing\n * table provisioned at a different size is unaffected — only the DDL\n * helper reads this.\n */\n dimensions?: number;\n\n /**\n * Approximate-nearest-neighbour index strategy baked into the DDL\n * emitted by {@link VectorStore.schema | ensureSchema}. Defaults to\n * `\"hnsw\"` (better recall/latency on modern pgvector). Use `\"ivfflat\"`\n * for the classic list-partitioned index, or `\"none\"` to emit no ANN\n * index (exact scan — correct, but linear in row count).\n */\n index?: \"hnsw\" | \"ivfflat\" | \"none\";\n\n /**\n * `lists` parameter for an `ivfflat` index (ignored for `hnsw` / `none`).\n * Defaults to `100`. Tune toward `rows / 1000` for large tables.\n */\n ivfflatLists?: number;\n}\n\n/**\n * Default backing table — provisions the store with no extra config when\n * the dev runs {@link VectorStore.schema | ensureSchema} through their\n * migration tool.\n */\nconst DEFAULT_TABLE = \"warlock_ai_rag_vectors\";\n\n/** Default embedding width baked into the DDL (OpenAI `text-embedding-3-small`). */\nconst DEFAULT_DIMENSIONS = 1536;\n\n/** Default `ivfflat` list count when that index strategy is chosen. */\nconst DEFAULT_IVFFLAT_LISTS = 100;\n\n/**\n * Allowed characters in a Postgres identifier (table name). The table name\n * is interpolated into DDL/DML, so anything outside this conservative\n * ASCII subset is rejected — interpolating an arbitrary string would be a\n * SQL-injection footgun (mirrors the snapshot / human-interrupt pg stores\n * and `@warlock.js/cache`'s `PgCacheDriver`).\n */\nconst SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * Module specifier for the optional `pg` driver. Held in a `string`\n * variable so the dynamic `import()` is not statically resolved at compile\n * time — `pg` is an optional peer that need not be installed for this\n * package to type-check or for a cache-only consumer to run.\n */\nconst PG_MODULE = \"pg\";\n\n/**\n * Curated install string surfaced (at use time) when a `connectionString`\n * is configured but the optional `pg` driver is absent. Never thrown at\n * import — a cache-only consumer must be able to load this module.\n */\nconst PG_INSTALL_INSTRUCTIONS = `\nThe @warlock.js/ai Postgres vector store requires the pg package and a\nPostgres database with the pgvector extension. Install the driver with:\n\n npm install pg\n\nOr with your preferred package manager:\n\n pnpm add pg\n yarn add pg\n`.trim();\n\n/**\n * Minimal structural view of a `pg.Pool` constructor — just enough of the\n * `pg` module surface for the store to build a client when handed a\n * `connectionString`. Declared locally (rather than `typeof import(\"pg\")`)\n * so this module type-checks even when `pg` is not installed.\n */\ninterface PgModuleLike {\n Pool: new (config: { connectionString: string }) => PgClientLike;\n}\n\n/**\n * Lazily import `pg` and return a `Pool` built from `connectionString`. A\n * bare `catch` rethrows the curated install string — a missing optional\n * peer surfaces as actionable guidance, never a raw resolution error.\n */\nasync function buildPgClient(connectionString: string): Promise<PgClientLike> {\n let sdk: PgModuleLike;\n\n try {\n sdk = (await import(PG_MODULE)) as unknown as PgModuleLike;\n } catch {\n throw new Error(PG_INSTALL_INSTRUCTIONS);\n }\n\n return new sdk.Pool({ connectionString });\n}\n\n/**\n * Serialize a JS `number[]` to the pgvector text literal: `[1,2,3]`.\n * pgvector accepts a vector either as this bracketed literal or via a\n * typed parameter; passing the literal string + an explicit `::vector`\n * cast keeps the store driver-agnostic (no dependency on a registered\n * `pg` type parser).\n *\n * Non-finite components (`NaN` / `±Infinity`) are rejected — pgvector\n * stores only finite floats, and silently coercing them would corrupt the\n * index. The check is cheap relative to the embed call that produced the\n * vector.\n *\n * @example\n * vectorLiteral([1, 0.5, -2]); // \"[1,0.5,-2]\"\n */\nexport function vectorLiteral(vector: number[]): string {\n let literal = \"[\";\n\n for (let index = 0; index < vector.length; index++) {\n const component = vector[index];\n\n if (!Number.isFinite(component)) {\n throw new TypeError(\n `pgVectorStore: embedding component at index ${index} is not finite (${component}); pgvector stores only finite floats.`,\n );\n }\n\n if (index > 0) {\n literal += \",\";\n }\n\n literal += String(component);\n }\n\n return literal + \"]\";\n}\n\n/**\n * Coerce a `value` JSONB column back into the stored payload. node-postgres\n * parses `JSONB` into a JS value already, but some pool wrappers hand back\n * the raw string — be defensive across both (mirrors the snapshot store's\n * `parsePayload`).\n */\nfunction parseValue<T>(value: unknown): T {\n if (typeof value === \"string\") {\n return JSON.parse(value) as T;\n }\n\n return value as T;\n}\n\n/**\n * Coerce a pgvector cosine **distance** (`<=>`, in `[0, 2]`, 0 = identical)\n * into the cosine **similarity** score the {@link VectorStore} contract\n * declares (`[0, 1]`, 1 = identical). `pg` returns the computed distance\n * column as a string for `double precision`; parse then map `1 - distance`,\n * clamped to `[0, 1]` so a tiny floating-point overshoot never yields a\n * score just outside the contract's range.\n */\nfunction distanceToScore(distance: unknown): number {\n const value = typeof distance === \"string\" ? Number(distance) : (distance as number);\n const score = 1 - value;\n\n if (score < 0) {\n return 0;\n }\n\n if (score > 1) {\n return 1;\n }\n\n return score;\n}\n\n/**\n * Postgres + pgvector-backed {@link VectorStore} — one durable row per\n * indexed chunk, keyed by the RAG pipeline's dotted `key`\n * (`ai.rag.<name>.<sourceId>.<chunkIndex>`), with the chunk payload in a\n * `value` JSONB column and the embedding in a `vector` column.\n *\n * Owns: the three RAG vector operations against a pgvector index —\n * `upsert` (INSERT … ON CONFLICT DO UPDATE), `query` (cosine\n * `ORDER BY embedding <=> $vec` with a `threshold` floor + optional `tags`\n * overlap filter, capped at `topK`), and `removeNamespace` (prefix DELETE).\n * Also emits the reference DDL via {@link PgVectorStore.schema} (alias\n * {@link PgVectorStore.ensureSchema}).\n *\n * Does NOT own: the connection lifecycle (a dev-supplied `client` is never\n * closed; a store-built `Pool` from a `connectionString` is also left open\n * for the process to reuse) or schema migration — the dev runs the DDL\n * through their own tool; the framework never auto-migrates.\n *\n * Front it with the {@link pgVectorStore} factory — callers never `new` it.\n */\nclass PgVectorStore implements VectorStore {\n /** Validated backing table name, safe to interpolate into SQL. */\n private readonly table: string;\n\n /** Embedding width baked into the DDL. */\n private readonly dimensions: number;\n\n /** ANN index strategy baked into the DDL. */\n private readonly index: \"hnsw\" | \"ivfflat\" | \"none\";\n\n /** `lists` parameter for an `ivfflat` index. */\n private readonly ivfflatLists: number;\n\n /**\n * A ready client, or a promise resolving to one the store builds lazily\n * from a `connectionString`. Resolved once and memoized so the optional\n * `pg` import happens at most once.\n */\n private readonly clientPromise: Promise<PgClientLike>;\n\n public constructor(options: PgVectorStoreOptions) {\n const table = options.table ?? DEFAULT_TABLE;\n\n if (!SAFE_IDENTIFIER.test(table)) {\n throw new TypeError(\n `pgVectorStore: invalid table name '${table}'. Allowed: [A-Za-z_][A-Za-z0-9_]*.`,\n );\n }\n\n this.table = table;\n this.dimensions = options.dimensions ?? DEFAULT_DIMENSIONS;\n this.index = options.index ?? \"hnsw\";\n this.ivfflatLists = options.ivfflatLists ?? DEFAULT_IVFFLAT_LISTS;\n\n if (options.client) {\n if (typeof options.client.query !== \"function\") {\n throw new TypeError(\n \"pgVectorStore requires a 'client' option implementing { query(text, params) } — pass a pg.Pool or pg.Client.\",\n );\n }\n\n this.clientPromise = Promise.resolve(options.client);\n\n return;\n }\n\n if (options.connectionString) {\n // Defer the optional `pg` import to first use — a curated install\n // string surfaces from `buildPgClient`, not at construction.\n this.clientPromise = buildPgClient(options.connectionString);\n\n return;\n }\n\n throw new TypeError(\n \"pgVectorStore requires either a 'client' or a 'connectionString' option.\",\n );\n }\n\n /**\n * Resolve the backing client, surfacing the lazy `pg` import's curated\n * install string on the first call that needs it.\n */\n private client(): Promise<PgClientLike> {\n return this.clientPromise;\n }\n\n /**\n * Index `value` under `key` with its embedding `vector`. Upserts on the\n * `key` primary key — re-indexing the same chunk overwrites its payload,\n * embedding, and tags rather than appending a duplicate row. Optional\n * `tags` ride a `text[]` column so {@link query} can restrict the\n * candidate set with an array-overlap filter.\n *\n * The embedding is sent as a pgvector text literal (`$3`) cast to\n * `::vector`, so the store needs no registered `pg` type parser. `tags`\n * defaults to an empty array (never `NULL`) to keep the overlap filter's\n * `&&` semantics simple.\n */\n public async upsert(\n key: string,\n value: unknown,\n vector: number[],\n tags?: string[],\n ): Promise<void> {\n const client = await this.client();\n\n await client.query(\n `INSERT INTO ${this.table} (key, value, embedding, tags)\n VALUES ($1, $2::jsonb, $3::vector, $4::text[])\n ON CONFLICT (key) DO UPDATE\n SET value = EXCLUDED.value,\n embedding = EXCLUDED.embedding,\n tags = EXCLUDED.tags`,\n [key, JSON.stringify(value), vectorLiteral(vector), tags ?? []],\n );\n }\n\n /**\n * Return the cosine-nearest rows to `vector`, mapped to the contract's\n * `{ key, value, score }` shape. The SQL:\n *\n * - computes `embedding <=> $1::vector` (cosine **distance**) once, aliased\n * `distance`, and `ORDER BY` it ascending (nearest first);\n * - applies the `threshold` floor as `distance <= 1 - threshold`\n * (similarity `>=` threshold), so the default `0.5` floor maps to a\n * `<= 0.5` distance bound — the filter runs in SQL, not in JS, so a\n * below-floor row never crosses the wire;\n * - when `tags` are given, restricts to rows whose `tags` array overlaps\n * the requested set via `tags && $tags::text[]` (one-of semantics,\n * matching the cache store);\n * - caps the result at `topK` with `LIMIT`.\n *\n * The returned `score` is `1 - distance`, clamped to `[0, 1]`, so callers\n * see the same cosine-similarity scale the cache store emits.\n */\n public async query<T>(\n vector: number[],\n options: { topK: number; threshold?: number; tags?: string[] },\n ): Promise<{ key: string; value: T; score: number }[]> {\n const client = await this.client();\n const queryVector = vectorLiteral(vector);\n\n // $1 = query vector, $2 = topK. Optional threshold + tags are appended\n // as $3 / $4 only when present, so the prepared statement carries no\n // unused placeholders.\n const params: unknown[] = [queryVector, options.topK];\n const conditions: string[] = [];\n\n if (options.threshold !== undefined) {\n params.push(1 - options.threshold);\n conditions.push(`(embedding <=> $1::vector) <= $${params.length}`);\n }\n\n if (options.tags !== undefined && options.tags.length > 0) {\n params.push(options.tags);\n conditions.push(`tags && $${params.length}::text[]`);\n }\n\n const where = conditions.length > 0 ? `WHERE ${conditions.join(\" AND \")}` : \"\";\n\n const { rows } = await client.query(\n `SELECT key, value, (embedding <=> $1::vector) AS distance\n FROM ${this.table}\n ${where}\n ORDER BY embedding <=> $1::vector\n LIMIT $2`,\n params,\n );\n\n return (rows as Record<string, unknown>[]).map((row) => ({\n key: row.key as string,\n value: parseValue<T>(row.value),\n score: distanceToScore(row.distance),\n }));\n }\n\n /**\n * Drop every entry written under `namespace`. The RAG pipeline keys\n * chunks as `<namespace>.<sourceId>.<chunkIndex>`, so a row belongs to\n * the namespace when its `key` equals it OR begins with `<namespace>.`\n * — deleting `ai.rag.docs` must not also catch `ai.rag.docs2`. The `_`\n * and `%` LIKE wildcards in the namespace are escaped so a namespace\n * that happens to contain them is matched literally.\n */\n public async removeNamespace(namespace: string): Promise<void> {\n const client = await this.client();\n\n const escaped = namespace\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/_/g, \"\\\\_\")\n .replace(/%/g, \"\\\\%\");\n\n await client.query(\n `DELETE FROM ${this.table}\n WHERE key = $1 OR key LIKE $2 ESCAPE '\\\\'`,\n [namespace, `${escaped}.%`],\n );\n }\n\n /**\n * Return the reference migration DDL for this store's backing table,\n * interpolating the configured table name, embedding width, and ANN\n * index strategy. The dev runs it once through their migration tool —\n * the framework never auto-migrates.\n *\n * The emitted statements:\n * 1. `CREATE EXTENSION IF NOT EXISTS vector;` — enables pgvector (needs\n * a superuser or a role with `CREATE` on the database the first time).\n * 2. `CREATE TABLE IF NOT EXISTS <table> (key TEXT PRIMARY KEY, value\n * JSONB NOT NULL, embedding vector(<dimensions>) NOT NULL, tags\n * text[] NOT NULL DEFAULT '{}');`\n * 3. A GIN index on `tags` so the array-overlap filter stays sargable.\n * 4. The chosen ANN index over `embedding` using `vector_cosine_ops`:\n * - `\"hnsw\"` → `USING hnsw (embedding vector_cosine_ops)`;\n * - `\"ivfflat\"` → `USING ivfflat (embedding vector_cosine_ops)\n * WITH (lists = <ivfflatLists>)`;\n * - `\"none\"` → emitted as a comment (exact scan, no ANN index).\n *\n * @example\n * const store = pgVectorStore({ client: pool, dimensions: 1536 });\n * await pool.query(store.ensureSchema());\n */\n public schema(): string {\n const lines = [\n `CREATE EXTENSION IF NOT EXISTS vector;`,\n `CREATE TABLE IF NOT EXISTS ${this.table} (`,\n ` key TEXT PRIMARY KEY,`,\n ` value JSONB NOT NULL,`,\n ` embedding vector(${this.dimensions}) NOT NULL,`,\n ` tags TEXT[] NOT NULL DEFAULT '{}'`,\n `);`,\n `CREATE INDEX IF NOT EXISTS idx_${this.table}_tags`,\n ` ON ${this.table} USING gin (tags);`,\n ];\n\n if (this.index === \"hnsw\") {\n lines.push(\n `CREATE INDEX IF NOT EXISTS idx_${this.table}_embedding`,\n ` ON ${this.table} USING hnsw (embedding vector_cosine_ops);`,\n );\n } else if (this.index === \"ivfflat\") {\n lines.push(\n `CREATE INDEX IF NOT EXISTS idx_${this.table}_embedding`,\n ` ON ${this.table} USING ivfflat (embedding vector_cosine_ops)`,\n ` WITH (lists = ${this.ivfflatLists});`,\n );\n } else {\n lines.push(\n `-- No ANN index requested (index: \"none\"): cosine queries fall back`,\n `-- to an exact sequential scan, which is correct but linear in rows.`,\n );\n }\n\n return lines.join(\"\\n\");\n }\n\n /**\n * Alias for {@link PgVectorStore.schema} — reads more naturally in a\n * migration script (`await pool.query(store.ensureSchema())`). Returns\n * the identical DDL string; it does NOT execute anything against the\n * database (the store never auto-migrates).\n */\n public ensureSchema(): string {\n return this.schema();\n }\n}\n\n/**\n * The {@link VectorStore} surface plus the pg store's extra DDL helpers.\n * `schema()` / `ensureSchema()` are not part of the base contract (the\n * cache store has no backing table), so the factory's return type widens\n * it for callers that want the migration SQL.\n */\nexport interface PgVectorStoreInstance extends VectorStore {\n /** Reference migration DDL (extension + table + indexes). Never executed. */\n schema(): string;\n /** Alias for {@link PgVectorStoreInstance.schema} — reads better in a migration script. */\n ensureSchema(): string;\n}\n\n/**\n * Create a Postgres + pgvector-backed {@link VectorStore} for the RAG\n * pipeline. Either pass a live `pg.Pool` / `pg.Client` (`{ client }`) —\n * `@warlock.js/ai` never imports `pg` in that case — or a\n * `{ connectionString }` and let the store lazily `import(\"pg\")` to build\n * its own pool. When `pg` is not installed, a curated install string\n * surfaces on first use, never at import.\n *\n * Run {@link PgVectorStoreInstance.ensureSchema} through your migration\n * tool once before use (it enables the `vector` extension, creates the\n * table, and builds the tag + ANN indexes); the store never auto-migrates.\n *\n * Index and query MUST use the same embedding model — the `vector(N)`\n * column width is fixed at table-creation time from `dimensions`.\n *\n * @example\n * import { Pool } from \"pg\";\n * import { ai } from \"@warlock.js/ai\";\n *\n * const pool = new Pool({ connectionString: process.env.DATABASE_URL });\n * const store = ai.rag.pgVectorStore({ client: pool, dimensions: 1536 });\n *\n * // Once, via your migration tooling:\n * // await pool.query(store.ensureSchema());\n *\n * const kb = ai.rag({\n * name: \"docs\",\n * embedder: openai.embedder({ name: \"text-embedding-3-small\" }),\n * store,\n * });\n *\n * @example\n * // Let the store build its own pool from a connection string:\n * const store = ai.rag.pgVectorStore({\n * connectionString: process.env.DATABASE_URL,\n * index: \"ivfflat\",\n * ivfflatLists: 200,\n * });\n */\nexport function pgVectorStore(options: PgVectorStoreOptions): PgVectorStoreInstance {\n return new PgVectorStore(options);\n}\n"],"mappings":"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"}
@@ -0,0 +1,41 @@
1
+ //#region ../@warlock.js/ai/src/rag/transforms/multi-query.ts
2
+ /**
3
+ * Multi-query expansion (A4) — ask a model for several alternative
4
+ * phrasings of `query`, so retrieval covers vocabulary the original
5
+ * wording missed (synonyms, specificity, rephrasings). Pair the variants
6
+ * with {@link hybridRank} / a vector search and fuse the per-variant hits.
7
+ *
8
+ * Deterministic, dependency-light parsing: the model is asked for one
9
+ * query per line; bullets / numbering are stripped, blanks dropped, and
10
+ * the set is de-duplicated. Returns the original (unless opted out) plus
11
+ * up to `n` variants.
12
+ *
13
+ * @example
14
+ * const queries = await multiQuery(model, "how do I cancel?", { n: 3 });
15
+ * // → ["how do I cancel?", "cancel my subscription", "end my plan", ...]
16
+ */
17
+ async function multiQuery(model, query, options = {}) {
18
+ const n = options.n ?? 3;
19
+ const includeOriginal = options.includeOriginal ?? true;
20
+ const prompt = `Rewrite the following search query into ${n} alternative phrasings that would retrieve relevant documents. Output ONE query per line, no numbering or commentary.\n\nQuery: ${query}`;
21
+ const variants = (await model.complete([{
22
+ role: "user",
23
+ content: prompt
24
+ }])).content.split("\n").map((line) => line.replace(/^\s*(?:[-*•]|\d+[.)])\s*/, "").trim()).filter(Boolean);
25
+ const seen = /* @__PURE__ */ new Set();
26
+ const out = [];
27
+ const add = (q) => {
28
+ const key = q.toLowerCase();
29
+ if (!seen.has(key)) {
30
+ seen.add(key);
31
+ out.push(q);
32
+ }
33
+ };
34
+ if (includeOriginal) add(query);
35
+ for (const variant of variants.slice(0, n)) add(variant);
36
+ return out;
37
+ }
38
+
39
+ //#endregion
40
+ export { multiQuery };
41
+ //# sourceMappingURL=multi-query.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-query.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/ai/src/rag/transforms/multi-query.ts"],"sourcesContent":["import type { ModelContract } from \"../../contracts/model.contract\";\n\n/** Options for {@link multiQuery}. */\nexport type MultiQueryOptions = {\n /** How many alternative phrasings to request. Default 3. */\n n?: number;\n /** Include the original query in the returned list. Default true. */\n includeOriginal?: boolean;\n};\n\n/**\n * Multi-query expansion (A4) — ask a model for several alternative\n * phrasings of `query`, so retrieval covers vocabulary the original\n * wording missed (synonyms, specificity, rephrasings). Pair the variants\n * with {@link hybridRank} / a vector search and fuse the per-variant hits.\n *\n * Deterministic, dependency-light parsing: the model is asked for one\n * query per line; bullets / numbering are stripped, blanks dropped, and\n * the set is de-duplicated. Returns the original (unless opted out) plus\n * up to `n` variants.\n *\n * @example\n * const queries = await multiQuery(model, \"how do I cancel?\", { n: 3 });\n * // → [\"how do I cancel?\", \"cancel my subscription\", \"end my plan\", ...]\n */\nexport async function multiQuery(\n model: ModelContract,\n query: string,\n options: MultiQueryOptions = {},\n): Promise<string[]> {\n const n = options.n ?? 3;\n const includeOriginal = options.includeOriginal ?? true;\n\n const prompt =\n `Rewrite the following search query into ${n} alternative phrasings that would ` +\n `retrieve relevant documents. Output ONE query per line, no numbering or commentary.\\n\\n` +\n `Query: ${query}`;\n\n const response = await model.complete([{ role: \"user\", content: prompt }]);\n\n const variants = response.content\n .split(\"\\n\")\n .map(line => line.replace(/^\\s*(?:[-*•]|\\d+[.)])\\s*/, \"\").trim())\n .filter(Boolean);\n\n const seen = new Set<string>();\n const out: string[] = [];\n\n const add = (q: string) => {\n const key = q.toLowerCase();\n if (!seen.has(key)) {\n seen.add(key);\n out.push(q);\n }\n };\n\n if (includeOriginal) add(query);\n for (const variant of variants.slice(0, n)) add(variant);\n\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,eAAsB,WACpB,OACA,OACA,UAA6B,CAAC,GACX;CACnB,MAAM,IAAI,QAAQ,KAAK;CACvB,MAAM,kBAAkB,QAAQ,mBAAmB;CAEnD,MAAM,SACJ,2CAA2C,EAAE,kIAEnC;CAIZ,MAAM,YAAW,MAFM,MAAM,SAAS,CAAC;EAAE,MAAM;EAAQ,SAAS;CAAO,CAAC,CAAC,EAEhD,CAAC,QACvB,MAAM,IAAI,CAAC,CACX,KAAI,SAAQ,KAAK,QAAQ,4BAA4B,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAChE,OAAO,OAAO;CAEjB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,MAAgB,CAAC;CAEvB,MAAM,OAAO,MAAc;EACzB,MAAM,MAAM,EAAE,YAAY;EAC1B,IAAI,CAAC,KAAK,IAAI,GAAG,GAAG;GAClB,KAAK,IAAI,GAAG;GACZ,IAAI,KAAK,CAAC;EACZ;CACF;CAEA,IAAI,iBAAiB,IAAI,KAAK;CAC9B,KAAK,MAAM,WAAW,SAAS,MAAM,GAAG,CAAC,GAAG,IAAI,OAAO;CAEvD,OAAO;AACT"}
@@ -0,0 +1,5 @@
1
+ import { isPrivateOrReservedIp } from "./private-ip.mjs";
2
+ import { assertUrlAllowed, fetchTextWithPolicy, guardedFetch, readTextCapped, resolveOutboundPolicy } from "./outbound-policy.mjs";
3
+ import { DEFAULT_SENSITIVE_KEYS, redact } from "./redact.mjs";
4
+
5
+ export { };
@@ -0,0 +1,187 @@
1
+ import { OutboundPolicyError } from "../errors/outbound-policy-error.mjs";
2
+ import "../errors/index.mjs";
3
+ import { isPrivateOrReservedIp } from "./private-ip.mjs";
4
+ import { lookup } from "node:dns/promises";
5
+ import { isIP } from "node:net";
6
+
7
+ //#region ../@warlock.js/ai/src/security/outbound-policy.ts
8
+ /** 5 MiB — default cap on an outbound response body. */
9
+ const DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
10
+ /** 10s — default per-request timeout. */
11
+ const DEFAULT_TIMEOUT_MS = 1e4;
12
+ /**
13
+ * Fill an {@link OutboundPolicy} with strict defaults: https-only,
14
+ * private-IP deny on, 10s timeout, 5 MiB cap, global `fetch`. Idempotent
15
+ * — resolving an already-resolved policy yields the same shape.
16
+ */
17
+ function resolveOutboundPolicy(policy = {}) {
18
+ return {
19
+ allowedSchemes: policy.allowedSchemes ?? ["https"],
20
+ hostAllowlist: policy.hostAllowlist,
21
+ denyPrivateIPsAfterDNS: policy.denyPrivateIPsAfterDNS ?? true,
22
+ maxBytes: policy.maxBytes ?? DEFAULT_MAX_BYTES,
23
+ timeoutMs: policy.timeoutMs ?? DEFAULT_TIMEOUT_MS,
24
+ signal: policy.signal,
25
+ fetch: policy.fetch ?? globalThis.fetch
26
+ };
27
+ }
28
+ /** Strip the `[ ]` IPv6 brackets `URL.hostname` keeps. */
29
+ function stripBrackets(host) {
30
+ return host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
31
+ }
32
+ /** Whether `host` equals or is a subdomain of any allowlist entry. */
33
+ function hostAllowed(host, allowlist) {
34
+ const lower = host.toLowerCase();
35
+ return allowlist.some((entry) => {
36
+ const e = entry.toLowerCase();
37
+ return lower === e || lower.endsWith(`.${e}`);
38
+ });
39
+ }
40
+ /**
41
+ * Validate a URL against the policy BEFORE any network call: scheme
42
+ * allowlist, host allowlist, and (when enabled) a DNS resolution that
43
+ * rejects private / loopback / link-local / metadata addresses — the SSRF
44
+ * guard. Returns the parsed `URL` on success; throws
45
+ * {@link OutboundPolicyError} otherwise.
46
+ */
47
+ async function assertUrlAllowed(rawUrl, policy) {
48
+ let url;
49
+ try {
50
+ url = new URL(rawUrl);
51
+ } catch {
52
+ throw new OutboundPolicyError(`outbound request blocked — invalid URL: ${rawUrl}`, { context: { url: rawUrl } });
53
+ }
54
+ const scheme = url.protocol.replace(/:$/, "").toLowerCase();
55
+ if (!policy.allowedSchemes.some((s) => s.toLowerCase() === scheme)) throw new OutboundPolicyError(`outbound request blocked — scheme "${scheme}" is not allowed (allowed: ${policy.allowedSchemes.join(", ")})`, { context: {
56
+ url: rawUrl,
57
+ scheme
58
+ } });
59
+ const host = stripBrackets(url.hostname);
60
+ if (policy.hostAllowlist && !hostAllowed(host, policy.hostAllowlist)) throw new OutboundPolicyError(`outbound request blocked — host "${host}" is not in the allowlist`, { context: {
61
+ url: rawUrl,
62
+ host
63
+ } });
64
+ if (policy.denyPrivateIPsAfterDNS) await assertHostNotPrivate(host, rawUrl);
65
+ return url;
66
+ }
67
+ /**
68
+ * Reject when `host` is — or resolves to — a private / reserved address.
69
+ * IP literals are checked directly; hostnames are resolved via DNS and
70
+ * every returned address is checked (a public name pointing inward is
71
+ * caught). A resolution failure fails closed.
72
+ */
73
+ async function assertHostNotPrivate(host, rawUrl) {
74
+ if (isIP(host) !== 0) {
75
+ if (isPrivateOrReservedIp(host)) throw new OutboundPolicyError(`outbound request blocked — "${host}" is a private/reserved address`, { context: {
76
+ url: rawUrl,
77
+ address: host
78
+ } });
79
+ return;
80
+ }
81
+ let addresses;
82
+ try {
83
+ addresses = await lookup(host, { all: true });
84
+ } catch (cause) {
85
+ throw new OutboundPolicyError(`outbound request blocked — could not resolve host "${host}" to verify it is public`, {
86
+ cause,
87
+ context: {
88
+ url: rawUrl,
89
+ host
90
+ }
91
+ });
92
+ }
93
+ for (const { address } of addresses) if (isPrivateOrReservedIp(address)) throw new OutboundPolicyError(`outbound request blocked — host "${host}" resolves to a private/reserved address (${address})`, { context: {
94
+ url: rawUrl,
95
+ host,
96
+ address
97
+ } });
98
+ }
99
+ /** Merge the internal timeout signal with an optional caller signal. */
100
+ function mergeSignals(timeout, external) {
101
+ if (!external) return timeout;
102
+ const controller = new AbortController();
103
+ const abort = (from) => controller.abort(from.reason);
104
+ if (timeout.aborted) abort(timeout);
105
+ else timeout.addEventListener("abort", () => abort(timeout), { once: true });
106
+ if (external.aborted) abort(external);
107
+ else external.addEventListener("abort", () => abort(external), { once: true });
108
+ return controller.signal;
109
+ }
110
+ /**
111
+ * Policy-guarded `fetch`: validates the URL ({@link assertUrlAllowed}),
112
+ * then performs the request with the policy's timeout and (optional)
113
+ * caller signal merged. Returns the raw `Response` — read its body via
114
+ * {@link readTextCapped} to enforce `maxBytes`. Throws
115
+ * {@link OutboundPolicyError} on a policy violation or timeout.
116
+ */
117
+ async function guardedFetch(rawUrl, policyInput, init) {
118
+ const policy = resolveOutboundPolicy(policyInput);
119
+ const url = await assertUrlAllowed(rawUrl, policy);
120
+ const timeoutController = new AbortController();
121
+ const timer = setTimeout(() => {
122
+ timeoutController.abort(new OutboundPolicyError(`outbound request timed out after ${policy.timeoutMs}ms`, { context: {
123
+ url: rawUrl,
124
+ timeoutMs: policy.timeoutMs
125
+ } }));
126
+ }, policy.timeoutMs);
127
+ try {
128
+ return await policy.fetch(url, {
129
+ ...init,
130
+ signal: mergeSignals(timeoutController.signal, policy.signal)
131
+ });
132
+ } finally {
133
+ clearTimeout(timer);
134
+ }
135
+ }
136
+ /**
137
+ * Read a response body as UTF-8 text with a hard byte cap. A declared
138
+ * `content-length` over the cap fails fast; otherwise the stream is read
139
+ * chunk-by-chunk and aborted the moment the running total exceeds
140
+ * `maxBytes`. Throws {@link OutboundPolicyError} on overflow.
141
+ */
142
+ async function readTextCapped(response, maxBytes) {
143
+ const declared = Number(response.headers.get("content-length"));
144
+ if (Number.isFinite(declared) && declared > maxBytes) throw new OutboundPolicyError(`outbound response body too large — declared ${declared} bytes exceeds the ${maxBytes}-byte cap`, { context: {
145
+ declared,
146
+ maxBytes
147
+ } });
148
+ if (!response.body) {
149
+ const text = await response.text();
150
+ if (Buffer.byteLength(text) > maxBytes) throw new OutboundPolicyError(`outbound response body exceeded the ${maxBytes}-byte cap`, { context: { maxBytes } });
151
+ return text;
152
+ }
153
+ const reader = response.body.getReader();
154
+ const chunks = [];
155
+ let total = 0;
156
+ for (;;) {
157
+ const { done, value } = await reader.read();
158
+ if (done) break;
159
+ if (!value) continue;
160
+ total += value.byteLength;
161
+ if (total > maxBytes) {
162
+ await reader.cancel();
163
+ throw new OutboundPolicyError(`outbound response body exceeded the ${maxBytes}-byte cap`, { context: { maxBytes } });
164
+ }
165
+ chunks.push(value);
166
+ }
167
+ return Buffer.concat(chunks).toString("utf8");
168
+ }
169
+ /**
170
+ * Convenience: {@link guardedFetch} + {@link readTextCapped}. Returns the
171
+ * response status alongside the (capped) body text so callers can shape
172
+ * their own not-OK error. The body is only read when the response is OK.
173
+ */
174
+ async function fetchTextWithPolicy(rawUrl, policyInput, init) {
175
+ const policy = resolveOutboundPolicy(policyInput);
176
+ const response = await guardedFetch(rawUrl, policy, init);
177
+ return {
178
+ ok: response.ok,
179
+ status: response.status,
180
+ statusText: response.statusText,
181
+ text: response.ok ? await readTextCapped(response, policy.maxBytes) : ""
182
+ };
183
+ }
184
+
185
+ //#endregion
186
+ export { assertUrlAllowed, fetchTextWithPolicy, guardedFetch, readTextCapped, resolveOutboundPolicy };
187
+ //# sourceMappingURL=outbound-policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outbound-policy.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/security/outbound-policy.ts"],"sourcesContent":["import { lookup } from \"node:dns/promises\";\nimport { isIP } from \"node:net\";\nimport { OutboundPolicyError } from \"../errors\";\nimport { isPrivateOrReservedIp } from \"./private-ip\";\nimport type {\n OutboundPolicy,\n ResolvedOutboundPolicy,\n} from \"./outbound-policy.type\";\n\n/** 5 MiB — default cap on an outbound response body. */\nconst DEFAULT_MAX_BYTES = 5 * 1024 * 1024;\n/** 10s — default per-request timeout. */\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\n/**\n * Fill an {@link OutboundPolicy} with strict defaults: https-only,\n * private-IP deny on, 10s timeout, 5 MiB cap, global `fetch`. Idempotent\n * — resolving an already-resolved policy yields the same shape.\n */\nexport function resolveOutboundPolicy(\n policy: OutboundPolicy = {},\n): ResolvedOutboundPolicy {\n return {\n allowedSchemes: policy.allowedSchemes ?? [\"https\"],\n hostAllowlist: policy.hostAllowlist,\n denyPrivateIPsAfterDNS: policy.denyPrivateIPsAfterDNS ?? true,\n maxBytes: policy.maxBytes ?? DEFAULT_MAX_BYTES,\n timeoutMs: policy.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n signal: policy.signal,\n fetch: policy.fetch ?? globalThis.fetch,\n };\n}\n\n/** Strip the `[ ]` IPv6 brackets `URL.hostname` keeps. */\nfunction stripBrackets(host: string): string {\n return host.startsWith(\"[\") && host.endsWith(\"]\") ? host.slice(1, -1) : host;\n}\n\n/** Whether `host` equals or is a subdomain of any allowlist entry. */\nfunction hostAllowed(host: string, allowlist: string[]): boolean {\n const lower = host.toLowerCase();\n return allowlist.some(entry => {\n const e = entry.toLowerCase();\n return lower === e || lower.endsWith(`.${e}`);\n });\n}\n\n/**\n * Validate a URL against the policy BEFORE any network call: scheme\n * allowlist, host allowlist, and (when enabled) a DNS resolution that\n * rejects private / loopback / link-local / metadata addresses — the SSRF\n * guard. Returns the parsed `URL` on success; throws\n * {@link OutboundPolicyError} otherwise.\n */\nexport async function assertUrlAllowed(\n rawUrl: string,\n policy: ResolvedOutboundPolicy,\n): Promise<URL> {\n let url: URL;\n try {\n url = new URL(rawUrl);\n } catch {\n throw new OutboundPolicyError(`outbound request blocked — invalid URL: ${rawUrl}`, {\n context: { url: rawUrl },\n });\n }\n\n const scheme = url.protocol.replace(/:$/, \"\").toLowerCase();\n if (!policy.allowedSchemes.some(s => s.toLowerCase() === scheme)) {\n throw new OutboundPolicyError(\n `outbound request blocked — scheme \"${scheme}\" is not allowed (allowed: ${policy.allowedSchemes.join(\", \")})`,\n { context: { url: rawUrl, scheme } },\n );\n }\n\n const host = stripBrackets(url.hostname);\n\n if (policy.hostAllowlist && !hostAllowed(host, policy.hostAllowlist)) {\n throw new OutboundPolicyError(\n `outbound request blocked — host \"${host}\" is not in the allowlist`,\n { context: { url: rawUrl, host } },\n );\n }\n\n if (policy.denyPrivateIPsAfterDNS) {\n await assertHostNotPrivate(host, rawUrl);\n }\n\n return url;\n}\n\n/**\n * Reject when `host` is — or resolves to — a private / reserved address.\n * IP literals are checked directly; hostnames are resolved via DNS and\n * every returned address is checked (a public name pointing inward is\n * caught). A resolution failure fails closed.\n */\nasync function assertHostNotPrivate(host: string, rawUrl: string): Promise<void> {\n if (isIP(host) !== 0) {\n if (isPrivateOrReservedIp(host)) {\n throw new OutboundPolicyError(\n `outbound request blocked — \"${host}\" is a private/reserved address`,\n { context: { url: rawUrl, address: host } },\n );\n }\n return;\n }\n\n let addresses: Array<{ address: string }>;\n try {\n addresses = await lookup(host, { all: true });\n } catch (cause) {\n throw new OutboundPolicyError(\n `outbound request blocked — could not resolve host \"${host}\" to verify it is public`,\n { cause, context: { url: rawUrl, host } },\n );\n }\n\n for (const { address } of addresses) {\n if (isPrivateOrReservedIp(address)) {\n throw new OutboundPolicyError(\n `outbound request blocked — host \"${host}\" resolves to a private/reserved address (${address})`,\n { context: { url: rawUrl, host, address } },\n );\n }\n }\n}\n\n/** Merge the internal timeout signal with an optional caller signal. */\nfunction mergeSignals(\n timeout: AbortSignal,\n external?: AbortSignal,\n): AbortSignal {\n if (!external) return timeout;\n\n const controller = new AbortController();\n const abort = (from: AbortSignal) => controller.abort(from.reason);\n\n if (timeout.aborted) abort(timeout);\n else timeout.addEventListener(\"abort\", () => abort(timeout), { once: true });\n\n if (external.aborted) abort(external);\n else external.addEventListener(\"abort\", () => abort(external), { once: true });\n\n return controller.signal;\n}\n\n/**\n * Policy-guarded `fetch`: validates the URL ({@link assertUrlAllowed}),\n * then performs the request with the policy's timeout and (optional)\n * caller signal merged. Returns the raw `Response` — read its body via\n * {@link readTextCapped} to enforce `maxBytes`. Throws\n * {@link OutboundPolicyError} on a policy violation or timeout.\n */\nexport async function guardedFetch(\n rawUrl: string,\n policyInput: OutboundPolicy,\n init?: RequestInit,\n): Promise<Response> {\n const policy = resolveOutboundPolicy(policyInput);\n const url = await assertUrlAllowed(rawUrl, policy);\n\n const timeoutController = new AbortController();\n const timer = setTimeout(() => {\n timeoutController.abort(\n new OutboundPolicyError(\n `outbound request timed out after ${policy.timeoutMs}ms`,\n { context: { url: rawUrl, timeoutMs: policy.timeoutMs } },\n ),\n );\n }, policy.timeoutMs);\n\n try {\n return await policy.fetch(url, {\n ...init,\n signal: mergeSignals(timeoutController.signal, policy.signal),\n });\n } finally {\n clearTimeout(timer);\n }\n}\n\n/**\n * Read a response body as UTF-8 text with a hard byte cap. A declared\n * `content-length` over the cap fails fast; otherwise the stream is read\n * chunk-by-chunk and aborted the moment the running total exceeds\n * `maxBytes`. Throws {@link OutboundPolicyError} on overflow.\n */\nexport async function readTextCapped(\n response: Response,\n maxBytes: number,\n): Promise<string> {\n const declared = Number(response.headers.get(\"content-length\"));\n if (Number.isFinite(declared) && declared > maxBytes) {\n throw new OutboundPolicyError(\n `outbound response body too large — declared ${declared} bytes exceeds the ${maxBytes}-byte cap`,\n { context: { declared, maxBytes } },\n );\n }\n\n if (!response.body) {\n const text = await response.text();\n if (Buffer.byteLength(text) > maxBytes) {\n throw new OutboundPolicyError(\n `outbound response body exceeded the ${maxBytes}-byte cap`,\n { context: { maxBytes } },\n );\n }\n return text;\n }\n\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n if (!value) continue;\n\n total += value.byteLength;\n if (total > maxBytes) {\n await reader.cancel();\n throw new OutboundPolicyError(\n `outbound response body exceeded the ${maxBytes}-byte cap`,\n { context: { maxBytes } },\n );\n }\n chunks.push(value);\n }\n\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n\n/**\n * Convenience: {@link guardedFetch} + {@link readTextCapped}. Returns the\n * response status alongside the (capped) body text so callers can shape\n * their own not-OK error. The body is only read when the response is OK.\n */\nexport async function fetchTextWithPolicy(\n rawUrl: string,\n policyInput: OutboundPolicy,\n init?: RequestInit,\n): Promise<{ ok: boolean; status: number; statusText: string; text: string }> {\n const policy = resolveOutboundPolicy(policyInput);\n const response = await guardedFetch(rawUrl, policy, init);\n\n return {\n ok: response.ok,\n status: response.status,\n statusText: response.statusText,\n text: response.ok ? await readTextCapped(response, policy.maxBytes) : \"\",\n };\n}\n"],"mappings":"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"}