@warlock.js/ai 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 (648) hide show
  1. package/CHANGELOG.md +63 -52
  2. package/cjs/index.cjs +240 -14147
  3. package/cjs/src-Bmajk4Qg.cjs +30 -0
  4. package/cjs/src-OZyDYHxm.cjs +25089 -0
  5. package/cjs/src-OZyDYHxm.cjs.map +1 -0
  6. package/esm/agent/agent-config.type.d.mts +119 -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 +328 -36
  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/agent/signature.mjs +57 -0
  21. package/esm/agent/signature.mjs.map +1 -0
  22. package/esm/agent/snapshot.mjs +101 -0
  23. package/esm/agent/snapshot.mjs.map +1 -0
  24. package/esm/ai-openai/src/embedder.mjs +4 -0
  25. package/esm/ai-openai/src/image.mjs +5 -0
  26. package/esm/ai-openai/src/index.mjs +7 -0
  27. package/esm/ai-openai/src/model.mjs +5 -0
  28. package/esm/ai-openai/src/sdk.mjs +9 -0
  29. package/esm/ai-openai/src/speech.mjs +5 -0
  30. package/esm/ai-openai/src/transcription.mjs +6 -0
  31. package/esm/ai-openai/src/utils/index.mjs +5 -0
  32. package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -0
  33. package/esm/ai-openai/src/utils/to-openai-tools.mjs +3 -0
  34. package/esm/ai-openai/src/utils/wrap-openai-error.mjs +4 -0
  35. package/esm/ai.d.mts +164 -53
  36. package/esm/ai.d.mts.map +1 -1
  37. package/esm/ai.mjs +79 -8
  38. package/esm/ai.mjs.map +1 -1
  39. package/esm/batch/batch.d.mts.map +1 -1
  40. package/esm/batch/batch.mjs +21 -1
  41. package/esm/batch/batch.mjs.map +1 -1
  42. package/esm/batch/batch.type.d.mts +11 -4
  43. package/esm/batch/batch.type.d.mts.map +1 -1
  44. package/esm/config.d.mts +39 -3
  45. package/esm/config.d.mts.map +1 -1
  46. package/esm/config.mjs +26 -2
  47. package/esm/config.mjs.map +1 -1
  48. package/esm/contracts/agent/agent-options.type.d.mts +33 -5
  49. package/esm/contracts/agent/agent-options.type.d.mts.map +1 -1
  50. package/esm/contracts/agent/agent-snapshot.type.d.mts +90 -0
  51. package/esm/contracts/agent/agent-snapshot.type.d.mts.map +1 -0
  52. package/esm/contracts/agent/agent.contract.d.mts +29 -1
  53. package/esm/contracts/agent/agent.contract.d.mts.map +1 -1
  54. package/esm/contracts/agent/eval.type.d.mts +43 -2
  55. package/esm/contracts/agent/eval.type.d.mts.map +1 -1
  56. package/esm/contracts/agent/index.d.mts +2 -1
  57. package/esm/contracts/attachment-policy.type.d.mts +51 -0
  58. package/esm/contracts/attachment-policy.type.d.mts.map +1 -0
  59. package/esm/contracts/attachment.type.d.mts +16 -7
  60. package/esm/contracts/attachment.type.d.mts.map +1 -1
  61. package/esm/contracts/content-part.type.d.mts +14 -5
  62. package/esm/contracts/content-part.type.d.mts.map +1 -1
  63. package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -1
  64. package/esm/contracts/image-model.contract.d.mts +156 -0
  65. package/esm/contracts/image-model.contract.d.mts.map +1 -0
  66. package/esm/contracts/index.d.mts +13 -6
  67. package/esm/contracts/model.contract.d.mts +11 -8
  68. package/esm/contracts/model.contract.d.mts.map +1 -1
  69. package/esm/contracts/orchestrator/index.d.mts +1 -0
  70. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts +31 -2
  71. package/esm/contracts/orchestrator/orchestrator-config.type.d.mts.map +1 -1
  72. package/esm/contracts/orchestrator/session-lock.contract.d.mts +47 -0
  73. package/esm/contracts/orchestrator/session-lock.contract.d.mts.map +1 -0
  74. package/esm/contracts/planner/index.d.mts +3 -2
  75. package/esm/contracts/planner/planner-config.type.d.mts +61 -0
  76. package/esm/contracts/planner/planner-config.type.d.mts.map +1 -1
  77. package/esm/contracts/planner/planner-execute-options.type.d.mts +60 -1
  78. package/esm/contracts/planner/planner-execute-options.type.d.mts.map +1 -1
  79. package/esm/contracts/planner/planner-result.type.d.mts +8 -0
  80. package/esm/contracts/planner/planner-result.type.d.mts.map +1 -1
  81. package/esm/contracts/planner/planner-snapshot.type.d.mts +77 -0
  82. package/esm/contracts/planner/planner-snapshot.type.d.mts.map +1 -0
  83. package/esm/contracts/planner/planner.contract.d.mts +21 -1
  84. package/esm/contracts/planner/planner.contract.d.mts.map +1 -1
  85. package/esm/contracts/result/agent-result.type.d.mts +6 -4
  86. package/esm/contracts/result/agent-result.type.d.mts.map +1 -1
  87. package/esm/contracts/result/base-report.type.d.mts +21 -3
  88. package/esm/contracts/result/base-report.type.d.mts.map +1 -1
  89. package/esm/contracts/result/base-report.type.mjs.map +1 -1
  90. package/esm/contracts/result/execution-report.type.d.mts +53 -1
  91. package/esm/contracts/result/execution-report.type.d.mts.map +1 -1
  92. package/esm/contracts/result/supervisor-result.type.d.mts +14 -2
  93. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
  94. package/esm/contracts/result/workflow-result.type.d.mts +2 -1
  95. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
  96. package/esm/contracts/sdk-adapter.contract.d.mts +37 -0
  97. package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -1
  98. package/esm/contracts/speech-model.contract.d.mts +97 -0
  99. package/esm/contracts/speech-model.contract.d.mts.map +1 -0
  100. package/esm/contracts/supervisor/supervisor-config.type.d.mts +29 -0
  101. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  102. package/esm/contracts/system-prompt.contract.d.mts +103 -1
  103. package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
  104. package/esm/contracts/team/index.d.mts +1 -0
  105. package/esm/contracts/team/team-config.type.d.mts +127 -0
  106. package/esm/contracts/team/team-config.type.d.mts.map +1 -0
  107. package/esm/contracts/tool.contract.d.mts +4 -2
  108. package/esm/contracts/tool.contract.d.mts.map +1 -1
  109. package/esm/contracts/transcription-model.contract.d.mts +101 -0
  110. package/esm/contracts/transcription-model.contract.d.mts.map +1 -0
  111. package/esm/contracts/workflow/step.contract.d.mts +30 -5
  112. package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
  113. package/esm/contracts/workflow/workflow.contract.d.mts +16 -0
  114. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  115. package/esm/errors/agent-drift-error.d.mts +32 -0
  116. package/esm/errors/agent-drift-error.d.mts.map +1 -0
  117. package/esm/errors/agent-drift-error.mjs +31 -0
  118. package/esm/errors/agent-drift-error.mjs.map +1 -0
  119. package/esm/errors/error-code.type.d.mts +1 -1
  120. package/esm/errors/index.d.mts +3 -0
  121. package/esm/errors/index.mjs +3 -0
  122. package/esm/errors/outbound-policy-error.d.mts +27 -0
  123. package/esm/errors/outbound-policy-error.d.mts.map +1 -0
  124. package/esm/errors/outbound-policy-error.mjs +32 -0
  125. package/esm/errors/outbound-policy-error.mjs.map +1 -0
  126. package/esm/errors/planner-drift-error.d.mts +34 -0
  127. package/esm/errors/planner-drift-error.d.mts.map +1 -0
  128. package/esm/errors/planner-drift-error.mjs +33 -0
  129. package/esm/errors/planner-drift-error.mjs.map +1 -0
  130. package/esm/eval/dataset.d.mts +28 -0
  131. package/esm/eval/dataset.d.mts.map +1 -0
  132. package/esm/eval/dataset.mjs +112 -0
  133. package/esm/eval/dataset.mjs.map +1 -0
  134. package/esm/eval/dataset.type.d.mts +53 -0
  135. package/esm/eval/dataset.type.d.mts.map +1 -0
  136. package/esm/eval/eval-runner.d.mts.map +1 -1
  137. package/esm/eval/eval-runner.mjs +16 -2
  138. package/esm/eval/eval-runner.mjs.map +1 -1
  139. package/esm/eval/index.d.mts +20 -1
  140. package/esm/eval/index.d.mts.map +1 -1
  141. package/esm/eval/index.mjs +20 -2
  142. package/esm/eval/index.mjs.map +1 -1
  143. package/esm/eval/regression.d.mts +30 -0
  144. package/esm/eval/regression.d.mts.map +1 -0
  145. package/esm/eval/regression.mjs +51 -0
  146. package/esm/eval/regression.mjs.map +1 -0
  147. package/esm/eval/report-json.d.mts +30 -0
  148. package/esm/eval/report-json.d.mts.map +1 -0
  149. package/esm/eval/report-json.mjs +33 -0
  150. package/esm/eval/report-json.mjs.map +1 -0
  151. package/esm/eval/report-junit.d.mts +22 -0
  152. package/esm/eval/report-junit.d.mts.map +1 -0
  153. package/esm/eval/report-junit.mjs +60 -0
  154. package/esm/eval/report-junit.mjs.map +1 -0
  155. package/esm/guard/contracts/guard-options.type.d.mts +165 -0
  156. package/esm/guard/contracts/guard-options.type.d.mts.map +1 -0
  157. package/esm/guard/contracts/guardrail.contract.d.mts +78 -0
  158. package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -0
  159. package/esm/guard/contracts/index.d.mts +4 -0
  160. package/esm/guard/contracts/openai-client.contract.d.mts +51 -0
  161. package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -0
  162. package/esm/guard/contracts/verdict.type.d.mts +76 -0
  163. package/esm/guard/contracts/verdict.type.d.mts.map +1 -0
  164. package/esm/guard/detectors/index.d.mts +4 -0
  165. package/esm/guard/detectors/index.mjs +6 -0
  166. package/esm/guard/detectors/injection.d.mts +34 -0
  167. package/esm/guard/detectors/injection.d.mts.map +1 -0
  168. package/esm/guard/detectors/injection.mjs +254 -0
  169. package/esm/guard/detectors/injection.mjs.map +1 -0
  170. package/esm/guard/detectors/moderation.d.mts +32 -0
  171. package/esm/guard/detectors/moderation.d.mts.map +1 -0
  172. package/esm/guard/detectors/moderation.mjs +134 -0
  173. package/esm/guard/detectors/moderation.mjs.map +1 -0
  174. package/esm/guard/detectors/pii.d.mts +41 -0
  175. package/esm/guard/detectors/pii.d.mts.map +1 -0
  176. package/esm/guard/detectors/pii.mjs +199 -0
  177. package/esm/guard/detectors/pii.mjs.map +1 -0
  178. package/esm/guard/detectors/topic.d.mts +29 -0
  179. package/esm/guard/detectors/topic.d.mts.map +1 -0
  180. package/esm/guard/detectors/topic.mjs +99 -0
  181. package/esm/guard/detectors/topic.mjs.map +1 -0
  182. package/esm/guard/errors.d.mts +12 -0
  183. package/esm/guard/errors.d.mts.map +1 -0
  184. package/esm/guard/errors.mjs +18 -0
  185. package/esm/guard/errors.mjs.map +1 -0
  186. package/esm/guard/guard.d.mts +67 -0
  187. package/esm/guard/guard.d.mts.map +1 -0
  188. package/esm/guard/guard.mjs +209 -0
  189. package/esm/guard/guard.mjs.map +1 -0
  190. package/esm/guard/guardrail.d.mts +39 -0
  191. package/esm/guard/guardrail.d.mts.map +1 -0
  192. package/esm/guard/guardrail.mjs +22 -0
  193. package/esm/guard/guardrail.mjs.map +1 -0
  194. package/esm/human/contracts/approval.type.d.mts +154 -0
  195. package/esm/human/contracts/approval.type.d.mts.map +1 -0
  196. package/esm/human/contracts/human-approval.type.d.mts +38 -0
  197. package/esm/human/contracts/human-approval.type.d.mts.map +1 -0
  198. package/esm/human/contracts/index.d.mts +4 -0
  199. package/esm/human/contracts/interrupt-store.contract.d.mts +112 -0
  200. package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -0
  201. package/esm/human/contracts/resume.type.d.mts +77 -0
  202. package/esm/human/contracts/resume.type.d.mts.map +1 -0
  203. package/esm/human/errors.d.mts +84 -0
  204. package/esm/human/errors.d.mts.map +1 -0
  205. package/esm/human/errors.mjs +60 -0
  206. package/esm/human/errors.mjs.map +1 -0
  207. package/esm/human/human-approval.d.mts +57 -0
  208. package/esm/human/human-approval.d.mts.map +1 -0
  209. package/esm/human/human-approval.mjs +170 -0
  210. package/esm/human/human-approval.mjs.map +1 -0
  211. package/esm/human/policy.d.mts +55 -0
  212. package/esm/human/policy.d.mts.map +1 -0
  213. package/esm/human/policy.mjs +67 -0
  214. package/esm/human/policy.mjs.map +1 -0
  215. package/esm/human/register.mjs +37 -0
  216. package/esm/human/register.mjs.map +1 -0
  217. package/esm/human/resume-seed.mjs +53 -0
  218. package/esm/human/resume-seed.mjs.map +1 -0
  219. package/esm/human/resume.d.mts +54 -0
  220. package/esm/human/resume.d.mts.map +1 -0
  221. package/esm/human/resume.mjs +121 -0
  222. package/esm/human/resume.mjs.map +1 -0
  223. package/esm/human/stores/index.mjs +5 -0
  224. package/esm/human/stores/memory.d.mts +30 -0
  225. package/esm/human/stores/memory.d.mts.map +1 -0
  226. package/esm/human/stores/memory.mjs +91 -0
  227. package/esm/human/stores/memory.mjs.map +1 -0
  228. package/esm/human/stores/pg.d.mts +59 -0
  229. package/esm/human/stores/pg.d.mts.map +1 -0
  230. package/esm/human/stores/pg.mjs +220 -0
  231. package/esm/human/stores/pg.mjs.map +1 -0
  232. package/esm/human/stores/redis.d.mts +56 -0
  233. package/esm/human/stores/redis.d.mts.map +1 -0
  234. package/esm/human/stores/redis.mjs +201 -0
  235. package/esm/human/stores/redis.mjs.map +1 -0
  236. package/esm/image/image-cost.d.mts +32 -0
  237. package/esm/image/image-cost.d.mts.map +1 -0
  238. package/esm/image/image-cost.mjs +55 -0
  239. package/esm/image/image-cost.mjs.map +1 -0
  240. package/esm/image/image.d.mts +92 -0
  241. package/esm/image/image.d.mts.map +1 -0
  242. package/esm/image/image.mjs +113 -0
  243. package/esm/image/image.mjs.map +1 -0
  244. package/esm/image/index.mjs +4 -0
  245. package/esm/index.d.mts +137 -24
  246. package/esm/index.mjs +101 -11
  247. package/esm/middleware/builtins/budget.mjs +6 -2
  248. package/esm/middleware/builtins/budget.mjs.map +1 -1
  249. package/esm/middleware/utils/extract-user-text.d.mts +8 -1
  250. package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
  251. package/esm/middleware/utils/extract-user-text.mjs +8 -1
  252. package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
  253. package/esm/mock/index.d.mts +3 -0
  254. package/esm/mock/index.mjs +3 -0
  255. package/esm/mock/mock-config.type.d.mts +22 -0
  256. package/esm/mock/mock-config.type.d.mts.map +1 -1
  257. package/esm/mock/mock-image-model.d.mts +41 -0
  258. package/esm/mock/mock-image-model.d.mts.map +1 -0
  259. package/esm/mock/mock-image-model.mjs +52 -0
  260. package/esm/mock/mock-image-model.mjs.map +1 -0
  261. package/esm/mock/mock-sdk.d.mts +7 -1
  262. package/esm/mock/mock-sdk.d.mts.map +1 -1
  263. package/esm/mock/mock-sdk.mjs +27 -0
  264. package/esm/mock/mock-sdk.mjs.map +1 -1
  265. package/esm/mock/mock-speech-model.d.mts +31 -0
  266. package/esm/mock/mock-speech-model.d.mts.map +1 -0
  267. package/esm/mock/mock-speech-model.mjs +39 -0
  268. package/esm/mock/mock-speech-model.mjs.map +1 -0
  269. package/esm/mock/mock-transcription-model.d.mts +32 -0
  270. package/esm/mock/mock-transcription-model.d.mts.map +1 -0
  271. package/esm/mock/mock-transcription-model.mjs +36 -0
  272. package/esm/mock/mock-transcription-model.mjs.map +1 -0
  273. package/esm/object-stream/index.d.mts +2 -0
  274. package/esm/object-stream/index.mjs +4 -0
  275. package/esm/object-stream/parse-partial-json.d.mts +22 -0
  276. package/esm/object-stream/parse-partial-json.d.mts.map +1 -0
  277. package/esm/object-stream/parse-partial-json.mjs +78 -0
  278. package/esm/object-stream/parse-partial-json.mjs.map +1 -0
  279. package/esm/object-stream/stream-object.d.mts +68 -0
  280. package/esm/object-stream/stream-object.d.mts.map +1 -0
  281. package/esm/object-stream/stream-object.mjs +104 -0
  282. package/esm/object-stream/stream-object.mjs.map +1 -0
  283. package/esm/observe/index.mjs +4 -0
  284. package/esm/observe/observer-registry.d.mts +30 -0
  285. package/esm/observe/observer-registry.d.mts.map +1 -0
  286. package/esm/observe/observer-registry.mjs +51 -0
  287. package/esm/observe/observer-registry.mjs.map +1 -0
  288. package/esm/observe/observer.contract.d.mts +40 -0
  289. package/esm/observe/observer.contract.d.mts.map +1 -0
  290. package/esm/observe/resolve-observers.d.mts +40 -0
  291. package/esm/observe/resolve-observers.d.mts.map +1 -0
  292. package/esm/observe/resolve-observers.mjs +73 -0
  293. package/esm/observe/resolve-observers.mjs.map +1 -0
  294. package/esm/orchestrator/execution.d.mts.map +1 -1
  295. package/esm/orchestrator/execution.mjs +5 -2
  296. package/esm/orchestrator/execution.mjs.map +1 -1
  297. package/esm/orchestrator/index.d.mts +1 -0
  298. package/esm/orchestrator/index.mjs +1 -0
  299. package/esm/orchestrator/orchestrator.d.mts.map +1 -1
  300. package/esm/orchestrator/orchestrator.mjs +39 -6
  301. package/esm/orchestrator/orchestrator.mjs.map +1 -1
  302. package/esm/orchestrator/session-lock.d.mts +25 -0
  303. package/esm/orchestrator/session-lock.d.mts.map +1 -0
  304. package/esm/orchestrator/session-lock.mjs +83 -0
  305. package/esm/orchestrator/session-lock.mjs.map +1 -0
  306. package/esm/planner/dag-scheduler.mjs +97 -0
  307. package/esm/planner/dag-scheduler.mjs.map +1 -0
  308. package/esm/planner/plan-prompt.d.mts +1 -1
  309. package/esm/planner/plan-prompt.d.mts.map +1 -1
  310. package/esm/planner/plan-prompt.mjs +2 -1
  311. package/esm/planner/plan-prompt.mjs.map +1 -1
  312. package/esm/planner/planner-run.d.mts +8 -0
  313. package/esm/planner/planner-run.d.mts.map +1 -1
  314. package/esm/planner/planner-run.mjs +457 -31
  315. package/esm/planner/planner-run.mjs.map +1 -1
  316. package/esm/planner/planner.d.mts.map +1 -1
  317. package/esm/planner/planner.mjs +26 -2
  318. package/esm/planner/planner.mjs.map +1 -1
  319. package/esm/planner/snapshot.mjs +95 -0
  320. package/esm/planner/snapshot.mjs.map +1 -0
  321. package/esm/prompt/errors.d.mts +57 -0
  322. package/esm/prompt/errors.d.mts.map +1 -0
  323. package/esm/prompt/errors.mjs +73 -0
  324. package/esm/prompt/errors.mjs.map +1 -0
  325. package/esm/prompt/index.d.mts +3 -0
  326. package/esm/prompt/index.mjs +4 -0
  327. package/esm/prompt/prompt-langfuse-sync.mjs +104 -0
  328. package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -0
  329. package/esm/prompt/prompt-langfuse-sync.type.d.mts +32 -0
  330. package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -0
  331. package/esm/prompt/prompt-validate.mjs +170 -0
  332. package/esm/prompt/prompt-validate.mjs.map +1 -0
  333. package/esm/prompt/prompt.d.mts +54 -0
  334. package/esm/prompt/prompt.d.mts.map +1 -0
  335. package/esm/prompt/prompt.mjs +218 -0
  336. package/esm/prompt/prompt.mjs.map +1 -0
  337. package/esm/prompt/prompt.type.d.mts +174 -0
  338. package/esm/prompt/prompt.type.d.mts.map +1 -0
  339. package/esm/prompts/index.d.mts +3 -0
  340. package/esm/prompts/index.mjs +3 -0
  341. package/esm/prompts/prompts-manager.contract.d.mts +154 -0
  342. package/esm/prompts/prompts-manager.contract.d.mts.map +1 -0
  343. package/esm/prompts/prompts-manager.d.mts +38 -0
  344. package/esm/prompts/prompts-manager.d.mts.map +1 -0
  345. package/esm/prompts/prompts-manager.mjs +410 -0
  346. package/esm/prompts/prompts-manager.mjs.map +1 -0
  347. package/esm/prompts/prompts-manager.type.d.mts +172 -0
  348. package/esm/prompts/prompts-manager.type.d.mts.map +1 -0
  349. package/esm/prompts/prompts-validate.mjs +200 -0
  350. package/esm/prompts/prompts-validate.mjs.map +1 -0
  351. package/esm/rag/as-tool.mjs +48 -0
  352. package/esm/rag/as-tool.mjs.map +1 -0
  353. package/esm/rag/chunk/chunk.d.mts +24 -0
  354. package/esm/rag/chunk/chunk.d.mts.map +1 -0
  355. package/esm/rag/chunk/chunk.mjs +44 -0
  356. package/esm/rag/chunk/chunk.mjs.map +1 -0
  357. package/esm/rag/chunk/fixed.mjs +32 -0
  358. package/esm/rag/chunk/fixed.mjs.map +1 -0
  359. package/esm/rag/chunk/markdown.mjs +75 -0
  360. package/esm/rag/chunk/markdown.mjs.map +1 -0
  361. package/esm/rag/chunk/recursive.mjs +132 -0
  362. package/esm/rag/chunk/recursive.mjs.map +1 -0
  363. package/esm/rag/chunk/sentence.mjs +73 -0
  364. package/esm/rag/chunk/sentence.mjs.map +1 -0
  365. package/esm/rag/contracts/chunk-options.type.d.mts +35 -0
  366. package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -0
  367. package/esm/rag/contracts/citation.type.d.mts +35 -0
  368. package/esm/rag/contracts/citation.type.d.mts.map +1 -0
  369. package/esm/rag/contracts/index.d.mts +4 -0
  370. package/esm/rag/contracts/rag-config.type.d.mts +68 -0
  371. package/esm/rag/contracts/rag-config.type.d.mts.map +1 -0
  372. package/esm/rag/contracts/rag-document.type.d.mts +21 -0
  373. package/esm/rag/contracts/rag-document.type.d.mts.map +1 -0
  374. package/esm/rag/hybrid/bm25.d.mts +23 -0
  375. package/esm/rag/hybrid/bm25.d.mts.map +1 -0
  376. package/esm/rag/hybrid/bm25.mjs +51 -0
  377. package/esm/rag/hybrid/bm25.mjs.map +1 -0
  378. package/esm/rag/hybrid/hybrid-rank.d.mts +33 -0
  379. package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -0
  380. package/esm/rag/hybrid/hybrid-rank.mjs +29 -0
  381. package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -0
  382. package/esm/rag/hybrid/rrf.d.mts +25 -0
  383. package/esm/rag/hybrid/rrf.d.mts.map +1 -0
  384. package/esm/rag/hybrid/rrf.mjs +30 -0
  385. package/esm/rag/hybrid/rrf.mjs.map +1 -0
  386. package/esm/rag/index.d.mts +22 -0
  387. package/esm/rag/index.mjs +18 -0
  388. package/esm/rag/loaders/errors.d.mts +19 -0
  389. package/esm/rag/loaders/errors.d.mts.map +1 -0
  390. package/esm/rag/loaders/errors.mjs +25 -0
  391. package/esm/rag/loaders/errors.mjs.map +1 -0
  392. package/esm/rag/loaders/index.mjs +7 -0
  393. package/esm/rag/loaders/load-html.d.mts +26 -0
  394. package/esm/rag/loaders/load-html.d.mts.map +1 -0
  395. package/esm/rag/loaders/load-html.mjs +138 -0
  396. package/esm/rag/loaders/load-html.mjs.map +1 -0
  397. package/esm/rag/loaders/load-pdf.d.mts +38 -0
  398. package/esm/rag/loaders/load-pdf.d.mts.map +1 -0
  399. package/esm/rag/loaders/load-pdf.mjs +150 -0
  400. package/esm/rag/loaders/load-pdf.mjs.map +1 -0
  401. package/esm/rag/loaders/load-text.d.mts +47 -0
  402. package/esm/rag/loaders/load-text.d.mts.map +1 -0
  403. package/esm/rag/loaders/load-text.mjs +60 -0
  404. package/esm/rag/loaders/load-text.mjs.map +1 -0
  405. package/esm/rag/loaders/load-web.d.mts +42 -0
  406. package/esm/rag/loaders/load-web.d.mts.map +1 -0
  407. package/esm/rag/loaders/load-web.mjs +89 -0
  408. package/esm/rag/loaders/load-web.mjs.map +1 -0
  409. package/esm/rag/loaders/loader.type.d.mts +89 -0
  410. package/esm/rag/loaders/loader.type.d.mts.map +1 -0
  411. package/esm/rag/rag.d.mts +38 -0
  412. package/esm/rag/rag.d.mts.map +1 -0
  413. package/esm/rag/rag.mjs +126 -0
  414. package/esm/rag/rag.mjs.map +1 -0
  415. package/esm/rag/rerank/keyword-reranker.d.mts +32 -0
  416. package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -0
  417. package/esm/rag/rerank/keyword-reranker.mjs +58 -0
  418. package/esm/rag/rerank/keyword-reranker.mjs.map +1 -0
  419. package/esm/rag/rerank/llm-reranker.d.mts +36 -0
  420. package/esm/rag/rerank/llm-reranker.d.mts.map +1 -0
  421. package/esm/rag/rerank/llm-reranker.mjs +85 -0
  422. package/esm/rag/rerank/llm-reranker.mjs.map +1 -0
  423. package/esm/rag/rerank/reranker.contract.d.mts +28 -0
  424. package/esm/rag/rerank/reranker.contract.d.mts.map +1 -0
  425. package/esm/rag/retrieve.mjs +68 -0
  426. package/esm/rag/retrieve.mjs.map +1 -0
  427. package/esm/rag/store/cache-vector-store.d.mts +27 -0
  428. package/esm/rag/store/cache-vector-store.d.mts.map +1 -0
  429. package/esm/rag/store/cache-vector-store.mjs +48 -0
  430. package/esm/rag/store/cache-vector-store.mjs.map +1 -0
  431. package/esm/rag/store/pg-vector-store.d.mts +139 -0
  432. package/esm/rag/store/pg-vector-store.d.mts.map +1 -0
  433. package/esm/rag/store/pg-vector-store.mjs +328 -0
  434. package/esm/rag/store/pg-vector-store.mjs.map +1 -0
  435. package/esm/rag/store/vector-store.contract.d.mts +38 -0
  436. package/esm/rag/store/vector-store.contract.d.mts.map +1 -0
  437. package/esm/rag/transforms/multi-query.d.mts +27 -0
  438. package/esm/rag/transforms/multi-query.d.mts.map +1 -0
  439. package/esm/rag/transforms/multi-query.mjs +41 -0
  440. package/esm/rag/transforms/multi-query.mjs.map +1 -0
  441. package/esm/security/index.mjs +5 -0
  442. package/esm/security/outbound-policy.d.mts +46 -0
  443. package/esm/security/outbound-policy.d.mts.map +1 -0
  444. package/esm/security/outbound-policy.mjs +187 -0
  445. package/esm/security/outbound-policy.mjs.map +1 -0
  446. package/esm/security/outbound-policy.type.d.mts +74 -0
  447. package/esm/security/outbound-policy.type.d.mts.map +1 -0
  448. package/esm/security/private-ip.d.mts +15 -0
  449. package/esm/security/private-ip.d.mts.map +1 -0
  450. package/esm/security/private-ip.mjs +48 -0
  451. package/esm/security/private-ip.mjs.map +1 -0
  452. package/esm/security/redact.d.mts +59 -0
  453. package/esm/security/redact.d.mts.map +1 -0
  454. package/esm/security/redact.mjs +122 -0
  455. package/esm/security/redact.mjs.map +1 -0
  456. package/esm/serve/serve.d.mts +50 -0
  457. package/esm/serve/serve.d.mts.map +1 -0
  458. package/esm/serve/serve.mjs +90 -0
  459. package/esm/serve/serve.mjs.map +1 -0
  460. package/esm/serve/sse.d.mts +20 -0
  461. package/esm/serve/sse.d.mts.map +1 -0
  462. package/esm/serve/sse.mjs +25 -0
  463. package/esm/serve/sse.mjs.map +1 -0
  464. package/esm/serve/stream-to-sse.d.mts +29 -0
  465. package/esm/serve/stream-to-sse.d.mts.map +1 -0
  466. package/esm/serve/stream-to-sse.mjs +37 -0
  467. package/esm/serve/stream-to-sse.mjs.map +1 -0
  468. package/esm/skills/catalog.d.mts +49 -0
  469. package/esm/skills/catalog.d.mts.map +1 -0
  470. package/esm/skills/catalog.mjs +140 -0
  471. package/esm/skills/catalog.mjs.map +1 -0
  472. package/esm/skills/contracts/skill-record.type.d.mts +37 -0
  473. package/esm/skills/contracts/skill-record.type.d.mts.map +1 -0
  474. package/esm/skills/contracts/skills-config.type.d.mts +108 -0
  475. package/esm/skills/contracts/skills-config.type.d.mts.map +1 -0
  476. package/esm/skills/contracts/skills-store.contract.d.mts +28 -0
  477. package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -0
  478. package/esm/skills/contracts/skills.contract.d.mts +43 -0
  479. package/esm/skills/contracts/skills.contract.d.mts.map +1 -0
  480. package/esm/skills/index.d.mts +16 -0
  481. package/esm/skills/index.mjs +14 -0
  482. package/esm/skills/load-skill-tool.d.mts +38 -0
  483. package/esm/skills/load-skill-tool.d.mts.map +1 -0
  484. package/esm/skills/load-skill-tool.mjs +65 -0
  485. package/esm/skills/load-skill-tool.mjs.map +1 -0
  486. package/esm/skills/review-gate.d.mts +33 -0
  487. package/esm/skills/review-gate.d.mts.map +1 -0
  488. package/esm/skills/review-gate.mjs +60 -0
  489. package/esm/skills/review-gate.mjs.map +1 -0
  490. package/esm/skills/save-skill-tool.d.mts +39 -0
  491. package/esm/skills/save-skill-tool.d.mts.map +1 -0
  492. package/esm/skills/save-skill-tool.mjs +65 -0
  493. package/esm/skills/save-skill-tool.mjs.map +1 -0
  494. package/esm/skills/skills.d.mts +33 -0
  495. package/esm/skills/skills.d.mts.map +1 -0
  496. package/esm/skills/skills.mjs +109 -0
  497. package/esm/skills/skills.mjs.map +1 -0
  498. package/esm/skills/sources/directory-source.d.mts +19 -0
  499. package/esm/skills/sources/directory-source.d.mts.map +1 -0
  500. package/esm/skills/sources/directory-source.mjs +108 -0
  501. package/esm/skills/sources/directory-source.mjs.map +1 -0
  502. package/esm/skills/sources/index.d.mts +18 -0
  503. package/esm/skills/sources/index.d.mts.map +1 -0
  504. package/esm/skills/sources/index.mjs +27 -0
  505. package/esm/skills/sources/index.mjs.map +1 -0
  506. package/esm/skills/sources/parse-frontmatter.d.mts +27 -0
  507. package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -0
  508. package/esm/skills/sources/parse-frontmatter.mjs +46 -0
  509. package/esm/skills/sources/parse-frontmatter.mjs.map +1 -0
  510. package/esm/skills/sources/store-source.d.mts +14 -0
  511. package/esm/skills/sources/store-source.d.mts.map +1 -0
  512. package/esm/skills/sources/store-source.mjs +15 -0
  513. package/esm/skills/sources/store-source.mjs.map +1 -0
  514. package/esm/skills/sources/url-source.d.mts +29 -0
  515. package/esm/skills/sources/url-source.d.mts.map +1 -0
  516. package/esm/skills/sources/url-source.mjs +117 -0
  517. package/esm/skills/sources/url-source.mjs.map +1 -0
  518. package/esm/skills/store/mock-skills-store.d.mts +57 -0
  519. package/esm/skills/store/mock-skills-store.d.mts.map +1 -0
  520. package/esm/skills/store/mock-skills-store.mjs +100 -0
  521. package/esm/skills/store/mock-skills-store.mjs.map +1 -0
  522. package/esm/skills/store/procedural-skill-store.d.mts +30 -0
  523. package/esm/skills/store/procedural-skill-store.d.mts.map +1 -0
  524. package/esm/skills/store/procedural-skill-store.mjs +125 -0
  525. package/esm/skills/store/procedural-skill-store.mjs.map +1 -0
  526. package/esm/speech/index.mjs +3 -0
  527. package/esm/speech/speech.d.mts +65 -0
  528. package/esm/speech/speech.d.mts.map +1 -0
  529. package/esm/speech/speech.mjs +123 -0
  530. package/esm/speech/speech.mjs.map +1 -0
  531. package/esm/supervisor/as-tool.mjs +2 -2
  532. package/esm/supervisor/as-tool.mjs.map +1 -1
  533. package/esm/supervisor/entries.mjs +2 -2
  534. package/esm/supervisor/entries.mjs.map +1 -1
  535. package/esm/supervisor/execution.d.mts.map +1 -1
  536. package/esm/supervisor/execution.mjs +31 -28
  537. package/esm/supervisor/execution.mjs.map +1 -1
  538. package/esm/supervisor/supervisor.d.mts.map +1 -1
  539. package/esm/supervisor/supervisor.mjs +8 -3
  540. package/esm/supervisor/supervisor.mjs.map +1 -1
  541. package/esm/system-prompt/index.d.mts +4 -0
  542. package/esm/system-prompt/system-prompt.d.mts +68 -4
  543. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  544. package/esm/system-prompt/system-prompt.mjs +89 -5
  545. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  546. package/esm/team/gates.mjs +48 -0
  547. package/esm/team/gates.mjs.map +1 -0
  548. package/esm/team/index.d.mts +1 -0
  549. package/esm/team/index.mjs +3 -0
  550. package/esm/team/team.d.mts +42 -0
  551. package/esm/team/team.d.mts.map +1 -0
  552. package/esm/team/team.mjs +94 -0
  553. package/esm/team/team.mjs.map +1 -0
  554. package/esm/tool/executable-as-tool.d.mts.map +1 -1
  555. package/esm/tool/executable-as-tool.mjs +2 -2
  556. package/esm/tool/executable-as-tool.mjs.map +1 -1
  557. package/esm/tool/tool.d.mts.map +1 -1
  558. package/esm/tool/tool.mjs +2 -2
  559. package/esm/tool/tool.mjs.map +1 -1
  560. package/esm/transcribe/audio-input.d.mts +47 -0
  561. package/esm/transcribe/audio-input.d.mts.map +1 -0
  562. package/esm/transcribe/audio-input.mjs +84 -0
  563. package/esm/transcribe/audio-input.mjs.map +1 -0
  564. package/esm/transcribe/index.mjs +4 -0
  565. package/esm/transcribe/transcribe.d.mts +64 -0
  566. package/esm/transcribe/transcribe.d.mts.map +1 -0
  567. package/esm/transcribe/transcribe.mjs +128 -0
  568. package/esm/transcribe/transcribe.mjs.map +1 -0
  569. package/esm/utils/compute-cost.d.mts +17 -1
  570. package/esm/utils/compute-cost.d.mts.map +1 -1
  571. package/esm/utils/compute-cost.mjs +26 -1
  572. package/esm/utils/compute-cost.mjs.map +1 -1
  573. package/esm/utils/extract-json-lenient.d.mts +42 -0
  574. package/esm/utils/extract-json-lenient.d.mts.map +1 -0
  575. package/esm/utils/extract-json-lenient.mjs +97 -0
  576. package/esm/utils/extract-json-lenient.mjs.map +1 -0
  577. package/esm/utils/index.d.mts +4 -2
  578. package/esm/utils/index.mjs +3 -1
  579. package/esm/utils/json-schema.d.mts +1 -1
  580. package/esm/utils/prepare-attachment-part.d.mts +10 -1
  581. package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
  582. package/esm/utils/prepare-attachment-part.mjs +103 -11
  583. package/esm/utils/prepare-attachment-part.mjs.map +1 -1
  584. package/esm/utils/resolve-attachment.d.mts +4 -3
  585. package/esm/utils/resolve-attachment.d.mts.map +1 -1
  586. package/esm/utils/resolve-attachment.mjs +4 -3
  587. package/esm/utils/resolve-attachment.mjs.map +1 -1
  588. package/esm/utils/run-context.d.mts +94 -0
  589. package/esm/utils/run-context.d.mts.map +1 -0
  590. package/esm/utils/run-context.mjs +98 -0
  591. package/esm/utils/run-context.mjs.map +1 -0
  592. package/esm/vcr/cassette-io.mjs +57 -0
  593. package/esm/vcr/cassette-io.mjs.map +1 -0
  594. package/esm/vcr/errors.d.mts +42 -0
  595. package/esm/vcr/errors.d.mts.map +1 -0
  596. package/esm/vcr/errors.mjs +37 -0
  597. package/esm/vcr/errors.mjs.map +1 -0
  598. package/esm/vcr/hash-request.d.mts +28 -0
  599. package/esm/vcr/hash-request.d.mts.map +1 -0
  600. package/esm/vcr/hash-request.mjs +118 -0
  601. package/esm/vcr/hash-request.mjs.map +1 -0
  602. package/esm/vcr/index.d.mts +4 -0
  603. package/esm/vcr/index.mjs +5 -0
  604. package/esm/vcr/vcr.d.mts +32 -0
  605. package/esm/vcr/vcr.d.mts.map +1 -0
  606. package/esm/vcr/vcr.mjs +248 -0
  607. package/esm/vcr/vcr.mjs.map +1 -0
  608. package/esm/vcr/vcr.type.d.mts +118 -0
  609. package/esm/vcr/vcr.type.d.mts.map +1 -0
  610. package/esm/workflow/as-tool.mjs +2 -2
  611. package/esm/workflow/as-tool.mjs.map +1 -1
  612. package/esm/workflow/engine.mjs +1 -0
  613. package/esm/workflow/engine.mjs.map +1 -1
  614. package/esm/workflow/step-runner.mjs +19 -20
  615. package/esm/workflow/step-runner.mjs.map +1 -1
  616. package/esm/workflow/workflow.d.mts.map +1 -1
  617. package/esm/workflow/workflow.mjs +8 -3
  618. package/esm/workflow/workflow.mjs.map +1 -1
  619. package/llms-full.txt +2572 -204
  620. package/llms.txt +21 -4
  621. package/package.json +7 -3
  622. package/skills/README.md +44 -4
  623. package/skills/ai-dx-helpers/SKILL.md +2 -2
  624. package/skills/approve-tool-calls/SKILL.md +134 -0
  625. package/skills/attach-ai-middleware/SKILL.md +1 -1
  626. package/skills/detect-and-redact-pii/SKILL.md +104 -0
  627. package/skills/durable-agent-runs/SKILL.md +135 -0
  628. package/skills/durable-resume/SKILL.md +128 -0
  629. package/skills/escalate-block-to-human/SKILL.md +85 -0
  630. package/skills/eval-datasets-and-ci/SKILL.md +117 -0
  631. package/skills/generate-images/SKILL.md +138 -0
  632. package/skills/generate-speech/SKILL.md +139 -0
  633. package/skills/guard-input-output/SKILL.md +117 -0
  634. package/skills/manage-prompts/SKILL.md +186 -0
  635. package/skills/observe-ai-flows/SKILL.md +94 -0
  636. package/skills/rag-loaders-and-stores/SKILL.md +164 -0
  637. package/skills/record-replay-llm/SKILL.md +92 -0
  638. package/skills/run-ai-agent/SKILL.md +26 -1
  639. package/skills/run-ai-rag/SKILL.md +139 -0
  640. package/skills/run-ai-team/SKILL.md +107 -0
  641. package/skills/run-orchestrator/SKILL.md +2 -0
  642. package/skills/run-planner/SKILL.md +73 -8
  643. package/skills/run-supervisor/SKILL.md +20 -1
  644. package/skills/transcribe-audio/SKILL.md +157 -0
  645. package/skills/use-runtime-skills/SKILL.md +106 -0
  646. package/skills/write-system-prompt/SKILL.md +30 -1
  647. package/cjs/index.cjs.map +0 -1
  648. package/esm/contracts/result/index.d.mts +0 -15
