@warlock.js/ai 4.3.0 → 4.5.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 (541) hide show
  1. package/CHANGELOG.md +52 -48
  2. package/cjs/index.cjs +221 -14144
  3. package/cjs/src-C02yzsLs.cjs +22991 -0
  4. package/cjs/src-C02yzsLs.cjs.map +1 -0
  5. package/cjs/src-DFibP2FQ.cjs +30 -0
  6. package/esm/agent/agent-config.type.d.mts +90 -1
  7. package/esm/agent/agent-config.type.d.mts.map +1 -1
  8. package/esm/agent/agent-input-builder.mjs +27 -6
  9. package/esm/agent/agent-input-builder.mjs.map +1 -1
  10. package/esm/agent/agent.d.mts +40 -1
  11. package/esm/agent/agent.d.mts.map +1 -1
  12. package/esm/agent/agent.mjs +203 -30
  13. package/esm/agent/agent.mjs.map +1 -1
  14. package/esm/agent/index.d.mts +2 -1
  15. package/esm/agent/index.mjs +1 -0
  16. package/esm/agent/judge-config.type.d.mts +33 -0
  17. package/esm/agent/judge-config.type.d.mts.map +1 -0
  18. package/esm/agent/judge-config.type.mjs +13 -0
  19. package/esm/agent/judge-config.type.mjs.map +1 -0
  20. package/esm/ai-openai/src/embedder.mjs +4 -0
  21. package/esm/ai-openai/src/index.mjs +4 -0
  22. package/esm/ai-openai/src/model.mjs +5 -0
  23. package/esm/ai-openai/src/sdk.mjs +6 -0
  24. package/esm/ai-openai/src/utils/index.mjs +4 -0
  25. package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
  26. package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
  27. package/esm/ai.d.mts +119 -53
  28. package/esm/ai.d.mts.map +1 -1
  29. package/esm/ai.mjs +43 -8
  30. package/esm/ai.mjs.map +1 -1
  31. package/esm/batch/batch.d.mts.map +1 -1
  32. package/esm/batch/batch.mjs +21 -1
  33. package/esm/batch/batch.mjs.map +1 -1
  34. package/esm/batch/batch.type.d.mts +11 -4
  35. package/esm/batch/batch.type.d.mts.map +1 -1
  36. package/esm/config.d.mts +39 -3
  37. package/esm/config.d.mts.map +1 -1
  38. package/esm/config.mjs +26 -2
  39. package/esm/config.mjs.map +1 -1
  40. package/esm/contracts/agent/agent-options.type.d.mts +11 -3
  41. package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
  42. package/esm/contracts/agent/eval.type.d.mts +43 -2
  43. package/esm/contracts/agent/eval.type.d.mts.map +1 -1
  44. package/esm/contracts/attachment-policy.type.d.mts +51 -0
  45. package/esm/contracts/attachment-policy.type.d.mts.map +1 -0
  46. package/esm/contracts/attachment.type.d.mts +16 -7
  47. package/esm/contracts/attachment.type.d.mts.map +1 -1
  48. package/esm/contracts/content-part.type.d.mts +14 -5
  49. package/esm/contracts/content-part.type.d.mts.map +1 -1
  50. package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
  51. package/esm/contracts/index.d.mts +6 -4
  52. package/esm/contracts/model.contract.d.mts +11 -8
  53. package/esm/contracts/model.contract.d.mts.map +1 -1
  54. package/esm/contracts/orchestrator/index.d.mts +1 -0
  55. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +31 -2
  56. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
  57. package/esm/contracts/orchestrator/session-lock.contract.d.mts +47 -0
  58. package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -0
  59. package/esm/contracts/planner/index.d.mts +1 -1
  60. package/esm/contracts/planner/planner-config.type.d.mts +31 -0
  61. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
  62. package/esm/contracts/planner/planner-execute-options.type.d.mts +48 -1
  63. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
  64. package/esm/contracts/planner/planner-result.type.d.mts +19 -5
  65. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
  66. package/esm/contracts/planner/planner.contract.d.mts +1 -1
  67. package/esm/contracts/result/agent-result.type.d.mts +6 -4
  68. package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
  69. package/esm/contracts/result/base-report.type.d.mts +21 -3
  70. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  71. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  72. package/esm/contracts/result/execution-report.type.d.mts +53 -1
  73. package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
  74. package/esm/contracts/result/orchestrator-result.type.d.mts +15 -11
  75. package/esm/contracts/result/orchestrator-result.type.d.mts.map +1 -1
  76. package/esm/contracts/result/supervisor-result.type.d.mts +13 -1
  77. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
  78. package/esm/contracts/result/tool-call.type.d.mts +2 -2
  79. package/esm/contracts/result/tool-call.type.d.mts.map +1 -1
  80. package/esm/contracts/result/workflow-result.type.d.mts +1 -0
  81. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
  82. package/esm/contracts/supervisor/supervisor-config.type.d.mts +29 -0
  83. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  84. package/esm/contracts/system-prompt.contract.d.mts +103 -1
  85. package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
  86. package/esm/contracts/team/index.d.mts +1 -0
  87. package/esm/contracts/team/team-config.type.d.mts +127 -0
  88. package/esm/contracts/team/team-config.type.d.mts.map +1 -0
  89. package/esm/contracts/tool.contract.d.mts +4 -2
  90. package/esm/contracts/tool.contract.d.mts.map +1 -1
  91. package/esm/contracts/workflow/step.contract.d.mts +30 -5
  92. package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
  93. package/esm/contracts/workflow/workflow.contract.d.mts +16 -0
  94. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  95. package/esm/errors/error-code.type.d.mts +1 -1
  96. package/esm/errors/index.d.mts +1 -0
  97. package/esm/errors/index.mjs +1 -0
  98. package/esm/errors/outbound-policy-error.d.mts +27 -0
  99. package/esm/errors/outbound-policy-error.d.mts.map +1 -0
  100. package/esm/errors/outbound-policy-error.mjs +32 -0
  101. package/esm/errors/outbound-policy-error.mjs.map +1 -0
  102. package/esm/eval/dataset.d.mts +28 -0
  103. package/esm/eval/dataset.d.mts.map +1 -0
  104. package/esm/eval/dataset.mjs +112 -0
  105. package/esm/eval/dataset.mjs.map +1 -0
  106. package/esm/eval/dataset.type.d.mts +53 -0
  107. package/esm/eval/dataset.type.d.mts.map +1 -0
  108. package/esm/eval/eval-runner.d.mts.map +1 -1
  109. package/esm/eval/eval-runner.mjs +16 -2
  110. package/esm/eval/eval-runner.mjs.map +1 -1
  111. package/esm/eval/index.d.mts +20 -1
  112. package/esm/eval/index.d.mts.map +1 -1
  113. package/esm/eval/index.mjs +20 -2
  114. package/esm/eval/index.mjs.map +1 -1
  115. package/esm/eval/regression.d.mts +30 -0
  116. package/esm/eval/regression.d.mts.map +1 -0
  117. package/esm/eval/regression.mjs +51 -0
  118. package/esm/eval/regression.mjs.map +1 -0
  119. package/esm/eval/report-json.d.mts +30 -0
  120. package/esm/eval/report-json.d.mts.map +1 -0
  121. package/esm/eval/report-json.mjs +33 -0
  122. package/esm/eval/report-json.mjs.map +1 -0
  123. package/esm/eval/report-junit.d.mts +22 -0
  124. package/esm/eval/report-junit.d.mts.map +1 -0
  125. package/esm/eval/report-junit.mjs +60 -0
  126. package/esm/eval/report-junit.mjs.map +1 -0
  127. package/esm/guard/contracts/guard-options.type.d.mts +165 -0
  128. package/esm/guard/contracts/guard-options.type.d.mts.map +1 -0
  129. package/esm/guard/contracts/guardrail.contract.d.mts +78 -0
  130. package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -0
  131. package/esm/guard/contracts/index.d.mts +4 -0
  132. package/esm/guard/contracts/openai-client.contract.d.mts +51 -0
  133. package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -0
  134. package/esm/guard/contracts/verdict.type.d.mts +76 -0
  135. package/esm/guard/contracts/verdict.type.d.mts.map +1 -0
  136. package/esm/guard/detectors/index.d.mts +4 -0
  137. package/esm/guard/detectors/index.mjs +6 -0
  138. package/esm/guard/detectors/injection.d.mts +34 -0
  139. package/esm/guard/detectors/injection.d.mts.map +1 -0
  140. package/esm/guard/detectors/injection.mjs +254 -0
  141. package/esm/guard/detectors/injection.mjs.map +1 -0
  142. package/esm/guard/detectors/moderation.d.mts +32 -0
  143. package/esm/guard/detectors/moderation.d.mts.map +1 -0
  144. package/esm/guard/detectors/moderation.mjs +134 -0
  145. package/esm/guard/detectors/moderation.mjs.map +1 -0
  146. package/esm/guard/detectors/pii.d.mts +41 -0
  147. package/esm/guard/detectors/pii.d.mts.map +1 -0
  148. package/esm/guard/detectors/pii.mjs +199 -0
  149. package/esm/guard/detectors/pii.mjs.map +1 -0
  150. package/esm/guard/detectors/topic.d.mts +29 -0
  151. package/esm/guard/detectors/topic.d.mts.map +1 -0
  152. package/esm/guard/detectors/topic.mjs +99 -0
  153. package/esm/guard/detectors/topic.mjs.map +1 -0
  154. package/esm/guard/errors.d.mts +12 -0
  155. package/esm/guard/errors.d.mts.map +1 -0
  156. package/esm/guard/errors.mjs +18 -0
  157. package/esm/guard/errors.mjs.map +1 -0
  158. package/esm/guard/guard.d.mts +67 -0
  159. package/esm/guard/guard.d.mts.map +1 -0
  160. package/esm/guard/guard.mjs +209 -0
  161. package/esm/guard/guard.mjs.map +1 -0
  162. package/esm/guard/guardrail.d.mts +39 -0
  163. package/esm/guard/guardrail.d.mts.map +1 -0
  164. package/esm/guard/guardrail.mjs +22 -0
  165. package/esm/guard/guardrail.mjs.map +1 -0
  166. package/esm/human/contracts/approval.type.d.mts +154 -0
  167. package/esm/human/contracts/approval.type.d.mts.map +1 -0
  168. package/esm/human/contracts/human-approval.type.d.mts +38 -0
  169. package/esm/human/contracts/human-approval.type.d.mts.map +1 -0
  170. package/esm/human/contracts/index.d.mts +4 -0
  171. package/esm/human/contracts/interrupt-store.contract.d.mts +112 -0
  172. package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -0
  173. package/esm/human/contracts/resume.type.d.mts +77 -0
  174. package/esm/human/contracts/resume.type.d.mts.map +1 -0
  175. package/esm/human/errors.d.mts +84 -0
  176. package/esm/human/errors.d.mts.map +1 -0
  177. package/esm/human/errors.mjs +60 -0
  178. package/esm/human/errors.mjs.map +1 -0
  179. package/esm/human/human-approval.d.mts +57 -0
  180. package/esm/human/human-approval.d.mts.map +1 -0
  181. package/esm/human/human-approval.mjs +170 -0
  182. package/esm/human/human-approval.mjs.map +1 -0
  183. package/esm/human/policy.d.mts +55 -0
  184. package/esm/human/policy.d.mts.map +1 -0
  185. package/esm/human/policy.mjs +67 -0
  186. package/esm/human/policy.mjs.map +1 -0
  187. package/esm/human/register.mjs +37 -0
  188. package/esm/human/register.mjs.map +1 -0
  189. package/esm/human/resume-seed.mjs +53 -0
  190. package/esm/human/resume-seed.mjs.map +1 -0
  191. package/esm/human/resume.d.mts +54 -0
  192. package/esm/human/resume.d.mts.map +1 -0
  193. package/esm/human/resume.mjs +121 -0
  194. package/esm/human/resume.mjs.map +1 -0
  195. package/esm/human/stores/index.mjs +5 -0
  196. package/esm/human/stores/memory.d.mts +30 -0
  197. package/esm/human/stores/memory.d.mts.map +1 -0
  198. package/esm/human/stores/memory.mjs +91 -0
  199. package/esm/human/stores/memory.mjs.map +1 -0
  200. package/esm/human/stores/pg.d.mts +59 -0
  201. package/esm/human/stores/pg.d.mts.map +1 -0
  202. package/esm/human/stores/pg.mjs +220 -0
  203. package/esm/human/stores/pg.mjs.map +1 -0
  204. package/esm/human/stores/redis.d.mts +56 -0
  205. package/esm/human/stores/redis.d.mts.map +1 -0
  206. package/esm/human/stores/redis.mjs +201 -0
  207. package/esm/human/stores/redis.mjs.map +1 -0
  208. package/esm/index.d.mts +113 -22
  209. package/esm/index.mjs +82 -11
  210. package/esm/middleware/builtins/budget.mjs +6 -2
  211. package/esm/middleware/builtins/budget.mjs.map +1 -1
  212. package/esm/middleware/utils/extract-user-text.d.mts +8 -1
  213. package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
  214. package/esm/middleware/utils/extract-user-text.mjs +8 -1
  215. package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
  216. package/esm/object-stream/index.d.mts +2 -0
  217. package/esm/object-stream/index.mjs +4 -0
  218. package/esm/object-stream/parse-partial-json.d.mts +22 -0
  219. package/esm/object-stream/parse-partial-json.d.mts.map +1 -0
  220. package/esm/object-stream/parse-partial-json.mjs +78 -0
  221. package/esm/object-stream/parse-partial-json.mjs.map +1 -0
  222. package/esm/object-stream/stream-object.d.mts +68 -0
  223. package/esm/object-stream/stream-object.d.mts.map +1 -0
  224. package/esm/object-stream/stream-object.mjs +104 -0
  225. package/esm/object-stream/stream-object.mjs.map +1 -0
  226. package/esm/observe/index.mjs +4 -0
  227. package/esm/observe/observer-registry.d.mts +30 -0
  228. package/esm/observe/observer-registry.d.mts.map +1 -0
  229. package/esm/observe/observer-registry.mjs +51 -0
  230. package/esm/observe/observer-registry.mjs.map +1 -0
  231. package/esm/observe/observer.contract.d.mts +40 -0
  232. package/esm/observe/observer.contract.d.mts.map +1 -0
  233. package/esm/observe/resolve-observers.d.mts +40 -0
  234. package/esm/observe/resolve-observers.d.mts.map +1 -0
  235. package/esm/observe/resolve-observers.mjs +73 -0
  236. package/esm/observe/resolve-observers.mjs.map +1 -0
  237. package/esm/orchestrator/execution.d.mts.map +1 -1
  238. package/esm/orchestrator/execution.mjs +5 -2
  239. package/esm/orchestrator/execution.mjs.map +1 -1
  240. package/esm/orchestrator/index.d.mts +1 -0
  241. package/esm/orchestrator/index.mjs +1 -0
  242. package/esm/orchestrator/orchestrator.d.mts.map +1 -1
  243. package/esm/orchestrator/orchestrator.mjs +39 -6
  244. package/esm/orchestrator/orchestrator.mjs.map +1 -1
  245. package/esm/orchestrator/session-lock.d.mts +25 -0
  246. package/esm/orchestrator/session-lock.d.mts.map +1 -0
  247. package/esm/orchestrator/session-lock.mjs +83 -0
  248. package/esm/orchestrator/session-lock.mjs.map +1 -0
  249. package/esm/planner/dag-scheduler.mjs +97 -0
  250. package/esm/planner/dag-scheduler.mjs.map +1 -0
  251. package/esm/planner/plan-prompt.d.mts +1 -1
  252. package/esm/planner/plan-prompt.d.mts.map +1 -1
  253. package/esm/planner/plan-prompt.mjs +2 -1
  254. package/esm/planner/plan-prompt.mjs.map +1 -1
  255. package/esm/planner/plan-schema.mjs +17 -14
  256. package/esm/planner/plan-schema.mjs.map +1 -1
  257. package/esm/planner/planner-run.d.mts.map +1 -1
  258. package/esm/planner/planner-run.mjs +300 -29
  259. package/esm/planner/planner-run.mjs.map +1 -1
  260. package/esm/planner/planner.mjs +1 -1
  261. package/esm/planner/planner.mjs.map +1 -1
  262. package/esm/prompt/errors.d.mts +57 -0
  263. package/esm/prompt/errors.d.mts.map +1 -0
  264. package/esm/prompt/errors.mjs +73 -0
  265. package/esm/prompt/errors.mjs.map +1 -0
  266. package/esm/prompt/index.d.mts +3 -0
  267. package/esm/prompt/index.mjs +4 -0
  268. package/esm/prompt/prompt-langfuse-sync.mjs +104 -0
  269. package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -0
  270. package/esm/prompt/prompt-langfuse-sync.type.d.mts +32 -0
  271. package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -0
  272. package/esm/prompt/prompt-validate.mjs +170 -0
  273. package/esm/prompt/prompt-validate.mjs.map +1 -0
  274. package/esm/prompt/prompt.d.mts +54 -0
  275. package/esm/prompt/prompt.d.mts.map +1 -0
  276. package/esm/prompt/prompt.mjs +218 -0
  277. package/esm/prompt/prompt.mjs.map +1 -0
  278. package/esm/prompt/prompt.type.d.mts +174 -0
  279. package/esm/prompt/prompt.type.d.mts.map +1 -0
  280. package/esm/prompts/index.d.mts +3 -0
  281. package/esm/prompts/index.mjs +3 -0
  282. package/esm/prompts/prompts-manager.contract.d.mts +154 -0
  283. package/esm/prompts/prompts-manager.contract.d.mts.map +1 -0
  284. package/esm/prompts/prompts-manager.d.mts +38 -0
  285. package/esm/prompts/prompts-manager.d.mts.map +1 -0
  286. package/esm/prompts/prompts-manager.mjs +410 -0
  287. package/esm/prompts/prompts-manager.mjs.map +1 -0
  288. package/esm/prompts/prompts-manager.type.d.mts +172 -0
  289. package/esm/prompts/prompts-manager.type.d.mts.map +1 -0
  290. package/esm/prompts/prompts-validate.mjs +200 -0
  291. package/esm/prompts/prompts-validate.mjs.map +1 -0
  292. package/esm/rag/as-tool.mjs +48 -0
  293. package/esm/rag/as-tool.mjs.map +1 -0
  294. package/esm/rag/chunk/chunk.d.mts +24 -0
  295. package/esm/rag/chunk/chunk.d.mts.map +1 -0
  296. package/esm/rag/chunk/chunk.mjs +44 -0
  297. package/esm/rag/chunk/chunk.mjs.map +1 -0
  298. package/esm/rag/chunk/fixed.mjs +32 -0
  299. package/esm/rag/chunk/fixed.mjs.map +1 -0
  300. package/esm/rag/chunk/markdown.mjs +75 -0
  301. package/esm/rag/chunk/markdown.mjs.map +1 -0
  302. package/esm/rag/chunk/recursive.mjs +132 -0
  303. package/esm/rag/chunk/recursive.mjs.map +1 -0
  304. package/esm/rag/chunk/sentence.mjs +73 -0
  305. package/esm/rag/chunk/sentence.mjs.map +1 -0
  306. package/esm/rag/contracts/chunk-options.type.d.mts +35 -0
  307. package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -0
  308. package/esm/rag/contracts/citation.type.d.mts +35 -0
  309. package/esm/rag/contracts/citation.type.d.mts.map +1 -0
  310. package/esm/rag/contracts/index.d.mts +4 -0
  311. package/esm/rag/contracts/rag-config.type.d.mts +68 -0
  312. package/esm/rag/contracts/rag-config.type.d.mts.map +1 -0
  313. package/esm/rag/contracts/rag-document.type.d.mts +21 -0
  314. package/esm/rag/contracts/rag-document.type.d.mts.map +1 -0
  315. package/esm/rag/hybrid/bm25.d.mts +23 -0
  316. package/esm/rag/hybrid/bm25.d.mts.map +1 -0
  317. package/esm/rag/hybrid/bm25.mjs +51 -0
  318. package/esm/rag/hybrid/bm25.mjs.map +1 -0
  319. package/esm/rag/hybrid/hybrid-rank.d.mts +33 -0
  320. package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -0
  321. package/esm/rag/hybrid/hybrid-rank.mjs +29 -0
  322. package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -0
  323. package/esm/rag/hybrid/rrf.d.mts +25 -0
  324. package/esm/rag/hybrid/rrf.d.mts.map +1 -0
  325. package/esm/rag/hybrid/rrf.mjs +30 -0
  326. package/esm/rag/hybrid/rrf.mjs.map +1 -0
  327. package/esm/rag/index.d.mts +15 -0
  328. package/esm/rag/index.mjs +11 -0
  329. package/esm/rag/rag.d.mts +38 -0
  330. package/esm/rag/rag.d.mts.map +1 -0
  331. package/esm/rag/rag.mjs +126 -0
  332. package/esm/rag/rag.mjs.map +1 -0
  333. package/esm/rag/rerank/keyword-reranker.d.mts +32 -0
  334. package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -0
  335. package/esm/rag/rerank/keyword-reranker.mjs +58 -0
  336. package/esm/rag/rerank/keyword-reranker.mjs.map +1 -0
  337. package/esm/rag/rerank/llm-reranker.d.mts +36 -0
  338. package/esm/rag/rerank/llm-reranker.d.mts.map +1 -0
  339. package/esm/rag/rerank/llm-reranker.mjs +85 -0
  340. package/esm/rag/rerank/llm-reranker.mjs.map +1 -0
  341. package/esm/rag/rerank/reranker.contract.d.mts +28 -0
  342. package/esm/rag/rerank/reranker.contract.d.mts.map +1 -0
  343. package/esm/rag/retrieve.mjs +68 -0
  344. package/esm/rag/retrieve.mjs.map +1 -0
  345. package/esm/rag/store/cache-vector-store.d.mts +27 -0
  346. package/esm/rag/store/cache-vector-store.d.mts.map +1 -0
  347. package/esm/rag/store/cache-vector-store.mjs +48 -0
  348. package/esm/rag/store/cache-vector-store.mjs.map +1 -0
  349. package/esm/rag/store/vector-store.contract.d.mts +38 -0
  350. package/esm/rag/store/vector-store.contract.d.mts.map +1 -0
  351. package/esm/rag/transforms/multi-query.d.mts +27 -0
  352. package/esm/rag/transforms/multi-query.d.mts.map +1 -0
  353. package/esm/rag/transforms/multi-query.mjs +41 -0
  354. package/esm/rag/transforms/multi-query.mjs.map +1 -0
  355. package/esm/security/index.mjs +5 -0
  356. package/esm/security/outbound-policy.d.mts +46 -0
  357. package/esm/security/outbound-policy.d.mts.map +1 -0
  358. package/esm/security/outbound-policy.mjs +187 -0
  359. package/esm/security/outbound-policy.mjs.map +1 -0
  360. package/esm/security/outbound-policy.type.d.mts +74 -0
  361. package/esm/security/outbound-policy.type.d.mts.map +1 -0
  362. package/esm/security/private-ip.d.mts +15 -0
  363. package/esm/security/private-ip.d.mts.map +1 -0
  364. package/esm/security/private-ip.mjs +48 -0
  365. package/esm/security/private-ip.mjs.map +1 -0
  366. package/esm/security/redact.d.mts +59 -0
  367. package/esm/security/redact.d.mts.map +1 -0
  368. package/esm/security/redact.mjs +122 -0
  369. package/esm/security/redact.mjs.map +1 -0
  370. package/esm/serve/serve.d.mts +50 -0
  371. package/esm/serve/serve.d.mts.map +1 -0
  372. package/esm/serve/serve.mjs +90 -0
  373. package/esm/serve/serve.mjs.map +1 -0
  374. package/esm/serve/sse.d.mts +20 -0
  375. package/esm/serve/sse.d.mts.map +1 -0
  376. package/esm/serve/sse.mjs +25 -0
  377. package/esm/serve/sse.mjs.map +1 -0
  378. package/esm/serve/stream-to-sse.d.mts +29 -0
  379. package/esm/serve/stream-to-sse.d.mts.map +1 -0
  380. package/esm/serve/stream-to-sse.mjs +37 -0
  381. package/esm/serve/stream-to-sse.mjs.map +1 -0
  382. package/esm/skills/catalog.d.mts +49 -0
  383. package/esm/skills/catalog.d.mts.map +1 -0
  384. package/esm/skills/catalog.mjs +140 -0
  385. package/esm/skills/catalog.mjs.map +1 -0
  386. package/esm/skills/contracts/skill-record.type.d.mts +37 -0
  387. package/esm/skills/contracts/skill-record.type.d.mts.map +1 -0
  388. package/esm/skills/contracts/skills-config.type.d.mts +108 -0
  389. package/esm/skills/contracts/skills-config.type.d.mts.map +1 -0
  390. package/esm/skills/contracts/skills-store.contract.d.mts +28 -0
  391. package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -0
  392. package/esm/skills/contracts/skills.contract.d.mts +43 -0
  393. package/esm/skills/contracts/skills.contract.d.mts.map +1 -0
  394. package/esm/skills/index.d.mts +16 -0
  395. package/esm/skills/index.mjs +14 -0
  396. package/esm/skills/load-skill-tool.d.mts +38 -0
  397. package/esm/skills/load-skill-tool.d.mts.map +1 -0
  398. package/esm/skills/load-skill-tool.mjs +65 -0
  399. package/esm/skills/load-skill-tool.mjs.map +1 -0
  400. package/esm/skills/review-gate.d.mts +33 -0
  401. package/esm/skills/review-gate.d.mts.map +1 -0
  402. package/esm/skills/review-gate.mjs +60 -0
  403. package/esm/skills/review-gate.mjs.map +1 -0
  404. package/esm/skills/save-skill-tool.d.mts +39 -0
  405. package/esm/skills/save-skill-tool.d.mts.map +1 -0
  406. package/esm/skills/save-skill-tool.mjs +65 -0
  407. package/esm/skills/save-skill-tool.mjs.map +1 -0
  408. package/esm/skills/skills.d.mts +33 -0
  409. package/esm/skills/skills.d.mts.map +1 -0
  410. package/esm/skills/skills.mjs +109 -0
  411. package/esm/skills/skills.mjs.map +1 -0
  412. package/esm/skills/sources/directory-source.d.mts +19 -0
  413. package/esm/skills/sources/directory-source.d.mts.map +1 -0
  414. package/esm/skills/sources/directory-source.mjs +108 -0
  415. package/esm/skills/sources/directory-source.mjs.map +1 -0
  416. package/esm/skills/sources/index.d.mts +18 -0
  417. package/esm/skills/sources/index.d.mts.map +1 -0
  418. package/esm/skills/sources/index.mjs +27 -0
  419. package/esm/skills/sources/index.mjs.map +1 -0
  420. package/esm/skills/sources/parse-frontmatter.d.mts +27 -0
  421. package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -0
  422. package/esm/skills/sources/parse-frontmatter.mjs +46 -0
  423. package/esm/skills/sources/parse-frontmatter.mjs.map +1 -0
  424. package/esm/skills/sources/store-source.d.mts +14 -0
  425. package/esm/skills/sources/store-source.d.mts.map +1 -0
  426. package/esm/skills/sources/store-source.mjs +15 -0
  427. package/esm/skills/sources/store-source.mjs.map +1 -0
  428. package/esm/skills/sources/url-source.d.mts +29 -0
  429. package/esm/skills/sources/url-source.d.mts.map +1 -0
  430. package/esm/skills/sources/url-source.mjs +117 -0
  431. package/esm/skills/sources/url-source.mjs.map +1 -0
  432. package/esm/skills/store/mock-skills-store.d.mts +57 -0
  433. package/esm/skills/store/mock-skills-store.d.mts.map +1 -0
  434. package/esm/skills/store/mock-skills-store.mjs +100 -0
  435. package/esm/skills/store/mock-skills-store.mjs.map +1 -0
  436. package/esm/skills/store/procedural-skill-store.d.mts +30 -0
  437. package/esm/skills/store/procedural-skill-store.d.mts.map +1 -0
  438. package/esm/skills/store/procedural-skill-store.mjs +125 -0
  439. package/esm/skills/store/procedural-skill-store.mjs.map +1 -0
  440. package/esm/supervisor/as-tool.mjs +2 -2
  441. package/esm/supervisor/as-tool.mjs.map +1 -1
  442. package/esm/supervisor/execution.d.mts.map +1 -1
  443. package/esm/supervisor/execution.mjs +31 -28
  444. package/esm/supervisor/execution.mjs.map +1 -1
  445. package/esm/supervisor/supervisor.d.mts.map +1 -1
  446. package/esm/supervisor/supervisor.mjs +8 -3
  447. package/esm/supervisor/supervisor.mjs.map +1 -1
  448. package/esm/system-prompt/index.d.mts +4 -0
  449. package/esm/system-prompt/system-prompt.d.mts +68 -4
  450. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  451. package/esm/system-prompt/system-prompt.mjs +89 -5
  452. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  453. package/esm/team/gates.mjs +48 -0
  454. package/esm/team/gates.mjs.map +1 -0
  455. package/esm/team/index.d.mts +1 -0
  456. package/esm/team/index.mjs +3 -0
  457. package/esm/team/team.d.mts +42 -0
  458. package/esm/team/team.d.mts.map +1 -0
  459. package/esm/team/team.mjs +94 -0
  460. package/esm/team/team.mjs.map +1 -0
  461. package/esm/tool/executable-as-tool.d.mts.map +1 -1
  462. package/esm/tool/executable-as-tool.mjs +2 -2
  463. package/esm/tool/executable-as-tool.mjs.map +1 -1
  464. package/esm/tool/tool.d.mts.map +1 -1
  465. package/esm/tool/tool.mjs +2 -2
  466. package/esm/tool/tool.mjs.map +1 -1
  467. package/esm/utils/compute-cost.d.mts +17 -1
  468. package/esm/utils/compute-cost.d.mts.map +1 -1
  469. package/esm/utils/compute-cost.mjs +26 -1
  470. package/esm/utils/compute-cost.mjs.map +1 -1
  471. package/esm/utils/extract-json-lenient.d.mts +42 -0
  472. package/esm/utils/extract-json-lenient.d.mts.map +1 -0
  473. package/esm/utils/extract-json-lenient.mjs +97 -0
  474. package/esm/utils/extract-json-lenient.mjs.map +1 -0
  475. package/esm/utils/index.d.mts +4 -2
  476. package/esm/utils/index.mjs +3 -1
  477. package/esm/utils/json-schema.d.mts +1 -1
  478. package/esm/utils/prepare-attachment-part.d.mts +10 -1
  479. package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
  480. package/esm/utils/prepare-attachment-part.mjs +103 -11
  481. package/esm/utils/prepare-attachment-part.mjs.map +1 -1
  482. package/esm/utils/resolve-attachment.d.mts +4 -3
  483. package/esm/utils/resolve-attachment.d.mts.map +1 -1
  484. package/esm/utils/resolve-attachment.mjs +4 -3
  485. package/esm/utils/resolve-attachment.mjs.map +1 -1
  486. package/esm/utils/run-context.d.mts +94 -0
  487. package/esm/utils/run-context.d.mts.map +1 -0
  488. package/esm/utils/run-context.mjs +98 -0
  489. package/esm/utils/run-context.mjs.map +1 -0
  490. package/esm/vcr/cassette-io.mjs +57 -0
  491. package/esm/vcr/cassette-io.mjs.map +1 -0
  492. package/esm/vcr/errors.d.mts +42 -0
  493. package/esm/vcr/errors.d.mts.map +1 -0
  494. package/esm/vcr/errors.mjs +37 -0
  495. package/esm/vcr/errors.mjs.map +1 -0
  496. package/esm/vcr/hash-request.d.mts +28 -0
  497. package/esm/vcr/hash-request.d.mts.map +1 -0
  498. package/esm/vcr/hash-request.mjs +118 -0
  499. package/esm/vcr/hash-request.mjs.map +1 -0
  500. package/esm/vcr/index.d.mts +4 -0
  501. package/esm/vcr/index.mjs +5 -0
  502. package/esm/vcr/vcr.d.mts +32 -0
  503. package/esm/vcr/vcr.d.mts.map +1 -0
  504. package/esm/vcr/vcr.mjs +248 -0
  505. package/esm/vcr/vcr.mjs.map +1 -0
  506. package/esm/vcr/vcr.type.d.mts +118 -0
  507. package/esm/vcr/vcr.type.d.mts.map +1 -0
  508. package/esm/workflow/as-tool.mjs +2 -2
  509. package/esm/workflow/as-tool.mjs.map +1 -1
  510. package/esm/workflow/engine.mjs +1 -0
  511. package/esm/workflow/engine.mjs.map +1 -1
  512. package/esm/workflow/step-runner.mjs +19 -20
  513. package/esm/workflow/step-runner.mjs.map +1 -1
  514. package/esm/workflow/workflow.d.mts.map +1 -1
  515. package/esm/workflow/workflow.mjs +8 -3
  516. package/esm/workflow/workflow.mjs.map +1 -1
  517. package/llms-full.txt +1683 -68
  518. package/llms.txt +16 -4
  519. package/package.json +7 -3
  520. package/skills/README.md +40 -4
  521. package/skills/ai-dx-helpers/SKILL.md +2 -2
  522. package/skills/approve-tool-calls/SKILL.md +134 -0
  523. package/skills/attach-ai-middleware/SKILL.md +1 -1
  524. package/skills/detect-and-redact-pii/SKILL.md +104 -0
  525. package/skills/durable-resume/SKILL.md +128 -0
  526. package/skills/escalate-block-to-human/SKILL.md +85 -0
  527. package/skills/eval-datasets-and-ci/SKILL.md +117 -0
  528. package/skills/guard-input-output/SKILL.md +117 -0
  529. package/skills/manage-prompts/SKILL.md +186 -0
  530. package/skills/observe-ai-flows/SKILL.md +94 -0
  531. package/skills/record-replay-llm/SKILL.md +92 -0
  532. package/skills/run-ai-agent/SKILL.md +26 -1
  533. package/skills/run-ai-rag/SKILL.md +139 -0
  534. package/skills/run-ai-team/SKILL.md +107 -0
  535. package/skills/run-orchestrator/SKILL.md +2 -0
  536. package/skills/run-planner/SKILL.md +73 -8
  537. package/skills/run-supervisor/SKILL.md +20 -1
  538. package/skills/use-runtime-skills/SKILL.md +106 -0
  539. package/skills/write-system-prompt/SKILL.md +30 -1
  540. package/cjs/index.cjs.map +0 -1
  541. package/esm/contracts/result/index.d.mts +0 -15
