@warlock.js/ai 4.4.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 (535) hide show
  1. package/CHANGELOG.md +52 -55
  2. package/cjs/index.cjs +221 -14147
  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 +8 -0
  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/supervisor-result.type.d.mts +14 -2
  75. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -1
  76. package/esm/contracts/result/workflow-result.type.d.mts +2 -1
  77. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -1
  78. package/esm/contracts/supervisor/supervisor-config.type.d.mts +29 -0
  79. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -1
  80. package/esm/contracts/system-prompt.contract.d.mts +103 -1
  81. package/esm/contracts/system-prompt.contract.d.mts.map +1 -1
  82. package/esm/contracts/team/index.d.mts +1 -0
  83. package/esm/contracts/team/team-config.type.d.mts +127 -0
  84. package/esm/contracts/team/team-config.type.d.mts.map +1 -0
  85. package/esm/contracts/tool.contract.d.mts +4 -2
  86. package/esm/contracts/tool.contract.d.mts.map +1 -1
  87. package/esm/contracts/workflow/step.contract.d.mts +30 -5
  88. package/esm/contracts/workflow/step.contract.d.mts.map +1 -1
  89. package/esm/contracts/workflow/workflow.contract.d.mts +16 -0
  90. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -1
  91. package/esm/errors/error-code.type.d.mts +1 -1
  92. package/esm/errors/index.d.mts +1 -0
  93. package/esm/errors/index.mjs +1 -0
  94. package/esm/errors/outbound-policy-error.d.mts +27 -0
  95. package/esm/errors/outbound-policy-error.d.mts.map +1 -0
  96. package/esm/errors/outbound-policy-error.mjs +32 -0
  97. package/esm/errors/outbound-policy-error.mjs.map +1 -0
  98. package/esm/eval/dataset.d.mts +28 -0
  99. package/esm/eval/dataset.d.mts.map +1 -0
  100. package/esm/eval/dataset.mjs +112 -0
  101. package/esm/eval/dataset.mjs.map +1 -0
  102. package/esm/eval/dataset.type.d.mts +53 -0
  103. package/esm/eval/dataset.type.d.mts.map +1 -0
  104. package/esm/eval/eval-runner.d.mts.map +1 -1
  105. package/esm/eval/eval-runner.mjs +16 -2
  106. package/esm/eval/eval-runner.mjs.map +1 -1
  107. package/esm/eval/index.d.mts +20 -1
  108. package/esm/eval/index.d.mts.map +1 -1
  109. package/esm/eval/index.mjs +20 -2
  110. package/esm/eval/index.mjs.map +1 -1
  111. package/esm/eval/regression.d.mts +30 -0
  112. package/esm/eval/regression.d.mts.map +1 -0
  113. package/esm/eval/regression.mjs +51 -0
  114. package/esm/eval/regression.mjs.map +1 -0
  115. package/esm/eval/report-json.d.mts +30 -0
  116. package/esm/eval/report-json.d.mts.map +1 -0
  117. package/esm/eval/report-json.mjs +33 -0
  118. package/esm/eval/report-json.mjs.map +1 -0
  119. package/esm/eval/report-junit.d.mts +22 -0
  120. package/esm/eval/report-junit.d.mts.map +1 -0
  121. package/esm/eval/report-junit.mjs +60 -0
  122. package/esm/eval/report-junit.mjs.map +1 -0
  123. package/esm/guard/contracts/guard-options.type.d.mts +165 -0
  124. package/esm/guard/contracts/guard-options.type.d.mts.map +1 -0
  125. package/esm/guard/contracts/guardrail.contract.d.mts +78 -0
  126. package/esm/guard/contracts/guardrail.contract.d.mts.map +1 -0
  127. package/esm/guard/contracts/index.d.mts +4 -0
  128. package/esm/guard/contracts/openai-client.contract.d.mts +51 -0
  129. package/esm/guard/contracts/openai-client.contract.d.mts.map +1 -0
  130. package/esm/guard/contracts/verdict.type.d.mts +76 -0
  131. package/esm/guard/contracts/verdict.type.d.mts.map +1 -0
  132. package/esm/guard/detectors/index.d.mts +4 -0
  133. package/esm/guard/detectors/index.mjs +6 -0
  134. package/esm/guard/detectors/injection.d.mts +34 -0
  135. package/esm/guard/detectors/injection.d.mts.map +1 -0
  136. package/esm/guard/detectors/injection.mjs +254 -0
  137. package/esm/guard/detectors/injection.mjs.map +1 -0
  138. package/esm/guard/detectors/moderation.d.mts +32 -0
  139. package/esm/guard/detectors/moderation.d.mts.map +1 -0
  140. package/esm/guard/detectors/moderation.mjs +134 -0
  141. package/esm/guard/detectors/moderation.mjs.map +1 -0
  142. package/esm/guard/detectors/pii.d.mts +41 -0
  143. package/esm/guard/detectors/pii.d.mts.map +1 -0
  144. package/esm/guard/detectors/pii.mjs +199 -0
  145. package/esm/guard/detectors/pii.mjs.map +1 -0
  146. package/esm/guard/detectors/topic.d.mts +29 -0
  147. package/esm/guard/detectors/topic.d.mts.map +1 -0
  148. package/esm/guard/detectors/topic.mjs +99 -0
  149. package/esm/guard/detectors/topic.mjs.map +1 -0
  150. package/esm/guard/errors.d.mts +12 -0
  151. package/esm/guard/errors.d.mts.map +1 -0
  152. package/esm/guard/errors.mjs +18 -0
  153. package/esm/guard/errors.mjs.map +1 -0
  154. package/esm/guard/guard.d.mts +67 -0
  155. package/esm/guard/guard.d.mts.map +1 -0
  156. package/esm/guard/guard.mjs +209 -0
  157. package/esm/guard/guard.mjs.map +1 -0
  158. package/esm/guard/guardrail.d.mts +39 -0
  159. package/esm/guard/guardrail.d.mts.map +1 -0
  160. package/esm/guard/guardrail.mjs +22 -0
  161. package/esm/guard/guardrail.mjs.map +1 -0
  162. package/esm/human/contracts/approval.type.d.mts +154 -0
  163. package/esm/human/contracts/approval.type.d.mts.map +1 -0
  164. package/esm/human/contracts/human-approval.type.d.mts +38 -0
  165. package/esm/human/contracts/human-approval.type.d.mts.map +1 -0
  166. package/esm/human/contracts/index.d.mts +4 -0
  167. package/esm/human/contracts/interrupt-store.contract.d.mts +112 -0
  168. package/esm/human/contracts/interrupt-store.contract.d.mts.map +1 -0
  169. package/esm/human/contracts/resume.type.d.mts +77 -0
  170. package/esm/human/contracts/resume.type.d.mts.map +1 -0
  171. package/esm/human/errors.d.mts +84 -0
  172. package/esm/human/errors.d.mts.map +1 -0
  173. package/esm/human/errors.mjs +60 -0
  174. package/esm/human/errors.mjs.map +1 -0
  175. package/esm/human/human-approval.d.mts +57 -0
  176. package/esm/human/human-approval.d.mts.map +1 -0
  177. package/esm/human/human-approval.mjs +170 -0
  178. package/esm/human/human-approval.mjs.map +1 -0
  179. package/esm/human/policy.d.mts +55 -0
  180. package/esm/human/policy.d.mts.map +1 -0
  181. package/esm/human/policy.mjs +67 -0
  182. package/esm/human/policy.mjs.map +1 -0
  183. package/esm/human/register.mjs +37 -0
  184. package/esm/human/register.mjs.map +1 -0
  185. package/esm/human/resume-seed.mjs +53 -0
  186. package/esm/human/resume-seed.mjs.map +1 -0
  187. package/esm/human/resume.d.mts +54 -0
  188. package/esm/human/resume.d.mts.map +1 -0
  189. package/esm/human/resume.mjs +121 -0
  190. package/esm/human/resume.mjs.map +1 -0
  191. package/esm/human/stores/index.mjs +5 -0
  192. package/esm/human/stores/memory.d.mts +30 -0
  193. package/esm/human/stores/memory.d.mts.map +1 -0
  194. package/esm/human/stores/memory.mjs +91 -0
  195. package/esm/human/stores/memory.mjs.map +1 -0
  196. package/esm/human/stores/pg.d.mts +59 -0
  197. package/esm/human/stores/pg.d.mts.map +1 -0
  198. package/esm/human/stores/pg.mjs +220 -0
  199. package/esm/human/stores/pg.mjs.map +1 -0
  200. package/esm/human/stores/redis.d.mts +56 -0
  201. package/esm/human/stores/redis.d.mts.map +1 -0
  202. package/esm/human/stores/redis.mjs +201 -0
  203. package/esm/human/stores/redis.mjs.map +1 -0
  204. package/esm/index.d.mts +113 -22
  205. package/esm/index.mjs +82 -11
  206. package/esm/middleware/builtins/budget.mjs +6 -2
  207. package/esm/middleware/builtins/budget.mjs.map +1 -1
  208. package/esm/middleware/utils/extract-user-text.d.mts +8 -1
  209. package/esm/middleware/utils/extract-user-text.d.mts.map +1 -1
  210. package/esm/middleware/utils/extract-user-text.mjs +8 -1
  211. package/esm/middleware/utils/extract-user-text.mjs.map +1 -1
  212. package/esm/object-stream/index.d.mts +2 -0
  213. package/esm/object-stream/index.mjs +4 -0
  214. package/esm/object-stream/parse-partial-json.d.mts +22 -0
  215. package/esm/object-stream/parse-partial-json.d.mts.map +1 -0
  216. package/esm/object-stream/parse-partial-json.mjs +78 -0
  217. package/esm/object-stream/parse-partial-json.mjs.map +1 -0
  218. package/esm/object-stream/stream-object.d.mts +68 -0
  219. package/esm/object-stream/stream-object.d.mts.map +1 -0
  220. package/esm/object-stream/stream-object.mjs +104 -0
  221. package/esm/object-stream/stream-object.mjs.map +1 -0
  222. package/esm/observe/index.mjs +4 -0
  223. package/esm/observe/observer-registry.d.mts +30 -0
  224. package/esm/observe/observer-registry.d.mts.map +1 -0
  225. package/esm/observe/observer-registry.mjs +51 -0
  226. package/esm/observe/observer-registry.mjs.map +1 -0
  227. package/esm/observe/observer.contract.d.mts +40 -0
  228. package/esm/observe/observer.contract.d.mts.map +1 -0
  229. package/esm/observe/resolve-observers.d.mts +40 -0
  230. package/esm/observe/resolve-observers.d.mts.map +1 -0
  231. package/esm/observe/resolve-observers.mjs +73 -0
  232. package/esm/observe/resolve-observers.mjs.map +1 -0
  233. package/esm/orchestrator/execution.d.mts.map +1 -1
  234. package/esm/orchestrator/execution.mjs +5 -2
  235. package/esm/orchestrator/execution.mjs.map +1 -1
  236. package/esm/orchestrator/index.d.mts +1 -0
  237. package/esm/orchestrator/index.mjs +1 -0
  238. package/esm/orchestrator/orchestrator.d.mts.map +1 -1
  239. package/esm/orchestrator/orchestrator.mjs +39 -6
  240. package/esm/orchestrator/orchestrator.mjs.map +1 -1
  241. package/esm/orchestrator/session-lock.d.mts +25 -0
  242. package/esm/orchestrator/session-lock.d.mts.map +1 -0
  243. package/esm/orchestrator/session-lock.mjs +83 -0
  244. package/esm/orchestrator/session-lock.mjs.map +1 -0
  245. package/esm/planner/dag-scheduler.mjs +97 -0
  246. package/esm/planner/dag-scheduler.mjs.map +1 -0
  247. package/esm/planner/plan-prompt.d.mts +1 -1
  248. package/esm/planner/plan-prompt.d.mts.map +1 -1
  249. package/esm/planner/plan-prompt.mjs +2 -1
  250. package/esm/planner/plan-prompt.mjs.map +1 -1
  251. package/esm/planner/planner-run.d.mts.map +1 -1
  252. package/esm/planner/planner-run.mjs +300 -29
  253. package/esm/planner/planner-run.mjs.map +1 -1
  254. package/esm/planner/planner.mjs +1 -1
  255. package/esm/planner/planner.mjs.map +1 -1
  256. package/esm/prompt/errors.d.mts +57 -0
  257. package/esm/prompt/errors.d.mts.map +1 -0
  258. package/esm/prompt/errors.mjs +73 -0
  259. package/esm/prompt/errors.mjs.map +1 -0
  260. package/esm/prompt/index.d.mts +3 -0
  261. package/esm/prompt/index.mjs +4 -0
  262. package/esm/prompt/prompt-langfuse-sync.mjs +104 -0
  263. package/esm/prompt/prompt-langfuse-sync.mjs.map +1 -0
  264. package/esm/prompt/prompt-langfuse-sync.type.d.mts +32 -0
  265. package/esm/prompt/prompt-langfuse-sync.type.d.mts.map +1 -0
  266. package/esm/prompt/prompt-validate.mjs +170 -0
  267. package/esm/prompt/prompt-validate.mjs.map +1 -0
  268. package/esm/prompt/prompt.d.mts +54 -0
  269. package/esm/prompt/prompt.d.mts.map +1 -0
  270. package/esm/prompt/prompt.mjs +218 -0
  271. package/esm/prompt/prompt.mjs.map +1 -0
  272. package/esm/prompt/prompt.type.d.mts +174 -0
  273. package/esm/prompt/prompt.type.d.mts.map +1 -0
  274. package/esm/prompts/index.d.mts +3 -0
  275. package/esm/prompts/index.mjs +3 -0
  276. package/esm/prompts/prompts-manager.contract.d.mts +154 -0
  277. package/esm/prompts/prompts-manager.contract.d.mts.map +1 -0
  278. package/esm/prompts/prompts-manager.d.mts +38 -0
  279. package/esm/prompts/prompts-manager.d.mts.map +1 -0
  280. package/esm/prompts/prompts-manager.mjs +410 -0
  281. package/esm/prompts/prompts-manager.mjs.map +1 -0
  282. package/esm/prompts/prompts-manager.type.d.mts +172 -0
  283. package/esm/prompts/prompts-manager.type.d.mts.map +1 -0
  284. package/esm/prompts/prompts-validate.mjs +200 -0
  285. package/esm/prompts/prompts-validate.mjs.map +1 -0
  286. package/esm/rag/as-tool.mjs +48 -0
  287. package/esm/rag/as-tool.mjs.map +1 -0
  288. package/esm/rag/chunk/chunk.d.mts +24 -0
  289. package/esm/rag/chunk/chunk.d.mts.map +1 -0
  290. package/esm/rag/chunk/chunk.mjs +44 -0
  291. package/esm/rag/chunk/chunk.mjs.map +1 -0
  292. package/esm/rag/chunk/fixed.mjs +32 -0
  293. package/esm/rag/chunk/fixed.mjs.map +1 -0
  294. package/esm/rag/chunk/markdown.mjs +75 -0
  295. package/esm/rag/chunk/markdown.mjs.map +1 -0
  296. package/esm/rag/chunk/recursive.mjs +132 -0
  297. package/esm/rag/chunk/recursive.mjs.map +1 -0
  298. package/esm/rag/chunk/sentence.mjs +73 -0
  299. package/esm/rag/chunk/sentence.mjs.map +1 -0
  300. package/esm/rag/contracts/chunk-options.type.d.mts +35 -0
  301. package/esm/rag/contracts/chunk-options.type.d.mts.map +1 -0
  302. package/esm/rag/contracts/citation.type.d.mts +35 -0
  303. package/esm/rag/contracts/citation.type.d.mts.map +1 -0
  304. package/esm/rag/contracts/index.d.mts +4 -0
  305. package/esm/rag/contracts/rag-config.type.d.mts +68 -0
  306. package/esm/rag/contracts/rag-config.type.d.mts.map +1 -0
  307. package/esm/rag/contracts/rag-document.type.d.mts +21 -0
  308. package/esm/rag/contracts/rag-document.type.d.mts.map +1 -0
  309. package/esm/rag/hybrid/bm25.d.mts +23 -0
  310. package/esm/rag/hybrid/bm25.d.mts.map +1 -0
  311. package/esm/rag/hybrid/bm25.mjs +51 -0
  312. package/esm/rag/hybrid/bm25.mjs.map +1 -0
  313. package/esm/rag/hybrid/hybrid-rank.d.mts +33 -0
  314. package/esm/rag/hybrid/hybrid-rank.d.mts.map +1 -0
  315. package/esm/rag/hybrid/hybrid-rank.mjs +29 -0
  316. package/esm/rag/hybrid/hybrid-rank.mjs.map +1 -0
  317. package/esm/rag/hybrid/rrf.d.mts +25 -0
  318. package/esm/rag/hybrid/rrf.d.mts.map +1 -0
  319. package/esm/rag/hybrid/rrf.mjs +30 -0
  320. package/esm/rag/hybrid/rrf.mjs.map +1 -0
  321. package/esm/rag/index.d.mts +15 -0
  322. package/esm/rag/index.mjs +11 -0
  323. package/esm/rag/rag.d.mts +38 -0
  324. package/esm/rag/rag.d.mts.map +1 -0
  325. package/esm/rag/rag.mjs +126 -0
  326. package/esm/rag/rag.mjs.map +1 -0
  327. package/esm/rag/rerank/keyword-reranker.d.mts +32 -0
  328. package/esm/rag/rerank/keyword-reranker.d.mts.map +1 -0
  329. package/esm/rag/rerank/keyword-reranker.mjs +58 -0
  330. package/esm/rag/rerank/keyword-reranker.mjs.map +1 -0
  331. package/esm/rag/rerank/llm-reranker.d.mts +36 -0
  332. package/esm/rag/rerank/llm-reranker.d.mts.map +1 -0
  333. package/esm/rag/rerank/llm-reranker.mjs +85 -0
  334. package/esm/rag/rerank/llm-reranker.mjs.map +1 -0
  335. package/esm/rag/rerank/reranker.contract.d.mts +28 -0
  336. package/esm/rag/rerank/reranker.contract.d.mts.map +1 -0
  337. package/esm/rag/retrieve.mjs +68 -0
  338. package/esm/rag/retrieve.mjs.map +1 -0
  339. package/esm/rag/store/cache-vector-store.d.mts +27 -0
  340. package/esm/rag/store/cache-vector-store.d.mts.map +1 -0
  341. package/esm/rag/store/cache-vector-store.mjs +48 -0
  342. package/esm/rag/store/cache-vector-store.mjs.map +1 -0
  343. package/esm/rag/store/vector-store.contract.d.mts +38 -0
  344. package/esm/rag/store/vector-store.contract.d.mts.map +1 -0
  345. package/esm/rag/transforms/multi-query.d.mts +27 -0
  346. package/esm/rag/transforms/multi-query.d.mts.map +1 -0
  347. package/esm/rag/transforms/multi-query.mjs +41 -0
  348. package/esm/rag/transforms/multi-query.mjs.map +1 -0
  349. package/esm/security/index.mjs +5 -0
  350. package/esm/security/outbound-policy.d.mts +46 -0
  351. package/esm/security/outbound-policy.d.mts.map +1 -0
  352. package/esm/security/outbound-policy.mjs +187 -0
  353. package/esm/security/outbound-policy.mjs.map +1 -0
  354. package/esm/security/outbound-policy.type.d.mts +74 -0
  355. package/esm/security/outbound-policy.type.d.mts.map +1 -0
  356. package/esm/security/private-ip.d.mts +15 -0
  357. package/esm/security/private-ip.d.mts.map +1 -0
  358. package/esm/security/private-ip.mjs +48 -0
  359. package/esm/security/private-ip.mjs.map +1 -0
  360. package/esm/security/redact.d.mts +59 -0
  361. package/esm/security/redact.d.mts.map +1 -0
  362. package/esm/security/redact.mjs +122 -0
  363. package/esm/security/redact.mjs.map +1 -0
  364. package/esm/serve/serve.d.mts +50 -0
  365. package/esm/serve/serve.d.mts.map +1 -0
  366. package/esm/serve/serve.mjs +90 -0
  367. package/esm/serve/serve.mjs.map +1 -0
  368. package/esm/serve/sse.d.mts +20 -0
  369. package/esm/serve/sse.d.mts.map +1 -0
  370. package/esm/serve/sse.mjs +25 -0
  371. package/esm/serve/sse.mjs.map +1 -0
  372. package/esm/serve/stream-to-sse.d.mts +29 -0
  373. package/esm/serve/stream-to-sse.d.mts.map +1 -0
  374. package/esm/serve/stream-to-sse.mjs +37 -0
  375. package/esm/serve/stream-to-sse.mjs.map +1 -0
  376. package/esm/skills/catalog.d.mts +49 -0
  377. package/esm/skills/catalog.d.mts.map +1 -0
  378. package/esm/skills/catalog.mjs +140 -0
  379. package/esm/skills/catalog.mjs.map +1 -0
  380. package/esm/skills/contracts/skill-record.type.d.mts +37 -0
  381. package/esm/skills/contracts/skill-record.type.d.mts.map +1 -0
  382. package/esm/skills/contracts/skills-config.type.d.mts +108 -0
  383. package/esm/skills/contracts/skills-config.type.d.mts.map +1 -0
  384. package/esm/skills/contracts/skills-store.contract.d.mts +28 -0
  385. package/esm/skills/contracts/skills-store.contract.d.mts.map +1 -0
  386. package/esm/skills/contracts/skills.contract.d.mts +43 -0
  387. package/esm/skills/contracts/skills.contract.d.mts.map +1 -0
  388. package/esm/skills/index.d.mts +16 -0
  389. package/esm/skills/index.mjs +14 -0
  390. package/esm/skills/load-skill-tool.d.mts +38 -0
  391. package/esm/skills/load-skill-tool.d.mts.map +1 -0
  392. package/esm/skills/load-skill-tool.mjs +65 -0
  393. package/esm/skills/load-skill-tool.mjs.map +1 -0
  394. package/esm/skills/review-gate.d.mts +33 -0
  395. package/esm/skills/review-gate.d.mts.map +1 -0
  396. package/esm/skills/review-gate.mjs +60 -0
  397. package/esm/skills/review-gate.mjs.map +1 -0
  398. package/esm/skills/save-skill-tool.d.mts +39 -0
  399. package/esm/skills/save-skill-tool.d.mts.map +1 -0
  400. package/esm/skills/save-skill-tool.mjs +65 -0
  401. package/esm/skills/save-skill-tool.mjs.map +1 -0
  402. package/esm/skills/skills.d.mts +33 -0
  403. package/esm/skills/skills.d.mts.map +1 -0
  404. package/esm/skills/skills.mjs +109 -0
  405. package/esm/skills/skills.mjs.map +1 -0
  406. package/esm/skills/sources/directory-source.d.mts +19 -0
  407. package/esm/skills/sources/directory-source.d.mts.map +1 -0
  408. package/esm/skills/sources/directory-source.mjs +108 -0
  409. package/esm/skills/sources/directory-source.mjs.map +1 -0
  410. package/esm/skills/sources/index.d.mts +18 -0
  411. package/esm/skills/sources/index.d.mts.map +1 -0
  412. package/esm/skills/sources/index.mjs +27 -0
  413. package/esm/skills/sources/index.mjs.map +1 -0
  414. package/esm/skills/sources/parse-frontmatter.d.mts +27 -0
  415. package/esm/skills/sources/parse-frontmatter.d.mts.map +1 -0
  416. package/esm/skills/sources/parse-frontmatter.mjs +46 -0
  417. package/esm/skills/sources/parse-frontmatter.mjs.map +1 -0
  418. package/esm/skills/sources/store-source.d.mts +14 -0
  419. package/esm/skills/sources/store-source.d.mts.map +1 -0
  420. package/esm/skills/sources/store-source.mjs +15 -0
  421. package/esm/skills/sources/store-source.mjs.map +1 -0
  422. package/esm/skills/sources/url-source.d.mts +29 -0
  423. package/esm/skills/sources/url-source.d.mts.map +1 -0
  424. package/esm/skills/sources/url-source.mjs +117 -0
  425. package/esm/skills/sources/url-source.mjs.map +1 -0
  426. package/esm/skills/store/mock-skills-store.d.mts +57 -0
  427. package/esm/skills/store/mock-skills-store.d.mts.map +1 -0
  428. package/esm/skills/store/mock-skills-store.mjs +100 -0
  429. package/esm/skills/store/mock-skills-store.mjs.map +1 -0
  430. package/esm/skills/store/procedural-skill-store.d.mts +30 -0
  431. package/esm/skills/store/procedural-skill-store.d.mts.map +1 -0
  432. package/esm/skills/store/procedural-skill-store.mjs +125 -0
  433. package/esm/skills/store/procedural-skill-store.mjs.map +1 -0
  434. package/esm/supervisor/as-tool.mjs +2 -2
  435. package/esm/supervisor/as-tool.mjs.map +1 -1
  436. package/esm/supervisor/execution.d.mts.map +1 -1
  437. package/esm/supervisor/execution.mjs +31 -28
  438. package/esm/supervisor/execution.mjs.map +1 -1
  439. package/esm/supervisor/supervisor.d.mts.map +1 -1
  440. package/esm/supervisor/supervisor.mjs +8 -3
  441. package/esm/supervisor/supervisor.mjs.map +1 -1
  442. package/esm/system-prompt/index.d.mts +4 -0
  443. package/esm/system-prompt/system-prompt.d.mts +68 -4
  444. package/esm/system-prompt/system-prompt.d.mts.map +1 -1
  445. package/esm/system-prompt/system-prompt.mjs +89 -5
  446. package/esm/system-prompt/system-prompt.mjs.map +1 -1
  447. package/esm/team/gates.mjs +48 -0
  448. package/esm/team/gates.mjs.map +1 -0
  449. package/esm/team/index.d.mts +1 -0
  450. package/esm/team/index.mjs +3 -0
  451. package/esm/team/team.d.mts +42 -0
  452. package/esm/team/team.d.mts.map +1 -0
  453. package/esm/team/team.mjs +94 -0
  454. package/esm/team/team.mjs.map +1 -0
  455. package/esm/tool/executable-as-tool.d.mts.map +1 -1
  456. package/esm/tool/executable-as-tool.mjs +2 -2
  457. package/esm/tool/executable-as-tool.mjs.map +1 -1
  458. package/esm/tool/tool.d.mts.map +1 -1
  459. package/esm/tool/tool.mjs +2 -2
  460. package/esm/tool/tool.mjs.map +1 -1
  461. package/esm/utils/compute-cost.d.mts +17 -1
  462. package/esm/utils/compute-cost.d.mts.map +1 -1
  463. package/esm/utils/compute-cost.mjs +26 -1
  464. package/esm/utils/compute-cost.mjs.map +1 -1
  465. package/esm/utils/extract-json-lenient.d.mts +42 -0
  466. package/esm/utils/extract-json-lenient.d.mts.map +1 -0
  467. package/esm/utils/extract-json-lenient.mjs +97 -0
  468. package/esm/utils/extract-json-lenient.mjs.map +1 -0
  469. package/esm/utils/index.d.mts +4 -2
  470. package/esm/utils/index.mjs +3 -1
  471. package/esm/utils/json-schema.d.mts +1 -1
  472. package/esm/utils/prepare-attachment-part.d.mts +10 -1
  473. package/esm/utils/prepare-attachment-part.d.mts.map +1 -1
  474. package/esm/utils/prepare-attachment-part.mjs +103 -11
  475. package/esm/utils/prepare-attachment-part.mjs.map +1 -1
  476. package/esm/utils/resolve-attachment.d.mts +4 -3
  477. package/esm/utils/resolve-attachment.d.mts.map +1 -1
  478. package/esm/utils/resolve-attachment.mjs +4 -3
  479. package/esm/utils/resolve-attachment.mjs.map +1 -1
  480. package/esm/utils/run-context.d.mts +94 -0
  481. package/esm/utils/run-context.d.mts.map +1 -0
  482. package/esm/utils/run-context.mjs +98 -0
  483. package/esm/utils/run-context.mjs.map +1 -0
  484. package/esm/vcr/cassette-io.mjs +57 -0
  485. package/esm/vcr/cassette-io.mjs.map +1 -0
  486. package/esm/vcr/errors.d.mts +42 -0
  487. package/esm/vcr/errors.d.mts.map +1 -0
  488. package/esm/vcr/errors.mjs +37 -0
  489. package/esm/vcr/errors.mjs.map +1 -0
  490. package/esm/vcr/hash-request.d.mts +28 -0
  491. package/esm/vcr/hash-request.d.mts.map +1 -0
  492. package/esm/vcr/hash-request.mjs +118 -0
  493. package/esm/vcr/hash-request.mjs.map +1 -0
  494. package/esm/vcr/index.d.mts +4 -0
  495. package/esm/vcr/index.mjs +5 -0
  496. package/esm/vcr/vcr.d.mts +32 -0
  497. package/esm/vcr/vcr.d.mts.map +1 -0
  498. package/esm/vcr/vcr.mjs +248 -0
  499. package/esm/vcr/vcr.mjs.map +1 -0
  500. package/esm/vcr/vcr.type.d.mts +118 -0
  501. package/esm/vcr/vcr.type.d.mts.map +1 -0
  502. package/esm/workflow/as-tool.mjs +2 -2
  503. package/esm/workflow/as-tool.mjs.map +1 -1
  504. package/esm/workflow/engine.mjs +1 -0
  505. package/esm/workflow/engine.mjs.map +1 -1
  506. package/esm/workflow/step-runner.mjs +19 -20
  507. package/esm/workflow/step-runner.mjs.map +1 -1
  508. package/esm/workflow/workflow.d.mts.map +1 -1
  509. package/esm/workflow/workflow.mjs +8 -3
  510. package/esm/workflow/workflow.mjs.map +1 -1
  511. package/llms-full.txt +1683 -68
  512. package/llms.txt +16 -4
  513. package/package.json +7 -3
  514. package/skills/README.md +40 -4
  515. package/skills/ai-dx-helpers/SKILL.md +2 -2
  516. package/skills/approve-tool-calls/SKILL.md +134 -0
  517. package/skills/attach-ai-middleware/SKILL.md +1 -1
  518. package/skills/detect-and-redact-pii/SKILL.md +104 -0
  519. package/skills/durable-resume/SKILL.md +128 -0
  520. package/skills/escalate-block-to-human/SKILL.md +85 -0
  521. package/skills/eval-datasets-and-ci/SKILL.md +117 -0
  522. package/skills/guard-input-output/SKILL.md +117 -0
  523. package/skills/manage-prompts/SKILL.md +186 -0
  524. package/skills/observe-ai-flows/SKILL.md +94 -0
  525. package/skills/record-replay-llm/SKILL.md +92 -0
  526. package/skills/run-ai-agent/SKILL.md +26 -1
  527. package/skills/run-ai-rag/SKILL.md +139 -0
  528. package/skills/run-ai-team/SKILL.md +107 -0
  529. package/skills/run-orchestrator/SKILL.md +2 -0
  530. package/skills/run-planner/SKILL.md +73 -8
  531. package/skills/run-supervisor/SKILL.md +20 -1
  532. package/skills/use-runtime-skills/SKILL.md +106 -0
  533. package/skills/write-system-prompt/SKILL.md +30 -1
  534. package/cjs/index.cjs.map +0 -1
  535. package/esm/contracts/result/index.d.mts +0 -15
