@warlock.js/core 4.4.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (997) hide show
  1. package/CHANGELOG.md +72 -5
  2. package/README.md +47 -11
  3. package/esm/ai/src/agent/agent-input-builder.mjs +132 -0
  4. package/esm/ai/src/agent/agent-input-builder.mjs.map +1 -0
  5. package/esm/ai/src/agent/agent-log-event.mjs +101 -0
  6. package/esm/ai/src/agent/agent-log-event.mjs.map +1 -0
  7. package/esm/ai/src/agent/agent-stream.mjs +82 -0
  8. package/esm/ai/src/agent/agent-stream.mjs.map +1 -0
  9. package/esm/ai/src/agent/agent-to-stream-event.mjs +86 -0
  10. package/esm/ai/src/agent/agent-to-stream-event.mjs.map +1 -0
  11. package/esm/ai/src/agent/agent.mjs +1276 -0
  12. package/esm/ai/src/agent/agent.mjs.map +1 -0
  13. package/esm/ai/src/agent/index.mjs +5 -0
  14. package/esm/ai/src/agent/json-stream-guard.mjs +400 -0
  15. package/esm/ai/src/agent/json-stream-guard.mjs.map +1 -0
  16. package/esm/ai/src/agent/signature.mjs +57 -0
  17. package/esm/ai/src/agent/signature.mjs.map +1 -0
  18. package/esm/ai/src/agent/snapshot.mjs +101 -0
  19. package/esm/ai/src/agent/snapshot.mjs.map +1 -0
  20. package/esm/ai/src/agent/spawn-sub-agent.mjs +68 -0
  21. package/esm/ai/src/agent/spawn-sub-agent.mjs.map +1 -0
  22. package/esm/ai/src/ai.mjs +191 -0
  23. package/esm/ai/src/ai.mjs.map +1 -0
  24. package/esm/ai/src/batch/batch.mjs +198 -0
  25. package/esm/ai/src/batch/batch.mjs.map +1 -0
  26. package/esm/ai/src/batch/index.mjs +3 -0
  27. package/esm/ai/src/batch/run-batch-item.mjs +100 -0
  28. package/esm/ai/src/batch/run-batch-item.mjs.map +1 -0
  29. package/esm/ai/src/batch/run-with-concurrency.mjs +39 -0
  30. package/esm/ai/src/batch/run-with-concurrency.mjs.map +1 -0
  31. package/esm/ai/src/checkpoint/memory.mjs +0 -0
  32. package/esm/ai/src/checkpoint/memory.mjs.map +1 -0
  33. package/esm/ai/src/checkpoint/pg.mjs +265 -0
  34. package/esm/ai/src/checkpoint/pg.mjs.map +1 -0
  35. package/esm/ai/src/checkpoint/redis.mjs +200 -0
  36. package/esm/ai/src/checkpoint/redis.mjs.map +1 -0
  37. package/esm/ai/src/config.mjs +59 -0
  38. package/esm/ai/src/config.mjs.map +1 -0
  39. package/esm/ai/src/contracts/end.type.mjs +47 -0
  40. package/esm/ai/src/contracts/end.type.mjs.map +1 -0
  41. package/esm/ai/src/errors/agent-cancelled-error.mjs +43 -0
  42. package/esm/ai/src/errors/agent-cancelled-error.mjs.map +1 -0
  43. package/esm/ai/src/errors/agent-drift-error.mjs +31 -0
  44. package/esm/ai/src/errors/agent-drift-error.mjs.map +1 -0
  45. package/esm/ai/src/errors/agent-execution-error.mjs +35 -0
  46. package/esm/ai/src/errors/agent-execution-error.mjs.map +1 -0
  47. package/esm/ai/src/errors/agent-max-trips-error.mjs +41 -0
  48. package/esm/ai/src/errors/agent-max-trips-error.mjs.map +1 -0
  49. package/esm/ai/src/errors/ai-error.mjs +68 -0
  50. package/esm/ai/src/errors/ai-error.mjs.map +1 -0
  51. package/esm/ai/src/errors/budget-exceeded-error.mjs +31 -0
  52. package/esm/ai/src/errors/budget-exceeded-error.mjs.map +1 -0
  53. package/esm/ai/src/errors/content-filter-error.mjs +28 -0
  54. package/esm/ai/src/errors/content-filter-error.mjs.map +1 -0
  55. package/esm/ai/src/errors/context-length-exceeded-error.mjs +31 -0
  56. package/esm/ai/src/errors/context-length-exceeded-error.mjs.map +1 -0
  57. package/esm/ai/src/errors/guardrail-violation-error.mjs +41 -0
  58. package/esm/ai/src/errors/guardrail-violation-error.mjs.map +1 -0
  59. package/esm/ai/src/errors/index.mjs +39 -0
  60. package/esm/ai/src/errors/invalid-request-error.mjs +31 -0
  61. package/esm/ai/src/errors/invalid-request-error.mjs.map +1 -0
  62. package/esm/ai/src/errors/max-iterations-error.mjs +32 -0
  63. package/esm/ai/src/errors/max-iterations-error.mjs.map +1 -0
  64. package/esm/ai/src/errors/max-steps-exceeded-error.mjs +21 -0
  65. package/esm/ai/src/errors/max-steps-exceeded-error.mjs.map +1 -0
  66. package/esm/ai/src/errors/orchestrator-cancelled-error.mjs +31 -0
  67. package/esm/ai/src/errors/orchestrator-cancelled-error.mjs.map +1 -0
  68. package/esm/ai/src/errors/orchestrator-config-error.mjs +30 -0
  69. package/esm/ai/src/errors/orchestrator-config-error.mjs.map +1 -0
  70. package/esm/ai/src/errors/orchestrator-drift-error.mjs +37 -0
  71. package/esm/ai/src/errors/orchestrator-drift-error.mjs.map +1 -0
  72. package/esm/ai/src/errors/orchestrator-failed-error.mjs +36 -0
  73. package/esm/ai/src/errors/orchestrator-failed-error.mjs.map +1 -0
  74. package/esm/ai/src/errors/outbound-policy-error.mjs +32 -0
  75. package/esm/ai/src/errors/outbound-policy-error.mjs.map +1 -0
  76. package/esm/ai/src/errors/planner-cancelled-error.mjs +29 -0
  77. package/esm/ai/src/errors/planner-cancelled-error.mjs.map +1 -0
  78. package/esm/ai/src/errors/planner-drift-error.mjs +33 -0
  79. package/esm/ai/src/errors/planner-drift-error.mjs.map +1 -0
  80. package/esm/ai/src/errors/planner-failed-error.mjs +37 -0
  81. package/esm/ai/src/errors/planner-failed-error.mjs.map +1 -0
  82. package/esm/ai/src/errors/planner-plan-invalid-error.mjs +25 -0
  83. package/esm/ai/src/errors/planner-plan-invalid-error.mjs.map +1 -0
  84. package/esm/ai/src/errors/provider-auth-error.mjs +26 -0
  85. package/esm/ai/src/errors/provider-auth-error.mjs.map +1 -0
  86. package/esm/ai/src/errors/provider-error.mjs +42 -0
  87. package/esm/ai/src/errors/provider-error.mjs.map +1 -0
  88. package/esm/ai/src/errors/provider-rate-limit-error.mjs +31 -0
  89. package/esm/ai/src/errors/provider-rate-limit-error.mjs.map +1 -0
  90. package/esm/ai/src/errors/provider-timeout-error.mjs +26 -0
  91. package/esm/ai/src/errors/provider-timeout-error.mjs.map +1 -0
  92. package/esm/ai/src/errors/quota-exceeded-error.mjs +40 -0
  93. package/esm/ai/src/errors/quota-exceeded-error.mjs.map +1 -0
  94. package/esm/ai/src/errors/routing-error.mjs +23 -0
  95. package/esm/ai/src/errors/routing-error.mjs.map +1 -0
  96. package/esm/ai/src/errors/schema-validation-error.mjs +37 -0
  97. package/esm/ai/src/errors/schema-validation-error.mjs.map +1 -0
  98. package/esm/ai/src/errors/step-failed-error.mjs +19 -0
  99. package/esm/ai/src/errors/step-failed-error.mjs.map +1 -0
  100. package/esm/ai/src/errors/supervisor-cancelled-error.mjs +29 -0
  101. package/esm/ai/src/errors/supervisor-cancelled-error.mjs.map +1 -0
  102. package/esm/ai/src/errors/supervisor-drift-error.mjs +30 -0
  103. package/esm/ai/src/errors/supervisor-drift-error.mjs.map +1 -0
  104. package/esm/ai/src/errors/supervisor-failed-error.mjs +43 -0
  105. package/esm/ai/src/errors/supervisor-failed-error.mjs.map +1 -0
  106. package/esm/ai/src/errors/supervisor-routing-error.mjs +39 -0
  107. package/esm/ai/src/errors/supervisor-routing-error.mjs.map +1 -0
  108. package/esm/ai/src/errors/tool-execution-error.mjs +32 -0
  109. package/esm/ai/src/errors/tool-execution-error.mjs.map +1 -0
  110. package/esm/ai/src/errors/workflow-cancelled-error.mjs +23 -0
  111. package/esm/ai/src/errors/workflow-cancelled-error.mjs.map +1 -0
  112. package/esm/ai/src/errors/workflow-drift-error.mjs +24 -0
  113. package/esm/ai/src/errors/workflow-drift-error.mjs.map +1 -0
  114. package/esm/ai/src/errors/workflow-error.mjs +18 -0
  115. package/esm/ai/src/errors/workflow-error.mjs.map +1 -0
  116. package/esm/ai/src/eval/dataset.mjs +112 -0
  117. package/esm/ai/src/eval/dataset.mjs.map +1 -0
  118. package/esm/ai/src/eval/eval-runner.mjs +135 -0
  119. package/esm/ai/src/eval/eval-runner.mjs.map +1 -0
  120. package/esm/ai/src/eval/index.mjs +48 -0
  121. package/esm/ai/src/eval/index.mjs.map +1 -0
  122. package/esm/ai/src/eval/judge-scorer.mjs +87 -0
  123. package/esm/ai/src/eval/judge-scorer.mjs.map +1 -0
  124. package/esm/ai/src/eval/regression.mjs +51 -0
  125. package/esm/ai/src/eval/regression.mjs.map +1 -0
  126. package/esm/ai/src/eval/report-json.mjs +33 -0
  127. package/esm/ai/src/eval/report-json.mjs.map +1 -0
  128. package/esm/ai/src/eval/report-junit.mjs +60 -0
  129. package/esm/ai/src/eval/report-junit.mjs.map +1 -0
  130. package/esm/ai/src/eval/scorers.mjs +101 -0
  131. package/esm/ai/src/eval/scorers.mjs.map +1 -0
  132. package/esm/ai/src/guard/detectors/index.mjs +6 -0
  133. package/esm/ai/src/guard/detectors/injection.mjs +254 -0
  134. package/esm/ai/src/guard/detectors/injection.mjs.map +1 -0
  135. package/esm/ai/src/guard/detectors/moderation.mjs +134 -0
  136. package/esm/ai/src/guard/detectors/moderation.mjs.map +1 -0
  137. package/esm/ai/src/guard/detectors/pii.mjs +199 -0
  138. package/esm/ai/src/guard/detectors/pii.mjs.map +1 -0
  139. package/esm/ai/src/guard/detectors/topic.mjs +99 -0
  140. package/esm/ai/src/guard/detectors/topic.mjs.map +1 -0
  141. package/esm/ai/src/guard/errors.mjs +18 -0
  142. package/esm/ai/src/guard/errors.mjs.map +1 -0
  143. package/esm/ai/src/guard/guard.mjs +209 -0
  144. package/esm/ai/src/guard/guard.mjs.map +1 -0
  145. package/esm/ai/src/guard/guardrail.mjs +22 -0
  146. package/esm/ai/src/guard/guardrail.mjs.map +1 -0
  147. package/esm/ai/src/human/errors.mjs +60 -0
  148. package/esm/ai/src/human/errors.mjs.map +1 -0
  149. package/esm/ai/src/human/human-approval.mjs +170 -0
  150. package/esm/ai/src/human/human-approval.mjs.map +1 -0
  151. package/esm/ai/src/human/policy.mjs +67 -0
  152. package/esm/ai/src/human/policy.mjs.map +1 -0
  153. package/esm/ai/src/human/register.mjs +37 -0
  154. package/esm/ai/src/human/register.mjs.map +1 -0
  155. package/esm/ai/src/human/resume-seed.mjs +53 -0
  156. package/esm/ai/src/human/resume-seed.mjs.map +1 -0
  157. package/esm/ai/src/human/resume.mjs +121 -0
  158. package/esm/ai/src/human/resume.mjs.map +1 -0
  159. package/esm/ai/src/human/stores/index.mjs +5 -0
  160. package/esm/ai/src/human/stores/memory.mjs +91 -0
  161. package/esm/ai/src/human/stores/memory.mjs.map +1 -0
  162. package/esm/ai/src/human/stores/pg.mjs +220 -0
  163. package/esm/ai/src/human/stores/pg.mjs.map +1 -0
  164. package/esm/ai/src/human/stores/redis.mjs +201 -0
  165. package/esm/ai/src/human/stores/redis.mjs.map +1 -0
  166. package/esm/ai/src/image/image-cost.mjs +55 -0
  167. package/esm/ai/src/image/image-cost.mjs.map +1 -0
  168. package/esm/ai/src/image/image.mjs +112 -0
  169. package/esm/ai/src/image/image.mjs.map +1 -0
  170. package/esm/ai/src/image/index.mjs +4 -0
  171. package/esm/ai/src/index.mjs +194 -0
  172. package/esm/ai/src/memory/derive-id.mjs +24 -0
  173. package/esm/ai/src/memory/derive-id.mjs.map +1 -0
  174. package/esm/ai/src/memory/episodic-memory.mjs +106 -0
  175. package/esm/ai/src/memory/episodic-memory.mjs.map +1 -0
  176. package/esm/ai/src/memory/memory.mjs +166 -0
  177. package/esm/ai/src/memory/memory.mjs.map +1 -0
  178. package/esm/ai/src/memory/procedural-memory.mjs +103 -0
  179. package/esm/ai/src/memory/procedural-memory.mjs.map +1 -0
  180. package/esm/ai/src/memory/semantic-memory.mjs +80 -0
  181. package/esm/ai/src/memory/semantic-memory.mjs.map +1 -0
  182. package/esm/ai/src/memory/working-memory.mjs +62 -0
  183. package/esm/ai/src/memory/working-memory.mjs.map +1 -0
  184. package/esm/ai/src/middleware/builtins/budget.mjs +219 -0
  185. package/esm/ai/src/middleware/builtins/budget.mjs.map +1 -0
  186. package/esm/ai/src/middleware/builtins/guardrail.mjs +76 -0
  187. package/esm/ai/src/middleware/builtins/guardrail.mjs.map +1 -0
  188. package/esm/ai/src/middleware/builtins/semantic-cache.mjs +149 -0
  189. package/esm/ai/src/middleware/builtins/semantic-cache.mjs.map +1 -0
  190. package/esm/ai/src/middleware/helpers/compose.mjs +52 -0
  191. package/esm/ai/src/middleware/helpers/compose.mjs.map +1 -0
  192. package/esm/ai/src/middleware/helpers/for-tool.mjs +80 -0
  193. package/esm/ai/src/middleware/helpers/for-tool.mjs.map +1 -0
  194. package/esm/ai/src/middleware/index.mjs +10 -0
  195. package/esm/ai/src/middleware/pipeline.mjs +100 -0
  196. package/esm/ai/src/middleware/pipeline.mjs.map +1 -0
  197. package/esm/ai/src/middleware/utils/extract-user-text.mjs +47 -0
  198. package/esm/ai/src/middleware/utils/extract-user-text.mjs.map +1 -0
  199. package/esm/ai/src/middleware/utils/namespaced-state.mjs +60 -0
  200. package/esm/ai/src/middleware/utils/namespaced-state.mjs.map +1 -0
  201. package/esm/ai/src/mock/index.mjs +4 -0
  202. package/esm/ai/src/mock/mock-agent.mjs +3 -0
  203. package/esm/ai/src/mock/mock-router.mjs +58 -0
  204. package/esm/ai/src/mock/mock-router.mjs.map +1 -0
  205. package/esm/ai/src/model/fallback-model.mjs +218 -0
  206. package/esm/ai/src/model/fallback-model.mjs.map +1 -0
  207. package/esm/ai/src/model/index.mjs +3 -0
  208. package/esm/ai/src/object-stream/index.mjs +4 -0
  209. package/esm/ai/src/object-stream/parse-partial-json.mjs +78 -0
  210. package/esm/ai/src/object-stream/parse-partial-json.mjs.map +1 -0
  211. package/esm/ai/src/object-stream/stream-object.mjs +97 -0
  212. package/esm/ai/src/object-stream/stream-object.mjs.map +1 -0
  213. package/esm/ai/src/observe/index.mjs +4 -0
  214. package/esm/ai/src/observe/observer-registry.mjs +35 -0
  215. package/esm/ai/src/observe/observer-registry.mjs.map +1 -0
  216. package/esm/ai/src/observe/resolve-observers.mjs +73 -0
  217. package/esm/ai/src/observe/resolve-observers.mjs.map +1 -0
  218. package/esm/ai/src/orchestrator/as-tool.mjs +98 -0
  219. package/esm/ai/src/orchestrator/as-tool.mjs.map +1 -0
  220. package/esm/ai/src/orchestrator/checkpoint.mjs +75 -0
  221. package/esm/ai/src/orchestrator/checkpoint.mjs.map +1 -0
  222. package/esm/ai/src/orchestrator/commands.mjs +34 -0
  223. package/esm/ai/src/orchestrator/commands.mjs.map +1 -0
  224. package/esm/ai/src/orchestrator/compaction.mjs +206 -0
  225. package/esm/ai/src/orchestrator/compaction.mjs.map +1 -0
  226. package/esm/ai/src/orchestrator/dispatch.mjs +171 -0
  227. package/esm/ai/src/orchestrator/dispatch.mjs.map +1 -0
  228. package/esm/ai/src/orchestrator/emitter.mjs +85 -0
  229. package/esm/ai/src/orchestrator/emitter.mjs.map +1 -0
  230. package/esm/ai/src/orchestrator/execution.mjs +395 -0
  231. package/esm/ai/src/orchestrator/execution.mjs.map +1 -0
  232. package/esm/ai/src/orchestrator/index.mjs +11 -0
  233. package/esm/ai/src/orchestrator/load.mjs +49 -0
  234. package/esm/ai/src/orchestrator/load.mjs.map +1 -0
  235. package/esm/ai/src/orchestrator/lock.mjs +75 -0
  236. package/esm/ai/src/orchestrator/lock.mjs.map +1 -0
  237. package/esm/ai/src/orchestrator/memory.mjs +141 -0
  238. package/esm/ai/src/orchestrator/memory.mjs.map +1 -0
  239. package/esm/ai/src/orchestrator/orchestrator-stream.mjs +98 -0
  240. package/esm/ai/src/orchestrator/orchestrator-stream.mjs.map +1 -0
  241. package/esm/ai/src/orchestrator/orchestrator.mjs +206 -0
  242. package/esm/ai/src/orchestrator/orchestrator.mjs.map +1 -0
  243. package/esm/ai/src/orchestrator/resume.mjs +74 -0
  244. package/esm/ai/src/orchestrator/resume.mjs.map +1 -0
  245. package/esm/ai/src/orchestrator/session-lock.mjs +83 -0
  246. package/esm/ai/src/orchestrator/session-lock.mjs.map +1 -0
  247. package/esm/ai/src/orchestrator/signature.mjs +120 -0
  248. package/esm/ai/src/orchestrator/signature.mjs.map +1 -0
  249. package/esm/ai/src/orchestrator/window.mjs +56 -0
  250. package/esm/ai/src/orchestrator/window.mjs.map +1 -0
  251. package/esm/ai/src/planner/dag-scheduler.mjs +97 -0
  252. package/esm/ai/src/planner/dag-scheduler.mjs.map +1 -0
  253. package/esm/ai/src/planner/index.mjs +6 -0
  254. package/esm/ai/src/planner/plan-prompt.mjs +31 -0
  255. package/esm/ai/src/planner/plan-prompt.mjs.map +1 -0
  256. package/esm/ai/src/planner/plan-schema.mjs +120 -0
  257. package/esm/ai/src/planner/plan-schema.mjs.map +1 -0
  258. package/esm/ai/src/planner/planner-run.mjs +769 -0
  259. package/esm/ai/src/planner/planner-run.mjs.map +1 -0
  260. package/esm/ai/src/planner/planner.mjs +144 -0
  261. package/esm/ai/src/planner/planner.mjs.map +1 -0
  262. package/esm/ai/src/planner/signature.mjs +27 -0
  263. package/esm/ai/src/planner/signature.mjs.map +1 -0
  264. package/esm/ai/src/planner/snapshot.mjs +95 -0
  265. package/esm/ai/src/planner/snapshot.mjs.map +1 -0
  266. package/esm/ai/src/prompt/errors.mjs +73 -0
  267. package/esm/ai/src/prompt/errors.mjs.map +1 -0
  268. package/esm/ai/src/prompt/index.mjs +4 -0
  269. package/esm/ai/src/prompt/prompt-langfuse-sync.mjs +104 -0
  270. package/esm/ai/src/prompt/prompt-langfuse-sync.mjs.map +1 -0
  271. package/esm/ai/src/prompt/prompt-validate.mjs +170 -0
  272. package/esm/ai/src/prompt/prompt-validate.mjs.map +1 -0
  273. package/esm/ai/src/prompt/prompt.mjs +218 -0
  274. package/esm/ai/src/prompt/prompt.mjs.map +1 -0
  275. package/esm/ai/src/prompts/index.mjs +3 -0
  276. package/esm/ai/src/prompts/prompts-manager.mjs +410 -0
  277. package/esm/ai/src/prompts/prompts-manager.mjs.map +1 -0
  278. package/esm/ai/src/prompts/prompts-validate.mjs +200 -0
  279. package/esm/ai/src/prompts/prompts-validate.mjs.map +1 -0
  280. package/esm/ai/src/rag/as-tool.mjs +48 -0
  281. package/esm/ai/src/rag/as-tool.mjs.map +1 -0
  282. package/esm/ai/src/rag/chunk/chunk.mjs +44 -0
  283. package/esm/ai/src/rag/chunk/chunk.mjs.map +1 -0
  284. package/esm/ai/src/rag/chunk/fixed.mjs +32 -0
  285. package/esm/ai/src/rag/chunk/fixed.mjs.map +1 -0
  286. package/esm/ai/src/rag/chunk/markdown.mjs +75 -0
  287. package/esm/ai/src/rag/chunk/markdown.mjs.map +1 -0
  288. package/esm/ai/src/rag/chunk/recursive.mjs +132 -0
  289. package/esm/ai/src/rag/chunk/recursive.mjs.map +1 -0
  290. package/esm/ai/src/rag/chunk/sentence.mjs +73 -0
  291. package/esm/ai/src/rag/chunk/sentence.mjs.map +1 -0
  292. package/esm/ai/src/rag/hybrid/bm25.mjs +51 -0
  293. package/esm/ai/src/rag/hybrid/bm25.mjs.map +1 -0
  294. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs +29 -0
  295. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs.map +1 -0
  296. package/esm/ai/src/rag/hybrid/rrf.mjs +30 -0
  297. package/esm/ai/src/rag/hybrid/rrf.mjs.map +1 -0
  298. package/esm/ai/src/rag/index.mjs +18 -0
  299. package/esm/ai/src/rag/loaders/errors.mjs +25 -0
  300. package/esm/ai/src/rag/loaders/errors.mjs.map +1 -0
  301. package/esm/ai/src/rag/loaders/index.mjs +7 -0
  302. package/esm/ai/src/rag/loaders/load-html.mjs +138 -0
  303. package/esm/ai/src/rag/loaders/load-html.mjs.map +1 -0
  304. package/esm/ai/src/rag/loaders/load-pdf.mjs +150 -0
  305. package/esm/ai/src/rag/loaders/load-pdf.mjs.map +1 -0
  306. package/esm/ai/src/rag/loaders/load-text.mjs +60 -0
  307. package/esm/ai/src/rag/loaders/load-text.mjs.map +1 -0
  308. package/esm/ai/src/rag/loaders/load-web.mjs +89 -0
  309. package/esm/ai/src/rag/loaders/load-web.mjs.map +1 -0
  310. package/esm/ai/src/rag/rag.mjs +126 -0
  311. package/esm/ai/src/rag/rag.mjs.map +1 -0
  312. package/esm/ai/src/rag/rerank/keyword-reranker.mjs +58 -0
  313. package/esm/ai/src/rag/rerank/keyword-reranker.mjs.map +1 -0
  314. package/esm/ai/src/rag/rerank/llm-reranker.mjs +85 -0
  315. package/esm/ai/src/rag/rerank/llm-reranker.mjs.map +1 -0
  316. package/esm/ai/src/rag/retrieve.mjs +68 -0
  317. package/esm/ai/src/rag/retrieve.mjs.map +1 -0
  318. package/esm/ai/src/rag/store/cache-vector-store.mjs +48 -0
  319. package/esm/ai/src/rag/store/cache-vector-store.mjs.map +1 -0
  320. package/esm/ai/src/rag/store/pg-vector-store.mjs +328 -0
  321. package/esm/ai/src/rag/store/pg-vector-store.mjs.map +1 -0
  322. package/esm/ai/src/rag/transforms/multi-query.mjs +41 -0
  323. package/esm/ai/src/rag/transforms/multi-query.mjs.map +1 -0
  324. package/esm/ai/src/security/index.mjs +5 -0
  325. package/esm/ai/src/security/outbound-policy.mjs +187 -0
  326. package/esm/ai/src/security/outbound-policy.mjs.map +1 -0
  327. package/esm/ai/src/security/private-ip.mjs +48 -0
  328. package/esm/ai/src/security/private-ip.mjs.map +1 -0
  329. package/esm/ai/src/security/redact.mjs +60 -0
  330. package/esm/ai/src/security/redact.mjs.map +1 -0
  331. package/esm/ai/src/serve/serve.mjs +90 -0
  332. package/esm/ai/src/serve/serve.mjs.map +1 -0
  333. package/esm/ai/src/serve/sse.mjs +25 -0
  334. package/esm/ai/src/serve/sse.mjs.map +1 -0
  335. package/esm/ai/src/serve/stream-to-sse.mjs +37 -0
  336. package/esm/ai/src/serve/stream-to-sse.mjs.map +1 -0
  337. package/esm/ai/src/skills/catalog.mjs +140 -0
  338. package/esm/ai/src/skills/catalog.mjs.map +1 -0
  339. package/esm/ai/src/skills/index.mjs +11 -0
  340. package/esm/ai/src/skills/load-skill-tool.mjs +65 -0
  341. package/esm/ai/src/skills/load-skill-tool.mjs.map +1 -0
  342. package/esm/ai/src/skills/save-skill-tool.mjs +65 -0
  343. package/esm/ai/src/skills/save-skill-tool.mjs.map +1 -0
  344. package/esm/ai/src/skills/skills.mjs +109 -0
  345. package/esm/ai/src/skills/skills.mjs.map +1 -0
  346. package/esm/ai/src/skills/sources/directory-source.mjs +108 -0
  347. package/esm/ai/src/skills/sources/directory-source.mjs.map +1 -0
  348. package/esm/ai/src/skills/sources/index.mjs +27 -0
  349. package/esm/ai/src/skills/sources/index.mjs.map +1 -0
  350. package/esm/ai/src/skills/sources/parse-frontmatter.mjs +46 -0
  351. package/esm/ai/src/skills/sources/parse-frontmatter.mjs.map +1 -0
  352. package/esm/ai/src/skills/sources/store-source.mjs +15 -0
  353. package/esm/ai/src/skills/sources/store-source.mjs.map +1 -0
  354. package/esm/ai/src/skills/sources/url-source.mjs +117 -0
  355. package/esm/ai/src/skills/sources/url-source.mjs.map +1 -0
  356. package/esm/ai/src/snapshot/memory.mjs +81 -0
  357. package/esm/ai/src/snapshot/memory.mjs.map +1 -0
  358. package/esm/ai/src/snapshot/pg.mjs +146 -0
  359. package/esm/ai/src/snapshot/pg.mjs.map +1 -0
  360. package/esm/ai/src/snapshot/redis.mjs +101 -0
  361. package/esm/ai/src/snapshot/redis.mjs.map +1 -0
  362. package/esm/ai/src/speech/index.mjs +3 -0
  363. package/esm/ai/src/speech/speech.mjs +122 -0
  364. package/esm/ai/src/speech/speech.mjs.map +1 -0
  365. package/esm/ai/src/supervisor/as-tool.mjs +74 -0
  366. package/esm/ai/src/supervisor/as-tool.mjs.map +1 -0
  367. package/esm/ai/src/supervisor/cancellation.mjs +22 -0
  368. package/esm/ai/src/supervisor/cancellation.mjs.map +1 -0
  369. package/esm/ai/src/supervisor/decide.mjs +272 -0
  370. package/esm/ai/src/supervisor/decide.mjs.map +1 -0
  371. package/esm/ai/src/supervisor/emitter.mjs +47 -0
  372. package/esm/ai/src/supervisor/emitter.mjs.map +1 -0
  373. package/esm/ai/src/supervisor/entries.mjs +206 -0
  374. package/esm/ai/src/supervisor/entries.mjs.map +1 -0
  375. package/esm/ai/src/supervisor/execution.mjs +1921 -0
  376. package/esm/ai/src/supervisor/execution.mjs.map +1 -0
  377. package/esm/ai/src/supervisor/fan-out.mjs +65 -0
  378. package/esm/ai/src/supervisor/fan-out.mjs.map +1 -0
  379. package/esm/ai/src/supervisor/index.mjs +14 -0
  380. package/esm/ai/src/supervisor/router-factory.mjs +141 -0
  381. package/esm/ai/src/supervisor/router-factory.mjs.map +1 -0
  382. package/esm/ai/src/supervisor/router-prompt.mjs +52 -0
  383. package/esm/ai/src/supervisor/router-prompt.mjs.map +1 -0
  384. package/esm/ai/src/supervisor/signature.mjs +89 -0
  385. package/esm/ai/src/supervisor/signature.mjs.map +1 -0
  386. package/esm/ai/src/supervisor/snapshot.mjs +69 -0
  387. package/esm/ai/src/supervisor/snapshot.mjs.map +1 -0
  388. package/esm/ai/src/supervisor/supervisor-stream.mjs +89 -0
  389. package/esm/ai/src/supervisor/supervisor-stream.mjs.map +1 -0
  390. package/esm/ai/src/supervisor/supervisor.mjs +144 -0
  391. package/esm/ai/src/supervisor/supervisor.mjs.map +1 -0
  392. package/esm/ai/src/system-prompt/index.mjs +6 -0
  393. package/esm/ai/src/system-prompt/instruction.mjs +57 -0
  394. package/esm/ai/src/system-prompt/instruction.mjs.map +1 -0
  395. package/esm/ai/src/system-prompt/persona.mjs +57 -0
  396. package/esm/ai/src/system-prompt/persona.mjs.map +1 -0
  397. package/esm/ai/src/system-prompt/render-placeholders.mjs +58 -0
  398. package/esm/ai/src/system-prompt/render-placeholders.mjs.map +1 -0
  399. package/esm/ai/src/system-prompt/system-prompt.mjs +267 -0
  400. package/esm/ai/src/system-prompt/system-prompt.mjs.map +1 -0
  401. package/esm/ai/src/team/gates.mjs +48 -0
  402. package/esm/ai/src/team/gates.mjs.map +1 -0
  403. package/esm/ai/src/team/index.mjs +3 -0
  404. package/esm/ai/src/team/team.mjs +94 -0
  405. package/esm/ai/src/team/team.mjs.map +1 -0
  406. package/esm/ai/src/tool/executable-as-tool.mjs +81 -0
  407. package/esm/ai/src/tool/executable-as-tool.mjs.map +1 -0
  408. package/esm/ai/src/tool/index.mjs +4 -0
  409. package/esm/ai/src/tool/tool.mjs +185 -0
  410. package/esm/ai/src/tool/tool.mjs.map +1 -0
  411. package/esm/ai/src/transcribe/audio-input.mjs +84 -0
  412. package/esm/ai/src/transcribe/audio-input.mjs.map +1 -0
  413. package/esm/ai/src/transcribe/index.mjs +4 -0
  414. package/esm/ai/src/transcribe/transcribe.mjs +127 -0
  415. package/esm/ai/src/transcribe/transcribe.mjs.map +1 -0
  416. package/esm/ai/src/utils/compute-cost.mjs +112 -0
  417. package/esm/ai/src/utils/compute-cost.mjs.map +1 -0
  418. package/esm/ai/src/utils/extract-json-lenient.mjs +97 -0
  419. package/esm/ai/src/utils/extract-json-lenient.mjs.map +1 -0
  420. package/esm/ai/src/utils/extract-json-payload.mjs +39 -0
  421. package/esm/ai/src/utils/extract-json-payload.mjs.map +1 -0
  422. package/esm/ai/src/utils/generate-run-id.mjs +23 -0
  423. package/esm/ai/src/utils/generate-run-id.mjs.map +1 -0
  424. package/esm/ai/src/utils/index.mjs +12 -0
  425. package/esm/ai/src/utils/json-schema.mjs +89 -0
  426. package/esm/ai/src/utils/json-schema.mjs.map +1 -0
  427. package/esm/ai/src/utils/prepare-attachment-part.mjs +232 -0
  428. package/esm/ai/src/utils/prepare-attachment-part.mjs.map +1 -0
  429. package/esm/ai/src/utils/resolve-attachment.mjs +74 -0
  430. package/esm/ai/src/utils/resolve-attachment.mjs.map +1 -0
  431. package/esm/ai/src/utils/run-context.mjs +89 -0
  432. package/esm/ai/src/utils/run-context.mjs.map +1 -0
  433. package/esm/ai/src/utils/safe-json-parse.mjs +22 -0
  434. package/esm/ai/src/utils/safe-json-parse.mjs.map +1 -0
  435. package/esm/ai/src/utils/stamp-report-lineage.mjs +45 -0
  436. package/esm/ai/src/utils/stamp-report-lineage.mjs.map +1 -0
  437. package/esm/ai/src/vcr/cassette-io.mjs +57 -0
  438. package/esm/ai/src/vcr/cassette-io.mjs.map +1 -0
  439. package/esm/ai/src/vcr/errors.mjs +37 -0
  440. package/esm/ai/src/vcr/errors.mjs.map +1 -0
  441. package/esm/ai/src/vcr/hash-request.mjs +118 -0
  442. package/esm/ai/src/vcr/hash-request.mjs.map +1 -0
  443. package/esm/ai/src/vcr/index.mjs +5 -0
  444. package/esm/ai/src/vcr/vcr.mjs +248 -0
  445. package/esm/ai/src/vcr/vcr.mjs.map +1 -0
  446. package/esm/ai/src/workflow/as-tool.mjs +49 -0
  447. package/esm/ai/src/workflow/as-tool.mjs.map +1 -0
  448. package/esm/ai/src/workflow/cancellation.mjs +44 -0
  449. package/esm/ai/src/workflow/cancellation.mjs.map +1 -0
  450. package/esm/ai/src/workflow/emitter.mjs +40 -0
  451. package/esm/ai/src/workflow/emitter.mjs.map +1 -0
  452. package/esm/ai/src/workflow/engine.mjs +363 -0
  453. package/esm/ai/src/workflow/engine.mjs.map +1 -0
  454. package/esm/ai/src/workflow/index.mjs +5 -0
  455. package/esm/ai/src/workflow/retry.mjs +32 -0
  456. package/esm/ai/src/workflow/retry.mjs.map +1 -0
  457. package/esm/ai/src/workflow/router.mjs +56 -0
  458. package/esm/ai/src/workflow/router.mjs.map +1 -0
  459. package/esm/ai/src/workflow/run-scoped-emitter.mjs +32 -0
  460. package/esm/ai/src/workflow/run-scoped-emitter.mjs.map +1 -0
  461. package/esm/ai/src/workflow/signature.mjs +34 -0
  462. package/esm/ai/src/workflow/signature.mjs.map +1 -0
  463. package/esm/ai/src/workflow/snapshot.mjs +77 -0
  464. package/esm/ai/src/workflow/snapshot.mjs.map +1 -0
  465. package/esm/ai/src/workflow/state.mjs +37 -0
  466. package/esm/ai/src/workflow/state.mjs.map +1 -0
  467. package/esm/ai/src/workflow/step-runner.mjs +370 -0
  468. package/esm/ai/src/workflow/step-runner.mjs.map +1 -0
  469. package/esm/ai/src/workflow/step.mjs +37 -0
  470. package/esm/ai/src/workflow/step.mjs.map +1 -0
  471. package/esm/ai/src/workflow/workflow.mjs +122 -0
  472. package/esm/ai/src/workflow/workflow.mjs.map +1 -0
  473. package/esm/ai-openai/src/embedder.mjs +4 -0
  474. package/esm/ai-openai/src/image.mjs +5 -0
  475. package/esm/ai-openai/src/index.mjs +7 -0
  476. package/esm/ai-openai/src/model.mjs +5 -0
  477. package/esm/ai-openai/src/sdk.mjs +9 -0
  478. package/esm/ai-openai/src/speech.mjs +5 -0
  479. package/esm/ai-openai/src/transcription.mjs +6 -0
  480. package/esm/ai-openai/src/utils/index.mjs +5 -0
  481. package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -0
  482. package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
  483. package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
  484. package/esm/cli/commands/dev-server.command.mjs +1 -1
  485. package/esm/cli/commands/dev-server.command.mjs.map +1 -1
  486. package/esm/cli/commands/doctor/checks/config.check.mjs +42 -0
  487. package/esm/cli/commands/doctor/checks/config.check.mjs.map +1 -0
  488. package/esm/cli/commands/doctor/checks/connectors.check.mjs +28 -0
  489. package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -0
  490. package/esm/cli/commands/doctor/checks/health.check.mjs +35 -0
  491. package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -0
  492. package/esm/cli/commands/doctor/checks/index.mjs +25 -0
  493. package/esm/cli/commands/doctor/checks/index.mjs.map +1 -0
  494. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs +90 -0
  495. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -0
  496. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs +69 -0
  497. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs.map +1 -0
  498. package/esm/cli/commands/doctor/checks/routes.check.mjs +30 -0
  499. package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -0
  500. package/esm/cli/commands/doctor/doctor-command.action.mjs +28 -0
  501. package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -0
  502. package/esm/cli/commands/doctor/format-report.mjs +44 -0
  503. package/esm/cli/commands/doctor/format-report.mjs.map +1 -0
  504. package/esm/cli/commands/doctor/run-checks.mjs +50 -0
  505. package/esm/cli/commands/doctor/run-checks.mjs.map +1 -0
  506. package/esm/cli/commands/doctor.command.mjs +29 -0
  507. package/esm/cli/commands/doctor.command.mjs.map +1 -0
  508. package/esm/cli/commands/generate/templates/stubs.mjs +9 -12
  509. package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
  510. package/esm/cli/commands/routes/format-routes-table.mjs +129 -0
  511. package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -0
  512. package/esm/cli/commands/routes/route-row.mjs +92 -0
  513. package/esm/cli/commands/routes/route-row.mjs.map +1 -0
  514. package/esm/cli/commands/routes/routes-command.action.mjs +43 -0
  515. package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -0
  516. package/esm/cli/commands/routes.command.mjs +51 -0
  517. package/esm/cli/commands/routes.command.mjs.map +1 -0
  518. package/esm/cli/commands/seed.command.mjs +5 -0
  519. package/esm/cli/commands/seed.command.mjs.map +1 -1
  520. package/esm/cli/framework-cli-commands.mjs +4 -0
  521. package/esm/cli/framework-cli-commands.mjs.map +1 -1
  522. package/esm/config/config-getter.mjs +5 -5
  523. package/esm/config/config-getter.mjs.map +1 -1
  524. package/esm/config/config-loader.mjs +2 -2
  525. package/esm/config/config-loader.mjs.map +1 -1
  526. package/esm/connectors/access-connector.mjs +2 -2
  527. package/esm/connectors/access-connector.mjs.map +1 -1
  528. package/esm/connectors/ai-connector.d.mts +43 -0
  529. package/esm/connectors/ai-connector.d.mts.map +1 -0
  530. package/esm/connectors/ai-connector.mjs +56 -0
  531. package/esm/connectors/ai-connector.mjs.map +1 -0
  532. package/esm/connectors/cache-connector.d.mts +5 -0
  533. package/esm/connectors/cache-connector.d.mts.map +1 -1
  534. package/esm/connectors/cache-connector.mjs +9 -2
  535. package/esm/connectors/cache-connector.mjs.map +1 -1
  536. package/esm/connectors/connectors-manager.d.mts +6 -2
  537. package/esm/connectors/connectors-manager.d.mts.map +1 -1
  538. package/esm/connectors/connectors-manager.mjs +8 -2
  539. package/esm/connectors/connectors-manager.mjs.map +1 -1
  540. package/esm/connectors/database-connector.mjs +2 -2
  541. package/esm/connectors/database-connector.mjs.map +1 -1
  542. package/esm/connectors/herald-connector.mjs +2 -2
  543. package/esm/connectors/herald-connector.mjs.map +1 -1
  544. package/esm/connectors/http-connector.d.mts.map +1 -1
  545. package/esm/connectors/http-connector.mjs +9 -7
  546. package/esm/connectors/http-connector.mjs.map +1 -1
  547. package/esm/connectors/index.d.mts +1 -0
  548. package/esm/connectors/index.mjs +1 -0
  549. package/esm/connectors/logger-connector.mjs +2 -2
  550. package/esm/connectors/logger-connector.mjs.map +1 -1
  551. package/esm/connectors/mail-connector.mjs +2 -2
  552. package/esm/connectors/mail-connector.mjs.map +1 -1
  553. package/esm/connectors/notifications-connector.mjs +2 -2
  554. package/esm/connectors/notifications-connector.mjs.map +1 -1
  555. package/esm/connectors/socket-connector.d.mts +16 -1
  556. package/esm/connectors/socket-connector.d.mts.map +1 -1
  557. package/esm/connectors/socket-connector.mjs +31 -8
  558. package/esm/connectors/socket-connector.mjs.map +1 -1
  559. package/esm/connectors/storage.connector.d.mts +7 -0
  560. package/esm/connectors/storage.connector.d.mts.map +1 -1
  561. package/esm/connectors/storage.connector.mjs +7 -0
  562. package/esm/connectors/storage.connector.mjs.map +1 -1
  563. package/esm/connectors/types.d.mts +3 -2
  564. package/esm/connectors/types.d.mts.map +1 -1
  565. package/esm/connectors/types.mjs +1 -0
  566. package/esm/connectors/types.mjs.map +1 -1
  567. package/esm/database/index.d.mts +2 -1
  568. package/esm/database/index.mjs +1 -0
  569. package/esm/database/seed-command-action.mjs +44 -4
  570. package/esm/database/seed-command-action.mjs.map +1 -1
  571. package/esm/database/seeds/seed-records-table-migration.mjs +36 -0
  572. package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -0
  573. package/esm/database/seeds/seeder.d.mts +22 -5
  574. package/esm/database/seeds/seeder.d.mts.map +1 -1
  575. package/esm/database/seeds/seeder.errors.d.mts +22 -0
  576. package/esm/database/seeds/seeder.errors.d.mts.map +1 -0
  577. package/esm/database/seeds/seeder.errors.mjs +29 -0
  578. package/esm/database/seeds/seeder.errors.mjs.map +1 -0
  579. package/esm/database/seeds/seeder.mjs.map +1 -1
  580. package/esm/database/seeds/seeders.manager.mjs +90 -11
  581. package/esm/database/seeds/seeders.manager.mjs.map +1 -1
  582. package/esm/database/seeds/types.d.mts +117 -1
  583. package/esm/database/seeds/types.d.mts.map +1 -1
  584. package/esm/database/seeds/utils.mjs +6 -1
  585. package/esm/database/seeds/utils.mjs.map +1 -1
  586. package/esm/dev-server/development-server.mjs +2 -14
  587. package/esm/dev-server/development-server.mjs.map +1 -1
  588. package/esm/dev-server/file-event-handler.mjs +15 -3
  589. package/esm/dev-server/file-event-handler.mjs.map +1 -1
  590. package/esm/dev-server/module-loader.d.mts +12 -0
  591. package/esm/dev-server/module-loader.d.mts.map +1 -1
  592. package/esm/dev-server/module-loader.mjs +30 -2
  593. package/esm/dev-server/module-loader.mjs.map +1 -1
  594. package/esm/generations/add-command.action.mjs +61 -12
  595. package/esm/generations/add-command.action.mjs.map +1 -1
  596. package/esm/generations/stubs.mjs +31 -1
  597. package/esm/generations/stubs.mjs.map +1 -1
  598. package/esm/http/config.mjs +2 -2
  599. package/esm/http/config.mjs.map +1 -1
  600. package/esm/http/createHttpApplication.mjs +2 -2
  601. package/esm/http/createHttpApplication.mjs.map +1 -1
  602. package/esm/http/health.d.mts +14 -0
  603. package/esm/http/health.d.mts.map +1 -1
  604. package/esm/http/health.mjs +16 -0
  605. package/esm/http/health.mjs.map +1 -1
  606. package/esm/http/middleware/cache-response-middleware.d.mts +1 -1
  607. package/esm/http/middleware/cache-response-middleware.d.mts.map +1 -1
  608. package/esm/http/middleware/cache-response-middleware.mjs +15 -6
  609. package/esm/http/middleware/cache-response-middleware.mjs.map +1 -1
  610. package/esm/http/middleware/concurrency-limit.middleware.mjs +2 -0
  611. package/esm/http/middleware/concurrency-limit.middleware.mjs.map +1 -1
  612. package/esm/http/middleware/idempotency.middleware.d.mts.map +1 -1
  613. package/esm/http/middleware/idempotency.middleware.mjs +9 -6
  614. package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
  615. package/esm/http/middleware/inject-request-context.mjs +2 -2
  616. package/esm/http/middleware/inject-request-context.mjs.map +1 -1
  617. package/esm/http/middleware/maintenance.middleware.mjs +6 -5
  618. package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
  619. package/esm/http/plugins.mjs +9 -9
  620. package/esm/http/plugins.mjs.map +1 -1
  621. package/esm/http/request.d.mts +9 -2
  622. package/esm/http/request.d.mts.map +1 -1
  623. package/esm/http/request.mjs +15 -3
  624. package/esm/http/request.mjs.map +1 -1
  625. package/esm/http/response.d.mts +12 -0
  626. package/esm/http/response.d.mts.map +1 -1
  627. package/esm/http/response.mjs +24 -7
  628. package/esm/http/response.mjs.map +1 -1
  629. package/esm/http/server.d.mts.map +1 -1
  630. package/esm/http/server.mjs +4 -4
  631. package/esm/http/server.mjs.map +1 -1
  632. package/esm/index.d.mts +9 -4
  633. package/esm/index.mjs +6 -1
  634. package/esm/node_modules/langfuse/lib/index.mjs +1827 -0
  635. package/esm/node_modules/langfuse/lib/index.mjs.map +1 -0
  636. package/esm/node_modules/langfuse-core/lib/index.mjs +1770 -0
  637. package/esm/node_modules/langfuse-core/lib/index.mjs.map +1 -0
  638. package/esm/node_modules/mustache/mustache.mjs +587 -0
  639. package/esm/node_modules/mustache/mustache.mjs.map +1 -0
  640. package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs +180 -0
  641. package/esm/node_modules/openai/_vendor/partial-json-parser/parser.mjs.map +1 -0
  642. package/esm/node_modules/openai/auth/workload-identity-auth.mjs +80 -0
  643. package/esm/node_modules/openai/auth/workload-identity-auth.mjs.map +1 -0
  644. package/esm/node_modules/openai/azure.mjs +82 -0
  645. package/esm/node_modules/openai/azure.mjs.map +1 -0
  646. package/esm/node_modules/openai/client.mjs +638 -0
  647. package/esm/node_modules/openai/client.mjs.map +1 -0
  648. package/esm/node_modules/openai/core/api-promise.mjs +75 -0
  649. package/esm/node_modules/openai/core/api-promise.mjs.map +1 -0
  650. package/esm/node_modules/openai/core/error.mjs +110 -0
  651. package/esm/node_modules/openai/core/error.mjs.map +1 -0
  652. package/esm/node_modules/openai/core/pagination.mjs +160 -0
  653. package/esm/node_modules/openai/core/pagination.mjs.map +1 -0
  654. package/esm/node_modules/openai/core/resource.mjs +10 -0
  655. package/esm/node_modules/openai/core/resource.mjs.map +1 -0
  656. package/esm/node_modules/openai/core/streaming.mjs +238 -0
  657. package/esm/node_modules/openai/core/streaming.mjs.map +1 -0
  658. package/esm/node_modules/openai/index.mjs +8 -0
  659. package/esm/node_modules/openai/internal/decoders/line.mjs +91 -0
  660. package/esm/node_modules/openai/internal/decoders/line.mjs.map +1 -0
  661. package/esm/node_modules/openai/internal/detect-platform.mjs +123 -0
  662. package/esm/node_modules/openai/internal/detect-platform.mjs.map +1 -0
  663. package/esm/node_modules/openai/internal/errors.mjs +26 -0
  664. package/esm/node_modules/openai/internal/errors.mjs.map +1 -0
  665. package/esm/node_modules/openai/internal/headers.mjs +65 -0
  666. package/esm/node_modules/openai/internal/headers.mjs.map +1 -0
  667. package/esm/node_modules/openai/internal/parse.mjs +41 -0
  668. package/esm/node_modules/openai/internal/parse.mjs.map +1 -0
  669. package/esm/node_modules/openai/internal/qs/formats.mjs +12 -0
  670. package/esm/node_modules/openai/internal/qs/formats.mjs.map +1 -0
  671. package/esm/node_modules/openai/internal/qs/stringify.mjs +179 -0
  672. package/esm/node_modules/openai/internal/qs/stringify.mjs.map +1 -0
  673. package/esm/node_modules/openai/internal/qs/utils.mjs +65 -0
  674. package/esm/node_modules/openai/internal/qs/utils.mjs.map +1 -0
  675. package/esm/node_modules/openai/internal/request-options.mjs +11 -0
  676. package/esm/node_modules/openai/internal/request-options.mjs.map +1 -0
  677. package/esm/node_modules/openai/internal/shims.mjs +77 -0
  678. package/esm/node_modules/openai/internal/shims.mjs.map +1 -0
  679. package/esm/node_modules/openai/internal/to-file.mjs +63 -0
  680. package/esm/node_modules/openai/internal/to-file.mjs.map +1 -0
  681. package/esm/node_modules/openai/internal/tslib.mjs +16 -0
  682. package/esm/node_modules/openai/internal/tslib.mjs.map +1 -0
  683. package/esm/node_modules/openai/internal/uploads.mjs +94 -0
  684. package/esm/node_modules/openai/internal/uploads.mjs.map +1 -0
  685. package/esm/node_modules/openai/internal/utils/base64.mjs +22 -0
  686. package/esm/node_modules/openai/internal/utils/base64.mjs.map +1 -0
  687. package/esm/node_modules/openai/internal/utils/bytes.mjs +26 -0
  688. package/esm/node_modules/openai/internal/utils/bytes.mjs.map +1 -0
  689. package/esm/node_modules/openai/internal/utils/env.mjs +16 -0
  690. package/esm/node_modules/openai/internal/utils/env.mjs.map +1 -0
  691. package/esm/node_modules/openai/internal/utils/log.mjs +58 -0
  692. package/esm/node_modules/openai/internal/utils/log.mjs.map +1 -0
  693. package/esm/node_modules/openai/internal/utils/path.mjs +62 -0
  694. package/esm/node_modules/openai/internal/utils/path.mjs.map +1 -0
  695. package/esm/node_modules/openai/internal/utils/query.mjs +10 -0
  696. package/esm/node_modules/openai/internal/utils/query.mjs.map +1 -0
  697. package/esm/node_modules/openai/internal/utils/sleep.mjs +6 -0
  698. package/esm/node_modules/openai/internal/utils/sleep.mjs.map +1 -0
  699. package/esm/node_modules/openai/internal/utils/uuid.mjs +18 -0
  700. package/esm/node_modules/openai/internal/utils/uuid.mjs.map +1 -0
  701. package/esm/node_modules/openai/internal/utils/values.mjs +41 -0
  702. package/esm/node_modules/openai/internal/utils/values.mjs.map +1 -0
  703. package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs +247 -0
  704. package/esm/node_modules/openai/lib/AbstractChatCompletionRunner.mjs.map +1 -0
  705. package/esm/node_modules/openai/lib/AssistantStream.mjs +472 -0
  706. package/esm/node_modules/openai/lib/AssistantStream.mjs.map +1 -0
  707. package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs +26 -0
  708. package/esm/node_modules/openai/lib/ChatCompletionRunner.mjs.map +1 -0
  709. package/esm/node_modules/openai/lib/ChatCompletionStream.mjs +423 -0
  710. package/esm/node_modules/openai/lib/ChatCompletionStream.mjs.map +1 -0
  711. package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs +26 -0
  712. package/esm/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs.map +1 -0
  713. package/esm/node_modules/openai/lib/EventStream.mjs +163 -0
  714. package/esm/node_modules/openai/lib/EventStream.mjs.map +1 -0
  715. package/esm/node_modules/openai/lib/ResponsesParser.mjs +94 -0
  716. package/esm/node_modules/openai/lib/ResponsesParser.mjs.map +1 -0
  717. package/esm/node_modules/openai/lib/RunnableFunction.mjs +8 -0
  718. package/esm/node_modules/openai/lib/RunnableFunction.mjs.map +1 -0
  719. package/esm/node_modules/openai/lib/Util.mjs +19 -0
  720. package/esm/node_modules/openai/lib/Util.mjs.map +1 -0
  721. package/esm/node_modules/openai/lib/chatCompletionUtils.mjs +11 -0
  722. package/esm/node_modules/openai/lib/chatCompletionUtils.mjs.map +1 -0
  723. package/esm/node_modules/openai/lib/parser.mjs +88 -0
  724. package/esm/node_modules/openai/lib/parser.mjs.map +1 -0
  725. package/esm/node_modules/openai/lib/responses/ResponseStream.mjs +231 -0
  726. package/esm/node_modules/openai/lib/responses/ResponseStream.mjs.map +1 -0
  727. package/esm/node_modules/openai/resources/admin/admin.mjs +15 -0
  728. package/esm/node_modules/openai/resources/admin/admin.mjs.map +1 -0
  729. package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs +81 -0
  730. package/esm/node_modules/openai/resources/admin/organization/admin-api-keys.mjs.map +1 -0
  731. package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs +31 -0
  732. package/esm/node_modules/openai/resources/admin/organization/audit-logs.mjs.map +1 -0
  733. package/esm/node_modules/openai/resources/admin/organization/certificates.mjs +153 -0
  734. package/esm/node_modules/openai/resources/admin/organization/certificates.mjs.map +1 -0
  735. package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs +42 -0
  736. package/esm/node_modules/openai/resources/admin/organization/data-retention.mjs.map +1 -0
  737. package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs +106 -0
  738. package/esm/node_modules/openai/resources/admin/organization/groups/groups.mjs.map +1 -0
  739. package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs +88 -0
  740. package/esm/node_modules/openai/resources/admin/organization/groups/roles.mjs.map +1 -0
  741. package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs +88 -0
  742. package/esm/node_modules/openai/resources/admin/organization/groups/users.mjs.map +1 -0
  743. package/esm/node_modules/openai/resources/admin/organization/invites.mjs +83 -0
  744. package/esm/node_modules/openai/resources/admin/organization/invites.mjs.map +1 -0
  745. package/esm/node_modules/openai/resources/admin/organization/organization.mjs +45 -0
  746. package/esm/node_modules/openai/resources/admin/organization/organization.mjs.map +1 -0
  747. package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs +72 -0
  748. package/esm/node_modules/openai/resources/admin/organization/projects/api-keys.mjs.map +1 -0
  749. package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs +78 -0
  750. package/esm/node_modules/openai/resources/admin/organization/projects/certificates.mjs.map +1 -0
  751. package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs +46 -0
  752. package/esm/node_modules/openai/resources/admin/organization/projects/data-retention.mjs.map +1 -0
  753. package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs +95 -0
  754. package/esm/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs.map +1 -0
  755. package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs +91 -0
  756. package/esm/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs.map +1 -0
  757. package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs +45 -0
  758. package/esm/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs.map +1 -0
  759. package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs +63 -0
  760. package/esm/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs.map +1 -0
  761. package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs +137 -0
  762. package/esm/node_modules/openai/resources/admin/organization/projects/projects.mjs.map +1 -0
  763. package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs +51 -0
  764. package/esm/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs.map +1 -0
  765. package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs +108 -0
  766. package/esm/node_modules/openai/resources/admin/organization/projects/roles.mjs.map +1 -0
  767. package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs +112 -0
  768. package/esm/node_modules/openai/resources/admin/organization/projects/service-accounts.mjs.map +1 -0
  769. package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs +106 -0
  770. package/esm/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs.map +1 -0
  771. package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs +91 -0
  772. package/esm/node_modules/openai/resources/admin/organization/projects/users/roles.mjs.map +1 -0
  773. package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs +118 -0
  774. package/esm/node_modules/openai/resources/admin/organization/projects/users/users.mjs.map +1 -0
  775. package/esm/node_modules/openai/resources/admin/organization/roles.mjs +96 -0
  776. package/esm/node_modules/openai/resources/admin/organization/roles.mjs.map +1 -0
  777. package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs +97 -0
  778. package/esm/node_modules/openai/resources/admin/organization/spend-alerts.mjs.map +1 -0
  779. package/esm/node_modules/openai/resources/admin/organization/usage.mjs +207 -0
  780. package/esm/node_modules/openai/resources/admin/organization/usage.mjs.map +1 -0
  781. package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs +88 -0
  782. package/esm/node_modules/openai/resources/admin/organization/users/roles.mjs.map +1 -0
  783. package/esm/node_modules/openai/resources/admin/organization/users/users.mjs +82 -0
  784. package/esm/node_modules/openai/resources/admin/organization/users/users.mjs.map +1 -0
  785. package/esm/node_modules/openai/resources/audio/audio.mjs +21 -0
  786. package/esm/node_modules/openai/resources/audio/audio.mjs.map +1 -0
  787. package/esm/node_modules/openai/resources/audio/speech.mjs +39 -0
  788. package/esm/node_modules/openai/resources/audio/speech.mjs.map +1 -0
  789. package/esm/node_modules/openai/resources/audio/transcriptions.mjs +22 -0
  790. package/esm/node_modules/openai/resources/audio/transcriptions.mjs.map +1 -0
  791. package/esm/node_modules/openai/resources/audio/translations.mjs +21 -0
  792. package/esm/node_modules/openai/resources/audio/translations.mjs.map +1 -0
  793. package/esm/node_modules/openai/resources/batches.mjs +54 -0
  794. package/esm/node_modules/openai/resources/batches.mjs.map +1 -0
  795. package/esm/node_modules/openai/resources/beta/assistants.mjs +78 -0
  796. package/esm/node_modules/openai/resources/beta/assistants.mjs.map +1 -0
  797. package/esm/node_modules/openai/resources/beta/beta.mjs +24 -0
  798. package/esm/node_modules/openai/resources/beta/beta.mjs.map +1 -0
  799. package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs +18 -0
  800. package/esm/node_modules/openai/resources/beta/chatkit/chatkit.mjs.map +1 -0
  801. package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs +49 -0
  802. package/esm/node_modules/openai/resources/beta/chatkit/sessions.mjs.map +1 -0
  803. package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs +85 -0
  804. package/esm/node_modules/openai/resources/beta/chatkit/threads.mjs.map +1 -0
  805. package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs +21 -0
  806. package/esm/node_modules/openai/resources/beta/realtime/realtime.mjs.map +1 -0
  807. package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs +33 -0
  808. package/esm/node_modules/openai/resources/beta/realtime/sessions.mjs.map +1 -0
  809. package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs +33 -0
  810. package/esm/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs.map +1 -0
  811. package/esm/node_modules/openai/resources/beta/threads/messages.mjs +83 -0
  812. package/esm/node_modules/openai/resources/beta/threads/messages.mjs.map +1 -0
  813. package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs +183 -0
  814. package/esm/node_modules/openai/resources/beta/threads/runs/runs.mjs.map +1 -0
  815. package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs +45 -0
  816. package/esm/node_modules/openai/resources/beta/threads/runs/steps.mjs.map +1 -0
  817. package/esm/node_modules/openai/resources/beta/threads/threads.mjs +101 -0
  818. package/esm/node_modules/openai/resources/beta/threads/threads.mjs.map +1 -0
  819. package/esm/node_modules/openai/resources/chat/chat.mjs +15 -0
  820. package/esm/node_modules/openai/resources/chat/chat.mjs.map +1 -0
  821. package/esm/node_modules/openai/resources/chat/completions/completions.mjs +123 -0
  822. package/esm/node_modules/openai/resources/chat/completions/completions.mjs.map +1 -0
  823. package/esm/node_modules/openai/resources/chat/completions/index.mjs +7 -0
  824. package/esm/node_modules/openai/resources/chat/completions/messages.mjs +35 -0
  825. package/esm/node_modules/openai/resources/chat/completions/messages.mjs.map +1 -0
  826. package/esm/node_modules/openai/resources/chat/index.mjs +5 -0
  827. package/esm/node_modules/openai/resources/completions.mjs +20 -0
  828. package/esm/node_modules/openai/resources/completions.mjs.map +1 -0
  829. package/esm/node_modules/openai/resources/containers/containers.mjs +57 -0
  830. package/esm/node_modules/openai/resources/containers/containers.mjs.map +1 -0
  831. package/esm/node_modules/openai/resources/containers/files/content.mjs +23 -0
  832. package/esm/node_modules/openai/resources/containers/files/content.mjs.map +1 -0
  833. package/esm/node_modules/openai/resources/containers/files/files.mjs +63 -0
  834. package/esm/node_modules/openai/resources/containers/files/files.mjs.map +1 -0
  835. package/esm/node_modules/openai/resources/conversations/conversations.mjs +57 -0
  836. package/esm/node_modules/openai/resources/conversations/conversations.mjs.map +1 -0
  837. package/esm/node_modules/openai/resources/conversations/items.mjs +57 -0
  838. package/esm/node_modules/openai/resources/conversations/items.mjs.map +1 -0
  839. package/esm/node_modules/openai/resources/embeddings.mjs +48 -0
  840. package/esm/node_modules/openai/resources/embeddings.mjs.map +1 -0
  841. package/esm/node_modules/openai/resources/evals/evals.mjs +73 -0
  842. package/esm/node_modules/openai/resources/evals/evals.mjs.map +1 -0
  843. package/esm/node_modules/openai/resources/evals/runs/output-items.mjs +35 -0
  844. package/esm/node_modules/openai/resources/evals/runs/output-items.mjs.map +1 -0
  845. package/esm/node_modules/openai/resources/evals/runs/runs.mjs +72 -0
  846. package/esm/node_modules/openai/resources/evals/runs/runs.mjs.map +1 -0
  847. package/esm/node_modules/openai/resources/files.mjs +111 -0
  848. package/esm/node_modules/openai/resources/files.mjs.map +1 -0
  849. package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs +15 -0
  850. package/esm/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs.map +1 -0
  851. package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs +60 -0
  852. package/esm/node_modules/openai/resources/fine-tuning/alpha/graders.mjs.map +1 -0
  853. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs +15 -0
  854. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs.map +1 -0
  855. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs +102 -0
  856. package/esm/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs.map +1 -0
  857. package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs +24 -0
  858. package/esm/node_modules/openai/resources/fine-tuning/fine-tuning.mjs.map +1 -0
  859. package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs +34 -0
  860. package/esm/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs.map +1 -0
  861. package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs +148 -0
  862. package/esm/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs.map +1 -0
  863. package/esm/node_modules/openai/resources/fine-tuning/methods.mjs +8 -0
  864. package/esm/node_modules/openai/resources/fine-tuning/methods.mjs.map +1 -0
  865. package/esm/node_modules/openai/resources/graders/grader-models.mjs +8 -0
  866. package/esm/node_modules/openai/resources/graders/grader-models.mjs.map +1 -0
  867. package/esm/node_modules/openai/resources/graders/graders.mjs +15 -0
  868. package/esm/node_modules/openai/resources/graders/graders.mjs.map +1 -0
  869. package/esm/node_modules/openai/resources/images.mjs +46 -0
  870. package/esm/node_modules/openai/resources/images.mjs.map +1 -0
  871. package/esm/node_modules/openai/resources/index.mjs +27 -0
  872. package/esm/node_modules/openai/resources/models.mjs +44 -0
  873. package/esm/node_modules/openai/resources/models.mjs.map +1 -0
  874. package/esm/node_modules/openai/resources/moderations.mjs +23 -0
  875. package/esm/node_modules/openai/resources/moderations.mjs.map +1 -0
  876. package/esm/node_modules/openai/resources/realtime/calls.mjs +79 -0
  877. package/esm/node_modules/openai/resources/realtime/calls.mjs.map +1 -0
  878. package/esm/node_modules/openai/resources/realtime/client-secrets.mjs +39 -0
  879. package/esm/node_modules/openai/resources/realtime/client-secrets.mjs.map +1 -0
  880. package/esm/node_modules/openai/resources/realtime/realtime.mjs +18 -0
  881. package/esm/node_modules/openai/resources/realtime/realtime.mjs.map +1 -0
  882. package/esm/node_modules/openai/resources/responses/input-items.mjs +31 -0
  883. package/esm/node_modules/openai/resources/responses/input-items.mjs.map +1 -0
  884. package/esm/node_modules/openai/resources/responses/input-tokens.mjs +27 -0
  885. package/esm/node_modules/openai/resources/responses/input-tokens.mjs.map +1 -0
  886. package/esm/node_modules/openai/resources/responses/responses.mjs +110 -0
  887. package/esm/node_modules/openai/resources/responses/responses.mjs.map +1 -0
  888. package/esm/node_modules/openai/resources/skills/content.mjs +22 -0
  889. package/esm/node_modules/openai/resources/skills/content.mjs.map +1 -0
  890. package/esm/node_modules/openai/resources/skills/skills.mjs +69 -0
  891. package/esm/node_modules/openai/resources/skills/skills.mjs.map +1 -0
  892. package/esm/node_modules/openai/resources/skills/versions/content.mjs +23 -0
  893. package/esm/node_modules/openai/resources/skills/versions/content.mjs.map +1 -0
  894. package/esm/node_modules/openai/resources/skills/versions/versions.mjs +58 -0
  895. package/esm/node_modules/openai/resources/skills/versions/versions.mjs.map +1 -0
  896. package/esm/node_modules/openai/resources/uploads/parts.mjs +34 -0
  897. package/esm/node_modules/openai/resources/uploads/parts.mjs.map +1 -0
  898. package/esm/node_modules/openai/resources/uploads/uploads.mjs +84 -0
  899. package/esm/node_modules/openai/resources/uploads/uploads.mjs.map +1 -0
  900. package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs +126 -0
  901. package/esm/node_modules/openai/resources/vector-stores/file-batches.mjs.map +1 -0
  902. package/esm/node_modules/openai/resources/vector-stores/files.mjs +147 -0
  903. package/esm/node_modules/openai/resources/vector-stores/files.mjs.map +1 -0
  904. package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs +87 -0
  905. package/esm/node_modules/openai/resources/vector-stores/vector-stores.mjs.map +1 -0
  906. package/esm/node_modules/openai/resources/videos.mjs +115 -0
  907. package/esm/node_modules/openai/resources/videos.mjs.map +1 -0
  908. package/esm/node_modules/openai/resources/webhooks/index.mjs +3 -0
  909. package/esm/node_modules/openai/resources/webhooks/webhooks.mjs +69 -0
  910. package/esm/node_modules/openai/resources/webhooks/webhooks.mjs.map +1 -0
  911. package/esm/node_modules/openai/resources/webhooks.mjs +4 -0
  912. package/esm/node_modules/openai/streaming.mjs +3 -0
  913. package/esm/node_modules/openai/version.mjs +6 -0
  914. package/esm/node_modules/openai/version.mjs.map +1 -0
  915. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +37 -1
  916. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
  917. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs +71 -5
  918. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
  919. package/esm/repositories/adapters/cascade/filter-applicator.mjs +17 -3
  920. package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
  921. package/esm/repositories/contracts/index.d.mts +1 -1
  922. package/esm/repositories/contracts/query-builder.contract.d.mts +87 -1
  923. package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
  924. package/esm/repositories/index.d.mts +1 -1
  925. package/esm/repositories/repository.manager.d.mts +110 -2
  926. package/esm/repositories/repository.manager.d.mts.map +1 -1
  927. package/esm/repositories/repository.manager.mjs +207 -25
  928. package/esm/repositories/repository.manager.mjs.map +1 -1
  929. package/esm/router/route-registry.mjs +19 -10
  930. package/esm/router/route-registry.mjs.map +1 -1
  931. package/esm/router/router.d.mts +9 -0
  932. package/esm/router/router.d.mts.map +1 -1
  933. package/esm/router/router.mjs +28 -5
  934. package/esm/router/router.mjs.map +1 -1
  935. package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
  936. package/esm/storage/drivers/cloud-driver.mjs +48 -12
  937. package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
  938. package/esm/storage/drivers/do-spaces-driver.mjs +1 -1
  939. package/esm/storage/drivers/do-spaces-driver.mjs.map +1 -1
  940. package/esm/storage/drivers/local-driver.d.mts +8 -0
  941. package/esm/storage/drivers/local-driver.d.mts.map +1 -1
  942. package/esm/storage/drivers/local-driver.mjs +19 -4
  943. package/esm/storage/drivers/local-driver.mjs.map +1 -1
  944. package/esm/storage/drivers/r2-driver.mjs +1 -1
  945. package/esm/storage/drivers/r2-driver.mjs.map +1 -1
  946. package/esm/storage/drivers/s3-driver.mjs +1 -1
  947. package/esm/storage/drivers/s3-driver.mjs.map +1 -1
  948. package/esm/storage/index.d.mts +4 -1
  949. package/esm/storage/index.mjs +3 -0
  950. package/esm/storage/scoped-storage.d.mts +8 -4
  951. package/esm/storage/scoped-storage.d.mts.map +1 -1
  952. package/esm/storage/scoped-storage.mjs +21 -6
  953. package/esm/storage/scoped-storage.mjs.map +1 -1
  954. package/esm/storage/storage.d.mts +12 -4
  955. package/esm/storage/storage.d.mts.map +1 -1
  956. package/esm/storage/storage.mjs +23 -9
  957. package/esm/storage/storage.mjs.map +1 -1
  958. package/esm/storage/types.d.mts +33 -5
  959. package/esm/storage/types.d.mts.map +1 -1
  960. package/esm/storage/utils/contain-path.d.mts +23 -0
  961. package/esm/storage/utils/contain-path.d.mts.map +1 -0
  962. package/esm/storage/utils/contain-path.mjs +35 -0
  963. package/esm/storage/utils/contain-path.mjs.map +1 -0
  964. package/esm/storage/utils/safe-fetch.d.mts +68 -0
  965. package/esm/storage/utils/safe-fetch.d.mts.map +1 -0
  966. package/esm/storage/utils/safe-fetch.mjs +205 -0
  967. package/esm/storage/utils/safe-fetch.mjs.map +1 -0
  968. package/esm/storage/utils/storage-error.d.mts +35 -0
  969. package/esm/storage/utils/storage-error.d.mts.map +1 -0
  970. package/esm/storage/utils/storage-error.mjs +17 -0
  971. package/esm/storage/utils/storage-error.mjs.map +1 -0
  972. package/esm/use-cases/use-case-pipeline.mjs +4 -1
  973. package/esm/use-cases/use-case-pipeline.mjs.map +1 -1
  974. package/esm/use-cases/use-case.mjs +12 -4
  975. package/esm/use-cases/use-case.mjs.map +1 -1
  976. package/esm/use-cases/use-cases-registry.d.mts +12 -4
  977. package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
  978. package/esm/use-cases/use-cases-registry.mjs +13 -3
  979. package/esm/use-cases/use-cases-registry.mjs.map +1 -1
  980. package/esm/utils/npm-registry.d.mts +1 -1
  981. package/esm/utils/npm-registry.mjs +2 -2
  982. package/esm/utils/npm-registry.mjs.map +1 -1
  983. package/esm/utils/paths.mjs +2 -2
  984. package/esm/utils/paths.mjs.map +1 -1
  985. package/esm/validation/validateAll.mjs +2 -2
  986. package/esm/validation/validateAll.mjs.map +1 -1
  987. package/llms-full.txt +456 -46
  988. package/llms.txt +4 -2
  989. package/package.json +9 -9
  990. package/skills/README.md +65 -0
  991. package/skills/add-connector/SKILL.md +6 -1
  992. package/skills/configure-app/SKILL.md +23 -0
  993. package/skills/health-checks/SKILL.md +13 -0
  994. package/skills/use-repository/SKILL.md +38 -1
  995. package/skills/warlock-doctor/SKILL.md +135 -0
  996. package/skills/warlock-routes/SKILL.md +91 -0
  997. package/skills/write-seeder/SKILL.md +143 -45
