@warlock.js/ai 4.8.2 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1169) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/cjs/index.cjs +263 -241
  3. package/cjs/index.cjs.map +1 -1
  4. package/cjs/{magic-string.es-BtxW4VqG.cjs → magic-string.es-BoSa5xIt.cjs} +3 -3
  5. package/cjs/magic-string.es-BoSa5xIt.cjs.map +1 -0
  6. package/cjs/{matcher-logic-SBnzYohQ.cjs → matcher-logic-07fFOz7r.cjs} +3 -3
  7. package/cjs/matcher-logic-07fFOz7r.cjs.map +1 -0
  8. package/cjs/{matchers-BBh3gyB-.cjs → matchers-DnV47KR_.cjs} +24 -24
  9. package/cjs/matchers-DnV47KR_.cjs.map +1 -0
  10. package/esm/agent/agent-config.type.d.mts +1 -1
  11. package/esm/agent/agent-config.type.d.mts.map +1 -1
  12. package/esm/agent/agent-input-builder.mjs +1 -1
  13. package/esm/agent/agent-input-builder.mjs.map +1 -1
  14. package/esm/agent/agent-log-event.mjs +1 -1
  15. package/esm/agent/agent-log-event.mjs.map +1 -1
  16. package/esm/agent/agent-stream.d.mts +1 -1
  17. package/esm/agent/agent-stream.d.mts.map +1 -1
  18. package/esm/agent/agent-stream.mjs +1 -1
  19. package/esm/agent/agent-stream.mjs.map +1 -1
  20. package/esm/agent/agent-to-stream-event.mjs +1 -1
  21. package/esm/agent/agent-to-stream-event.mjs.map +1 -1
  22. package/esm/agent/agent.d.mts +1 -1
  23. package/esm/agent/agent.d.mts.map +1 -1
  24. package/esm/agent/agent.mjs +1 -1
  25. package/esm/agent/agent.mjs.map +1 -1
  26. package/esm/agent/json-stream-guard.mjs +1 -1
  27. package/esm/agent/json-stream-guard.mjs.map +1 -1
  28. package/esm/agent/judge-config.type.d.mts +1 -1
  29. package/esm/agent/judge-config.type.d.mts.map +1 -1
  30. package/esm/agent/judge-config.type.mjs +1 -1
  31. package/esm/agent/judge-config.type.mjs.map +1 -1
  32. package/esm/agent/signature.mjs +1 -1
  33. package/esm/agent/signature.mjs.map +1 -1
  34. package/esm/agent/snapshot.mjs +1 -1
  35. package/esm/agent/snapshot.mjs.map +1 -1
  36. package/esm/agent/spawn-sub-agent.d.mts +1 -1
  37. package/esm/agent/spawn-sub-agent.d.mts.map +1 -1
  38. package/esm/agent/spawn-sub-agent.mjs +1 -1
  39. package/esm/agent/spawn-sub-agent.mjs.map +1 -1
  40. package/esm/ai.d.mts +1 -1
  41. package/esm/ai.d.mts.map +1 -1
  42. package/esm/ai.mjs +1 -1
  43. package/esm/ai.mjs.map +1 -1
  44. package/esm/batch/batch.d.mts +1 -1
  45. package/esm/batch/batch.d.mts.map +1 -1
  46. package/esm/batch/batch.mjs +1 -1
  47. package/esm/batch/batch.mjs.map +1 -1
  48. package/esm/batch/batch.type.d.mts +1 -1
  49. package/esm/batch/batch.type.d.mts.map +1 -1
  50. package/esm/batch/run-batch-item.mjs +1 -1
  51. package/esm/batch/run-batch-item.mjs.map +1 -1
  52. package/esm/batch/run-with-concurrency.mjs +1 -1
  53. package/esm/batch/run-with-concurrency.mjs.map +1 -1
  54. package/esm/checkpoint/memory.d.mts +1 -1
  55. package/esm/checkpoint/memory.d.mts.map +1 -1
  56. package/esm/checkpoint/memory.mjs +0 -0
  57. package/esm/checkpoint/memory.mjs.map +1 -1
  58. package/esm/checkpoint/pg.d.mts +1 -1
  59. package/esm/checkpoint/pg.d.mts.map +1 -1
  60. package/esm/checkpoint/pg.mjs +1 -1
  61. package/esm/checkpoint/pg.mjs.map +1 -1
  62. package/esm/checkpoint/redis.d.mts +1 -1
  63. package/esm/checkpoint/redis.d.mts.map +1 -1
  64. package/esm/checkpoint/redis.mjs +1 -1
  65. package/esm/checkpoint/redis.mjs.map +1 -1
  66. package/esm/config.d.mts +1 -1
  67. package/esm/config.d.mts.map +1 -1
  68. package/esm/config.mjs +1 -1
  69. package/esm/config.mjs.map +1 -1
  70. package/esm/contracts/agent/agent-options.type.d.mts +1 -1
  71. package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
  72. package/esm/contracts/agent/agent-snapshot.type.d.mts +1 -1
  73. package/esm/contracts/agent/agent-snapshot.type.d.mts.map +1 -1
  74. package/esm/contracts/agent/agent.contract.d.mts +1 -1
  75. package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
  76. package/esm/contracts/agent/eval.type.d.mts +1 -1
  77. package/esm/contracts/agent/eval.type.d.mts.map +1 -1
  78. package/esm/contracts/attachment-policy.type.d.mts +1 -1
  79. package/esm/contracts/attachment-policy.type.d.mts.map +1 -1
  80. package/esm/contracts/attachment.type.d.mts +1 -1
  81. package/esm/contracts/attachment.type.d.mts.map +1 -1
  82. package/esm/contracts/content-part.type.d.mts +1 -1
  83. package/esm/contracts/content-part.type.d.mts.map +1 -1
  84. package/esm/contracts/conversation-message.type.d.mts +1 -1
  85. package/esm/contracts/conversation-message.type.d.mts.map +1 -1
  86. package/esm/contracts/embedder.contract.d.mts +1 -1
  87. package/esm/contracts/embedder.contract.d.mts.map +1 -1
  88. package/esm/contracts/end.type.d.mts +1 -1
  89. package/esm/contracts/end.type.d.mts.map +1 -1
  90. package/esm/contracts/end.type.mjs +1 -1
  91. package/esm/contracts/end.type.mjs.map +1 -1
  92. package/esm/contracts/events/agent-events.type.d.mts +1 -1
  93. package/esm/contracts/events/agent-events.type.d.mts.map +1 -1
  94. package/esm/contracts/events/complete-event.type.d.mts +1 -1
  95. package/esm/contracts/events/complete-event.type.d.mts.map +1 -1
  96. package/esm/contracts/events/event-identity.type.d.mts +1 -1
  97. package/esm/contracts/events/event-identity.type.d.mts.map +1 -1
  98. package/esm/contracts/events/event-map.type.d.mts +1 -1
  99. package/esm/contracts/events/event-map.type.d.mts.map +1 -1
  100. package/esm/contracts/events/supervisor-events.type.d.mts +1 -1
  101. package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
  102. package/esm/contracts/events/usage-event.type.d.mts +1 -1
  103. package/esm/contracts/events/usage-event.type.d.mts.map +1 -1
  104. package/esm/contracts/events/workflow-events.type.d.mts +1 -1
  105. package/esm/contracts/events/workflow-events.type.d.mts.map +1 -1
  106. package/esm/contracts/executable.contract.d.mts +1 -1
  107. package/esm/contracts/executable.contract.d.mts.map +1 -1
  108. package/esm/contracts/fallback-model.contract.d.mts +1 -1
  109. package/esm/contracts/fallback-model.contract.d.mts.map +1 -1
  110. package/esm/contracts/finish-reason.type.d.mts +1 -1
  111. package/esm/contracts/finish-reason.type.d.mts.map +1 -1
  112. package/esm/contracts/image-model.contract.d.mts +1 -1
  113. package/esm/contracts/image-model.contract.d.mts.map +1 -1
  114. package/esm/contracts/memory/memory-config.type.d.mts +1 -1
  115. package/esm/contracts/memory/memory-config.type.d.mts.map +1 -1
  116. package/esm/contracts/memory/memory-item.type.d.mts +1 -1
  117. package/esm/contracts/memory/memory-item.type.d.mts.map +1 -1
  118. package/esm/contracts/memory/memory.contract.d.mts +1 -1
  119. package/esm/contracts/memory/memory.contract.d.mts.map +1 -1
  120. package/esm/contracts/memory/recall-options.type.d.mts +1 -1
  121. package/esm/contracts/memory/recall-options.type.d.mts.map +1 -1
  122. package/esm/contracts/middleware/middleware-context.type.d.mts +1 -1
  123. package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -1
  124. package/esm/contracts/middleware/middleware-state.type.d.mts +1 -1
  125. package/esm/contracts/middleware/middleware-state.type.d.mts.map +1 -1
  126. package/esm/contracts/middleware/middleware.contract.d.mts +1 -1
  127. package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -1
  128. package/esm/contracts/model-tool-call-request.type.d.mts +1 -1
  129. package/esm/contracts/model-tool-call-request.type.d.mts.map +1 -1
  130. package/esm/contracts/model.contract.d.mts +9 -1
  131. package/esm/contracts/model.contract.d.mts.map +1 -1
  132. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts +1 -1
  133. package/esm/contracts/orchestrator/checkpoint-store.contract.d.mts.map +1 -1
  134. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts +1 -1
  135. package/esm/contracts/orchestrator/orchestrator-commands.type.d.mts.map +1 -1
  136. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +1 -1
  137. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
  138. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts +1 -1
  139. package/esm/contracts/orchestrator/orchestrator-event.type.d.mts.map +1 -1
  140. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts +1 -1
  141. package/esm/contracts/orchestrator/orchestrator-execute-options.type.d.mts.map +1 -1
  142. package/esm/contracts/orchestrator/orchestrator.contract.d.mts +1 -1
  143. package/esm/contracts/orchestrator/orchestrator.contract.d.mts.map +1 -1
  144. package/esm/contracts/orchestrator/session-lock.contract.d.mts +1 -1
  145. package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -1
  146. package/esm/contracts/orchestrator/session.contract.d.mts +1 -1
  147. package/esm/contracts/orchestrator/session.contract.d.mts.map +1 -1
  148. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts +1 -1
  149. package/esm/contracts/orchestrator/snapshot-store.contract.d.mts.map +1 -1
  150. package/esm/contracts/placeholders.type.d.mts +1 -1
  151. package/esm/contracts/placeholders.type.d.mts.map +1 -1
  152. package/esm/contracts/planner/planner-capability.type.d.mts +1 -1
  153. package/esm/contracts/planner/planner-capability.type.d.mts.map +1 -1
  154. package/esm/contracts/planner/planner-config.type.d.mts +1 -1
  155. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
  156. package/esm/contracts/planner/planner-execute-options.type.d.mts +1 -1
  157. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
  158. package/esm/contracts/planner/planner-plan.type.d.mts +1 -1
  159. package/esm/contracts/planner/planner-plan.type.d.mts.map +1 -1
  160. package/esm/contracts/planner/planner-result.type.d.mts +1 -1
  161. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
  162. package/esm/contracts/planner/planner-snapshot.type.d.mts +1 -1
  163. package/esm/contracts/planner/planner-snapshot.type.d.mts.map +1 -1
  164. package/esm/contracts/planner/planner.contract.d.mts +1 -1
  165. package/esm/contracts/planner/planner.contract.d.mts.map +1 -1
  166. package/esm/contracts/result/agent-result.type.d.mts +1 -1
  167. package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
  168. package/esm/contracts/result/attempt-entry.type.d.mts +1 -1
  169. package/esm/contracts/result/attempt-entry.type.d.mts.map +1 -1
  170. package/esm/contracts/result/base-report.type.d.mts +1 -1
  171. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  172. package/esm/contracts/result/base-report.type.mjs +1 -1
  173. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  174. package/esm/contracts/result/base-result.type.d.mts +1 -1
  175. package/esm/contracts/result/base-result.type.d.mts.map +1 -1
  176. package/esm/contracts/result/execute-result.type.d.mts +1 -1
  177. package/esm/contracts/result/execute-result.type.d.mts.map +1 -1
  178. package/esm/contracts/result/execution-report.type.d.mts +1 -1
  179. package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
  180. package/esm/contracts/result/llm-trip.type.d.mts +1 -1
  181. package/esm/contracts/result/llm-trip.type.d.mts.map +1 -1
  182. package/esm/contracts/result/model-pricing.type.d.mts +1 -1
  183. package/esm/contracts/result/model-pricing.type.d.mts.map +1 -1
  184. package/esm/contracts/result/orchestrator-result.type.d.mts +1 -1
  185. package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -1
  186. package/esm/contracts/result/session-send-result.type.d.mts +1 -1
  187. package/esm/contracts/result/session-send-result.type.d.mts.map +1 -1
  188. package/esm/contracts/result/step-result.type.d.mts +12 -2
  189. package/esm/contracts/result/step-result.type.d.mts.map +1 -1
  190. package/esm/contracts/result/supervisor-result.type.d.mts +1 -1
  191. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
  192. package/esm/contracts/result/tool-call.type.d.mts +1 -1
  193. package/esm/contracts/result/tool-call.type.d.mts.map +1 -1
  194. package/esm/contracts/result/usage.type.d.mts +1 -1
  195. package/esm/contracts/result/usage.type.d.mts.map +1 -1
  196. package/esm/contracts/result/workflow-result.type.d.mts +1 -1
  197. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
  198. package/esm/contracts/sdk-adapter.contract.d.mts +1 -1
  199. package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -1
  200. package/esm/contracts/speech-model.contract.d.mts +1 -1
  201. package/esm/contracts/speech-model.contract.d.mts.map +1 -1
  202. package/esm/contracts/stream/stream-event.type.d.mts +1 -1
  203. package/esm/contracts/stream/stream-event.type.d.mts.map +1 -1
  204. package/esm/contracts/stream/stream.contract.d.mts +1 -1
  205. package/esm/contracts/stream/stream.contract.d.mts.map +1 -1
  206. package/esm/contracts/streaming-tool-guard-config.type.d.mts +1 -1
  207. package/esm/contracts/streaming-tool-guard-config.type.d.mts.map +1 -1
  208. package/esm/contracts/supervisor/ack-entry.type.d.mts +1 -1
  209. package/esm/contracts/supervisor/ack-entry.type.d.mts.map +1 -1
  210. package/esm/contracts/supervisor/classifier-context.type.d.mts +1 -1
  211. package/esm/contracts/supervisor/classifier-context.type.d.mts.map +1 -1
  212. package/esm/contracts/supervisor/dispatch-context.type.d.mts +1 -1
  213. package/esm/contracts/supervisor/dispatch-context.type.d.mts.map +1 -1
  214. package/esm/contracts/supervisor/evaluate-context.type.d.mts +1 -1
  215. package/esm/contracts/supervisor/evaluate-context.type.d.mts.map +1 -1
  216. package/esm/contracts/supervisor/intent-entry.type.d.mts +1 -1
  217. package/esm/contracts/supervisor/intent-entry.type.d.mts.map +1 -1
  218. package/esm/contracts/supervisor/iteration-snapshot.type.d.mts +1 -1
  219. package/esm/contracts/supervisor/iteration-snapshot.type.d.mts.map +1 -1
  220. package/esm/contracts/supervisor/next.type.d.mts +1 -1
  221. package/esm/contracts/supervisor/next.type.d.mts.map +1 -1
  222. package/esm/contracts/supervisor/route-context.type.d.mts +1 -1
  223. package/esm/contracts/supervisor/route-context.type.d.mts.map +1 -1
  224. package/esm/contracts/supervisor/router-entry.type.d.mts +1 -1
  225. package/esm/contracts/supervisor/router-entry.type.d.mts.map +1 -1
  226. package/esm/contracts/supervisor/supervisor-config.type.d.mts +1 -1
  227. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  228. package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts +1 -1
  229. package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts.map +1 -1
  230. package/esm/contracts/supervisor/supervisor-input.type.d.mts +1 -1
  231. package/esm/contracts/supervisor/supervisor-input.type.d.mts.map +1 -1
  232. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +1 -1
  233. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts.map +1 -1
  234. package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts +1 -1
  235. package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts.map +1 -1
  236. package/esm/contracts/supervisor/supervisor.contract.d.mts +1 -1
  237. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -1
  238. package/esm/contracts/system-prompt.contract.d.mts +1 -1
  239. package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
  240. package/esm/contracts/team/team-config.type.d.mts +1 -1
  241. package/esm/contracts/team/team-config.type.d.mts.map +1 -1
  242. package/esm/contracts/tool.contract.d.mts +1 -1
  243. package/esm/contracts/tool.contract.d.mts.map +1 -1
  244. package/esm/contracts/transcription-model.contract.d.mts +1 -1
  245. package/esm/contracts/transcription-model.contract.d.mts.map +1 -1
  246. package/esm/contracts/workflow/next-step-result.type.d.mts +1 -1
  247. package/esm/contracts/workflow/next-step-result.type.d.mts.map +1 -1
  248. package/esm/contracts/workflow/retry-config.type.d.mts +1 -1
  249. package/esm/contracts/workflow/retry-config.type.d.mts.map +1 -1
  250. package/esm/contracts/workflow/step.contract.d.mts +1 -1
  251. package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
  252. package/esm/contracts/workflow/workflow-context.type.d.mts +1 -1
  253. package/esm/contracts/workflow/workflow-context.type.d.mts.map +1 -1
  254. package/esm/contracts/workflow/workflow-snapshot.type.d.mts +1 -1
  255. package/esm/contracts/workflow/workflow-snapshot.type.d.mts.map +1 -1
  256. package/esm/contracts/workflow/workflow.contract.d.mts +1 -1
  257. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  258. package/esm/errors/agent-cancelled-error.d.mts +1 -1
  259. package/esm/errors/agent-cancelled-error.d.mts.map +1 -1
  260. package/esm/errors/agent-cancelled-error.mjs +1 -1
  261. package/esm/errors/agent-cancelled-error.mjs.map +1 -1
  262. package/esm/errors/agent-drift-error.d.mts +1 -1
  263. package/esm/errors/agent-drift-error.d.mts.map +1 -1
  264. package/esm/errors/agent-drift-error.mjs +1 -1
  265. package/esm/errors/agent-drift-error.mjs.map +1 -1
  266. package/esm/errors/agent-execution-error.d.mts +1 -1
  267. package/esm/errors/agent-execution-error.d.mts.map +1 -1
  268. package/esm/errors/agent-execution-error.mjs +1 -1
  269. package/esm/errors/agent-execution-error.mjs.map +1 -1
  270. package/esm/errors/agent-max-trips-error.d.mts +1 -1
  271. package/esm/errors/agent-max-trips-error.d.mts.map +1 -1
  272. package/esm/errors/agent-max-trips-error.mjs +1 -1
  273. package/esm/errors/agent-max-trips-error.mjs.map +1 -1
  274. package/esm/errors/ai-error.d.mts +1 -1
  275. package/esm/errors/ai-error.d.mts.map +1 -1
  276. package/esm/errors/ai-error.mjs +1 -1
  277. package/esm/errors/ai-error.mjs.map +1 -1
  278. package/esm/errors/budget-exceeded-error.d.mts +1 -1
  279. package/esm/errors/budget-exceeded-error.d.mts.map +1 -1
  280. package/esm/errors/budget-exceeded-error.mjs +1 -1
  281. package/esm/errors/budget-exceeded-error.mjs.map +1 -1
  282. package/esm/errors/content-filter-error.d.mts +1 -1
  283. package/esm/errors/content-filter-error.d.mts.map +1 -1
  284. package/esm/errors/content-filter-error.mjs +1 -1
  285. package/esm/errors/content-filter-error.mjs.map +1 -1
  286. package/esm/errors/context-length-exceeded-error.d.mts +1 -1
  287. package/esm/errors/context-length-exceeded-error.d.mts.map +1 -1
  288. package/esm/errors/context-length-exceeded-error.mjs +1 -1
  289. package/esm/errors/context-length-exceeded-error.mjs.map +1 -1
  290. package/esm/errors/error-category.type.d.mts +1 -1
  291. package/esm/errors/error-category.type.d.mts.map +1 -1
  292. package/esm/errors/error-code.type.d.mts +1 -1
  293. package/esm/errors/error-code.type.d.mts.map +1 -1
  294. package/esm/errors/guardrail-violation-error.d.mts +1 -1
  295. package/esm/errors/guardrail-violation-error.d.mts.map +1 -1
  296. package/esm/errors/guardrail-violation-error.mjs +1 -1
  297. package/esm/errors/guardrail-violation-error.mjs.map +1 -1
  298. package/esm/errors/invalid-request-error.d.mts +1 -1
  299. package/esm/errors/invalid-request-error.d.mts.map +1 -1
  300. package/esm/errors/invalid-request-error.mjs +1 -1
  301. package/esm/errors/invalid-request-error.mjs.map +1 -1
  302. package/esm/errors/max-iterations-error.d.mts +1 -1
  303. package/esm/errors/max-iterations-error.d.mts.map +1 -1
  304. package/esm/errors/max-iterations-error.mjs +1 -1
  305. package/esm/errors/max-iterations-error.mjs.map +1 -1
  306. package/esm/errors/max-steps-exceeded-error.d.mts +1 -1
  307. package/esm/errors/max-steps-exceeded-error.d.mts.map +1 -1
  308. package/esm/errors/max-steps-exceeded-error.mjs +1 -1
  309. package/esm/errors/max-steps-exceeded-error.mjs.map +1 -1
  310. package/esm/errors/orchestrator-cancelled-error.d.mts +1 -1
  311. package/esm/errors/orchestrator-cancelled-error.d.mts.map +1 -1
  312. package/esm/errors/orchestrator-cancelled-error.mjs +1 -1
  313. package/esm/errors/orchestrator-cancelled-error.mjs.map +1 -1
  314. package/esm/errors/orchestrator-config-error.d.mts +1 -1
  315. package/esm/errors/orchestrator-config-error.d.mts.map +1 -1
  316. package/esm/errors/orchestrator-config-error.mjs +1 -1
  317. package/esm/errors/orchestrator-config-error.mjs.map +1 -1
  318. package/esm/errors/orchestrator-drift-error.d.mts +1 -1
  319. package/esm/errors/orchestrator-drift-error.d.mts.map +1 -1
  320. package/esm/errors/orchestrator-drift-error.mjs +1 -1
  321. package/esm/errors/orchestrator-drift-error.mjs.map +1 -1
  322. package/esm/errors/orchestrator-failed-error.d.mts +1 -1
  323. package/esm/errors/orchestrator-failed-error.d.mts.map +1 -1
  324. package/esm/errors/orchestrator-failed-error.mjs +1 -1
  325. package/esm/errors/orchestrator-failed-error.mjs.map +1 -1
  326. package/esm/errors/outbound-policy-error.d.mts +1 -1
  327. package/esm/errors/outbound-policy-error.d.mts.map +1 -1
  328. package/esm/errors/outbound-policy-error.mjs +1 -1
  329. package/esm/errors/outbound-policy-error.mjs.map +1 -1
  330. package/esm/errors/planner-cancelled-error.d.mts +1 -1
  331. package/esm/errors/planner-cancelled-error.d.mts.map +1 -1
  332. package/esm/errors/planner-cancelled-error.mjs +1 -1
  333. package/esm/errors/planner-cancelled-error.mjs.map +1 -1
  334. package/esm/errors/planner-drift-error.d.mts +1 -1
  335. package/esm/errors/planner-drift-error.d.mts.map +1 -1
  336. package/esm/errors/planner-drift-error.mjs +1 -1
  337. package/esm/errors/planner-drift-error.mjs.map +1 -1
  338. package/esm/errors/planner-failed-error.d.mts +1 -1
  339. package/esm/errors/planner-failed-error.d.mts.map +1 -1
  340. package/esm/errors/planner-failed-error.mjs +1 -1
  341. package/esm/errors/planner-failed-error.mjs.map +1 -1
  342. package/esm/errors/planner-plan-invalid-error.d.mts +1 -1
  343. package/esm/errors/planner-plan-invalid-error.d.mts.map +1 -1
  344. package/esm/errors/planner-plan-invalid-error.mjs +1 -1
  345. package/esm/errors/planner-plan-invalid-error.mjs.map +1 -1
  346. package/esm/errors/prompt-refinement-error.d.mts +1 -1
  347. package/esm/errors/prompt-refinement-error.d.mts.map +1 -1
  348. package/esm/errors/prompt-refinement-error.mjs +1 -1
  349. package/esm/errors/prompt-refinement-error.mjs.map +1 -1
  350. package/esm/errors/provider-auth-error.d.mts +1 -1
  351. package/esm/errors/provider-auth-error.d.mts.map +1 -1
  352. package/esm/errors/provider-auth-error.mjs +1 -1
  353. package/esm/errors/provider-auth-error.mjs.map +1 -1
  354. package/esm/errors/provider-error.d.mts +1 -1
  355. package/esm/errors/provider-error.d.mts.map +1 -1
  356. package/esm/errors/provider-error.mjs +1 -1
  357. package/esm/errors/provider-error.mjs.map +1 -1
  358. package/esm/errors/provider-rate-limit-error.d.mts +1 -1
  359. package/esm/errors/provider-rate-limit-error.d.mts.map +1 -1
  360. package/esm/errors/provider-rate-limit-error.mjs +1 -1
  361. package/esm/errors/provider-rate-limit-error.mjs.map +1 -1
  362. package/esm/errors/provider-timeout-error.d.mts +1 -1
  363. package/esm/errors/provider-timeout-error.d.mts.map +1 -1
  364. package/esm/errors/provider-timeout-error.mjs +1 -1
  365. package/esm/errors/provider-timeout-error.mjs.map +1 -1
  366. package/esm/errors/quota-exceeded-error.d.mts +1 -1
  367. package/esm/errors/quota-exceeded-error.d.mts.map +1 -1
  368. package/esm/errors/quota-exceeded-error.mjs +1 -1
  369. package/esm/errors/quota-exceeded-error.mjs.map +1 -1
  370. package/esm/errors/routing-error.d.mts +1 -1
  371. package/esm/errors/routing-error.d.mts.map +1 -1
  372. package/esm/errors/routing-error.mjs +1 -1
  373. package/esm/errors/routing-error.mjs.map +1 -1
  374. package/esm/errors/schema-validation-error.d.mts +1 -1
  375. package/esm/errors/schema-validation-error.d.mts.map +1 -1
  376. package/esm/errors/schema-validation-error.mjs +1 -1
  377. package/esm/errors/schema-validation-error.mjs.map +1 -1
  378. package/esm/errors/step-failed-error.d.mts +1 -1
  379. package/esm/errors/step-failed-error.d.mts.map +1 -1
  380. package/esm/errors/step-failed-error.mjs +1 -1
  381. package/esm/errors/step-failed-error.mjs.map +1 -1
  382. package/esm/errors/supervisor-cancelled-error.d.mts +1 -1
  383. package/esm/errors/supervisor-cancelled-error.d.mts.map +1 -1
  384. package/esm/errors/supervisor-cancelled-error.mjs +1 -1
  385. package/esm/errors/supervisor-cancelled-error.mjs.map +1 -1
  386. package/esm/errors/supervisor-drift-error.d.mts +1 -1
  387. package/esm/errors/supervisor-drift-error.d.mts.map +1 -1
  388. package/esm/errors/supervisor-drift-error.mjs +1 -1
  389. package/esm/errors/supervisor-drift-error.mjs.map +1 -1
  390. package/esm/errors/supervisor-failed-error.d.mts +1 -1
  391. package/esm/errors/supervisor-failed-error.d.mts.map +1 -1
  392. package/esm/errors/supervisor-failed-error.mjs +1 -1
  393. package/esm/errors/supervisor-failed-error.mjs.map +1 -1
  394. package/esm/errors/supervisor-routing-error.d.mts +1 -1
  395. package/esm/errors/supervisor-routing-error.d.mts.map +1 -1
  396. package/esm/errors/supervisor-routing-error.mjs +1 -1
  397. package/esm/errors/supervisor-routing-error.mjs.map +1 -1
  398. package/esm/errors/tool-execution-error.d.mts +1 -1
  399. package/esm/errors/tool-execution-error.d.mts.map +1 -1
  400. package/esm/errors/tool-execution-error.mjs +1 -1
  401. package/esm/errors/tool-execution-error.mjs.map +1 -1
  402. package/esm/errors/workflow-cancelled-error.d.mts +1 -1
  403. package/esm/errors/workflow-cancelled-error.d.mts.map +1 -1
  404. package/esm/errors/workflow-cancelled-error.mjs +1 -1
  405. package/esm/errors/workflow-cancelled-error.mjs.map +1 -1
  406. package/esm/errors/workflow-drift-error.d.mts +1 -1
  407. package/esm/errors/workflow-drift-error.d.mts.map +1 -1
  408. package/esm/errors/workflow-drift-error.mjs +1 -1
  409. package/esm/errors/workflow-drift-error.mjs.map +1 -1
  410. package/esm/errors/workflow-error.d.mts +1 -1
  411. package/esm/errors/workflow-error.d.mts.map +1 -1
  412. package/esm/errors/workflow-error.mjs +1 -1
  413. package/esm/errors/workflow-error.mjs.map +1 -1
  414. package/esm/eval/dataset.d.mts +1 -1
  415. package/esm/eval/dataset.d.mts.map +1 -1
  416. package/esm/eval/dataset.mjs +1 -1
  417. package/esm/eval/dataset.mjs.map +1 -1
  418. package/esm/eval/dataset.type.d.mts +1 -1
  419. package/esm/eval/dataset.type.d.mts.map +1 -1
  420. package/esm/eval/eval-runner.d.mts +1 -1
  421. package/esm/eval/eval-runner.d.mts.map +1 -1
  422. package/esm/eval/eval-runner.mjs +1 -1
  423. package/esm/eval/eval-runner.mjs.map +1 -1
  424. package/esm/eval/index.d.mts +1 -1
  425. package/esm/eval/index.d.mts.map +1 -1
  426. package/esm/eval/index.mjs +1 -1
  427. package/esm/eval/index.mjs.map +1 -1
  428. package/esm/eval/judge-scorer.d.mts +1 -1
  429. package/esm/eval/judge-scorer.d.mts.map +1 -1
  430. package/esm/eval/judge-scorer.mjs +1 -1
  431. package/esm/eval/judge-scorer.mjs.map +1 -1
  432. package/esm/eval/regression.d.mts +1 -1
  433. package/esm/eval/regression.d.mts.map +1 -1
  434. package/esm/eval/regression.mjs +1 -1
  435. package/esm/eval/regression.mjs.map +1 -1
  436. package/esm/eval/report-json.d.mts +1 -1
  437. package/esm/eval/report-json.d.mts.map +1 -1
  438. package/esm/eval/report-json.mjs +1 -1
  439. package/esm/eval/report-json.mjs.map +1 -1
  440. package/esm/eval/report-junit.d.mts +1 -1
  441. package/esm/eval/report-junit.d.mts.map +1 -1
  442. package/esm/eval/report-junit.mjs +1 -1
  443. package/esm/eval/report-junit.mjs.map +1 -1
  444. package/esm/eval/scorers.d.mts +1 -1
  445. package/esm/eval/scorers.d.mts.map +1 -1
  446. package/esm/eval/scorers.mjs +1 -1
  447. package/esm/eval/scorers.mjs.map +1 -1
  448. package/esm/guard/contracts/guard-options.type.d.mts +1 -1
  449. package/esm/guard/contracts/guard-options.type.d.mts.map +1 -1
  450. package/esm/guard/contracts/guardrail.contract.d.mts +1 -1
  451. package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -1
  452. package/esm/guard/contracts/openai-client.contract.d.mts +1 -1
  453. package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -1
  454. package/esm/guard/contracts/verdict.type.d.mts +1 -1
  455. package/esm/guard/contracts/verdict.type.d.mts.map +1 -1
  456. package/esm/guard/detectors/injection.d.mts +1 -1
  457. package/esm/guard/detectors/injection.d.mts.map +1 -1
  458. package/esm/guard/detectors/injection.mjs +1 -1
  459. package/esm/guard/detectors/injection.mjs.map +1 -1
  460. package/esm/guard/detectors/moderation.d.mts +1 -1
  461. package/esm/guard/detectors/moderation.d.mts.map +1 -1
  462. package/esm/guard/detectors/moderation.mjs +1 -1
  463. package/esm/guard/detectors/moderation.mjs.map +1 -1
  464. package/esm/guard/detectors/pii.d.mts +1 -1
  465. package/esm/guard/detectors/pii.d.mts.map +1 -1
  466. package/esm/guard/detectors/pii.mjs +1 -1
  467. package/esm/guard/detectors/pii.mjs.map +1 -1
  468. package/esm/guard/detectors/topic.d.mts +1 -1
  469. package/esm/guard/detectors/topic.d.mts.map +1 -1
  470. package/esm/guard/detectors/topic.mjs +1 -1
  471. package/esm/guard/detectors/topic.mjs.map +1 -1
  472. package/esm/guard/errors.d.mts +1 -1
  473. package/esm/guard/errors.d.mts.map +1 -1
  474. package/esm/guard/errors.mjs +1 -1
  475. package/esm/guard/errors.mjs.map +1 -1
  476. package/esm/guard/guard.d.mts +1 -1
  477. package/esm/guard/guard.d.mts.map +1 -1
  478. package/esm/guard/guard.mjs +1 -1
  479. package/esm/guard/guard.mjs.map +1 -1
  480. package/esm/guard/guardrail.d.mts +1 -1
  481. package/esm/guard/guardrail.d.mts.map +1 -1
  482. package/esm/guard/guardrail.mjs +1 -1
  483. package/esm/guard/guardrail.mjs.map +1 -1
  484. package/esm/human/contracts/approval.type.d.mts +1 -1
  485. package/esm/human/contracts/approval.type.d.mts.map +1 -1
  486. package/esm/human/contracts/human-approval.type.d.mts +1 -1
  487. package/esm/human/contracts/human-approval.type.d.mts.map +1 -1
  488. package/esm/human/contracts/interrupt-store.contract.d.mts +1 -1
  489. package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -1
  490. package/esm/human/contracts/resume.type.d.mts +1 -1
  491. package/esm/human/contracts/resume.type.d.mts.map +1 -1
  492. package/esm/human/errors.d.mts +1 -1
  493. package/esm/human/errors.d.mts.map +1 -1
  494. package/esm/human/errors.mjs +1 -1
  495. package/esm/human/errors.mjs.map +1 -1
  496. package/esm/human/human-approval.d.mts +1 -1
  497. package/esm/human/human-approval.d.mts.map +1 -1
  498. package/esm/human/human-approval.mjs +1 -1
  499. package/esm/human/human-approval.mjs.map +1 -1
  500. package/esm/human/policy.d.mts +1 -1
  501. package/esm/human/policy.d.mts.map +1 -1
  502. package/esm/human/policy.mjs +1 -1
  503. package/esm/human/policy.mjs.map +1 -1
  504. package/esm/human/register.mjs +1 -1
  505. package/esm/human/register.mjs.map +1 -1
  506. package/esm/human/resume-seed.mjs +1 -1
  507. package/esm/human/resume-seed.mjs.map +1 -1
  508. package/esm/human/resume.d.mts +1 -1
  509. package/esm/human/resume.d.mts.map +1 -1
  510. package/esm/human/resume.mjs +1 -1
  511. package/esm/human/resume.mjs.map +1 -1
  512. package/esm/human/stores/memory.d.mts +1 -1
  513. package/esm/human/stores/memory.d.mts.map +1 -1
  514. package/esm/human/stores/memory.mjs +1 -1
  515. package/esm/human/stores/memory.mjs.map +1 -1
  516. package/esm/human/stores/pg.d.mts +1 -1
  517. package/esm/human/stores/pg.d.mts.map +1 -1
  518. package/esm/human/stores/pg.mjs +1 -1
  519. package/esm/human/stores/pg.mjs.map +1 -1
  520. package/esm/human/stores/redis.d.mts +1 -1
  521. package/esm/human/stores/redis.d.mts.map +1 -1
  522. package/esm/human/stores/redis.mjs +1 -1
  523. package/esm/human/stores/redis.mjs.map +1 -1
  524. package/esm/image/image-cost.d.mts +1 -1
  525. package/esm/image/image-cost.d.mts.map +1 -1
  526. package/esm/image/image-cost.mjs +1 -1
  527. package/esm/image/image-cost.mjs.map +1 -1
  528. package/esm/image/image.d.mts +1 -1
  529. package/esm/image/image.d.mts.map +1 -1
  530. package/esm/image/image.mjs +1 -1
  531. package/esm/image/image.mjs.map +1 -1
  532. package/esm/memory/derive-id.mjs +1 -1
  533. package/esm/memory/derive-id.mjs.map +1 -1
  534. package/esm/memory/episodic-memory.mjs +1 -1
  535. package/esm/memory/episodic-memory.mjs.map +1 -1
  536. package/esm/memory/memory.d.mts +1 -1
  537. package/esm/memory/memory.d.mts.map +1 -1
  538. package/esm/memory/memory.mjs +1 -1
  539. package/esm/memory/memory.mjs.map +1 -1
  540. package/esm/memory/procedural-memory.mjs +1 -1
  541. package/esm/memory/procedural-memory.mjs.map +1 -1
  542. package/esm/memory/semantic-memory.mjs +1 -1
  543. package/esm/memory/semantic-memory.mjs.map +1 -1
  544. package/esm/memory/working-memory.mjs +1 -1
  545. package/esm/memory/working-memory.mjs.map +1 -1
  546. package/esm/middleware/builtins/budget-contract.type.d.mts +1 -1
  547. package/esm/middleware/builtins/budget-contract.type.d.mts.map +1 -1
  548. package/esm/middleware/builtins/budget.d.mts +1 -1
  549. package/esm/middleware/builtins/budget.d.mts.map +1 -1
  550. package/esm/middleware/builtins/budget.mjs +1 -1
  551. package/esm/middleware/builtins/budget.mjs.map +1 -1
  552. package/esm/middleware/builtins/guardrail.d.mts +1 -1
  553. package/esm/middleware/builtins/guardrail.d.mts.map +1 -1
  554. package/esm/middleware/builtins/guardrail.mjs +1 -1
  555. package/esm/middleware/builtins/guardrail.mjs.map +1 -1
  556. package/esm/middleware/builtins/semantic-cache.d.mts +1 -1
  557. package/esm/middleware/builtins/semantic-cache.d.mts.map +1 -1
  558. package/esm/middleware/builtins/semantic-cache.mjs +1 -1
  559. package/esm/middleware/builtins/semantic-cache.mjs.map +1 -1
  560. package/esm/middleware/helpers/compose.d.mts +1 -1
  561. package/esm/middleware/helpers/compose.d.mts.map +1 -1
  562. package/esm/middleware/helpers/compose.mjs +1 -1
  563. package/esm/middleware/helpers/compose.mjs.map +1 -1
  564. package/esm/middleware/helpers/for-tool.d.mts +1 -1
  565. package/esm/middleware/helpers/for-tool.d.mts.map +1 -1
  566. package/esm/middleware/helpers/for-tool.mjs +1 -1
  567. package/esm/middleware/helpers/for-tool.mjs.map +1 -1
  568. package/esm/middleware/pipeline.d.mts +1 -1
  569. package/esm/middleware/pipeline.d.mts.map +1 -1
  570. package/esm/middleware/pipeline.mjs +1 -1
  571. package/esm/middleware/pipeline.mjs.map +1 -1
  572. package/esm/middleware/utils/extract-user-text.d.mts +1 -1
  573. package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
  574. package/esm/middleware/utils/extract-user-text.mjs +1 -1
  575. package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
  576. package/esm/middleware/utils/namespaced-state.d.mts +1 -1
  577. package/esm/middleware/utils/namespaced-state.d.mts.map +1 -1
  578. package/esm/middleware/utils/namespaced-state.mjs +1 -1
  579. package/esm/middleware/utils/namespaced-state.mjs.map +1 -1
  580. package/esm/mock/mock-agent.d.mts +1 -1
  581. package/esm/mock/mock-agent.d.mts.map +1 -1
  582. package/esm/mock/mock-agent.mjs +1 -1
  583. package/esm/mock/mock-agent.mjs.map +1 -1
  584. package/esm/mock/mock-config.type.d.mts +1 -1
  585. package/esm/mock/mock-config.type.d.mts.map +1 -1
  586. package/esm/mock/mock-image-model.d.mts +1 -1
  587. package/esm/mock/mock-image-model.d.mts.map +1 -1
  588. package/esm/mock/mock-image-model.mjs +1 -1
  589. package/esm/mock/mock-image-model.mjs.map +1 -1
  590. package/esm/mock/mock-model.d.mts +1 -1
  591. package/esm/mock/mock-model.d.mts.map +1 -1
  592. package/esm/mock/mock-model.mjs +1 -1
  593. package/esm/mock/mock-model.mjs.map +1 -1
  594. package/esm/mock/mock-router.d.mts +1 -1
  595. package/esm/mock/mock-router.d.mts.map +1 -1
  596. package/esm/mock/mock-router.mjs +1 -1
  597. package/esm/mock/mock-router.mjs.map +1 -1
  598. package/esm/mock/mock-sdk.d.mts +1 -1
  599. package/esm/mock/mock-sdk.d.mts.map +1 -1
  600. package/esm/mock/mock-sdk.mjs +1 -1
  601. package/esm/mock/mock-sdk.mjs.map +1 -1
  602. package/esm/mock/mock-speech-model.d.mts +1 -1
  603. package/esm/mock/mock-speech-model.d.mts.map +1 -1
  604. package/esm/mock/mock-speech-model.mjs +1 -1
  605. package/esm/mock/mock-speech-model.mjs.map +1 -1
  606. package/esm/mock/mock-transcription-model.d.mts +1 -1
  607. package/esm/mock/mock-transcription-model.d.mts.map +1 -1
  608. package/esm/mock/mock-transcription-model.mjs +1 -1
  609. package/esm/mock/mock-transcription-model.mjs.map +1 -1
  610. package/esm/model/fallback-model.d.mts +1 -1
  611. package/esm/model/fallback-model.d.mts.map +1 -1
  612. package/esm/model/fallback-model.mjs +1 -1
  613. package/esm/model/fallback-model.mjs.map +1 -1
  614. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +1 -1
  615. package/esm/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -1
  616. package/esm/node_modules/@vitest/expect/dist/index.mjs +1 -1
  617. package/esm/node_modules/@vitest/expect/dist/index.mjs.map +1 -1
  618. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs +1 -1
  619. package/esm/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -1
  620. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs +1 -1
  621. package/esm/node_modules/@vitest/runner/dist/chunk-artifact.mjs.map +1 -1
  622. package/esm/node_modules/@vitest/snapshot/dist/index.mjs +1 -1
  623. package/esm/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -1
  624. package/esm/node_modules/@vitest/spy/dist/index.mjs +1 -1
  625. package/esm/node_modules/@vitest/spy/dist/index.mjs.map +1 -1
  626. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs +1 -1
  627. package/esm/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.mjs.map +1 -1
  628. package/esm/node_modules/@vitest/utils/dist/diff.mjs +1 -1
  629. package/esm/node_modules/@vitest/utils/dist/diff.mjs.map +1 -1
  630. package/esm/node_modules/@vitest/utils/dist/display.mjs +1 -1
  631. package/esm/node_modules/@vitest/utils/dist/display.mjs.map +1 -1
  632. package/esm/node_modules/@vitest/utils/dist/error.mjs +1 -1
  633. package/esm/node_modules/@vitest/utils/dist/error.mjs.map +1 -1
  634. package/esm/node_modules/@vitest/utils/dist/helpers.mjs +1 -1
  635. package/esm/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -1
  636. package/esm/node_modules/@vitest/utils/dist/offset.mjs +1 -1
  637. package/esm/node_modules/@vitest/utils/dist/offset.mjs.map +1 -1
  638. package/esm/node_modules/@vitest/utils/dist/serialize.mjs +1 -1
  639. package/esm/node_modules/@vitest/utils/dist/serialize.mjs.map +1 -1
  640. package/esm/node_modules/@vitest/utils/dist/source-map.mjs +1 -1
  641. package/esm/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -1
  642. package/esm/node_modules/@vitest/utils/dist/timers.mjs +1 -1
  643. package/esm/node_modules/@vitest/utils/dist/timers.mjs.map +1 -1
  644. package/esm/node_modules/chai/index.mjs +1 -1
  645. package/esm/node_modules/chai/index.mjs.map +1 -1
  646. package/esm/node_modules/magic-string/dist/magic-string.es.mjs +1 -1
  647. package/esm/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -1
  648. package/esm/node_modules/tinyrainbow/dist/index.mjs +1 -1
  649. package/esm/node_modules/tinyrainbow/dist/index.mjs.map +1 -1
  650. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs +1 -1
  651. package/esm/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.mjs.map +1 -1
  652. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs +1 -1
  653. package/esm/node_modules/vitest/dist/chunks/rpc.MzXet3jl.mjs.map +1 -1
  654. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs +1 -1
  655. package/esm/node_modules/vitest/dist/chunks/test.DNmyFkvJ.mjs.map +1 -1
  656. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs +1 -1
  657. package/esm/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.mjs.map +1 -1
  658. package/esm/object-stream/parse-partial-json.d.mts +1 -1
  659. package/esm/object-stream/parse-partial-json.d.mts.map +1 -1
  660. package/esm/object-stream/parse-partial-json.mjs +1 -1
  661. package/esm/object-stream/parse-partial-json.mjs.map +1 -1
  662. package/esm/object-stream/stream-object.d.mts +1 -1
  663. package/esm/object-stream/stream-object.d.mts.map +1 -1
  664. package/esm/object-stream/stream-object.mjs +1 -1
  665. package/esm/object-stream/stream-object.mjs.map +1 -1
  666. package/esm/observe/observer-registry.d.mts +1 -1
  667. package/esm/observe/observer-registry.d.mts.map +1 -1
  668. package/esm/observe/observer-registry.mjs +1 -1
  669. package/esm/observe/observer-registry.mjs.map +1 -1
  670. package/esm/observe/observer.contract.d.mts +1 -1
  671. package/esm/observe/observer.contract.d.mts.map +1 -1
  672. package/esm/observe/resolve-observers.d.mts +1 -1
  673. package/esm/observe/resolve-observers.d.mts.map +1 -1
  674. package/esm/observe/resolve-observers.mjs +1 -1
  675. package/esm/observe/resolve-observers.mjs.map +1 -1
  676. package/esm/orchestrator/as-tool.d.mts +1 -1
  677. package/esm/orchestrator/as-tool.d.mts.map +1 -1
  678. package/esm/orchestrator/as-tool.mjs +1 -1
  679. package/esm/orchestrator/as-tool.mjs.map +1 -1
  680. package/esm/orchestrator/checkpoint.mjs +1 -1
  681. package/esm/orchestrator/checkpoint.mjs.map +1 -1
  682. package/esm/orchestrator/commands.d.mts +1 -1
  683. package/esm/orchestrator/commands.d.mts.map +1 -1
  684. package/esm/orchestrator/commands.mjs +1 -1
  685. package/esm/orchestrator/commands.mjs.map +1 -1
  686. package/esm/orchestrator/compaction.mjs +1 -1
  687. package/esm/orchestrator/compaction.mjs.map +1 -1
  688. package/esm/orchestrator/dispatch.mjs +1 -1
  689. package/esm/orchestrator/dispatch.mjs.map +1 -1
  690. package/esm/orchestrator/emitter-port.type.d.mts +1 -1
  691. package/esm/orchestrator/emitter-port.type.d.mts.map +1 -1
  692. package/esm/orchestrator/emitter.d.mts +1 -1
  693. package/esm/orchestrator/emitter.d.mts.map +1 -1
  694. package/esm/orchestrator/emitter.mjs +1 -1
  695. package/esm/orchestrator/emitter.mjs.map +1 -1
  696. package/esm/orchestrator/engine-context.type.d.mts +1 -1
  697. package/esm/orchestrator/engine-context.type.d.mts.map +1 -1
  698. package/esm/orchestrator/execution.d.mts +1 -1
  699. package/esm/orchestrator/execution.d.mts.map +1 -1
  700. package/esm/orchestrator/execution.mjs +1 -1
  701. package/esm/orchestrator/execution.mjs.map +1 -1
  702. package/esm/orchestrator/load.mjs +1 -1
  703. package/esm/orchestrator/load.mjs.map +1 -1
  704. package/esm/orchestrator/lock.mjs +1 -1
  705. package/esm/orchestrator/lock.mjs.map +1 -1
  706. package/esm/orchestrator/memory.d.mts +1 -1
  707. package/esm/orchestrator/memory.d.mts.map +1 -1
  708. package/esm/orchestrator/memory.mjs +1 -1
  709. package/esm/orchestrator/memory.mjs.map +1 -1
  710. package/esm/orchestrator/orchestrator-stream.d.mts +1 -1
  711. package/esm/orchestrator/orchestrator-stream.d.mts.map +1 -1
  712. package/esm/orchestrator/orchestrator-stream.mjs +1 -1
  713. package/esm/orchestrator/orchestrator-stream.mjs.map +1 -1
  714. package/esm/orchestrator/orchestrator.d.mts +1 -1
  715. package/esm/orchestrator/orchestrator.d.mts.map +1 -1
  716. package/esm/orchestrator/orchestrator.mjs +1 -1
  717. package/esm/orchestrator/orchestrator.mjs.map +1 -1
  718. package/esm/orchestrator/resume.mjs +1 -1
  719. package/esm/orchestrator/resume.mjs.map +1 -1
  720. package/esm/orchestrator/session-lock.d.mts +1 -1
  721. package/esm/orchestrator/session-lock.d.mts.map +1 -1
  722. package/esm/orchestrator/session-lock.mjs +1 -1
  723. package/esm/orchestrator/session-lock.mjs.map +1 -1
  724. package/esm/orchestrator/signature.d.mts +1 -1
  725. package/esm/orchestrator/signature.d.mts.map +1 -1
  726. package/esm/orchestrator/signature.mjs +1 -1
  727. package/esm/orchestrator/signature.mjs.map +1 -1
  728. package/esm/orchestrator/window.mjs +1 -1
  729. package/esm/orchestrator/window.mjs.map +1 -1
  730. package/esm/planner/dag-scheduler.mjs +1 -1
  731. package/esm/planner/dag-scheduler.mjs.map +1 -1
  732. package/esm/planner/plan-prompt.d.mts +1 -1
  733. package/esm/planner/plan-prompt.d.mts.map +1 -1
  734. package/esm/planner/plan-prompt.mjs +1 -1
  735. package/esm/planner/plan-prompt.mjs.map +1 -1
  736. package/esm/planner/plan-schema.d.mts +1 -1
  737. package/esm/planner/plan-schema.d.mts.map +1 -1
  738. package/esm/planner/plan-schema.mjs +1 -1
  739. package/esm/planner/plan-schema.mjs.map +1 -1
  740. package/esm/planner/planner-run.d.mts +1 -1
  741. package/esm/planner/planner-run.d.mts.map +1 -1
  742. package/esm/planner/planner-run.mjs +1 -1
  743. package/esm/planner/planner-run.mjs.map +1 -1
  744. package/esm/planner/planner.d.mts +1 -1
  745. package/esm/planner/planner.d.mts.map +1 -1
  746. package/esm/planner/planner.mjs +1 -1
  747. package/esm/planner/planner.mjs.map +1 -1
  748. package/esm/planner/signature.d.mts +1 -1
  749. package/esm/planner/signature.d.mts.map +1 -1
  750. package/esm/planner/signature.mjs +1 -1
  751. package/esm/planner/signature.mjs.map +1 -1
  752. package/esm/planner/snapshot.mjs +1 -1
  753. package/esm/planner/snapshot.mjs.map +1 -1
  754. package/esm/prompt/errors.d.mts +1 -1
  755. package/esm/prompt/errors.d.mts.map +1 -1
  756. package/esm/prompt/errors.mjs +1 -1
  757. package/esm/prompt/errors.mjs.map +1 -1
  758. package/esm/prompt/prompt-langfuse-sync.mjs +1 -1
  759. package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -1
  760. package/esm/prompt/prompt-langfuse-sync.type.d.mts +1 -1
  761. package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -1
  762. package/esm/prompt/prompt-validate.mjs +1 -1
  763. package/esm/prompt/prompt-validate.mjs.map +1 -1
  764. package/esm/prompt/prompt.d.mts +1 -1
  765. package/esm/prompt/prompt.d.mts.map +1 -1
  766. package/esm/prompt/prompt.mjs +1 -1
  767. package/esm/prompt/prompt.mjs.map +1 -1
  768. package/esm/prompt/prompt.type.d.mts +1 -1
  769. package/esm/prompt/prompt.type.d.mts.map +1 -1
  770. package/esm/prompts/prompts-manager.contract.d.mts +1 -1
  771. package/esm/prompts/prompts-manager.contract.d.mts.map +1 -1
  772. package/esm/prompts/prompts-manager.d.mts +1 -1
  773. package/esm/prompts/prompts-manager.d.mts.map +1 -1
  774. package/esm/prompts/prompts-manager.mjs +1 -1
  775. package/esm/prompts/prompts-manager.mjs.map +1 -1
  776. package/esm/prompts/prompts-manager.type.d.mts +1 -1
  777. package/esm/prompts/prompts-manager.type.d.mts.map +1 -1
  778. package/esm/prompts/prompts-validate.d.mts +1 -1
  779. package/esm/prompts/prompts-validate.d.mts.map +1 -1
  780. package/esm/prompts/prompts-validate.mjs +0 -0
  781. package/esm/prompts/prompts-validate.mjs.map +1 -1
  782. package/esm/rag/as-tool.mjs +1 -1
  783. package/esm/rag/as-tool.mjs.map +1 -1
  784. package/esm/rag/chunk/chunk.d.mts +1 -1
  785. package/esm/rag/chunk/chunk.d.mts.map +1 -1
  786. package/esm/rag/chunk/chunk.mjs +1 -1
  787. package/esm/rag/chunk/chunk.mjs.map +1 -1
  788. package/esm/rag/chunk/fixed.mjs +1 -1
  789. package/esm/rag/chunk/fixed.mjs.map +1 -1
  790. package/esm/rag/chunk/markdown.mjs +1 -1
  791. package/esm/rag/chunk/markdown.mjs.map +1 -1
  792. package/esm/rag/chunk/recursive.mjs +1 -1
  793. package/esm/rag/chunk/recursive.mjs.map +1 -1
  794. package/esm/rag/chunk/sentence.mjs +1 -1
  795. package/esm/rag/chunk/sentence.mjs.map +1 -1
  796. package/esm/rag/contracts/chunk-options.type.d.mts +1 -1
  797. package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -1
  798. package/esm/rag/contracts/citation.type.d.mts +1 -1
  799. package/esm/rag/contracts/citation.type.d.mts.map +1 -1
  800. package/esm/rag/contracts/rag-config.type.d.mts +1 -1
  801. package/esm/rag/contracts/rag-config.type.d.mts.map +1 -1
  802. package/esm/rag/contracts/rag-document.type.d.mts +1 -1
  803. package/esm/rag/contracts/rag-document.type.d.mts.map +1 -1
  804. package/esm/rag/hybrid/bm25.d.mts +1 -1
  805. package/esm/rag/hybrid/bm25.d.mts.map +1 -1
  806. package/esm/rag/hybrid/bm25.mjs +1 -1
  807. package/esm/rag/hybrid/bm25.mjs.map +1 -1
  808. package/esm/rag/hybrid/hybrid-rank.d.mts +1 -1
  809. package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -1
  810. package/esm/rag/hybrid/hybrid-rank.mjs +1 -1
  811. package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -1
  812. package/esm/rag/hybrid/rrf.d.mts +1 -1
  813. package/esm/rag/hybrid/rrf.d.mts.map +1 -1
  814. package/esm/rag/hybrid/rrf.mjs +1 -1
  815. package/esm/rag/hybrid/rrf.mjs.map +1 -1
  816. package/esm/rag/loaders/errors.d.mts +1 -1
  817. package/esm/rag/loaders/errors.d.mts.map +1 -1
  818. package/esm/rag/loaders/errors.mjs +1 -1
  819. package/esm/rag/loaders/errors.mjs.map +1 -1
  820. package/esm/rag/loaders/load-html.d.mts +1 -1
  821. package/esm/rag/loaders/load-html.d.mts.map +1 -1
  822. package/esm/rag/loaders/load-html.mjs +1 -1
  823. package/esm/rag/loaders/load-html.mjs.map +1 -1
  824. package/esm/rag/loaders/load-pdf.d.mts +1 -1
  825. package/esm/rag/loaders/load-pdf.d.mts.map +1 -1
  826. package/esm/rag/loaders/load-pdf.mjs +1 -1
  827. package/esm/rag/loaders/load-pdf.mjs.map +1 -1
  828. package/esm/rag/loaders/load-text.d.mts +1 -1
  829. package/esm/rag/loaders/load-text.d.mts.map +1 -1
  830. package/esm/rag/loaders/load-text.mjs +1 -1
  831. package/esm/rag/loaders/load-text.mjs.map +1 -1
  832. package/esm/rag/loaders/load-web.d.mts +1 -1
  833. package/esm/rag/loaders/load-web.d.mts.map +1 -1
  834. package/esm/rag/loaders/load-web.mjs +1 -1
  835. package/esm/rag/loaders/load-web.mjs.map +1 -1
  836. package/esm/rag/loaders/loader.type.d.mts +1 -1
  837. package/esm/rag/loaders/loader.type.d.mts.map +1 -1
  838. package/esm/rag/rag.d.mts +1 -1
  839. package/esm/rag/rag.d.mts.map +1 -1
  840. package/esm/rag/rag.mjs +1 -1
  841. package/esm/rag/rag.mjs.map +1 -1
  842. package/esm/rag/rerank/keyword-reranker.d.mts +1 -1
  843. package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -1
  844. package/esm/rag/rerank/keyword-reranker.mjs +1 -1
  845. package/esm/rag/rerank/keyword-reranker.mjs.map +1 -1
  846. package/esm/rag/rerank/llm-reranker.d.mts +1 -1
  847. package/esm/rag/rerank/llm-reranker.d.mts.map +1 -1
  848. package/esm/rag/rerank/llm-reranker.mjs +1 -1
  849. package/esm/rag/rerank/llm-reranker.mjs.map +1 -1
  850. package/esm/rag/rerank/reranker.contract.d.mts +1 -1
  851. package/esm/rag/rerank/reranker.contract.d.mts.map +1 -1
  852. package/esm/rag/retrieve.mjs +1 -1
  853. package/esm/rag/retrieve.mjs.map +1 -1
  854. package/esm/rag/store/cache-vector-store.d.mts +1 -1
  855. package/esm/rag/store/cache-vector-store.d.mts.map +1 -1
  856. package/esm/rag/store/cache-vector-store.mjs +1 -1
  857. package/esm/rag/store/cache-vector-store.mjs.map +1 -1
  858. package/esm/rag/store/pg-vector-store.d.mts +1 -1
  859. package/esm/rag/store/pg-vector-store.d.mts.map +1 -1
  860. package/esm/rag/store/pg-vector-store.mjs +1 -1
  861. package/esm/rag/store/pg-vector-store.mjs.map +1 -1
  862. package/esm/rag/store/vector-store.contract.d.mts +1 -1
  863. package/esm/rag/store/vector-store.contract.d.mts.map +1 -1
  864. package/esm/rag/transforms/multi-query.d.mts +1 -1
  865. package/esm/rag/transforms/multi-query.d.mts.map +1 -1
  866. package/esm/rag/transforms/multi-query.mjs +1 -1
  867. package/esm/rag/transforms/multi-query.mjs.map +1 -1
  868. package/esm/security/outbound-policy.d.mts +1 -1
  869. package/esm/security/outbound-policy.d.mts.map +1 -1
  870. package/esm/security/outbound-policy.mjs +1 -1
  871. package/esm/security/outbound-policy.mjs.map +1 -1
  872. package/esm/security/outbound-policy.type.d.mts +1 -1
  873. package/esm/security/outbound-policy.type.d.mts.map +1 -1
  874. package/esm/security/private-ip.d.mts +1 -1
  875. package/esm/security/private-ip.d.mts.map +1 -1
  876. package/esm/security/private-ip.mjs +1 -1
  877. package/esm/security/private-ip.mjs.map +1 -1
  878. package/esm/security/redact.d.mts +1 -1
  879. package/esm/security/redact.d.mts.map +1 -1
  880. package/esm/security/redact.mjs +1 -1
  881. package/esm/security/redact.mjs.map +1 -1
  882. package/esm/serve/serve.d.mts +1 -1
  883. package/esm/serve/serve.d.mts.map +1 -1
  884. package/esm/serve/serve.mjs +1 -1
  885. package/esm/serve/serve.mjs.map +1 -1
  886. package/esm/serve/sse.d.mts +1 -1
  887. package/esm/serve/sse.d.mts.map +1 -1
  888. package/esm/serve/sse.mjs +1 -1
  889. package/esm/serve/sse.mjs.map +1 -1
  890. package/esm/serve/stream-to-sse.d.mts +1 -1
  891. package/esm/serve/stream-to-sse.d.mts.map +1 -1
  892. package/esm/serve/stream-to-sse.mjs +1 -1
  893. package/esm/serve/stream-to-sse.mjs.map +1 -1
  894. package/esm/skills/catalog.d.mts +1 -1
  895. package/esm/skills/catalog.d.mts.map +1 -1
  896. package/esm/skills/catalog.mjs +1 -1
  897. package/esm/skills/catalog.mjs.map +1 -1
  898. package/esm/skills/contracts/skill-record.type.d.mts +1 -1
  899. package/esm/skills/contracts/skill-record.type.d.mts.map +1 -1
  900. package/esm/skills/contracts/skills-config.type.d.mts +1 -1
  901. package/esm/skills/contracts/skills-config.type.d.mts.map +1 -1
  902. package/esm/skills/contracts/skills-store.contract.d.mts +1 -1
  903. package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -1
  904. package/esm/skills/contracts/skills.contract.d.mts +1 -1
  905. package/esm/skills/contracts/skills.contract.d.mts.map +1 -1
  906. package/esm/skills/load-skill-tool.d.mts +1 -1
  907. package/esm/skills/load-skill-tool.d.mts.map +1 -1
  908. package/esm/skills/load-skill-tool.mjs +1 -1
  909. package/esm/skills/load-skill-tool.mjs.map +1 -1
  910. package/esm/skills/review-gate.d.mts +1 -1
  911. package/esm/skills/review-gate.d.mts.map +1 -1
  912. package/esm/skills/review-gate.mjs +1 -1
  913. package/esm/skills/review-gate.mjs.map +1 -1
  914. package/esm/skills/save-skill-tool.d.mts +1 -1
  915. package/esm/skills/save-skill-tool.d.mts.map +1 -1
  916. package/esm/skills/save-skill-tool.mjs +1 -1
  917. package/esm/skills/save-skill-tool.mjs.map +1 -1
  918. package/esm/skills/skills.d.mts +1 -1
  919. package/esm/skills/skills.d.mts.map +1 -1
  920. package/esm/skills/skills.mjs +1 -1
  921. package/esm/skills/skills.mjs.map +1 -1
  922. package/esm/skills/sources/directory-source.d.mts +1 -1
  923. package/esm/skills/sources/directory-source.d.mts.map +1 -1
  924. package/esm/skills/sources/directory-source.mjs +1 -1
  925. package/esm/skills/sources/directory-source.mjs.map +1 -1
  926. package/esm/skills/sources/index.d.mts +1 -1
  927. package/esm/skills/sources/index.d.mts.map +1 -1
  928. package/esm/skills/sources/index.mjs +1 -1
  929. package/esm/skills/sources/index.mjs.map +1 -1
  930. package/esm/skills/sources/parse-frontmatter.d.mts +1 -1
  931. package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -1
  932. package/esm/skills/sources/parse-frontmatter.mjs +1 -1
  933. package/esm/skills/sources/parse-frontmatter.mjs.map +1 -1
  934. package/esm/skills/sources/store-source.d.mts +1 -1
  935. package/esm/skills/sources/store-source.d.mts.map +1 -1
  936. package/esm/skills/sources/store-source.mjs +1 -1
  937. package/esm/skills/sources/store-source.mjs.map +1 -1
  938. package/esm/skills/sources/url-source.d.mts +1 -1
  939. package/esm/skills/sources/url-source.d.mts.map +1 -1
  940. package/esm/skills/sources/url-source.mjs +1 -1
  941. package/esm/skills/sources/url-source.mjs.map +1 -1
  942. package/esm/skills/store/mock-skills-store.d.mts +1 -1
  943. package/esm/skills/store/mock-skills-store.d.mts.map +1 -1
  944. package/esm/skills/store/mock-skills-store.mjs +1 -1
  945. package/esm/skills/store/mock-skills-store.mjs.map +1 -1
  946. package/esm/skills/store/procedural-skill-store.d.mts +1 -1
  947. package/esm/skills/store/procedural-skill-store.d.mts.map +1 -1
  948. package/esm/skills/store/procedural-skill-store.mjs +1 -1
  949. package/esm/skills/store/procedural-skill-store.mjs.map +1 -1
  950. package/esm/snapshot/memory.d.mts +1 -1
  951. package/esm/snapshot/memory.d.mts.map +1 -1
  952. package/esm/snapshot/memory.mjs +1 -1
  953. package/esm/snapshot/memory.mjs.map +1 -1
  954. package/esm/snapshot/pg.d.mts +1 -1
  955. package/esm/snapshot/pg.d.mts.map +1 -1
  956. package/esm/snapshot/pg.mjs +1 -1
  957. package/esm/snapshot/pg.mjs.map +1 -1
  958. package/esm/snapshot/redis.d.mts +1 -1
  959. package/esm/snapshot/redis.d.mts.map +1 -1
  960. package/esm/snapshot/redis.mjs +1 -1
  961. package/esm/snapshot/redis.mjs.map +1 -1
  962. package/esm/speech/speech.d.mts +1 -1
  963. package/esm/speech/speech.d.mts.map +1 -1
  964. package/esm/speech/speech.mjs +1 -1
  965. package/esm/speech/speech.mjs.map +1 -1
  966. package/esm/supervisor/as-tool.d.mts +1 -1
  967. package/esm/supervisor/as-tool.d.mts.map +1 -1
  968. package/esm/supervisor/as-tool.mjs +1 -1
  969. package/esm/supervisor/as-tool.mjs.map +1 -1
  970. package/esm/supervisor/cancellation.d.mts +1 -1
  971. package/esm/supervisor/cancellation.d.mts.map +1 -1
  972. package/esm/supervisor/cancellation.mjs +1 -1
  973. package/esm/supervisor/cancellation.mjs.map +1 -1
  974. package/esm/supervisor/decide.mjs +1 -1
  975. package/esm/supervisor/decide.mjs.map +1 -1
  976. package/esm/supervisor/emitter.d.mts +1 -1
  977. package/esm/supervisor/emitter.d.mts.map +1 -1
  978. package/esm/supervisor/emitter.mjs +1 -1
  979. package/esm/supervisor/emitter.mjs.map +1 -1
  980. package/esm/supervisor/entries.d.mts +1 -1
  981. package/esm/supervisor/entries.d.mts.map +1 -1
  982. package/esm/supervisor/entries.mjs +1 -1
  983. package/esm/supervisor/entries.mjs.map +1 -1
  984. package/esm/supervisor/execution.d.mts +1 -1
  985. package/esm/supervisor/execution.d.mts.map +1 -1
  986. package/esm/supervisor/execution.mjs +1 -1
  987. package/esm/supervisor/execution.mjs.map +1 -1
  988. package/esm/supervisor/fan-out.d.mts +1 -1
  989. package/esm/supervisor/fan-out.d.mts.map +1 -1
  990. package/esm/supervisor/fan-out.mjs +1 -1
  991. package/esm/supervisor/fan-out.mjs.map +1 -1
  992. package/esm/supervisor/router-factory.d.mts +1 -1
  993. package/esm/supervisor/router-factory.d.mts.map +1 -1
  994. package/esm/supervisor/router-factory.mjs +1 -1
  995. package/esm/supervisor/router-factory.mjs.map +1 -1
  996. package/esm/supervisor/router-prompt.d.mts +1 -1
  997. package/esm/supervisor/router-prompt.d.mts.map +1 -1
  998. package/esm/supervisor/router-prompt.mjs +1 -1
  999. package/esm/supervisor/router-prompt.mjs.map +1 -1
  1000. package/esm/supervisor/signature.d.mts +1 -1
  1001. package/esm/supervisor/signature.d.mts.map +1 -1
  1002. package/esm/supervisor/signature.mjs +1 -1
  1003. package/esm/supervisor/signature.mjs.map +1 -1
  1004. package/esm/supervisor/snapshot.d.mts +1 -1
  1005. package/esm/supervisor/snapshot.d.mts.map +1 -1
  1006. package/esm/supervisor/snapshot.mjs +1 -1
  1007. package/esm/supervisor/snapshot.mjs.map +1 -1
  1008. package/esm/supervisor/supervisor-stream.d.mts +1 -1
  1009. package/esm/supervisor/supervisor-stream.d.mts.map +1 -1
  1010. package/esm/supervisor/supervisor-stream.mjs +1 -1
  1011. package/esm/supervisor/supervisor-stream.mjs.map +1 -1
  1012. package/esm/supervisor/supervisor.d.mts +1 -1
  1013. package/esm/supervisor/supervisor.d.mts.map +1 -1
  1014. package/esm/supervisor/supervisor.mjs +1 -1
  1015. package/esm/supervisor/supervisor.mjs.map +1 -1
  1016. package/esm/system-prompt/instruction.d.mts +1 -1
  1017. package/esm/system-prompt/instruction.d.mts.map +1 -1
  1018. package/esm/system-prompt/instruction.mjs +1 -1
  1019. package/esm/system-prompt/instruction.mjs.map +1 -1
  1020. package/esm/system-prompt/persona.d.mts +1 -1
  1021. package/esm/system-prompt/persona.d.mts.map +1 -1
  1022. package/esm/system-prompt/persona.mjs +1 -1
  1023. package/esm/system-prompt/persona.mjs.map +1 -1
  1024. package/esm/system-prompt/refined-system-prompt.d.mts +1 -1
  1025. package/esm/system-prompt/refined-system-prompt.d.mts.map +1 -1
  1026. package/esm/system-prompt/refined-system-prompt.mjs +1 -1
  1027. package/esm/system-prompt/refined-system-prompt.mjs.map +1 -1
  1028. package/esm/system-prompt/render-placeholders.d.mts +1 -1
  1029. package/esm/system-prompt/render-placeholders.d.mts.map +1 -1
  1030. package/esm/system-prompt/render-placeholders.mjs +1 -1
  1031. package/esm/system-prompt/render-placeholders.mjs.map +1 -1
  1032. package/esm/system-prompt/system-prompt.d.mts +1 -1
  1033. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  1034. package/esm/system-prompt/system-prompt.mjs +1 -1
  1035. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  1036. package/esm/team/gates.mjs +1 -1
  1037. package/esm/team/gates.mjs.map +1 -1
  1038. package/esm/team/team.d.mts +1 -1
  1039. package/esm/team/team.d.mts.map +1 -1
  1040. package/esm/team/team.mjs +1 -1
  1041. package/esm/team/team.mjs.map +1 -1
  1042. package/esm/testing/matcher-logic.d.mts +1 -1
  1043. package/esm/testing/matcher-logic.d.mts.map +1 -1
  1044. package/esm/testing/matcher-logic.mjs +1 -1
  1045. package/esm/testing/matcher-logic.mjs.map +1 -1
  1046. package/esm/testing/matchers.d.mts +1 -1
  1047. package/esm/testing/matchers.d.mts.map +1 -1
  1048. package/esm/testing/matchers.mjs +1 -1
  1049. package/esm/testing/matchers.mjs.map +1 -1
  1050. package/esm/testing/register-lazy.d.mts +1 -1
  1051. package/esm/testing/register-lazy.d.mts.map +1 -1
  1052. package/esm/testing/register-lazy.mjs +1 -1
  1053. package/esm/testing/register-lazy.mjs.map +1 -1
  1054. package/esm/tool/executable-as-tool.d.mts +1 -1
  1055. package/esm/tool/executable-as-tool.d.mts.map +1 -1
  1056. package/esm/tool/executable-as-tool.mjs +1 -1
  1057. package/esm/tool/executable-as-tool.mjs.map +1 -1
  1058. package/esm/tool/tool.d.mts +1 -1
  1059. package/esm/tool/tool.d.mts.map +1 -1
  1060. package/esm/tool/tool.mjs +1 -1
  1061. package/esm/tool/tool.mjs.map +1 -1
  1062. package/esm/transcribe/audio-input.d.mts +1 -1
  1063. package/esm/transcribe/audio-input.d.mts.map +1 -1
  1064. package/esm/transcribe/audio-input.mjs +1 -1
  1065. package/esm/transcribe/audio-input.mjs.map +1 -1
  1066. package/esm/transcribe/transcribe.d.mts +1 -1
  1067. package/esm/transcribe/transcribe.d.mts.map +1 -1
  1068. package/esm/transcribe/transcribe.mjs +1 -1
  1069. package/esm/transcribe/transcribe.mjs.map +1 -1
  1070. package/esm/utils/compute-cost.d.mts +1 -1
  1071. package/esm/utils/compute-cost.d.mts.map +1 -1
  1072. package/esm/utils/compute-cost.mjs +1 -1
  1073. package/esm/utils/compute-cost.mjs.map +1 -1
  1074. package/esm/utils/extract-json-lenient.d.mts +1 -1
  1075. package/esm/utils/extract-json-lenient.d.mts.map +1 -1
  1076. package/esm/utils/extract-json-lenient.mjs +1 -1
  1077. package/esm/utils/extract-json-lenient.mjs.map +1 -1
  1078. package/esm/utils/extract-json-payload.d.mts +1 -1
  1079. package/esm/utils/extract-json-payload.d.mts.map +1 -1
  1080. package/esm/utils/extract-json-payload.mjs +1 -1
  1081. package/esm/utils/extract-json-payload.mjs.map +1 -1
  1082. package/esm/utils/generate-run-id.d.mts +1 -1
  1083. package/esm/utils/generate-run-id.d.mts.map +1 -1
  1084. package/esm/utils/generate-run-id.mjs +1 -1
  1085. package/esm/utils/generate-run-id.mjs.map +1 -1
  1086. package/esm/utils/json-schema.d.mts +1 -1
  1087. package/esm/utils/json-schema.d.mts.map +1 -1
  1088. package/esm/utils/json-schema.mjs +1 -1
  1089. package/esm/utils/json-schema.mjs.map +1 -1
  1090. package/esm/utils/prepare-attachment-part.d.mts +1 -1
  1091. package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
  1092. package/esm/utils/prepare-attachment-part.mjs +1 -1
  1093. package/esm/utils/prepare-attachment-part.mjs.map +1 -1
  1094. package/esm/utils/resolve-attachment.d.mts +1 -1
  1095. package/esm/utils/resolve-attachment.d.mts.map +1 -1
  1096. package/esm/utils/resolve-attachment.mjs +1 -1
  1097. package/esm/utils/resolve-attachment.mjs.map +1 -1
  1098. package/esm/utils/run-context.d.mts +1 -1
  1099. package/esm/utils/run-context.d.mts.map +1 -1
  1100. package/esm/utils/run-context.mjs +1 -1
  1101. package/esm/utils/run-context.mjs.map +1 -1
  1102. package/esm/utils/safe-json-parse.d.mts +1 -1
  1103. package/esm/utils/safe-json-parse.d.mts.map +1 -1
  1104. package/esm/utils/safe-json-parse.mjs +1 -1
  1105. package/esm/utils/safe-json-parse.mjs.map +1 -1
  1106. package/esm/utils/stamp-report-lineage.d.mts +1 -1
  1107. package/esm/utils/stamp-report-lineage.d.mts.map +1 -1
  1108. package/esm/utils/stamp-report-lineage.mjs +1 -1
  1109. package/esm/utils/stamp-report-lineage.mjs.map +1 -1
  1110. package/esm/utils/token-count.d.mts +1 -1
  1111. package/esm/utils/token-count.d.mts.map +1 -1
  1112. package/esm/utils/token-count.mjs +1 -1
  1113. package/esm/utils/token-count.mjs.map +1 -1
  1114. package/esm/vcr/cassette-io.mjs +1 -1
  1115. package/esm/vcr/cassette-io.mjs.map +1 -1
  1116. package/esm/vcr/errors.d.mts +1 -1
  1117. package/esm/vcr/errors.d.mts.map +1 -1
  1118. package/esm/vcr/errors.mjs +1 -1
  1119. package/esm/vcr/errors.mjs.map +1 -1
  1120. package/esm/vcr/hash-request.d.mts +1 -1
  1121. package/esm/vcr/hash-request.d.mts.map +1 -1
  1122. package/esm/vcr/hash-request.mjs +1 -1
  1123. package/esm/vcr/hash-request.mjs.map +1 -1
  1124. package/esm/vcr/vcr.d.mts +1 -1
  1125. package/esm/vcr/vcr.d.mts.map +1 -1
  1126. package/esm/vcr/vcr.mjs +1 -1
  1127. package/esm/vcr/vcr.mjs.map +1 -1
  1128. package/esm/vcr/vcr.type.d.mts +1 -1
  1129. package/esm/vcr/vcr.type.d.mts.map +1 -1
  1130. package/esm/workflow/as-tool.mjs +1 -1
  1131. package/esm/workflow/as-tool.mjs.map +1 -1
  1132. package/esm/workflow/cancellation.mjs +1 -1
  1133. package/esm/workflow/cancellation.mjs.map +1 -1
  1134. package/esm/workflow/emitter.mjs +1 -1
  1135. package/esm/workflow/emitter.mjs.map +1 -1
  1136. package/esm/workflow/engine.mjs +5 -2
  1137. package/esm/workflow/engine.mjs.map +1 -1
  1138. package/esm/workflow/retry.mjs +1 -1
  1139. package/esm/workflow/retry.mjs.map +1 -1
  1140. package/esm/workflow/router.mjs +1 -1
  1141. package/esm/workflow/router.mjs.map +1 -1
  1142. package/esm/workflow/run-scoped-emitter.mjs +1 -1
  1143. package/esm/workflow/run-scoped-emitter.mjs.map +1 -1
  1144. package/esm/workflow/signature.d.mts +1 -1
  1145. package/esm/workflow/signature.d.mts.map +1 -1
  1146. package/esm/workflow/signature.mjs +1 -1
  1147. package/esm/workflow/signature.mjs.map +1 -1
  1148. package/esm/workflow/snapshot.mjs +1 -1
  1149. package/esm/workflow/snapshot.mjs.map +1 -1
  1150. package/esm/workflow/state.mjs +1 -1
  1151. package/esm/workflow/state.mjs.map +1 -1
  1152. package/esm/workflow/step-runner.mjs +25 -6
  1153. package/esm/workflow/step-runner.mjs.map +1 -1
  1154. package/esm/workflow/step.d.mts +1 -1
  1155. package/esm/workflow/step.d.mts.map +1 -1
  1156. package/esm/workflow/step.mjs +1 -1
  1157. package/esm/workflow/step.mjs.map +1 -1
  1158. package/esm/workflow/workflow.d.mts +1 -1
  1159. package/esm/workflow/workflow.d.mts.map +1 -1
  1160. package/esm/workflow/workflow.mjs +1 -1
  1161. package/esm/workflow/workflow.mjs.map +1 -1
  1162. package/llms-full.txt +23 -2
  1163. package/package.json +4 -4
  1164. package/skills/observe-ai-flows/SKILL.md +2 -2
  1165. package/skills/run-ai-workflow/SKILL.md +19 -0
  1166. package/skills/run-supervisor/SKILL.md +2 -0
  1167. package/cjs/magic-string.es-BtxW4VqG.cjs.map +0 -1
  1168. package/cjs/matcher-logic-SBnzYohQ.cjs.map +0 -1
  1169. package/cjs/matchers-BBh3gyB-.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"loader.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/loaders/loader.type.ts"],"mappings":";;;;;;AAgBA;;;;AAAyC;AASzC;;;;;;KATY,eAAA,GAAkB,WAAW;;;;;;AAwB5B;AAIb;KAnBY,iBAAA;;;AAmBa;AAQzB;EAtBE,MAAA;EAEA,KAAA,WA0BA;EAxBA,MAAA,GAAS,aAAa,EA6BX;EA3BX,IAAA,WA6BI;EA3BJ,SAAA,WA+BU;EA7BV,WAAA;AAAA;;KAIU,aAAA;AA4BZ;;;;AAA8C;AAG9C;AAHA,KApBY,gBAAA;;;AA6BH;AAST;;EAhCE,EAAA;EAsCuB;;;;EAjCvB,QAAA,GAAW,MAAM,mBAiCM;EA/BvB,IAAA;AAAA;;KAIU,eAAA,GAAkB,gBAAgB;;KAGlC,eAAA,GAAkB,gBAAgB;;KAGlC,cAAA,GAAiB,gBAAgB;;;;;;EAM3C,OAAO;AAAA;;;;;;;KASG,cAAA,GAAiB,gBAAA;;;;;;EAM3B,MAAA,GAAS,cAAc;AAAA"}