@@ -0,0 +1,101 @@
1
+ import { AgentExecutionError } from "../errors/agent-execution-error.mjs";
2
+ import { AgentDriftError } from "../errors/agent-drift-error.mjs";
3
+ import "../errors/index.mjs";
4
+ import { resolveDefaultSnapshotStore } from "../config.mjs";
5
+
6
+ //#region ../@warlock.js/ai/src/agent/snapshot.ts
7
+ /**
8
+ * Resolve the effective {@link SnapshotStore}: the agent's own
9
+ * `durable.store` wins; absent that, fall back to the global default
10
+ * set via `ai.config({ defaultSnapshotStore })`.
11
+ *
12
+ * The global default is typed for the supervisor snapshot shape, but
13
+ * every store impl keys purely by `runId` and round-trips whatever
14
+ * envelope it is handed — so it serves an `AgentSnapshot` just as well.
15
+ * The cast re-tags the shape at this single boundary (Option B); the
16
+ * agent only ever hands it an `AgentSnapshot`.
17
+ */
18
+ function resolveSnapshotStore(durable) {
19
+ return durable?.store ?? resolveDefaultSnapshotStore();
20
+ }
21
+ /**
22
+ * Write the current run state to the resolved snapshot store. No-op
23
+ * (returns `{ ok: true }`) when neither `durable.store` nor the global
24
+ * `defaultSnapshotStore` is configured — the common non-durable path.
25
+ * Failures are returned as `{ ok: false }` rather than thrown so the
26
+ * engine can surface them via logs without aborting the run — a failed
27
+ * checkpoint loses resume-ability from that point but never breaks an
28
+ * otherwise-healthy run.
29
+ */
30
+ async function persistAgentSnapshot(params) {
31
+ const store = resolveSnapshotStore(params.durable);
32
+ if (!store) return { ok: true };
33
+ const snapshot = {
34
+ runId: params.runId,
35
+ agentName: params.agentName,
36
+ signature: params.signature,
37
+ version: params.version,
38
+ input: params.input,
39
+ systemPrompt: params.systemPrompt,
40
+ responseSchema: params.responseSchema,
41
+ promptName: params.promptName,
42
+ promptVersion: params.promptVersion,
43
+ messages: params.messages,
44
+ trips: params.trips,
45
+ toolCalls: params.toolCalls,
46
+ usage: params.usage,
47
+ status: params.status,
48
+ startedAt: params.startedAt,
49
+ savedAt: (/* @__PURE__ */ new Date()).toISOString()
50
+ };
51
+ try {
52
+ await store.save(snapshot);
53
+ return { ok: true };
54
+ } catch (error) {
55
+ return {
56
+ ok: false,
57
+ error
58
+ };
59
+ }
60
+ }
61
+ /**
62
+ * Delete a persisted snapshot — used after a successful run when
63
+ * `durable.deleteOnComplete` is set. Never throws: a failed delete is
64
+ * surfaced as `{ ok: false }` and the engine logs it. No-op (ok) when no
65
+ * store is configured.
66
+ */
67
+ async function deleteAgentSnapshot(params) {
68
+ const store = resolveSnapshotStore(params.durable);
69
+ if (!store) return { ok: true };
70
+ try {
71
+ await store.delete(params.runId);
72
+ return { ok: true };
73
+ } catch (error) {
74
+ return {
75
+ ok: false,
76
+ error
77
+ };
78
+ }
79
+ }
80
+ /**
81
+ * Load a persisted snapshot for `resume()` and run the drift check.
82
+ * Throws `AgentExecutionError` when no store is configured or when the
83
+ * run is missing; throws `AgentDriftError` when the stored signature
84
+ * doesn't match the current definition (unless `force` is set).
85
+ */
86
+ async function loadAgentSnapshotForResume(params) {
87
+ const store = resolveSnapshotStore(params.durable);
88
+ if (!store) throw new AgentExecutionError(`agent "${params.agentName}" has no durable store configured — set \`durable: { store }\` on the config or call \`ai.config({ defaultSnapshotStore })\` at boot before calling resume()`, { context: { runId: params.runId } });
89
+ const snapshot = await store.load(params.runId) ?? null;
90
+ if (!snapshot) throw new AgentExecutionError(`agent "${params.agentName}": no snapshot for runId "${params.runId}"`, { context: { runId: params.runId } });
91
+ if (!params.options?.force && snapshot.signature !== params.signature) throw new AgentDriftError(`agent "${params.agentName}" signature drift on resume`, {
92
+ savedSignature: snapshot.signature,
93
+ currentSignature: params.signature,
94
+ runId: params.runId
95
+ });
96
+ return snapshot;
97
+ }
98
+
99
+ //#endregion
100
+ export { deleteAgentSnapshot, loadAgentSnapshotForResume, persistAgentSnapshot };
101
+ //# sourceMappingURL=snapshot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/agent/snapshot.ts"],"sourcesContent":["import { resolveDefaultSnapshotStore } from \"../config\";\nimport type {\n AgentResumeOptions,\n} from \"../contracts/agent/agent-options.type\";\nimport type {\n AgentSnapshot,\n AgentSnapshotStatus,\n} from \"../contracts/agent/agent-snapshot.type\";\nimport type { SnapshotStore } from \"../contracts/orchestrator/snapshot-store.contract\";\nimport type { Message } from \"../contracts/conversation-message.type\";\nimport type { LLMTrip } from \"../contracts/result/llm-trip.type\";\nimport type { ToolCall } from \"../contracts/result/tool-call.type\";\nimport type { Usage } from \"../contracts/result/usage.type\";\nimport { AgentDriftError, AgentExecutionError } from \"../errors\";\n\n/**\n * The agent's `durable` config, narrowed to the fields the snapshot\n * helpers read. Kept minimal so this module doesn't depend on the full\n * resolved-config shape.\n */\nexport type AgentDurableConfig = {\n store?: SnapshotStore<AgentSnapshot>;\n deleteOnComplete?: boolean;\n};\n\n/**\n * Resolve the effective {@link SnapshotStore}: the agent's own\n * `durable.store` wins; absent that, fall back to the global default\n * set via `ai.config({ defaultSnapshotStore })`.\n *\n * The global default is typed for the supervisor snapshot shape, but\n * every store impl keys purely by `runId` and round-trips whatever\n * envelope it is handed — so it serves an `AgentSnapshot` just as well.\n * The cast re-tags the shape at this single boundary (Option B); the\n * agent only ever hands it an `AgentSnapshot`.\n */\nfunction resolveSnapshotStore(\n durable: AgentDurableConfig | undefined,\n): SnapshotStore<AgentSnapshot> | undefined {\n return (\n durable?.store ??\n (resolveDefaultSnapshotStore() as SnapshotStore<AgentSnapshot> | undefined)\n );\n}\n\nexport type PersistAgentParams = {\n durable: AgentDurableConfig | undefined;\n runId: string;\n agentName: string;\n signature: string;\n version?: string;\n input: string;\n systemPrompt?: string;\n responseSchema?: Record<string, unknown>;\n promptName?: string;\n promptVersion?: string;\n messages: Message[];\n trips: LLMTrip[];\n toolCalls: ToolCall[];\n usage: Usage;\n status: AgentSnapshotStatus;\n startedAt: string;\n};\n\nexport type PersistOutcome = { ok: true } | { ok: false; error: unknown };\n\n/**\n * Write the current run state to the resolved snapshot store. No-op\n * (returns `{ ok: true }`) when neither `durable.store` nor the global\n * `defaultSnapshotStore` is configured — the common non-durable path.\n * Failures are returned as `{ ok: false }` rather than thrown so the\n * engine can surface them via logs without aborting the run — a failed\n * checkpoint loses resume-ability from that point but never breaks an\n * otherwise-healthy run.\n */\nexport async function persistAgentSnapshot(\n params: PersistAgentParams,\n): Promise<PersistOutcome> {\n const store = resolveSnapshotStore(params.durable);\n\n if (!store) {\n return { ok: true };\n }\n\n const snapshot: AgentSnapshot = {\n runId: params.runId,\n agentName: params.agentName,\n signature: params.signature,\n version: params.version,\n input: params.input,\n systemPrompt: params.systemPrompt,\n responseSchema: params.responseSchema,\n promptName: params.promptName,\n promptVersion: params.promptVersion,\n messages: params.messages,\n trips: params.trips,\n toolCalls: params.toolCalls,\n usage: params.usage,\n status: params.status,\n startedAt: params.startedAt,\n savedAt: new Date().toISOString(),\n };\n\n try {\n await store.save(snapshot);\n\n return { ok: true };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/**\n * Delete a persisted snapshot — used after a successful run when\n * `durable.deleteOnComplete` is set. Never throws: a failed delete is\n * surfaced as `{ ok: false }` and the engine logs it. No-op (ok) when no\n * store is configured.\n */\nexport async function deleteAgentSnapshot(params: {\n durable: AgentDurableConfig | undefined;\n runId: string;\n}): Promise<PersistOutcome> {\n const store = resolveSnapshotStore(params.durable);\n\n if (!store) {\n return { ok: true };\n }\n\n try {\n await store.delete(params.runId);\n\n return { ok: true };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/**\n * Load a persisted snapshot for `resume()` and run the drift check.\n * Throws `AgentExecutionError` when no store is configured or when the\n * run is missing; throws `AgentDriftError` when the stored signature\n * doesn't match the current definition (unless `force` is set).\n */\nexport async function loadAgentSnapshotForResume(params: {\n durable: AgentDurableConfig | undefined;\n agentName: string;\n signature: string;\n runId: string;\n options?: AgentResumeOptions<unknown>;\n}): Promise<AgentSnapshot> {\n const store = resolveSnapshotStore(params.durable);\n\n if (!store) {\n throw new AgentExecutionError(\n `agent \"${params.agentName}\" has no durable store configured — set \\`durable: { store }\\` on the config or call \\`ai.config({ defaultSnapshotStore })\\` at boot before calling resume()`,\n { context: { runId: params.runId } },\n );\n }\n\n const snapshot = (await store.load(params.runId)) ?? null;\n\n if (!snapshot) {\n throw new AgentExecutionError(\n `agent \"${params.agentName}\": no snapshot for runId \"${params.runId}\"`,\n { context: { runId: params.runId } },\n );\n }\n\n if (!params.options?.force && snapshot.signature !== params.signature) {\n throw new AgentDriftError(\n `agent \"${params.agentName}\" signature drift on resume`,\n {\n savedSignature: snapshot.signature,\n currentSignature: params.signature,\n runId: params.runId,\n },\n );\n }\n\n return snapshot;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,SAAS,qBACP,SAC0C;CAC1C,OACE,SAAS,SACR,4BAA4B;AAEjC;;;;;;;;;;AAgCA,eAAsB,qBACpB,QACyB;CACzB,MAAM,QAAQ,qBAAqB,OAAO,OAAO;CAEjD,IAAI,CAAC,OACH,OAAO,EAAE,IAAI,KAAK;CAGpB,MAAM,WAA0B;EAC9B,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,OAAO,OAAO;EACd,cAAc,OAAO;EACrB,gBAAgB,OAAO;EACvB,YAAY,OAAO;EACnB,eAAe,OAAO;EACtB,UAAU,OAAO;EACjB,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,OAAO,OAAO;EACd,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB,0BAAS,IAAI,KAAK,EAAC,CAAC,YAAY;CAClC;CAEA,IAAI;EACF,MAAM,MAAM,KAAK,QAAQ;EAEzB,OAAO,EAAE,IAAI,KAAK;CACpB,SAAS,OAAO;EACd,OAAO;GAAE,IAAI;GAAO;EAAM;CAC5B;AACF;;;;;;;AAQA,eAAsB,oBAAoB,QAGd;CAC1B,MAAM,QAAQ,qBAAqB,OAAO,OAAO;CAEjD,IAAI,CAAC,OACH,OAAO,EAAE,IAAI,KAAK;CAGpB,IAAI;EACF,MAAM,MAAM,OAAO,OAAO,KAAK;EAE/B,OAAO,EAAE,IAAI,KAAK;CACpB,SAAS,OAAO;EACd,OAAO;GAAE,IAAI;GAAO;EAAM;CAC5B;AACF;;;;;;;AAQA,eAAsB,2BAA2B,QAMtB;CACzB,MAAM,QAAQ,qBAAqB,OAAO,OAAO;CAEjD,IAAI,CAAC,OACH,MAAM,IAAI,oBACR,UAAU,OAAO,UAAU,+JAC3B,EAAE,SAAS,EAAE,OAAO,OAAO,MAAM,EAAE,CACrC;CAGF,MAAM,WAAY,MAAM,MAAM,KAAK,OAAO,KAAK,KAAM;CAErD,IAAI,CAAC,UACH,MAAM,IAAI,oBACR,UAAU,OAAO,UAAU,4BAA4B,OAAO,MAAM,IACpE,EAAE,SAAS,EAAE,OAAO,OAAO,MAAM,EAAE,CACrC;CAGF,IAAI,CAAC,OAAO,SAAS,SAAS,SAAS,cAAc,OAAO,WAC1D,MAAM,IAAI,gBACR,UAAU,OAAO,UAAU,8BAC3B;EACE,gBAAgB,SAAS;EACzB,kBAAkB,OAAO;EACzB,OAAO,OAAO;CAChB,CACF;CAGF,OAAO;AACT"}
@@ -0,0 +1,4 @@
1
+ import "./utils/index.mjs";
2
+ import { log } from "@warlock.js/logger";
3
+
4
+ export { };
@@ -0,0 +1,5 @@
1
+ import "../../index.mjs";
2
+ import "./utils/index.mjs";
3
+ import { log } from "@warlock.js/logger";
4
+
5
+ export { };
@@ -0,0 +1,7 @@
1
+ import "./embedder.mjs";
2
+ import "./image.mjs";
3
+ import "./speech.mjs";
4
+ import "./transcription.mjs";
5
+ import "./sdk.mjs";
6
+
7
+ export { };
@@ -0,0 +1,5 @@
1
+ import "../../index.mjs";
2
+ import "./utils/index.mjs";
3
+ import { log } from "@warlock.js/logger";
4
+
5
+ export { };
@@ -0,0 +1,9 @@
1
+ import "../../index.mjs";
2
+ import "./embedder.mjs";
3
+ import "./image.mjs";
4
+ import "./model.mjs";
5
+ import "./speech.mjs";
6
+ import "./transcription.mjs";
7
+ import "openai";
8
+
9
+ export { };
@@ -0,0 +1,5 @@
1
+ import "../../index.mjs";
2
+ import "./utils/index.mjs";
3
+ import { log } from "@warlock.js/logger";
4
+
5
+ export { };
@@ -0,0 +1,6 @@
1
+ import "../../index.mjs";
2
+ import "./utils/index.mjs";
3
+ import { log } from "@warlock.js/logger";
4
+ import "openai";
5
+
6
+ export { };
@@ -0,0 +1,5 @@
1
+ import "./to-openai-messages.mjs";
2
+ import "./to-openai-tools.mjs";
3
+ import "./wrap-openai-error.mjs";
4
+
5
+ export { };
@@ -0,0 +1,3 @@
1
+ import "../../../index.mjs";
2
+
3
+ export { };
@@ -0,0 +1,3 @@
1
+ import "../../../index.mjs";
2
+
3
+ export { };
@@ -0,0 +1,4 @@
1
+ import "../../../index.mjs";
2
+ import "openai";
3
+
4
+ export { };
package/esm/ai.d.mts CHANGED
@@ -2,16 +2,27 @@ import { tool } from "./tool/tool.mjs";
2
2
  import { agent } from "./agent/agent.mjs";
