@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 @@
1
+ {"version":3,"file":"save-skill-tool.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/skills/save-skill-tool.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ToolContract } from \"../tool/tool\";\nimport { tool } from \"../tool/tool\";\nimport type { SkillRecord } from \"./contracts/skill-record.type\";\n\n/** Validated input of the `saveSkill` tool. */\nexport type SaveSkillInput = {\n name: string;\n description: string;\n body: string;\n tags?: string[];\n};\n\n/** Result the `saveSkill` tool feeds back to the model. */\nexport type SaveSkillResult =\n | { saved: true; name: string; status: \"candidate\" }\n | { error: string };\n\n/**\n * Hand-built Standard Schema for the `saveSkill` input — dependency-free,\n * mirroring `loadSkillSchema`. Requires `name` / `description` / `body`;\n * `tags` is an optional string array.\n */\nfunction saveSkillSchema(): StandardSchemaV1<SaveSkillInput> {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"warlock-ai-skills\",\n validate: (value: unknown) => {\n const candidate = value as\n | { name?: unknown; description?: unknown; body?: unknown; tags?: unknown }\n | null;\n\n if (\n !candidate ||\n typeof candidate.name !== \"string\" ||\n typeof candidate.description !== \"string\" ||\n typeof candidate.body !== \"string\"\n ) {\n return {\n issues: [\n {\n message:\n \"saveSkill input must be { name: string; description: string; body: string; tags?: string[] }\",\n },\n ],\n };\n }\n\n if (\n candidate.tags !== undefined &&\n (!Array.isArray(candidate.tags) ||\n !candidate.tags.every((tag) => typeof tag === \"string\"))\n ) {\n return { issues: [{ message: \"saveSkill `tags` must be a string[] when provided\" }] };\n }\n\n return {\n value: {\n name: candidate.name,\n description: candidate.description,\n body: candidate.body,\n ...(candidate.tags !== undefined ? { tags: candidate.tags as string[] } : {}),\n },\n };\n },\n },\n };\n}\n\n/** Dependencies the `saveSkill` tool closes over. */\nexport type SaveSkillToolDeps = {\n /** Write an INERT candidate; the returned record is `type: \"candidate\"`. */\n saveCandidate: (record: Omit<SkillRecord, \"version\" | \"type\">) => Promise<SkillRecord>;\n /** Fired on a successful save (`type: \"saved\"`); errors swallowed by the sink wrapper. */\n onSaved?: (record: SkillRecord) => void;\n};\n\n/**\n * Build the **Phase 2** `saveSkill` tool — exposed ONLY when a `review`\n * gate is configured. It writes an INERT `type: \"candidate\"` record via\n * `saveCandidate`. A candidate is filtered out of the catalog and from\n * preload — it can NEVER be injected until the default-DENY review gate\n * promotes it. So `saveSkill` alone can never turn the model's own output\n * into an injected instruction; promotion is a separate, gated step.\n *\n * `execute` never throws — a store write failure surfaces as an error\n * result so the run continues.\n */\nexport function saveSkillTool(deps: SaveSkillToolDeps): ToolContract<SaveSkillInput, SaveSkillResult> {\n return tool<SaveSkillInput, SaveSkillResult>({\n name: \"saveSkill\",\n description:\n \"Propose a new reusable skill. The skill is saved as an INERT candidate and is NOT used until a reviewer approves it — it will not affect the current run.\",\n input: saveSkillSchema(),\n execute: async (input) => {\n try {\n const record = await deps.saveCandidate({\n name: input.name,\n description: input.description,\n body: input.body,\n ...(input.tags !== undefined ? { tags: input.tags } : {}),\n });\n\n deps.onSaved?.(record);\n\n return { saved: true, name: record.name, status: \"candidate\" };\n } catch (error) {\n return { error: error instanceof Error ? error.message : String(error) };\n }\n },\n });\n}\n"],"mappings":";;;;;;;;AAuBA,SAAS,kBAAoD;CAC3D,OAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,YAAY;GAIlB,IACE,CAAC,aACD,OAAO,UAAU,SAAS,YAC1B,OAAO,UAAU,gBAAgB,YACjC,OAAO,UAAU,SAAS,UAE1B,OAAO,EACL,QAAQ,CACN,EACE,SACE,+FACJ,CACF,EACF;GAGF,IACE,UAAU,SAAS,WAClB,CAAC,MAAM,QAAQ,UAAU,IAAI,KAC5B,CAAC,UAAU,KAAK,OAAO,QAAQ,OAAO,QAAQ,QAAQ,IAExD,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,oDAAoD,CAAC,EAAE;GAGtF,OAAO,EACL,OAAO;IACL,MAAM,UAAU;IAChB,aAAa,UAAU;IACvB,MAAM,UAAU;IAChB,GAAI,UAAU,SAAS,SAAY,EAAE,MAAM,UAAU,KAAiB,IAAI,CAAC;GAC7E,EACF;EACF;CACF,EACF;AACF;;;;;;;;;;;;AAqBA,SAAgB,cAAc,MAAwE;CACpG,OAAO,KAAsC;EAC3C,MAAM;EACN,aACE;EACF,OAAO,gBAAgB;EACvB,SAAS,OAAO,UAAU;GACxB,IAAI;IACF,MAAM,SAAS,MAAM,KAAK,cAAc;KACtC,MAAM,MAAM;KACZ,aAAa,MAAM;KACnB,MAAM,MAAM;KACZ,GAAI,MAAM,SAAS,SAAY,EAAE,MAAM,MAAM,KAAK,IAAI,CAAC;IACzD,CAAC;IAED,KAAK,UAAU,MAAM;IAErB,OAAO;KAAE,OAAO;KAAM,MAAM,OAAO;KAAM,QAAQ;IAAY;GAC/D,SAAS,OAAO;IACd,OAAO,EAAE,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE;GACzE;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,33 @@
1
+ import { SkillsConfig } from "./contracts/skills-config.type.mjs";
2
+ import { SkillsContract } from "./contracts/skills.contract.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/skills/skills.d.ts
5
+ /**
6
+ * Create a runtime skills library — the **mechanism** behind the
7
+ * first-class `skills` agent option.
8
+ *
9
+ * The returned {@link SkillsContract} produces the agent-facing wiring:
10
+ * - `catalog` / `catalogPrompt` — the always-injected cheap metadata block
11
+ * (one line per in-scope, non-candidate skill).
12
+ * - `preload` — the bodies to inject up front per `inject` (`[]` when
13
+ * `inject` is omitted — the default catalog-only progressive disclosure).
14
+ * - `tools(runId)` — the `loadSkill` tool always; plus `saveSkill` ONLY
15
+ * when a `review` gate is configured (otherwise self-authoring is inert).
16
+ *
17
+ * Sources are merged in order; a later source wins on a name collision.
18
+ * `maxLoadsPerRun` (default 5) caps `loadSkill` calls per run; exhaustion
19
+ * is an error RESULT the model self-corrects from, never a throw.
20
+ *
21
+ * @example
22
+ * const lib = skills({
23
+ * name: "build-skills",
24
+ * sources: [{ type: "directory", path: "./agent-skills" }],
25
+ * inject: { select: "semantic", topK: 2, embedder },
26
+ * maxLoadsPerRun: 4,
27
+ * scope: { tags: ["frontend"] },
28
+ * });
29
+ */
30
+ declare function skills(config: SkillsConfig): SkillsContract;
31
+ //#endregion
32
+ export { skills };
33
+ //# sourceMappingURL=skills.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/skills/skills.ts"],"mappings":";;;;;;AAgDA;;;;;;;;AAA4D;;;;;;;;;;;;;;;iBAA5C,MAAA,CAAO,MAAA,EAAQ,YAAA,GAAe,cAAc"}
@@ -0,0 +1,109 @@
1
+ import { buildCatalog, loadRecord, renderCatalogPrompt, semanticPreselect } from "./catalog.mjs";
2
+ import { loadSkillTool } from "./load-skill-tool.mjs";
3
+ import { saveSkillTool } from "./save-skill-tool.mjs";
4
+ import { resolveSource } from "./sources/index.mjs";
5
+
6
+ //#region ../@warlock.js/ai/src/skills/skills.ts
7
+ const DEFAULT_MAX_LOADS_PER_RUN = 5;
8
+ /**
9
+ * Create a runtime skills library — the **mechanism** behind the
10
+ * first-class `skills` agent option.
11
+ *
12
+ * The returned {@link SkillsContract} produces the agent-facing wiring:
13
+ * - `catalog` / `catalogPrompt` — the always-injected cheap metadata block
14
+ * (one line per in-scope, non-candidate skill).
15
+ * - `preload` — the bodies to inject up front per `inject` (`[]` when
16
+ * `inject` is omitted — the default catalog-only progressive disclosure).
17
+ * - `tools(runId)` — the `loadSkill` tool always; plus `saveSkill` ONLY
18
+ * when a `review` gate is configured (otherwise self-authoring is inert).
19
+ *
20
+ * Sources are merged in order; a later source wins on a name collision.
21
+ * `maxLoadsPerRun` (default 5) caps `loadSkill` calls per run; exhaustion
22
+ * is an error RESULT the model self-corrects from, never a throw.
23
+ *
24
+ * @example
25
+ * const lib = skills({
26
+ * name: "build-skills",
27
+ * sources: [{ type: "directory", path: "./agent-skills" }],
28
+ * inject: { select: "semantic", topK: 2, embedder },
29
+ * maxLoadsPerRun: 4,
30
+ * scope: { tags: ["frontend"] },
31
+ * });
32
+ */
33
+ function skills(config) {
34
+ if (!config.sources || config.sources.length === 0) throw new Error(`skills("${config.name}"): at least one source is required (directory / url / store)`);
35
+ const stores = config.sources.map(resolveSource);
36
+ const scope = config.scope;
37
+ const maxLoadsPerRun = config.maxLoadsPerRun ?? DEFAULT_MAX_LOADS_PER_RUN;
38
+ const reviewExposed = config.review !== void 0;
39
+ /** Fire an analytics event, swallowing any sink error (mirrors agent hooks). */
40
+ const emit = (event) => {
41
+ if (!config.analytics) return;
42
+ try {
43
+ Promise.resolve(config.analytics(event)).catch(() => void 0);
44
+ } catch {}
45
+ };
46
+ const catalog = async () => {
47
+ const entries = await buildCatalog(stores, scope);
48
+ for (const entry of entries) emit({
49
+ type: "catalogued",
50
+ skill: entry.name,
51
+ version: entry.version
52
+ });
53
+ return entries;
54
+ };
55
+ return {
56
+ name: config.name,
57
+ catalog,
58
+ async catalogPrompt() {
59
+ const entries = await catalog();
60
+ return renderCatalogPrompt(config.name, entries);
61
+ },
62
+ async preload(input) {
63
+ if (!config.inject) return [];
64
+ if (config.inject === "all") {
65
+ const entries = await buildCatalog(stores, scope);
66
+ const records = [];
67
+ for (const entry of entries) {
68
+ const record = await loadRecord(stores, entry.name, entry.version);
69
+ if (record) records.push(record);
70
+ }
71
+ return records;
72
+ }
73
+ return semanticPreselect(stores, input, config.inject.topK, {
74
+ embedder: config.inject.embedder,
75
+ threshold: config.inject.threshold,
76
+ scope
77
+ });
78
+ },
79
+ tools(runId) {
80
+ const entries = [loadSkillTool({
81
+ load: (name, version) => loadRecord(stores, name, version),
82
+ maxLoadsPerRun,
83
+ onLoaded: (record) => emit({
84
+ type: "loaded",
85
+ skill: record.name,
86
+ version: record.version,
87
+ runId
88
+ })
89
+ })];
90
+ if (reviewExposed && config.review) {
91
+ const reviewStore = config.review.store;
92
+ entries.push(saveSkillTool({
93
+ saveCandidate: (record) => reviewStore.saveCandidate(record),
94
+ onSaved: (record) => emit({
95
+ type: "saved",
96
+ skill: record.name,
97
+ version: record.version,
98
+ runId
99
+ })
100
+ }));
101
+ }
102
+ return entries;
103
+ }
104
+ };
105
+ }
106
+
107
+ //#endregion
108
+ export { skills };
109
+ //# sourceMappingURL=skills.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/skills/skills.ts"],"sourcesContent":["import type { AgentToolEntry } from \"../tool/executable-as-tool\";\nimport {\n buildCatalog,\n loadRecord,\n renderCatalogPrompt,\n semanticPreselect,\n} from \"./catalog\";\nimport type {\n SkillAnalyticsEvent,\n SkillsConfig,\n} from \"./contracts/skills-config.type\";\nimport type {\n SkillCatalogEntry,\n SkillRecord,\n} from \"./contracts/skill-record.type\";\nimport type { SkillsContract } from \"./contracts/skills.contract\";\nimport type { SkillsStoreContract } from \"./contracts/skills-store.contract\";\nimport { loadSkillTool } from \"./load-skill-tool\";\nimport { saveSkillTool } from \"./save-skill-tool\";\nimport { resolveSource } from \"./sources\";\n\nconst DEFAULT_MAX_LOADS_PER_RUN = 5;\n\n/**\n * Create a runtime skills library — the **mechanism** behind the\n * first-class `skills` agent option.\n *\n * The returned {@link SkillsContract} produces the agent-facing wiring:\n * - `catalog` / `catalogPrompt` — the always-injected cheap metadata block\n * (one line per in-scope, non-candidate skill).\n * - `preload` — the bodies to inject up front per `inject` (`[]` when\n * `inject` is omitted — the default catalog-only progressive disclosure).\n * - `tools(runId)` — the `loadSkill` tool always; plus `saveSkill` ONLY\n * when a `review` gate is configured (otherwise self-authoring is inert).\n *\n * Sources are merged in order; a later source wins on a name collision.\n * `maxLoadsPerRun` (default 5) caps `loadSkill` calls per run; exhaustion\n * is an error RESULT the model self-corrects from, never a throw.\n *\n * @example\n * const lib = skills({\n * name: \"build-skills\",\n * sources: [{ type: \"directory\", path: \"./agent-skills\" }],\n * inject: { select: \"semantic\", topK: 2, embedder },\n * maxLoadsPerRun: 4,\n * scope: { tags: [\"frontend\"] },\n * });\n */\nexport function skills(config: SkillsConfig): SkillsContract {\n if (!config.sources || config.sources.length === 0) {\n throw new Error(\n `skills(\"${config.name}\"): at least one source is required (directory / url / store)`,\n );\n }\n\n const stores: SkillsStoreContract[] = config.sources.map(resolveSource);\n const scope = config.scope;\n const maxLoadsPerRun = config.maxLoadsPerRun ?? DEFAULT_MAX_LOADS_PER_RUN;\n const reviewExposed = config.review !== undefined;\n\n /** Fire an analytics event, swallowing any sink error (mirrors agent hooks). */\n const emit = (event: SkillAnalyticsEvent): void => {\n if (!config.analytics) {\n return;\n }\n\n try {\n void Promise.resolve(config.analytics(event)).catch(() => undefined);\n } catch {\n // Sink threw synchronously — swallowed; analytics never crash a run.\n }\n };\n\n const catalog = async (): Promise<SkillCatalogEntry[]> => {\n const entries = await buildCatalog(stores, scope);\n\n for (const entry of entries) {\n emit({ type: \"catalogued\", skill: entry.name, version: entry.version });\n }\n\n return entries;\n };\n\n return {\n name: config.name,\n\n catalog,\n\n async catalogPrompt(): Promise<string> {\n const entries = await catalog();\n\n return renderCatalogPrompt(config.name, entries);\n },\n\n async preload(input: string): Promise<SkillRecord[]> {\n if (!config.inject) {\n return [];\n }\n\n if (config.inject === \"all\") {\n const entries = await buildCatalog(stores, scope);\n const records: SkillRecord[] = [];\n\n for (const entry of entries) {\n const record = await loadRecord(stores, entry.name, entry.version);\n\n if (record) {\n records.push(record);\n }\n }\n\n return records;\n }\n\n // `{ select: \"semantic\", topK }`\n return semanticPreselect(stores, input, config.inject.topK, {\n embedder: config.inject.embedder,\n threshold: config.inject.threshold,\n scope,\n });\n },\n\n tools(runId?: string): AgentToolEntry<any, any>[] {\n const entries: AgentToolEntry<any, any>[] = [\n loadSkillTool({\n load: (name, version) => loadRecord(stores, name, version),\n maxLoadsPerRun,\n onLoaded: (record) =>\n emit({ type: \"loaded\", skill: record.name, version: record.version, runId }),\n }),\n ];\n\n // Phase 2 — `saveSkill` is exposed ONLY when a review gate is wired.\n // Absent gate ⇒ self-authoring is inert: the tool is never registered\n // and a candidate can never be written, let alone injected.\n if (reviewExposed && config.review) {\n const reviewStore = config.review.store;\n\n entries.push(\n saveSkillTool({\n saveCandidate: (record) => reviewStore.saveCandidate(record),\n onSaved: (record) =>\n emit({ type: \"saved\", skill: record.name, version: record.version, runId }),\n }),\n );\n }\n\n return entries;\n },\n };\n}\n"],"mappings":";;;;;;AAqBA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BlC,SAAgB,OAAO,QAAsC;CAC3D,IAAI,CAAC,OAAO,WAAW,OAAO,QAAQ,WAAW,GAC/C,MAAM,IAAI,MACR,WAAW,OAAO,KAAK,8DACzB;CAGF,MAAM,SAAgC,OAAO,QAAQ,IAAI,aAAa;CACtE,MAAM,QAAQ,OAAO;CACrB,MAAM,iBAAiB,OAAO,kBAAkB;CAChD,MAAM,gBAAgB,OAAO,WAAW;;CAGxC,MAAM,QAAQ,UAAqC;EACjD,IAAI,CAAC,OAAO,WACV;EAGF,IAAI;GACF,AAAK,QAAQ,QAAQ,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS;EACrE,QAAQ,CAER;CACF;CAEA,MAAM,UAAU,YAA0C;EACxD,MAAM,UAAU,MAAM,aAAa,QAAQ,KAAK;EAEhD,KAAK,MAAM,SAAS,SAClB,KAAK;GAAE,MAAM;GAAc,OAAO,MAAM;GAAM,SAAS,MAAM;EAAQ,CAAC;EAGxE,OAAO;CACT;CAEA,OAAO;EACL,MAAM,OAAO;EAEb;EAEA,MAAM,gBAAiC;GACrC,MAAM,UAAU,MAAM,QAAQ;GAE9B,OAAO,oBAAoB,OAAO,MAAM,OAAO;EACjD;EAEA,MAAM,QAAQ,OAAuC;GACnD,IAAI,CAAC,OAAO,QACV,OAAO,CAAC;GAGV,IAAI,OAAO,WAAW,OAAO;IAC3B,MAAM,UAAU,MAAM,aAAa,QAAQ,KAAK;IAChD,MAAM,UAAyB,CAAC;IAEhC,KAAK,MAAM,SAAS,SAAS;KAC3B,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM,MAAM,MAAM,OAAO;KAEjE,IAAI,QACF,QAAQ,KAAK,MAAM;IAEvB;IAEA,OAAO;GACT;GAGA,OAAO,kBAAkB,QAAQ,OAAO,OAAO,OAAO,MAAM;IAC1D,UAAU,OAAO,OAAO;IACxB,WAAW,OAAO,OAAO;IACzB;GACF,CAAC;EACH;EAEA,MAAM,OAA4C;GAChD,MAAM,UAAsC,CAC1C,cAAc;IACZ,OAAO,MAAM,YAAY,WAAW,QAAQ,MAAM,OAAO;IACzD;IACA,WAAW,WACT,KAAK;KAAE,MAAM;KAAU,OAAO,OAAO;KAAM,SAAS,OAAO;KAAS;IAAM,CAAC;GAC/E,CAAC,CACH;GAKA,IAAI,iBAAiB,OAAO,QAAQ;IAClC,MAAM,cAAc,OAAO,OAAO;IAElC,QAAQ,KACN,cAAc;KACZ,gBAAgB,WAAW,YAAY,cAAc,MAAM;KAC3D,UAAU,WACR,KAAK;MAAE,MAAM;MAAS,OAAO,OAAO;MAAM,SAAS,OAAO;MAAS;KAAM,CAAC;IAC9E,CAAC,CACH;GACF;GAEA,OAAO;EACT;CACF;AACF"}
@@ -0,0 +1,19 @@
1
+ import { SkillsStoreContract } from "../contracts/skills-store.contract.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/skills/sources/directory-source.d.ts
4
+ /**
5
+ * Read `path/<folder>/SKILL.md` into {@link SkillRecord}s, parsing the
6
+ * same `key: value` front-matter as `scripts/generate-llms.mjs`. Each
7
+ * direct sub-directory holding a `SKILL.md` becomes one skill named after
8
+ * the folder; the `description` comes from front-matter, `tags` from a
9
+ * comma-separated `tags:` line, and the body is everything after the
10
+ * closing `---`. Files at the root (e.g. `README.md`) are ignored.
11
+ *
12
+ * Reads are a snapshot at first call and cached for the source's lifetime
13
+ * (a single agent run reads the catalog and bodies from one consistent
14
+ * view). A missing directory yields an empty library, not a throw.
15
+ */
16
+ declare function directorySource(dirPath: string): SkillsStoreContract;
17
+ //#endregion
18
+ export { directorySource };
19
+ //# sourceMappingURL=directory-source.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-source.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/directory-source.ts"],"mappings":";;;;;AA2CA;;;;AAAqE;;;;;;iBAArD,eAAA,CAAgB,OAAA,WAAkB,mBAAmB"}
@@ -0,0 +1,108 @@
1
+ import { parseFrontmatter, parseTags } from "./parse-frontmatter.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/skills/sources/directory-source.ts
4
+ /**
5
+ * Lazily-loaded `node:fs/promises`. Core takes no new filesystem
6
+ * dependency — a `store`-only or `url`-only consumer never touches the
7
+ * filesystem because the module is imported on first read, not at module
8
+ * load. Settled once and cached.
9
+ */
10
+ let fsMod;
11
+ let pathMod;
12
+ async function loadFs() {
13
+ if (!fsMod) fsMod = await import("node:fs/promises");
14
+ if (!pathMod) pathMod = await import("node:path");
15
+ return {
16
+ fs: fsMod,
17
+ path: pathMod
18
+ };
19
+ }
20
+ /**
21
+ * Read `path/<folder>/SKILL.md` into {@link SkillRecord}s, parsing the
22
+ * same `key: value` front-matter as `scripts/generate-llms.mjs`. Each
23
+ * direct sub-directory holding a `SKILL.md` becomes one skill named after
24
+ * the folder; the `description` comes from front-matter, `tags` from a
25
+ * comma-separated `tags:` line, and the body is everything after the
26
+ * closing `---`. Files at the root (e.g. `README.md`) are ignored.
27
+ *
28
+ * Reads are a snapshot at first call and cached for the source's lifetime
29
+ * (a single agent run reads the catalog and bodies from one consistent
30
+ * view). A missing directory yields an empty library, not a throw.
31
+ */
32
+ function directorySource(dirPath) {
33
+ let cache;
34
+ const records = () => {
35
+ if (!cache) cache = readDirectory(dirPath);
36
+ return cache;
37
+ };
38
+ return {
39
+ async list(scope) {
40
+ const all = await records();
41
+ const wanted = scope?.tags;
42
+ return [...all.values()].filter((record) => intersects(record.tags, wanted)).map(toCatalogEntry);
43
+ },
44
+ async load(name, version) {
45
+ const record = (await records()).get(name);
46
+ if (!record) return;
47
+ if (version !== void 0 && record.version !== version) return;
48
+ return record;
49
+ },
50
+ async saveCandidate() {
51
+ throw new Error("directory source is read-only — saveCandidate requires a writable store (set `review.store`)");
52
+ },
53
+ async promote() {
54
+ throw new Error("directory source is read-only — promote requires a writable store (set `review.store`)");
55
+ }
56
+ };
57
+ }
58
+ /** Walk the directory once, parsing every `<folder>/SKILL.md` into a record. */
59
+ async function readDirectory(dirPath) {
60
+ const { fs, path } = await loadFs();
61
+ const records = /* @__PURE__ */ new Map();
62
+ let entries;
63
+ try {
64
+ entries = await fs.readdir(dirPath, { withFileTypes: true });
65
+ } catch {
66
+ return records;
67
+ }
68
+ for (const entry of entries) {
69
+ if (!entry.isDirectory()) continue;
70
+ const skillFile = path.join(dirPath, entry.name, "SKILL.md");
71
+ let text;
72
+ try {
73
+ text = await fs.readFile(skillFile, "utf8");
74
+ } catch {
75
+ continue;
76
+ }
77
+ const { meta, body } = parseFrontmatter(text);
78
+ records.set(entry.name, {
79
+ name: entry.name,
80
+ description: meta.description ?? "(no description)",
81
+ version: 1,
82
+ body: body.trim(),
83
+ tags: parseTags(meta.tags),
84
+ type: "authored"
85
+ });
86
+ }
87
+ return records;
88
+ }
89
+ /** Project a full record down to its catalog entry (body omitted). */
90
+ function toCatalogEntry(record) {
91
+ return {
92
+ name: record.name,
93
+ description: record.description,
94
+ version: record.version,
95
+ tags: record.tags,
96
+ type: record.type
97
+ };
98
+ }
99
+ /** True when no filter is requested or the record shares a requested tag. */
100
+ function intersects(recordTags, wanted) {
101
+ if (!wanted || wanted.length === 0) return true;
102
+ if (!recordTags || recordTags.length === 0) return false;
103
+ return recordTags.some((tag) => wanted.includes(tag));
104
+ }
105
+
106
+ //#endregion
107
+ export { directorySource };
108
+ //# sourceMappingURL=directory-source.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-source.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/directory-source.ts"],"sourcesContent":["import type {\n SkillCatalogEntry,\n SkillRecord,\n} from \"../contracts/skill-record.type\";\nimport type { SkillsStoreContract } from \"../contracts/skills-store.contract\";\nimport { parseFrontmatter, parseTags } from \"./parse-frontmatter\";\n\n/**\n * Lazily-loaded `node:fs/promises`. Core takes no new filesystem\n * dependency — a `store`-only or `url`-only consumer never touches the\n * filesystem because the module is imported on first read, not at module\n * load. Settled once and cached.\n */\nlet fsMod: typeof import(\"node:fs/promises\") | undefined;\nlet pathMod: typeof import(\"node:path\") | undefined;\n\nasync function loadFs(): Promise<{\n fs: typeof import(\"node:fs/promises\");\n path: typeof import(\"node:path\");\n}> {\n if (!fsMod) {\n fsMod = await import(\"node:fs/promises\");\n }\n\n if (!pathMod) {\n pathMod = await import(\"node:path\");\n }\n\n return { fs: fsMod, path: pathMod };\n}\n\n/**\n * Read `path/<folder>/SKILL.md` into {@link SkillRecord}s, parsing the\n * same `key: value` front-matter as `scripts/generate-llms.mjs`. Each\n * direct sub-directory holding a `SKILL.md` becomes one skill named after\n * the folder; the `description` comes from front-matter, `tags` from a\n * comma-separated `tags:` line, and the body is everything after the\n * closing `---`. Files at the root (e.g. `README.md`) are ignored.\n *\n * Reads are a snapshot at first call and cached for the source's lifetime\n * (a single agent run reads the catalog and bodies from one consistent\n * view). A missing directory yields an empty library, not a throw.\n */\nexport function directorySource(dirPath: string): SkillsStoreContract {\n let cache: Promise<Map<string, SkillRecord>> | undefined;\n\n const records = (): Promise<Map<string, SkillRecord>> => {\n if (!cache) {\n cache = readDirectory(dirPath);\n }\n\n return cache;\n };\n\n return {\n async list(scope?: { tags?: string[] }): Promise<SkillCatalogEntry[]> {\n const all = await records();\n const wanted = scope?.tags;\n\n return [...all.values()]\n .filter((record) => intersects(record.tags, wanted))\n .map(toCatalogEntry);\n },\n async load(name: string, version?: number): Promise<SkillRecord | undefined> {\n const all = await records();\n const record = all.get(name);\n\n if (!record) {\n return undefined;\n }\n\n if (version !== undefined && record.version !== version) {\n return undefined;\n }\n\n return record;\n },\n async saveCandidate(): Promise<SkillRecord> {\n throw new Error(\n \"directory source is read-only — saveCandidate requires a writable store (set `review.store`)\",\n );\n },\n async promote(): Promise<SkillRecord> {\n throw new Error(\n \"directory source is read-only — promote requires a writable store (set `review.store`)\",\n );\n },\n };\n}\n\n/** Walk the directory once, parsing every `<folder>/SKILL.md` into a record. */\nasync function readDirectory(dirPath: string): Promise<Map<string, SkillRecord>> {\n const { fs, path } = await loadFs();\n const records = new Map<string, SkillRecord>();\n\n let entries: Array<{ name: string; isDirectory(): boolean }>;\n\n try {\n entries = await fs.readdir(dirPath, { withFileTypes: true });\n } catch {\n // Missing directory ⇒ empty library; the catalog simply omits it.\n return records;\n }\n\n for (const entry of entries) {\n if (!entry.isDirectory()) {\n continue;\n }\n\n const skillFile = path.join(dirPath, entry.name, \"SKILL.md\");\n\n let text: string;\n\n try {\n text = await fs.readFile(skillFile, \"utf8\");\n } catch {\n // A sub-directory without a SKILL.md is not a skill — skip it.\n continue;\n }\n\n const { meta, body } = parseFrontmatter(text);\n\n records.set(entry.name, {\n name: entry.name,\n description: meta.description ?? \"(no description)\",\n version: 1,\n body: body.trim(),\n tags: parseTags(meta.tags),\n type: \"authored\",\n });\n }\n\n return records;\n}\n\n/** Project a full record down to its catalog entry (body omitted). */\nfunction toCatalogEntry(record: SkillRecord): SkillCatalogEntry {\n return {\n name: record.name,\n description: record.description,\n version: record.version,\n tags: record.tags,\n type: record.type,\n };\n}\n\n/** True when no filter is requested or the record shares a requested tag. */\nfunction intersects(recordTags: string[] | undefined, wanted: string[] | undefined): boolean {\n if (!wanted || wanted.length === 0) {\n return true;\n }\n\n if (!recordTags || recordTags.length === 0) {\n return false;\n }\n\n return recordTags.some((tag) => wanted.includes(tag));\n}\n"],"mappings":";;;;;;;;;AAaA,IAAI;AACJ,IAAI;AAEJ,eAAe,SAGZ;CACD,IAAI,CAAC,OACH,QAAQ,MAAM,OAAO;CAGvB,IAAI,CAAC,SACH,UAAU,MAAM,OAAO;CAGzB,OAAO;EAAE,IAAI;EAAO,MAAM;CAAQ;AACpC;;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,SAAsC;CACpE,IAAI;CAEJ,MAAM,gBAAmD;EACvD,IAAI,CAAC,OACH,QAAQ,cAAc,OAAO;EAG/B,OAAO;CACT;CAEA,OAAO;EACL,MAAM,KAAK,OAA2D;GACpE,MAAM,MAAM,MAAM,QAAQ;GAC1B,MAAM,SAAS,OAAO;GAEtB,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CACrB,QAAQ,WAAW,WAAW,OAAO,MAAM,MAAM,CAAC,CAAC,CACnD,IAAI,cAAc;EACvB;EACA,MAAM,KAAK,MAAc,SAAoD;GAE3E,MAAM,UAAS,MADG,QAAQ,EACR,CAAC,IAAI,IAAI;GAE3B,IAAI,CAAC,QACH;GAGF,IAAI,YAAY,UAAa,OAAO,YAAY,SAC9C;GAGF,OAAO;EACT;EACA,MAAM,gBAAsC;GAC1C,MAAM,IAAI,MACR,8FACF;EACF;EACA,MAAM,UAAgC;GACpC,MAAM,IAAI,MACR,wFACF;EACF;CACF;AACF;;AAGA,eAAe,cAAc,SAAoD;CAC/E,MAAM,EAAE,IAAI,SAAS,MAAM,OAAO;CAClC,MAAM,0BAAU,IAAI,IAAyB;CAE7C,IAAI;CAEJ,IAAI;EACF,UAAU,MAAM,GAAG,QAAQ,SAAS,EAAE,eAAe,KAAK,CAAC;CAC7D,QAAQ;EAEN,OAAO;CACT;CAEA,KAAK,MAAM,SAAS,SAAS;EAC3B,IAAI,CAAC,MAAM,YAAY,GACrB;EAGF,MAAM,YAAY,KAAK,KAAK,SAAS,MAAM,MAAM,UAAU;EAE3D,IAAI;EAEJ,IAAI;GACF,OAAO,MAAM,GAAG,SAAS,WAAW,MAAM;EAC5C,QAAQ;GAEN;EACF;EAEA,MAAM,EAAE,MAAM,SAAS,iBAAiB,IAAI;EAE5C,QAAQ,IAAI,MAAM,MAAM;GACtB,MAAM,MAAM;GACZ,aAAa,KAAK,eAAe;GACjC,SAAS;GACT,MAAM,KAAK,KAAK;GAChB,MAAM,UAAU,KAAK,IAAI;GACzB,MAAM;EACR,CAAC;CACH;CAEA,OAAO;AACT;;AAGA,SAAS,eAAe,QAAwC;CAC9D,OAAO;EACL,MAAM,OAAO;EACb,aAAa,OAAO;EACpB,SAAS,OAAO;EAChB,MAAM,OAAO;EACb,MAAM,OAAO;CACf;AACF;;AAGA,SAAS,WAAW,YAAkC,QAAuC;CAC3F,IAAI,CAAC,UAAU,OAAO,WAAW,GAC/B,OAAO;CAGT,IAAI,CAAC,cAAc,WAAW,WAAW,GACvC,OAAO;CAGT,OAAO,WAAW,MAAM,QAAQ,OAAO,SAAS,GAAG,CAAC;AACtD"}
@@ -0,0 +1,18 @@
1
+ import { SkillsStoreContract } from "../contracts/skills-store.contract.mjs";
2
+ import { SkillSource } from "../contracts/skills-config.type.mjs";
3
+ import { directorySource } from "./directory-source.mjs";
4
+ import { urlSource } from "./url-source.mjs";
5
+ import { storeSource } from "./store-source.mjs";
6
+ import { ParsedFrontmatter, parseFrontmatter, parseTags } from "./parse-frontmatter.mjs";
7
+
8
+ //#region ../@warlock.js/ai/src/skills/sources/index.d.ts
9
+ /**
10
+ * Resolve a declarative {@link SkillSource} into a concrete
11
+ * {@link SkillsStoreContract} reader. Discriminated by `type` (never
12
+ * `kind`): `directory` reads the filesystem, `url` fetches a manifest,
13
+ * `store` passes a store through verbatim.
14
+ */
15
+ declare function resolveSource(source: SkillSource): SkillsStoreContract;
16
+ //#endregion
17
+ export { resolveSource };
18
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/index.ts"],"mappings":";;;;;;;;;AAkBA;;;;;iBAAgB,aAAA,CAAc,MAAA,EAAQ,WAAA,GAAc,mBAAmB"}
@@ -0,0 +1,27 @@
1
+ import { parseFrontmatter, parseTags } from "./parse-frontmatter.mjs";
2
+ import { directorySource } from "./directory-source.mjs";
3
+ import { storeSource } from "./store-source.mjs";
4
+ import { urlSource } from "./url-source.mjs";
5
+
6
+ //#region ../@warlock.js/ai/src/skills/sources/index.ts
7
+ /**
8
+ * Resolve a declarative {@link SkillSource} into a concrete
9
+ * {@link SkillsStoreContract} reader. Discriminated by `type` (never
10
+ * `kind`): `directory` reads the filesystem, `url` fetches a manifest,
11
+ * `store` passes a store through verbatim.
12
+ */
13
+ function resolveSource(source) {
14
+ switch (source.type) {
15
+ case "directory": return directorySource(source.path);
16
+ case "url": return urlSource(source.url, {
17
+ headers: source.headers,
18
+ policy: source.policy,
19
+ cacheTtlMs: source.cacheTtlMs
20
+ });
21
+ case "store": return storeSource(source.store);
22
+ }
23
+ }
24
+
25
+ //#endregion
26
+ export { resolveSource };
27
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/index.ts"],"sourcesContent":["import type { SkillSource } from \"../contracts/skills-config.type\";\nimport type { SkillsStoreContract } from \"../contracts/skills-store.contract\";\nimport { directorySource } from \"./directory-source\";\nimport { storeSource } from \"./store-source\";\nimport { urlSource } from \"./url-source\";\n\nexport { directorySource } from \"./directory-source\";\nexport { urlSource } from \"./url-source\";\nexport { storeSource } from \"./store-source\";\nexport { parseFrontmatter, parseTags } from \"./parse-frontmatter\";\nexport type { ParsedFrontmatter } from \"./parse-frontmatter\";\n\n/**\n * Resolve a declarative {@link SkillSource} into a concrete\n * {@link SkillsStoreContract} reader. Discriminated by `type` (never\n * `kind`): `directory` reads the filesystem, `url` fetches a manifest,\n * `store` passes a store through verbatim.\n */\nexport function resolveSource(source: SkillSource): SkillsStoreContract {\n switch (source.type) {\n case \"directory\":\n return directorySource(source.path);\n case \"url\":\n return urlSource(source.url, {\n headers: source.headers,\n policy: source.policy,\n cacheTtlMs: source.cacheTtlMs,\n });\n case \"store\":\n return storeSource(source.store);\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,cAAc,QAA0C;CACtE,QAAQ,OAAO,MAAf;EACE,KAAK,aACH,OAAO,gBAAgB,OAAO,IAAI;EACpC,KAAK,OACH,OAAO,UAAU,OAAO,KAAK;GAC3B,SAAS,OAAO;GAChB,QAAQ,OAAO;GACf,YAAY,OAAO;EACrB,CAAC;EACH,KAAK,SACH,OAAO,YAAY,OAAO,KAAK;CACnC;AACF"}
@@ -0,0 +1,27 @@
1
+ //#region ../@warlock.js/ai/src/skills/sources/parse-frontmatter.d.ts
2
+ /** The parsed front-matter (cheap metadata) plus the stripped body. */
3
+ type ParsedFrontmatter = {
4
+ /** Every `key: value` line from the front-matter block, values quote-stripped. */meta: Record<string, string>; /** Everything after the closing `---`, verbatim (the skill body). */
5
+ body: string;
6
+ };
7
+ /**
8
+ * Parse simple `key: value` YAML front-matter — the only form `SKILL.md`
9
+ * uses (no nested objects, no block arrays). Ported verbatim from the
10
+ * package's `scripts/generate-llms.mjs` `parseFrontmatter()` so the
11
+ * runtime catalog and the docs `llms.txt` index agree byte-for-byte on
12
+ * what a skill's `description` is.
13
+ *
14
+ * When the text has no `---`-delimited front-matter block, returns an
15
+ * empty `meta` and the full text as `body`.
16
+ */
17
+ declare function parseFrontmatter(text: string): ParsedFrontmatter;
18
+ /**
19
+ * Split a front-matter `tags:` value into a string array. Accepts a
20
+ * comma-separated inline list (`tags: frontend, react`) — the simple
21
+ * inline form that fits the `key: value` parser. Returns `undefined` when
22
+ * the value is absent or blank so a tagless skill stays `tags: undefined`.
23
+ */
24
+ declare function parseTags(value: string | undefined): string[] | undefined;
25
+ //#endregion
26
+ export { ParsedFrontmatter, parseFrontmatter, parseTags };
27
+ //# sourceMappingURL=parse-frontmatter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-frontmatter.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/parse-frontmatter.ts"],"mappings":";;KACY,iBAAA;EAAiB,kFAE3B,IAAA,EAAM,MAAM,kBAAA;EAEZ,IAAA;AAAA;;;AAAI;AAaN;;;;AAAiE;AAsCjE;;iBAtCgB,gBAAA,CAAiB,IAAA,WAAe,iBAAiB;;AAsCd;;;;;iBAAnC,SAAA,CAAU,KAAyB"}
@@ -0,0 +1,46 @@
1
+ //#region ../@warlock.js/ai/src/skills/sources/parse-frontmatter.ts
2
+ /**
3
+ * Parse simple `key: value` YAML front-matter — the only form `SKILL.md`
4
+ * uses (no nested objects, no block arrays). Ported verbatim from the
5
+ * package's `scripts/generate-llms.mjs` `parseFrontmatter()` so the
6
+ * runtime catalog and the docs `llms.txt` index agree byte-for-byte on
7
+ * what a skill's `description` is.
8
+ *
9
+ * When the text has no `---`-delimited front-matter block, returns an
10
+ * empty `meta` and the full text as `body`.
11
+ */
12
+ function parseFrontmatter(text) {
13
+ const match = text.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
14
+ if (!match) return {
15
+ meta: {},
16
+ body: text
17
+ };
18
+ const meta = {};
19
+ for (const line of match[1].split("\n")) {
20
+ const colon = line.indexOf(":");
21
+ if (colon === -1) continue;
22
+ const key = line.slice(0, colon).trim();
23
+ let value = line.slice(colon + 1).trim();
24
+ if (value.startsWith("'") && value.endsWith("'") || value.startsWith("\"") && value.endsWith("\"")) value = value.slice(1, -1).replace(/''/g, "'").replace(/\\"/g, "\"");
25
+ meta[key] = value;
26
+ }
27
+ return {
28
+ meta,
29
+ body: match[2]
30
+ };
31
+ }
32
+ /**
33
+ * Split a front-matter `tags:` value into a string array. Accepts a
34
+ * comma-separated inline list (`tags: frontend, react`) — the simple
35
+ * inline form that fits the `key: value` parser. Returns `undefined` when
36
+ * the value is absent or blank so a tagless skill stays `tags: undefined`.
37
+ */
38
+ function parseTags(value) {
39
+ if (!value) return;
40
+ const tags = value.split(",").map((tag) => tag.trim()).filter((tag) => tag.length > 0);
41
+ return tags.length > 0 ? tags : void 0;
42
+ }
43
+
44
+ //#endregion
45
+ export { parseFrontmatter, parseTags };
46
+ //# sourceMappingURL=parse-frontmatter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-frontmatter.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/parse-frontmatter.ts"],"sourcesContent":["/** The parsed front-matter (cheap metadata) plus the stripped body. */\nexport type ParsedFrontmatter = {\n /** Every `key: value` line from the front-matter block, values quote-stripped. */\n meta: Record<string, string>;\n /** Everything after the closing `---`, verbatim (the skill body). */\n body: string;\n};\n\n/**\n * Parse simple `key: value` YAML front-matter — the only form `SKILL.md`\n * uses (no nested objects, no block arrays). Ported verbatim from the\n * package's `scripts/generate-llms.mjs` `parseFrontmatter()` so the\n * runtime catalog and the docs `llms.txt` index agree byte-for-byte on\n * what a skill's `description` is.\n *\n * When the text has no `---`-delimited front-matter block, returns an\n * empty `meta` and the full text as `body`.\n */\nexport function parseFrontmatter(text: string): ParsedFrontmatter {\n const match = text.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n\n if (!match) {\n return { meta: {}, body: text };\n }\n\n const meta: Record<string, string> = {};\n\n for (const line of match[1].split(\"\\n\")) {\n const colon = line.indexOf(\":\");\n\n if (colon === -1) {\n continue;\n }\n\n const key = line.slice(0, colon).trim();\n let value = line.slice(colon + 1).trim();\n\n if (\n (value.startsWith(\"'\") && value.endsWith(\"'\")) ||\n (value.startsWith('\"') && value.endsWith('\"'))\n ) {\n value = value.slice(1, -1).replace(/''/g, \"'\").replace(/\\\\\"/g, '\"');\n }\n\n meta[key] = value;\n }\n\n return { meta, body: match[2] };\n}\n\n/**\n * Split a front-matter `tags:` value into a string array. Accepts a\n * comma-separated inline list (`tags: frontend, react`) — the simple\n * inline form that fits the `key: value` parser. Returns `undefined` when\n * the value is absent or blank so a tagless skill stays `tags: undefined`.\n */\nexport function parseTags(value: string | undefined): string[] | undefined {\n if (!value) {\n return undefined;\n }\n\n const tags = value\n .split(\",\")\n .map((tag) => tag.trim())\n .filter((tag) => tag.length > 0);\n\n return tags.length > 0 ? tags : undefined;\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,iBAAiB,MAAiC;CAChE,MAAM,QAAQ,KAAK,MAAM,mCAAmC;CAE5D,IAAI,CAAC,OACH,OAAO;EAAE,MAAM,CAAC;EAAG,MAAM;CAAK;CAGhC,MAAM,OAA+B,CAAC;CAEtC,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,IAAI,GAAG;EACvC,MAAM,QAAQ,KAAK,QAAQ,GAAG;EAE9B,IAAI,UAAU,IACZ;EAGF,MAAM,MAAM,KAAK,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK;EACtC,IAAI,QAAQ,KAAK,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK;EAEvC,IACG,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,KAC3C,MAAM,WAAW,IAAG,KAAK,MAAM,SAAS,IAAG,GAE5C,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,QAAQ,IAAG;EAGpE,KAAK,OAAO;CACd;CAEA,OAAO;EAAE;EAAM,MAAM,MAAM;CAAG;AAChC;;;;;;;AAQA,SAAgB,UAAU,OAAiD;CACzE,IAAI,CAAC,OACH;CAGF,MAAM,OAAO,MACV,MAAM,GAAG,CAAC,CACV,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,CACxB,QAAQ,QAAQ,IAAI,SAAS,CAAC;CAEjC,OAAO,KAAK,SAAS,IAAI,OAAO;AAClC"}
@@ -0,0 +1,14 @@
1
+ import { SkillsStoreContract } from "../contracts/skills-store.contract.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/skills/sources/store-source.d.ts
4
+ /**
5
+ * Adapt a `{ type: "store", store }` source — a pass-through to any
6
+ * {@link SkillsStoreContract} (e.g. `MockSkillsStore`, or the Phase-2
7
+ * `ProceduralSkillStore`). The store already implements every reader
8
+ * method, so this is identity; it exists for symmetry with the directory
9
+ * and url sources and to keep `resolveSource` a single dispatch table.
10
+ */
11
+ declare function storeSource(store: SkillsStoreContract): SkillsStoreContract;
12
+ //#endregion
13
+ export { storeSource };
14
+ //# sourceMappingURL=store-source.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-source.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/store-source.ts"],"mappings":";;;;;AASA;;;;;iBAAgB,WAAA,CAAY,KAAA,EAAO,mBAAA,GAAsB,mBAAmB"}
@@ -0,0 +1,15 @@
1
+ //#region ../@warlock.js/ai/src/skills/sources/store-source.ts
2
+ /**
3
+ * Adapt a `{ type: "store", store }` source — a pass-through to any
4
+ * {@link SkillsStoreContract} (e.g. `MockSkillsStore`, or the Phase-2
5
+ * `ProceduralSkillStore`). The store already implements every reader
6
+ * method, so this is identity; it exists for symmetry with the directory
7
+ * and url sources and to keep `resolveSource` a single dispatch table.
8
+ */
9
+ function storeSource(store) {
10
+ return store;
11
+ }
12
+
13
+ //#endregion
14
+ export { storeSource };
15
+ //# sourceMappingURL=store-source.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-source.mjs","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/store-source.ts"],"sourcesContent":["import type { SkillsStoreContract } from \"../contracts/skills-store.contract\";\n\n/**\n * Adapt a `{ type: \"store\", store }` source — a pass-through to any\n * {@link SkillsStoreContract} (e.g. `MockSkillsStore`, or the Phase-2\n * `ProceduralSkillStore`). The store already implements every reader\n * method, so this is identity; it exists for symmetry with the directory\n * and url sources and to keep `resolveSource` a single dispatch table.\n */\nexport function storeSource(store: SkillsStoreContract): SkillsStoreContract {\n return store;\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,YAAY,OAAiD;CAC3E,OAAO;AACT"}
@@ -0,0 +1,29 @@
1
+ import { OutboundPolicy } from "../../security/outbound-policy.type.mjs";
2
+ import { SkillsStoreContract } from "../contracts/skills-store.contract.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/skills/sources/url-source.d.ts
5
+ /** Options for {@link urlSource} (S3). */
6
+ type UrlSourceOptions = {
7
+ headers?: Record<string, string>; /** Fetch hardening for the manifest request. */
8
+ policy?: OutboundPolicy; /** Cache the manifest for this many ms; omit to cache for the source's lifetime. */
9
+ cacheTtlMs?: number;
10
+ };
11
+ /**
12
+ * Read skills from a remote JSON manifest at `url`. The manifest is a flat
13
+ * array of {@link SkillRecord}s (bodies inline).
14
+ *
15
+ * **Trust boundary (S3).** A remote skill source is a prompt supply chain —
16
+ * its bodies flow straight into model context — so the manifest fetch runs
17
+ * through the shared `OutboundPolicy` (scheme + host allowlist, post-DNS
18
+ * private-IP deny, max bytes, timeout) and **every record is runtime-
19
+ * validated** before it can be served. A malformed record fails loudly
20
+ * rather than being cast blindly into a `SkillRecord`.
21
+ *
22
+ * The request is made lazily on the first `list()` / `load()`. The result
23
+ * is cached for the source's lifetime, or for `cacheTtlMs` when set
24
+ * (a stale cache refetches on next access).
25
+ */
26
+ declare function urlSource(url: string, options?: UrlSourceOptions): SkillsStoreContract;
27
+ //#endregion
28
+ export { urlSource };
29
+ //# sourceMappingURL=url-source.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-source.d.mts","names":[],"sources":["../../../../../../../../@warlock.js/ai/src/skills/sources/url-source.ts"],"mappings":";;;;;KAgBY,gBAAA;EACV,OAAA,GAAU,MAAA,kBADgB;EAG1B,MAAA,GAAS,cAAc,EAAA;EAEvB,UAAA;AAAA;;;;;AAAU;AAkBZ;;;;;;;;;AAGsB;iBAHN,SAAA,CACd,GAAA,UACA,OAAA,GAAS,gBAAA,GACR,mBAAmB"}