1
+ {"version":3,"file":"loader.type.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/loaders/loader.type.ts"],"mappings":";;;;;;AAgBA;;;;AAAyC;AASzC;;;;;;KATY,eAAA,GAAkB,WAAW;;;;;;AAwB5B;AAIb;KAnBY,iBAAA;;;AAmBa;AAQzB;EAtBE,MAAA;EAEA,KAAA,WA0BA;EAxBA,MAAA,GAAS,aAAa,EA6BX;EA3BX,IAAA,WA6BI;EA3BJ,SAAA,WA+BU;EA7BV,WAAA;AAAA;;KAIU,aAAA;AA4BZ;;;;AAA8C;AAG9C;AAHA,KApBY,gBAAA;;;AA6BH;AAST;;EAhCE,EAAA;EAsCuB;;;;EAjCvB,QAAA,GAAW,MAAM,mBAiCM;EA/BvB,IAAA;AAAA;;KAIU,eAAA,GAAkB,gBAAgB;;KAGlC,eAAA,GAAkB,gBAAgB;;KAGlC,cAAA,GAAiB,gBAAgB;;;;;;EAM3C,OAAO;AAAA;;;;;;;KASG,cAAA,GAAiB,gBAAA;;;;;;EAM3B,MAAA,GAAS,cAAc;AAAA"}
package/esm/rag/rag.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Rag, RagConfig } from "./contracts/rag-config.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/rag/rag.d.ts
3
+ //#region ../ai/src/rag/rag.d.ts
4
4
  /**
5
5
  * Create a RAG pipeline: **chunk → embed → vector store → retrieve →
6
6
  * rerank → cite**, reusing the app's `ai.embedder` for embedding, a
@@ -1 +1 @@
1
- {"version":3,"file":"rag.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/rag/rag.ts"],"mappings":";;;;;AAyDA;;;;;;;;AAA2C;;;;;;;;;;;;;;;;;;;;;iBAA3B,GAAA,CAAI,MAAA,EAAQ,SAAA,GAAY,GAAG"}
1
+ {"version":3,"file":"rag.d.mts","names":[],"sources":["../../../../../../../ai/src/rag/rag.ts"],"mappings":";;;;;AAyDA;;;;;;;;AAA2C;;;;;;;;;;;;;;;;;;;;;iBAA3B,GAAA,CAAI,MAAA,EAAQ,SAAA,GAAY,GAAG"}
package/esm/rag/rag.mjs CHANGED
@@ -4,7 +4,7 @@ import { ragAsTool } from "./as-tool.mjs";
4
4
  import { retrieve } from "./retrieve.mjs";
5
5
  import { cacheVectorStore } from "./store/cache-vector-store.mjs";
6
6
 
7
- //#region ../@warlock.js/ai/src/rag/rag.ts
7
+ //#region ../ai/src/rag/rag.ts
8
8
  const DEFAULT_NAME = "rag";
9
9
  const DEFAULT_NAMESPACE_PREFIX = "ai.rag";
10
10
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"rag.mjs","names":["chunkText","runRetrieve"],"sources":["../../../../../../../@warlock.js/ai/src/rag/rag.ts"],"sourcesContent":["import { resolveDefaultStore } from \"../config\";\nimport { chunk as chunkText } from \"./chunk/chunk\";\nimport type { ChunkOptions } from \"./contracts/chunk-options.type\";\nimport type { RetrieveOptions, RetrieveResult } from \"./contracts/citation.type\";\nimport type {\n Rag,\n RagAsToolOptions,\n RagConfig,\n} from \"./contracts/rag-config.type\";\nimport type { RagDocument } from \"./contracts/rag-document.type\";\nimport { ragAsTool } from \"./as-tool\";\nimport { retrieve as runRetrieve, type StoredChunk } from \"./retrieve\";\nimport { cacheVectorStore } from \"./store/cache-vector-store\";\nimport type { VectorStore } from \"./store/vector-store.contract\";\n\nconst DEFAULT_NAME = \"rag\";\nconst DEFAULT_NAMESPACE_PREFIX = \"ai.rag\";\n\n/**\n * Max chunk texts embedded per `embedder.embedMany()` call. One call is\n * one provider request, so a giant document is sub-batched to stay under\n * the provider's per-request token cap (the design's \"chunk larger than\n * provider per-request cap\" guard).\n */\nconst DEFAULT_MAX_BATCH = 96;\n\n/**\n * Create a RAG pipeline: **chunk → embed → vector store → retrieve →\n * rerank → cite**, reusing the app's `ai.embedder` for embedding, a\n * `@warlock.js/cache` `CacheDriver` as the vector store, and the\n * composite-as-tool engine to expose retrieval as a tool.\n *\n * Resolution is loud at construction (mirroring `memory()`):\n * - `embedder` is required — a provider with no embedder must be caught\n * here, not at first index.\n * - `store` falls back to `ai.config({ defaultStore })`; if neither\n * resolves, construction throws.\n *\n * `retrieve()` is return-only — it never auto-injects into a prompt; the\n * caller formats the cited chunks (or uses `asTool()` for the agent loop).\n * The reranker is OFF by default (cosine-only) unless `config.reranker`\n * is set.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n * import { MemoryCacheDriver } from \"@warlock.js/cache\";\n *\n * const kb = ai.rag({\n * name: \"docs\",\n * embedder: openai.embedder({ name: \"text-embedding-3-small\" }),\n * store: new MemoryCacheDriver(),\n * chunk: { type: \"markdown\", size: 800, overlap: 120 },\n * });\n *\n * await kb.index([{ id: \"guide\", text: longMarkdown, metadata: { url: \"/guide\" } }]);\n * const { chunks } = await kb.retrieve(\"how do I configure caching?\", { topK: 4 });\n */\nexport function rag(config: RagConfig): Rag {\n const name = config.name ?? DEFAULT_NAME;\n\n if (!config.embedder) {\n throw new Error(\n `rag(\"${name}\"): an \\`embedder\\` is required — pass one from a provider that supports embeddings (e.g. openai.embedder({ name: \"text-embedding-3-small\" }))`,\n );\n }\n\n const driver = config.store ?? resolveDefaultStore();\n\n if (!driver) {\n throw new Error(\n `rag(\"${name}\"): no store — pass \\`store\\` (a vector-capable @warlock.js/cache CacheDriver) or call \\`ai.config({ defaultStore })\\` at app boot before constructing the rag`,\n );\n }\n\n const store: VectorStore = cacheVectorStore(driver);\n const namespace = config.namespace ?? `${DEFAULT_NAMESPACE_PREFIX}.${name}`;\n const embedder = config.embedder;\n\n // Captured at first index for the dimension-mismatch guard in retrieve().\n let indexedDimensions: number | undefined;\n\n const instance: Rag = {\n name,\n\n async index(\n docs: RagDocument[],\n chunkOverride?: ChunkOptions,\n ): Promise<{ chunks: number }> {\n const chunkOptions = chunkOverride ?? config.chunk;\n\n // Ingestion guardrails (D5) — fail BEFORE any embedding spend.\n const limits = config.limits;\n if (limits?.maxDocuments !== undefined && docs.length > limits.maxDocuments) {\n throw new Error(\n `rag(\"${name}\"): index() received ${docs.length} documents, exceeding the configured maxDocuments of ${limits.maxDocuments}`,\n );\n }\n if (limits?.maxBytes !== undefined) {\n const totalBytes = docs.reduce(\n (sum, doc) => sum + Buffer.byteLength(doc.text ?? \"\"),\n 0,\n );\n if (totalBytes > limits.maxBytes) {\n throw new Error(\n `rag(\"${name}\"): index() received ${totalBytes} bytes of document text, exceeding the configured maxBytes of ${limits.maxBytes}`,\n );\n }\n }\n\n // Flatten every document into stored-chunk records + their texts,\n // preserving document order so a single batched embed maps back 1:1.\n const records: { key: string; value: StoredChunk; text: string; tags?: string[] }[] = [];\n\n for (const doc of docs) {\n const pieces = chunkText(doc.text, chunkOptions);\n\n for (const piece of pieces) {\n const value: StoredChunk = {\n sourceId: doc.id,\n chunkIndex: piece.index,\n span: piece.span,\n text: piece.text,\n metadata: doc.metadata,\n };\n\n records.push({\n key: keyFor(namespace, doc.id, piece.index),\n value,\n text: piece.text,\n tags: doc.tags,\n });\n }\n }\n\n // Empty / whitespace-only documents yield zero chunks — write\n // nothing and never embed an empty batch.\n if (records.length === 0) {\n return { chunks: 0 };\n }\n\n // Chunk cap (D5) — checked after chunking, still before embedding.\n if (limits?.maxChunks !== undefined && records.length > limits.maxChunks) {\n throw new Error(\n `rag(\"${name}\"): index() produced ${records.length} chunks, exceeding the configured maxChunks of ${limits.maxChunks}`,\n );\n }\n\n // Sub-batch the embed calls so one giant document does not blow the\n // provider's per-request token cap.\n for (let offset = 0; offset < records.length; offset += DEFAULT_MAX_BATCH) {\n const batch = records.slice(offset, offset + DEFAULT_MAX_BATCH);\n const { vectors, dimensions } = await embedder.embedMany(\n batch.map((record) => record.text),\n );\n\n if (indexedDimensions === undefined && dimensions !== 0) {\n indexedDimensions = dimensions;\n }\n\n await Promise.all(\n batch.map((record, position) =>\n store.upsert(record.key, record.value, vectors[position], record.tags),\n ),\n );\n }\n\n return { chunks: records.length };\n },\n\n async retrieve(query: string, options?: RetrieveOptions): Promise<RetrieveResult> {\n return runRetrieve(\n query,\n {\n embedder,\n store,\n namespace,\n reranker: config.reranker,\n defaults: config.retrieve,\n indexedDimensions,\n },\n options,\n );\n },\n\n async clear(): Promise<void> {\n await store.removeNamespace(namespace);\n },\n\n asTool(options?: RagAsToolOptions) {\n return ragAsTool(name, (query, retrieveOptions) => instance.retrieve(query, retrieveOptions), options);\n },\n };\n\n return instance;\n}\n\n/**\n * Namespaced key for a stored chunk. Uses the `.` separator (matching\n * `SemanticMemory.keyFor`) so namespace-prefix filtering on the returned\n * `hit.key` stays aligned with the cache's `parseKey` normalization.\n */\nfunction keyFor(namespace: string, sourceId: string, chunkIndex: number): string {\n return `${namespace}.${sourceId}.${chunkIndex}`;\n}\n"],"mappings":";;;;;;;AAeA,MAAM,eAAe;AACrB,MAAM,2BAA2B;;;;;;;AAQjC,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC1B,SAAgB,IAAI,QAAwB;CAC1C,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,CAAC,OAAO,UACV,MAAM,IAAI,MACR,QAAQ,KAAK,+IACf;CAGF,MAAM,SAAS,OAAO,SAAS,oBAAoB;CAEnD,IAAI,CAAC,QACH,MAAM,IAAI,MACR,QAAQ,KAAK,+JACf;CAGF,MAAM,QAAqB,iBAAiB,MAAM;CAClD,MAAM,YAAY,OAAO,aAAa,GAAG,yBAAyB,GAAG;CACrE,MAAM,WAAW,OAAO;CAGxB,IAAI;CAEJ,MAAM,WAAgB;EACpB;EAEA,MAAM,MACJ,MACA,eAC6B;GAC7B,MAAM,eAAe,iBAAiB,OAAO;GAG7C,MAAM,SAAS,OAAO;GACtB,IAAI,QAAQ,iBAAiB,UAAa,KAAK,SAAS,OAAO,cAC7D,MAAM,IAAI,MACR,QAAQ,KAAK,uBAAuB,KAAK,OAAO,uDAAuD,OAAO,cAChH;GAEF,IAAI,QAAQ,aAAa,QAAW;IAClC,MAAM,aAAa,KAAK,QACrB,KAAK,QAAQ,MAAM,OAAO,WAAW,IAAI,QAAQ,EAAE,GACpD,CACF;IACA,IAAI,aAAa,OAAO,UACtB,MAAM,IAAI,MACR,QAAQ,KA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AAO,SAA4B;GACjC,OAAO,UAAU,OAAO,OAAO,oBAAoB,SAAS,SAAS,OAAO,eAAe,GAAG,OAAO;EACvG;CACF;CAEA,OAAO;AACT;;;;;;AAOA,SAAS,OAAO,WAAmB,UAAkB,YAA4B;CAC/E,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG;AACrC"}
1
+ {"version":3,"file":"rag.mjs","names":["chunkText","runRetrieve"],"sources":["../../../../../../../ai/src/rag/rag.ts"],"sourcesContent":["import { resolveDefaultStore } from \"../config\";\nimport { chunk as chunkText } from \"./chunk/chunk\";\nimport type { ChunkOptions } from \"./contracts/chunk-options.type\";\nimport type { RetrieveOptions, RetrieveResult } from \"./contracts/citation.type\";\nimport type {\n Rag,\n RagAsToolOptions,\n RagConfig,\n} from \"./contracts/rag-config.type\";\nimport type { RagDocument } from \"./contracts/rag-document.type\";\nimport { ragAsTool } from \"./as-tool\";\nimport { retrieve as runRetrieve, type StoredChunk } from \"./retrieve\";\nimport { cacheVectorStore } from \"./store/cache-vector-store\";\nimport type { VectorStore } from \"./store/vector-store.contract\";\n\nconst DEFAULT_NAME = \"rag\";\nconst DEFAULT_NAMESPACE_PREFIX = \"ai.rag\";\n\n/**\n * Max chunk texts embedded per `embedder.embedMany()` call. One call is\n * one provider request, so a giant document is sub-batched to stay under\n * the provider's per-request token cap (the design's \"chunk larger than\n * provider per-request cap\" guard).\n */\nconst DEFAULT_MAX_BATCH = 96;\n\n/**\n * Create a RAG pipeline: **chunk → embed → vector store → retrieve →\n * rerank → cite**, reusing the app's `ai.embedder` for embedding, a\n * `@warlock.js/cache` `CacheDriver` as the vector store, and the\n * composite-as-tool engine to expose retrieval as a tool.\n *\n * Resolution is loud at construction (mirroring `memory()`):\n * - `embedder` is required — a provider with no embedder must be caught\n * here, not at first index.\n * - `store` falls back to `ai.config({ defaultStore })`; if neither\n * resolves, construction throws.\n *\n * `retrieve()` is return-only — it never auto-injects into a prompt; the\n * caller formats the cited chunks (or uses `asTool()` for the agent loop).\n * The reranker is OFF by default (cosine-only) unless `config.reranker`\n * is set.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n * import { MemoryCacheDriver } from \"@warlock.js/cache\";\n *\n * const kb = ai.rag({\n * name: \"docs\",\n * embedder: openai.embedder({ name: \"text-embedding-3-small\" }),\n * store: new MemoryCacheDriver(),\n * chunk: { type: \"markdown\", size: 800, overlap: 120 },\n * });\n *\n * await kb.index([{ id: \"guide\", text: longMarkdown, metadata: { url: \"/guide\" } }]);\n * const { chunks } = await kb.retrieve(\"how do I configure caching?\", { topK: 4 });\n */\nexport function rag(config: RagConfig): Rag {\n const name = config.name ?? DEFAULT_NAME;\n\n if (!config.embedder) {\n throw new Error(\n `rag(\"${name}\"): an \\`embedder\\` is required — pass one from a provider that supports embeddings (e.g. openai.embedder({ name: \"text-embedding-3-small\" }))`,\n );\n }\n\n const driver = config.store ?? resolveDefaultStore();\n\n if (!driver) {\n throw new Error(\n `rag(\"${name}\"): no store — pass \\`store\\` (a vector-capable @warlock.js/cache CacheDriver) or call \\`ai.config({ defaultStore })\\` at app boot before constructing the rag`,\n );\n }\n\n const store: VectorStore = cacheVectorStore(driver);\n const namespace = config.namespace ?? `${DEFAULT_NAMESPACE_PREFIX}.${name}`;\n const embedder = config.embedder;\n\n // Captured at first index for the dimension-mismatch guard in retrieve().\n let indexedDimensions: number | undefined;\n\n const instance: Rag = {\n name,\n\n async index(\n docs: RagDocument[],\n chunkOverride?: ChunkOptions,\n ): Promise<{ chunks: number }> {\n const chunkOptions = chunkOverride ?? config.chunk;\n\n // Ingestion guardrails (D5) — fail BEFORE any embedding spend.\n const limits = config.limits;\n if (limits?.maxDocuments !== undefined && docs.length > limits.maxDocuments) {\n throw new Error(\n `rag(\"${name}\"): index() received ${docs.length} documents, exceeding the configured maxDocuments of ${limits.maxDocuments}`,\n );\n }\n if (limits?.maxBytes !== undefined) {\n const totalBytes = docs.reduce(\n (sum, doc) => sum + Buffer.byteLength(doc.text ?? \"\"),\n 0,\n );\n if (totalBytes > limits.maxBytes) {\n throw new Error(\n `rag(\"${name}\"): index() received ${totalBytes} bytes of document text, exceeding the configured maxBytes of ${limits.maxBytes}`,\n );\n }\n }\n\n // Flatten every document into stored-chunk records + their texts,\n // preserving document order so a single batched embed maps back 1:1.\n const records: { key: string; value: StoredChunk; text: string; tags?: string[] }[] = [];\n\n for (const doc of docs) {\n const pieces = chunkText(doc.text, chunkOptions);\n\n for (const piece of pieces) {\n const value: StoredChunk = {\n sourceId: doc.id,\n chunkIndex: piece.index,\n span: piece.span,\n text: piece.text,\n metadata: doc.metadata,\n };\n\n records.push({\n key: keyFor(namespace, doc.id, piece.index),\n value,\n text: piece.text,\n tags: doc.tags,\n });\n }\n }\n\n // Empty / whitespace-only documents yield zero chunks — write\n // nothing and never embed an empty batch.\n if (records.length === 0) {\n return { chunks: 0 };\n }\n\n // Chunk cap (D5) — checked after chunking, still before embedding.\n if (limits?.maxChunks !== undefined && records.length > limits.maxChunks) {\n throw new Error(\n `rag(\"${name}\"): index() produced ${records.length} chunks, exceeding the configured maxChunks of ${limits.maxChunks}`,\n );\n }\n\n // Sub-batch the embed calls so one giant document does not blow the\n // provider's per-request token cap.\n for (let offset = 0; offset < records.length; offset += DEFAULT_MAX_BATCH) {\n const batch = records.slice(offset, offset + DEFAULT_MAX_BATCH);\n const { vectors, dimensions } = await embedder.embedMany(\n batch.map((record) => record.text),\n );\n\n if (indexedDimensions === undefined && dimensions !== 0) {\n indexedDimensions = dimensions;\n }\n\n await Promise.all(\n batch.map((record, position) =>\n store.upsert(record.key, record.value, vectors[position], record.tags),\n ),\n );\n }\n\n return { chunks: records.length };\n },\n\n async retrieve(query: string, options?: RetrieveOptions): Promise<RetrieveResult> {\n return runRetrieve(\n query,\n {\n embedder,\n store,\n namespace,\n reranker: config.reranker,\n defaults: config.retrieve,\n indexedDimensions,\n },\n options,\n );\n },\n\n async clear(): Promise<void> {\n await store.removeNamespace(namespace);\n },\n\n asTool(options?: RagAsToolOptions) {\n return ragAsTool(name, (query, retrieveOptions) => instance.retrieve(query, retrieveOptions), options);\n },\n };\n\n return instance;\n}\n\n/**\n * Namespaced key for a stored chunk. Uses the `.` separator (matching\n * `SemanticMemory.keyFor`) so namespace-prefix filtering on the returned\n * `hit.key` stays aligned with the cache's `parseKey` normalization.\n */\nfunction keyFor(namespace: string, sourceId: string, chunkIndex: number): string {\n return `${namespace}.${sourceId}.${chunkIndex}`;\n}\n"],"mappings":";;;;;;;AAeA,MAAM,eAAe;AACrB,MAAM,2BAA2B;;;;;;;AAQjC,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC1B,SAAgB,IAAI,QAAwB;CAC1C,MAAM,OAAO,OAAO,QAAQ;CAE5B,IAAI,CAAC,OAAO,UACV,MAAM,IAAI,MACR,QAAQ,KAAK,+IACf;CAGF,MAAM,SAAS,OAAO,SAAS,oBAAoB;CAEnD,IAAI,CAAC,QACH,MAAM,IAAI,MACR,QAAQ,KAAK,+JACf;CAGF,MAAM,QAAqB,iBAAiB,MAAM;CAClD,MAAM,YAAY,OAAO,aAAa,GAAG,yBAAyB,GAAG;CACrE,MAAM,WAAW,OAAO;CAGxB,IAAI;CAEJ,MAAM,WAAgB;EACpB;EAEA,MAAM,MACJ,MACA,eAC6B;GAC7B,MAAM,eAAe,iBAAiB,OAAO;GAG7C,MAAM,SAAS,OAAO;GACtB,IAAI,QAAQ,iBAAiB,UAAa,KAAK,SAAS,OAAO,cAC7D,MAAM,IAAI,MACR,QAAQ,KAAK,uBAAuB,KAAK,OAAO,uDAAuD,OAAO,cAChH;GAEF,IAAI,QAAQ,aAAa,QAAW;IAClC,MAAM,aAAa,KAAK,QACrB,KAAK,QAAQ,MAAM,OAAO,WAAW,IAAI,QAAQ,EAAE,GACpD,CACF;IACA,IAAI,aAAa,OAAO,UACtB,MAAM,IAAI,MACR,QAAQ,KAAK,uBAAuB,WAAW,gEAAgE,OAAO,UACxH;GAEJ;GAIA,MAAM,UAAgF,CAAC;GA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,GAAG,OAAO;EACvG;CACF;CAEA,OAAO;AACT;;;;;;AAOA,SAAS,OAAO,WAAmB,UAAkB,YAA4B;CAC/E,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG;AACrC"}
@@ -1,6 +1,6 @@
1
1
  import { RagReranker } from "./reranker.contract.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/rag/rerank/keyword-reranker.d.ts
3
+ //#region ../ai/src/rag/rerank/keyword-reranker.d.ts
4
4
  /** Options for the {@link keywordReranker}. */
5
5
  type KeywordRerankerOptions = {
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"keyword-reranker.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/rerank/keyword-reranker.ts"],"mappings":";;;;KAIY,sBAAA;EAAA;;;;AAMJ;EAAN,MAAM;AAAA;;;;;;;AA2B0E;;;;;;;;;;iBAAlE,eAAA,CAAgB,OAAA,GAAS,sBAAA,GAA8B,WAAW"}
1
+ {"version":3,"file":"keyword-reranker.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/rerank/keyword-reranker.ts"],"mappings":";;;;KAIY,sBAAA;EAAA;;;;AAMJ;EAAN,MAAM;AAAA;;;;;;;AA2B0E;;;;;;;;;;iBAAlE,eAAA,CAAgB,OAAA,GAAS,sBAAA,GAA8B,WAAW"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/rag/rerank/keyword-reranker.ts
1
+ //#region ../ai/src/rag/rerank/keyword-reranker.ts
2
2
  /** Splits text into lowercase alphanumeric terms. */