3
3
  import { budget, readBudgetFallbackSignal } from "./middleware/builtins/budget.mjs";
4
4
  import { spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
5
- import { SystemPromptFactory } from "./system-prompt/system-prompt.mjs";
6
- import { judge } from "./eval/judge-scorer.mjs";
7
- import { contains, exact, predicate } from "./eval/scorers.mjs";
8
5
  import { batch } from "./batch/batch.mjs";
6
+ import { streamObject } from "./object-stream/stream-object.mjs";
7
+ import { serve } from "./serve/serve.mjs";
9
8
  import { memory } from "./checkpoint/memory.mjs";
10
9
  import { pg } from "./checkpoint/pg.mjs";
11
10
  import { redis } from "./checkpoint/redis.mjs";
12
11
  import { setAIConfig } from "./config.mjs";
13
- import { memory as memory$1 } from "./memory/memory.mjs";
14
- import { guardrail } from "./middleware/builtins/guardrail.mjs";
12
+ import { dataset } from "./eval/dataset.mjs";
13
+ import { evalScorers } from "./eval/index.mjs";
14
+ import { humanApproval } from "./human/human-approval.mjs";
15
+ import { image } from "./image/image.mjs";
16
+ import { speech } from "./speech/speech.mjs";
17
+ import { audioFromBuffer, audioFromFile, audioMediaTypeForFilename } from "./transcribe/audio-input.mjs";
18
+ import { transcribe } from "./transcribe/transcribe.mjs";
19
+ import { resume } from "./human/resume.mjs";
20
+ import { memory as memory$1 } from "./human/stores/memory.mjs";
21
+ import { pg as pg$1 } from "./human/stores/pg.mjs";
22
+ import { redis as redis$1 } from "./human/stores/redis.mjs";
23
+ import { guardrail } from "./guard/guardrail.mjs";
24
+ import { memory as memory$2 } from "./memory/memory.mjs";
25
+ import { guardrail as guardrail$1 } from "./middleware/builtins/guardrail.mjs";
15
26
  import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
16
27
  import { composeMiddleware } from "./middleware/helpers/compose.mjs";
17
28
  import { forTool } from "./middleware/helpers/for-tool.mjs";
@@ -19,18 +30,158 @@ import { mockRouter } from "./mock/mock-router.mjs";
19
30
  import { fallbackModel } from "./model/fallback-model.mjs";
20
31
  import { orchestrator } from "./orchestrator/orchestrator.mjs";
21
32
  import { planner } from "./planner/planner.mjs";
22
- import { memory as memory$2 } from "./snapshot/memory.mjs";
23
- import { pg as pg$1 } from "./snapshot/pg.mjs";
24
- import { redis as redis$1 } from "./snapshot/redis.mjs";
33
+ import { defaultPromptsManager } from "./prompts/prompts-manager.mjs";
34
+ import { rag } from "./rag/rag.mjs";
35
+ import { chunk } from "./rag/chunk/chunk.mjs";
36
+ import { cacheVectorStore } from "./rag/store/cache-vector-store.mjs";
37
+ import { pgVectorStore, vectorLiteral } from "./rag/store/pg-vector-store.mjs";
38
+ import { loadText } from "./rag/loaders/load-text.mjs";
39
+ import { loadHtml } from "./rag/loaders/load-html.mjs";
40
+ import { loadWeb } from "./rag/loaders/load-web.mjs";
41
+ import { loadPdf } from "./rag/loaders/load-pdf.mjs";
42
+ import { keywordReranker } from "./rag/rerank/keyword-reranker.mjs";
43
+ import { llmReranker } from "./rag/rerank/llm-reranker.mjs";
44
+ import { reciprocalRankFusion } from "./rag/hybrid/rrf.mjs";
45
+ import { bm25Rank } from "./rag/hybrid/bm25.mjs";
46
+ import { hybridRank } from "./rag/hybrid/hybrid-rank.mjs";
47
+ import { multiQuery } from "./rag/transforms/multi-query.mjs";
48
+ import { skills } from "./skills/skills.mjs";
49
+ import { systemPrompt } from "./system-prompt/system-prompt.mjs";
50
+ import { prompt } from "./prompt/prompt.mjs";
51
+ import { vcr } from "./vcr/vcr.mjs";
52
+ import { memory as memory$3 } from "./snapshot/memory.mjs";
53
+ import { pg as pg$2 } from "./snapshot/pg.mjs";
54
+ import { redis as redis$2 } from "./snapshot/redis.mjs";
25
55
  import { fanOut } from "./supervisor/fan-out.mjs";
26
56
  import { router } from "./supervisor/router-factory.mjs";
27
57
  import { supervisor } from "./supervisor/supervisor.mjs";
58
+ import { team } from "./team/team.mjs";
28
59
  import { instruction } from "./system-prompt/instruction.mjs";
29
60
  import { persona } from "./system-prompt/persona.mjs";
30
61
  import { step } from "./workflow/step.mjs";
31
62
  import { workflow } from "./workflow/workflow.mjs";
32
63
 
33
64
  //#region ../@warlock.js/ai/src/ai.d.ts
65
+ /**
66
+ * The shape of the top-level `ai` namespace. Declared as an `interface` (not an
67
+ * inferred `const` type) so satellite packages can attach their verb via
68
+ * `declare module "@warlock.js/ai" { interface Ai { … } }` — e.g. `ai.workspace`,
69
+ * `ai.tools`, `ai.mcp`, `ai.human`. The runtime object below is asserted to this
70
+ * type; a satellite assigns its member on import.
71
+ */
72
+ interface Ai {
73
+ config: typeof setAIConfig;
74
+ tool: typeof tool;
75
+ agent: typeof agent;
76
+ systemPrompt: typeof systemPrompt;
77
+ persona: typeof persona;
78
+ instruction: typeof instruction;
79
+ workflow: typeof workflow;
80
+ step: typeof step;
81
+ supervisor: typeof supervisor;
82
+ team: typeof team;
83
+ orchestrator: typeof orchestrator;
84
+ memory: typeof memory$2;
85
+ skills: typeof skills;
86
+ planner: typeof planner;
87
+ rag: typeof rag & {
88
+ keywordReranker: typeof keywordReranker;
89
+ llmReranker: typeof llmReranker;
90
+ chunk: typeof chunk;
91
+ cacheVectorStore: typeof cacheVectorStore;
92
+ pgVectorStore: typeof pgVectorStore;
93
+ vectorLiteral: typeof vectorLiteral;
94
+ loadText: typeof loadText;
95
+ loadHtml: typeof loadHtml;
96
+ loadWeb: typeof loadWeb;
97
+ loadPdf: typeof loadPdf;
98
+ bm25Rank: typeof bm25Rank;
99
+ reciprocalRankFusion: typeof reciprocalRankFusion;
100
+ hybridRank: typeof hybridRank;
101
+ multiQuery: typeof multiQuery;
102
+ };
103
+ spawnSubAgent: typeof spawnSubAgent;
104
+ router: typeof router;
105
+ fanOut: typeof fanOut;
106
+ batch: typeof batch;
107
+ /** Structured-output streaming — partial-object snapshots + a strict final parse (A1). */
108
+ streamObject: typeof streamObject;
109
+ /** Serve an executable as an SSE HTTP endpoint — production serving primitive (A3). */
110
+ serve: typeof serve;
111
+ /**
112
+ * Generate images from a text prompt — the image-output verb of the
113
+ * output-modality track (Theme I). Wraps an `ImageModelContract` (from
114
+ * `openai.image(...)` / `google.image(...)`) in the uniform
115
+ * never-throws `{ data, error, usage, report }` envelope with cost-truth
116
+ * and observability.
117
+ */
118
+ image: typeof image;
119
+ /** Text-to-speech (TTS) — the audio-output verb of the modality track (Theme I). */
120
+ speech: typeof speech;
121
+ /** Speech-to-text (STT / transcription) — the audio-input verb of the modality track (Theme I). */
122
+ transcribe: typeof transcribe;
123
+ /** Read an audio file from disk → `AudioInput` for `ai.transcribe` (non-AI file plumbing). */
124
+ audioFromFile: typeof audioFromFile;
125
+ /** Package raw audio bytes → `AudioInput` for `ai.transcribe`. */
126
+ audioFromBuffer: typeof audioFromBuffer;
127
+ /** Resolve the audio media type from a filename's extension. */
128
+ audioMediaTypeForFilename: typeof audioMediaTypeForFilename;
129
+ fallbackModel: typeof fallbackModel;
130
+ eval: typeof evalScorers;
131
+ dataset: typeof dataset;
132
+ prompt: typeof prompt;
133
+ /**
134
+ * Process-wide registry of named, versioned `systemPrompt(...)` builders,
135
+ * keyed by `name@version`. A `systemPrompt(input, { name })` (or any
136
+ * `.meta({ name })` rename) auto-registers here; `ai.prompts.get(name)` /
137
+ * `.resolve(name)` reads them back, and `systemPrompt().merge(name)` folds a
138
+ * registered prompt into a new one.
139
+ */
140
+ prompts: ReturnType<typeof defaultPromptsManager>;
141
+ vcr: typeof vcr;
142
+ mockRouter: typeof mockRouter;
143
+ middleware: {
144
+ budget: typeof budget;
145
+ guardrail: typeof guardrail$1;
146
+ semanticCache: typeof semanticCache;
147
+ compose: typeof composeMiddleware;
148
+ forTool: typeof forTool;
149
+ readBudgetFallbackSignal: typeof readBudgetFallbackSignal;
150
+ };
151
+ checkpoint: {
152
+ memory: typeof memory;
153
+ pg: typeof pg;
154
+ redis: typeof redis;
155
+ };
156
+ snapshot: {
157
+ memory: typeof memory$3;
158
+ pg: typeof pg$2;
159
+ redis: typeof redis$2;
160
+ };
161
+ /**
162
+ * Human-in-the-loop tool approval (interrupt / resume).
163
+ *
164
+ * - `human.approval(options)` — the `tool.before` approval-gate middleware.
165
+ * - `human.resume(id, decision, options)` — out-of-process durable resume.
166
+ * - `human.interrupt.{memory,pg,redis}()` — durable {@link InterruptStore}
167
+ * factories (memory ships real; pg/redis are lazy optional peers).
168
+ */
169
+ human: {
170
+ approval: typeof humanApproval;
171
+ resume: typeof resume;
172
+ interrupt: {
173
+ memory: typeof memory$1;
174
+ pg: typeof pg$1;
175
+ redis: typeof redis$1;
176
+ };
177
+ };
178
+ /**
179
+ * Content-intelligence guardrail. `ai.guardrail(options)` builds a composed
180
+ * input / output / tool middleware; `ai.guardrail.{pii,topic,injection,moderation}`
181
+ * are the built-in detector factories.
182
+ */
183
+ guardrail: typeof guardrail;
184
+ }
34
185
  /**
35
186
  * Top-level `ai` namespace — holds built-in factories and user-registered SDK adapters.
36
187
  *
@@ -42,6 +193,7 @@ import { workflow } from "./workflow/workflow.mjs";
42
193
  * - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).
43
194
  * - `ai.orchestrator(...)` — session-state manager wrapped around a supervisor (durable session, drift detection, resume, commands).
44
195
  * - `ai.memory(...)` — build an agent-memory store with WORKING (in-run scratch) and SEMANTIC (cache-driver `.similar()` recall) tiers.
196
+ * - `ai.skills(...)` — build a runtime skills library (always-injected metadata catalog + on-demand loadSkill tool).
45
197
  * - `ai.planner(...)` — build an executable that generates an ordered plan over registered capabilities, then runs it step-by-step.
46
198
  * - `ai.spawnSubAgent(spec)` — thin wrapper that builds a fresh one-shot `agent()` with an optional per-task `budget` and runs the task once. A general primitive (not planner-specific).
47
199
  * - `ai.router(...)` — build a supervisor-compatible routing agent from named intents.
@@ -52,6 +204,8 @@ import { workflow } from "./workflow/workflow.mjs";
52
204
  * - `ai.mockRouter(decisions, opts?)` — deterministic supervisor `route` callback for tests.
53
205
  * - `ai.checkpoint.{memory,pg,redis}()` — durable orchestrator session checkpoint stores.
54
206
  * - `ai.snapshot.{memory,pg,redis}()` — supervisor-run snapshot stores for `iterate: true` resume.
207
+ * - `ai.human.approval(...)` / `ai.human.resume(...)` / `ai.human.interrupt.{memory,pg,redis}()` — human-in-the-loop tool approval (interrupt / resume).
208
+ * - `ai.guardrail(options)` + `ai.guardrail.{pii,topic,injection,moderation}(...)` — content-intelligence guardrails (moderation / PII / injection / topic).
55
209
  * - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.
56
210
  *
57
211
  * @example
@@ -70,50 +224,7 @@ import { workflow } from "./workflow/workflow.mjs";
70
224
  * placeholders: { language: "Arabic" },
71
225
  * });
72
226
  */
73
- declare const ai: {
74
- config: typeof setAIConfig;
75
- tool: typeof tool;
76
- agent: typeof agent;
77
- systemPrompt: SystemPromptFactory;
78
- persona: typeof persona;
79
- instruction: typeof instruction;
80
- workflow: typeof workflow;
81
- step: typeof step;
82
- supervisor: typeof supervisor;
83
- orchestrator: typeof orchestrator;
84
- memory: typeof memory$1;
85
- planner: typeof planner;
86
- spawnSubAgent: typeof spawnSubAgent;
87
- router: typeof router;
88
- fanOut: typeof fanOut;
89
- batch: typeof batch;
90
- fallbackModel: typeof fallbackModel;
91
- eval: {
92
- exact: typeof exact;
93
- contains: typeof contains;
94
- predicate: typeof predicate;
95
- judge: typeof judge;
96
- };
97
- mockRouter: typeof mockRouter;
98
- middleware: {
99
- budget: typeof budget;
100
- guardrail: typeof guardrail;
101
- semanticCache: typeof semanticCache;
102
- compose: typeof composeMiddleware;
103
- forTool: typeof forTool;
104
- readBudgetFallbackSignal: typeof readBudgetFallbackSignal;
105
- };
106
- checkpoint: {
107
- memory: typeof memory;
108
- pg: typeof pg;
109
- redis: typeof redis;
110
- };
111
- snapshot: {
112
- memory: typeof memory$2;
113
- pg: typeof pg$1;
114
- redis: typeof redis$1;
115
- };
116
- };
227
+ declare const ai: Ai;
117
228
  //#endregion
118
- export { ai };
229
+ export { Ai, ai };
119
230
  //# sourceMappingURL=ai.d.mts.map
package/esm/ai.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/ai.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA;;;;;;;;;;;;;;;;;;cAAa,EAAA"}
1
+ {"version":3,"file":"ai.d.mts","names":[],"sources":["../../../../../../@warlock.js/ai/src/ai.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA6EiB,EAAA;EACf,MAAA,SAAe,WAAA;EACf,IAAA,SAAa,IAAA;EACb,KAAA,SAAc,KAAA;EACd,YAAA,SAAqB,YAAA;EACrB,OAAA,SAAgB,OAAA;EAChB,WAAA,SAAoB,WAAA;EACpB,QAAA,SAAiB,QAAA;EACjB,IAAA,SAAa,IAAA;EACb,UAAA,SAAmB,UAAA;EACnB,IAAA,SAAa,IAAA;EACb,YAAA,SAAqB,YAAA;EACrB,MAAA,SAAe,QAAA;EACf,MAAA,SAAe,MAAA;EACf,OAAA,SAAgB,OAAA;EAChB,GAAA,SAAY,GAAA;IACV,eAAA,SAAwB,eAAA;IACxB,WAAA,SAAoB,WAAA;IACpB,KAAA,SAAc,KAAA;IACd,gBAAA,SAAyB,gBAAA;IACzB,aAAA,SAAsB,aAAA;IACtB,aAAA,SAAsB,aAAA;IACtB,QAAA,SAAiB,QAAA;IACjB,QAAA,SAAiB,QAAA;IACjB,OAAA,SAAgB,OAAA;IAChB,OAAA,SAAgB,OAAA;IAChB,QAAA,SAAiB,QAAA;IACjB,oBAAA,SAA6B,oBAAA;IAC7B,UAAA,SAAmB,UAAA;IACnB,UAAA,SAAmB,UAAA;EAAA;EAErB,aAAA,SAAsB,aAAA;EACtB,MAAA,SAAe,MAAA;EACf,MAAA,SAAe,MAAA;EACf,KAAA,SAAc,KAAA;EAjCC;EAmCf,YAAA,SAAqB,YAAA;EAjCP;EAmCd,KAAA,SAAc,KAAA;EAjCE;;;;;;;EAyChB,KAAA,SAAc,KAAA;EAjCC;EAmCf,MAAA,SAAe,MAAA;EAjCH;EAmCZ,UAAA,SAAmB,UAAA;EAjCG;EAmCtB,aAAA,SAAsB,aAAA;EAjCK;EAmC3B,eAAA,SAAwB,eAAA;EAjCA;EAmCxB,yBAAA,SAAkC,yBAAA;EAClC,aAAA,SAAsB,aAAA;EACtB,IAAA,SAAa,WAAA;EACb,OAAA,SAAgB,OAAA;EAChB,MAAA,SAAe,MAAA;EAjCgB;;;;;;;EAyC/B,OAAA,EAAS,UAAA,QAAkB,qBAAA;EAC3B,GAAA,SAAY,GAAA;EACZ,UAAA,SAAmB,UAAA;EACnB,UAAA;IACE,MAAA,SAAe,MAAA;IACf,SAAA,SAAkB,WAAA;IAClB,aAAA,SAAsB,aAAA;IACtB,OAAA,SAAgB,iBAAA;IAChB,OAAA,SAAgB,OAAA;IAChB,wBAAA,SAAiC,wBAAA;EAAA;EAEnC,UAAA;IACE,MAAA,SAAe,MAAA;IACf,EAAA,SAAW,EAAA;IACX,KAAA,SAAc,KAAA;EAAA;EAEhB,QAAA;IACE,MAAA,SAAe,QAAA;IACf,EAAA,SAAW,IAAA;IACX,KAAA,SAAc,OAAA;EAAA;EAVmB;;;;;;;;EAoBnC,KAAA;IACE,QAAA,SAAiB,aAAA;IACjB,MAAA,SAAe,MAAA;IACf,SAAA;MACE,MAAA,SAAe,QAAA;MACf,EAAA,SAAW,IAAA;MACX,KAAA,SAAc,OAAA;IAAA;EAAA;EArGlB;;;;;EA6GA,SAAA,SAAkB,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6CP,EAAA,EAwER,EAAE"}
package/esm/ai.mjs CHANGED
@@ -5,15 +5,30 @@ import { semanticCache } from "./middleware/builtins/semantic-cache.mjs";
5
5
  import { composeMiddleware } from "./middleware/helpers/compose.mjs";
6
6
  import { forTool } from "./middleware/helpers/for-tool.mjs";
7
7
  import { tool } from "./tool/tool.mjs";
8
+ import { skills } from "./skills/skills.mjs";
9
+ import { memory } from "./memory/memory.mjs";
10
+ import "./skills/index.mjs";
8
11
  import { agent } from "./agent/agent.mjs";
9
12
  import { spawnSubAgent } from "./agent/spawn-sub-agent.mjs";
10
13
  import { batch } from "./batch/batch.mjs";
11
14
  import "./batch/index.mjs";
12
- import { memory } from "./checkpoint/memory.mjs";
15
+ import { streamObject } from "./object-stream/stream-object.mjs";
16
+ import "./object-stream/index.mjs";
17
+ import { serve } from "./serve/serve.mjs";
18
+ import { memory as memory$1 } from "./checkpoint/memory.mjs";
13
19
  import { pg } from "./checkpoint/pg.mjs";
14
20
  import { redis } from "./checkpoint/redis.mjs";
21
+ import { dataset } from "./eval/dataset.mjs";
15
22
  import { evalScorers } from "./eval/index.mjs";
16
- import { memory as memory$1 } from "./memory/memory.mjs";
23
+ import { human } from "./human/register.mjs";
24
+ import { image } from "./image/image.mjs";
25
+ import "./image/index.mjs";
26
+ import { speech } from "./speech/speech.mjs";
27
+ import "./speech/index.mjs";
28
+ import { audioFromBuffer, audioFromFile, audioMediaTypeForFilename } from "./transcribe/audio-input.mjs";
29
+ import { transcribe } from "./transcribe/transcribe.mjs";
30
+ import "./transcribe/index.mjs";
31
+ import { guardrail as guardrail$1 } from "./guard/guardrail.mjs";
17
32
  import { mockRouter } from "./mock/mock-router.mjs";
18
33
  import "./mock/index.mjs";
19
34
  import { fallbackModel } from "./model/fallback-model.mjs";
@@ -23,15 +38,36 @@ import { orchestrator } from "./orchestrator/orchestrator.mjs";
23
38
  import "./orchestrator/index.mjs";
24
39
  import { planner } from "./planner/planner.mjs";
25
40
  import "./planner/index.mjs";
41
+ import { instruction } from "./system-prompt/instruction.mjs";
42
+ import { persona } from "./system-prompt/persona.mjs";
43
+ import { systemPrompt } from "./system-prompt/system-prompt.mjs";
44
+ import { defaultPromptsManager } from "./prompts/prompts-manager.mjs";
45
+ import { chunk } from "./rag/chunk/chunk.mjs";
46
+ import { cacheVectorStore } from "./rag/store/cache-vector-store.mjs";
47
+ import { rag } from "./rag/rag.mjs";
48
+ import { pgVectorStore, vectorLiteral } from "./rag/store/pg-vector-store.mjs";
49
+ import { loadText } from "./rag/loaders/load-text.mjs";
50
+ import { loadHtml } from "./rag/loaders/load-html.mjs";
51
+ import { loadWeb } from "./rag/loaders/load-web.mjs";
52
+ import { loadPdf } from "./rag/loaders/load-pdf.mjs";
53
+ import { keywordReranker } from "./rag/rerank/keyword-reranker.mjs";
54
+ import { llmReranker } from "./rag/rerank/llm-reranker.mjs";
55
+ import { reciprocalRankFusion } from "./rag/hybrid/rrf.mjs";
56
+ import { bm25Rank } from "./rag/hybrid/bm25.mjs";
57
+ import { hybridRank } from "./rag/hybrid/hybrid-rank.mjs";
58
+ import { multiQuery } from "./rag/transforms/multi-query.mjs";
59
+ import "./rag/index.mjs";
60
+ import { prompt } from "./prompt/prompt.mjs";
61
+ import "./prompt/index.mjs";
62
+ import { vcr } from "./vcr/vcr.mjs";
63
+ import "./vcr/index.mjs";
26
64
  import { memory as memory$2 } from "./snapshot/memory.mjs";
27
65
  import { pg as pg$1 } from "./snapshot/pg.mjs";
28
66
  import { redis as redis$1 } from "./snapshot/redis.mjs";
29
67
  import { fanOut } from "./supervisor/fan-out.mjs";
30
68
  import { router } from "./supervisor/router-factory.mjs";
31
69
  import "./supervisor/index.mjs";
32
- import { instruction } from "./system-prompt/instruction.mjs";
33
- import { persona } from "./system-prompt/persona.mjs";
34
- import { systemPrompt } from "./system-prompt/system-prompt.mjs";
70
+ import { team } from "./team/team.mjs";
35
71
  import { step } from "./workflow/step.mjs";
36
72
  import { workflow } from "./workflow/workflow.mjs";
37
73
 
@@ -47,6 +83,7 @@ import { workflow } from "./workflow/workflow.mjs";
47
83
  * - `ai.instruction(text)` — reusable instruction block (can be passed to `systemPrompt`).
48
84
  * - `ai.orchestrator(...)` — session-state manager wrapped around a supervisor (durable session, drift detection, resume, commands).
49
85
  * - `ai.memory(...)` — build an agent-memory store with WORKING (in-run scratch) and SEMANTIC (cache-driver `.similar()` recall) tiers.
86
+ * - `ai.skills(...)` — build a runtime skills library (always-injected metadata catalog + on-demand loadSkill tool).
50
87
  * - `ai.planner(...)` — build an executable that generates an ordered plan over registered capabilities, then runs it step-by-step.
51
88
  * - `ai.spawnSubAgent(spec)` — thin wrapper that builds a fresh one-shot `agent()` with an optional per-task `budget` and runs the task once. A general primitive (not planner-specific).
52
89
  * - `ai.router(...)` — build a supervisor-compatible routing agent from named intents.
@@ -57,6 +94,8 @@ import { workflow } from "./workflow/workflow.mjs";
57
94
  * - `ai.mockRouter(decisions, opts?)` — deterministic supervisor `route` callback for tests.
58
95
  * - `ai.checkpoint.{memory,pg,redis}()` — durable orchestrator session checkpoint stores.
59
96
  * - `ai.snapshot.{memory,pg,redis}()` — supervisor-run snapshot stores for `iterate: true` resume.
97
+ * - `ai.human.approval(...)` / `ai.human.resume(...)` / `ai.human.interrupt.{memory,pg,redis}()` — human-in-the-loop tool approval (interrupt / resume).
98
+ * - `ai.guardrail(options)` + `ai.guardrail.{pii,topic,injection,moderation}(...)` — content-intelligence guardrails (moderation / PII / injection / topic).
60
99
  * - `ai.openai.model(...)` / `ai.anthropic.model(...)` / ... once the adapter SDK is registered.
61
100
  *
62
101
  * @example
@@ -85,15 +124,45 @@ const ai = {
85
124
  workflow,
86
125
  step,
87
126
  supervisor,
127
+ team,
88
128
  orchestrator,
89
- memory: memory$1,
129
+ memory,
130
+ skills,
90
131
  planner,
132
+ rag: Object.assign(rag, {
133
+ keywordReranker,
134
+ llmReranker,
135
+ chunk,
136
+ cacheVectorStore,
137
+ pgVectorStore,
138
+ vectorLiteral,
139
+ loadText,
140
+ loadHtml,
141
+ loadWeb,
142
+ loadPdf,
143
+ bm25Rank,
144
+ reciprocalRankFusion,
145
+ hybridRank,
146
+ multiQuery
147
+ }),
91
148
  spawnSubAgent,
92
149
  router,
93
150
  fanOut,
94
151
  batch,
152
+ streamObject,
153
+ serve,
154
+ image,
155
+ speech,
156
+ transcribe,
157
+ audioFromFile,
158
+ audioFromBuffer,
159
+ audioMediaTypeForFilename,
95
160
  fallbackModel,
96
161
  eval: evalScorers,
162
+ dataset,
163
+ prompt,
164
+ prompts: defaultPromptsManager(),
165
+ vcr,
97
166
  mockRouter,
98
167
  middleware: {
99
168
  budget,
@@ -104,7 +173,7 @@ const ai = {
104
173
  readBudgetFallbackSignal
105
174
  },
106
175
  checkpoint: {
107
- memory,
176
+ memory: memory$1,
108
177
  pg,
109
178
  redis
110
179
  },
@@ -112,7 +181,9 @@ const ai = {
112
181
  memory: memory$2,
113
182
  pg: pg$1,
114
183
  redis: redis$1
115
- }
184
+ },
185
+ human,
186
+ guardrail: guardrail$1
116
187
  };
117
188
 
118
189
  //#endregion