@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
@@ -1,5 +1,8 @@
1
1
  import { approximateTokenCount } from "../utils/token-count.mjs";
2
+ import { MockImageModel } from "./mock-image-model.mjs";
2
3
  import { MockModel } from "./mock-model.mjs";
4
+ import { MockSpeechModel } from "./mock-speech-model.mjs";
5
+ import { MockTranscriptionModel } from "./mock-transcription-model.mjs";
3
6
 
4
7
  //#region ../@warlock.js/ai/src/mock/mock-sdk.ts
5
8
  /**
@@ -18,14 +21,38 @@ import { MockModel } from "./mock-model.mjs";
18
21
  */
19
22
  function MockSDK(config = {}) {
20
23
  const models = [];
24
+ const imageModels = [];
25
+ const speechModels = [];
26
+ const transcriptionModels = [];
21
27
  const responses = config.responses ?? [{ content: "Mock response" }];
28
+ const imageResponses = config.imageResponses ?? [{}];
29
+ const speechResponses = config.speechResponses ?? [{}];
30
+ const transcriptionResponses = config.transcriptionResponses ?? [{}];
22
31
  return {
23
32
  models,
33
+ imageModels,
34
+ speechModels,
35
+ transcriptionModels,
24
36
  model(modelConfig) {
25
37
  const model = new MockModel(modelConfig.name ?? config.defaultModelName ?? "mock-model", responses, config.capabilities);
26
38
  models.push(model);
27
39
  return model;
28
40
  },
41
+ image(imageConfig) {
42
+ const model = new MockImageModel(imageConfig.name ?? config.defaultModelName ?? "mock-image-model", imageResponses, imageConfig.pricing ?? config.imagePricing);
43
+ imageModels.push(model);
44
+ return model;
45
+ },
46
+ speech(speechConfig) {
47
+ const model = new MockSpeechModel(speechConfig.name ?? config.defaultModelName ?? "mock-speech-model", speechResponses, speechConfig.pricing ?? config.speechPricing);
48
+ speechModels.push(model);
49
+ return model;
50
+ },
51
+ transcribe(transcribeConfig) {
52
+ const model = new MockTranscriptionModel(transcribeConfig.name ?? config.defaultModelName ?? "mock-transcription-model", transcriptionResponses, transcribeConfig.pricing ?? config.transcriptionPricing);
53
+ transcriptionModels.push(model);
54
+ return model;
55
+ },
29
56
  async count(text, _model) {
30
57
  return approximateTokenCount(text);
31
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mock-sdk.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/mock/mock-sdk.ts"],"sourcesContent":["import type {\n ModelConfig,\n SDKAdapterContract,\n} from \"../contracts/sdk-adapter.contract\";\nimport { approximateTokenCount } from \"../utils/token-count\";\nimport type { MockSDKConfig } from \"./mock-config.type\";\nimport { MockModel } from \"./mock-model\";\n\n/**\n * Creates a mock SDK adapter for testing — no HTTP calls, fully configurable.\n *\n * @example\n * const mock = MockSDK({\n * responses: [\n * { content: \"Hello from mock!\" },\n * { content: \"Second response\" },\n * ],\n * });\n * const model = mock.model({ name: \"gpt-4o\" });\n * const result = await model.complete([{ role: \"user\", content: \"Hi\" }]);\n * console.log(result.content); // \"Hello from mock!\"\n */\nexport function MockSDK(config: MockSDKConfig = {}): SDKAdapterContract & {\n /** All model instances created by this SDK — for inspecting calls in tests */\n models: MockModel[];\n} {\n const models: MockModel[] = [];\n const responses = config.responses ?? [{ content: \"Mock response\" }];\n\n return {\n models,\n model(modelConfig: ModelConfig) {\n const model = new MockModel(\n modelConfig.name ?? config.defaultModelName ?? \"mock-model\",\n responses,\n config.capabilities,\n );\n models.push(model);\n return model;\n },\n async count(text: string, _model?: string): Promise<number> {\n return approximateTokenCount(text);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,SAAgB,QAAQ,SAAwB,CAAC,GAG/C;CACA,MAAM,SAAsB,CAAC;CAC7B,MAAM,YAAY,OAAO,aAAa,CAAC,EAAE,SAAS,gBAAgB,CAAC;CAEnE,OAAO;EACL;EACA,MAAM,aAA0B;GAC9B,MAAM,QAAQ,IAAI,UAChB,YAAY,QAAQ,OAAO,oBAAoB,cAC/C,WACA,OAAO,YACT;GACA,OAAO,KAAK,KAAK;GACjB,OAAO;EACT;EACA,MAAM,MAAM,MAAc,QAAkC;GAC1D,OAAO,sBAAsB,IAAI;EACnC;CACF;AACF"}
1
+ {"version":3,"file":"mock-sdk.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/mock/mock-sdk.ts"],"sourcesContent":["import type { ImageModelConfig } from \"../contracts/image-model.contract\";\nimport type {\n ModelConfig,\n SDKAdapterContract,\n} from \"../contracts/sdk-adapter.contract\";\nimport type { SpeechModelConfig } from \"../contracts/speech-model.contract\";\nimport type { TranscriptionModelConfig } from \"../contracts/transcription-model.contract\";\nimport { approximateTokenCount } from \"../utils/token-count\";\nimport type { MockSDKConfig } from \"./mock-config.type\";\nimport { MockImageModel } from \"./mock-image-model\";\nimport { MockModel } from \"./mock-model\";\nimport { MockSpeechModel } from \"./mock-speech-model\";\nimport { MockTranscriptionModel } from \"./mock-transcription-model\";\n\n/**\n * Creates a mock SDK adapter for testing — no HTTP calls, fully configurable.\n *\n * @example\n * const mock = MockSDK({\n * responses: [\n * { content: \"Hello from mock!\" },\n * { content: \"Second response\" },\n * ],\n * });\n * const model = mock.model({ name: \"gpt-4o\" });\n * const result = await model.complete([{ role: \"user\", content: \"Hi\" }]);\n * console.log(result.content); // \"Hello from mock!\"\n */\nexport function MockSDK(config: MockSDKConfig = {}): SDKAdapterContract & {\n /** All model instances created by this SDK — for inspecting calls in tests */\n models: MockModel[];\n /** All image-model instances created by this SDK — for inspecting calls in tests */\n imageModels: MockImageModel[];\n /** All speech-model instances created by this SDK — for inspecting calls in tests */\n speechModels: MockSpeechModel[];\n /** All transcription-model instances created by this SDK — for inspecting calls in tests */\n transcriptionModels: MockTranscriptionModel[];\n} {\n const models: MockModel[] = [];\n const imageModels: MockImageModel[] = [];\n const speechModels: MockSpeechModel[] = [];\n const transcriptionModels: MockTranscriptionModel[] = [];\n const responses = config.responses ?? [{ content: \"Mock response\" }];\n const imageResponses = config.imageResponses ?? [{}];\n const speechResponses = config.speechResponses ?? [{}];\n const transcriptionResponses = config.transcriptionResponses ?? [{}];\n\n return {\n models,\n imageModels,\n speechModels,\n transcriptionModels,\n model(modelConfig: ModelConfig) {\n const model = new MockModel(\n modelConfig.name ?? config.defaultModelName ?? \"mock-model\",\n responses,\n config.capabilities,\n );\n models.push(model);\n return model;\n },\n image(imageConfig: ImageModelConfig) {\n const model = new MockImageModel(\n imageConfig.name ?? config.defaultModelName ?? \"mock-image-model\",\n imageResponses,\n imageConfig.pricing ?? config.imagePricing,\n );\n imageModels.push(model);\n return model;\n },\n speech(speechConfig: SpeechModelConfig) {\n const model = new MockSpeechModel(\n speechConfig.name ?? config.defaultModelName ?? \"mock-speech-model\",\n speechResponses,\n speechConfig.pricing ?? config.speechPricing,\n );\n speechModels.push(model);\n return model;\n },\n transcribe(transcribeConfig: TranscriptionModelConfig) {\n const model = new MockTranscriptionModel(\n transcribeConfig.name ?? config.defaultModelName ?? \"mock-transcription-model\",\n transcriptionResponses,\n transcribeConfig.pricing ?? config.transcriptionPricing,\n );\n transcriptionModels.push(model);\n return model;\n },\n async count(text: string, _model?: string): Promise<number> {\n return approximateTokenCount(text);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,QAAQ,SAAwB,CAAC,GAS/C;CACA,MAAM,SAAsB,CAAC;CAC7B,MAAM,cAAgC,CAAC;CACvC,MAAM,eAAkC,CAAC;CACzC,MAAM,sBAAgD,CAAC;CACvD,MAAM,YAAY,OAAO,aAAa,CAAC,EAAE,SAAS,gBAAgB,CAAC;CACnE,MAAM,iBAAiB,OAAO,kBAAkB,CAAC,CAAC,CAAC;CACnD,MAAM,kBAAkB,OAAO,mBAAmB,CAAC,CAAC,CAAC;CACrD,MAAM,yBAAyB,OAAO,0BAA0B,CAAC,CAAC,CAAC;CAEnE,OAAO;EACL;EACA;EACA;EACA;EACA,MAAM,aAA0B;GAC9B,MAAM,QAAQ,IAAI,UAChB,YAAY,QAAQ,OAAO,oBAAoB,cAC/C,WACA,OAAO,YACT;GACA,OAAO,KAAK,KAAK;GACjB,OAAO;EACT;EACA,MAAM,aAA+B;GACnC,MAAM,QAAQ,IAAI,eAChB,YAAY,QAAQ,OAAO,oBAAoB,oBAC/C,gBACA,YAAY,WAAW,OAAO,YAChC;GACA,YAAY,KAAK,KAAK;GACtB,OAAO;EACT;EACA,OAAO,cAAiC;GACtC,MAAM,QAAQ,IAAI,gBAChB,aAAa,QAAQ,OAAO,oBAAoB,qBAChD,iBACA,aAAa,WAAW,OAAO,aACjC;GACA,aAAa,KAAK,KAAK;GACvB,OAAO;EACT;EACA,WAAW,kBAA4C;GACrD,MAAM,QAAQ,IAAI,uBAChB,iBAAiB,QAAQ,OAAO,oBAAoB,4BACpD,wBACA,iBAAiB,WAAW,OAAO,oBACrC;GACA,oBAAoB,KAAK,KAAK;GAC9B,OAAO;EACT;EACA,MAAM,MAAM,MAAc,QAAkC;GAC1D,OAAO,sBAAsB,IAAI;EACnC;CACF;AACF"}
@@ -0,0 +1,31 @@
1
+ import { Usage } from "../contracts/result/usage.type.mjs";
2
+ import { GeneratedAudio, SpeechGenerationResponse, SpeechModelContract, SpeechModelPricing, SpeechOptions } from "../contracts/speech-model.contract.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/mock/mock-speech-model.d.ts
5
+ /** One scripted response for a {@link MockSpeechModel}. */
6
+ type MockSpeechResponse = {
7
+ audio?: GeneratedAudio;
8
+ usage?: Usage; /** Characters synthesized; defaults to the input text length. */
9
+ characters?: number;
10
+ error?: Error;
11
+ delay?: number;
12
+ };
13
+ /** One recorded `generate()` invocation, for test assertions. */
14
+ type MockSpeechCall = {
15
+ text: string;
16
+ options: SpeechOptions | undefined;
17
+ };
18
+ /** Deterministic {@link SpeechModelContract} double for tests — no HTTP. */
19
+ declare class MockSpeechModel implements SpeechModelContract {
20
+ readonly name: string;
21
+ private readonly responses;
22
+ readonly pricing?: SpeechModelPricing | undefined;
23
+ readonly provider = "mock";
24
+ readonly calls: MockSpeechCall[];
25
+ private callIndex;
26
+ constructor(name: string, responses: MockSpeechResponse[], pricing?: SpeechModelPricing | undefined);
27
+ generate(text: string, options?: SpeechOptions): Promise<SpeechGenerationResponse>;
28
+ }
29
+ //#endregion
30
+ export { MockSpeechCall, MockSpeechModel, MockSpeechResponse };
31
+ //# sourceMappingURL=mock-speech-model.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-speech-model.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/mock/mock-speech-model.ts"],"mappings":";;;;;KAUY,kBAAA;EACV,KAAA,GAAQ,cAAA;EACR,KAAA,GAAQ,KAAA;EAER,UAAA;EACA,KAAA,GAAQ,KAAA;EACR,KAAA;AAAA;;KAIU,cAAA;EAAmB,IAAA;EAAc,OAAA,EAAS,aAAa;AAAA;;cAGtD,eAAA,YAA2B,mBAAA;EAAA,SAOpB,IAAA;EAAA,iBACC,SAAA;EAAA,SACD,OAAA,GAAU,kBAAA;EAAA,SARZ,QAAA;EAAA,SACA,KAAA,EAAO,cAAA;EAAA,QAEf,SAAA;cAGU,IAAA,UACC,SAAA,EAAW,kBAAA,IACZ,OAAA,GAAU,kBAAA;EAGf,QAAA,CAAS,IAAA,UAAc,OAAA,GAAU,aAAA,GAAgB,OAAA,CAAQ,wBAAA;AAAA"}
@@ -0,0 +1,39 @@
1
+ //#region ../@warlock.js/ai/src/mock/mock-speech-model.ts
2
+ /** Deterministic {@link SpeechModelContract} double for tests — no HTTP. */
3
+ var MockSpeechModel = class {
4
+ constructor(name, responses, pricing) {
5
+ this.name = name;
6
+ this.responses = responses;
7
+ this.pricing = pricing;
8
+ this.provider = "mock";
9
+ this.calls = [];
10
+ this.callIndex = 0;
11
+ }
12
+ async generate(text, options) {
13
+ this.calls.push({
14
+ text,
15
+ options
16
+ });
17
+ const response = this.responses[Math.min(this.callIndex, this.responses.length - 1)] ?? {};
18
+ this.callIndex += 1;
19
+ if (response.delay) await new Promise((resolve) => setTimeout(resolve, response.delay));
20
+ if (response.error) throw response.error;
21
+ return {
22
+ audio: response.audio ?? {
23
+ type: "base64",
24
+ base64: "AAAA",
25
+ mediaType: "audio/mpeg"
26
+ },
27
+ usage: response.usage ?? {
28
+ input: 0,
29
+ output: 0,
30
+ total: 0
31
+ },
32
+ characters: response.characters ?? text.length
33
+ };
34
+ }
35
+ };
36
+
37
+ //#endregion
38
+ export { MockSpeechModel };
39
+ //# sourceMappingURL=mock-speech-model.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-speech-model.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/mock/mock-speech-model.ts"],"sourcesContent":["import type {\n GeneratedAudio,\n SpeechGenerationResponse,\n SpeechModelContract,\n SpeechModelPricing,\n SpeechOptions,\n} from \"../contracts/speech-model.contract\";\nimport type { Usage } from \"../contracts/result/usage.type\";\n\n/** One scripted response for a {@link MockSpeechModel}. */\nexport type MockSpeechResponse = {\n audio?: GeneratedAudio;\n usage?: Usage;\n /** Characters synthesized; defaults to the input text length. */\n characters?: number;\n error?: Error;\n delay?: number;\n};\n\n/** One recorded `generate()` invocation, for test assertions. */\nexport type MockSpeechCall = { text: string; options: SpeechOptions | undefined };\n\n/** Deterministic {@link SpeechModelContract} double for tests — no HTTP. */\nexport class MockSpeechModel implements SpeechModelContract {\n public readonly provider = \"mock\";\n public readonly calls: MockSpeechCall[] = [];\n\n private callIndex = 0;\n\n public constructor(\n public readonly name: string,\n private readonly responses: MockSpeechResponse[],\n public readonly pricing?: SpeechModelPricing,\n ) {}\n\n public async generate(text: string, options?: SpeechOptions): Promise<SpeechGenerationResponse> {\n this.calls.push({ text, options });\n\n const response = this.responses[Math.min(this.callIndex, this.responses.length - 1)] ?? {};\n this.callIndex += 1;\n\n if (response.delay) {\n await new Promise((resolve) => setTimeout(resolve, response.delay));\n }\n if (response.error) {\n throw response.error;\n }\n\n return {\n audio: response.audio ?? { type: \"base64\", base64: \"AAAA\", mediaType: \"audio/mpeg\" },\n usage: response.usage ?? { input: 0, output: 0, total: 0 },\n characters: response.characters ?? text.length,\n };\n }\n}\n"],"mappings":";;AAuBA,IAAa,kBAAb,MAA4D;CAM1D,AAAO,YACL,AAAgB,MAChB,AAAiB,WACjB,AAAgB,SAChB;EAHgB;EACC;EACD;kBARS;eACe,CAAC;mBAEvB;CAMjB;CAEH,MAAa,SAAS,MAAc,SAA4D;EAC9F,KAAK,MAAM,KAAK;GAAE;GAAM;EAAQ,CAAC;EAEjC,MAAM,WAAW,KAAK,UAAU,KAAK,IAAI,KAAK,WAAW,KAAK,UAAU,SAAS,CAAC,MAAM,CAAC;EACzF,KAAK,aAAa;EAElB,IAAI,SAAS,OACX,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,SAAS,KAAK,CAAC;EAEpE,IAAI,SAAS,OACX,MAAM,SAAS;EAGjB,OAAO;GACL,OAAO,SAAS,SAAS;IAAE,MAAM;IAAU,QAAQ;IAAQ,WAAW;GAAa;GACnF,OAAO,SAAS,SAAS;IAAE,OAAO;IAAG,QAAQ;IAAG,OAAO;GAAE;GACzD,YAAY,SAAS,cAAc,KAAK;EAC1C;CACF;AACF"}
@@ -0,0 +1,32 @@
1
+ import { Usage } from "../contracts/result/usage.type.mjs";
2
+ import { AudioInput, TranscribeOptions, TranscriptionModelContract, TranscriptionModelPricing, TranscriptionResponse, TranscriptionSegment } from "../contracts/transcription-model.contract.mjs";
3
+
4
+ //#region ../@warlock.js/ai/src/mock/mock-transcription-model.d.ts
5
+ /** One scripted response for a {@link MockTranscriptionModel}. */
6
+ type MockTranscriptionResponse = {
7
+ text?: string;
8
+ segments?: TranscriptionSegment[];
9
+ durationSeconds?: number;
10
+ usage?: Usage;
11
+ error?: Error;
12
+ delay?: number;
13
+ };
14
+ /** One recorded `transcribe()` invocation, for test assertions. */
15
+ type MockTranscriptionCall = {
16
+ audio: AudioInput;
17
+ options: TranscribeOptions | undefined;
18
+ };
19
+ /** Deterministic {@link TranscriptionModelContract} double for tests — no HTTP. */
20
+ declare class MockTranscriptionModel implements TranscriptionModelContract {
21
+ readonly name: string;
22
+ private readonly responses;
23
+ readonly pricing?: TranscriptionModelPricing | undefined;
24
+ readonly provider = "mock";
25
+ readonly calls: MockTranscriptionCall[];
26
+ private callIndex;
27
+ constructor(name: string, responses: MockTranscriptionResponse[], pricing?: TranscriptionModelPricing | undefined);
28
+ transcribe(audio: AudioInput, options?: TranscribeOptions): Promise<TranscriptionResponse>;
29
+ }
30
+ //#endregion
31
+ export { MockTranscriptionCall, MockTranscriptionModel, MockTranscriptionResponse };
32
+ //# sourceMappingURL=mock-transcription-model.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-transcription-model.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/mock/mock-transcription-model.ts"],"mappings":";;;;;KAWY,yBAAA;EACV,IAAA;EACA,QAAA,GAAW,oBAAA;EACX,eAAA;EACA,KAAA,GAAQ,KAAA;EACR,KAAA,GAAQ,KAAA;EACR,KAAA;AAAA;;KAIU,qBAAA;EAA0B,KAAA,EAAO,UAAA;EAAY,OAAA,EAAS,iBAAiB;AAAA;;cAGtE,sBAAA,YAAkC,0BAAA;EAAA,SAO3B,IAAA;EAAA,iBACC,SAAA;EAAA,SACD,OAAA,GAAU,yBAAA;EAAA,SARZ,QAAA;EAAA,SACA,KAAA,EAAO,qBAAA;EAAA,QAEf,SAAA;cAGU,IAAA,UACC,SAAA,EAAW,yBAAA,IACZ,OAAA,GAAU,yBAAA;EAGf,UAAA,CACX,KAAA,EAAO,UAAA,EACP,OAAA,GAAU,iBAAA,GACT,OAAA,CAAQ,qBAAA;AAAA"}
@@ -0,0 +1,36 @@
1
+ //#region ../@warlock.js/ai/src/mock/mock-transcription-model.ts
2
+ /** Deterministic {@link TranscriptionModelContract} double for tests — no HTTP. */
3
+ var MockTranscriptionModel = class {
4
+ constructor(name, responses, pricing) {
5
+ this.name = name;
6
+ this.responses = responses;
7
+ this.pricing = pricing;
8
+ this.provider = "mock";
9
+ this.calls = [];
10
+ this.callIndex = 0;
11
+ }
12
+ async transcribe(audio, options) {
13
+ this.calls.push({
14
+ audio,
15
+ options
16
+ });
17
+ const response = this.responses[Math.min(this.callIndex, this.responses.length - 1)] ?? {};
18
+ this.callIndex += 1;
19
+ if (response.delay) await new Promise((resolve) => setTimeout(resolve, response.delay));
20
+ if (response.error) throw response.error;
21
+ return {
22
+ text: response.text ?? "mock transcript",
23
+ ...response.segments ? { segments: response.segments } : {},
24
+ ...response.durationSeconds !== void 0 ? { durationSeconds: response.durationSeconds } : {},
25
+ usage: response.usage ?? {
26
+ input: 0,
27
+ output: 0,
28
+ total: 0
29
+ }
30
+ };
31
+ }
32
+ };
33
+
34
+ //#endregion
35
+ export { MockTranscriptionModel };
36
+ //# sourceMappingURL=mock-transcription-model.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-transcription-model.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/mock/mock-transcription-model.ts"],"sourcesContent":["import type { Usage } from \"../contracts/result/usage.type\";\nimport type {\n AudioInput,\n TranscribeOptions,\n TranscriptionModelContract,\n TranscriptionModelPricing,\n TranscriptionResponse,\n TranscriptionSegment,\n} from \"../contracts/transcription-model.contract\";\n\n/** One scripted response for a {@link MockTranscriptionModel}. */\nexport type MockTranscriptionResponse = {\n text?: string;\n segments?: TranscriptionSegment[];\n durationSeconds?: number;\n usage?: Usage;\n error?: Error;\n delay?: number;\n};\n\n/** One recorded `transcribe()` invocation, for test assertions. */\nexport type MockTranscriptionCall = { audio: AudioInput; options: TranscribeOptions | undefined };\n\n/** Deterministic {@link TranscriptionModelContract} double for tests — no HTTP. */\nexport class MockTranscriptionModel implements TranscriptionModelContract {\n public readonly provider = \"mock\";\n public readonly calls: MockTranscriptionCall[] = [];\n\n private callIndex = 0;\n\n public constructor(\n public readonly name: string,\n private readonly responses: MockTranscriptionResponse[],\n public readonly pricing?: TranscriptionModelPricing,\n ) {}\n\n public async transcribe(\n audio: AudioInput,\n options?: TranscribeOptions,\n ): Promise<TranscriptionResponse> {\n this.calls.push({ audio, options });\n\n const response = this.responses[Math.min(this.callIndex, this.responses.length - 1)] ?? {};\n this.callIndex += 1;\n\n if (response.delay) {\n await new Promise((resolve) => setTimeout(resolve, response.delay));\n }\n if (response.error) {\n throw response.error;\n }\n\n return {\n text: response.text ?? \"mock transcript\",\n ...(response.segments ? { segments: response.segments } : {}),\n ...(response.durationSeconds !== undefined\n ? { durationSeconds: response.durationSeconds }\n : {}),\n usage: response.usage ?? { input: 0, output: 0, total: 0 },\n };\n }\n}\n"],"mappings":";;AAwBA,IAAa,yBAAb,MAA0E;CAMxE,AAAO,YACL,AAAgB,MAChB,AAAiB,WACjB,AAAgB,SAChB;EAHgB;EACC;EACD;kBARS;eACsB,CAAC;mBAE9B;CAMjB;CAEH,MAAa,WACX,OACA,SACgC;EAChC,KAAK,MAAM,KAAK;GAAE;GAAO;EAAQ,CAAC;EAElC,MAAM,WAAW,KAAK,UAAU,KAAK,IAAI,KAAK,WAAW,KAAK,UAAU,SAAS,CAAC,MAAM,CAAC;EACzF,KAAK,aAAa;EAElB,IAAI,SAAS,OACX,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,SAAS,KAAK,CAAC;EAEpE,IAAI,SAAS,OACX,MAAM,SAAS;EAGjB,OAAO;GACL,MAAM,SAAS,QAAQ;GACvB,GAAI,SAAS,WAAW,EAAE,UAAU,SAAS,SAAS,IAAI,CAAC;GAC3D,GAAI,SAAS,oBAAoB,SAC7B,EAAE,iBAAiB,SAAS,gBAAgB,IAC5C,CAAC;GACL,OAAO,SAAS,SAAS;IAAE,OAAO;IAAG,QAAQ;IAAG,OAAO;GAAE;EAC3D;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import { ObjectStreamEvent, StreamObjectParams, collectStreamObject, streamObject } from "./stream-object.mjs";
2
+ import { parsePartialJson } from "./parse-partial-json.mjs";
@@ -0,0 +1,4 @@
1
+ import { parsePartialJson } from "./parse-partial-json.mjs";
2
+ import { collectStreamObject, streamObject } from "./stream-object.mjs";
3
+
4
+ export { };
@@ -0,0 +1,22 @@
1
+ //#region ../@warlock.js/ai/src/object-stream/parse-partial-json.d.ts
2
+ /**
3
+ * Best-effort parse of a possibly-truncated JSON string into the value it
4
+ * is "on its way to" becoming. Used by {@link streamObject} to emit a
5
+ * partial object snapshot from each streamed delta before the full reply
6
+ * has arrived.
7
+ *
8
+ * Returns `undefined` when the prefix can't yet be coerced into a value
9
+ * (so the caller simply waits for more text). The FINAL parse in
10
+ * `streamObject` is always strict `JSON.parse` — this tolerant parser only
11
+ * powers the in-flight snapshots, so a too-clever completion never affects
12
+ * the authoritative result.
13
+ *
14
+ * @example
15
+ * parsePartialJson('{"name":"Al'); // → { name: "Al" }
16
+ * parsePartialJson('{"items":[1,2,'); // → { items: [1, 2] }
17
+ * parsePartialJson('{"a":1,"b"'); // → { a: 1 } (drops the dangling key)
18
+ */
19
+ declare function parsePartialJson(text: string): unknown | undefined;
20
+ //#endregion
21
+ export { parsePartialJson };
22
+ //# sourceMappingURL=parse-partial-json.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-partial-json.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/object-stream/parse-partial-json.ts"],"mappings":";;AAiBA;;;;AAA6C;;;;;;;;;;;;iBAA7B,gBAAA,CAAiB,IAAY"}
@@ -0,0 +1,78 @@
1
+ //#region ../@warlock.js/ai/src/object-stream/parse-partial-json.ts
2
+ /**
3
+ * Best-effort parse of a possibly-truncated JSON string into the value it
4
+ * is "on its way to" becoming. Used by {@link streamObject} to emit a
5
+ * partial object snapshot from each streamed delta before the full reply
6
+ * has arrived.
7
+ *
8
+ * Returns `undefined` when the prefix can't yet be coerced into a value
9
+ * (so the caller simply waits for more text). The FINAL parse in
10
+ * `streamObject` is always strict `JSON.parse` — this tolerant parser only
11
+ * powers the in-flight snapshots, so a too-clever completion never affects
12
+ * the authoritative result.
13
+ *
14
+ * @example
15
+ * parsePartialJson('{"name":"Al'); // → { name: "Al" }
16
+ * parsePartialJson('{"items":[1,2,'); // → { items: [1, 2] }
17
+ * parsePartialJson('{"a":1,"b"'); // → { a: 1 } (drops the dangling key)
18
+ */
19
+ function parsePartialJson(text) {
20
+ const trimmed = text.trim();
21
+ if (!trimmed) return void 0;
22
+ const direct = tryParse(trimmed);
23
+ if (direct.ok) return direct.value;
24
+ const completed = completePartialJson(trimmed);
25
+ if (completed === void 0) return void 0;
26
+ const parsed = tryParse(completed);
27
+ return parsed.ok ? parsed.value : void 0;
28
+ }
29
+ function tryParse(text) {
30
+ try {
31
+ return {
32
+ ok: true,
33
+ value: JSON.parse(text)
34
+ };
35
+ } catch {
36
+ return { ok: false };
37
+ }
38
+ }
39
+ /**
40
+ * Reconstruct a parseable JSON string from a truncated prefix by closing
41
+ * open strings/containers and trimming dangling separators, keys, and
42
+ * partial literals. Tries the most faithful completion first, then falls
43
+ * back to dropping the unfinished tail.
44
+ */
45
+ function completePartialJson(text) {
46
+ const stack = [];
47
+ let inString = false;
48
+ let escaped = false;
49
+ for (const ch of text) {
50
+ if (inString) {
51
+ if (escaped) escaped = false;
52
+ else if (ch === "\\") escaped = true;
53
+ else if (ch === "\"") inString = false;
54
+ continue;
55
+ }
56
+ if (ch === "\"") inString = true;
57
+ else if (ch === "{" || ch === "[") stack.push(ch);
58
+ else if (ch === "}" || ch === "]") stack.pop();
59
+ }
60
+ const closers = () => stack.map((c) => c === "{" ? "}" : "]").reverse().join("");
61
+ let core = text;
62
+ if (inString) core += "\"";
63
+ core = core.replace(/\s+$/, "");
64
+ if (core.endsWith(",")) core = core.slice(0, -1);
65
+ if (core.endsWith(":")) core += "null";
66
+ const attempts = [core + closers()];
67
+ if (stack[stack.length - 1] === "{") {
68
+ const droppedKey = core.replace(/,?\s*"(?:[^"\\]|\\.)*"\s*$/, "");
69
+ attempts.push(droppedKey.replace(/,\s*$/, "") + closers());
70
+ }
71
+ const droppedLiteral = core.replace(/[:,]?\s*[A-Za-z0-9.+\-eE]+$/, (match) => match.trimStart().startsWith(":") ? ":null" : "");
72
+ attempts.push(droppedLiteral.replace(/,\s*$/, "") + closers());
73
+ for (const candidate of attempts) if (tryParse(candidate).ok) return candidate;
74
+ }
75
+
76
+ //#endregion
77
+ export { parsePartialJson };
78
+ //# sourceMappingURL=parse-partial-json.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-partial-json.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/object-stream/parse-partial-json.ts"],"sourcesContent":["/**\n * Best-effort parse of a possibly-truncated JSON string into the value it\n * is \"on its way to\" becoming. Used by {@link streamObject} to emit a\n * partial object snapshot from each streamed delta before the full reply\n * has arrived.\n *\n * Returns `undefined` when the prefix can't yet be coerced into a value\n * (so the caller simply waits for more text). The FINAL parse in\n * `streamObject` is always strict `JSON.parse` — this tolerant parser only\n * powers the in-flight snapshots, so a too-clever completion never affects\n * the authoritative result.\n *\n * @example\n * parsePartialJson('{\"name\":\"Al'); // → { name: \"Al\" }\n * parsePartialJson('{\"items\":[1,2,'); // → { items: [1, 2] }\n * parsePartialJson('{\"a\":1,\"b\"'); // → { a: 1 } (drops the dangling key)\n */\nexport function parsePartialJson(text: string): unknown | undefined {\n const trimmed = text.trim();\n if (!trimmed) return undefined;\n\n // Fast path: already-valid JSON.\n const direct = tryParse(trimmed);\n if (direct.ok) return direct.value;\n\n const completed = completePartialJson(trimmed);\n if (completed === undefined) return undefined;\n\n const parsed = tryParse(completed);\n return parsed.ok ? parsed.value : undefined;\n}\n\nfunction tryParse(text: string): { ok: true; value: unknown } | { ok: false } {\n try {\n return { ok: true, value: JSON.parse(text) };\n } catch {\n return { ok: false };\n }\n}\n\n/**\n * Reconstruct a parseable JSON string from a truncated prefix by closing\n * open strings/containers and trimming dangling separators, keys, and\n * partial literals. Tries the most faithful completion first, then falls\n * back to dropping the unfinished tail.\n */\nfunction completePartialJson(text: string): string | undefined {\n const stack: Array<\"{\" | \"[\"> = [];\n let inString = false;\n let escaped = false;\n\n for (const ch of text) {\n if (inString) {\n if (escaped) escaped = false;\n else if (ch === \"\\\\\") escaped = true;\n else if (ch === '\"') inString = false;\n continue;\n }\n if (ch === '\"') inString = true;\n else if (ch === \"{\" || ch === \"[\") stack.push(ch);\n else if (ch === \"}\" || ch === \"]\") stack.pop();\n }\n\n const closers = () =>\n stack\n .map(c => (c === \"{\" ? \"}\" : \"]\"))\n .reverse()\n .join(\"\");\n\n // Faithful completion: close an open string, drop a trailing comma,\n // fill a dangling `key:` with null, then close containers.\n let core = text;\n if (inString) core += '\"';\n core = core.replace(/\\s+$/, \"\");\n if (core.endsWith(\",\")) core = core.slice(0, -1);\n if (core.endsWith(\":\")) core += \"null\";\n\n const attempts: string[] = [core + closers()];\n\n // Fallback 1: drop a dangling object key (a `\"...\"` with no value yet).\n if (stack[stack.length - 1] === \"{\") {\n const droppedKey = core.replace(/,?\\s*\"(?:[^\"\\\\]|\\\\.)*\"\\s*$/, \"\");\n attempts.push(droppedKey.replace(/,\\s*$/, \"\") + closers());\n }\n\n // Fallback 2: drop a partial trailing literal / number (e.g. `tr`, `12.`).\n const droppedLiteral = core.replace(/[:,]?\\s*[A-Za-z0-9.+\\-eE]+$/, match =>\n match.trimStart().startsWith(\":\") ? \":null\" : \"\",\n );\n attempts.push(droppedLiteral.replace(/,\\s*$/, \"\") + closers());\n\n for (const candidate of attempts) {\n if (tryParse(candidate).ok) return candidate;\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,iBAAiB,MAAmC;CAClE,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,SAAS,OAAO;CAGrB,MAAM,SAAS,SAAS,OAAO;CAC/B,IAAI,OAAO,IAAI,OAAO,OAAO;CAE7B,MAAM,YAAY,oBAAoB,OAAO;CAC7C,IAAI,cAAc,QAAW,OAAO;CAEpC,MAAM,SAAS,SAAS,SAAS;CACjC,OAAO,OAAO,KAAK,OAAO,QAAQ;AACpC;AAEA,SAAS,SAAS,MAA4D;CAC5E,IAAI;EACF,OAAO;GAAE,IAAI;GAAM,OAAO,KAAK,MAAM,IAAI;EAAE;CAC7C,QAAQ;EACN,OAAO,EAAE,IAAI,MAAM;CACrB;AACF;;;;;;;AAQA,SAAS,oBAAoB,MAAkC;CAC7D,MAAM,QAA0B,CAAC;CACjC,IAAI,WAAW;CACf,IAAI,UAAU;CAEd,KAAK,MAAM,MAAM,MAAM;EACrB,IAAI,UAAU;GACZ,IAAI,SAAS,UAAU;QAClB,IAAI,OAAO,MAAM,UAAU;QAC3B,IAAI,OAAO,MAAK,WAAW;GAChC;EACF;EACA,IAAI,OAAO,MAAK,WAAW;OACtB,IAAI,OAAO,OAAO,OAAO,KAAK,MAAM,KAAK,EAAE;OAC3C,IAAI,OAAO,OAAO,OAAO,KAAK,MAAM,IAAI;CAC/C;CAEA,MAAM,gBACJ,MACG,KAAI,MAAM,MAAM,MAAM,MAAM,GAAI,CAAC,CACjC,QAAQ,CAAC,CACT,KAAK,EAAE;CAIZ,IAAI,OAAO;CACX,IAAI,UAAU,QAAQ;CACtB,OAAO,KAAK,QAAQ,QAAQ,EAAE;CAC9B,IAAI,KAAK,SAAS,GAAG,GAAG,OAAO,KAAK,MAAM,GAAG,EAAE;CAC/C,IAAI,KAAK,SAAS,GAAG,GAAG,QAAQ;CAEhC,MAAM,WAAqB,CAAC,OAAO,QAAQ,CAAC;CAG5C,IAAI,MAAM,MAAM,SAAS,OAAO,KAAK;EACnC,MAAM,aAAa,KAAK,QAAQ,8BAA8B,EAAE;EAChE,SAAS,KAAK,WAAW,QAAQ,SAAS,EAAE,IAAI,QAAQ,CAAC;CAC3D;CAGA,MAAM,iBAAiB,KAAK,QAAQ,gCAA+B,UACjE,MAAM,UAAU,CAAC,CAAC,WAAW,GAAG,IAAI,UAAU,EAChD;CACA,SAAS,KAAK,eAAe,QAAQ,SAAS,EAAE,IAAI,QAAQ,CAAC;CAE7D,KAAK,MAAM,aAAa,UACtB,IAAI,SAAS,SAAS,CAAC,CAAC,IAAI,OAAO;AAIvC"}
@@ -0,0 +1,68 @@
1
+ import { Message } from "../contracts/conversation-message.type.mjs";
2
+ import { AIError } from "../errors/ai-error.mjs";
3
+ import { Usage } from "../contracts/result/usage.type.mjs";
4
+ import { ModelCallOptions, ModelContract } from "../contracts/model.contract.mjs";
5
+ import { StandardSchemaV1 } from "@standard-schema/spec";
6
+
7
+ //#region ../@warlock.js/ai/src/object-stream/stream-object.d.ts
8
+ /**
9
+ * One event in a {@link streamObject} run.
10
+ *
11
+ * - `text-delta` — the raw token text as it streams (for a "typing" view).
12
+ * - `partial` — a best-effort snapshot of the object so far, re-parsed
13
+ * from the accumulated text on each delta (only emitted when it changed).
14
+ * - `done` — terminal: the final text is strictly parsed and validated
15
+ * against the schema. `valid` + `value` on success; `valid: false` +
16
+ * `error` when the output wasn't valid JSON or failed the schema.
17
+ */
18
+ type ObjectStreamEvent<T> = {
19
+ type: "text-delta";
20
+ delta: string;
21
+ } | {
22
+ type: "partial";
23
+ value: unknown;
24
+ } | {
25
+ type: "done";
26
+ valid: true;
27
+ value: T;
28
+ usage: Usage;
29
+ } | {
30
+ type: "done";
31
+ valid: false;
32
+ error: AIError;
33
+ usage: Usage;
34
+ };
35
+ /** Parameters for {@link streamObject}. */
36
+ type StreamObjectParams<T> = {
37
+ /** The model to stream from (e.g. `sdk.model({ name })`). */model: ModelContract; /** The prompt messages. */
38
+ messages: Message[]; /** Standard Schema the final object is validated against. */
39
+ schema: StandardSchemaV1<T>; /** Extra model call options (e.g. `responseSchema`, `temperature`). */
40
+ options?: ModelCallOptions;
41
+ };
42
+ /**
43
+ * Stream a structured object: emit raw token deltas, progressively-parsed
44
+ * partial-object snapshots, and a final strictly-validated object — the
45
+ * first-class structured-output streaming primitive (A1). Reuses the
46
+ * model's existing `stream()` seam; the partial snapshots come from a
47
+ * tolerant {@link parsePartialJson}, while the terminal `done` event is a
48
+ * strict `JSON.parse` + schema validation, so an over-eager partial parse
49
+ * never affects the authoritative result.
50
+ *
51
+ * Pair it with a `structuredOutput`-capable model and a `responseSchema`
52
+ * (via `options`) for the cleanest JSON; otherwise prompt the model to
53
+ * reply with JSON only.
54
+ *
55
+ * @example
56
+ * for await (const event of streamObject({ model, messages, schema })) {
57
+ * if (event.type === "partial") render(event.value); // live UI
58
+ * if (event.type === "done" && event.valid) save(event.value); // final
59
+ * }
60
+ */
61
+ declare function streamObject<T>(params: StreamObjectParams<T>): AsyncIterable<ObjectStreamEvent<T>>;
62
+ /** Collect a {@link streamObject} run down to just its terminal event. */
63
+ declare function collectStreamObject<T>(stream: AsyncIterable<ObjectStreamEvent<T>>): Promise<Extract<ObjectStreamEvent<T>, {
64
+ type: "done";
65
+ }>>;
66
+ //#endregion
67
+ export { ObjectStreamEvent, StreamObjectParams, collectStreamObject, streamObject };
68
+ //# sourceMappingURL=stream-object.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-object.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/object-stream/stream-object.ts"],"mappings":";;;;;;;;;;AAiBA;;;;;;;KAAY,iBAAA;EACN,IAAA;EAAoB,KAAA;AAAA;EACpB,IAAA;EAAiB,KAAA;AAAA;EACjB,IAAA;EAAc,KAAA;EAAa,KAAA,EAAO,CAAA;EAAG,KAAA,EAAO,KAAA;AAAA;EAC5C,IAAA;EAAc,KAAA;EAAc,KAAA,EAAO,OAAA;EAAS,KAAA,EAAO,KAAA;AAAA;;KAG7C,kBAAA;EAHkD,6DAK5D,KAAA,EAAO,aAAA,EAFG;EAIV,QAAA,EAAU,OAAA,IAJkB;EAM5B,MAAA,EAAQ,gBAAA,CAAiB,CAAA,GAFf;EAIV,OAAA,GAAU,gBAAA;AAAA;;;;;;;;;;;;;;;AAAgB;AAsB5B;;;;iBAAuB,YAAA,IACrB,MAAA,EAAQ,kBAAA,CAAmB,CAAA,IAC1B,aAAA,CAAc,iBAAA,CAAkB,CAAA;;iBAoEb,mBAAA,IACpB,MAAA,EAAQ,aAAA,CAAc,iBAAA,CAAkB,CAAA,KACvC,OAAA,CAAQ,OAAA,CAAQ,iBAAA,CAAkB,CAAA;EAAM,IAAA;AAAA"}
@@ -0,0 +1,104 @@
1
+ import { SchemaValidationError } from "../errors/schema-validation-error.mjs";
2
+ import "../errors/index.mjs";
3
+ import { parsePartialJson } from "./parse-partial-json.mjs";
4
+
5
+ //#region ../@warlock.js/ai/src/object-stream/stream-object.ts
6
+ /**
7
+ * Stream a structured object: emit raw token deltas, progressively-parsed
8
+ * partial-object snapshots, and a final strictly-validated object — the
9
+ * first-class structured-output streaming primitive (A1). Reuses the
10
+ * model's existing `stream()` seam; the partial snapshots come from a
11
+ * tolerant {@link parsePartialJson}, while the terminal `done` event is a
12
+ * strict `JSON.parse` + schema validation, so an over-eager partial parse
13
+ * never affects the authoritative result.
14
+ *
15
+ * Pair it with a `structuredOutput`-capable model and a `responseSchema`
16
+ * (via `options`) for the cleanest JSON; otherwise prompt the model to
17
+ * reply with JSON only.
18
+ *
19
+ * @example
20
+ * for await (const event of streamObject({ model, messages, schema })) {
21
+ * if (event.type === "partial") render(event.value); // live UI
22
+ * if (event.type === "done" && event.valid) save(event.value); // final
23
+ * }
24
+ */
25
+ async function* streamObject(params) {
26
+ const { model, messages, schema, options } = params;
27
+ let accumulated = "";
28
+ let lastPartialKey;
29
+ let usage = {
30
+ input: 0,
31
+ output: 0,
32
+ total: 0
33
+ };
34
+ for await (const chunk of model.stream(messages, options)) if (chunk.type === "delta") {
35
+ accumulated += chunk.content;
36
+ yield {
37
+ type: "text-delta",
38
+ delta: chunk.content
39
+ };
40
+ const partial = parsePartialJson(accumulated);
41
+ if (partial !== void 0) {
42
+ const key = safeStringify(partial);
43
+ if (key !== lastPartialKey) {
44
+ lastPartialKey = key;
45
+ yield {
46
+ type: "partial",
47
+ value: partial
48
+ };
49
+ }
50
+ }
51
+ } else if (chunk.type === "done") usage = chunk.usage;
52
+ yield await finalize(accumulated, schema, usage);
53
+ }
54
+ /** Strict parse + schema validation of the complete streamed text. */
55
+ async function finalize(text, schema, usage) {
56
+ const cleaned = stripJsonFences(text).trim();
57
+ let parsed;
58
+ try {
59
+ parsed = JSON.parse(cleaned);
60
+ } catch (cause) {
61
+ return {
62
+ type: "done",
63
+ valid: false,
64
+ error: new SchemaValidationError("streamObject: the final streamed output was not valid JSON", { cause }),
65
+ usage
66
+ };
67
+ }
68
+ const result = await schema["~standard"].validate(parsed);
69
+ if ("issues" in result && result.issues) return {
70
+ type: "done",
71
+ valid: false,
72
+ error: new SchemaValidationError("streamObject: the streamed object failed schema validation", { issues: result.issues }),
73
+ usage
74
+ };
75
+ return {
76
+ type: "done",
77
+ valid: true,
78
+ value: result.value,
79
+ usage
80
+ };
81
+ }
82
+ /** Collect a {@link streamObject} run down to just its terminal event. */
83
+ async function collectStreamObject(stream) {
84
+ let done;
85
+ for await (const event of stream) if (event.type === "done") done = event;
86
+ if (!done) throw new SchemaValidationError("streamObject: stream ended without a terminal event");
87
+ return done;
88
+ }
89
+ /** Strip a leading/trailing ```json fence the model may wrap output in. */
90
+ function stripJsonFences(text) {
91
+ const fenced = text.match(/```(?:json)?\s*([\s\S]*?)\s*```/i);
92
+ return fenced ? fenced[1] : text;
93
+ }
94
+ function safeStringify(value) {
95
+ try {
96
+ return JSON.stringify(value);
97
+ } catch {
98
+ return String(value);
99
+ }
100
+ }
101
+
102
+ //#endregion
103
+ export { collectStreamObject, streamObject };
104
+ //# sourceMappingURL=stream-object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-object.mjs","names":[],"sources":["../../../../../../../@warlock.js/ai/src/object-stream/stream-object.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { Message } from \"../contracts/conversation-message.type\";\nimport type { ModelCallOptions, ModelContract } from \"../contracts/model.contract\";\nimport type { Usage } from \"../contracts/result/usage.type\";\nimport { AIError, SchemaValidationError } from \"../errors\";\nimport { parsePartialJson } from \"./parse-partial-json\";\n\n/**\n * One event in a {@link streamObject} run.\n *\n * - `text-delta` — the raw token text as it streams (for a \"typing\" view).\n * - `partial` — a best-effort snapshot of the object so far, re-parsed\n * from the accumulated text on each delta (only emitted when it changed).\n * - `done` — terminal: the final text is strictly parsed and validated\n * against the schema. `valid` + `value` on success; `valid: false` +\n * `error` when the output wasn't valid JSON or failed the schema.\n */\nexport type ObjectStreamEvent<T> =\n | { type: \"text-delta\"; delta: string }\n | { type: \"partial\"; value: unknown }\n | { type: \"done\"; valid: true; value: T; usage: Usage }\n | { type: \"done\"; valid: false; error: AIError; usage: Usage };\n\n/** Parameters for {@link streamObject}. */\nexport type StreamObjectParams<T> = {\n /** The model to stream from (e.g. `sdk.model({ name })`). */\n model: ModelContract;\n /** The prompt messages. */\n messages: Message[];\n /** Standard Schema the final object is validated against. */\n schema: StandardSchemaV1<T>;\n /** Extra model call options (e.g. `responseSchema`, `temperature`). */\n options?: ModelCallOptions;\n};\n\n/**\n * Stream a structured object: emit raw token deltas, progressively-parsed\n * partial-object snapshots, and a final strictly-validated object — the\n * first-class structured-output streaming primitive (A1). Reuses the\n * model's existing `stream()` seam; the partial snapshots come from a\n * tolerant {@link parsePartialJson}, while the terminal `done` event is a\n * strict `JSON.parse` + schema validation, so an over-eager partial parse\n * never affects the authoritative result.\n *\n * Pair it with a `structuredOutput`-capable model and a `responseSchema`\n * (via `options`) for the cleanest JSON; otherwise prompt the model to\n * reply with JSON only.\n *\n * @example\n * for await (const event of streamObject({ model, messages, schema })) {\n * if (event.type === \"partial\") render(event.value); // live UI\n * if (event.type === \"done\" && event.valid) save(event.value); // final\n * }\n */\nexport async function* streamObject<T>(\n params: StreamObjectParams<T>,\n): AsyncIterable<ObjectStreamEvent<T>> {\n const { model, messages, schema, options } = params;\n\n let accumulated = \"\";\n let lastPartialKey: string | undefined;\n let usage: Usage = { input: 0, output: 0, total: 0 };\n\n for await (const chunk of model.stream(messages, options)) {\n if (chunk.type === \"delta\") {\n accumulated += chunk.content;\n yield { type: \"text-delta\", delta: chunk.content };\n\n const partial = parsePartialJson(accumulated);\n if (partial !== undefined) {\n const key = safeStringify(partial);\n if (key !== lastPartialKey) {\n lastPartialKey = key;\n yield { type: \"partial\", value: partial };\n }\n }\n } else if (chunk.type === \"done\") {\n usage = chunk.usage;\n }\n }\n\n yield await finalize(accumulated, schema, usage);\n}\n\n/** Strict parse + schema validation of the complete streamed text. */\nasync function finalize<T>(\n text: string,\n schema: StandardSchemaV1<T>,\n usage: Usage,\n): Promise<ObjectStreamEvent<T>> {\n const cleaned = stripJsonFences(text).trim();\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(cleaned);\n } catch (cause) {\n return {\n type: \"done\",\n valid: false,\n error: new SchemaValidationError(\n \"streamObject: the final streamed output was not valid JSON\",\n { cause },\n ),\n usage,\n };\n }\n\n const result = await schema[\"~standard\"].validate(parsed);\n if (\"issues\" in result && result.issues) {\n return {\n type: \"done\",\n valid: false,\n error: new SchemaValidationError(\n \"streamObject: the streamed object failed schema validation\",\n { issues: result.issues },\n ),\n usage,\n };\n }\n\n return { type: \"done\", valid: true, value: (result as { value: T }).value, usage };\n}\n\n/** Collect a {@link streamObject} run down to just its terminal event. */\nexport async function collectStreamObject<T>(\n stream: AsyncIterable<ObjectStreamEvent<T>>,\n): Promise<Extract<ObjectStreamEvent<T>, { type: \"done\" }>> {\n let done: Extract<ObjectStreamEvent<T>, { type: \"done\" }> | undefined;\n for await (const event of stream) {\n if (event.type === \"done\") done = event;\n }\n if (!done) {\n throw new SchemaValidationError(\"streamObject: stream ended without a terminal event\");\n }\n return done;\n}\n\n/** Strip a leading/trailing ```json fence the model may wrap output in. */\nfunction stripJsonFences(text: string): string {\n const fenced = text.match(/```(?:json)?\\s*([\\s\\S]*?)\\s*```/i);\n return fenced ? fenced[1] : text;\n}\n\nfunction safeStringify(value: unknown): string {\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsDA,gBAAuB,aACrB,QACqC;CACrC,MAAM,EAAE,OAAO,UAAU,QAAQ,YAAY;CAE7C,IAAI,cAAc;CAClB,IAAI;CACJ,IAAI,QAAe;EAAE,OAAO;EAAG,QAAQ;EAAG,OAAO;CAAE;CAEnD,WAAW,MAAM,SAAS,MAAM,OAAO,UAAU,OAAO,GACtD,IAAI,MAAM,SAAS,SAAS;EAC1B,eAAe,MAAM;EACrB,MAAM;GAAE,MAAM;GAAc,OAAO,MAAM;EAAQ;EAEjD,MAAM,UAAU,iBAAiB,WAAW;EAC5C,IAAI,YAAY,QAAW;GACzB,MAAM,MAAM,cAAc,OAAO;GACjC,IAAI,QAAQ,gBAAgB;IAC1B,iBAAiB;IACjB,MAAM;KAAE,MAAM;KAAW,OAAO;IAAQ;GAC1C;EACF;CACF,OAAO,IAAI,MAAM,SAAS,QACxB,QAAQ,MAAM;CAIlB,MAAM,MAAM,SAAS,aAAa,QAAQ,KAAK;AACjD;;AAGA,eAAe,SACb,MACA,QACA,OAC+B;CAC/B,MAAM,UAAU,gBAAgB,IAAI,CAAC,CAAC,KAAK;CAE3C,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,OAAO;CAC7B,SAAS,OAAO;EACd,OAAO;GACL,MAAM;GACN,OAAO;GACP,OAAO,IAAI,sBACT,8DACA,EAAE,MAAM,CACV;GACA;EACF;CACF;CAEA,MAAM,SAAS,MAAM,OAAO,YAAY,CAAC,SAAS,MAAM;CACxD,IAAI,YAAY,UAAU,OAAO,QAC/B,OAAO;EACL,MAAM;EACN,OAAO;EACP,OAAO,IAAI,sBACT,8DACA,EAAE,QAAQ,OAAO,OAAO,CAC1B;EACA;CACF;CAGF,OAAO;EAAE,MAAM;EAAQ,OAAO;EAAM,OAAQ,OAAwB;EAAO;CAAM;AACnF;;AAGA,eAAsB,oBACpB,QAC0D;CAC1D,IAAI;CACJ,WAAW,MAAM,SAAS,QACxB,IAAI,MAAM,SAAS,QAAQ,OAAO;CAEpC,IAAI,CAAC,MACH,MAAM,IAAI,sBAAsB,qDAAqD;CAEvF,OAAO;AACT;;AAGA,SAAS,gBAAgB,MAAsB;CAC7C,MAAM,SAAS,KAAK,MAAM,kCAAkC;CAC5D,OAAO,SAAS,OAAO,KAAK;AAC9B;AAEA,SAAS,cAAc,OAAwB;CAC7C,IAAI;EACF,OAAO,KAAK,UAAU,KAAK;CAC7B,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF"}
@@ -0,0 +1,4 @@
1
+ import { getObservers, isObserveAll, registerObserver, setObserveAll } from "./observer-registry.mjs";
2
+ import { notifyObservers, resolveObservers } from "./resolve-observers.mjs";
3
+
4
+ export { };
@@ -0,0 +1,30 @@
1
+ import { Observer } from "./observer.contract.mjs";
2
+
3
+ //#region ../@warlock.js/ai/src/observe/observer-registry.d.ts
4
+ /**
5
+ * Register a global {@link Observer}. Every flow that resolves to
6
+ * "observed" (via `observeAll` or `observe: true`) routes its completed
7
+ * report to it. An observability tool registers its collector here once,
8
+ * when its config is applied.
9
+ */
10
+ declare function registerObserver(observer: Observer): void;
11
+ /**
12
+ * The currently registered global observers. Returned as a read-only
13
+ * snapshot reference — callers must not mutate it; use
14
+ * {@link registerObserver} to add and {@link clearObservers} (test-only)
15
+ * to reset.
16
+ */
17
+ declare function getObservers(): readonly Observer[];
18
+ /**
19
+ * Set the global "observe every flow by default" flag. An observability
20
+ * tool flips this on when configured with its own observe-all option.
21
+ */
22
+ declare function setObserveAll(value: boolean): void;
23
+ /**
24
+ * Read the global "observe every flow by default" flag. Consulted by the
25
+ * observe-resolution helper when a flow left `observe` undefined.
26
+ */
27
+ declare function isObserveAll(): boolean;
28
+ //#endregion
29
+ export { getObservers, isObserveAll, registerObserver, setObserveAll };
30
+ //# sourceMappingURL=observer-registry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observer-registry.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/observe/observer-registry.ts"],"mappings":";;;;;AAwBA;;;;iBAAgB,gBAAA,CAAiB,QAAkB,EAAR,QAAQ;AAUnD;;;;AAAiD;AAQjD;AARA,iBAAgB,YAAA,aAAyB,QAAQ;;;AAQL;AAQ5C;iBARgB,aAAA,CAAc,KAAc;;;AAQhB;;iBAAZ,YAAA"}