3
3
  function tokenize(text) {
4
4
  return text.toLowerCase().split(/[^a-z0-9]+/).filter((term) => term.length > 0);
@@ -1 +1 @@
1
- {"version":3,"file":"keyword-reranker.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/rerank/keyword-reranker.ts"],"sourcesContent":["import type { RetrievedChunk } from \"../contracts/citation.type\";\nimport type { RagReranker } from \"./reranker.contract\";\n\n/** Options for the {@link keywordReranker}. */\nexport type KeywordRerankerOptions = {\n /**\n * Weight of the lexical-overlap signal blended with the original cosine\n * score, in `[0, 1]`. `1` ranks purely by keyword overlap; `0` keeps the\n * cosine order. Default `0.5`.\n */\n weight?: number;\n};\n\n/** Splits text into lowercase alphanumeric terms. */\nfunction tokenize(text: string): string[] {\n return text\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((term) => term.length > 0);\n}\n\n/**\n * Zero-dependency lexical reranker (a BM25-lite, IDF-free keyword overlap).\n *\n * For each candidate it computes the fraction of distinct query terms that\n * appear in the chunk, blends that with the candidate's original cosine\n * score by `weight`, and sorts descending. A pure-lexical pass costs\n * nothing beyond string splits — no peer, no model — so it is the\n * recommended opt-in reranker when an embedding-only ranking surfaces a\n * keyword-rich chunk too low.\n *\n * Ties (equal blended score) preserve the incoming order, so the cosine\n * ranking breaks ties deterministically.\n *\n * @example\n * const kb = ai.rag({ embedder, store, reranker: ai.rag.keywordReranker() });\n */\nexport function keywordReranker(options: KeywordRerankerOptions = {}): RagReranker {\n const weight = options.weight ?? 0.5;\n\n return {\n name: \"keyword\",\n async rerank(query: string, candidates: RetrievedChunk[]): Promise<RetrievedChunk[]> {\n if (candidates.length === 0) {\n return [];\n }\n\n const queryTerms = new Set(tokenize(query));\n\n if (queryTerms.size === 0) {\n return [...candidates];\n }\n\n const scored = candidates.map((candidate, position) => {\n const chunkTerms = new Set(tokenize(candidate.text));\n\n let overlap = 0;\n for (const term of queryTerms) {\n if (chunkTerms.has(term)) {\n overlap += 1;\n }\n }\n\n const lexical = overlap / queryTerms.size;\n const blended = weight * lexical + (1 - weight) * candidate.score;\n\n return { candidate, blended, position };\n });\n\n scored.sort((first, second) => {\n if (second.blended !== first.blended) {\n return second.blended - first.blended;\n }\n\n // Stable on ties: keep the incoming (cosine) order.\n return first.position - second.position;\n });\n\n return scored.map((entry) => ({\n ...entry.candidate,\n score: entry.blended,\n citation: { ...entry.candidate.citation, score: entry.blended },\n }));\n },\n };\n}\n"],"mappings":";;AAcA,SAAS,SAAS,MAAwB;CACxC,OAAO,KACJ,YAAY,CAAC,CACb,MAAM,YAAY,CAAC,CACnB,QAAQ,SAAS,KAAK,SAAS,CAAC;AACrC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,gBAAgB,UAAkC,CAAC,GAAgB;CACjF,MAAM,SAAS,QAAQ,UAAU;CAEjC,OAAO;EACL,MAAM;EACN,MAAM,OAAO,OAAe,YAAyD;GACnF,IAAI,WAAW,WAAW,GACxB,OAAO,CAAC;GAGV,MAAM,aAAa,IAAI,IAAI,SAAS,KAAK,CAAC;GAE1C,IAAI,WAAW,SAAS,GACtB,OAAO,CAAC,GAAG,UAAU;GAGvB,MAAM,SAAS,WAAW,KAAK,WAAW,aAAa;IACrD,MAAM,aAAa,IAAI,IAAI,SAAS,UAAU,IAAI,CAAC;IAEnD,IAAI,UAAU;IACd,KAAK,MAAM,QAAQ,YACjB,IAAI,WAAW,IAAI,IAAI,GACrB,WAAW;IAOf,OAAO;KAAE;KAAW,SAFJ,UADA,UAAU,WAAW,SACD,IAAI,UAAU,UAAU;KAE/B;IAAS;GACxC,CAAC;GAED,OAAO,MAAM,OAAO,WAAW;IAC7B,IAAI,OAAO,YAAY,MAAM,SAC3B,OAAO,OAAO,UAAU,MAAM;IAIhC,OAAO,MAAM,WAAW,OAAO;GACjC,CAAC;GAED,OAAO,OAAO,KAAK,WAAW;IAC5B,GAAG,MAAM;IACT,OAAO,MAAM;IACb,UAAU;KAAE,GAAG,MAAM,UAAU;KAAU,OAAO,MAAM;IAAQ;GAChE,EAAE;EACJ;CACF;AACF"}
1
+ {"version":3,"file":"keyword-reranker.mjs","names":[],"sources":["../../../../../../../../ai/src/rag/rerank/keyword-reranker.ts"],"sourcesContent":["import type { RetrievedChunk } from \"../contracts/citation.type\";\nimport type { RagReranker } from \"./reranker.contract\";\n\n/** Options for the {@link keywordReranker}. */\nexport type KeywordRerankerOptions = {\n /**\n * Weight of the lexical-overlap signal blended with the original cosine\n * score, in `[0, 1]`. `1` ranks purely by keyword overlap; `0` keeps the\n * cosine order. Default `0.5`.\n */\n weight?: number;\n};\n\n/** Splits text into lowercase alphanumeric terms. */\nfunction tokenize(text: string): string[] {\n return text\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((term) => term.length > 0);\n}\n\n/**\n * Zero-dependency lexical reranker (a BM25-lite, IDF-free keyword overlap).\n *\n * For each candidate it computes the fraction of distinct query terms that\n * appear in the chunk, blends that with the candidate's original cosine\n * score by `weight`, and sorts descending. A pure-lexical pass costs\n * nothing beyond string splits — no peer, no model — so it is the\n * recommended opt-in reranker when an embedding-only ranking surfaces a\n * keyword-rich chunk too low.\n *\n * Ties (equal blended score) preserve the incoming order, so the cosine\n * ranking breaks ties deterministically.\n *\n * @example\n * const kb = ai.rag({ embedder, store, reranker: ai.rag.keywordReranker() });\n */\nexport function keywordReranker(options: KeywordRerankerOptions = {}): RagReranker {\n const weight = options.weight ?? 0.5;\n\n return {\n name: \"keyword\",\n async rerank(query: string, candidates: RetrievedChunk[]): Promise<RetrievedChunk[]> {\n if (candidates.length === 0) {\n return [];\n }\n\n const queryTerms = new Set(tokenize(query));\n\n if (queryTerms.size === 0) {\n return [...candidates];\n }\n\n const scored = candidates.map((candidate, position) => {\n const chunkTerms = new Set(tokenize(candidate.text));\n\n let overlap = 0;\n for (const term of queryTerms) {\n if (chunkTerms.has(term)) {\n overlap += 1;\n }\n }\n\n const lexical = overlap / queryTerms.size;\n const blended = weight * lexical + (1 - weight) * candidate.score;\n\n return { candidate, blended, position };\n });\n\n scored.sort((first, second) => {\n if (second.blended !== first.blended) {\n return second.blended - first.blended;\n }\n\n // Stable on ties: keep the incoming (cosine) order.\n return first.position - second.position;\n });\n\n return scored.map((entry) => ({\n ...entry.candidate,\n score: entry.blended,\n citation: { ...entry.candidate.citation, score: entry.blended },\n }));\n },\n };\n}\n"],"mappings":";;AAcA,SAAS,SAAS,MAAwB;CACxC,OAAO,KACJ,YAAY,CAAC,CACb,MAAM,YAAY,CAAC,CACnB,QAAQ,SAAS,KAAK,SAAS,CAAC;AACrC;;;;;;;;;;;;;;;;;AAkBA,SAAgB,gBAAgB,UAAkC,CAAC,GAAgB;CACjF,MAAM,SAAS,QAAQ,UAAU;CAEjC,OAAO;EACL,MAAM;EACN,MAAM,OAAO,OAAe,YAAyD;GACnF,IAAI,WAAW,WAAW,GACxB,OAAO,CAAC;GAGV,MAAM,aAAa,IAAI,IAAI,SAAS,KAAK,CAAC;GAE1C,IAAI,WAAW,SAAS,GACtB,OAAO,CAAC,GAAG,UAAU;GAGvB,MAAM,SAAS,WAAW,KAAK,WAAW,aAAa;IACrD,MAAM,aAAa,IAAI,IAAI,SAAS,UAAU,IAAI,CAAC;IAEnD,IAAI,UAAU;IACd,KAAK,MAAM,QAAQ,YACjB,IAAI,WAAW,IAAI,IAAI,GACrB,WAAW;IAOf,OAAO;KAAE;KAAW,SAFJ,UADA,UAAU,WAAW,SACD,IAAI,UAAU,UAAU;KAE/B;IAAS;GACxC,CAAC;GAED,OAAO,MAAM,OAAO,WAAW;IAC7B,IAAI,OAAO,YAAY,MAAM,SAC3B,OAAO,OAAO,UAAU,MAAM;IAIhC,OAAO,MAAM,WAAW,OAAO;GACjC,CAAC;GAED,OAAO,OAAO,KAAK,WAAW;IAC5B,GAAG,MAAM;IACT,OAAO,MAAM;IACb,UAAU;KAAE,GAAG,MAAM,UAAU;KAAU,OAAO,MAAM;IAAQ;GAChE,EAAE;EACJ;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { ModelContract } from "../../contracts/model.contract.mjs";
2
2
  import { RagReranker } from "./reranker.contract.mjs";
3
3
 
4
- //#region ../@warlock.js/ai/src/rag/rerank/llm-reranker.d.ts
4
+ //#region ../ai/src/rag/rerank/llm-reranker.d.ts
5
5
  /** Options for the {@link llmReranker}. */
6
6
  type LlmRerankerOptions = {
7
7
  /** The model used to score candidate relevance. Required. */model: ModelContract;
@@ -1 +1 @@
1
- {"version":3,"file":"llm-reranker.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/rerank/llm-reranker.ts"],"mappings":";;;;;KAMY,kBAAA;EAAA,6DAEV,KAAA,EAAO,aAAa;;;;;EAKpB,SAAA;AAAA;AAAS;AA8FX;;;;;;;;AAAqE;;;;;;;;;;AA9F1D,iBA8FK,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,WAAW"}
1
+ {"version":3,"file":"llm-reranker.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/rerank/llm-reranker.ts"],"mappings":";;;;;KAMY,kBAAA;EAAA,6DAEV,KAAA,EAAO,aAAa;;;;;EAKpB,SAAA;AAAA;AAAS;AA8FX;;;;;;;;AAAqE;;;;;;;;;;AA9F1D,iBA8FK,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,WAAW"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/rag/rerank/llm-reranker.ts
1
+ //#region ../ai/src/rag/rerank/llm-reranker.ts
2
2
  /**
3
3
  * Build the scoring prompt — the model rates each candidate's relevance to
4
4
  * the query on a `0..1` scale and replies with one `index: score` line per
@@ -1 +1 @@
1
- {"version":3,"file":"llm-reranker.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/rerank/llm-reranker.ts"],"sourcesContent":["import type { Message } from \"../../contracts/conversation-message.type\";\nimport type { ModelContract } from \"../../contracts/model.contract\";\nimport type { RetrievedChunk } from \"../contracts/citation.type\";\nimport type { RagReranker } from \"./reranker.contract\";\n\n/** Options for the {@link llmReranker}. */\nexport type LlmRerankerOptions = {\n /** The model used to score candidate relevance. Required. */\n model: ModelContract;\n /**\n * How many candidates to score per model call. Larger batches mean\n * fewer round-trips but a longer prompt. Default `10`.\n */\n batchSize?: number;\n};\n\n/**\n * A single relevance score the model returns for a candidate, in `[0, 1]`,\n * keyed by the candidate's position in the batch.\n */\ntype ScoreLine = {\n index: number;\n score: number;\n};\n\n/**\n * Build the scoring prompt — the model rates each candidate's relevance to\n * the query on a `0..1` scale and replies with one `index: score` line per\n * candidate. Kept terse and JSON-light so any chat model can answer.\n */\nfunction buildPrompt(query: string, candidates: RetrievedChunk[]): Message[] {\n const lines = candidates\n .map((candidate, index) => `[${index}] ${candidate.text}`)\n .join(\"\\n\\n\");\n\n return [\n {\n role: \"system\",\n content:\n \"You are a relevance grader. For each numbered passage, rate how well it answers the query on a scale from 0 (irrelevant) to 1 (fully relevant). Reply with ONLY a JSON array of objects like [{\\\"index\\\":0,\\\"score\\\":0.9}], one entry per passage, no prose.\",\n },\n {\n role: \"user\",\n content: `Query: ${query}\\n\\nPassages:\\n${lines}`,\n },\n ];\n}\n\n/**\n * Parse the model's reply into a score map. Tolerant of surrounding prose:\n * extracts the first JSON array and reads `{ index, score }` entries.\n * Returns an empty map when nothing parseable is found, so the caller can\n * fall back to the original order.\n */\nfunction parseScores(reply: string): Map<number, number> {\n const scores = new Map<number, number>();\n const start = reply.indexOf(\"[\");\n const end = reply.lastIndexOf(\"]\");\n\n if (start === -1 || end === -1 || end <= start) {\n return scores;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(reply.slice(start, end + 1));\n } catch {\n return scores;\n }\n\n if (!Array.isArray(parsed)) {\n return scores;\n }\n\n for (const entry of parsed as ScoreLine[]) {\n if (\n entry &&\n typeof entry.index === \"number\" &&\n typeof entry.score === \"number\" &&\n Number.isFinite(entry.score)\n ) {\n scores.set(entry.index, Math.max(0, Math.min(1, entry.score)));\n }\n }\n\n return scores;\n}\n\n/**\n * Optional model-backed reranker.\n *\n * Asks an LLM to grade each over-fetched candidate's relevance to the\n * query on a `0..1` scale, then sorts descending by the model's score.\n * Candidates the model does not score keep their original cosine score, so\n * a partial/garbled reply degrades gracefully rather than dropping hits.\n * Scoring is batched (`batchSize`) to bound prompt length.\n *\n * Unlike {@link keywordReranker}, this costs one or more model calls per\n * retrieval — opt in only when precision matters more than latency/cost.\n *\n * @example\n * const kb = ai.rag({\n * embedder,\n * store,\n * reranker: ai.rag.llmReranker({ model: openai.model({ name: \"gpt-4o-mini\" }) }),\n * });\n */\nexport function llmReranker(options: LlmRerankerOptions): RagReranker {\n const batchSize = options.batchSize ?? 10;\n\n return {\n name: \"llm\",\n async rerank(query: string, candidates: RetrievedChunk[]): Promise<RetrievedChunk[]> {\n if (candidates.length === 0) {\n return [];\n }\n\n const rescored: RetrievedChunk[] = [];\n\n for (let offset = 0; offset < candidates.length; offset += batchSize) {\n const batch = candidates.slice(offset, offset + batchSize);\n const response = await options.model.complete(buildPrompt(query, batch));\n const scores = parseScores(response.content);\n\n batch.forEach((candidate, index) => {\n const score = scores.has(index) ? (scores.get(index) as number) : candidate.score;\n\n rescored.push({\n ...candidate,\n score,\n citation: { ...candidate.citation, score },\n });\n });\n }\n\n return rescored.sort((first, second) => second.score - first.score);\n },\n };\n}\n"],"mappings":";;;;;;AA8BA,SAAS,YAAY,OAAe,YAAyC;CAK3E,OAAO,CACL;EACE,MAAM;EACN,SACE;CACJ,GACA;EACE,MAAM;EACN,SAAS,UAAU,MAAM,iBAZf,WACX,KAAK,WAAW,UAAU,IAAI,MAAM,IAAI,UAAU,MAAM,CAAC,CACzD,KAAK,MAU0C;CAChD,CACF;AACF;;;;;;;AAQA,SAAS,YAAY,OAAoC;CACvD,MAAM,yBAAS,IAAI,IAAoB;CACvC,MAAM,QAAQ,MAAM,QAAQ,GAAG;CAC/B,MAAM,MAAM,MAAM,YAAY,GAAG;CAEjC,IAAI,UAAU,MAAM,QAAQ,MAAM,OAAO,OACvC,OAAO;CAGT,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,MAAM,MAAM,OAAO,MAAM,CAAC,CAAC;CACjD,QAAQ;EACN,OAAO;CACT;CAEA,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,OAAO;CAGT,KAAK,MAAM,SAAS,QAClB,IACE,SACA,OAAO,MAAM,UAAU,YACvB,OAAO,MAAM,UAAU,YACvB,OAAO,SAAS,MAAM,KAAK,GAE3B,OAAO,IAAI,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,MAAM,KAAK,CAAC,CAAC;CAIjE,OAAO;AACT;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,YAAY,SAA0C;CACpE,MAAM,YAAY,QAAQ,aAAa;CAEvC,OAAO;EACL,MAAM;EACN,MAAM,OAAO,OAAe,YAAyD;GACnF,IAAI,WAAW,WAAW,GACxB,OAAO,CAAC;GAGV,MAAM,WAA6B,CAAC;GAEpC,KAAK,IAAI,SAAS,GAAG,SAAS,WAAW,QAAQ,UAAU,WAAW;IACpE,MAAM,QAAQ,WAAW,MAAM,QAAQ,SAAS,SAAS;IAEzD,MAAM,SAAS,aAAY,MADJ,QAAQ,MAAM,SAAS,YAAY,OAAO,KAAK,CAAC,EACpC,CAAC,OAAO;IAE3C,MAAM,SAAS,WAAW,UAAU;KAClC,MAAM,QAAQ,OAAO,IAAI,KAAK,IAAK,OAAO,IAAI,KAAK,IAAe,UAAU;KAE5E,SAAS,KAAK;MACZ,GAAG;MACH;MACA,UAAU;OAAE,GAAG,UAAU;OAAU;MAAM;KAC3C,CAAC;IACH,CAAC;GACH;GAEA,OAAO,SAAS,MAAM,OAAO,WAAW,OAAO,QAAQ,MAAM,KAAK;EACpE;CACF;AACF"}
1
+ {"version":3,"file":"llm-reranker.mjs","names":[],"sources":["../../../../../../../../ai/src/rag/rerank/llm-reranker.ts"],"sourcesContent":["import type { Message } from \"../../contracts/conversation-message.type\";\nimport type { ModelContract } from \"../../contracts/model.contract\";\nimport type { RetrievedChunk } from \"../contracts/citation.type\";\nimport type { RagReranker } from \"./reranker.contract\";\n\n/** Options for the {@link llmReranker}. */\nexport type LlmRerankerOptions = {\n /** The model used to score candidate relevance. Required. */\n model: ModelContract;\n /**\n * How many candidates to score per model call. Larger batches mean\n * fewer round-trips but a longer prompt. Default `10`.\n */\n batchSize?: number;\n};\n\n/**\n * A single relevance score the model returns for a candidate, in `[0, 1]`,\n * keyed by the candidate's position in the batch.\n */\ntype ScoreLine = {\n index: number;\n score: number;\n};\n\n/**\n * Build the scoring prompt — the model rates each candidate's relevance to\n * the query on a `0..1` scale and replies with one `index: score` line per\n * candidate. Kept terse and JSON-light so any chat model can answer.\n */\nfunction buildPrompt(query: string, candidates: RetrievedChunk[]): Message[] {\n const lines = candidates\n .map((candidate, index) => `[${index}] ${candidate.text}`)\n .join(\"\\n\\n\");\n\n return [\n {\n role: \"system\",\n content:\n \"You are a relevance grader. For each numbered passage, rate how well it answers the query on a scale from 0 (irrelevant) to 1 (fully relevant). Reply with ONLY a JSON array of objects like [{\\\"index\\\":0,\\\"score\\\":0.9}], one entry per passage, no prose.\",\n },\n {\n role: \"user\",\n content: `Query: ${query}\\n\\nPassages:\\n${lines}`,\n },\n ];\n}\n\n/**\n * Parse the model's reply into a score map. Tolerant of surrounding prose:\n * extracts the first JSON array and reads `{ index, score }` entries.\n * Returns an empty map when nothing parseable is found, so the caller can\n * fall back to the original order.\n */\nfunction parseScores(reply: string): Map<number, number> {\n const scores = new Map<number, number>();\n const start = reply.indexOf(\"[\");\n const end = reply.lastIndexOf(\"]\");\n\n if (start === -1 || end === -1 || end <= start) {\n return scores;\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(reply.slice(start, end + 1));\n } catch {\n return scores;\n }\n\n if (!Array.isArray(parsed)) {\n return scores;\n }\n\n for (const entry of parsed as ScoreLine[]) {\n if (\n entry &&\n typeof entry.index === \"number\" &&\n typeof entry.score === \"number\" &&\n Number.isFinite(entry.score)\n ) {\n scores.set(entry.index, Math.max(0, Math.min(1, entry.score)));\n }\n }\n\n return scores;\n}\n\n/**\n * Optional model-backed reranker.\n *\n * Asks an LLM to grade each over-fetched candidate's relevance to the\n * query on a `0..1` scale, then sorts descending by the model's score.\n * Candidates the model does not score keep their original cosine score, so\n * a partial/garbled reply degrades gracefully rather than dropping hits.\n * Scoring is batched (`batchSize`) to bound prompt length.\n *\n * Unlike {@link keywordReranker}, this costs one or more model calls per\n * retrieval — opt in only when precision matters more than latency/cost.\n *\n * @example\n * const kb = ai.rag({\n * embedder,\n * store,\n * reranker: ai.rag.llmReranker({ model: openai.model({ name: \"gpt-4o-mini\" }) }),\n * });\n */\nexport function llmReranker(options: LlmRerankerOptions): RagReranker {\n const batchSize = options.batchSize ?? 10;\n\n return {\n name: \"llm\",\n async rerank(query: string, candidates: RetrievedChunk[]): Promise<RetrievedChunk[]> {\n if (candidates.length === 0) {\n return [];\n }\n\n const rescored: RetrievedChunk[] = [];\n\n for (let offset = 0; offset < candidates.length; offset += batchSize) {\n const batch = candidates.slice(offset, offset + batchSize);\n const response = await options.model.complete(buildPrompt(query, batch));\n const scores = parseScores(response.content);\n\n batch.forEach((candidate, index) => {\n const score = scores.has(index) ? (scores.get(index) as number) : candidate.score;\n\n rescored.push({\n ...candidate,\n score,\n citation: { ...candidate.citation, score },\n });\n });\n }\n\n return rescored.sort((first, second) => second.score - first.score);\n },\n };\n}\n"],"mappings":";;;;;;AA8BA,SAAS,YAAY,OAAe,YAAyC;CAK3E,OAAO,CACL;EACE,MAAM;EACN,SACE;CACJ,GACA;EACE,MAAM;EACN,SAAS,UAAU,MAAM,iBAZf,WACX,KAAK,WAAW,UAAU,IAAI,MAAM,IAAI,UAAU,MAAM,CAAC,CACzD,KAAK,MAU0C;CAChD,CACF;AACF;;;;;;;AAQA,SAAS,YAAY,OAAoC;CACvD,MAAM,yBAAS,IAAI,IAAoB;CACvC,MAAM,QAAQ,MAAM,QAAQ,GAAG;CAC/B,MAAM,MAAM,MAAM,YAAY,GAAG;CAEjC,IAAI,UAAU,MAAM,QAAQ,MAAM,OAAO,OACvC,OAAO;CAGT,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,MAAM,MAAM,OAAO,MAAM,CAAC,CAAC;CACjD,QAAQ;EACN,OAAO;CACT;CAEA,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,OAAO;CAGT,KAAK,MAAM,SAAS,QAClB,IACE,SACA,OAAO,MAAM,UAAU,YACvB,OAAO,MAAM,UAAU,YACvB,OAAO,SAAS,MAAM,KAAK,GAE3B,OAAO,IAAI,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,MAAM,KAAK,CAAC,CAAC;CAIjE,OAAO;AACT;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,YAAY,SAA0C;CACpE,MAAM,YAAY,QAAQ,aAAa;CAEvC,OAAO;EACL,MAAM;EACN,MAAM,OAAO,OAAe,YAAyD;GACnF,IAAI,WAAW,WAAW,GACxB,OAAO,CAAC;GAGV,MAAM,WAA6B,CAAC;GAEpC,KAAK,IAAI,SAAS,GAAG,SAAS,WAAW,QAAQ,UAAU,WAAW;IACpE,MAAM,QAAQ,WAAW,MAAM,QAAQ,SAAS,SAAS;IAEzD,MAAM,SAAS,aAAY,MADJ,QAAQ,MAAM,SAAS,YAAY,OAAO,KAAK,CAAC,EACpC,CAAC,OAAO;IAE3C,MAAM,SAAS,WAAW,UAAU;KAClC,MAAM,QAAQ,OAAO,IAAI,KAAK,IAAK,OAAO,IAAI,KAAK,IAAe,UAAU;KAE5E,SAAS,KAAK;MACZ,GAAG;MACH;MACA,UAAU;OAAE,GAAG,UAAU;OAAU;MAAM;KAC3C,CAAC;IACH,CAAC;GACH;GAEA,OAAO,SAAS,MAAM,OAAO,WAAW,OAAO,QAAQ,MAAM,KAAK;EACpE;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { RetrievedChunk } from "../contracts/citation.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/rag/rerank/reranker.contract.d.ts
3
+ //#region ../ai/src/rag/rerank/reranker.contract.d.ts
4
4
  /**
5
5
  * Reranks an over-fetched candidate set against the query before the
6
6
  * pipeline slices to `topK`. Optional — when no reranker is configured the
@@ -1 +1 @@
1
- {"version":3,"file":"reranker.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/rerank/reranker.contract.ts"],"mappings":";;;;;AAcA;;;;;;;;;;UAAiB,WAAA;EAQmB;EAAA,SANzB,IAAA;EAM4C;;;AAAsB;;EAA3E,MAAA,CAAO,KAAA,UAAe,UAAA,EAAY,cAAA,KAAmB,OAAA,CAAQ,cAAA;AAAA"}
1
+ {"version":3,"file":"reranker.contract.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/rerank/reranker.contract.ts"],"mappings":";;;;;AAcA;;;;;;;;;;UAAiB,WAAA;EAQmB;EAAA,SANzB,IAAA;EAM4C;;;AAAsB;;EAA3E,MAAA,CAAO,KAAA,UAAe,UAAA,EAAY,cAAA,KAAmB,OAAA,CAAQ,cAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/rag/retrieve.ts
1
+ //#region ../ai/src/rag/retrieve.ts
2
2
  /** Default number of chunks returned after reranking. */
3
3
  const DEFAULT_TOP_K = 5;
4
4
  /** Default cosine floor applied at the vector-store stage. */
@@ -1 +1 @@
1
- {"version":3,"file":"retrieve.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/rag/retrieve.ts"],"sourcesContent":["import type { EmbedderContract } from \"../contracts/embedder.contract\";\nimport type {\n Citation,\n RetrievedChunk,\n RetrieveOptions,\n RetrieveResult,\n} from \"./contracts/citation.type\";\nimport type { RagReranker } from \"./rerank/reranker.contract\";\nimport type { VectorStore } from \"./store/vector-store.contract\";\n\n/** Default number of chunks returned after reranking. */\nexport const DEFAULT_TOP_K = 5;\n\n/** Default cosine floor applied at the vector-store stage. */\nexport const DEFAULT_THRESHOLD = 0.5;\n\n/**\n * Shape persisted per chunk in the vector store. The vector itself is held\n * by the driver's own index (passed via `set({ vector })`), so it is not\n * duplicated here.\n */\nexport type StoredChunk = {\n sourceId: string;\n chunkIndex: number;\n span: [start: number, end: number];\n text: string;\n metadata?: Record<string, unknown>;\n};\n\n/** Dependencies the retrieve pipeline needs, resolved once by `rag()`. */\nexport type RetrieveDeps = {\n embedder: EmbedderContract;\n store: VectorStore;\n /** Namespace prefix every stored key carries (e.g. `\"ai.rag.docs\"`). */\n namespace: string;\n /** Optional reranker; when absent the cosine order is kept. */\n reranker?: RagReranker;\n /** Pipeline-level retrieval defaults. */\n defaults?: RetrieveOptions;\n /**\n * Dimension count captured at first index for the mismatch guard. When\n * set, the query embedder's `dimensions` must equal it.\n */\n indexedDimensions?: number;\n};\n\n/**\n * The cite pipeline: embed the query → over-fetch candidates from the\n * store → filter to this rag's namespace → map to {@link RetrievedChunk}s\n * with a {@link Citation} → optionally rerank → slice `topK`.\n *\n * Behavior matches the design's failure modes:\n * - No hits clearing the threshold → `{ query, chunks: [] }`, never throws.\n * - Namespace-prefix filtering keeps two rags sharing one driver isolated.\n * - A reranker that throws is caught; the raw cosine order is used instead.\n * - A dimension mismatch (indexed with model A, queried with model B)\n * throws a clear error rather than returning garbage hits.\n */\nexport async function retrieve(\n query: string,\n deps: RetrieveDeps,\n options: RetrieveOptions = {},\n): Promise<RetrieveResult> {\n const topK = options.topK ?? deps.defaults?.topK ?? DEFAULT_TOP_K;\n const threshold = options.threshold ?? deps.defaults?.threshold ?? DEFAULT_THRESHOLD;\n const tags = options.tags ?? deps.defaults?.tags;\n const candidates = options.candidates ?? deps.defaults?.candidates ?? Math.max(topK * 4, topK);\n\n const { vector, dimensions } = await deps.embedder.embed(query);\n\n if (\n deps.indexedDimensions !== undefined &&\n dimensions !== 0 &&\n deps.indexedDimensions !== 0 &&\n dimensions !== deps.indexedDimensions\n ) {\n throw new Error(\n `rag.retrieve(): query embedder dimensions (${dimensions}) do not match the dimensions captured at index time (${deps.indexedDimensions}); index and query must use the same embedding model`,\n );\n }\n\n const hits = await deps.store.query<StoredChunk>(vector, {\n topK: candidates,\n threshold,\n tags,\n });\n\n const prefix = `${deps.namespace}.`;\n\n let retrieved: RetrievedChunk[] = hits\n .filter((hit) => hit.key.startsWith(prefix))\n .map((hit) => toRetrievedChunk(hit.value, hit.score));\n\n retrieved = await applyReranker(query, retrieved, deps.reranker);\n\n return { query, chunks: retrieved.slice(0, topK) };\n}\n\n/** Build a cited {@link RetrievedChunk} from a stored chunk + its cosine score. */\nfunction toRetrievedChunk(stored: StoredChunk, score: number): RetrievedChunk {\n const citation: Citation = {\n sourceId: stored.sourceId,\n chunkIndex: stored.chunkIndex,\n span: stored.span,\n score,\n metadata: stored.metadata,\n };\n\n return { text: stored.text, score, citation };\n}\n\n/**\n * Run the optional reranker, degrading to the raw cosine order if it\n * throws — a flaky optional reranker must never fail the whole retrieval.\n */\nasync function applyReranker(\n query: string,\n candidates: RetrievedChunk[],\n reranker: RagReranker | undefined,\n): Promise<RetrievedChunk[]> {\n if (!reranker) {\n return candidates;\n }\n\n try {\n return await reranker.rerank(query, candidates);\n } catch {\n // Logged at the call site in a richer build; here we degrade silently\n // to vector-only ranking rather than aborting the retrieval.\n return candidates;\n }\n}\n"],"mappings":";;AAWA,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB;;;;;;;;;;;;;AA4CjC,eAAsB,SACpB,OACA,MACA,UAA2B,CAAC,GACH;CACzB,MAAM,OAAO,QAAQ,QAAQ,KAAK,UAAU;CAC5C,MAAM,YAAY,QAAQ,aAAa,KAAK,UAAU;CACtD,MAAM,OAAO,QAAQ,QAAQ,KAAK,UAAU;CAC5C,MAAM,aAAa,QAAQ,cAAc,KAAK,UAAU,cAAc,KAAK,IAAI,OAAO,GAAG,IAAI;CAE7F,MAAM,EAAE,QAAQ,eAAe,MAAM,KAAK,SAAS,MAAM,KAAK;CAE9D,IACE,KAAK,sBAAsB,UAC3B,eAAe,KACf,KAAK,sBAAsB,KAC3B,eAAe,KAAK,mBAEpB,MAAM,IAAI,MACR,8CAA8C,WAAW,wDAAwD,KAAK,kBAAkB,qDAC1I;CAGF,MAAM,OAAO,MAAM,KAAK,MAAM,MAAmB,QAAQ;EACvD,MAAM;EACN;EACA;CACF,CAAC;CAED,MAAM,SAAS,GAAG,KAAK,UAAU;CAEjC,IAAI,YAA8B,KAC/B,QAAQ,QAAQ,IAAI,IAAI,WAAW,MAAM,CAAC,CAAC,CAC3C,KAAK,QAAQ,iBAAiB,IAAI,OAAO,IAAI,KAAK,CAAC;CAEtD,YAAY,MAAM,cAAc,OAAO,WAAW,KAAK,QAAQ;CAE/D,OAAO;EAAE;EAAO,QAAQ,UAAU,MAAM,GAAG,IAAI;CAAE;AACnD;;AAGA,SAAS,iBAAiB,QAAqB,OAA+B;CAC5E,MAAM,WAAqB;EACzB,UAAU,OAAO;EACjB,YAAY,OAAO;EACnB,MAAM,OAAO;EACb;EACA,UAAU,OAAO;CACnB;CAEA,OAAO;EAAE,MAAM,OAAO;EAAM;EAAO;CAAS;AAC9C;;;;;AAMA,eAAe,cACb,OACA,YACA,UAC2B;CAC3B,IAAI,CAAC,UACH,OAAO;CAGT,IAAI;EACF,OAAO,MAAM,SAAS,OAAO,OAAO,UAAU;CAChD,QAAQ;EAGN,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"retrieve.mjs","names":[],"sources":["../../../../../../../ai/src/rag/retrieve.ts"],"sourcesContent":["import type { EmbedderContract } from \"../contracts/embedder.contract\";\nimport type {\n Citation,\n RetrievedChunk,\n RetrieveOptions,\n RetrieveResult,\n} from \"./contracts/citation.type\";\nimport type { RagReranker } from \"./rerank/reranker.contract\";\nimport type { VectorStore } from \"./store/vector-store.contract\";\n\n/** Default number of chunks returned after reranking. */\nexport const DEFAULT_TOP_K = 5;\n\n/** Default cosine floor applied at the vector-store stage. */\nexport const DEFAULT_THRESHOLD = 0.5;\n\n/**\n * Shape persisted per chunk in the vector store. The vector itself is held\n * by the driver's own index (passed via `set({ vector })`), so it is not\n * duplicated here.\n */\nexport type StoredChunk = {\n sourceId: string;\n chunkIndex: number;\n span: [start: number, end: number];\n text: string;\n metadata?: Record<string, unknown>;\n};\n\n/** Dependencies the retrieve pipeline needs, resolved once by `rag()`. */\nexport type RetrieveDeps = {\n embedder: EmbedderContract;\n store: VectorStore;\n /** Namespace prefix every stored key carries (e.g. `\"ai.rag.docs\"`). */\n namespace: string;\n /** Optional reranker; when absent the cosine order is kept. */\n reranker?: RagReranker;\n /** Pipeline-level retrieval defaults. */\n defaults?: RetrieveOptions;\n /**\n * Dimension count captured at first index for the mismatch guard. When\n * set, the query embedder's `dimensions` must equal it.\n */\n indexedDimensions?: number;\n};\n\n/**\n * The cite pipeline: embed the query → over-fetch candidates from the\n * store → filter to this rag's namespace → map to {@link RetrievedChunk}s\n * with a {@link Citation} → optionally rerank → slice `topK`.\n *\n * Behavior matches the design's failure modes:\n * - No hits clearing the threshold → `{ query, chunks: [] }`, never throws.\n * - Namespace-prefix filtering keeps two rags sharing one driver isolated.\n * - A reranker that throws is caught; the raw cosine order is used instead.\n * - A dimension mismatch (indexed with model A, queried with model B)\n * throws a clear error rather than returning garbage hits.\n */\nexport async function retrieve(\n query: string,\n deps: RetrieveDeps,\n options: RetrieveOptions = {},\n): Promise<RetrieveResult> {\n const topK = options.topK ?? deps.defaults?.topK ?? DEFAULT_TOP_K;\n const threshold = options.threshold ?? deps.defaults?.threshold ?? DEFAULT_THRESHOLD;\n const tags = options.tags ?? deps.defaults?.tags;\n const candidates = options.candidates ?? deps.defaults?.candidates ?? Math.max(topK * 4, topK);\n\n const { vector, dimensions } = await deps.embedder.embed(query);\n\n if (\n deps.indexedDimensions !== undefined &&\n dimensions !== 0 &&\n deps.indexedDimensions !== 0 &&\n dimensions !== deps.indexedDimensions\n ) {\n throw new Error(\n `rag.retrieve(): query embedder dimensions (${dimensions}) do not match the dimensions captured at index time (${deps.indexedDimensions}); index and query must use the same embedding model`,\n );\n }\n\n const hits = await deps.store.query<StoredChunk>(vector, {\n topK: candidates,\n threshold,\n tags,\n });\n\n const prefix = `${deps.namespace}.`;\n\n let retrieved: RetrievedChunk[] = hits\n .filter((hit) => hit.key.startsWith(prefix))\n .map((hit) => toRetrievedChunk(hit.value, hit.score));\n\n retrieved = await applyReranker(query, retrieved, deps.reranker);\n\n return { query, chunks: retrieved.slice(0, topK) };\n}\n\n/** Build a cited {@link RetrievedChunk} from a stored chunk + its cosine score. */\nfunction toRetrievedChunk(stored: StoredChunk, score: number): RetrievedChunk {\n const citation: Citation = {\n sourceId: stored.sourceId,\n chunkIndex: stored.chunkIndex,\n span: stored.span,\n score,\n metadata: stored.metadata,\n };\n\n return { text: stored.text, score, citation };\n}\n\n/**\n * Run the optional reranker, degrading to the raw cosine order if it\n * throws — a flaky optional reranker must never fail the whole retrieval.\n */\nasync function applyReranker(\n query: string,\n candidates: RetrievedChunk[],\n reranker: RagReranker | undefined,\n): Promise<RetrievedChunk[]> {\n if (!reranker) {\n return candidates;\n }\n\n try {\n return await reranker.rerank(query, candidates);\n } catch {\n // Logged at the call site in a richer build; here we degrade silently\n // to vector-only ranking rather than aborting the retrieval.\n return candidates;\n }\n}\n"],"mappings":";;AAWA,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB;;;;;;;;;;;;;AA4CjC,eAAsB,SACpB,OACA,MACA,UAA2B,CAAC,GACH;CACzB,MAAM,OAAO,QAAQ,QAAQ,KAAK,UAAU;CAC5C,MAAM,YAAY,QAAQ,aAAa,KAAK,UAAU;CACtD,MAAM,OAAO,QAAQ,QAAQ,KAAK,UAAU;CAC5C,MAAM,aAAa,QAAQ,cAAc,KAAK,UAAU,cAAc,KAAK,IAAI,OAAO,GAAG,IAAI;CAE7F,MAAM,EAAE,QAAQ,eAAe,MAAM,KAAK,SAAS,MAAM,KAAK;CAE9D,IACE,KAAK,sBAAsB,UAC3B,eAAe,KACf,KAAK,sBAAsB,KAC3B,eAAe,KAAK,mBAEpB,MAAM,IAAI,MACR,8CAA8C,WAAW,wDAAwD,KAAK,kBAAkB,qDAC1I;CAGF,MAAM,OAAO,MAAM,KAAK,MAAM,MAAmB,QAAQ;EACvD,MAAM;EACN;EACA;CACF,CAAC;CAED,MAAM,SAAS,GAAG,KAAK,UAAU;CAEjC,IAAI,YAA8B,KAC/B,QAAQ,QAAQ,IAAI,IAAI,WAAW,MAAM,CAAC,CAAC,CAC3C,KAAK,QAAQ,iBAAiB,IAAI,OAAO,IAAI,KAAK,CAAC;CAEtD,YAAY,MAAM,cAAc,OAAO,WAAW,KAAK,QAAQ;CAE/D,OAAO;EAAE;EAAO,QAAQ,UAAU,MAAM,GAAG,IAAI;CAAE;AACnD;;AAGA,SAAS,iBAAiB,QAAqB,OAA+B;CAC5E,MAAM,WAAqB;EACzB,UAAU,OAAO;EACjB,YAAY,OAAO;EACnB,MAAM,OAAO;EACb;EACA,UAAU,OAAO;CACnB;CAEA,OAAO;EAAE,MAAM,OAAO;EAAM;EAAO;CAAS;AAC9C;;;;;AAMA,eAAe,cACb,OACA,YACA,UAC2B;CAC3B,IAAI,CAAC,UACH,OAAO;CAGT,IAAI;EACF,OAAO,MAAM,SAAS,OAAO,OAAO,UAAU;CAChD,QAAQ;EAGN,OAAO;CACT;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { VectorStore } from "./vector-store.contract.mjs";
2
2
  import { CacheDriver } from "@warlock.js/cache";
3
3
 
4
- //#region ../@warlock.js/ai/src/rag/store/cache-vector-store.d.ts
4
+ //#region ../ai/src/rag/store/cache-vector-store.d.ts
5
5
  /**
6
6
  * Adapt any `@warlock.js/cache` `CacheDriver` to the {@link VectorStore}
7
7
  * narrowing the RAG pipeline depends on. The cache driver IS the vector
@@ -1 +1 @@
1
- {"version":3,"file":"cache-vector-store.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/store/cache-vector-store.ts"],"mappings":";;;;;;AAsBA;;;;;;;;AAA4E;;;;;;;;;iBAA5D,gBAAA,CAAiB,MAAA,EAAQ,WAAA,aAAwB,WAAW"}
1
+ {"version":3,"file":"cache-vector-store.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/store/cache-vector-store.ts"],"mappings":";;;;;;AAsBA;;;;;;;;AAA4E;;;;;;;;;iBAA5D,gBAAA,CAAiB,MAAA,EAAQ,WAAA,aAAwB,WAAW"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/rag/store/cache-vector-store.ts
1
+ //#region ../ai/src/rag/store/cache-vector-store.ts
2
2
  /**
3
3
  * Adapt any `@warlock.js/cache` `CacheDriver` to the {@link VectorStore}
4
4
  * narrowing the RAG pipeline depends on. The cache driver IS the vector
@@ -1 +1 @@
1
- {"version":3,"file":"cache-vector-store.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/store/cache-vector-store.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\nimport type { VectorStore } from \"./vector-store.contract\";\n\n/**\n * Adapt any `@warlock.js/cache` `CacheDriver` to the {@link VectorStore}\n * narrowing the RAG pipeline depends on. The cache driver IS the vector\n * store — exactly as `SemanticMemory` and `semanticCache` already use it:\n *\n * - `upsert` → `driver.set(key, value, { vector, tags })`\n * - `query` → `driver.similar<T>(vector, { topK, threshold, tags })`\n * - `removeNamespace` → `driver.removeNamespace(namespace)`\n *\n * Drivers without similarity support throw `CacheUnsupportedError` from\n * `set({ vector })` / `similar()`; the error surfaces unchanged so the\n * caller sees the cache layer's own message (pointing at the `pg` /\n * `redis` drivers for production-scale similarity).\n *\n * @example\n * const store = cacheVectorStore(new MemoryCacheDriver());\n * await store.upsert(\"ai.rag.docs.guide.0\", { text: \"…\" }, vector);\n * const hits = await store.query(queryVector, { topK: 5, threshold: 0.5 });\n */\nexport function cacheVectorStore(driver: CacheDriver<any, any>): VectorStore {\n return {\n async upsert(\n key: string,\n value: unknown,\n vector: number[],\n tags?: string[],\n ): Promise<void> {\n await driver.set(key, value, tags && tags.length > 0 ? { vector, tags } : { vector });\n },\n\n async query<T>(\n vector: number[],\n options: { topK: number; threshold?: number; tags?: string[] },\n ): Promise<{ key: string; value: T; score: number }[]> {\n const hits = await driver.similar<T>(vector, {\n topK: options.topK,\n threshold: options.threshold,\n tags: options.tags,\n });\n\n return hits.map((hit: { key: string; value: T; score: number }) => ({\n key: hit.key,\n value: hit.value,\n score: hit.score,\n }));\n },\n\n async removeNamespace(namespace: string): Promise<void> {\n await driver.removeNamespace(namespace);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAiB,QAA4C;CAC3E,OAAO;EACL,MAAM,OACJ,KACA,OACA,QACA,MACe;GACf,MAAM,OAAO,IAAI,KAAK,OAAO,QAAQ,KAAK,SAAS,IAAI;IAAE;IAAQ;GAAK,IAAI,EAAE,OAAO,CAAC;EACtF;EAEA,MAAM,MACJ,QACA,SACqD;GAOrD,QAAO,MANY,OAAO,QAAW,QAAQ;IAC3C,MAAM,QAAQ;IACd,WAAW,QAAQ;IACnB,MAAM,QAAQ;GAChB,CAAC,EAEU,CAAC,KAAK,SAAmD;IAClE,KAAK,IAAI;IACT,OAAO,IAAI;IACX,OAAO,IAAI;GACb,EAAE;EACJ;EAEA,MAAM,gBAAgB,WAAkC;GACtD,MAAM,OAAO,gBAAgB,SAAS;EACxC;CACF;AACF"}
1
+ {"version":3,"file":"cache-vector-store.mjs","names":[],"sources":["../../../../../../../../ai/src/rag/store/cache-vector-store.ts"],"sourcesContent":["import type { CacheDriver } from \"@warlock.js/cache\";\nimport type { VectorStore } from \"./vector-store.contract\";\n\n/**\n * Adapt any `@warlock.js/cache` `CacheDriver` to the {@link VectorStore}\n * narrowing the RAG pipeline depends on. The cache driver IS the vector\n * store — exactly as `SemanticMemory` and `semanticCache` already use it:\n *\n * - `upsert` → `driver.set(key, value, { vector, tags })`\n * - `query` → `driver.similar<T>(vector, { topK, threshold, tags })`\n * - `removeNamespace` → `driver.removeNamespace(namespace)`\n *\n * Drivers without similarity support throw `CacheUnsupportedError` from\n * `set({ vector })` / `similar()`; the error surfaces unchanged so the\n * caller sees the cache layer's own message (pointing at the `pg` /\n * `redis` drivers for production-scale similarity).\n *\n * @example\n * const store = cacheVectorStore(new MemoryCacheDriver());\n * await store.upsert(\"ai.rag.docs.guide.0\", { text: \"…\" }, vector);\n * const hits = await store.query(queryVector, { topK: 5, threshold: 0.5 });\n */\nexport function cacheVectorStore(driver: CacheDriver<any, any>): VectorStore {\n return {\n async upsert(\n key: string,\n value: unknown,\n vector: number[],\n tags?: string[],\n ): Promise<void> {\n await driver.set(key, value, tags && tags.length > 0 ? { vector, tags } : { vector });\n },\n\n async query<T>(\n vector: number[],\n options: { topK: number; threshold?: number; tags?: string[] },\n ): Promise<{ key: string; value: T; score: number }[]> {\n const hits = await driver.similar<T>(vector, {\n topK: options.topK,\n threshold: options.threshold,\n tags: options.tags,\n });\n\n return hits.map((hit: { key: string; value: T; score: number }) => ({\n key: hit.key,\n value: hit.value,\n score: hit.score,\n }));\n },\n\n async removeNamespace(namespace: string): Promise<void> {\n await driver.removeNamespace(namespace);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAiB,QAA4C;CAC3E,OAAO;EACL,MAAM,OACJ,KACA,OACA,QACA,MACe;GACf,MAAM,OAAO,IAAI,KAAK,OAAO,QAAQ,KAAK,SAAS,IAAI;IAAE;IAAQ;GAAK,IAAI,EAAE,OAAO,CAAC;EACtF;EAEA,MAAM,MACJ,QACA,SACqD;GAOrD,QAAO,MANY,OAAO,QAAW,QAAQ;IAC3C,MAAM,QAAQ;IACd,WAAW,QAAQ;IACnB,MAAM,QAAQ;GAChB,CAAC,EAEU,CAAC,KAAK,SAAmD;IAClE,KAAK,IAAI;IACT,OAAO,IAAI;IACX,OAAO,IAAI;GACb,EAAE;EACJ;EAEA,MAAM,gBAAgB,WAAkC;GACtD,MAAM,OAAO,gBAAgB,SAAS;EACxC;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { VectorStore } from "./vector-store.contract.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/rag/store/pg-vector-store.d.ts
3
+ //#region ../ai/src/rag/store/pg-vector-store.d.ts
4
4
  /**
5
5
  * Minimal `pg`-compatible client surface the Postgres {@link VectorStore}
6
6
  * depends on. Both `pg.Pool` and `pg.Client` satisfy it — the store only
@@ -1 +1 @@
1
- {"version":3,"file":"pg-vector-store.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/store/pg-vector-store.ts"],"mappings":";;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-vector-store.ts
1
+ //#region ../ai/src/rag/store/pg-vector-store.ts
2
2
  /**
3
3
  * Default backing table — provisions the store with no extra config when
4
4
  * the dev runs {@link VectorStore.schema | ensureSchema} through their
@@ -1 +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":";;;;;;AA6EA,MAAM,gBAAgB;;AAGtB,MAAM,qBAAqB;;AAG3B,MAAM,wBAAwB;;;;;;;;AAS9B,MAAM,kBAAkB;;;;;;;AAQxB,MAAM,YAAY;;;;;;AAOlB,MAAM,0BAA0B;;;;;;;;;;EAU9B,KAAK;;;;;;AAiBP,eAAe,cAAc,kBAAiD;CAC5E,IAAI;CAEJ,IAAI;EACF,MAAO,MAAM,OAAO;CACtB,QAAQ;EACN,MAAM,IAAI,MAAM,uBAAuB;CACzC;CAEA,OAAO,IAAI,IAAI,KAAK,EAAE,iBAAiB,CAAC;AAC1C;;;;;;;;;;;;;;;;AAiBA,SAAgB,cAAc,QAA0B;CACtD,IAAI,UAAU;CAEd,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EAClD,MAAM,YAAY,OAAO;EAEzB,IAAI,CAAC,OAAO,SAAS,SAAS,GAC5B,MAAM,IAAI,UACR,+CAA+C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KACJ,kCAAkC,KAAK,MAAM,aAC7C,QAAQ,KAAK,MAAM,2CACrB;OACK,IAAI,KAAK,UAAU,WACxB,MAAM,KACJ,kCAAkC,KAAK,MAAM,aAC7C,QAAQ,KAAK,MAAM,+CACnB,mBAAmB,KAAK,aAAa,GACvC;OAEA,MAAM,KACJ,uEACA,sEACF;EAGF,OAAO,MAAM,KAAK,IAAI;CACxB;;;;;;;CAQA,AAAO,eAAuB;EAC5B,OAAO,KAAK,OAAO;CACrB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,cAAc,SAAsD;CAClF,OAAO,IAAI,cAAc,OAAO;AAClC"}
1
+ {"version":3,"file":"pg-vector-store.mjs","names":[],"sources":["../../../../../../../../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":";;;;;;AA6EA,MAAM,gBAAgB;;AAGtB,MAAM,qBAAqB;;AAG3B,MAAM,wBAAwB;;;;;;;;AAS9B,MAAM,kBAAkB;;;;;;;AAQxB,MAAM,YAAY;;;;;;AAOlB,MAAM,0BAA0B;;;;;;;;;;EAU9B,KAAK;;;;;;AAiBP,eAAe,cAAc,kBAAiD;CAC5E,IAAI;CAEJ,IAAI;EACF,MAAO,MAAM,OAAO;CACtB,QAAQ;EACN,MAAM,IAAI,MAAM,uBAAuB;C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WAAW,GAAG,QAAQ,GAAG,CAC5B;CACF;;;;;;;;;;;;;;;;;;;;;;;;CAyBA,AAAO,SAAiB;EACtB,MAAM,QAAQ;GACZ;GACA,8BAA8B,KAAK,MAAM;GACzC;GACA;GACA,uBAAuB,KAAK,WAAW;GACvC;GACA;GACA,kCAAkC,KAAK,MAAM;GAC7C,QAAQ,KAAK,MAAM;EACrB;EAEA,IAAI,KAAK,UAAU,QACjB,MAAM,KACJ,kCAAkC,KAAK,MAAM,aAC7C,QAAQ,KAAK,MAAM,2CACrB;OACK,IAAI,KAAK,UAAU,WACxB,MAAM,KACJ,kCAAkC,KAAK,MAAM,aAC7C,QAAQ,KAAK,MAAM,+CACnB,mBAAmB,KAAK,aAAa,GACvC;OAEA,MAAM,KACJ,uEACA,sEACF;EAGF,OAAO,MAAM,KAAK,IAAI;CACxB;;;;;;;CAQA,AAAO,eAAuB;EAC5B,OAAO,KAAK,OAAO;CACrB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,cAAc,SAAsD;CAClF,OAAO,IAAI,cAAc,OAAO;AAClC"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/rag/store/vector-store.contract.d.ts
1
+ //#region ../ai/src/rag/store/vector-store.contract.d.ts
2
2
  /**
3
3
  * The three vector operations the RAG pipeline needs, expressed as a thin
4
4
  * structural narrowing of the `@warlock.js/cache` `CacheDriver` surface
@@ -1 +1 @@
1
- {"version":3,"file":"vector-store.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/store/vector-store.contract.ts"],"mappings":";;AAWA;;;;;;;;;;UAAiB,WAAA;EAMK;;;;;EAApB,MAAA,CAAO,GAAA,UAAa,KAAA,WAAgB,MAAA,YAAkB,IAAA,cAAkB,OAAA;EAMtE;;;;EADF,KAAA,IACE,MAAA,YACA,OAAA;IAAW,IAAA;IAAc,SAAA;IAAoB,IAAA;EAAA,IAC5C,OAAA;IAAU,GAAA;IAAa,KAAA,EAAO,CAAA;IAAG,KAAA;EAAA;EAEO;EAA3C,eAAA,CAAgB,SAAA,WAAoB,OAAA;AAAA"}
1
+ {"version":3,"file":"vector-store.contract.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/store/vector-store.contract.ts"],"mappings":";;AAWA;;;;;;;;;;UAAiB,WAAA;EAMK;;;;;EAApB,MAAA,CAAO,GAAA,UAAa,KAAA,WAAgB,MAAA,YAAkB,IAAA,cAAkB,OAAA;EAMtE;;;;EADF,KAAA,IACE,MAAA,YACA,OAAA;IAAW,IAAA;IAAc,SAAA;IAAoB,IAAA;EAAA,IAC5C,OAAA;IAAU,GAAA;IAAa,KAAA,EAAO,CAAA;IAAG,KAAA;EAAA;EAEO;EAA3C,eAAA,CAAgB,SAAA,WAAoB,OAAA;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import { ModelContract } from "../../contracts/model.contract.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/rag/transforms/multi-query.d.ts
3
+ //#region ../ai/src/rag/transforms/multi-query.d.ts
4
4
  /** Options for {@link multiQuery}. */
5
5
  type MultiQueryOptions = {
6
6
  /** How many alternative phrasings to request. Default 3. */n?: number; /** Include the original query in the returned list. Default true. */
@@ -1 +1 @@
1
- {"version":3,"file":"multi-query.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/rag/transforms/multi-query.ts"],"mappings":";;;;KAGY,iBAAA;EAAA,4DAEV,CAAA;EAEA,eAAe;AAAA;AAkBjB;;;;;;;;;;;;;;;AAAA,iBAAsB,UAAA,CACpB,KAAA,EAAO,aAAA,EACP,KAAA,UACA,OAAA,GAAS,iBAAA,GACR,OAAA"}
1
+ {"version":3,"file":"multi-query.d.mts","names":[],"sources":["../../../../../../../../ai/src/rag/transforms/multi-query.ts"],"mappings":";;;;KAGY,iBAAA;EAAA,4DAEV,CAAA;EAEA,eAAe;AAAA;AAkBjB;;;;;;;;;;;;;;;AAAA,iBAAsB,UAAA,CACpB,KAAA,EAAO,aAAA,EACP,KAAA,UACA,OAAA,GAAS,iBAAA,GACR,OAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/rag/transforms/multi-query.ts
1
+ //#region ../ai/src/rag/transforms/multi-query.ts
2
2
  /**
3
3
  * Multi-query expansion (A4) — ask a model for several alternative
4
4
  * phrasings of `query`, so retrieval covers vocabulary the original
@@ -1 +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"}
1
+ {"version":3,"file":"multi-query.mjs","names":[],"sources":["../../../../../../../../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"}
@@ -1,6 +1,6 @@
1
1
  import { OutboundPolicy, ResolvedOutboundPolicy } from "./outbound-policy.type.mjs";
2
2
 
3
- //#region ../@warlock.js/ai/src/security/outbound-policy.d.ts
3
+ //#region ../ai/src/security/outbound-policy.d.ts
4
4
  /**
5
5
  * Fill an {@link OutboundPolicy} with strict defaults: https-only,
6
6
  * private-IP deny on, 10s timeout, 5 MiB cap, global `fetch`. Idempotent
@@ -1 +1 @@
1
- {"version":3,"file":"outbound-policy.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/security/outbound-policy.ts"],"mappings":";;;;;AAmBA;;;iBAAgB,qBAAA,CACd,MAAA,GAAQ,cAAA,GACP,sBAAsB;;;;;AAAA;AAiCzB;;iBAAsB,gBAAA,CACpB,MAAA,UACA,MAAA,EAAQ,sBAAA,GACP,OAAA,CAAQ,GAAA;;;;;;;;iBAiGW,YAAA,CACpB,MAAA,UACA,WAAA,EAAa,cAAA,EACb,IAAA,GAAO,WAAA,GACN,OAAA,CAAQ,QAAA;;;;AArGG;AAiGd;;iBAkCsB,cAAA,CACpB,QAAA,EAAU,QAAA,EACV,QAAA,WACC,OAAO;;;;;;iBAgDY,mBAAA,CACpB,MAAA,UACA,WAAA,EAAa,cAAA,EACb,IAAA,GAAO,WAAA,GACN,OAAA;EAAU,EAAA;EAAa,MAAA;EAAgB,UAAA;EAAoB,IAAA;AAAA"}
1
+ {"version":3,"file":"outbound-policy.d.mts","names":[],"sources":["../../../../../../../ai/src/security/outbound-policy.ts"],"mappings":";;;;;AAmBA;;;iBAAgB,qBAAA,CACd,MAAA,GAAQ,cAAA,GACP,sBAAsB;;;;;AAAA;AAiCzB;;iBAAsB,gBAAA,CACpB,MAAA,UACA,MAAA,EAAQ,sBAAA,GACP,OAAA,CAAQ,GAAA;;;;;;;;iBAiGW,YAAA,CACpB,MAAA,UACA,WAAA,EAAa,cAAA,EACb,IAAA,GAAO,WAAA,GACN,OAAA,CAAQ,QAAA;;;;AArGG;AAiGd;;iBAkCsB,cAAA,CACpB,QAAA,EAAU,QAAA,EACV,QAAA,WACC,OAAO;;;;;;iBAgDY,mBAAA,CACpB,MAAA,UACA,WAAA,EAAa,cAAA,EACb,IAAA,GAAO,WAAA,GACN,OAAA;EAAU,EAAA;EAAa,MAAA;EAAgB,UAAA;EAAoB,IAAA;AAAA"}
@@ -4,7 +4,7 @@ import { isPrivateOrReservedIp } from "./private-ip.mjs";
4
4
  import { lookup } from "node:dns/promises";
5
5
  import { isIP } from "node:net";
6
6
 
7
- //#region ../@warlock.js/ai/src/security/outbound-policy.ts
7
+ //#region ../ai/src/security/outbound-policy.ts
8
8
  /** 5 MiB — default cap on an outbound response body. */
9
9
  const DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
10
10
  /** 10s — default per-request timeout. */
@@ -1 +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":";;;;;;;;AAUA,MAAM,oBAAoB,IAAI,OAAO;;AAErC,MAAM,qBAAqB;;;;;;AAO3B,SAAgB,sBACd,SAAyB,CAAC,GACF;CACxB,OAAO;EACL,gBAAgB,OAAO,kBAAkB,CAAC,OAAO;EACjD,eAAe,OAAO;EACtB,wBAAwB,OAAO,0BAA0B;EACzD,UAAU,OAAO,YAAY;EAC7B,WAAW,OAAO,aAAa;EAC/B,QAAQ,OAAO;EACf,OAAO,OAAO,SAAS,WAAW;CACpC;AACF;;AAGA,SAAS,cAAc,MAAsB;CAC3C,OAAO,KAAK,WAAW,GAAG,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAC1E;;AAGA,SAAS,YAAY,MAAc,WAA8B;CAC/D,MAAM,QAAQ,KAAK,YAAY;CAC/B,OAAO,UAAU,MAAK,UAAS;EAC7B,MAAM,IAAI,MAAM,YAAY;EAC5B,OAAO,UAAU,KAAK,MAAM,SAAS,IAAI,GAAG;CAC9C,CAAC;AACH;;;;;;;;AASA,eAAsB,iBACpB,QACA,QACc;CACd,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,MAAM;CACtB,QAAQ;EACN,MAAM,IAAI,oBAAoB,2CAA2C,UAAU,EACjF,SAAS,EAAE,KAAK,OAAO,EACzB,CAAC;CACH;CAEA,MAAM,SAAS,IAAI,SAAS,QAAQ,MAAM,EAAE,CAAC,CAAC,YAAY;CAC1D,IAAI,CAAC,OAAO,eAAe,MAAK,MAAK,EAAE,YAAY,MAAM,MAAM,G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C1C,IAAI,MAAM;EACV,IAAI,CAAC,OAAO;EAEZ,SAAS,MAAM;EACf,IAAI,QAAQ,UAAU;GACpB,MAAM,OAAO,OAAO;GACpB,MAAM,IAAI,oBACR,uCAAuC,SAAS,YAChD,EAAE,SAAS,EAAE,SAAS,EAAE,CAC1B;EACF;EACA,OAAO,KAAK,KAAK;CACnB;CAEA,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAM;AAC9C;;;;;;AAOA,eAAsB,oBACpB,QACA,aACA,MAC4E;CAC5E,MAAM,SAAS,sBAAsB,WAAW;CAChD,MAAM,WAAW,MAAM,aAAa,QAAQ,QAAQ,IAAI;CAExD,OAAO;EACL,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,MAAM,SAAS,KAAK,MAAM,eAAe,UAAU,OAAO,QAAQ,IAAI;CACxE;AACF"}
1
+ {"version":3,"file":"outbound-policy.mjs","names":[],"sources":["../../../../../../../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 read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A,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAM;AAC9C;;;;;;AAOA,eAAsB,oBACpB,QACA,aACA,MAC4E;CAC5E,MAAM,SAAS,sBAAsB,WAAW;CAChD,MAAM,WAAW,MAAM,aAAa,QAAQ,QAAQ,IAAI;CAExD,OAAO;EACL,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,MAAM,SAAS,KAAK,MAAM,eAAe,UAAU,OAAO,QAAQ,IAAI;CACxE;AACF"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/security/outbound-policy.type.d.ts
1
+ //#region ../ai/src/security/outbound-policy.type.d.ts
2
2
  /**
3
3
  * One shared policy for every server-side outbound request the framework
4
4
  * makes on a user's behalf — attachment fetches (S1), URL skill manifests
@@ -1 +1 @@
1
- {"version":3,"file":"outbound-policy.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/security/outbound-policy.type.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;AAuCsB;AAItB;;;;KA3CY,cAAA;EA6CV;;;;;EAvCA,cAAA;EA4CA;;;AAAmB;;;EArCnB,aAAA;;;;;;;EAOA,sBAAA;;;;;;EAMA,QAAA;EAEA,SAAA;;;;;EAKA,MAAA,GAAS,WAAA;;;;;;EAMT,KAAA,UAAe,KAAK;AAAA;;KAIV,sBAAA;EACV,cAAA;EACA,aAAA;EACA,sBAAA;EACA,QAAA;EACA,SAAA;EACA,MAAA,GAAS,WAAA;EACT,KAAA,SAAc,KAAK;AAAA"}
1
+ {"version":3,"file":"outbound-policy.type.d.mts","names":[],"sources":["../../../../../../../ai/src/security/outbound-policy.type.ts"],"mappings":";;AAoBA;;;;;;;;;;;;;;AAuCsB;AAItB;;;;KA3CY,cAAA;EA6CV;;;;;EAvCA,cAAA;EA4CA;;;AAAmB;;;EArCnB,aAAA;;;;;;;EAOA,sBAAA;;;;;;EAMA,QAAA;EAEA,SAAA;;;;;EAKA,MAAA,GAAS,WAAA;;;;;;EAMT,KAAA,UAAe,KAAK;AAAA;;KAIV,sBAAA;EACV,cAAA;EACA,aAAA;EACA,sBAAA;EACA,QAAA;EACA,SAAA;EACA,MAAA,GAAS,WAAA;EACT,KAAA,SAAc,KAAK;AAAA"}
@@ -1,4 +1,4 @@
1
- //#region ../@warlock.js/ai/src/security/private-ip.d.ts
1
+ //#region ../ai/src/security/private-ip.d.ts
2
2
  /**
3
3
  * True when `ip` is a private, loopback, link-local, unique-local,
4
4
  * carrier-grade-NAT, unspecified, or otherwise non-public address — the