@@ -0,0 +1,78 @@
1
+ import { MiddlewareTripContext } from "../../contracts/middleware/middleware-context.type.mjs";
2
+ import { GuardrailPhase, GuardrailVerdict } from "./verdict.type.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/guard/contracts/guardrail.contract.d.ts
5
+ /**
6
+ * The stable context every detector receives on each `check()` — the phase
7
+ * it is running at plus the live middleware trip context.
8
+ *
9
+ * A detector reads `phase` to branch on *where* it is running (e.g. an
10
+ * injection detector escalating to `block` on `"input"` but only `flag` on
11
+ * `"output"`), and `ctx` for the surrounding run identity (`state`,
12
+ * `messages`, `agent`, `model`, `signal`). A detector must never mutate
13
+ * `ctx` — it is a read-only view; the factory owns all pipeline effects.
14
+ */
15
+ interface GuardrailDetectorContext {
16
+ /** Where this detector is running: input prompt, output, or tool args. */
17
+ readonly phase: GuardrailPhase;
18
+ /** The live middleware trip context (state, messages, agent, model, signal). */
19
+ readonly ctx: MiddlewareTripContext;
20
+ }
21
+ /**
22
+ * A guardrail detector — the unit of content intelligence. Inspects a piece
23
+ * of text and returns a {@link GuardrailVerdict}. Sync or async (an async
24
+ * `check` routes to an external moderation API).
25
+ *
26
+ * A detector has **no** knowledge of hooks, ordering, or `ctx.state`
27
+ * mutation — the {@link guard} factory is the thin adapter that runs
28
+ * detectors at the right hook points and translates verdicts into the
29
+ * pipeline's throw / return / record mechanics.
30
+ *
31
+ * @example
32
+ * const noShouting: GuardrailDetector = {
33
+ * name: "no-shouting",
34
+ * check(text) {
35
+ * return text === text.toUpperCase() && text.length > 0
36
+ * ? { type: "flag", reason: "all caps", matches: [{ rule: "no-shouting" }] }
37
+ * : { type: "allow" };
38
+ * },
39
+ * };
40
+ */
41
+ interface GuardrailDetector {
42
+ /**
43
+ * Kebab-case identifier, used as the rule prefix in {@link GuardrailMatch}
44
+ * and surfaced in logs / events — e.g. `"pii"`, `"topic"`, `"injection"`,
45
+ * `"moderation.openai"`.
46
+ */
47
+ readonly name: string;
48
+ /**
49
+ * Inspect `text` and return a verdict. Receives the
50
+ * {@link GuardrailDetectorContext} so it can branch on the phase or read
51
+ * the surrounding run state.
52
+ */
53
+ check(text: string, detectorCtx: GuardrailDetectorContext): GuardrailVerdict | Promise<GuardrailVerdict>;
54
+ }
55
+ /**
56
+ * A {@link GuardrailDetector} whose `check()` is **synchronous** — it returns a
57
+ * {@link GuardrailVerdict} directly, never a `Promise`. Used by the built-in
58
+ * zero-dependency detectors (`pii`, `topic`, `injection`) that inspect text
59
+ * with pure string / regex matching and have no async work to do.
60
+ *
61
+ * Because the return type is covariant, a `SyncGuardrailDetector` is
62
+ * structurally assignable to {@link GuardrailDetector}: anything that accepts a
63
+ * `GuardrailDetector` (the guard factory's `input` / `output` / `tool` arrays)
64
+ * accepts a `SyncGuardrailDetector` unchanged. Callers that hold the concrete
65
+ * sync type additionally get to read `verdict.type` / `.matches` / `.text`
66
+ * without awaiting.
67
+ */
68
+ interface SyncGuardrailDetector extends GuardrailDetector {
69
+ /**
70
+ * Inspect `text` and return a verdict synchronously. Receives the
71
+ * {@link GuardrailDetectorContext} so it can branch on the phase or read
72
+ * the surrounding run state.
73
+ */
74
+ check(text: string, detectorCtx: GuardrailDetectorContext): GuardrailVerdict;
75
+ }
76
+ //#endregion
77
+ export { GuardrailDetector, GuardrailDetectorContext, SyncGuardrailDetector };
78
+ //# sourceMappingURL=guardrail.contract.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guardrail.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/guard/contracts/guardrail.contract.ts"],"mappings":";;;;;;AAaA;;;;;;;;UAAiB,wBAAA;EAIoB;EAAA,SAF1B,KAAA,EAAO,cAAA;EAyBgB;EAAA,SAvBvB,GAAA,EAAK,qBAAqB;AAAA;;;;;;;;;;;;;;;AAsCW;AAgBhD;;;;;UA/BiB,iBAAA;EA+B+C;;;;;EAAA,SAzBrD,IAAA;EA+BW;;;AAAwD;;EAzB5E,KAAA,CACE,IAAA,UACA,WAAA,EAAa,wBAAA,GACZ,gBAAA,GAAmB,OAAA,CAAQ,gBAAA;AAAA;;;;;;;;;;;;;;UAgBf,qBAAA,SAA8B,iBAAA;;;;;;EAM7C,KAAA,CAAM,IAAA,UAAc,WAAA,EAAa,wBAAA,GAA2B,gBAAA;AAAA"}
@@ -0,0 +1,4 @@
1
+ import { GuardrailAction, GuardrailMatch, GuardrailPhase, GuardrailVerdict } from "./verdict.type.mjs";
2
+ import { GuardrailDetector, GuardrailDetectorContext, SyncGuardrailDetector } from "./guardrail.contract.mjs";
3
+ import { OpenAiClientLike, OpenAiModerationCreateBody, OpenAiModerationResponse, OpenAiModerationResult } from "./openai-client.contract.mjs";
4
+ import { GuardOptions, GuardrailBlockEvent, GuardrailEscalation, InjectionDetectorOptions, OpenAiModerationOptions, PiiCategory, PiiDetectorOptions, TopicFilterOptions } from "./guard-options.type.mjs";
@@ -0,0 +1,51 @@
1
+ //#region ../@warlock.js/ai/src/guard/contracts/openai-client.contract.d.ts
2
+ /**
3
+ * Minimal structural view of the part of the `openai` SDK the
4
+ * `moderation` detector actually calls. Declared locally (rather than
5
+ * importing the SDK's own types) so `@warlock.js/ai` type-checks even
6
+ * when `openai` is **not** installed — it is an OPTIONAL peer, lazily
7
+ * imported at runtime. The shape tracks the OpenAI Node SDK v4:
8
+ * `client.moderations.create({ model, input })` resolves to a response whose
9
+ * `results[]` each carry a `flagged` boolean and per-category `categories` /
10
+ * `category_scores` maps.
11
+ *
12
+ * Surfacing it as a contract lets a caller pass a ready
13
+ * {@link OpenAiClientLike} (real `OpenAI` instance, mock, or proxy) on
14
+ * `OpenAiModerationOptions.client` to bypass the lazy import entirely.
15
+ */
16
+ /**
17
+ * A pre-built OpenAI-compatible client — any object exposing
18
+ * `moderations.create`. Passing one on `OpenAiModerationOptions.client` lets
19
+ * the detector skip the lazy `import("openai")` entirely (so bring-your-own-
20
+ * client callers and hermetic tests never need the SDK on disk).
21
+ */
22
+ interface OpenAiClientLike {
23
+ readonly moderations: {
24
+ create(body: OpenAiModerationCreateBody): Promise<OpenAiModerationResponse>;
25
+ };
26
+ }
27
+ /** Subset of the moderation-create body the detector populates. */
28
+ interface OpenAiModerationCreateBody {
29
+ /** Moderation model id (e.g. `"omni-moderation-latest"`). */
30
+ readonly model: string;
31
+ /** The text to moderate. */
32
+ readonly input: string;
33
+ }
34
+ /** Subset of the moderation response the detector reads. */
35
+ interface OpenAiModerationResponse {
36
+ readonly results: readonly OpenAiModerationResult[];
37
+ }
38
+ /**
39
+ * One moderation result. `flagged` is the SDK's overall verdict; `categories`
40
+ * maps each policy category to whether it tripped; `category_scores` carries
41
+ * the per-category confidence, surfaced on each {@link GuardrailMatch.label}'s
42
+ * companion data when present.
43
+ */
44
+ interface OpenAiModerationResult {
45
+ readonly flagged: boolean;
46
+ readonly categories: Record<string, boolean>;
47
+ readonly category_scores?: Record<string, number>;
48
+ }
49
+ //#endregion
50
+ export { OpenAiClientLike, OpenAiModerationCreateBody, OpenAiModerationResponse, OpenAiModerationResult };
51
+ //# sourceMappingURL=openai-client.contract.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-client.contract.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/guard/contracts/openai-client.contract.ts"],"mappings":";;AAqBA;;;;;;;;;;;;;;;AAE8E;AAK9E;;;UAPiB,gBAAA;EAAA,SACN,WAAA;IACP,MAAA,CAAO,IAAA,EAAM,0BAAA,GAA6B,OAAA,CAAQ,wBAAA;EAAA;AAAA;;UAKrC,0BAAA;EAkBA;EAAA,SAhBN,KAAA;;WAEA,KAAK;AAAA;;UAIC,wBAAA;EAAA,SACN,OAAA,WAAkB,sBAAsB;AAAA;;AAYhB;;;;;UAHlB,sBAAA;EAAA,SACN,OAAA;EAAA,SACA,UAAA,EAAY,MAAA;EAAA,SACZ,eAAA,GAAkB,MAAM;AAAA"}
@@ -0,0 +1,76 @@
1
+ //#region ../@warlock.js/ai/src/guard/contracts/verdict.type.d.ts
2
+ /**
3
+ * Where a detector is running. Widens the core guardrail phase
4
+ * (`"input" | "output"`) with a third value, `"tool"`, for detectors that
5
+ * inspect the arguments the model produced for a tool call. Reused on the
6
+ * `GuardrailViolationError.phase` surfaced to callers and on any emitted
7
+ * escalation event.
8
+ */
9
+ type GuardrailPhase = "input" | "output" | "tool";
10
+ /**
11
+ * The four actions a detector can return, the discriminator of
12
+ * {@link GuardrailVerdict}.
13
+ *
14
+ * - `allow` — content is clean; continue to the next detector.
15
+ * - `redact` — rewrite the inspected text and continue.
16
+ * - `block` — reject the trip / tool call with a `GuardrailViolationError`.
17
+ * - `flag` — allow the content but record the match for a downstream observer.
18
+ *
19
+ * `type` is always the discriminator — never `kind`.
20
+ */
21
+ type GuardrailAction = "allow" | "redact" | "block" | "flag";
22
+ /**
23
+ * A single thing a detector matched inside the inspected text. Surfaced in
24
+ * logs, events, and on `redact` / `flag` verdicts so an operator can see
25
+ * *what* tripped a rule without re-running the detector.
26
+ */
27
+ interface GuardrailMatch {
28
+ /**
29
+ * The detector rule that produced the match, namespaced under the
30
+ * detector — e.g. `"pii.ssn"`, `"topic.deny.medical"`,
31
+ * `"injection.jailbreak"`.
32
+ */
33
+ readonly rule: string;
34
+ /**
35
+ * Inclusive `[start, end]` character offsets into the inspected text,
36
+ * when the detector can locate the match. Omitted for whole-text
37
+ * verdicts (e.g. an allow-list miss or a moderation-model category).
38
+ */
39
+ readonly span?: readonly [start: number, end: number];
40
+ /**
41
+ * Free-form category surfaced in logs and events and substituted into a
42
+ * redaction `mask` template — e.g. `"ssn"`, `"email"`, `"violence"`.
43
+ */
44
+ readonly label?: string;
45
+ }
46
+ /**
47
+ * The verdict a {@link GuardrailDetector} returns from `check()` — a
48
+ * discriminated union with exactly one {@link GuardrailAction} per shape.
49
+ * The factory folds a detector array and acts on the first non-`allow`
50
+ * verdict (short-circuit, in registration order).
51
+ */
52
+ type GuardrailVerdict = {
53
+ /** Content is clean; continue to the next detector. */readonly type: "allow";
54
+ } | {
55
+ /** Rewrite the inspected text and continue. */readonly type: "redact"; /** The inspected text with every match replaced (detector-produced). */
56
+ readonly text: string; /** Human-readable explanation of what was redacted and why. */
57
+ readonly reason: string; /** The matches the detector replaced. */
58
+ readonly matches: readonly GuardrailMatch[];
59
+ } | {
60
+ /** Reject the trip / tool call. */readonly type: "block"; /** Human-readable reason surfaced on `GuardrailViolationError.reason`. */
61
+ readonly reason: string; /** The matches that triggered the block, when known. */
62
+ readonly matches?: readonly GuardrailMatch[];
63
+ /**
64
+ * Ask the host to route this block to a human-review surface. When
65
+ * `true`, the factory awaits `escalation.onBlock` before throwing.
66
+ * Default `false`.
67
+ */
68
+ readonly escalate?: boolean;
69
+ } | {
70
+ /** Allow the content but record the match for a downstream observer. */readonly type: "flag"; /** Human-readable explanation of what was flagged. */
71
+ readonly reason: string; /** The matches the detector recorded. */
72
+ readonly matches: readonly GuardrailMatch[];
73
+ };
74
+ //#endregion
75
+ export { GuardrailAction, GuardrailMatch, GuardrailPhase, GuardrailVerdict };
76
+ //# sourceMappingURL=verdict.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict.type.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/guard/contracts/verdict.type.ts"],"mappings":";;AAOA;;;;AAA0B;AAa1B;KAbY,cAAA;;;AAae;AAO3B;;;;;;;;KAPY,eAAA;;AAwBI;AAShB;;;UA1BiB,cAAA;EA+CiB;;;;;EAAA,SAzCvB,IAAA;EA6BI;;;;;EAAA,SAvBJ,IAAA,aAAiB,KAAA,UAAe,GAAA;EAmC5B;;;;EAAA,SA9BJ,KAAA;AAAA;;;AA4CoC;;;;KAnCnC,gBAAA;kEAGG,IAAA;AAAA;0DAIA,IAAA;WAEA,IAAA;WAEA,MAAA;WAEA,OAAA,WAAkB,cAAA;AAAA;8CAIlB,IAAA;WAEA,MAAA;WAEA,OAAA,YAAmB,cAAA;;;;;;WAMnB,QAAA;AAAA;mFAIA,IAAA;WAEA,MAAA;WAEA,OAAA,WAAkB,cAAA;AAAA"}
@@ -0,0 +1,4 @@
1
+ import { injection } from "./injection.mjs";
2
+ import { pii } from "./pii.mjs";
3
+ import { topic } from "./topic.mjs";
4
+ import { moderation } from "./moderation.mjs";
@@ -0,0 +1,6 @@
1
+ import { injection } from "./injection.mjs";
2
+ import { pii } from "./pii.mjs";
3
+ import { topic } from "./topic.mjs";
4
+ import { moderation } from "./moderation.mjs";
5
+
6
+ export { };
@@ -0,0 +1,34 @@
1
+ import { SyncGuardrailDetector } from "../contracts/guardrail.contract.mjs";
2
+ import { InjectionDetectorOptions } from "../contracts/guard-options.type.mjs";
3
+ //#region ../@warlock.js/ai/src/guard/detectors/injection.d.ts
4
+ /**
5
+ * Build the built-in `injection` detector (surfaced as
6
+ * `ai.guardrail.injection(options?)`). Matches a curated set of jailbreak /
7
+ * prompt-injection marker phrases — override (`"ignore previous
8
+ * instructions"`), role-reset (`"you are now"`), jailbreak (`"developer
9
+ * mode"`, `"do anything now"`), and exfiltration (`"reveal your system
10
+ * prompt"`) — extensible with caller `markers` (case-insensitive substrings
11
+ * or `RegExp`s).
12
+ *
13
+ * Zero runtime dependency: matching is pure string / regex. On a hit the
14
+ * verdict is `flag` by default (record but allow); pass `onMatch: "block"`
15
+ * to reject instead — commonly used on the `input` phase, where the core
16
+ * `trip.before` seam supports `block` / `flag` only.
17
+ *
18
+ * @param options - Extra `markers` and the `onMatch` action (`"flag"` | `"block"`).
19
+ * @returns A {@link SyncGuardrailDetector} for the guard's `input` / `output` / `tool` arrays.
20
+ *
21
+ * @example
22
+ * const guard = ai.guardrail({
23
+ * input: [ai.guardrail.injection({ onMatch: "block" })],
24
+ * output: [ai.guardrail.injection()], // flag-only on the model's reply
25
+ * });
26
+ *
27
+ * @example
28
+ * // Extend the built-in set with a house rule.
29
+ * ai.guardrail.injection({ markers: [/system\s*:\s*override/i, "sudo mode"] });
30
+ */
31
+ declare function injection(options?: InjectionDetectorOptions): SyncGuardrailDetector;
32
+ //#endregion
33
+ export { injection };
34
+ //# sourceMappingURL=injection.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injection.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/guard/detectors/injection.ts"],"mappings":";;;;;;;AAiNA;;;;;;;;AAEwB;;;;;;;;;;;;;;;iBAFR,SAAA,CACd,OAAA,GAAU,wBAAA,GACT,qBAAqB"}
@@ -0,0 +1,254 @@
1
+ //#region ../@warlock.js/ai/src/guard/detectors/injection.ts
2
+ const DETECTOR_NAME = "injection";
3
+ /**
4
+ * Built-in jailbreak / prompt-injection marker phrases. Each entry is a
5
+ * case-insensitive substring (matched lowercased) paired with the rule
6
+ * label surfaced on the {@link GuardrailMatch} (`injection.<label>`).
7
+ *
8
+ * The set targets the canonical override / role-reset / exfiltration
9
+ * patterns rather than trying to be exhaustive — a curated, low-false-
10
+ * positive seed that callers extend with their own `markers`. Phrases are
11
+ * deliberately specific (`"ignore previous instructions"`, not the bare
12
+ * word `"ignore"`) so ordinary prose does not trip the rule.
13
+ */
14
+ const BUILT_IN_MARKERS = [
15
+ {
16
+ phrase: "ignore previous instructions",
17
+ label: "override"
18
+ },
19
+ {
20
+ phrase: "ignore all previous instructions",
21
+ label: "override"
22
+ },
23
+ {
24
+ phrase: "ignore the above instructions",
25
+ label: "override"
26
+ },
27
+ {
28
+ phrase: "disregard previous instructions",
29
+ label: "override"
30
+ },
31
+ {
32
+ phrase: "disregard all previous instructions",
33
+ label: "override"
34
+ },
35
+ {
36
+ phrase: "forget previous instructions",
37
+ label: "override"
38
+ },
39
+ {
40
+ phrase: "forget all previous instructions",
41
+ label: "override"
42
+ },
43
+ {
44
+ phrase: "ignore your instructions",
45
+ label: "override"
46
+ },
47
+ {
48
+ phrase: "override your instructions",
49
+ label: "override"
50
+ },
51
+ {
52
+ phrase: "do not follow your instructions",
53
+ label: "override"
54
+ },
55
+ {
56
+ phrase: "you are now",
57
+ label: "role-reset"
58
+ },
59
+ {
60
+ phrase: "act as",
61
+ label: "role-reset"
62
+ },
63
+ {
64
+ phrase: "pretend to be",
65
+ label: "role-reset"
66
+ },
67
+ {
68
+ phrase: "developer mode",
69
+ label: "jailbreak"
70
+ },
71
+ {
72
+ phrase: "jailbreak",
73
+ label: "jailbreak"
74
+ },
75
+ {
76
+ phrase: "dan mode",
77
+ label: "jailbreak"
78
+ },
79
+ {
80
+ phrase: "do anything now",
81
+ label: "jailbreak"
82
+ },
83
+ {
84
+ phrase: "bypass your",
85
+ label: "jailbreak"
86
+ },
87
+ {
88
+ phrase: "ignore your guidelines",
89
+ label: "jailbreak"
90
+ },
91
+ {
92
+ phrase: "ignore your safety",
93
+ label: "jailbreak"
94
+ },
95
+ {
96
+ phrase: "ignore the rules",
97
+ label: "jailbreak"
98
+ },
99
+ {
100
+ phrase: "without any restrictions",
101
+ label: "jailbreak"
102
+ },
103
+ {
104
+ phrase: "reveal your system prompt",
105
+ label: "exfiltration"
106
+ },
107
+ {
108
+ phrase: "print your system prompt",
109
+ label: "exfiltration"
110
+ },
111
+ {
112
+ phrase: "show your system prompt",
113
+ label: "exfiltration"
114
+ },
115
+ {
116
+ phrase: "repeat your instructions",
117
+ label: "exfiltration"
118
+ },
119
+ {
120
+ phrase: "what are your instructions",
121
+ label: "exfiltration"
122
+ },
123
+ {
124
+ phrase: "reveal your prompt",
125
+ label: "exfiltration"
126
+ }
127
+ ];
128
+ /**
129
+ * The zero-dependency built-in injection detector — the internal class
130
+ * behind the {@link injection} factory. Scans for jailbreak / prompt-
131
+ * injection marker phrases (built-in set + caller `markers`) and returns a
132
+ * `block` or `flag` verdict (per `onMatch`) listing every match, or `allow`
133
+ * when the text is clean.
134
+ *
135
+ * Detection only: a detector never throws or mutates the pipeline — the
136
+ * `guard()` factory translates the verdict into the trip's throw / record
137
+ * mechanics.
138
+ */
139
+ var InjectionDetector = class {
140
+ constructor(options = {}) {
141
+ this.name = DETECTOR_NAME;
142
+ this.block = options.onMatch === "block";
143
+ this.markers = compileMarkers(options.markers ?? []);
144
+ }
145
+ /**
146
+ * Inspect `text` for any built-in or caller marker. Returns `allow` when
147
+ * none hit, otherwise the configured `block` / `flag` verdict carrying a
148
+ * {@link GuardrailMatch} per hit (with a `[start, end]` span for literal
149
+ * substrings; regex hits report a span only when the match is locatable).
150
+ */
151
+ check(text) {
152
+ const matches = this.scan(text);
153
+ if (matches.length === 0) return { type: "allow" };
154
+ const reason = `Detected ${matches.length} prompt-injection marker(s).`;
155
+ if (this.block) return {
156
+ type: "block",
157
+ reason,
158
+ matches
159
+ };
160
+ return {
161
+ type: "flag",
162
+ reason,
163
+ matches
164
+ };
165
+ }
166
+ /** Collect every marker hit in `text`, in marker registration order. */
167
+ scan(text) {
168
+ const lowered = text.toLowerCase();
169
+ const matches = [];
170
+ for (const marker of this.markers) {
171
+ if (marker.phrase !== void 0) {
172
+ const start = lowered.indexOf(marker.phrase);
173
+ if (start !== -1) matches.push({
174
+ rule: `${DETECTOR_NAME}.${marker.label}`,
175
+ label: marker.label,
176
+ span: [start, start + marker.phrase.length - 1]
177
+ });
178
+ continue;
179
+ }
180
+ const pattern = marker.pattern;
181
+ if (pattern === void 0) continue;
182
+ const result = pattern.exec(text);
183
+ if (result !== null) {
184
+ const start = result.index;
185
+ matches.push({
186
+ rule: `${DETECTOR_NAME}.${marker.label}`,
187
+ label: marker.label,
188
+ span: [start, start + result[0].length - 1]
189
+ });
190
+ }
191
+ }
192
+ return matches;
193
+ }
194
+ };
195
+ /**
196
+ * Compile the built-in phrase set plus any caller `markers` into a single
197
+ * ordered list. A caller `string` becomes a lowercased substring matcher
198
+ * (labelled `custom`); a caller `RegExp` is carried as-is (labelled
199
+ * `custom`). Built-ins keep their threat-category label.
200
+ */
201
+ function compileMarkers(extra) {
202
+ const compiled = BUILT_IN_MARKERS.map((entry) => ({
203
+ label: entry.label,
204
+ phrase: entry.phrase
205
+ }));
206
+ for (const marker of extra) {
207
+ if (typeof marker === "string") {
208
+ compiled.push({
209
+ label: "custom",
210
+ phrase: marker.toLowerCase()
211
+ });
212
+ continue;
213
+ }
214
+ compiled.push({
215
+ label: "custom",
216
+ pattern: marker
217
+ });
218
+ }
219
+ return compiled;
220
+ }
221
+ /**
222
+ * Build the built-in `injection` detector (surfaced as
223
+ * `ai.guardrail.injection(options?)`). Matches a curated set of jailbreak /
224
+ * prompt-injection marker phrases — override (`"ignore previous
225
+ * instructions"`), role-reset (`"you are now"`), jailbreak (`"developer
226
+ * mode"`, `"do anything now"`), and exfiltration (`"reveal your system
227
+ * prompt"`) — extensible with caller `markers` (case-insensitive substrings
228
+ * or `RegExp`s).
229
+ *
230
+ * Zero runtime dependency: matching is pure string / regex. On a hit the
231
+ * verdict is `flag` by default (record but allow); pass `onMatch: "block"`
232
+ * to reject instead — commonly used on the `input` phase, where the core
233
+ * `trip.before` seam supports `block` / `flag` only.
234
+ *
235
+ * @param options - Extra `markers` and the `onMatch` action (`"flag"` | `"block"`).
236
+ * @returns A {@link SyncGuardrailDetector} for the guard's `input` / `output` / `tool` arrays.
237
+ *
238
+ * @example
239
+ * const guard = ai.guardrail({
240
+ * input: [ai.guardrail.injection({ onMatch: "block" })],
241
+ * output: [ai.guardrail.injection()], // flag-only on the model's reply
242
+ * });
243
+ *
244
+ * @example
245
+ * // Extend the built-in set with a house rule.
246
+ * ai.guardrail.injection({ markers: [/system\s*:\s*override/i, "sudo mode"] });
247
+ */
248
+ function injection(options) {
249
+ return new InjectionDetector(options);
250
+ }
251
+
252
+ //#endregion
253
+ export { injection };
254
+ //# sourceMappingURL=injection.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injection.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/guard/detectors/injection.ts"],"sourcesContent":["import type {\n GuardrailMatch,\n GuardrailVerdict,\n InjectionDetectorOptions,\n SyncGuardrailDetector,\n} from \"../contracts\";\n\nconst DETECTOR_NAME = \"injection\";\n\n/**\n * Built-in jailbreak / prompt-injection marker phrases. Each entry is a\n * case-insensitive substring (matched lowercased) paired with the rule\n * label surfaced on the {@link GuardrailMatch} (`injection.<label>`).\n *\n * The set targets the canonical override / role-reset / exfiltration\n * patterns rather than trying to be exhaustive — a curated, low-false-\n * positive seed that callers extend with their own `markers`. Phrases are\n * deliberately specific (`\"ignore previous instructions\"`, not the bare\n * word `\"ignore\"`) so ordinary prose does not trip the rule.\n */\nconst BUILT_IN_MARKERS: readonly { readonly phrase: string; readonly label: string }[] = [\n { phrase: \"ignore previous instructions\", label: \"override\" },\n { phrase: \"ignore all previous instructions\", label: \"override\" },\n { phrase: \"ignore the above instructions\", label: \"override\" },\n { phrase: \"disregard previous instructions\", label: \"override\" },\n { phrase: \"disregard all previous instructions\", label: \"override\" },\n { phrase: \"forget previous instructions\", label: \"override\" },\n { phrase: \"forget all previous instructions\", label: \"override\" },\n { phrase: \"ignore your instructions\", label: \"override\" },\n { phrase: \"override your instructions\", label: \"override\" },\n { phrase: \"do not follow your instructions\", label: \"override\" },\n { phrase: \"you are now\", label: \"role-reset\" },\n { phrase: \"act as\", label: \"role-reset\" },\n { phrase: \"pretend to be\", label: \"role-reset\" },\n { phrase: \"developer mode\", label: \"jailbreak\" },\n { phrase: \"jailbreak\", label: \"jailbreak\" },\n { phrase: \"dan mode\", label: \"jailbreak\" },\n { phrase: \"do anything now\", label: \"jailbreak\" },\n { phrase: \"bypass your\", label: \"jailbreak\" },\n { phrase: \"ignore your guidelines\", label: \"jailbreak\" },\n { phrase: \"ignore your safety\", label: \"jailbreak\" },\n { phrase: \"ignore the rules\", label: \"jailbreak\" },\n { phrase: \"without any restrictions\", label: \"jailbreak\" },\n { phrase: \"reveal your system prompt\", label: \"exfiltration\" },\n { phrase: \"print your system prompt\", label: \"exfiltration\" },\n { phrase: \"show your system prompt\", label: \"exfiltration\" },\n { phrase: \"repeat your instructions\", label: \"exfiltration\" },\n { phrase: \"what are your instructions\", label: \"exfiltration\" },\n { phrase: \"reveal your prompt\", label: \"exfiltration\" },\n];\n\n/**\n * A compiled marker — either a literal substring (matched case-insensitively\n * against the lowercased text) or a caller-supplied `RegExp` (tested as-is).\n * `label` is the namespaced rule suffix (`injection.<label>`); for built-in\n * phrases it is the threat category, for caller markers the index.\n */\ninterface CompiledMarker {\n readonly label: string;\n readonly phrase?: string;\n readonly pattern?: RegExp;\n}\n\n/**\n * The zero-dependency built-in injection detector — the internal class\n * behind the {@link injection} factory. Scans for jailbreak / prompt-\n * injection marker phrases (built-in set + caller `markers`) and returns a\n * `block` or `flag` verdict (per `onMatch`) listing every match, or `allow`\n * when the text is clean.\n *\n * Detection only: a detector never throws or mutates the pipeline — the\n * `guard()` factory translates the verdict into the trip's throw / record\n * mechanics.\n */\nclass InjectionDetector implements SyncGuardrailDetector {\n public readonly name = DETECTOR_NAME;\n\n /** The compiled built-in + caller markers, scanned in registration order. */\n private readonly markers: readonly CompiledMarker[];\n\n /** Whether a match escalates to `block` (`true`) or stays a `flag`. */\n private readonly block: boolean;\n\n public constructor(options: InjectionDetectorOptions = {}) {\n this.block = options.onMatch === \"block\";\n this.markers = compileMarkers(options.markers ?? []);\n }\n\n /**\n * Inspect `text` for any built-in or caller marker. Returns `allow` when\n * none hit, otherwise the configured `block` / `flag` verdict carrying a\n * {@link GuardrailMatch} per hit (with a `[start, end]` span for literal\n * substrings; regex hits report a span only when the match is locatable).\n */\n public check(text: string): GuardrailVerdict {\n const matches = this.scan(text);\n\n if (matches.length === 0) {\n return { type: \"allow\" };\n }\n\n const reason = `Detected ${matches.length} prompt-injection marker(s).`;\n\n if (this.block) {\n return { type: \"block\", reason, matches };\n }\n\n return { type: \"flag\", reason, matches };\n }\n\n /** Collect every marker hit in `text`, in marker registration order. */\n private scan(text: string): GuardrailMatch[] {\n const lowered = text.toLowerCase();\n const matches: GuardrailMatch[] = [];\n\n for (const marker of this.markers) {\n if (marker.phrase !== undefined) {\n const start = lowered.indexOf(marker.phrase);\n\n if (start !== -1) {\n matches.push({\n rule: `${DETECTOR_NAME}.${marker.label}`,\n label: marker.label,\n span: [start, start + marker.phrase.length - 1],\n });\n }\n\n continue;\n }\n\n // Caller-supplied RegExp — tested against the original (not lowered)\n // text so author-controlled case sensitivity is preserved.\n const pattern = marker.pattern;\n\n if (pattern === undefined) {\n continue;\n }\n\n const result = pattern.exec(text);\n\n if (result !== null) {\n const start = result.index;\n\n matches.push({\n rule: `${DETECTOR_NAME}.${marker.label}`,\n label: marker.label,\n span: [start, start + result[0].length - 1],\n });\n }\n }\n\n return matches;\n }\n}\n\n/**\n * Compile the built-in phrase set plus any caller `markers` into a single\n * ordered list. A caller `string` becomes a lowercased substring matcher\n * (labelled `custom`); a caller `RegExp` is carried as-is (labelled\n * `custom`). Built-ins keep their threat-category label.\n */\nfunction compileMarkers(\n extra: readonly (string | RegExp)[],\n): readonly CompiledMarker[] {\n const compiled: CompiledMarker[] = BUILT_IN_MARKERS.map((entry) => ({\n label: entry.label,\n phrase: entry.phrase,\n }));\n\n for (const marker of extra) {\n if (typeof marker === \"string\") {\n compiled.push({ label: \"custom\", phrase: marker.toLowerCase() });\n\n continue;\n }\n\n compiled.push({ label: \"custom\", pattern: marker });\n }\n\n return compiled;\n}\n\n/**\n * Build the built-in `injection` detector (surfaced as\n * `ai.guardrail.injection(options?)`). Matches a curated set of jailbreak /\n * prompt-injection marker phrases — override (`\"ignore previous\n * instructions\"`), role-reset (`\"you are now\"`), jailbreak (`\"developer\n * mode\"`, `\"do anything now\"`), and exfiltration (`\"reveal your system\n * prompt\"`) — extensible with caller `markers` (case-insensitive substrings\n * or `RegExp`s).\n *\n * Zero runtime dependency: matching is pure string / regex. On a hit the\n * verdict is `flag` by default (record but allow); pass `onMatch: \"block\"`\n * to reject instead — commonly used on the `input` phase, where the core\n * `trip.before` seam supports `block` / `flag` only.\n *\n * @param options - Extra `markers` and the `onMatch` action (`\"flag\"` | `\"block\"`).\n * @returns A {@link SyncGuardrailDetector} for the guard's `input` / `output` / `tool` arrays.\n *\n * @example\n * const guard = ai.guardrail({\n * input: [ai.guardrail.injection({ onMatch: \"block\" })],\n * output: [ai.guardrail.injection()], // flag-only on the model's reply\n * });\n *\n * @example\n * // Extend the built-in set with a house rule.\n * ai.guardrail.injection({ markers: [/system\\s*:\\s*override/i, \"sudo mode\"] });\n */\nexport function injection(\n options?: InjectionDetectorOptions,\n): SyncGuardrailDetector {\n return new InjectionDetector(options);\n}\n"],"mappings":";AAOA,MAAM,gBAAgB;;;;;;;;;;;;AAatB,MAAM,mBAAmF;CACvF;EAAE,QAAQ;EAAgC,OAAO;CAAW;CAC5D;EAAE,QAAQ;EAAoC,OAAO;CAAW;CAChE;EAAE,QAAQ;EAAiC,OAAO;CAAW;CAC7D;EAAE,QAAQ;EAAmC,OAAO;CAAW;CAC/D;EAAE,QAAQ;EAAuC,OAAO;CAAW;CACnE;EAAE,QAAQ;EAAgC,OAAO;CAAW;CAC5D;EAAE,QAAQ;EAAoC,OAAO;CAAW;CAChE;EAAE,QAAQ;EAA4B,OAAO;CAAW;CACxD;EAAE,QAAQ;EAA8B,OAAO;CAAW;CAC1D;EAAE,QAAQ;EAAmC,OAAO;CAAW;CAC/D;EAAE,QAAQ;EAAe,OAAO;CAAa;CAC7C;EAAE,QAAQ;EAAU,OAAO;CAAa;CACxC;EAAE,QAAQ;EAAiB,OAAO;CAAa;CAC/C;EAAE,QAAQ;EAAkB,OAAO;CAAY;CAC/C;EAAE,QAAQ;EAAa,OAAO;CAAY;CAC1C;EAAE,QAAQ;EAAY,OAAO;CAAY;CACzC;EAAE,QAAQ;EAAmB,OAAO;CAAY;CAChD;EAAE,QAAQ;EAAe,OAAO;CAAY;CAC5C;EAAE,QAAQ;EAA0B,OAAO;CAAY;CACvD;EAAE,QAAQ;EAAsB,OAAO;CAAY;CACnD;EAAE,QAAQ;EAAoB,OAAO;CAAY;CACjD;EAAE,QAAQ;EAA4B,OAAO;CAAY;CACzD;EAAE,QAAQ;EAA6B,OAAO;CAAe;CAC7D;EAAE,QAAQ;EAA4B,OAAO;CAAe;CAC5D;EAAE,QAAQ;EAA2B,OAAO;CAAe;CAC3D;EAAE,QAAQ;EAA4B,OAAO;CAAe;CAC5D;EAAE,QAAQ;EAA8B,OAAO;CAAe;CAC9D;EAAE,QAAQ;EAAsB,OAAO;CAAe;AACxD;;;;;;;;;;;;AAyBA,IAAM,oBAAN,MAAyD;CASvD,AAAO,YAAY,UAAoC,CAAC,GAAG;cARpC;EASrB,KAAK,QAAQ,QAAQ,YAAY;EACjC,KAAK,UAAU,eAAe,QAAQ,WAAW,CAAC,CAAC;CACrD;;;;;;;CAQA,AAAO,MAAM,MAAgC;EAC3C,MAAM,UAAU,KAAK,KAAK,IAAI;EAE9B,IAAI,QAAQ,WAAW,GACrB,OAAO,EAAE,MAAM,QAAQ;EAGzB,MAAM,SAAS,YAAY,QAAQ,OAAO;EAE1C,IAAI,KAAK,OACP,OAAO;GAAE,MAAM;GAAS;GAAQ;EAAQ;EAG1C,OAAO;GAAE,MAAM;GAAQ;GAAQ;EAAQ;CACzC;;CAGA,AAAQ,KAAK,MAAgC;EAC3C,MAAM,UAAU,KAAK,YAAY;EACjC,MAAM,UAA4B,CAAC;EAEnC,KAAK,MAAM,UAAU,KAAK,SAAS;GACjC,IAAI,OAAO,WAAW,QAAW;IAC/B,MAAM,QAAQ,QAAQ,QAAQ,OAAO,MAAM;IAE3C,IAAI,UAAU,IACZ,QAAQ,KAAK;KACX,MAAM,GAAG,cAAc,GAAG,OAAO;KACjC,OAAO,OAAO;KACd,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,SAAS,CAAC;IAChD,CAAC;IAGH;GACF;GAIA,MAAM,UAAU,OAAO;GAEvB,IAAI,YAAY,QACd;GAGF,MAAM,SAAS,QAAQ,KAAK,IAAI;GAEhC,IAAI,WAAW,MAAM;IACnB,MAAM,QAAQ,OAAO;IAErB,QAAQ,KAAK;KACX,MAAM,GAAG,cAAc,GAAG,OAAO;KACjC,OAAO,OAAO;KACd,MAAM,CAAC,OAAO,QAAQ,OAAO,EAAE,CAAC,SAAS,CAAC;IAC5C,CAAC;GACH;EACF;EAEA,OAAO;CACT;AACF;;;;;;;AAQA,SAAS,eACP,OAC2B;CAC3B,MAAM,WAA6B,iBAAiB,KAAK,WAAW;EAClE,OAAO,MAAM;EACb,QAAQ,MAAM;CAChB,EAAE;CAEF,KAAK,MAAM,UAAU,OAAO;EAC1B,IAAI,OAAO,WAAW,UAAU;GAC9B,SAAS,KAAK;IAAE,OAAO;IAAU,QAAQ,OAAO,YAAY;GAAE,CAAC;GAE/D;EACF;EAEA,SAAS,KAAK;GAAE,OAAO;GAAU,SAAS;EAAO,CAAC;CACpD;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,UACd,SACuB;CACvB,OAAO,IAAI,kBAAkB,OAAO;AACtC"}
@@ -0,0 +1,32 @@
1
+ import { GuardrailDetector } from "../contracts/guardrail.contract.mjs";
2
+ import { OpenAiModerationOptions } from "../contracts/guard-options.type.mjs";
3
+ //#region ../@warlock.js/ai/src/guard/detectors/moderation.d.ts
4
+ /**
5
+ * Build the optional `moderation` detector (surfaced as
6
+ * `ai.guardrail.moderation(options?)`), backed by OpenAI's moderation
7
+ * endpoint. The `openai` SDK is an **optional lazy peer**: importing
8
+ * `@warlock.js/ai` never forces it to resolve, and the detector throws
9
+ * a curated install string ({@link OPENAI_INSTALL_INSTRUCTIONS}) on first
10
+ * `check()` when the peer is absent — mirroring ai-panoptic's lazy Langfuse
11
+ * exporter.
12
+ *
13
+ * On a moderation hit, every flagged category becomes a
14
+ * {@link GuardrailMatch}; the verdict is `block` when any flagged category is
15
+ * listed in `blockOn`, otherwise `flag`. A clean result is `allow`.
16
+ *
17
+ * @param options - `apiKey` (defaults to `OPENAI_API_KEY`), `model`
18
+ * (defaults to `"omni-moderation-latest"`), `blockOn` (categories that
19
+ * escalate to `block`), or a pre-built `client` to bypass the lazy import.
20
+ * @returns A {@link GuardrailDetector} for the guard's `input` / `output` / `tool` arrays.
21
+ *
22
+ * @example
23
+ * const guard = ai.guardrail({
24
+ * output: [
25
+ * ai.guardrail.moderation({ blockOn: ["violence", "sexual/minors"] }),
26
+ * ],
27
+ * });
28
+ */
29
+ declare function moderation(options?: OpenAiModerationOptions): GuardrailDetector;
30
+ //#endregion
31
+ export { moderation };
32
+ //# sourceMappingURL=moderation.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moderation.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/guard/detectors/moderation.ts"],"mappings":";;;;;;;AAoMA;;;;;;;;AAEoB;;;;;;;;;;;;;iBAFJ,UAAA,CACd,OAAA,GAAU,uBAAA,GACT,iBAAiB"}