@@ -0,0 +1,37 @@
1
+ import { humanApproval } from "./human-approval.mjs";
2
+ import { resume } from "./resume.mjs";
3
+ import { memory } from "./stores/memory.mjs";
4
+ import { pg } from "./stores/pg.mjs";
5
+ import { redis } from "./stores/redis.mjs";
6
+ import "./stores/index.mjs";
7
+
8
+ //#region ../@warlock.js/ai/src/human/register.ts
9
+ /**
10
+ * The assembled `ai.human.*` namespace — the human-in-the-loop surface
11
+ * mounted onto the shared `ai` object in `../ai`.
12
+ *
13
+ * - `approval(options)` — the `tool.before` approval-gate middleware.
14
+ * - `resume(id, decision, options)` — out-of-process durable resume.
15
+ * - `interrupt.{memory,pg,redis}()` — the
16
+ * {@link import("./contracts").InterruptStore} factories (memory ships
17
+ * real; pg/redis lazily import their optional-peer driver).
18
+ *
19
+ * Declared as a standalone object so `../ai` can spread it onto the `ai`
20
+ * literal and pin the `Ai.human` member to this exact shape with no casts.
21
+ * Lives here (not inlined into `../ai`) to keep the human factories grouped
22
+ * with the rest of the human module and avoid `../ai` reaching into each
23
+ * store/middleware file directly.
24
+ */
25
+ const human = {
26
+ approval: humanApproval,
27
+ resume,
28
+ interrupt: {
29
+ memory,
30
+ pg,
31
+ redis
32
+ }
33
+ };
34
+
35
+ //#endregion
36
+ export { human };
37
+ //# sourceMappingURL=register.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.mjs","names":["interruptMemory","interruptPg","interruptRedis"],"sources":["../../../../../../../@warlock.js/ai/src/human/register.ts"],"sourcesContent":["import { humanApproval } from \"./human-approval\";\nimport { resume } from \"./resume\";\nimport { interruptMemory, interruptPg, interruptRedis } from \"./stores\";\n\n/**\n * The assembled `ai.human.*` namespace — the human-in-the-loop surface\n * mounted onto the shared `ai` object in `../ai`.\n *\n * - `approval(options)` — the `tool.before` approval-gate middleware.\n * - `resume(id, decision, options)` — out-of-process durable resume.\n * - `interrupt.{memory,pg,redis}()` — the\n * {@link import(\"./contracts\").InterruptStore} factories (memory ships\n * real; pg/redis lazily import their optional-peer driver).\n *\n * Declared as a standalone object so `../ai` can spread it onto the `ai`\n * literal and pin the `Ai.human` member to this exact shape with no casts.\n * Lives here (not inlined into `../ai`) to keep the human factories grouped\n * with the rest of the human module and avoid `../ai` reaching into each\n * store/middleware file directly.\n */\nexport const human = {\n approval: humanApproval,\n resume,\n interrupt: {\n memory: interruptMemory,\n pg: interruptPg,\n redis: interruptRedis,\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,QAAQ;CACnB,UAAU;CACV;CACA,WAAW;EACDA;EACJC;EACGC;CACT;AACF"}
@@ -0,0 +1,53 @@
1
+ //#region ../@warlock.js/ai/src/human/resume-seed.ts
2
+ /**
3
+ * Process-local registry of decisions pre-seeded for a durable re-run.
4
+ *
5
+ * **Why it exists.** v1 durable resume re-runs the *same* agent turn with
6
+ * the human's decision already in hand (it does **not** rehydrate an
7
+ * in-flight supervisor — that is the deferred v2 lift). The agent's
8
+ * `ai.human.approval(...)` middleware is baked in at construction, so the
9
+ * re-run cannot be handed a different handler. Instead, `ai.human.resume(...)`
10
+ * stashes the decision here keyed by the agent name; the approval
11
+ * middleware's handler consults the registry **before** calling the
12
+ * author's handler and, on a hit, replays the seeded decision exactly once
13
+ * — so the gated tool call this time resolves to the human's ruling instead
14
+ * of pausing again.
15
+ *
16
+ * Keyed by agent name (not interrupt id): the re-run produces a *fresh*
17
+ * interrupt id (the id embeds a random segment), so the seed must be
18
+ * matched to the run, not the prior id. The registry holds at most one
19
+ * seeded decision per agent and consumes it on first read, so a second
20
+ * gated call in the same re-run falls through to the author's handler.
21
+ */
22
+ const seededDecisions = /* @__PURE__ */ new Map();
23
+ /**
24
+ * Stash a decision to be replayed on the next gated tool call of `agentName`.
25
+ * Overwrites any prior seed for the same agent (a re-run carries exactly one
26
+ * pre-seeded decision).
27
+ */
28
+ function seedDecision(agentName, decision) {
29
+ seededDecisions.set(agentName, decision);
30
+ }
31
+ /**
32
+ * Take (read **and** remove) the seeded decision for `agentName`, or
33
+ * `undefined` when none is staged. Consuming on read makes the seed
34
+ * one-shot: only the first gated call of a re-run replays it.
35
+ */
36
+ function takeSeededDecision(agentName) {
37
+ const decision = seededDecisions.get(agentName);
38
+ if (decision === void 0) return;
39
+ seededDecisions.delete(agentName);
40
+ return decision;
41
+ }
42
+ /**
43
+ * Drop any staged seed for `agentName` without consuming it as a decision.
44
+ * Used to clean up after a re-run that errored before the seeded call fired,
45
+ * so a stale seed never leaks into an unrelated later run of the same agent.
46
+ */
47
+ function clearSeededDecision(agentName) {
48
+ seededDecisions.delete(agentName);
49
+ }
50
+
51
+ //#endregion
52
+ export { clearSeededDecision, seedDecision, takeSeededDecision };
53
+ //# sourceMappingURL=resume-seed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume-seed.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/human/resume-seed.ts"],"sourcesContent":["import type { ApprovalDecision } from \"./contracts\";\n\n/**\n * Process-local registry of decisions pre-seeded for a durable re-run.\n *\n * **Why it exists.** v1 durable resume re-runs the *same* agent turn with\n * the human's decision already in hand (it does **not** rehydrate an\n * in-flight supervisor — that is the deferred v2 lift). The agent's\n * `ai.human.approval(...)` middleware is baked in at construction, so the\n * re-run cannot be handed a different handler. Instead, `ai.human.resume(...)`\n * stashes the decision here keyed by the agent name; the approval\n * middleware's handler consults the registry **before** calling the\n * author's handler and, on a hit, replays the seeded decision exactly once\n * — so the gated tool call this time resolves to the human's ruling instead\n * of pausing again.\n *\n * Keyed by agent name (not interrupt id): the re-run produces a *fresh*\n * interrupt id (the id embeds a random segment), so the seed must be\n * matched to the run, not the prior id. The registry holds at most one\n * seeded decision per agent and consumes it on first read, so a second\n * gated call in the same re-run falls through to the author's handler.\n */\nconst seededDecisions = new Map<string, ApprovalDecision>();\n\n/**\n * Stash a decision to be replayed on the next gated tool call of `agentName`.\n * Overwrites any prior seed for the same agent (a re-run carries exactly one\n * pre-seeded decision).\n */\nexport function seedDecision(agentName: string, decision: ApprovalDecision): void {\n seededDecisions.set(agentName, decision);\n}\n\n/**\n * Take (read **and** remove) the seeded decision for `agentName`, or\n * `undefined` when none is staged. Consuming on read makes the seed\n * one-shot: only the first gated call of a re-run replays it.\n */\nexport function takeSeededDecision(agentName: string): ApprovalDecision | undefined {\n const decision = seededDecisions.get(agentName);\n\n if (decision === undefined) {\n return undefined;\n }\n\n seededDecisions.delete(agentName);\n\n return decision;\n}\n\n/**\n * Drop any staged seed for `agentName` without consuming it as a decision.\n * Used to clean up after a re-run that errored before the seeded call fired,\n * so a stale seed never leaks into an unrelated later run of the same agent.\n */\nexport function clearSeededDecision(agentName: string): void {\n seededDecisions.delete(agentName);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kCAAkB,IAAI,IAA8B;;;;;;AAO1D,SAAgB,aAAa,WAAmB,UAAkC;CAChF,gBAAgB,IAAI,WAAW,QAAQ;AACzC;;;;;;AAOA,SAAgB,mBAAmB,WAAiD;CAClF,MAAM,WAAW,gBAAgB,IAAI,SAAS;CAE9C,IAAI,aAAa,QACf;CAGF,gBAAgB,OAAO,SAAS;CAEhC,OAAO;AACT;;;;;;AAOA,SAAgB,oBAAoB,WAAyB;CAC3D,gBAAgB,OAAO,SAAS;AAClC"}
@@ -0,0 +1,54 @@
1
+ import { ApprovalDecision } from "./contracts/approval.type.mjs";
2
+ import { ResumeOptions, ResumeResult } from "./contracts/resume.type.mjs";
3
+ //#region ../@warlock.js/ai/src/human/resume.d.ts
4
+ /**
5
+ * Apply a human's decision to a persisted interrupt — the out-of-process
6
+ * resume entry point behind `ai.human.resume(interruptId, decision, options)`.
7
+ *
8
+ * **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the
9
+ * {@link PendingInterrupt} from `options.store`, validates the decision,
10
+ * deletes the pending record, and (when an `agent` is supplied) re-executes
11
+ * the original turn with the decision **pre-seeded**, so the gated tool call
12
+ * resolves to the ruling instead of pausing again. It does **not** rehydrate
13
+ * an in-flight supervisor — that is the deferred v2 lift.
14
+ *
15
+ * **Idempotent.** A second resume of an already-resolved (deleted) or
16
+ * never-raised interrupt is a no-op: it returns `{ type: "already-resolved" }`
17
+ * without re-applying the decision or re-running the turn — mirroring the
18
+ * orchestrator resume's drain idempotency. The record is deleted **before**
19
+ * the re-run, so even a re-run that itself raises a fresh interrupt cannot
20
+ * collide with the one being resolved.
21
+ *
22
+ * **Two shapes** (see {@link ResumeOptions}):
23
+ * - **apply-only** — omit `agent`: load, validate, delete, return
24
+ * `{ type: "applied", decision }` for a caller-owned re-drive.
25
+ * - **re-run** — pass `agent`: additionally re-execute the turn; the
26
+ * {@link import("@warlock.js/ai").AgentResult} rides `result.result`.
27
+ *
28
+ * @param interruptId - Id of the persisted interrupt to resolve.
29
+ * @param decision - The human's ruling (approve / reject / edit).
30
+ * @param options - The durable `store` (required) plus optional re-run
31
+ * `agent` / `input` / `executeOptions`.
32
+ * @returns A {@link ResumeResult} — `"applied"` or idempotent
33
+ * `"already-resolved"`.
34
+ *
35
+ * @example
36
+ * // Process B (webhook, hours later) — apply-only:
37
+ * const outcome = await ai.human.resume(interruptId, { type: "reject", reason: "Out of policy" }, {
38
+ * store,
39
+ * });
40
+ *
41
+ * @example
42
+ * // Re-run the turn with the decision pre-seeded:
43
+ * const outcome = await ai.human.resume(interruptId, { type: "edit", args: { amount: 5 } }, {
44
+ * store,
45
+ * agent: support,
46
+ * });
47
+ * if (outcome.type === "applied" && outcome.result) {
48
+ * console.log(outcome.result.text);
49
+ * }
50
+ */
51
+ declare function resume<TOutput = unknown>(interruptId: string, decision: ApprovalDecision, options: ResumeOptions<TOutput>): Promise<ResumeResult<TOutput>>;
52
+ //#endregion
53
+ export { resume };
54
+ //# sourceMappingURL=resume.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/human/resume.ts"],"mappings":";;;;;;;AAyIA;;;;;;;;;;;;;;;;;;;;;;AAI+B;;;;;;;;;;;;;;;;;;;;;iBAJT,MAAA,oBACpB,WAAA,UACA,QAAA,EAAU,gBAAA,EACV,OAAA,EAAS,aAAA,CAAc,OAAA,IACtB,OAAA,CAAQ,YAAA,CAAa,OAAA"}
@@ -0,0 +1,121 @@
1
+ import { clearSeededDecision, seedDecision } from "./resume-seed.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/human/resume.ts
4
+ /**
5
+ * Validate that a decision is a well-formed {@link ApprovalDecision}.
6
+ *
7
+ * `ai.human.resume(...)` is a public, out-of-process entry point — a
8
+ * webhook can hand it anything. Guard the closed `type` union (and the
9
+ * per-variant required fields) before applying it, so a malformed payload
10
+ * fails loudly here rather than silently mis-driving the re-run.
11
+ */
12
+ function assertDecision(decision) {
13
+ if (decision.type === "approve") return;
14
+ if (decision.type === "reject") {
15
+ if (typeof decision.reason !== "string") throw new TypeError("ai.human.resume: a 'reject' decision requires a string 'reason'.");
16
+ return;
17
+ }
18
+ if (decision.type === "edit") {
19
+ if (!("args" in decision)) throw new TypeError("ai.human.resume: an 'edit' decision requires replacement 'args'.");
20
+ return;
21
+ }
22
+ throw new TypeError(`ai.human.resume: unknown decision type '${decision.type}'. Expected one of: approve, reject, edit.`);
23
+ }
24
+ /**
25
+ * Re-run the agent for a resumed interrupt with the decision pre-seeded.
26
+ *
27
+ * Stages the decision in the process-local seed registry (keyed by agent
28
+ * name), then re-executes the original prompt. The agent's
29
+ * `ai.human.approval(...)` middleware consumes the seed on the gated tool
30
+ * call — so this time it resolves to the human's ruling instead of pausing
31
+ * again. The seed is cleared in a `finally` so a re-run that errors before
32
+ * the gated call never leaks a stale seed into a later run.
33
+ */
34
+ async function rerun(pending, decision, options) {
35
+ const { agent } = options;
36
+ if (!agent) return {
37
+ type: "applied",
38
+ interruptId: pending.interruptId,
39
+ decision
40
+ };
41
+ const input = options.input ?? pending.request.context.originalInput ?? "";
42
+ seedDecision(agent.name, decision);
43
+ try {
44
+ const result = await agent.execute(input, options.executeOptions);
45
+ return {
46
+ type: "applied",
47
+ interruptId: pending.interruptId,
48
+ decision,
49
+ result
50
+ };
51
+ } finally {
52
+ clearSeededDecision(agent.name);
53
+ }
54
+ }
55
+ /**
56
+ * Apply a human's decision to a persisted interrupt — the out-of-process
57
+ * resume entry point behind `ai.human.resume(interruptId, decision, options)`.
58
+ *
59
+ * **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the
60
+ * {@link PendingInterrupt} from `options.store`, validates the decision,
61
+ * deletes the pending record, and (when an `agent` is supplied) re-executes
62
+ * the original turn with the decision **pre-seeded**, so the gated tool call
63
+ * resolves to the ruling instead of pausing again. It does **not** rehydrate
64
+ * an in-flight supervisor — that is the deferred v2 lift.
65
+ *
66
+ * **Idempotent.** A second resume of an already-resolved (deleted) or
67
+ * never-raised interrupt is a no-op: it returns `{ type: "already-resolved" }`
68
+ * without re-applying the decision or re-running the turn — mirroring the
69
+ * orchestrator resume's drain idempotency. The record is deleted **before**
70
+ * the re-run, so even a re-run that itself raises a fresh interrupt cannot
71
+ * collide with the one being resolved.
72
+ *
73
+ * **Two shapes** (see {@link ResumeOptions}):
74
+ * - **apply-only** — omit `agent`: load, validate, delete, return
75
+ * `{ type: "applied", decision }` for a caller-owned re-drive.
76
+ * - **re-run** — pass `agent`: additionally re-execute the turn; the
77
+ * {@link import("@warlock.js/ai").AgentResult} rides `result.result`.
78
+ *
79
+ * @param interruptId - Id of the persisted interrupt to resolve.
80
+ * @param decision - The human's ruling (approve / reject / edit).
81
+ * @param options - The durable `store` (required) plus optional re-run
82
+ * `agent` / `input` / `executeOptions`.
83
+ * @returns A {@link ResumeResult} — `"applied"` or idempotent
84
+ * `"already-resolved"`.
85
+ *
86
+ * @example
87
+ * // Process B (webhook, hours later) — apply-only:
88
+ * const outcome = await ai.human.resume(interruptId, { type: "reject", reason: "Out of policy" }, {
89
+ * store,
90
+ * });
91
+ *
92
+ * @example
93
+ * // Re-run the turn with the decision pre-seeded:
94
+ * const outcome = await ai.human.resume(interruptId, { type: "edit", args: { amount: 5 } }, {
95
+ * store,
96
+ * agent: support,
97
+ * });
98
+ * if (outcome.type === "applied" && outcome.result) {
99
+ * console.log(outcome.result.text);
100
+ * }
101
+ */
102
+ async function resume(interruptId, decision, options) {
103
+ assertDecision(decision);
104
+ const { store } = options;
105
+ const pending = await store.load(interruptId);
106
+ if (pending === void 0 || pending.status !== "pending") return {
107
+ type: "already-resolved",
108
+ interruptId
109
+ };
110
+ await store.delete(interruptId);
111
+ if (!options.agent) return {
112
+ type: "applied",
113
+ interruptId,
114
+ decision
115
+ };
116
+ return rerun(pending, decision, options);
117
+ }
118
+
119
+ //#endregion
120
+ export { resume };
121
+ //# sourceMappingURL=resume.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/human/resume.ts"],"sourcesContent":["import type {\n ApprovalDecision,\n PendingInterrupt,\n ResumeOptions,\n ResumeResult,\n} from \"./contracts\";\nimport { clearSeededDecision, seedDecision } from \"./resume-seed\";\n\n/**\n * Validate that a decision is a well-formed {@link ApprovalDecision}.\n *\n * `ai.human.resume(...)` is a public, out-of-process entry point — a\n * webhook can hand it anything. Guard the closed `type` union (and the\n * per-variant required fields) before applying it, so a malformed payload\n * fails loudly here rather than silently mis-driving the re-run.\n */\nfunction assertDecision(decision: ApprovalDecision): void {\n if (decision.type === \"approve\") {\n return;\n }\n\n if (decision.type === \"reject\") {\n if (typeof decision.reason !== \"string\") {\n throw new TypeError(\n \"ai.human.resume: a 'reject' decision requires a string 'reason'.\",\n );\n }\n\n return;\n }\n\n if (decision.type === \"edit\") {\n if (!(\"args\" in decision)) {\n throw new TypeError(\n \"ai.human.resume: an 'edit' decision requires replacement 'args'.\",\n );\n }\n\n return;\n }\n\n throw new TypeError(\n `ai.human.resume: unknown decision type '${(decision as { type: string }).type}'. Expected one of: approve, reject, edit.`,\n );\n}\n\n/**\n * Re-run the agent for a resumed interrupt with the decision pre-seeded.\n *\n * Stages the decision in the process-local seed registry (keyed by agent\n * name), then re-executes the original prompt. The agent's\n * `ai.human.approval(...)` middleware consumes the seed on the gated tool\n * call — so this time it resolves to the human's ruling instead of pausing\n * again. The seed is cleared in a `finally` so a re-run that errors before\n * the gated call never leaks a stale seed into a later run.\n */\nasync function rerun<TOutput>(\n pending: PendingInterrupt,\n decision: ApprovalDecision,\n options: ResumeOptions<TOutput>,\n): Promise<ResumeResult<TOutput>> {\n const { agent } = options;\n\n // `agent` is guaranteed by the caller (this is only reached on the\n // re-run path), but narrow for the type system.\n if (!agent) {\n return { type: \"applied\", interruptId: pending.interruptId, decision };\n }\n\n const input = options.input ?? pending.request.context.originalInput ?? \"\";\n\n seedDecision(agent.name, decision);\n\n try {\n const result = await agent.execute(input, options.executeOptions);\n\n return {\n type: \"applied\",\n interruptId: pending.interruptId,\n decision,\n result,\n };\n } finally {\n // If the seeded call never fired (the re-run errored early, or the\n // policy no longer gates the tool), drop the stale seed so it cannot\n // leak into an unrelated later run of the same agent.\n clearSeededDecision(agent.name);\n }\n}\n\n/**\n * Apply a human's decision to a persisted interrupt — the out-of-process\n * resume entry point behind `ai.human.resume(interruptId, decision, options)`.\n *\n * **Durable v1 model — re-run, not mid-supervisor suspend.** This loads the\n * {@link PendingInterrupt} from `options.store`, validates the decision,\n * deletes the pending record, and (when an `agent` is supplied) re-executes\n * the original turn with the decision **pre-seeded**, so the gated tool call\n * resolves to the ruling instead of pausing again. It does **not** rehydrate\n * an in-flight supervisor — that is the deferred v2 lift.\n *\n * **Idempotent.** A second resume of an already-resolved (deleted) or\n * never-raised interrupt is a no-op: it returns `{ type: \"already-resolved\" }`\n * without re-applying the decision or re-running the turn — mirroring the\n * orchestrator resume's drain idempotency. The record is deleted **before**\n * the re-run, so even a re-run that itself raises a fresh interrupt cannot\n * collide with the one being resolved.\n *\n * **Two shapes** (see {@link ResumeOptions}):\n * - **apply-only** — omit `agent`: load, validate, delete, return\n * `{ type: \"applied\", decision }` for a caller-owned re-drive.\n * - **re-run** — pass `agent`: additionally re-execute the turn; the\n * {@link import(\"@warlock.js/ai\").AgentResult} rides `result.result`.\n *\n * @param interruptId - Id of the persisted interrupt to resolve.\n * @param decision - The human's ruling (approve / reject / edit).\n * @param options - The durable `store` (required) plus optional re-run\n * `agent` / `input` / `executeOptions`.\n * @returns A {@link ResumeResult} — `\"applied\"` or idempotent\n * `\"already-resolved\"`.\n *\n * @example\n * // Process B (webhook, hours later) — apply-only:\n * const outcome = await ai.human.resume(interruptId, { type: \"reject\", reason: \"Out of policy\" }, {\n * store,\n * });\n *\n * @example\n * // Re-run the turn with the decision pre-seeded:\n * const outcome = await ai.human.resume(interruptId, { type: \"edit\", args: { amount: 5 } }, {\n * store,\n * agent: support,\n * });\n * if (outcome.type === \"applied\" && outcome.result) {\n * console.log(outcome.result.text);\n * }\n */\nexport async function resume<TOutput = unknown>(\n interruptId: string,\n decision: ApprovalDecision,\n options: ResumeOptions<TOutput>,\n): Promise<ResumeResult<TOutput>> {\n assertDecision(decision);\n\n const { store } = options;\n const pending = await store.load(interruptId);\n\n // No live interrupt — already resolved + deleted, or never raised. Never\n // double-apply; never re-run. Idempotent no-op.\n if (pending === undefined || pending.status !== \"pending\") {\n return { type: \"already-resolved\", interruptId };\n }\n\n // Resolve + delete BEFORE the re-run so a re-run that itself raises a new\n // interrupt cannot collide with the one being resolved, and a concurrent\n // resume of the same id sees it gone.\n await store.delete(interruptId);\n\n if (!options.agent) {\n return { type: \"applied\", interruptId, decision };\n }\n\n return rerun(pending, decision, options);\n}\n"],"mappings":";;;;;;;;;;;AAgBA,SAAS,eAAe,UAAkC;CACxD,IAAI,SAAS,SAAS,WACpB;CAGF,IAAI,SAAS,SAAS,UAAU;EAC9B,IAAI,OAAO,SAAS,WAAW,UAC7B,MAAM,IAAI,UACR,kEACF;EAGF;CACF;CAEA,IAAI,SAAS,SAAS,QAAQ;EAC5B,IAAI,EAAE,UAAU,WACd,MAAM,IAAI,UACR,kEACF;EAGF;CACF;CAEA,MAAM,IAAI,UACR,2CAA4C,SAA8B,KAAK,2CACjF;AACF;;;;;;;;;;;AAYA,eAAe,MACb,SACA,UACA,SACgC;CAChC,MAAM,EAAE,UAAU;CAIlB,IAAI,CAAC,OACH,OAAO;EAAE,MAAM;EAAW,aAAa,QAAQ;EAAa;CAAS;CAGvE,MAAM,QAAQ,QAAQ,SAAS,QAAQ,QAAQ,QAAQ,iBAAiB;CAExE,aAAa,MAAM,MAAM,QAAQ;CAEjC,IAAI;EACF,MAAM,SAAS,MAAM,MAAM,QAAQ,OAAO,QAAQ,cAAc;EAEhE,OAAO;GACL,MAAM;GACN,aAAa,QAAQ;GACrB;GACA;EACF;CACF,UAAU;EAIR,oBAAoB,MAAM,IAAI;CAChC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,eAAsB,OACpB,aACA,UACA,SACgC;CAChC,eAAe,QAAQ;CAEvB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,MAAM,MAAM,KAAK,WAAW;CAI5C,IAAI,YAAY,UAAa,QAAQ,WAAW,WAC9C,OAAO;EAAE,MAAM;EAAoB;CAAY;CAMjD,MAAM,MAAM,OAAO,WAAW;CAE9B,IAAI,CAAC,QAAQ,OACX,OAAO;EAAE,MAAM;EAAW;EAAa;CAAS;CAGlD,OAAO,MAAM,SAAS,UAAU,OAAO;AACzC"}
@@ -0,0 +1,5 @@
1
+ import { memory } from "./memory.mjs";
2
+ import { pg } from "./pg.mjs";
3
+ import { redis } from "./redis.mjs";
4
+
5
+ export { };
@@ -0,0 +1,30 @@
1
+ import { InterruptStore } from "../contracts/interrupt-store.contract.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/human/stores/memory.d.ts
4
+ /**
5
+ * Create an in-memory {@link InterruptStore}. Zero-config — no client, no
6
+ * connection. Suitable for dev, tests, and single-process apps whose
7
+ * approval flow stays interactive and doesn't need resume across
8
+ * restarts.
9
+ *
10
+ * @example
11
+ * import { ai } from "@warlock.js/ai";
12
+ *
13
+ * const store = ai.human.interrupt.memory();
14
+ *
15
+ * const agent = ai.agent({
16
+ * model,
17
+ * tools: [deleteAccount],
18
+ * middleware: [
19
+ * ai.human.approval({
20
+ * policy: { type: "allowlist", tools: ["deleteAccount"] },
21
+ * store,
22
+ * handler,
23
+ * }),
24
+ * ],
25
+ * });
26
+ */
27
+ declare function memory(): InterruptStore;
28
+ //#endregion
29
+ export { memory };
30
+ //# sourceMappingURL=memory.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/human/stores/memory.ts"],"mappings":";;;;;AAmGA;;;;AAAwC;;;;;;;;;;;;;;;;;iBAAxB,MAAA,IAAU,cAAc"}
@@ -0,0 +1,91 @@
1
+ //#region ../@warlock.js/ai/src/human/stores/memory.ts
2
+ /**
3
+ * In-memory {@link InterruptStore} — pending interrupts held in a
4
+ * process-local `Map`, never persisted to disk.
5
+ *
6
+ * Owns: the `interruptId → {@link PendingInterrupt}` index and the
7
+ * last-writer-wins `save` / `load` / `delete` / `list` semantics the
8
+ * contract declares. Does NOT own: durability, cross-process sharing, or
9
+ * TTL eviction — it is the zero-config default for dev, tests, and
10
+ * single-process apps whose approval flow stays interactive (the run
11
+ * `await`s the decision in-process and never needs to survive a restart).
12
+ * Reach for `ai.human.interrupt.pg()` / `ai.human.interrupt.redis()` when
13
+ * a reviewer rules out-of-process, hours later.
14
+ *
15
+ * Front it with the {@link memory} factory — callers never `new` it.
16
+ */
17
+ var MemoryInterruptStore = class {
18
+ constructor() {
19
+ this.interrupts = /* @__PURE__ */ new Map();
20
+ }
21
+ /**
22
+ * Persist a pending interrupt, keyed by its own `interruptId`.
23
+ * Overwrites any prior record for the same id — a call has exactly one
24
+ * live interrupt, so a re-save replaces rather than appends.
25
+ */
26
+ async save(record) {
27
+ this.interrupts.set(record.interruptId, record);
28
+ }
29
+ /**
30
+ * Return the interrupt for an `interruptId`, or `undefined` when none is
31
+ * recorded (never raised, or already resolved + deleted).
32
+ */
33
+ async load(interruptId) {
34
+ return this.interrupts.get(interruptId);
35
+ }
36
+ /**
37
+ * Drop the interrupt for an `interruptId`. Idempotent — deleting an
38
+ * absent id is a no-op.
39
+ */
40
+ async delete(interruptId) {
41
+ this.interrupts.delete(interruptId);
42
+ }
43
+ /**
44
+ * List the interrupt ids the store knows, optionally filtered by a
45
+ * prefix. Returns a fresh array each call so a caller can mutate it
46
+ * freely without touching the backing index.
47
+ */
48
+ async list(prefix) {
49
+ const ids = [...this.interrupts.keys()];
50
+ if (prefix === void 0) return ids;
51
+ return ids.filter((id) => id.startsWith(prefix));
52
+ }
53
+ /**
54
+ * The memory store has no backing table — there is nothing to migrate.
55
+ * Returns an empty string so callers can treat `schema()` uniformly
56
+ * across drivers.
57
+ */
58
+ schema() {
59
+ return "";
60
+ }
61
+ };
62
+ /**
63
+ * Create an in-memory {@link InterruptStore}. Zero-config — no client, no
64
+ * connection. Suitable for dev, tests, and single-process apps whose
65
+ * approval flow stays interactive and doesn't need resume across
66
+ * restarts.
67
+ *
68
+ * @example
69
+ * import { ai } from "@warlock.js/ai";
70
+ *
71
+ * const store = ai.human.interrupt.memory();
72
+ *
73
+ * const agent = ai.agent({
74
+ * model,
75
+ * tools: [deleteAccount],
76
+ * middleware: [
77
+ * ai.human.approval({
78
+ * policy: { type: "allowlist", tools: ["deleteAccount"] },
79
+ * store,
80
+ * handler,
81
+ * }),
82
+ * ],
83
+ * });
84
+ */
85
+ function memory() {
86
+ return new MemoryInterruptStore();
87
+ }
88
+
89
+ //#endregion
90
+ export { memory };
91
+ //# sourceMappingURL=memory.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/human/stores/memory.ts"],"sourcesContent":["import type {\n InterruptStore,\n PendingInterrupt,\n} from \"../contracts/interrupt-store.contract\";\n\n/**\n * In-memory {@link InterruptStore} — pending interrupts held in a\n * process-local `Map`, never persisted to disk.\n *\n * Owns: the `interruptId → {@link PendingInterrupt}` index and the\n * last-writer-wins `save` / `load` / `delete` / `list` semantics the\n * contract declares. Does NOT own: durability, cross-process sharing, or\n * TTL eviction — it is the zero-config default for dev, tests, and\n * single-process apps whose approval flow stays interactive (the run\n * `await`s the decision in-process and never needs to survive a restart).\n * Reach for `ai.human.interrupt.pg()` / `ai.human.interrupt.redis()` when\n * a reviewer rules out-of-process, hours later.\n *\n * Front it with the {@link memory} factory — callers never `new` it.\n */\nclass MemoryInterruptStore implements InterruptStore {\n /** Pending interrupts keyed by their own `interruptId`. */\n private readonly interrupts = new Map<string, PendingInterrupt>();\n\n /**\n * Persist a pending interrupt, keyed by its own `interruptId`.\n * Overwrites any prior record for the same id — a call has exactly one\n * live interrupt, so a re-save replaces rather than appends.\n */\n public async save(record: PendingInterrupt): Promise<void> {\n this.interrupts.set(record.interruptId, record);\n }\n\n /**\n * Return the interrupt for an `interruptId`, or `undefined` when none is\n * recorded (never raised, or already resolved + deleted).\n */\n public async load(\n interruptId: string,\n ): Promise<PendingInterrupt | undefined> {\n return this.interrupts.get(interruptId);\n }\n\n /**\n * Drop the interrupt for an `interruptId`. Idempotent — deleting an\n * absent id is a no-op.\n */\n public async delete(interruptId: string): Promise<void> {\n this.interrupts.delete(interruptId);\n }\n\n /**\n * List the interrupt ids the store knows, optionally filtered by a\n * prefix. Returns a fresh array each call so a caller can mutate it\n * freely without touching the backing index.\n */\n public async list(prefix?: string): Promise<string[]> {\n const ids = [...this.interrupts.keys()];\n\n if (prefix === undefined) {\n return ids;\n }\n\n return ids.filter((id) => id.startsWith(prefix));\n }\n\n /**\n * The memory store has no backing table — there is nothing to migrate.\n * Returns an empty string so callers can treat `schema()` uniformly\n * across drivers.\n */\n public schema(): string {\n return \"\";\n }\n}\n\n/**\n * Create an in-memory {@link InterruptStore}. Zero-config — no client, no\n * connection. Suitable for dev, tests, and single-process apps whose\n * approval flow stays interactive and doesn't need resume across\n * restarts.\n *\n * @example\n * import { ai } from \"@warlock.js/ai\";\n *\n * const store = ai.human.interrupt.memory();\n *\n * const agent = ai.agent({\n * model,\n * tools: [deleteAccount],\n * middleware: [\n * ai.human.approval({\n * policy: { type: \"allowlist\", tools: [\"deleteAccount\"] },\n * store,\n * handler,\n * }),\n * ],\n * });\n */\nexport function memory(): InterruptStore {\n return new MemoryInterruptStore();\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,IAAM,uBAAN,MAAqD;;oCAErB,IAAI,IAA8B;;;;;;;CAOhE,MAAa,KAAK,QAAyC;EACzD,KAAK,WAAW,IAAI,OAAO,aAAa,MAAM;CAChD;;;;;CAMA,MAAa,KACX,aACuC;EACvC,OAAO,KAAK,WAAW,IAAI,WAAW;CACxC;;;;;CAMA,MAAa,OAAO,aAAoC;EACtD,KAAK,WAAW,OAAO,WAAW;CACpC;;;;;;CAOA,MAAa,KAAK,QAAoC;EACpD,MAAM,MAAM,CAAC,GAAG,KAAK,WAAW,KAAK,CAAC;EAEtC,IAAI,WAAW,QACb,OAAO;EAGT,OAAO,IAAI,QAAQ,OAAO,GAAG,WAAW,MAAM,CAAC;CACjD;;;;;;CAOA,AAAO,SAAiB;EACtB,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAAyB;CACvC,OAAO,IAAI,qBAAqB;AAClC"}
@@ -0,0 +1,59 @@
1
+ import { InterruptStore, PgClientLike } from "../contracts/interrupt-store.contract.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/human/stores/pg.d.ts
4
+ /**
5
+ * Options for the Postgres {@link InterruptStore}.
6
+ *
7
+ * Two mutually-supportive ways to supply the connection:
8
+ * - **`client`** — pass an already-built `pg.Pool` / `pg.Client` (anything
9
+ * satisfying {@link PgClientLike}). The store only ever calls `query`
10
+ * and never opens or closes it; a single pool can back both an
11
+ * orchestrator's checkpoint/snapshot stores and this interrupt table.
12
+ * - **`connectionString`** — let the store lazily `import("pg")` and build
13
+ * its own `Pool`. `@warlock.js/ai` takes **no** hard dependency on
14
+ * `pg` (it is an optional peer); when it is absent the store throws a
15
+ * curated install string at first use, never a raw module-resolution
16
+ * stack trace at import.
17
+ *
18
+ * Exactly one of the two must be present.
19
+ */
20
+ interface PgInterruptOptions {
21
+ /** An already-built `pg.Pool` / `pg.Client` — anything matching {@link PgClientLike}. */
22
+ client?: PgClientLike;
23
+ /** Connection string the store passes to a lazily-imported `pg.Pool`. */
24
+ connectionString?: string;
25
+ /**
26
+ * Backing table name. Defaults to `warlock_ai_human_interrupts`. Must be
27
+ * a safe SQL identifier — it is interpolated into DDL/DML.
28
+ */
29
+ table?: string;
30
+ }
31
+ /**
32
+ * Create a Postgres-backed {@link InterruptStore}. Either pass a live
33
+ * `pg.Pool` / `pg.Client` (`{ client }`) — `@warlock.js/ai` never
34
+ * imports `pg` in that case — or a `{ connectionString }` and let the
35
+ * store lazily `import("pg")` to build its own pool. When `pg` is not
36
+ * installed, the curated install string surfaces on first use, never at
37
+ * import. Run {@link InterruptStore.schema} through your migration tool
38
+ * once before use; the store never auto-migrates.
39
+ *
40
+ * @example
41
+ * import { Pool } from "pg";
42
+ * import { ai } from "@warlock.js/ai";
43
+ *
44
+ * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
45
+ * const store = ai.human.interrupt.pg({ client: pool });
46
+ *
47
+ * // Once, via your migration tooling:
48
+ * // await pool.query(store.schema());
49
+ *
50
+ * @example
51
+ * // Let the store build its own pool from a connection string:
52
+ * const store = ai.human.interrupt.pg({
53
+ * connectionString: process.env.DATABASE_URL,
54
+ * });
55
+ */
56
+ declare function pg(options: PgInterruptOptions): InterruptStore;
57
+ //#endregion
58
+ export { PgInterruptOptions, pg };
59
+ //# sourceMappingURL=pg.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/human/stores/pg.ts"],"mappings":";;;;;AAsBA;;;;;;;;;AAWO;AA0TP;;;;UArUiB,kBAAA;EAqUE;EAnUjB,MAAA,GAAS,YAAY;EAmUwC;EAhU7D,gBAAA;;;;;EAMA,KAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0Tc,EAAA,CAAG,OAAA,EAAS,kBAAA,GAAqB,cAAc"}