@@ -0,0 +1,209 @@
1
+ import { GuardrailViolationError } from "../errors/guardrail-violation-error.mjs";
2
+ import { extractUserText } from "../middleware/utils/extract-user-text.mjs";
3
+ import { forTool } from "../middleware/helpers/for-tool.mjs";
4
+ import "./errors.mjs";
5
+
6
+ //#region ../@warlock.js/ai/src/guard/guard.ts
7
+ /** Default middleware name when the caller supplies none. */
8
+ const DEFAULT_NAME = "guardrail";
9
+ /**
10
+ * The `ctx.state` key under which a guard records its `flag` verdicts. The
11
+ * value is an append-only array of {@link FlagRecord}, namespaced by the
12
+ * middleware name so two guards on the same agent never collide and a
13
+ * downstream observer (panoptic, the caller) can read the annotations
14
+ * post-run.
15
+ */
16
+ function flagsKey(name) {
17
+ return `${name}.flags`;
18
+ }
19
+ /**
20
+ * Append a `flag` record onto the namespaced `ctx.state` array, creating it
21
+ * on first write. Never throws — recording is best-effort annotation.
22
+ */
23
+ function recordFlag(ctx, name, record) {
24
+ const key = flagsKey(name);
25
+ const existing = ctx.state.get(key);
26
+ const flags = Array.isArray(existing) ? existing : [];
27
+ flags.push(record);
28
+ ctx.state.set(key, flags);
29
+ }
30
+ /**
31
+ * Run a phase's detector array over `text`, in registration order, and fold
32
+ * the verdicts into a single {@link PhaseOutcome}.
33
+ *
34
+ * **Short-circuit.** The first non-`allow`/non-`flag` verdict (a `redact` or
35
+ * `block`) decides the outcome and stops the fold — outer detectors never run
36
+ * after one objects, matching the install-array ordering. `flag` verdicts are
37
+ * recorded into `ctx.state` and the fold continues (allow-but-annotate).
38
+ *
39
+ * **Phase-aware redact downgrade.** A `redact` verdict is only honoured where
40
+ * the seam supports rewrite-and-continue:
41
+ * - `"output"` — `trip.after` may return a replacement `ModelResponse`, so the
42
+ * rewritten text is threaded out.
43
+ * - `"input"` — the core `trip.before` hook can only short-circuit (return a
44
+ * response) or throw; it has **no** rewrite-and-continue seam, so an input
45
+ * `redact` is downgraded to a `block` rather than silently passing the
46
+ * un-redacted prompt through. (Documented on {@link GuardOptions.input}.)
47
+ * - `"tool"` — silently rewriting tool arguments changes the call's
48
+ * side-effects unpredictably, so a tool `redact` is downgraded to a `block`
49
+ * (`tool-arg-redaction-unsupported`) rather than mutating what the tool runs.
50
+ *
51
+ * **Fail-open on detector fault.** A detector's `check()` rejecting is an
52
+ * infrastructure fault, not a content violation — it is recorded as a `flag`
53
+ * (`<detector>.error`) and the fold continues, so a moderation-API outage does
54
+ * not abort every agent run.
55
+ */
56
+ async function runDetectors(detectors, text, phase, ctx, name) {
57
+ for (const detector of detectors) {
58
+ let verdict;
59
+ try {
60
+ verdict = await detector.check(text, {
61
+ phase,
62
+ ctx
63
+ });
64
+ } catch (error) {
65
+ recordFlag(ctx, name, {
66
+ detector: detector.name,
67
+ phase,
68
+ reason: `detector "${detector.name}" threw: ${error instanceof Error ? error.message : String(error)}`,
69
+ matches: []
70
+ });
71
+ continue;
72
+ }
73
+ if (verdict.type === "allow") continue;
74
+ if (verdict.type === "flag") {
75
+ recordFlag(ctx, name, {
76
+ detector: detector.name,
77
+ phase,
78
+ reason: verdict.reason,
79
+ matches: verdict.matches
80
+ });
81
+ continue;
82
+ }
83
+ if (verdict.type === "redact") {
84
+ if (phase === "output") return {
85
+ type: "redact",
86
+ text: verdict.text
87
+ };
88
+ return {
89
+ type: "block",
90
+ reason: phase === "tool" ? "tool-arg-redaction-unsupported" : verdict.reason,
91
+ matches: verdict.matches,
92
+ escalate: false
93
+ };
94
+ }
95
+ return {
96
+ type: "block",
97
+ reason: verdict.reason,
98
+ matches: verdict.matches,
99
+ escalate: verdict.escalate ?? false
100
+ };
101
+ }
102
+ return { type: "allow" };
103
+ }
104
+ /**
105
+ * Realize a `block` outcome: fire the escalation seam (when the verdict asked
106
+ * for it) and throw the typed {@link GuardrailViolationError} on `result.error`.
107
+ * Never returns — always throws.
108
+ *
109
+ * The core `GuardrailViolationError.phase` is typed `"input" | "output"`; this
110
+ * package widens the surfaced `phase` with `"tool"` (a source-compatible third
111
+ * value), so the construction site asserts the wider value through the options
112
+ * shape the error already accepts at runtime.
113
+ */
114
+ async function block(outcome, phase, ctx, name, escalation) {
115
+ if (outcome.escalate) await escalation?.onBlock?.({
116
+ phase,
117
+ reason: outcome.reason,
118
+ matches: outcome.matches,
119
+ ctx
120
+ });
121
+ throw new GuardrailViolationError(`guardrail "${name}" rejected ${phase} — ${outcome.reason}`, {
122
+ phase,
123
+ reason: outcome.reason,
124
+ guardrail: name
125
+ });
126
+ }
127
+ /**
128
+ * Build the composed **guardrail middleware** (surfaced as
129
+ * `ai.guardrail(options)`) — one {@link AgentMiddleware} that runs the
130
+ * configured detectors at three hook points and maps each
131
+ * {@link GuardrailVerdict} onto the pipeline's throw / return / record
132
+ * mechanics:
133
+ *
134
+ * - **`input`** detectors run at `trip.before` over the outbound prompt
135
+ * (`extractUserText(ctx.messages)`). `block` / `flag` only — the core
136
+ * `trip.before` seam cannot rewrite-and-continue, so a `redact` verdict here
137
+ * is downgraded to a `block`.
138
+ * - **`output`** detectors run at `trip.after` over `response.content`. Full
139
+ * `allow` / `redact` / `block` / `flag` support — a `redact` returns a
140
+ * replacement `ModelResponse` with the rewritten `content`.
141
+ * - **`tool`** detectors run at `tool.before` over `JSON.stringify(toolArgs)`.
142
+ * `block` / `flag`; a `redact` is downgraded to a `block`
143
+ * (`tool-arg-redaction-unsupported`). Scoped to `toolNames` via the core
144
+ * `forTool(toolNames, mw)` helper when set.
145
+ *
146
+ * **Verdict → action.** Detectors run in registration order; the first
147
+ * `redact` / `block` short-circuits the phase. `block` throws a
148
+ * {@link GuardrailViolationError} on `result.error` (never out of the
149
+ * pipeline); `flag` records the match into `ctx.state` under `<name>.flags`
150
+ * and continues; a `{ type: "block", escalate: true }` verdict awaits
151
+ * `escalation.onBlock` before throwing. A detector that *throws* is treated as
152
+ * an infra fault and fails open (recorded as a flag, run continues).
153
+ *
154
+ * @param options - The {@link GuardOptions}: per-phase detector arrays,
155
+ * optional `toolNames` scope, `escalation` seam, and `name` override.
156
+ * @returns One {@link AgentMiddleware} to pass into `ai.agent({ middleware: [...] })`.
157
+ *
158
+ * @example
159
+ * const policy = ai.guardrail({
160
+ * name: "compliance",
161
+ * input: [ai.guardrail.injection({ onMatch: "block" })],
162
+ * output: [ai.guardrail.pii({ onMatch: "redact", mask: "[REDACTED:{label}]" })],
163
+ * tool: [ai.guardrail.pii({ onMatch: "block" })],
164
+ * toolNames: ["send_email"],
165
+ * escalation: { async onBlock(e) { await reviewQueue.enqueue(e); } },
166
+ * });
167
+ *
168
+ * const agent = ai.agent({ model, tools: [sendEmail], middleware: [policy] });
169
+ */
170
+ function guard(options) {
171
+ const name = options.name ?? DEFAULT_NAME;
172
+ const input = options.input ?? [];
173
+ const output = options.output ?? [];
174
+ const tool = options.tool ?? [];
175
+ const escalation = options.escalation;
176
+ const middleware = {
177
+ name,
178
+ trip: {
179
+ async before(ctx) {
180
+ if (input.length === 0) return;
181
+ const prompt = extractUserText(ctx.messages);
182
+ if (!prompt) return;
183
+ const outcome = await runDetectors(input, prompt, "input", ctx, name);
184
+ if (outcome.type === "block") await block(outcome, "input", ctx, name, escalation);
185
+ },
186
+ async after(ctx, response) {
187
+ if (output.length === 0 || !response.content) return;
188
+ const outcome = await runDetectors(output, response.content, "output", ctx, name);
189
+ if (outcome.type === "block") await block(outcome, "output", ctx, name, escalation);
190
+ if (outcome.type === "redact") return {
191
+ ...response,
192
+ content: outcome.text
193
+ };
194
+ }
195
+ }
196
+ };
197
+ if (tool.length > 0) middleware.tool = { async before(ctx) {
198
+ const args = JSON.stringify(ctx.request.input);
199
+ if (!args) return;
200
+ const outcome = await runDetectors(tool, args, "tool", ctx, name);
201
+ if (outcome.type === "block") await block(outcome, "tool", ctx, name, escalation);
202
+ } };
203
+ if (options.toolNames !== void 0 && middleware.tool) return forTool(options.toolNames, middleware);
204
+ return middleware;
205
+ }
206
+
207
+ //#endregion
208
+ export { guard };
209
+ //# sourceMappingURL=guard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/guard/guard.ts"],"sourcesContent":["import { extractUserText } from \"../middleware/utils/extract-user-text\";\nimport { forTool } from \"../middleware/helpers/for-tool\";\nimport type { AgentMiddleware } from \"../contracts/middleware/middleware.contract\";\nimport type {\n MiddlewareToolContext,\n MiddlewareTripContext,\n} from \"../contracts/middleware/middleware-context.type\";\nimport type { ModelResponse } from \"../contracts/model.contract\";\nimport type {\n GuardOptions,\n GuardrailDetector,\n GuardrailEscalation,\n GuardrailMatch,\n GuardrailPhase,\n GuardrailVerdict,\n} from \"./contracts\";\nimport { GuardrailViolationError } from \"./errors\";\n\n/** Default middleware name when the caller supplies none. */\nconst DEFAULT_NAME = \"guardrail\";\n\n/**\n * The `ctx.state` key under which a guard records its `flag` verdicts. The\n * value is an append-only array of {@link FlagRecord}, namespaced by the\n * middleware name so two guards on the same agent never collide and a\n * downstream observer (panoptic, the caller) can read the annotations\n * post-run.\n */\nfunction flagsKey(name: string): string {\n return `${name}.flags`;\n}\n\n/**\n * One flagged match recorded into `ctx.state`. Mirrors the\n * {@link GuardrailVerdict} `flag` shape plus the phase it fired at, so an\n * observer can reconstruct *what* tripped *where* without re-running the\n * detector.\n */\nexport interface FlagRecord {\n /** The detector that produced the flag. */\n readonly detector: string;\n /** Where the detector was running. */\n readonly phase: GuardrailPhase;\n /** The detector's human-readable reason. */\n readonly reason: string;\n /** The matches the detector recorded. */\n readonly matches: readonly GuardrailMatch[];\n}\n\n/**\n * Append a `flag` record onto the namespaced `ctx.state` array, creating it\n * on first write. Never throws — recording is best-effort annotation.\n */\nfunction recordFlag(\n ctx: MiddlewareTripContext,\n name: string,\n record: FlagRecord,\n): void {\n const key = flagsKey(name);\n const existing = ctx.state.get(key);\n const flags = Array.isArray(existing) ? (existing as FlagRecord[]) : [];\n\n flags.push(record);\n ctx.state.set(key, flags);\n}\n\n/**\n * The outcome of folding a phase's detector array — what the hook should do\n * with the inspected text once every detector has had its say.\n *\n * - `allow` — no detector objected; the hook continues untouched.\n * - `redact` — a detector returned rewritten `text`; the hook substitutes it\n * (output / tool phases only — see {@link runDetectors}).\n * - `block` — a detector rejected; the hook throws a\n * {@link GuardrailViolationError} carrying `reason` / `matches` / `escalate`.\n *\n * `flag` verdicts never reach this type — they are recorded into `ctx.state`\n * as a side effect inside {@link runDetectors} and do not short-circuit the\n * fold, so a flagged-but-otherwise-clean run resolves to `allow`.\n */\ntype PhaseOutcome =\n | { readonly type: \"allow\" }\n | { readonly type: \"redact\"; readonly text: string }\n | {\n readonly type: \"block\";\n readonly reason: string;\n readonly matches?: readonly GuardrailMatch[];\n readonly escalate: boolean;\n };\n\n/**\n * Run a phase's detector array over `text`, in registration order, and fold\n * the verdicts into a single {@link PhaseOutcome}.\n *\n * **Short-circuit.** The first non-`allow`/non-`flag` verdict (a `redact` or\n * `block`) decides the outcome and stops the fold — outer detectors never run\n * after one objects, matching the install-array ordering. `flag` verdicts are\n * recorded into `ctx.state` and the fold continues (allow-but-annotate).\n *\n * **Phase-aware redact downgrade.** A `redact` verdict is only honoured where\n * the seam supports rewrite-and-continue:\n * - `\"output\"` — `trip.after` may return a replacement `ModelResponse`, so the\n * rewritten text is threaded out.\n * - `\"input\"` — the core `trip.before` hook can only short-circuit (return a\n * response) or throw; it has **no** rewrite-and-continue seam, so an input\n * `redact` is downgraded to a `block` rather than silently passing the\n * un-redacted prompt through. (Documented on {@link GuardOptions.input}.)\n * - `\"tool\"` — silently rewriting tool arguments changes the call's\n * side-effects unpredictably, so a tool `redact` is downgraded to a `block`\n * (`tool-arg-redaction-unsupported`) rather than mutating what the tool runs.\n *\n * **Fail-open on detector fault.** A detector's `check()` rejecting is an\n * infrastructure fault, not a content violation — it is recorded as a `flag`\n * (`<detector>.error`) and the fold continues, so a moderation-API outage does\n * not abort every agent run.\n */\nasync function runDetectors(\n detectors: readonly GuardrailDetector[],\n text: string,\n phase: GuardrailPhase,\n ctx: MiddlewareTripContext,\n name: string,\n): Promise<PhaseOutcome> {\n for (const detector of detectors) {\n let verdict: GuardrailVerdict;\n\n try {\n verdict = await detector.check(text, { phase, ctx });\n } catch (error) {\n // Infra fault — fail open: record and continue, never abort the run.\n recordFlag(ctx, name, {\n detector: detector.name,\n phase,\n reason: `detector \"${detector.name}\" threw: ${\n error instanceof Error ? error.message : String(error)\n }`,\n matches: [],\n });\n\n continue;\n }\n\n if (verdict.type === \"allow\") {\n continue;\n }\n\n if (verdict.type === \"flag\") {\n recordFlag(ctx, name, {\n detector: detector.name,\n phase,\n reason: verdict.reason,\n matches: verdict.matches,\n });\n\n continue;\n }\n\n if (verdict.type === \"redact\") {\n if (phase === \"output\") {\n return { type: \"redact\", text: verdict.text };\n }\n\n // Input / tool phases have no safe rewrite-and-continue seam — downgrade\n // to a block so the un-redacted text is never threaded through.\n const reason =\n phase === \"tool\"\n ? \"tool-arg-redaction-unsupported\"\n : verdict.reason;\n\n return {\n type: \"block\",\n reason,\n matches: verdict.matches,\n escalate: false,\n };\n }\n\n // verdict.type === \"block\"\n return {\n type: \"block\",\n reason: verdict.reason,\n matches: verdict.matches,\n escalate: verdict.escalate ?? false,\n };\n }\n\n return { type: \"allow\" };\n}\n\n/**\n * Realize a `block` outcome: fire the escalation seam (when the verdict asked\n * for it) and throw the typed {@link GuardrailViolationError} on `result.error`.\n * Never returns — always throws.\n *\n * The core `GuardrailViolationError.phase` is typed `\"input\" | \"output\"`; this\n * package widens the surfaced `phase` with `\"tool\"` (a source-compatible third\n * value), so the construction site asserts the wider value through the options\n * shape the error already accepts at runtime.\n */\nasync function block(\n outcome: Extract<PhaseOutcome, { type: \"block\" }>,\n phase: GuardrailPhase,\n ctx: MiddlewareTripContext,\n name: string,\n escalation: GuardrailEscalation | undefined,\n): Promise<never> {\n if (outcome.escalate) {\n await escalation?.onBlock?.({\n phase,\n reason: outcome.reason,\n matches: outcome.matches,\n ctx,\n });\n }\n\n throw new GuardrailViolationError(\n `guardrail \"${name}\" rejected ${phase} — ${outcome.reason}`,\n {\n // `phase` is widened to include \"tool\"; the error carries it verbatim.\n phase: phase as \"input\" | \"output\",\n reason: outcome.reason,\n guardrail: name,\n },\n );\n}\n\n/**\n * Build the composed **guardrail middleware** (surfaced as\n * `ai.guardrail(options)`) — one {@link AgentMiddleware} that runs the\n * configured detectors at three hook points and maps each\n * {@link GuardrailVerdict} onto the pipeline's throw / return / record\n * mechanics:\n *\n * - **`input`** detectors run at `trip.before` over the outbound prompt\n * (`extractUserText(ctx.messages)`). `block` / `flag` only — the core\n * `trip.before` seam cannot rewrite-and-continue, so a `redact` verdict here\n * is downgraded to a `block`.\n * - **`output`** detectors run at `trip.after` over `response.content`. Full\n * `allow` / `redact` / `block` / `flag` support — a `redact` returns a\n * replacement `ModelResponse` with the rewritten `content`.\n * - **`tool`** detectors run at `tool.before` over `JSON.stringify(toolArgs)`.\n * `block` / `flag`; a `redact` is downgraded to a `block`\n * (`tool-arg-redaction-unsupported`). Scoped to `toolNames` via the core\n * `forTool(toolNames, mw)` helper when set.\n *\n * **Verdict → action.** Detectors run in registration order; the first\n * `redact` / `block` short-circuits the phase. `block` throws a\n * {@link GuardrailViolationError} on `result.error` (never out of the\n * pipeline); `flag` records the match into `ctx.state` under `<name>.flags`\n * and continues; a `{ type: \"block\", escalate: true }` verdict awaits\n * `escalation.onBlock` before throwing. A detector that *throws* is treated as\n * an infra fault and fails open (recorded as a flag, run continues).\n *\n * @param options - The {@link GuardOptions}: per-phase detector arrays,\n * optional `toolNames` scope, `escalation` seam, and `name` override.\n * @returns One {@link AgentMiddleware} to pass into `ai.agent({ middleware: [...] })`.\n *\n * @example\n * const policy = ai.guardrail({\n * name: \"compliance\",\n * input: [ai.guardrail.injection({ onMatch: \"block\" })],\n * output: [ai.guardrail.pii({ onMatch: \"redact\", mask: \"[REDACTED:{label}]\" })],\n * tool: [ai.guardrail.pii({ onMatch: \"block\" })],\n * toolNames: [\"send_email\"],\n * escalation: { async onBlock(e) { await reviewQueue.enqueue(e); } },\n * });\n *\n * const agent = ai.agent({ model, tools: [sendEmail], middleware: [policy] });\n */\nexport function guard(options: GuardOptions): AgentMiddleware {\n const name = options.name ?? DEFAULT_NAME;\n const input = options.input ?? [];\n const output = options.output ?? [];\n const tool = options.tool ?? [];\n const escalation = options.escalation;\n\n const middleware: AgentMiddleware = {\n name,\n trip: {\n async before(ctx: MiddlewareTripContext): Promise<void> {\n if (input.length === 0) {\n return;\n }\n\n const prompt = extractUserText(ctx.messages);\n\n if (!prompt) {\n return;\n }\n\n const outcome = await runDetectors(input, prompt, \"input\", ctx, name);\n\n if (outcome.type === \"block\") {\n await block(outcome, \"input\", ctx, name, escalation);\n }\n\n // `allow` (incl. any recorded flags) and a downgraded-but-impossible\n // input `redact` (already mapped to block above) fall through — the\n // real model call proceeds with the un-mutated prompt.\n },\n async after(\n ctx: MiddlewareTripContext,\n response: ModelResponse,\n ): Promise<void | ModelResponse> {\n if (output.length === 0 || !response.content) {\n return;\n }\n\n const outcome = await runDetectors(\n output,\n response.content,\n \"output\",\n ctx,\n name,\n );\n\n if (outcome.type === \"block\") {\n await block(outcome, \"output\", ctx, name, escalation);\n }\n\n if (outcome.type === \"redact\") {\n // `trip.after` may return a replacement response — thread the\n // rewritten content back so the caller never sees the original.\n return { ...response, content: outcome.text };\n }\n\n return;\n },\n },\n };\n\n // Only declare the `tool` hook map when there are tool detectors — an empty\n // `tool` array would otherwise make `forTool` scoping a no-op cost.\n if (tool.length > 0) {\n middleware.tool = {\n async before(ctx: MiddlewareToolContext): Promise<void> {\n const args = JSON.stringify(ctx.request.input);\n\n if (!args) {\n return;\n }\n\n const outcome = await runDetectors(tool, args, \"tool\", ctx, name);\n\n if (outcome.type === \"block\") {\n await block(outcome, \"tool\", ctx, name, escalation);\n }\n\n // A tool `redact` is downgraded to `block` inside `runDetectors`, so\n // `redact` is unreachable here; `allow`/`flag` fall through and the\n // real tool dispatch proceeds.\n },\n };\n }\n\n // Scope the `tool` hooks to the named tools when requested — `forTool`\n // leaves `trip` hooks untouched, so input/output detectors still fire for\n // every trip regardless of which tool is being dispatched.\n if (options.toolNames !== undefined && middleware.tool) {\n return forTool(options.toolNames, middleware);\n }\n\n return middleware;\n}\n"],"mappings":";;;;;;;AAmBA,MAAM,eAAe;;;;;;;;AASrB,SAAS,SAAS,MAAsB;CACtC,OAAO,GAAG,KAAK;AACjB;;;;;AAuBA,SAAS,WACP,KACA,MACA,QACM;CACN,MAAM,MAAM,SAAS,IAAI;CACzB,MAAM,WAAW,IAAI,MAAM,IAAI,GAAG;CAClC,MAAM,QAAQ,MAAM,QAAQ,QAAQ,IAAK,WAA4B,CAAC;CAEtE,MAAM,KAAK,MAAM;CACjB,IAAI,MAAM,IAAI,KAAK,KAAK;AAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,eAAe,aACb,WACA,MACA,OACA,KACA,MACuB;CACvB,KAAK,MAAM,YAAY,WAAW;EAChC,IAAI;EAEJ,IAAI;GACF,UAAU,MAAM,SAAS,MAAM,MAAM;IAAE;IAAO;GAAI,CAAC;EACrD,SAAS,OAAO;GAEd,WAAW,KAAK,MAAM;IACpB,UAAU,SAAS;IACnB;IACA,QAAQ,aAAa,SAAS,KAAK,WACjC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;IAEvD,SAAS,CAAC;GACZ,CAAC;GAED;EACF;EAEA,IAAI,QAAQ,SAAS,SACnB;EAGF,IAAI,QAAQ,SAAS,QAAQ;GAC3B,WAAW,KAAK,MAAM;IACpB,UAAU,SAAS;IACnB;IACA,QAAQ,QAAQ;IAChB,SAAS,QAAQ;GACnB,CAAC;GAED;EACF;EAEA,IAAI,QAAQ,SAAS,UAAU;GAC7B,IAAI,UAAU,UACZ,OAAO;IAAE,MAAM;IAAU,MAAM,QAAQ;GAAK;GAU9C,OAAO;IACL,MAAM;IACN,QANA,UAAU,SACN,mCACA,QAAQ;IAKZ,SAAS,QAAQ;IACjB,UAAU;GACZ;EACF;EAGA,OAAO;GACL,MAAM;GACN,QAAQ,QAAQ;GAChB,SAAS,QAAQ;GACjB,UAAU,QAAQ,YAAY;EAChC;CACF;CAEA,OAAO,EAAE,MAAM,QAAQ;AACzB;;;;;;;;;;;AAYA,eAAe,MACb,SACA,OACA,KACA,MACA,YACgB;CAChB,IAAI,QAAQ,UACV,MAAM,YAAY,UAAU;EAC1B;EACA,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB;CACF,CAAC;CAGH,MAAM,IAAI,wBACR,cAAc,KAAK,aAAa,MAAM,KAAK,QAAQ,UACnD;EAES;EACP,QAAQ,QAAQ;EAChB,WAAW;CACb,CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,MAAM,SAAwC;CAC5D,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,QAAQ,QAAQ,SAAS,CAAC;CAChC,MAAM,SAAS,QAAQ,UAAU,CAAC;CAClC,MAAM,OAAO,QAAQ,QAAQ,CAAC;CAC9B,MAAM,aAAa,QAAQ;CAE3B,MAAM,aAA8B;EAClC;EACA,MAAM;GACJ,MAAM,OAAO,KAA2C;IACtD,IAAI,MAAM,WAAW,GACnB;IAGF,MAAM,SAAS,gBAAgB,IAAI,QAAQ;IAE3C,IAAI,CAAC,QACH;IAGF,MAAM,UAAU,MAAM,aAAa,OAAO,QAAQ,SAAS,KAAK,IAAI;IAEpE,IAAI,QAAQ,SAAS,SACnB,MAAM,MAAM,SAAS,SAAS,KAAK,MAAM,UAAU;GAMvD;GACA,MAAM,MACJ,KACA,UAC+B;IAC/B,IAAI,OAAO,WAAW,KAAK,CAAC,SAAS,SACnC;IAGF,MAAM,UAAU,MAAM,aACpB,QACA,SAAS,SACT,UACA,KACA,IACF;IAEA,IAAI,QAAQ,SAAS,SACnB,MAAM,MAAM,SAAS,UAAU,KAAK,MAAM,UAAU;IAGtD,IAAI,QAAQ,SAAS,UAGnB,OAAO;KAAE,GAAG;KAAU,SAAS,QAAQ;IAAK;GAIhD;EACF;CACF;CAIA,IAAI,KAAK,SAAS,GAChB,WAAW,OAAO,EAChB,MAAM,OAAO,KAA2C;EACtD,MAAM,OAAO,KAAK,UAAU,IAAI,QAAQ,KAAK;EAE7C,IAAI,CAAC,MACH;EAGF,MAAM,UAAU,MAAM,aAAa,MAAM,MAAM,QAAQ,KAAK,IAAI;EAEhE,IAAI,QAAQ,SAAS,SACnB,MAAM,MAAM,SAAS,QAAQ,KAAK,MAAM,UAAU;CAMtD,EACF;CAMF,IAAI,QAAQ,cAAc,UAAa,WAAW,MAChD,OAAO,QAAQ,QAAQ,WAAW,UAAU;CAG9C,OAAO;AACT"}
@@ -0,0 +1,22 @@
1
+ import { injection } from "./detectors/injection.mjs";
2
+ import { pii } from "./detectors/pii.mjs";
3
+ import { topic } from "./detectors/topic.mjs";
4
+ import { moderation } from "./detectors/moderation.mjs";
5
+ import "./detectors/index.mjs";
6
+ import { guard } from "./guard.mjs";
7
+
8
+ //#region ../@warlock.js/ai/src/guard/guardrail.ts
9
+ /**
10
+ * The `ai.guardrail` value: the {@link guard} factory with the detector
11
+ * factories assigned onto it. Built once and shared.
12
+ */
13
+ const guardrail = Object.assign(guard, {
14
+ pii,
15
+ topic,
16
+ injection,
17
+ moderation
18
+ });
19
+
20
+ //#endregion
21
+ export { guardrail };
22
+ //# sourceMappingURL=guardrail.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/guard/guardrail.ts"],"sourcesContent":["import type { AgentMiddleware } from \"../contracts/middleware/middleware.contract\";\nimport type {\n GuardOptions,\n GuardrailDetector,\n InjectionDetectorOptions,\n OpenAiModerationOptions,\n PiiDetectorOptions,\n TopicFilterOptions,\n} from \"./contracts\";\nimport { injection, moderation, pii, topic } from \"./detectors\";\nimport { guard } from \"./guard\";\n\n/**\n * The callable `ai.guardrail` surface — the {@link guard} factory with the\n * built-in detector factories attached as methods, so the whole guardrail\n * vocabulary lives under one name:\n *\n * - `ai.guardrail(options)` — build the composed middleware.\n * - `ai.guardrail.pii(o?)` / `.topic(o)` / `.injection(o?)` / `.moderation(o?)`\n * — build a detector to pass into the factory's `input` / `output` / `tool`\n * arrays.\n *\n * @example\n * const policy = ai.guardrail({\n * output: [ai.guardrail.pii({ onMatch: \"redact\" })],\n * });\n */\nexport interface GuardrailFactory {\n /** Build the composed guardrail {@link AgentMiddleware}. */\n (options: GuardOptions): AgentMiddleware;\n /** Built-in PII detector (regex + dictionary, zero runtime dep). */\n pii(options?: PiiDetectorOptions): GuardrailDetector;\n /** Built-in topic filter (allow / deny string | RegExp lists). */\n topic(options: TopicFilterOptions): GuardrailDetector;\n /** Built-in jailbreak / prompt-injection marker detector. */\n injection(options?: InjectionDetectorOptions): GuardrailDetector;\n /** Optional OpenAI-backed moderation detector (lazy `openai` peer). */\n moderation(options?: OpenAiModerationOptions): GuardrailDetector;\n}\n\n/**\n * The `ai.guardrail` value: the {@link guard} factory with the detector\n * factories assigned onto it. Built once and shared.\n */\nexport const guardrail: GuardrailFactory = Object.assign(guard, {\n pii,\n topic,\n injection,\n moderation,\n});\n\n// `ai.guardrail` is registered natively on the core `ai` object (in `../ai`),\n// now that the guardrail suite ships inside `@warlock.js/ai`.\n"],"mappings":";;;;;;;;;;;;AA4CA,MAAa,YAA8B,OAAO,OAAO,OAAO;CAC9D;CACA;CACA;CACA;AACF,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { AIError } from "../errors/ai-error.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/human/errors.ts
4
+ /**
5
+ * A durable approval handler suspended the run rather than denying the
6
+ * call.
7
+ *
8
+ * **Role.** The sentinel a durable {@link import("./contracts").ApprovalHandler}
9
+ * throws after persisting a
10
+ * {@link import("./contracts").PendingInterrupt}. The approval
11
+ * middleware recognizes its own sentinel (an `instanceof` check) and
12
+ * re-throws so the agent run unwinds; the dispatch records it as a failed
13
+ * tool call carrying this typed error. The caller reads
14
+ * `error.interruptId` off the surfaced `result.error`, surfaces it to the
15
+ * reviewer, and later calls `ai.human.resume(...)`.
16
+ *
17
+ * Surfaced via `result.error` like every other `AIError` — the middleware
18
+ * never lets it escape `execute()`.
19
+ *
20
+ * @example
21
+ * if (result.error instanceof InterruptSuspendedError) {
22
+ * await notifyReviewer(result.error.interruptId);
23
+ * return { status: "awaiting-approval", interruptId: result.error.interruptId };
24
+ * }
25
+ */
26
+ var InterruptSuspendedError = class extends AIError {
27
+ constructor(message, options) {
28
+ super("INTERRUPT_SUSPENDED", message, options);
29
+ this.name = "InterruptSuspendedError";
30
+ this.interruptId = options.interruptId;
31
+ }
32
+ };
33
+ /**
34
+ * A human rejected a gated tool call.
35
+ *
36
+ * **Role.** The typed result of an `{ type: "reject", reason }` decision.
37
+ * The approval middleware throws it from `tool.before`; the agent
38
+ * dispatch records a failed tool call and writes a `role: "tool"`
39
+ * message carrying `reason`, so the **next trip lets the model
40
+ * self-correct** — exactly the existing tool-error feedback path.
41
+ *
42
+ * Surfaced via `result.error` like every other `AIError`.
43
+ *
44
+ * @example
45
+ * if (result.error instanceof ApprovalRejectedError) {
46
+ * logAudit(`${result.error.toolName} rejected: ${result.error.reason}`);
47
+ * }
48
+ */
49
+ var ApprovalRejectedError = class extends AIError {
50
+ constructor(message, options) {
51
+ super("APPROVAL_REJECTED", message, options);
52
+ this.name = "ApprovalRejectedError";
53
+ this.reason = options.reason;
54
+ this.toolName = options.toolName;
55
+ }
56
+ };
57
+
58
+ //#endregion
59
+ export { ApprovalRejectedError, InterruptSuspendedError };
60
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/errors.ts"],"sourcesContent":["import { AIError, type AIErrorOptions } from \"../errors/ai-error\";\nimport type { AIErrorCode } from \"../errors/error-code.type\";\n\n/**\n * Stable, machine-readable codes this package raises.\n *\n * `@warlock.js/ai`'s `AIErrorCode` is a closed union that (by design)\n * does not enumerate satellite-package codes, and this package must not\n * modify the core union. These codes are therefore declared locally and\n * narrowed into the base `AIError` `code` slot at the single `super(...)`\n * call — the runtime string is exactly what a consumer branches on via\n * `error.code`, identical to every other `AIError`.\n */\nexport type HumanErrorCode = \"INTERRUPT_SUSPENDED\" | \"APPROVAL_REJECTED\";\n\n/**\n * Payload for {@link InterruptSuspendedError}. `interruptId` is the key a\n * later `ai.human.resume(interruptId, decision)` call uses to replay the\n * decision against the persisted interrupt.\n */\nexport type InterruptSuspendedErrorOptions = AIErrorOptions & {\n /** Id of the persisted interrupt awaiting a decision. */\n interruptId: string;\n};\n\n/**\n * A durable approval handler suspended the run rather than denying the\n * call.\n *\n * **Role.** The sentinel a durable {@link import(\"./contracts\").ApprovalHandler}\n * throws after persisting a\n * {@link import(\"./contracts\").PendingInterrupt}. The approval\n * middleware recognizes its own sentinel (an `instanceof` check) and\n * re-throws so the agent run unwinds; the dispatch records it as a failed\n * tool call carrying this typed error. The caller reads\n * `error.interruptId` off the surfaced `result.error`, surfaces it to the\n * reviewer, and later calls `ai.human.resume(...)`.\n *\n * Surfaced via `result.error` like every other `AIError` — the middleware\n * never lets it escape `execute()`.\n *\n * @example\n * if (result.error instanceof InterruptSuspendedError) {\n * await notifyReviewer(result.error.interruptId);\n * return { status: \"awaiting-approval\", interruptId: result.error.interruptId };\n * }\n */\nexport class InterruptSuspendedError extends AIError {\n /** Id of the persisted interrupt awaiting a human decision. */\n public readonly interruptId: string;\n\n public constructor(message: string, options: InterruptSuspendedErrorOptions) {\n super(\"INTERRUPT_SUSPENDED\" as AIErrorCode, message, options);\n\n this.name = \"InterruptSuspendedError\";\n this.interruptId = options.interruptId;\n }\n}\n\n/**\n * Payload for {@link ApprovalRejectedError}. `reason` is the reviewer's\n * explanation, surfaced to the model on the next trip so it can\n * self-correct; `toolName` names the call that was rejected.\n */\nexport type ApprovalRejectedErrorOptions = AIErrorOptions & {\n /** The reviewer's explanation for rejecting the call. */\n reason: string;\n /** Name of the tool whose call was rejected. */\n toolName: string;\n};\n\n/**\n * A human rejected a gated tool call.\n *\n * **Role.** The typed result of an `{ type: \"reject\", reason }` decision.\n * The approval middleware throws it from `tool.before`; the agent\n * dispatch records a failed tool call and writes a `role: \"tool\"`\n * message carrying `reason`, so the **next trip lets the model\n * self-correct** — exactly the existing tool-error feedback path.\n *\n * Surfaced via `result.error` like every other `AIError`.\n *\n * @example\n * if (result.error instanceof ApprovalRejectedError) {\n * logAudit(`${result.error.toolName} rejected: ${result.error.reason}`);\n * }\n */\nexport class ApprovalRejectedError extends AIError {\n /** The reviewer's explanation for rejecting the call. */\n public readonly reason: string;\n\n /** Name of the tool whose call was rejected. */\n public readonly toolName: string;\n\n public constructor(message: string, options: ApprovalRejectedErrorOptions) {\n super(\"APPROVAL_REJECTED\" as AIErrorCode, message, options);\n\n this.name = \"ApprovalRejectedError\";\n this.reason = options.reason;\n this.toolName = options.toolName;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAa,0BAAb,cAA6C,QAAQ;CAInD,AAAO,YAAY,SAAiB,SAAyC;EAC3E,MAAM,uBAAsC,SAAS,OAAO;EAE5D,KAAK,OAAO;EACZ,KAAK,cAAc,QAAQ;CAC7B;AACF;;;;;;;;;;;;;;;;;AA8BA,IAAa,wBAAb,cAA2C,QAAQ;CAOjD,AAAO,YAAY,SAAiB,SAAuC;EACzE,MAAM,qBAAoC,SAAS,OAAO;EAE1D,KAAK,OAAO;EACZ,KAAK,SAAS,QAAQ;EACtB,KAAK,WAAW,QAAQ;CAC1B;AACF"}
@@ -0,0 +1,170 @@
1
+ import { generateRunId } from "../utils/generate-run-id.mjs";
2
+ import { ApprovalRejectedError, InterruptSuspendedError } from "./errors.mjs";
3
+ import { evaluatePolicy } from "./policy.mjs";
4
+ import { takeSeededDecision } from "./resume-seed.mjs";
5
+
6
+ //#region ../@warlock.js/ai/src/human/human-approval.ts
7
+ /** Default middleware name when {@link HumanApprovalOptions.name} is omitted. */
8
+ const DEFAULT_NAME = "human-approval";
9
+ /** Zero usage for a synthetic, no-LLM-spend short-circuit result. */
10
+ const ZERO_USAGE = Object.freeze({
11
+ input: 0,
12
+ output: 0,
13
+ total: 0
14
+ });
15
+ /**
16
+ * Derive the read-only {@link PolicyContext} the policy + request are
17
+ * built from out of the wrapping {@link MiddlewareToolContext}.
18
+ */
19
+ function toPolicyContext(ctx) {
20
+ return {
21
+ toolName: ctx.tool.name,
22
+ toolDescription: ctx.tool.description,
23
+ args: ctx.request.input,
24
+ agentName: ctx.agent.name,
25
+ tripIndex: ctx.tripIndex,
26
+ sessionId: ctx.options?.sessionId
27
+ };
28
+ }
29
+ /**
30
+ * Generate a stable, unique id for a pending interrupt. Shaped
31
+ * `${agentName}.${sessionId ?? "nosession"}.${tripIndex}.${random}` so a
32
+ * reviewer can eyeball the originating run, while the trailing random
33
+ * segment guarantees per-call uniqueness even within one trip.
34
+ */
35
+ function makeInterruptId(ctx) {
36
+ const session = ctx.options?.sessionId ?? "nosession";
37
+ const random = generateRunId("interrupt");
38
+ return `${ctx.agent.name}.${session}.${ctx.tripIndex}.${random}`;
39
+ }
40
+ /**
41
+ * Build the {@link ApprovalRequest} a human rules on, from the tool
42
+ * context and the policy-derived tags.
43
+ */
44
+ function buildRequest(ctx, interruptId, tags) {
45
+ return {
46
+ interruptId,
47
+ toolName: ctx.tool.name,
48
+ toolDescription: ctx.tool.description,
49
+ args: ctx.request.input,
50
+ context: {
51
+ agentName: ctx.agent.name,
52
+ tripIndex: ctx.tripIndex,
53
+ sessionId: ctx.options?.sessionId,
54
+ originalInput: ctx.input,
55
+ ...tags ? { tags } : {}
56
+ },
57
+ requestedAt: (/* @__PURE__ */ new Date()).toISOString()
58
+ };
59
+ }
60
+ /**
61
+ * Synthesize a failed {@link ToolInvokeResult} carrying a typed error.
62
+ *
63
+ * The approval middleware returns this from `tool.before` to
64
+ * **short-circuit** the real tool without throwing: the pipeline treats a
65
+ * defined return as the tool's result, the agent records a failed
66
+ * `ToolCall`, and the model sees `{ error }` on the next trip — exactly
67
+ * the existing tool-error feedback path. Used for both `reject`
68
+ * (`ApprovalRejectedError`) and durable suspend (`InterruptSuspendedError`).
69
+ */
70
+ function failedResult(error, toolName) {
71
+ const runId = generateRunId("tool");
72
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
73
+ return {
74
+ error,
75
+ usage: ZERO_USAGE,
76
+ report: {
77
+ runId,
78
+ rootRunId: runId,
79
+ name: toolName,
80
+ type: "tool",
81
+ status: "failed",
82
+ startedAt: nowIso,
83
+ endedAt: nowIso,
84
+ duration: 0,
85
+ usage: ZERO_USAGE,
86
+ children: []
87
+ }
88
+ };
89
+ }
90
+ /**
91
+ * Human-in-the-loop approval gate for an agent's tool calls — the
92
+ * middleware behind `ai.human.approval(options)`.
93
+ *
94
+ * **Role.** Pauses *before a specific tool call* and routes it to a human
95
+ * who can **approve** (run the real tool unchanged), **reject** (the model
96
+ * sees a typed error and self-corrects), or **edit** (run the tool with
97
+ * reviewer-replaced args). The dangerous subset is chosen by an
98
+ * {@link import("./contracts").InterruptPolicy} (allowlist / denylist /
99
+ * predicate); every other call passes through untouched.
100
+ *
101
+ * **One hook.** Declares only `tool.before`. On each tool dispatch it:
102
+ * 1. evaluates the policy — not gated → returns `void`, the real tool runs;
103
+ * 2. for a gated call, builds an {@link ApprovalRequest} and calls the
104
+ * {@link import("./contracts").ApprovalHandler};
105
+ * 3. applies the returned {@link ApprovalDecision}:
106
+ * - `approve` → returns `void`, the real tool runs;
107
+ * - `reject` → short-circuits a failed `ToolInvokeResult` carrying an
108
+ * {@link ApprovalRejectedError} (the reviewer's `reason` reaches the
109
+ * model);
110
+ * - `edit` → rewrites `ctx.request.input` to the reviewer's args and
111
+ * returns `void`, so the real tool runs with the edited args (schema
112
+ * validation still applies — bad edits surface as a tool error).
113
+ *
114
+ * **Durable mode.** When a `store` is configured and the handler throws
115
+ * {@link InterruptSuspendedError} (after persisting the interrupt
116
+ * out-of-band), the middleware catches its **own** sentinel and
117
+ * short-circuits a failed result carrying it — so the caller reads
118
+ * `result.error.interruptId` and later calls
119
+ * `ai.human.resume(interruptId, decision)`. The middleware **never throws
120
+ * out of the pipeline**: every outcome (skip, approve, reject, edit,
121
+ * suspend) returns normally; only a *handler bug* (a non-sentinel throw)
122
+ * propagates, and even then the agent dispatch funnels it onto
123
+ * `result.error` — `execute()` still never throws.
124
+ *
125
+ * @param options - Policy, handler, optional durable store, optional name.
126
+ * @returns An {@link AgentMiddleware} declaring a single `tool.before` hook.
127
+ *
128
+ * @example
129
+ * const support = ai.agent({
130
+ * model,
131
+ * tools: [refundCustomer],
132
+ * middleware: [
133
+ * humanApproval({
134
+ * policy: { type: "allowlist", tools: ["refundCustomer"], tags: () => ["money"] },
135
+ * handler: async (req) => ui.prompt(req), // { type: "edit", args: { amount: 5 } }
136
+ * }),
137
+ * ],
138
+ * });
139
+ */
140
+ function humanApproval(options) {
141
+ const name = options.name ?? DEFAULT_NAME;
142
+ const { policy, handler } = options;
143
+ return {
144
+ name,
145
+ tool: { async before(ctx) {
146
+ const verdict = evaluatePolicy(policy, toPolicyContext(ctx));
147
+ if (!verdict.requiresApproval) return;
148
+ const request = buildRequest(ctx, makeInterruptId(ctx), verdict.tags);
149
+ const seeded = takeSeededDecision(ctx.agent.name);
150
+ let decision;
151
+ if (seeded !== void 0) decision = seeded;
152
+ else try {
153
+ decision = await handler(request);
154
+ } catch (thrown) {
155
+ if (thrown instanceof InterruptSuspendedError) return failedResult(thrown, ctx.tool.name);
156
+ throw thrown;
157
+ }
158
+ if (decision.type === "approve") return;
159
+ if (decision.type === "reject") return failedResult(new ApprovalRejectedError(`Tool call "${ctx.tool.name}" rejected by reviewer — ${decision.reason}`, {
160
+ reason: decision.reason,
161
+ toolName: ctx.tool.name
162
+ }), ctx.tool.name);
163
+ ctx.request.input = decision.args;
164
+ } }
165
+ };
166
+ }
167
+
168
+ //#endregion
169
+ export { humanApproval };
170
+ //# sourceMappingURL=human-approval.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"human-approval.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/human-approval.ts"],"sourcesContent":["import type { AgentMiddleware } from \"../contracts/middleware/middleware.contract\";\nimport type { MiddlewareToolContext } from \"../contracts/middleware/middleware-context.type\";\nimport type { BaseReport } from \"../contracts/result/base-report.type\";\nimport type { Usage } from \"../contracts/result/usage.type\";\nimport type { AIError } from \"../errors/ai-error\";\nimport type { ToolInvokeResult } from \"../tool/tool\";\nimport { generateRunId } from \"../utils/generate-run-id\";\nimport type {\n ApprovalDecision,\n ApprovalRequest,\n HumanApprovalOptions,\n PolicyContext,\n} from \"./contracts\";\nimport { ApprovalRejectedError, InterruptSuspendedError } from \"./errors\";\nimport { evaluatePolicy } from \"./policy\";\nimport { takeSeededDecision } from \"./resume-seed\";\n\n/** Default middleware name when {@link HumanApprovalOptions.name} is omitted. */\nconst DEFAULT_NAME = \"human-approval\";\n\n/** Zero usage for a synthetic, no-LLM-spend short-circuit result. */\nconst ZERO_USAGE: Usage = Object.freeze({ input: 0, output: 0, total: 0 });\n\n/**\n * Mutable view of {@link MiddlewareToolContext.request} used only to\n * apply an `edit` decision. The context types `request.input` as\n * `readonly`, but the agent dispatch reads `request.input` (the SAME\n * object) when it invokes the real tool *after* the `tool.before`\n * pipeline returns — so reassigning it here is how an edited-args\n * decision reaches the tool. This narrow local type makes that one\n * deliberate write explicit instead of casting away the whole context.\n */\ninterface MutableToolRequest {\n input: unknown;\n}\n\n/**\n * Derive the read-only {@link PolicyContext} the policy + request are\n * built from out of the wrapping {@link MiddlewareToolContext}.\n */\nfunction toPolicyContext(ctx: MiddlewareToolContext): PolicyContext {\n return {\n toolName: ctx.tool.name,\n toolDescription: ctx.tool.description,\n args: ctx.request.input,\n agentName: ctx.agent.name,\n tripIndex: ctx.tripIndex,\n sessionId: ctx.options?.sessionId,\n };\n}\n\n/**\n * Generate a stable, unique id for a pending interrupt. Shaped\n * `${agentName}.${sessionId ?? \"nosession\"}.${tripIndex}.${random}` so a\n * reviewer can eyeball the originating run, while the trailing random\n * segment guarantees per-call uniqueness even within one trip.\n */\nfunction makeInterruptId(ctx: MiddlewareToolContext): string {\n const session = ctx.options?.sessionId ?? \"nosession\";\n const random = generateRunId(\"interrupt\");\n\n return `${ctx.agent.name}.${session}.${ctx.tripIndex}.${random}`;\n}\n\n/**\n * Build the {@link ApprovalRequest} a human rules on, from the tool\n * context and the policy-derived tags.\n */\nfunction buildRequest(\n ctx: MiddlewareToolContext,\n interruptId: string,\n tags: string[] | undefined,\n): ApprovalRequest {\n return {\n interruptId,\n toolName: ctx.tool.name,\n toolDescription: ctx.tool.description,\n args: ctx.request.input,\n context: {\n agentName: ctx.agent.name,\n tripIndex: ctx.tripIndex,\n sessionId: ctx.options?.sessionId,\n originalInput: ctx.input,\n ...(tags ? { tags } : {}),\n },\n requestedAt: new Date().toISOString(),\n };\n}\n\n/**\n * Synthesize a failed {@link ToolInvokeResult} carrying a typed error.\n *\n * The approval middleware returns this from `tool.before` to\n * **short-circuit** the real tool without throwing: the pipeline treats a\n * defined return as the tool's result, the agent records a failed\n * `ToolCall`, and the model sees `{ error }` on the next trip — exactly\n * the existing tool-error feedback path. Used for both `reject`\n * (`ApprovalRejectedError`) and durable suspend (`InterruptSuspendedError`).\n */\nfunction failedResult(error: AIError, toolName: string): ToolInvokeResult<unknown> {\n const runId = generateRunId(\"tool\");\n const nowIso = new Date().toISOString();\n\n const report: BaseReport = {\n runId,\n rootRunId: runId,\n name: toolName,\n type: \"tool\",\n status: \"failed\",\n startedAt: nowIso,\n endedAt: nowIso,\n duration: 0,\n usage: ZERO_USAGE,\n children: [],\n };\n\n return { error, usage: ZERO_USAGE, report };\n}\n\n/**\n * Human-in-the-loop approval gate for an agent's tool calls — the\n * middleware behind `ai.human.approval(options)`.\n *\n * **Role.** Pauses *before a specific tool call* and routes it to a human\n * who can **approve** (run the real tool unchanged), **reject** (the model\n * sees a typed error and self-corrects), or **edit** (run the tool with\n * reviewer-replaced args). The dangerous subset is chosen by an\n * {@link import(\"./contracts\").InterruptPolicy} (allowlist / denylist /\n * predicate); every other call passes through untouched.\n *\n * **One hook.** Declares only `tool.before`. On each tool dispatch it:\n * 1. evaluates the policy — not gated → returns `void`, the real tool runs;\n * 2. for a gated call, builds an {@link ApprovalRequest} and calls the\n * {@link import(\"./contracts\").ApprovalHandler};\n * 3. applies the returned {@link ApprovalDecision}:\n * - `approve` → returns `void`, the real tool runs;\n * - `reject` → short-circuits a failed `ToolInvokeResult` carrying an\n * {@link ApprovalRejectedError} (the reviewer's `reason` reaches the\n * model);\n * - `edit` → rewrites `ctx.request.input` to the reviewer's args and\n * returns `void`, so the real tool runs with the edited args (schema\n * validation still applies — bad edits surface as a tool error).\n *\n * **Durable mode.** When a `store` is configured and the handler throws\n * {@link InterruptSuspendedError} (after persisting the interrupt\n * out-of-band), the middleware catches its **own** sentinel and\n * short-circuits a failed result carrying it — so the caller reads\n * `result.error.interruptId` and later calls\n * `ai.human.resume(interruptId, decision)`. The middleware **never throws\n * out of the pipeline**: every outcome (skip, approve, reject, edit,\n * suspend) returns normally; only a *handler bug* (a non-sentinel throw)\n * propagates, and even then the agent dispatch funnels it onto\n * `result.error` — `execute()` still never throws.\n *\n * @param options - Policy, handler, optional durable store, optional name.\n * @returns An {@link AgentMiddleware} declaring a single `tool.before` hook.\n *\n * @example\n * const support = ai.agent({\n * model,\n * tools: [refundCustomer],\n * middleware: [\n * humanApproval({\n * policy: { type: \"allowlist\", tools: [\"refundCustomer\"], tags: () => [\"money\"] },\n * handler: async (req) => ui.prompt(req), // { type: \"edit\", args: { amount: 5 } }\n * }),\n * ],\n * });\n */\nexport function humanApproval(options: HumanApprovalOptions): AgentMiddleware {\n const name = options.name ?? DEFAULT_NAME;\n const { policy, handler } = options;\n\n return {\n name,\n tool: {\n async before(\n ctx: MiddlewareToolContext,\n ): Promise<ToolInvokeResult<unknown> | void> {\n const verdict = evaluatePolicy(policy, toPolicyContext(ctx));\n\n // Not gated — let the real tool run unchanged.\n if (!verdict.requiresApproval) {\n return;\n }\n\n const interruptId = makeInterruptId(ctx);\n const request = buildRequest(ctx, interruptId, verdict.tags);\n\n // Durable resume: `ai.human.resume(...)` re-runs this same agent\n // with the human's decision pre-seeded (keyed by agent name). On a\n // hit we replay the seeded decision exactly once and skip the\n // author's handler entirely — the gated call resolves to the\n // ruling instead of pausing again.\n const seeded = takeSeededDecision(ctx.agent.name);\n\n let decision: ApprovalDecision;\n\n if (seeded !== undefined) {\n decision = seeded;\n } else {\n try {\n decision = await handler(request);\n } catch (thrown) {\n // A durable handler signals suspension by throwing our OWN\n // sentinel after persisting the interrupt. Recognize it and\n // short-circuit a failed result carrying it — the caller reads\n // `error.interruptId` and resumes later. Any OTHER throw is a\n // handler bug; re-throw so the agent dispatch funnels it onto\n // `result.error` (we never swallow a bug into silent approval).\n if (thrown instanceof InterruptSuspendedError) {\n return failedResult(thrown, ctx.tool.name);\n }\n\n throw thrown;\n }\n }\n\n if (decision.type === \"approve\") {\n // Run the real tool with the model's original args.\n return;\n }\n\n if (decision.type === \"reject\") {\n const error = new ApprovalRejectedError(\n `Tool call \"${ctx.tool.name}\" rejected by reviewer — ${decision.reason}`,\n { reason: decision.reason, toolName: ctx.tool.name },\n );\n\n return failedResult(error, ctx.tool.name);\n }\n\n // `edit` — rewrite the pending args, then let the real tool run.\n // The agent dispatch reads `request.input` (this same object) when\n // it invokes the tool after this hook returns, so the reassignment\n // takes effect. Bad edits still fail the tool's own schema check.\n (ctx.request as unknown as MutableToolRequest).input = decision.args;\n\n return;\n },\n },\n };\n}\n"],"mappings":";;;;;;;AAkBA,MAAM,eAAe;;AAGrB,MAAM,aAAoB,OAAO,OAAO;CAAE,OAAO;CAAG,QAAQ;CAAG,OAAO;AAAE,CAAC;;;;;AAmBzE,SAAS,gBAAgB,KAA2C;CAClE,OAAO;EACL,UAAU,IAAI,KAAK;EACnB,iBAAiB,IAAI,KAAK;EAC1B,MAAM,IAAI,QAAQ;EAClB,WAAW,IAAI,MAAM;EACrB,WAAW,IAAI;EACf,WAAW,IAAI,SAAS;CAC1B;AACF;;;;;;;AAQA,SAAS,gBAAgB,KAAoC;CAC3D,MAAM,UAAU,IAAI,SAAS,aAAa;CAC1C,MAAM,SAAS,cAAc,WAAW;CAExC,OAAO,GAAG,IAAI,MAAM,KAAK,GAAG,QAAQ,GAAG,IAAI,UAAU,GAAG;AAC1D;;;;;AAMA,SAAS,aACP,KACA,aACA,MACiB;CACjB,OAAO;EACL;EACA,UAAU,IAAI,KAAK;EACnB,iBAAiB,IAAI,KAAK;EAC1B,MAAM,IAAI,QAAQ;EAClB,SAAS;GACP,WAAW,IAAI,MAAM;GACrB,WAAW,IAAI;GACf,WAAW,IAAI,SAAS;GACxB,eAAe,IAAI;GACnB,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC;EACzB;EACA,8BAAa,IAAI,KAAK,EAAC,CAAC,YAAY;CACtC;AACF;;;;;;;;;;;AAYA,SAAS,aAAa,OAAgB,UAA6C;CACjF,MAAM,QAAQ,cAAc,MAAM;CAClC,MAAM,0BAAS,IAAI,KAAK,EAAC,CAAC,YAAY;CAetC,OAAO;EAAE;EAAO,OAAO;EAAY;GAZjC;GACA,WAAW;GACX,MAAM;GACN,MAAM;GACN,QAAQ;GACR,WAAW;GACX,SAAS;GACT,UAAU;GACV,OAAO;GACP,UAAU,CAAC;EAG2B;CAAE;AAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,cAAc,SAAgD;CAC5E,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,EAAE,QAAQ,YAAY;CAE5B,OAAO;EACL;EACA,MAAM,EACJ,MAAM,OACJ,KAC2C;GAC3C,MAAM,UAAU,eAAe,QAAQ,gBAAgB,GAAG,CAAC;GAG3D,IAAI,CAAC,QAAQ,kBACX;GAIF,MAAM,UAAU,aAAa,KADT,gBAAgB,GACQ,GAAG,QAAQ,IAAI;GAO3D,MAAM,SAAS,mBAAmB,IAAI,MAAM,IAAI;GAEhD,IAAI;GAEJ,IAAI,WAAW,QACb,WAAW;QAEX,IAAI;IACF,WAAW,MAAM,QAAQ,OAAO;GAClC,SAAS,QAAQ;IAOf,IAAI,kBAAkB,yBACpB,OAAO,aAAa,QAAQ,IAAI,KAAK,IAAI;IAG3C,MAAM;GACR;GAGF,IAAI,SAAS,SAAS,WAEpB;GAGF,IAAI,SAAS,SAAS,UAMpB,OAAO,aAAa,IALF,sBAChB,cAAc,IAAI,KAAK,KAAK,2BAA2B,SAAS,UAChE;IAAE,QAAQ,SAAS;IAAQ,UAAU,IAAI,KAAK;GAAK,CAG7B,GAAG,IAAI,KAAK,IAAI;GAO1C,AAAC,IAAI,QAA0C,QAAQ,SAAS;EAGlE,EACF;CACF;AACF"}
@@ -0,0 +1,67 @@
1
+ //#region ../@warlock.js/ai/src/human/policy.ts
2
+ /**
3
+ * A verdict that lets a call through untouched. Frozen and shared so the
4
+ * (common) skip path allocates nothing.
5
+ */
6
+ const SKIP = Object.freeze({ requiresApproval: false });
7
+ /**
8
+ * Normalize an author-supplied tags array into the verdict shape — an
9
+ * empty array is treated as "no tags" so callers never have to
10
+ * distinguish `[]` from `undefined`.
11
+ */
12
+ function withTags(tags) {
13
+ if (tags === void 0 || tags.length === 0) return { requiresApproval: true };
14
+ return {
15
+ requiresApproval: true,
16
+ tags
17
+ };
18
+ }
19
+ /**
20
+ * Decide whether a single pending tool call requires human approval —
21
+ * the pure core behind the `ai.human.approval` middleware's gate.
22
+ *
23
+ * **Pure.** No IO, no throwing, no mutation of `policy` or `context`. The
24
+ * middleware calls this once per tool dispatch and routes to a human only
25
+ * when {@link PolicyVerdict.requiresApproval} is `true`.
26
+ *
27
+ * **The three rule types** ({@link InterruptPolicy}):
28
+ * - `allowlist` — gate the call **only** when its tool name is listed; an
29
+ * optional `tags(toolName)` callback derives the verdict tags.
30
+ * - `denylist` — gate **every** call **except** the listed tool names;
31
+ * the same optional `tags(toolName)` callback applies to the gated
32
+ * (non-listed) name.
33
+ * - `predicate` — gate the call when `requiresApproval(context)` returns a
34
+ * truthy result. A non-empty `string[]` both gates the call **and**
35
+ * supplies the verdict tags; `true` gates with no tags; `false` (or an
36
+ * **empty** array — "no rule matched") lets the call through.
37
+ *
38
+ * @param policy - The interrupt policy to evaluate.
39
+ * @param context - The read-only view of the pending tool call.
40
+ * @returns A {@link PolicyVerdict} — gate-or-skip plus any tags.
41
+ *
42
+ * @example
43
+ * const verdict = evaluatePolicy(
44
+ * { type: "allowlist", tools: ["refundCustomer"], tags: () => ["money"] },
45
+ * { toolName: "refundCustomer", args: { amount: 50 }, agentName: "support", tripIndex: 0 },
46
+ * );
47
+ * // → { requiresApproval: true, tags: ["money"] }
48
+ */
49
+ function evaluatePolicy(policy, context) {
50
+ if (policy.type === "allowlist") {
51
+ if (!policy.tools.includes(context.toolName)) return SKIP;
52
+ return withTags(policy.tags?.(context.toolName));
53
+ }
54
+ if (policy.type === "denylist") {
55
+ if (policy.tools.includes(context.toolName)) return SKIP;
56
+ return withTags(policy.tags?.(context.toolName));
57
+ }
58
+ const outcome = policy.requiresApproval(context);
59
+ if (outcome === false) return SKIP;
60
+ if (outcome === true) return { requiresApproval: true };
61
+ if (outcome.length === 0) return SKIP;
62
+ return withTags(outcome);
63
+ }
64
+
65
+ //#endregion
66
+ export { evaluatePolicy };
67
+ //# sourceMappingURL=policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/ai/src/human/policy.ts"],"sourcesContent":["import type { InterruptPolicy, PolicyContext } from \"./contracts\";\n\n/**\n * Verdict of evaluating an {@link InterruptPolicy} against a single\n * pending tool call.\n *\n * - `requiresApproval` — `true` when the call must be routed to a human\n * before the real tool runs; `false` when the policy lets it through\n * untouched.\n * - `tags` — author-supplied labels from the matched rule (e.g.\n * `\"destructive\"`, `\"money\"`), surfaced verbatim on the resulting\n * `ApprovalRequest.context.tags`. Only ever present when\n * `requiresApproval` is `true`; `undefined` when the rule produced no\n * tags.\n */\nexport interface PolicyVerdict {\n /** Whether this tool call must be approved by a human. */\n requiresApproval: boolean;\n\n /** Author-supplied tags from the matched rule, when any. */\n tags?: string[];\n}\n\n/**\n * A verdict that lets a call through untouched. Frozen and shared so the\n * (common) skip path allocates nothing.\n */\nconst SKIP: PolicyVerdict = Object.freeze({ requiresApproval: false });\n\n/**\n * Normalize an author-supplied tags array into the verdict shape — an\n * empty array is treated as \"no tags\" so callers never have to\n * distinguish `[]` from `undefined`.\n */\nfunction withTags(tags: string[] | undefined): PolicyVerdict {\n if (tags === undefined || tags.length === 0) {\n return { requiresApproval: true };\n }\n\n return { requiresApproval: true, tags };\n}\n\n/**\n * Decide whether a single pending tool call requires human approval —\n * the pure core behind the `ai.human.approval` middleware's gate.\n *\n * **Pure.** No IO, no throwing, no mutation of `policy` or `context`. The\n * middleware calls this once per tool dispatch and routes to a human only\n * when {@link PolicyVerdict.requiresApproval} is `true`.\n *\n * **The three rule types** ({@link InterruptPolicy}):\n * - `allowlist` — gate the call **only** when its tool name is listed; an\n * optional `tags(toolName)` callback derives the verdict tags.\n * - `denylist` — gate **every** call **except** the listed tool names;\n * the same optional `tags(toolName)` callback applies to the gated\n * (non-listed) name.\n * - `predicate` — gate the call when `requiresApproval(context)` returns a\n * truthy result. A non-empty `string[]` both gates the call **and**\n * supplies the verdict tags; `true` gates with no tags; `false` (or an\n * **empty** array — \"no rule matched\") lets the call through.\n *\n * @param policy - The interrupt policy to evaluate.\n * @param context - The read-only view of the pending tool call.\n * @returns A {@link PolicyVerdict} — gate-or-skip plus any tags.\n *\n * @example\n * const verdict = evaluatePolicy(\n * { type: \"allowlist\", tools: [\"refundCustomer\"], tags: () => [\"money\"] },\n * { toolName: \"refundCustomer\", args: { amount: 50 }, agentName: \"support\", tripIndex: 0 },\n * );\n * // → { requiresApproval: true, tags: [\"money\"] }\n */\nexport function evaluatePolicy(\n policy: InterruptPolicy,\n context: PolicyContext,\n): PolicyVerdict {\n if (policy.type === \"allowlist\") {\n if (!policy.tools.includes(context.toolName)) {\n return SKIP;\n }\n\n return withTags(policy.tags?.(context.toolName));\n }\n\n if (policy.type === \"denylist\") {\n if (policy.tools.includes(context.toolName)) {\n return SKIP;\n }\n\n return withTags(policy.tags?.(context.toolName));\n }\n\n // Predicate: a truthy result gates the call; a `string[]` doubles as the\n // verdict tags.\n const outcome = policy.requiresApproval(context);\n\n if (outcome === false) {\n return SKIP;\n }\n\n if (outcome === true) {\n return { requiresApproval: true };\n }\n\n // `outcome` is a `string[]`. Per the contract, an EMPTY array means \"no\n // rule matched\" and skips approval; a non-empty array gates the call and\n // doubles as the verdict tags.\n if (outcome.length === 0) {\n return SKIP;\n }\n\n return withTags(outcome);\n}\n"],"mappings":";;;;;AA2BA,MAAM,OAAsB,OAAO,OAAO,EAAE,kBAAkB,MAAM,CAAC;;;;;;AAOrE,SAAS,SAAS,MAA2C;CAC3D,IAAI,SAAS,UAAa,KAAK,WAAW,GACxC,OAAO,EAAE,kBAAkB,KAAK;CAGlC,OAAO;EAAE,kBAAkB;EAAM;CAAK;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,eACd,QACA,SACe;CACf,IAAI,OAAO,SAAS,aAAa;EAC/B,IAAI,CAAC,OAAO,MAAM,SAAS,QAAQ,QAAQ,GACzC,OAAO;EAGT,OAAO,SAAS,OAAO,OAAO,QAAQ,QAAQ,CAAC;CACjD;CAEA,IAAI,OAAO,SAAS,YAAY;EAC9B,IAAI,OAAO,MAAM,SAAS,QAAQ,QAAQ,GACxC,OAAO;EAGT,OAAO,SAAS,OAAO,OAAO,QAAQ,QAAQ,CAAC;CACjD;CAIA,MAAM,UAAU,OAAO,iBAAiB,OAAO;CAE/C,IAAI,YAAY,OACd,OAAO;CAGT,IAAI,YAAY,MACd,OAAO,EAAE,kBAAkB,KAAK;CAMlC,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,OAAO,SAAS,OAAO;AACzB"}