@warlock.js/ai 4.1.1

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 (490) hide show
  1. package/README.md +72 -0
  2. package/cjs/index.cjs +8625 -0
  3. package/cjs/index.cjs.map +1 -0
  4. package/esm/agent/agent-config.type.d.mts +160 -0
  5. package/esm/agent/agent-config.type.d.mts.map +1 -0
  6. package/esm/agent/agent-input-builder.mjs +111 -0
  7. package/esm/agent/agent-input-builder.mjs.map +1 -0
  8. package/esm/agent/agent-log-event.mjs +101 -0
  9. package/esm/agent/agent-log-event.mjs.map +1 -0
  10. package/esm/agent/agent-stream.d.mts +47 -0
  11. package/esm/agent/agent-stream.d.mts.map +1 -0
  12. package/esm/agent/agent-stream.mjs +82 -0
  13. package/esm/agent/agent-stream.mjs.map +1 -0
  14. package/esm/agent/agent-to-stream-event.mjs +86 -0
  15. package/esm/agent/agent-to-stream-event.mjs.map +1 -0
  16. package/esm/agent/agent.d.mts +38 -0
  17. package/esm/agent/agent.d.mts.map +1 -0
  18. package/esm/agent/agent.mjs +974 -0
  19. package/esm/agent/agent.mjs.map +1 -0
  20. package/esm/agent/index.d.mts +3 -0
  21. package/esm/agent/index.mjs +4 -0
  22. package/esm/agent/json-stream-guard.mjs +400 -0
  23. package/esm/agent/json-stream-guard.mjs.map +1 -0
  24. package/esm/ai.d.mts +64 -0
  25. package/esm/ai.d.mts.map +1 -0
  26. package/esm/ai.mjs +65 -0
  27. package/esm/ai.mjs.map +1 -0
  28. package/esm/config.d.mts +79 -0
  29. package/esm/config.d.mts.map +1 -0
  30. package/esm/config.mjs +43 -0
  31. package/esm/config.mjs.map +1 -0
  32. package/esm/contracts/agent/agent-options.type.d.mts +132 -0
  33. package/esm/contracts/agent/agent-options.type.d.mts.map +1 -0
  34. package/esm/contracts/agent/agent.contract.d.mts +92 -0
  35. package/esm/contracts/agent/agent.contract.d.mts.map +1 -0
  36. package/esm/contracts/agent/index.d.mts +2 -0
  37. package/esm/contracts/attachment.type.d.mts +100 -0
  38. package/esm/contracts/attachment.type.d.mts.map +1 -0
  39. package/esm/contracts/content-part.type.d.mts +55 -0
  40. package/esm/contracts/content-part.type.d.mts.map +1 -0
  41. package/esm/contracts/conversation-message.type.d.mts +51 -0
  42. package/esm/contracts/conversation-message.type.d.mts.map +1 -0
  43. package/esm/contracts/embedder.contract.d.mts +69 -0
  44. package/esm/contracts/embedder.contract.d.mts.map +1 -0
  45. package/esm/contracts/end.type.d.mts +53 -0
  46. package/esm/contracts/end.type.d.mts.map +1 -0
  47. package/esm/contracts/end.type.mjs +47 -0
  48. package/esm/contracts/end.type.mjs.map +1 -0
  49. package/esm/contracts/events/agent-events.type.d.mts +71 -0
  50. package/esm/contracts/events/agent-events.type.d.mts.map +1 -0
  51. package/esm/contracts/events/complete-event.type.d.mts +33 -0
  52. package/esm/contracts/events/complete-event.type.d.mts.map +1 -0
  53. package/esm/contracts/events/event-identity.type.d.mts +30 -0
  54. package/esm/contracts/events/event-identity.type.d.mts.map +1 -0
  55. package/esm/contracts/events/event-map.type.d.mts +80 -0
  56. package/esm/contracts/events/event-map.type.d.mts.map +1 -0
  57. package/esm/contracts/events/index.d.mts +7 -0
  58. package/esm/contracts/events/supervisor-events.type.d.mts +162 -0
  59. package/esm/contracts/events/supervisor-events.type.d.mts.map +1 -0
  60. package/esm/contracts/events/usage-event.type.d.mts +39 -0
  61. package/esm/contracts/events/usage-event.type.d.mts.map +1 -0
  62. package/esm/contracts/events/workflow-events.type.d.mts +51 -0
  63. package/esm/contracts/events/workflow-events.type.d.mts.map +1 -0
  64. package/esm/contracts/executable.contract.d.mts +25 -0
  65. package/esm/contracts/executable.contract.d.mts.map +1 -0
  66. package/esm/contracts/finish-reason.type.d.mts +17 -0
  67. package/esm/contracts/finish-reason.type.d.mts.map +1 -0
  68. package/esm/contracts/index.d.mts +63 -0
  69. package/esm/contracts/middleware/index.d.mts +3 -0
  70. package/esm/contracts/middleware/middleware-context.type.d.mts +99 -0
  71. package/esm/contracts/middleware/middleware-context.type.d.mts.map +1 -0
  72. package/esm/contracts/middleware/middleware-state.type.d.mts +34 -0
  73. package/esm/contracts/middleware/middleware-state.type.d.mts.map +1 -0
  74. package/esm/contracts/middleware/middleware.contract.d.mts +140 -0
  75. package/esm/contracts/middleware/middleware.contract.d.mts.map +1 -0
  76. package/esm/contracts/model-tool-call-request.type.d.mts +58 -0
  77. package/esm/contracts/model-tool-call-request.type.d.mts.map +1 -0
  78. package/esm/contracts/model.contract.d.mts +164 -0
  79. package/esm/contracts/model.contract.d.mts.map +1 -0
  80. package/esm/contracts/placeholders.type.d.mts +23 -0
  81. package/esm/contracts/placeholders.type.d.mts.map +1 -0
  82. package/esm/contracts/result/agent-result.type.d.mts +33 -0
  83. package/esm/contracts/result/agent-result.type.d.mts.map +1 -0
  84. package/esm/contracts/result/attempt-entry.type.d.mts +40 -0
  85. package/esm/contracts/result/attempt-entry.type.d.mts.map +1 -0
  86. package/esm/contracts/result/base-report.type.d.mts +137 -0
  87. package/esm/contracts/result/base-report.type.d.mts.map +1 -0
  88. package/esm/contracts/result/base-report.type.mjs +17 -0
  89. package/esm/contracts/result/base-report.type.mjs.map +1 -0
  90. package/esm/contracts/result/base-result.type.d.mts +26 -0
  91. package/esm/contracts/result/base-result.type.d.mts.map +1 -0
  92. package/esm/contracts/result/execute-result.type.d.mts +40 -0
  93. package/esm/contracts/result/execute-result.type.d.mts.map +1 -0
  94. package/esm/contracts/result/execution-report.type.d.mts +50 -0
  95. package/esm/contracts/result/execution-report.type.d.mts.map +1 -0
  96. package/esm/contracts/result/index.d.mts +14 -0
  97. package/esm/contracts/result/llm-trip.type.d.mts +36 -0
  98. package/esm/contracts/result/llm-trip.type.d.mts.map +1 -0
  99. package/esm/contracts/result/model-pricing.type.d.mts +51 -0
  100. package/esm/contracts/result/model-pricing.type.d.mts.map +1 -0
  101. package/esm/contracts/result/session-send-result.type.d.mts +29 -0
  102. package/esm/contracts/result/session-send-result.type.d.mts.map +1 -0
  103. package/esm/contracts/result/step-result.type.d.mts +43 -0
  104. package/esm/contracts/result/step-result.type.d.mts.map +1 -0
  105. package/esm/contracts/result/supervisor-result.type.d.mts +86 -0
  106. package/esm/contracts/result/supervisor-result.type.d.mts.map +1 -0
  107. package/esm/contracts/result/tool-call.type.d.mts +44 -0
  108. package/esm/contracts/result/tool-call.type.d.mts.map +1 -0
  109. package/esm/contracts/result/usage.type.d.mts +57 -0
  110. package/esm/contracts/result/usage.type.d.mts.map +1 -0
  111. package/esm/contracts/result/workflow-result.type.d.mts +45 -0
  112. package/esm/contracts/result/workflow-result.type.d.mts.map +1 -0
  113. package/esm/contracts/sdk-adapter.contract.d.mts +77 -0
  114. package/esm/contracts/sdk-adapter.contract.d.mts.map +1 -0
  115. package/esm/contracts/stream/stream-event.type.d.mts +68 -0
  116. package/esm/contracts/stream/stream-event.type.d.mts.map +1 -0
  117. package/esm/contracts/stream/stream.contract.d.mts +61 -0
  118. package/esm/contracts/stream/stream.contract.d.mts.map +1 -0
  119. package/esm/contracts/streaming-tool-guard-config.type.d.mts +78 -0
  120. package/esm/contracts/streaming-tool-guard-config.type.d.mts.map +1 -0
  121. package/esm/contracts/supervisor/ack-entry.type.d.mts +97 -0
  122. package/esm/contracts/supervisor/ack-entry.type.d.mts.map +1 -0
  123. package/esm/contracts/supervisor/classifier-context.type.d.mts +189 -0
  124. package/esm/contracts/supervisor/classifier-context.type.d.mts.map +1 -0
  125. package/esm/contracts/supervisor/dispatch-context.type.d.mts +235 -0
  126. package/esm/contracts/supervisor/dispatch-context.type.d.mts.map +1 -0
  127. package/esm/contracts/supervisor/evaluate-context.type.d.mts +124 -0
  128. package/esm/contracts/supervisor/evaluate-context.type.d.mts.map +1 -0
  129. package/esm/contracts/supervisor/index.d.mts +16 -0
  130. package/esm/contracts/supervisor/intent-entry.type.d.mts +254 -0
  131. package/esm/contracts/supervisor/intent-entry.type.d.mts.map +1 -0
  132. package/esm/contracts/supervisor/iteration-snapshot.type.d.mts +117 -0
  133. package/esm/contracts/supervisor/iteration-snapshot.type.d.mts.map +1 -0
  134. package/esm/contracts/supervisor/next.type.d.mts +25 -0
  135. package/esm/contracts/supervisor/next.type.d.mts.map +1 -0
  136. package/esm/contracts/supervisor/route-context.type.d.mts +91 -0
  137. package/esm/contracts/supervisor/route-context.type.d.mts.map +1 -0
  138. package/esm/contracts/supervisor/router-entry.type.d.mts +67 -0
  139. package/esm/contracts/supervisor/router-entry.type.d.mts.map +1 -0
  140. package/esm/contracts/supervisor/supervisor-config.type.d.mts +356 -0
  141. package/esm/contracts/supervisor/supervisor-config.type.d.mts.map +1 -0
  142. package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts +90 -0
  143. package/esm/contracts/supervisor/supervisor-execute-options.type.d.mts.map +1 -0
  144. package/esm/contracts/supervisor/supervisor-input.type.d.mts +24 -0
  145. package/esm/contracts/supervisor/supervisor-input.type.d.mts.map +1 -0
  146. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts +49 -0
  147. package/esm/contracts/supervisor/supervisor-snapshot.type.d.mts.map +1 -0
  148. package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts +16 -0
  149. package/esm/contracts/supervisor/supervisor-stream-event.type.d.mts.map +1 -0
  150. package/esm/contracts/supervisor/supervisor.contract.d.mts +126 -0
  151. package/esm/contracts/supervisor/supervisor.contract.d.mts.map +1 -0
  152. package/esm/contracts/system-prompt.contract.d.mts +118 -0
  153. package/esm/contracts/system-prompt.contract.d.mts.map +1 -0
  154. package/esm/contracts/tool.contract.d.mts +161 -0
  155. package/esm/contracts/tool.contract.d.mts.map +1 -0
  156. package/esm/contracts/workflow/index.d.mts +6 -0
  157. package/esm/contracts/workflow/next-step-result.type.d.mts +17 -0
  158. package/esm/contracts/workflow/next-step-result.type.d.mts.map +1 -0
  159. package/esm/contracts/workflow/retry-config.type.d.mts +19 -0
  160. package/esm/contracts/workflow/retry-config.type.d.mts.map +1 -0
  161. package/esm/contracts/workflow/step.contract.d.mts +189 -0
  162. package/esm/contracts/workflow/step.contract.d.mts.map +1 -0
  163. package/esm/contracts/workflow/workflow-context.type.d.mts +45 -0
  164. package/esm/contracts/workflow/workflow-context.type.d.mts.map +1 -0
  165. package/esm/contracts/workflow/workflow-snapshot.type.d.mts +24 -0
  166. package/esm/contracts/workflow/workflow-snapshot.type.d.mts.map +1 -0
  167. package/esm/contracts/workflow/workflow.contract.d.mts +142 -0
  168. package/esm/contracts/workflow/workflow.contract.d.mts.map +1 -0
  169. package/esm/errors/agent-cancelled-error.d.mts +49 -0
  170. package/esm/errors/agent-cancelled-error.d.mts.map +1 -0
  171. package/esm/errors/agent-cancelled-error.mjs +43 -0
  172. package/esm/errors/agent-cancelled-error.mjs.map +1 -0
  173. package/esm/errors/agent-execution-error.d.mts +32 -0
  174. package/esm/errors/agent-execution-error.d.mts.map +1 -0
  175. package/esm/errors/agent-execution-error.mjs +35 -0
  176. package/esm/errors/agent-execution-error.mjs.map +1 -0
  177. package/esm/errors/agent-max-trips-error.d.mts +45 -0
  178. package/esm/errors/agent-max-trips-error.d.mts.map +1 -0
  179. package/esm/errors/agent-max-trips-error.mjs +41 -0
  180. package/esm/errors/agent-max-trips-error.mjs.map +1 -0
  181. package/esm/errors/ai-error.d.mts +94 -0
  182. package/esm/errors/ai-error.d.mts.map +1 -0
  183. package/esm/errors/ai-error.mjs +68 -0
  184. package/esm/errors/ai-error.mjs.map +1 -0
  185. package/esm/errors/budget-exceeded-error.d.mts +41 -0
  186. package/esm/errors/budget-exceeded-error.d.mts.map +1 -0
  187. package/esm/errors/budget-exceeded-error.mjs +31 -0
  188. package/esm/errors/budget-exceeded-error.mjs.map +1 -0
  189. package/esm/errors/content-filter-error.d.mts +33 -0
  190. package/esm/errors/content-filter-error.d.mts.map +1 -0
  191. package/esm/errors/content-filter-error.mjs +28 -0
  192. package/esm/errors/content-filter-error.mjs.map +1 -0
  193. package/esm/errors/context-length-exceeded-error.d.mts +38 -0
  194. package/esm/errors/context-length-exceeded-error.d.mts.map +1 -0
  195. package/esm/errors/context-length-exceeded-error.mjs +31 -0
  196. package/esm/errors/context-length-exceeded-error.mjs.map +1 -0
  197. package/esm/errors/error-category.type.d.mts +30 -0
  198. package/esm/errors/error-category.type.d.mts.map +1 -0
  199. package/esm/errors/error-code.type.d.mts +19 -0
  200. package/esm/errors/error-code.type.d.mts.map +1 -0
  201. package/esm/errors/guardrail-violation-error.d.mts +55 -0
  202. package/esm/errors/guardrail-violation-error.d.mts.map +1 -0
  203. package/esm/errors/guardrail-violation-error.mjs +41 -0
  204. package/esm/errors/guardrail-violation-error.mjs.map +1 -0
  205. package/esm/errors/index.d.mts +29 -0
  206. package/esm/errors/index.mjs +29 -0
  207. package/esm/errors/invalid-request-error.d.mts +27 -0
  208. package/esm/errors/invalid-request-error.d.mts.map +1 -0
  209. package/esm/errors/invalid-request-error.mjs +31 -0
  210. package/esm/errors/invalid-request-error.mjs.map +1 -0
  211. package/esm/errors/max-iterations-error.d.mts +31 -0
  212. package/esm/errors/max-iterations-error.d.mts.map +1 -0
  213. package/esm/errors/max-iterations-error.mjs +32 -0
  214. package/esm/errors/max-iterations-error.mjs.map +1 -0
  215. package/esm/errors/max-steps-exceeded-error.d.mts +20 -0
  216. package/esm/errors/max-steps-exceeded-error.d.mts.map +1 -0
  217. package/esm/errors/max-steps-exceeded-error.mjs +21 -0
  218. package/esm/errors/max-steps-exceeded-error.mjs.map +1 -0
  219. package/esm/errors/provider-auth-error.d.mts +22 -0
  220. package/esm/errors/provider-auth-error.d.mts.map +1 -0
  221. package/esm/errors/provider-auth-error.mjs +26 -0
  222. package/esm/errors/provider-auth-error.mjs.map +1 -0
  223. package/esm/errors/provider-error.d.mts +38 -0
  224. package/esm/errors/provider-error.d.mts.map +1 -0
  225. package/esm/errors/provider-error.mjs +42 -0
  226. package/esm/errors/provider-error.mjs.map +1 -0
  227. package/esm/errors/provider-rate-limit-error.d.mts +34 -0
  228. package/esm/errors/provider-rate-limit-error.d.mts.map +1 -0
  229. package/esm/errors/provider-rate-limit-error.mjs +31 -0
  230. package/esm/errors/provider-rate-limit-error.mjs.map +1 -0
  231. package/esm/errors/provider-timeout-error.d.mts +22 -0
  232. package/esm/errors/provider-timeout-error.d.mts.map +1 -0
  233. package/esm/errors/provider-timeout-error.mjs +26 -0
  234. package/esm/errors/provider-timeout-error.mjs.map +1 -0
  235. package/esm/errors/quota-exceeded-error.d.mts +36 -0
  236. package/esm/errors/quota-exceeded-error.d.mts.map +1 -0
  237. package/esm/errors/quota-exceeded-error.mjs +40 -0
  238. package/esm/errors/quota-exceeded-error.mjs.map +1 -0
  239. package/esm/errors/routing-error.d.mts +23 -0
  240. package/esm/errors/routing-error.d.mts.map +1 -0
  241. package/esm/errors/routing-error.mjs +23 -0
  242. package/esm/errors/routing-error.mjs.map +1 -0
  243. package/esm/errors/schema-validation-error.d.mts +40 -0
  244. package/esm/errors/schema-validation-error.d.mts.map +1 -0
  245. package/esm/errors/schema-validation-error.mjs +37 -0
  246. package/esm/errors/schema-validation-error.mjs.map +1 -0
  247. package/esm/errors/step-failed-error.d.mts +20 -0
  248. package/esm/errors/step-failed-error.d.mts.map +1 -0
  249. package/esm/errors/step-failed-error.mjs +19 -0
  250. package/esm/errors/step-failed-error.mjs.map +1 -0
  251. package/esm/errors/supervisor-cancelled-error.d.mts +29 -0
  252. package/esm/errors/supervisor-cancelled-error.d.mts.map +1 -0
  253. package/esm/errors/supervisor-cancelled-error.mjs +29 -0
  254. package/esm/errors/supervisor-cancelled-error.mjs.map +1 -0
  255. package/esm/errors/supervisor-drift-error.d.mts +31 -0
  256. package/esm/errors/supervisor-drift-error.d.mts.map +1 -0
  257. package/esm/errors/supervisor-drift-error.mjs +30 -0
  258. package/esm/errors/supervisor-drift-error.mjs.map +1 -0
  259. package/esm/errors/supervisor-failed-error.d.mts +40 -0
  260. package/esm/errors/supervisor-failed-error.d.mts.map +1 -0
  261. package/esm/errors/supervisor-failed-error.mjs +43 -0
  262. package/esm/errors/supervisor-failed-error.mjs.map +1 -0
  263. package/esm/errors/supervisor-routing-error.d.mts +44 -0
  264. package/esm/errors/supervisor-routing-error.d.mts.map +1 -0
  265. package/esm/errors/supervisor-routing-error.mjs +39 -0
  266. package/esm/errors/supervisor-routing-error.mjs.map +1 -0
  267. package/esm/errors/tool-execution-error.d.mts +35 -0
  268. package/esm/errors/tool-execution-error.d.mts.map +1 -0
  269. package/esm/errors/tool-execution-error.mjs +32 -0
  270. package/esm/errors/tool-execution-error.mjs.map +1 -0
  271. package/esm/errors/workflow-cancelled-error.d.mts +23 -0
  272. package/esm/errors/workflow-cancelled-error.d.mts.map +1 -0
  273. package/esm/errors/workflow-cancelled-error.mjs +23 -0
  274. package/esm/errors/workflow-cancelled-error.mjs.map +1 -0
  275. package/esm/errors/workflow-drift-error.d.mts +25 -0
  276. package/esm/errors/workflow-drift-error.d.mts.map +1 -0
  277. package/esm/errors/workflow-drift-error.mjs +24 -0
  278. package/esm/errors/workflow-drift-error.mjs.map +1 -0
  279. package/esm/errors/workflow-error.d.mts +15 -0
  280. package/esm/errors/workflow-error.d.mts.map +1 -0
  281. package/esm/errors/workflow-error.mjs +18 -0
  282. package/esm/errors/workflow-error.mjs.map +1 -0
  283. package/esm/index.d.mts +137 -0
  284. package/esm/index.mjs +81 -0
  285. package/esm/middleware/builtins/budget.d.mts +103 -0
  286. package/esm/middleware/builtins/budget.d.mts.map +1 -0
  287. package/esm/middleware/builtins/budget.mjs +100 -0
  288. package/esm/middleware/builtins/budget.mjs.map +1 -0
  289. package/esm/middleware/builtins/guardrail.d.mts +92 -0
  290. package/esm/middleware/builtins/guardrail.d.mts.map +1 -0
  291. package/esm/middleware/builtins/guardrail.mjs +76 -0
  292. package/esm/middleware/builtins/guardrail.mjs.map +1 -0
  293. package/esm/middleware/builtins/semantic-cache.d.mts +106 -0
  294. package/esm/middleware/builtins/semantic-cache.d.mts.map +1 -0
  295. package/esm/middleware/builtins/semantic-cache.mjs +149 -0
  296. package/esm/middleware/builtins/semantic-cache.mjs.map +1 -0
  297. package/esm/middleware/helpers/compose.d.mts +42 -0
  298. package/esm/middleware/helpers/compose.d.mts.map +1 -0
  299. package/esm/middleware/helpers/compose.mjs +52 -0
  300. package/esm/middleware/helpers/compose.mjs.map +1 -0
  301. package/esm/middleware/helpers/for-tool.d.mts +55 -0
  302. package/esm/middleware/helpers/for-tool.d.mts.map +1 -0
  303. package/esm/middleware/helpers/for-tool.mjs +80 -0
  304. package/esm/middleware/helpers/for-tool.mjs.map +1 -0
  305. package/esm/middleware/helpers/index.d.mts +2 -0
  306. package/esm/middleware/index.d.mts +8 -0
  307. package/esm/middleware/index.mjs +10 -0
  308. package/esm/middleware/pipeline.d.mts +70 -0
  309. package/esm/middleware/pipeline.d.mts.map +1 -0
  310. package/esm/middleware/pipeline.mjs +100 -0
  311. package/esm/middleware/pipeline.mjs.map +1 -0
  312. package/esm/middleware/utils/extract-user-text.d.mts +33 -0
  313. package/esm/middleware/utils/extract-user-text.d.mts.map +1 -0
  314. package/esm/middleware/utils/extract-user-text.mjs +40 -0
  315. package/esm/middleware/utils/extract-user-text.mjs.map +1 -0
  316. package/esm/middleware/utils/index.d.mts +2 -0
  317. package/esm/middleware/utils/namespaced-state.d.mts +60 -0
  318. package/esm/middleware/utils/namespaced-state.d.mts.map +1 -0
  319. package/esm/middleware/utils/namespaced-state.mjs +60 -0
  320. package/esm/middleware/utils/namespaced-state.mjs.map +1 -0
  321. package/esm/mock/index.d.mts +4 -0
  322. package/esm/mock/index.mjs +5 -0
  323. package/esm/mock/mock-agent.d.mts +41 -0
  324. package/esm/mock/mock-agent.d.mts.map +1 -0
  325. package/esm/mock/mock-agent.mjs +39 -0
  326. package/esm/mock/mock-agent.mjs.map +1 -0
  327. package/esm/mock/mock-config.type.d.mts +31 -0
  328. package/esm/mock/mock-config.type.d.mts.map +1 -0
  329. package/esm/mock/mock-model.d.mts +94 -0
  330. package/esm/mock/mock-model.d.mts.map +1 -0
  331. package/esm/mock/mock-model.mjs +150 -0
  332. package/esm/mock/mock-model.mjs.map +1 -0
  333. package/esm/mock/mock-sdk.d.mts +25 -0
  334. package/esm/mock/mock-sdk.d.mts.map +1 -0
  335. package/esm/mock/mock-sdk.mjs +37 -0
  336. package/esm/mock/mock-sdk.mjs.map +1 -0
  337. package/esm/supervisor/as-tool.d.mts +45 -0
  338. package/esm/supervisor/as-tool.d.mts.map +1 -0
  339. package/esm/supervisor/as-tool.mjs +80 -0
  340. package/esm/supervisor/as-tool.mjs.map +1 -0
  341. package/esm/supervisor/cancellation.d.mts +12 -0
  342. package/esm/supervisor/cancellation.d.mts.map +1 -0
  343. package/esm/supervisor/cancellation.mjs +22 -0
  344. package/esm/supervisor/cancellation.mjs.map +1 -0
  345. package/esm/supervisor/decide.mjs +272 -0
  346. package/esm/supervisor/decide.mjs.map +1 -0
  347. package/esm/supervisor/emitter.d.mts +27 -0
  348. package/esm/supervisor/emitter.d.mts.map +1 -0
  349. package/esm/supervisor/emitter.mjs +47 -0
  350. package/esm/supervisor/emitter.mjs.map +1 -0
  351. package/esm/supervisor/entries.d.mts +141 -0
  352. package/esm/supervisor/entries.d.mts.map +1 -0
  353. package/esm/supervisor/entries.mjs +206 -0
  354. package/esm/supervisor/entries.mjs.map +1 -0
  355. package/esm/supervisor/execution.d.mts +637 -0
  356. package/esm/supervisor/execution.d.mts.map +1 -0
  357. package/esm/supervisor/execution.mjs +1868 -0
  358. package/esm/supervisor/execution.mjs.map +1 -0
  359. package/esm/supervisor/index.d.mts +11 -0
  360. package/esm/supervisor/index.mjs +12 -0
  361. package/esm/supervisor/router-prompt.d.mts +56 -0
  362. package/esm/supervisor/router-prompt.d.mts.map +1 -0
  363. package/esm/supervisor/router-prompt.mjs +52 -0
  364. package/esm/supervisor/router-prompt.mjs.map +1 -0
  365. package/esm/supervisor/signature.d.mts +28 -0
  366. package/esm/supervisor/signature.d.mts.map +1 -0
  367. package/esm/supervisor/signature.mjs +89 -0
  368. package/esm/supervisor/signature.mjs.map +1 -0
  369. package/esm/supervisor/snapshot.d.mts +54 -0
  370. package/esm/supervisor/snapshot.d.mts.map +1 -0
  371. package/esm/supervisor/snapshot.mjs +77 -0
  372. package/esm/supervisor/snapshot.mjs.map +1 -0
  373. package/esm/supervisor/supervisor-stream.d.mts +29 -0
  374. package/esm/supervisor/supervisor-stream.d.mts.map +1 -0
  375. package/esm/supervisor/supervisor-stream.mjs +89 -0
  376. package/esm/supervisor/supervisor-stream.mjs.map +1 -0
  377. package/esm/supervisor/supervisor.d.mts +27 -0
  378. package/esm/supervisor/supervisor.d.mts.map +1 -0
  379. package/esm/supervisor/supervisor.mjs +138 -0
  380. package/esm/supervisor/supervisor.mjs.map +1 -0
  381. package/esm/system-prompt/instruction.d.mts +52 -0
  382. package/esm/system-prompt/instruction.d.mts.map +1 -0
  383. package/esm/system-prompt/instruction.mjs +57 -0
  384. package/esm/system-prompt/instruction.mjs.map +1 -0
  385. package/esm/system-prompt/persona.d.mts +52 -0
  386. package/esm/system-prompt/persona.d.mts.map +1 -0
  387. package/esm/system-prompt/persona.mjs +57 -0
  388. package/esm/system-prompt/persona.mjs.map +1 -0
  389. package/esm/system-prompt/render-placeholders.d.mts +31 -0
  390. package/esm/system-prompt/render-placeholders.d.mts.map +1 -0
  391. package/esm/system-prompt/render-placeholders.mjs +58 -0
  392. package/esm/system-prompt/render-placeholders.mjs.map +1 -0
  393. package/esm/system-prompt/system-prompt.d.mts +117 -0
  394. package/esm/system-prompt/system-prompt.d.mts.map +1 -0
  395. package/esm/system-prompt/system-prompt.mjs +137 -0
  396. package/esm/system-prompt/system-prompt.mjs.map +1 -0
  397. package/esm/tool/index.d.mts +1 -0
  398. package/esm/tool/index.mjs +3 -0
  399. package/esm/tool/tool.d.mts +64 -0
  400. package/esm/tool/tool.d.mts.map +1 -0
  401. package/esm/tool/tool.mjs +184 -0
  402. package/esm/tool/tool.mjs.map +1 -0
  403. package/esm/utils/compute-cost.d.mts +58 -0
  404. package/esm/utils/compute-cost.d.mts.map +1 -0
  405. package/esm/utils/compute-cost.mjs +87 -0
  406. package/esm/utils/compute-cost.mjs.map +1 -0
  407. package/esm/utils/extract-json-payload.d.mts +33 -0
  408. package/esm/utils/extract-json-payload.d.mts.map +1 -0
  409. package/esm/utils/extract-json-payload.mjs +39 -0
  410. package/esm/utils/extract-json-payload.mjs.map +1 -0
  411. package/esm/utils/generate-run-id.d.mts +20 -0
  412. package/esm/utils/generate-run-id.d.mts.map +1 -0
  413. package/esm/utils/generate-run-id.mjs +23 -0
  414. package/esm/utils/generate-run-id.mjs.map +1 -0
  415. package/esm/utils/index.d.mts +9 -0
  416. package/esm/utils/index.mjs +11 -0
  417. package/esm/utils/json-schema.d.mts +57 -0
  418. package/esm/utils/json-schema.d.mts.map +1 -0
  419. package/esm/utils/json-schema.mjs +89 -0
  420. package/esm/utils/json-schema.mjs.map +1 -0
  421. package/esm/utils/prepare-attachment-part.d.mts +36 -0
  422. package/esm/utils/prepare-attachment-part.d.mts.map +1 -0
  423. package/esm/utils/prepare-attachment-part.mjs +140 -0
  424. package/esm/utils/prepare-attachment-part.mjs.map +1 -0
  425. package/esm/utils/resolve-attachment.d.mts +33 -0
  426. package/esm/utils/resolve-attachment.d.mts.map +1 -0
  427. package/esm/utils/resolve-attachment.mjs +73 -0
  428. package/esm/utils/resolve-attachment.mjs.map +1 -0
  429. package/esm/utils/safe-json-parse.d.mts +14 -0
  430. package/esm/utils/safe-json-parse.d.mts.map +1 -0
  431. package/esm/utils/safe-json-parse.mjs +22 -0
  432. package/esm/utils/safe-json-parse.mjs.map +1 -0
  433. package/esm/utils/stamp-report-lineage.d.mts +61 -0
  434. package/esm/utils/stamp-report-lineage.d.mts.map +1 -0
  435. package/esm/utils/stamp-report-lineage.mjs +47 -0
  436. package/esm/utils/stamp-report-lineage.mjs.map +1 -0
  437. package/esm/utils/token-count.d.mts +15 -0
  438. package/esm/utils/token-count.d.mts.map +1 -0
  439. package/esm/utils/token-count.mjs +18 -0
  440. package/esm/utils/token-count.mjs.map +1 -0
  441. package/esm/workflow/as-tool.mjs +55 -0
  442. package/esm/workflow/as-tool.mjs.map +1 -0
  443. package/esm/workflow/cancellation.mjs +44 -0
  444. package/esm/workflow/cancellation.mjs.map +1 -0
  445. package/esm/workflow/emitter.mjs +40 -0
  446. package/esm/workflow/emitter.mjs.map +1 -0
  447. package/esm/workflow/engine.mjs +362 -0
  448. package/esm/workflow/engine.mjs.map +1 -0
  449. package/esm/workflow/index.d.mts +3 -0
  450. package/esm/workflow/index.mjs +5 -0
  451. package/esm/workflow/retry.mjs +32 -0
  452. package/esm/workflow/retry.mjs.map +1 -0
  453. package/esm/workflow/router.mjs +56 -0
  454. package/esm/workflow/router.mjs.map +1 -0
  455. package/esm/workflow/run-scoped-emitter.mjs +32 -0
  456. package/esm/workflow/run-scoped-emitter.mjs.map +1 -0
  457. package/esm/workflow/signature.d.mts +7 -0
  458. package/esm/workflow/signature.d.mts.map +1 -0
  459. package/esm/workflow/signature.mjs +34 -0
  460. package/esm/workflow/signature.mjs.map +1 -0
  461. package/esm/workflow/snapshot.mjs +71 -0
  462. package/esm/workflow/snapshot.mjs.map +1 -0
  463. package/esm/workflow/state.mjs +37 -0
  464. package/esm/workflow/state.mjs.map +1 -0
  465. package/esm/workflow/step-runner.mjs +371 -0
  466. package/esm/workflow/step-runner.mjs.map +1 -0
  467. package/esm/workflow/step.d.mts +19 -0
  468. package/esm/workflow/step.d.mts.map +1 -0
  469. package/esm/workflow/step.mjs +37 -0
  470. package/esm/workflow/step.mjs.map +1 -0
  471. package/esm/workflow/workflow.d.mts +12 -0
  472. package/esm/workflow/workflow.d.mts.map +1 -0
  473. package/esm/workflow/workflow.mjs +116 -0
  474. package/esm/workflow/workflow.mjs.map +1 -0
  475. package/llms-full.txt +2293 -0
  476. package/llms.txt +20 -0
  477. package/package.json +37 -0
  478. package/skills/README.md +53 -0
  479. package/skills/ai-basics/SKILL.md +95 -0
  480. package/skills/attach-ai-middleware/SKILL.md +184 -0
  481. package/skills/define-ai-tool/SKILL.md +186 -0
  482. package/skills/embed-text/SKILL.md +105 -0
  483. package/skills/handle-ai-errors/SKILL.md +194 -0
  484. package/skills/log-ai-calls/SKILL.md +141 -0
  485. package/skills/persist-ai-data/SKILL.md +207 -0
  486. package/skills/pick-ai-provider/SKILL.md +164 -0
  487. package/skills/run-ai-agent/SKILL.md +267 -0
  488. package/skills/run-ai-workflow/SKILL.md +258 -0
  489. package/skills/run-supervisor/SKILL.md +309 -0
  490. package/skills/write-system-prompt/SKILL.md +129 -0
@@ -0,0 +1,26 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+
4
+ //#region ../../@warlock.js/ai/src/contracts/result/base-result.type.d.ts
5
+ /**
6
+ * Minimal shape every execution result satisfies. Used as the upper
7
+ * bound on `ExecutableContract`'s `TResult` generic so the contract
8
+ * can promise the fields every caller needs regardless of which
9
+ * primitive ran.
10
+ *
11
+ * Timing metadata now lives on each primitive's `report` field (see
12
+ * `ExecutionReport`); `duration` was removed from this base to avoid
13
+ * two sources of truth.
14
+ *
15
+ * @example
16
+ * function summarize(result: BaseResult) {
17
+ * console.log(`${result.usage.total} tokens, ${result.error ? "failed" : "ok"}`);
18
+ * }
19
+ */
20
+ type BaseResult = {
21
+ /** Typed AI error if the execution failed, undefined on success. */error?: AIError; /** Aggregated token usage across the execution. */
22
+ usage: Usage;
23
+ };
24
+ //#endregion
25
+ export { BaseResult };
26
+ //# sourceMappingURL=base-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/base-result.type.ts"],"mappings":";;;;;;AAkBA;;;;;;;;;AAIc;;;;KAJF,UAAA;sEAEV,KAAA,GAAQ,OAAA;EAER,KAAA,EAAO,KAAK;AAAA"}
@@ -0,0 +1,40 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+ import { BaseReport } from "./base-report.type.mjs";
4
+
5
+ //#region ../../@warlock.js/ai/src/contracts/result/execute-result.type.d.ts
6
+ /**
7
+ * Unified result envelope returned by every executable primitive —
8
+ * `tool.invoke()`, `agent.execute()`, `workflow.execute()`,
9
+ * `supervisor.execute()`. Per-primitive result types
10
+ * (`AgentResult`, `WorkflowResult`, `SupervisorResult`,
11
+ * `ToolInvokeResult`) all satisfy this shape and add their own
12
+ * discriminator / domain-specific fields.
13
+ *
14
+ * `usage` and `report` are **required** on every invocation, including
15
+ * leaf tools — the framework synthesizes a trivial report for tools
16
+ * (type `"tool"`, empty children, zero usage, real timing) so
17
+ * consumers never have to nil-check the presence of a report.
18
+ *
19
+ * Recursion happens inside `report.children[]` — parent walks the
20
+ * report tree top-down to see every child executable that ran.
21
+ *
22
+ * @example
23
+ * const { data, usage, report, error } = await executable.execute(input);
24
+ *
25
+ * if (error) {
26
+ * logger.error(error.code, { runId: report.runId, duration: report.duration });
27
+ * return;
28
+ * }
29
+ *
30
+ * console.log(`spent ${usage.total} tokens across ${report.children.length} children`);
31
+ */
32
+ type ExecuteResult<TData = unknown> = {
33
+ /** Typed output if the execution succeeded. */data?: TData; /** Typed AI error if the execution failed, undefined on success. */
34
+ error?: AIError; /** Rolled-up usage (own + sum of children). Always present. */
35
+ usage: Usage; /** Recursive execution report — `report.children[]` carries nested executables. */
36
+ report: BaseReport;
37
+ };
38
+ //#endregion
39
+ export { ExecuteResult };
40
+ //# sourceMappingURL=execute-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/execute-result.type.ts"],"mappings":";;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;AAQoB;;;;;KARR,aAAA;iDAEV,IAAA,GAAO,KAAA;EAEP,KAAA,GAAQ,OAAA;EAER,KAAA,EAAO,KAAA;EAEP,MAAA,EAAQ,UAAA;AAAA"}
@@ -0,0 +1,50 @@
1
+ import { BaseReport, ReportStatus } from "./base-report.type.mjs";
2
+ import { LLMTrip } from "./llm-trip.type.mjs";
3
+
4
+ //#region ../../@warlock.js/ai/src/contracts/result/execution-report.type.d.ts
5
+ /**
6
+ * Terminal status alias retained for backwards-compatibility with
7
+ * existing imports. Use {@link ReportStatus} directly for new code —
8
+ * both point at the same unified union across every primitive.
9
+ */
10
+ type ExecutionStatus = ReportStatus;
11
+ /**
12
+ * Alias kept for callers referencing the pre-3.1 shared timing block.
13
+ * Structurally a {@link BaseReport} — use that for new code.
14
+ */
15
+ type ExecutionReport = BaseReport;
16
+ /**
17
+ * Agent-specific execution report — {@link BaseReport} plus the LLM
18
+ * trip history for a single `agent.execute()` call.
19
+ *
20
+ * Tool dispatches that previously lived under `toolCalls[]` are now
21
+ * reported as child `BaseReport` nodes on
22
+ * {@link BaseReport.children} — filter by `type === "tool"` to isolate
23
+ * leaf tool calls, or walk the full tree to see every nested
24
+ * executable. Trips stay here because they describe the agent's
25
+ * **internal** turn structure (LLM round-trips), not child executions.
26
+ *
27
+ * @example
28
+ * const { report } = await agent.execute("hi");
29
+ * console.log(report.status, report.duration, report.trips.length);
30
+ *
31
+ * const toolCalls = report.children.filter((c) => c.type === "tool");
32
+ * const nestedAgents = report.children.filter((c) => c.type === "agent");
33
+ */
34
+ type AgentReport = BaseReport & {
35
+ /**
36
+ * Identity of the model the agent ran against. Captured from the
37
+ * `ModelContract` at result-build time so consumers can attribute
38
+ * cost, latency, and behavior to the right upstream — especially
39
+ * useful when the same provider package fronts multiple labels
40
+ * (e.g. `openai` vs `openrouter` vs `azure` via the OpenAI adapter).
41
+ */
42
+ model: {
43
+ name: string;
44
+ provider: string;
45
+ }; /** Every LLM round-trip that happened during execution. */
46
+ trips: LLMTrip[];
47
+ };
48
+ //#endregion
49
+ export { AgentReport, ExecutionReport, ExecutionStatus };
50
+ //# sourceMappingURL=execution-report.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-report.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/execution-report.type.ts"],"mappings":";;;;;;AAQA;;;KAAY,eAAA,GAAkB,YAAY;AAAA;AAM1C;;;AAN0C,KAM9B,eAAA,GAAkB,UAAU;AAAA;AAoBxC;;;;;;;;;;;AAUgB;;;;;;AA9BwB,KAoB5B,WAAA,GAAc,UAAA;;;;;;;;EAQxB,KAAA;IAAS,IAAA;IAAc,QAAA;EAAA;EAEvB,KAAA,EAAO,OAAO;AAAA"}
@@ -0,0 +1,14 @@
1
+ import { ModelPricing } from "./model-pricing.type.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+ import { BaseResult } from "./base-result.type.mjs";
4
+ import { AttemptEntry } from "./attempt-entry.type.mjs";
5
+ import { BaseReport, REPORT_SCHEMA_VERSION, ReportStatus, ReportType } from "./base-report.type.mjs";
6
+ import { ToolCall } from "./tool-call.type.mjs";
7
+ import { LLMTrip } from "./llm-trip.type.mjs";
8
+ import { AgentReport, ExecutionReport, ExecutionStatus } from "./execution-report.type.mjs";
9
+ import { AgentResult } from "./agent-result.type.mjs";
10
+ import { ExecuteResult } from "./execute-result.type.mjs";
11
+ import { StepSnapshot } from "./step-result.type.mjs";
12
+ import { WorkflowReport, WorkflowResult } from "./workflow-result.type.mjs";
13
+ import { SupervisorReport, SupervisorResult, SupervisorTerminatedBy } from "./supervisor-result.type.mjs";
14
+ import { SessionSendResult } from "./session-send-result.type.mjs";
@@ -0,0 +1,36 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+ import { FinishReason } from "../finish-reason.type.mjs";
4
+ import { ToolCall } from "./tool-call.type.mjs";
5
+
6
+ //#region ../../@warlock.js/ai/src/contracts/result/llm-trip.type.d.ts
7
+ /**
8
+ * A single LLM round-trip within an agent execution.
9
+ * An agent may make multiple trips when tools are called.
10
+ *
11
+ * @example
12
+ * const trip: LLMTrip = {
13
+ * index: 0,
14
+ * input: "Search for the latest AI news",
15
+ * output: "I'll search for that...",
16
+ * finishReason: "tool_calls",
17
+ * duration: 850,
18
+ * usage: { input: 120, output: 45, total: 165 },
19
+ * toolCalls: [{ tripIndex: 0, name: "searchWeb", input: {...}, duration: 300 }],
20
+ * };
21
+ */
22
+ type LLMTrip = {
23
+ /** 0-indexed position of this trip in the execution sequence */index: number; /** The prompt/input sent to the LLM for this trip */
24
+ input: string; /** The raw text output from the LLM */
25
+ output: string; /** Why the LLM stopped generating */
26
+ finishReason: FinishReason; /** ISO-8601 timestamp when this trip's model call started */
27
+ startedAt: string; /** ISO-8601 timestamp when this trip finished (post tool dispatch) */
28
+ endedAt: string; /** Duration of this trip in milliseconds */
29
+ duration: number; /** Token usage for this trip */
30
+ usage: Usage; /** Tool calls made during this trip, if any */
31
+ toolCalls?: ToolCall[]; /** Typed AI error that occurred during this trip, if any */
32
+ error?: AIError;
33
+ };
34
+ //#endregion
35
+ export { LLMTrip };
36
+ //# sourceMappingURL=llm-trip.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-trip.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/llm-trip.type.ts"],"mappings":";;;;;;;;AAoBA;;;;;;;;;;;;;KAAY,OAAA;EAUV,gEARA,KAAA,UAYA;EAVA,KAAA,UAYO;EAVP,MAAA,UAYY;EAVZ,YAAA,EAAc,YAAA,EAYN;EAVR,SAAA,UAUe;EARf,OAAA;EAEA,QAAA;EAEA,KAAA,EAAO,KAAA;EAEP,SAAA,GAAY,QAAA;EAEZ,KAAA,GAAQ,OAAA;AAAA"}
@@ -0,0 +1,51 @@
1
+ //#region ../../@warlock.js/ai/src/contracts/result/model-pricing.type.d.ts
2
+ /**
3
+ * Per-million-token USD pricing for a model. All values are in USD per
4
+ * 1,000,000 tokens — the industry-standard unit. Used by the framework
5
+ * to compute `Usage.costUSD` at emit time, so stored reports carry
6
+ * historical cost (not re-derived against today's pricing).
7
+ *
8
+ * **Optionality.** Every field except `input` / `output` is optional.
9
+ * `cachedInput` / `cachedOutput` are populated only when the provider
10
+ * actually meters them (OpenAI prompt-cache hits, Anthropic cache
11
+ * reads / writes). Leave undefined for adapters that don't report a
12
+ * cache channel — cost falls back to full-rate pricing for those
13
+ * tokens.
14
+ *
15
+ * **Where it lives.** Two declaration sites, both optional:
16
+ *
17
+ * 1. `SDK.pricing` — a registry keyed by model name. One source of
18
+ * truth per provider; matches how providers publish pricing tables.
19
+ * 2. `model({ pricing })` — per-model override at instantiation. Wins
20
+ * over the SDK-level entry. Critical for multi-tenant projects
21
+ * where pricing is contract-specific or runtime-resolved.
22
+ *
23
+ * Resolution order: per-model > SDK registry > undefined (no cost
24
+ * computed).
25
+ *
26
+ * @example
27
+ * const pricing: ModelPricing = {
28
+ * input: 0.15,
29
+ * output: 0.6,
30
+ * cachedInput: 0.075,
31
+ * };
32
+ */
33
+ type ModelPricing = {
34
+ /** USD per 1M input tokens. */input: number; /** USD per 1M output tokens. */
35
+ output: number;
36
+ /**
37
+ * USD per 1M input tokens served from the provider's prompt cache.
38
+ * Typically a fraction of `input`. Falls back to `input` when
39
+ * undefined.
40
+ */
41
+ cachedInput?: number;
42
+ /**
43
+ * USD per 1M tokens written to the provider's prompt cache.
44
+ * Anthropic charges a small premium on cache-write tokens; OpenAI
45
+ * does not. Falls back to `output` when undefined.
46
+ */
47
+ cachedOutput?: number;
48
+ };
49
+ //#endregion
50
+ export { ModelPricing };
51
+ //# sourceMappingURL=model-pricing.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-pricing.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/model-pricing.type.ts"],"mappings":";;AA+BA;;;;;;;;;AAgBc;;;;;;;;;;;;;;;;;;;;;KAhBF,YAAA;iCAEV,KAAA;EAEA,MAAA;;;;;;EAMA,WAAA;;;;;;EAMA,YAAA;AAAA"}
@@ -0,0 +1,29 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+ import { AgentResult } from "./agent-result.type.mjs";
4
+ import { WorkflowResult } from "./workflow-result.type.mjs";
5
+ import { SupervisorResult } from "./supervisor-result.type.mjs";
6
+
7
+ //#region ../../@warlock.js/ai/src/contracts/result/session-send-result.type.d.ts
8
+ /**
9
+ * Result returned by SessionContract.send().
10
+ * Narrows executionResult by checking the `type` discriminant.
11
+ *
12
+ * @example
13
+ * const result = await session.send("Analyze this dataset");
14
+ * if (result.executionResult.type === "agent") {
15
+ * console.log(result.executionResult.report.trips.length, "trips");
16
+ * } else if (result.executionResult.type === "workflow") {
17
+ * console.log(Object.keys(result.executionResult.steps), "steps ran");
18
+ * }
19
+ */
20
+ type SessionSendResult = {
21
+ /** Final text response to display to the user */response: string; /** Whether the session is complete (no more turns expected) */
22
+ done: boolean; /** Typed AI error if the session turn failed */
23
+ error?: AIError; /** Full execution result — narrow by `.executionResult.type` */
24
+ executionResult: AgentResult<unknown> | SupervisorResult<unknown> | WorkflowResult<unknown>; /** Aggregated token usage for this turn */
25
+ usage: Usage;
26
+ };
27
+ //#endregion
28
+ export { SessionSendResult };
29
+ //# sourceMappingURL=session-send-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-send-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/session-send-result.type.ts"],"mappings":";;;;;;;;;AAkBA;;;;;;;;;;KAAY,iBAAA;EAIV,iDAFA,QAAA,UAIQ;EAFR,IAAA,WAKI;EAHJ,KAAA,GAAQ,OAAA,EAKJ;EAHJ,eAAA,EACI,WAAA,YACA,gBAAA,YACA,cAAA,WAEG;EAAP,KAAA,EAAO,KAAA;AAAA"}
@@ -0,0 +1,43 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { Usage } from "./usage.type.mjs";
3
+ import { AttemptEntry } from "./attempt-entry.type.mjs";
4
+ import { AgentReport } from "./execution-report.type.mjs";
5
+ import { AgentResult } from "./agent-result.type.mjs";
6
+
7
+ //#region ../../@warlock.js/ai/src/contracts/result/step-result.type.d.ts
8
+ /**
9
+ * Frozen snapshot of a completed workflow step, stored under
10
+ * `WorkflowReport.steps[name]` and `ctx.steps[name]`.
11
+ *
12
+ * For agent-backed steps, three forensic fields are surfaced at the
13
+ * top level for easy inspection:
14
+ *
15
+ * - `agentReport` — trips, tool calls, status, timing for the agent
16
+ * call that produced this step's output. Mirrors
17
+ * `executionResult.report` but is directly reachable without
18
+ * narrowing the union.
19
+ * - `agentUsage` — token counts for this step in isolation. Sum of
20
+ * all `steps[*].agentUsage` equals the workflow-level `usage`.
21
+ * - `executionResult` — the full `AgentResult` (or custom `run`
22
+ * return value). Use this when you need `data` / `text` / `error`
23
+ * alongside the report.
24
+ */
25
+ type StepSnapshot = Readonly<{
26
+ output: unknown;
27
+ skipped: boolean;
28
+ status: "completed" | "skipped" | "failed";
29
+ startedAt: string;
30
+ endedAt: string;
31
+ duration: number;
32
+ attempts: number;
33
+ attemptHistory: AttemptEntry[];
34
+ error?: AIError;
35
+ state: Readonly<Record<string, unknown>>; /** Full agent result when the step ran an agent; absent for `run` / skipped / parallel steps. */
36
+ executionResult?: AgentResult<unknown>; /** Shortcut: `executionResult.report` when present. */
37
+ agentReport?: AgentReport; /** Shortcut: `executionResult.usage` when present. */
38
+ agentUsage?: Usage; /** Nested children for parallel steps. */
39
+ steps?: Record<string, StepSnapshot>;
40
+ }>;
41
+ //#endregion
42
+ export { StepSnapshot };
43
+ //# sourceMappingURL=step-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/step-result.type.ts"],"mappings":";;;;;;;;AAyBA;;;;;;;;;;;;;;;;KAAY,YAAA,GAAe,QAAA;EACzB,MAAA;EACA,OAAA;EACA,MAAA;EACA,SAAA;EACA,OAAA;EACA,QAAA;EACA,QAAA;EACA,cAAA,EAAgB,YAAA;EAChB,KAAA,GAAQ,OAAA;EACR,KAAA,EAAO,QAAA,CAAS,MAAA,oBAAhB;EAEA,eAAA,GAAkB,WAAA,WAFF;EAIhB,WAAA,GAAc,WAAA,EAFI;EAIlB,UAAA,GAAa,KAAA,EAFC;EAId,KAAA,GAAQ,MAAA,SAAe,YAAA;AAAA"}
@@ -0,0 +1,86 @@
1
+ import { BaseResult } from "./base-result.type.mjs";
2
+ import { BaseReport } from "./base-report.type.mjs";
3
+ import { AckSnapshot, IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs";
4
+ import { ClassifierSnapshot } from "../supervisor/classifier-context.type.mjs";
5
+
6
+ //#region ../../@warlock.js/ai/src/contracts/result/supervisor-result.type.d.ts
7
+ /**
8
+ * How the supervisor decided to stop iterating. Recorded so log and
9
+ * dashboard queries can slice "ended because router said END" from
10
+ * "ran out of iterations" from "user aborted" without re-reading the
11
+ * error object.
12
+ */
13
+ type SupervisorTerminatedBy = "router" | "route" | "classifier" | "evaluate" | "max-iterations" | "cancelled" | "error";
14
+ /**
15
+ * Supervisor-specific execution report. Extends {@link BaseReport}
16
+ * with supervisor-only fields — iteration count, termination reason,
17
+ * per-iteration snapshots — while sharing the canonical timing,
18
+ * status, usage, and recursive `children[]` block with every other
19
+ * primitive.
20
+ *
21
+ * `snapshots` remains the primary iteration-granularity debug artifact
22
+ * — every routing decision, every dispatch, every evaluate verdict.
23
+ * The cross-cutting view of "which executables ran underneath" lives
24
+ * on {@link BaseReport.children}, which duplicates nothing: it's the
25
+ * reports of the child agents/workflows dispatched across iterations.
26
+ */
27
+ type SupervisorReport = BaseReport & {
28
+ supervisorName: string; /** Structural fingerprint — same value exposed on the instance. */
29
+ signature: string;
30
+ terminatedBy: SupervisorTerminatedBy; /** How many iterations ran (including the terminal one). */
31
+ iterations: number; /** ISO-8601 timestamp when a cancellation was observed, if any. */
32
+ cancelledAt?: string;
33
+ snapshots: IterationSnapshot[];
34
+ /**
35
+ * Receptionist (`ackAgent`) forensic record. Present only when an
36
+ * ack agent was configured AND the run started fresh (resumes don't
37
+ * re-fire ack). The ack agent's full report node also lives under
38
+ * `children[]` like any other dispatched agent.
39
+ */
40
+ ack?: AckSnapshot;
41
+ /**
42
+ * Classifier (Phase 7 / decisions §37) forensic record. Present
43
+ * only when `SupervisorConfig.classifier` was configured AND the
44
+ * run started fresh (resumes don't re-fire classifier). Sibling of
45
+ * `ack` — full forensic detail regardless of what strip-merged
46
+ * into state. Distinct from the children list — classifier runs
47
+ * are not also pushed onto `children[]`.
48
+ */
49
+ classifier?: ClassifierSnapshot;
50
+ };
51
+ /**
52
+ * Result returned by `supervisor.execute()` and resolved by
53
+ * `stream.result`. Canonical destructure —
54
+ * `const { data, report, usage, error } = await supervisor.execute(...)` —
55
+ * mirrors agent and workflow so nested composition feels uniform.
56
+ *
57
+ * `data` populates only on successful completion of a supervisor
58
+ * configured with `output`. On failure or cancellation it is
59
+ * `undefined`; `error` carries the typed cause and `report.status`
60
+ * narrows further.
61
+ *
62
+ * `usage` is rolled up from every child executable this supervisor
63
+ * ran (router agent, dispatched agents/workflows, evaluate agent) —
64
+ * see {@link BaseReport} rollup semantics.
65
+ *
66
+ * @example
67
+ * const { data, report, usage, error } = await supervisor.execute(input);
68
+ *
69
+ * if (error) {
70
+ * logger.error(error.code, {
71
+ * terminatedBy: report.terminatedBy,
72
+ * iterations: report.iterations,
73
+ * });
74
+ * return;
75
+ * }
76
+ *
77
+ * return { answer: data, cost: usage.total, turns: report.iterations };
78
+ */
79
+ type SupervisorResult<TOutput = unknown> = BaseResult & {
80
+ /** Discriminant for narrowing `SessionSendResult.executionResult`. */type: "supervisor";
81
+ data?: TOutput;
82
+ report: SupervisorReport;
83
+ };
84
+ //#endregion
85
+ export { SupervisorReport, SupervisorResult, SupervisorTerminatedBy };
86
+ //# sourceMappingURL=supervisor-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/supervisor-result.type.ts"],"mappings":";;;;;;;;AAWA;;;;KAAY,sBAAA;AAsBZ;;;;;;;;;;;;;AAAA,KAAY,gBAAA,GAAmB,UAAA;EAC7B,cAAA,UAKA;EAHA,SAAA;EACA,YAAA,EAAc,sBAAA,EAKH;EAHX,UAAA,UAUM;EARN,WAAA;EACA,SAAA,EAAW,iBAAA;EAgBoB;AAAA;AA+BjC;;;;EAxCE,GAAA,GAAM,WAAA;EA4CE;;;;;;;;EAnCR,UAAA,GAAa,kBAAA;AAAA;;AAmCW;;;;;;;;;;;;;;;;;;;;;;;;;;;KAJd,gBAAA,sBAAsC,UAAA;wEAEhD,IAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,EAAQ,gBAAA;AAAA"}
@@ -0,0 +1,44 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { BaseReport } from "./base-report.type.mjs";
3
+
4
+ //#region ../../@warlock.js/ai/src/contracts/result/tool-call.type.d.ts
5
+ /**
6
+ * Forensic record of a single leaf-tool dispatch inside an agent's
7
+ * execution. Structurally a {@link BaseReport} (`type: "tool"`) with
8
+ * agent-level enrichments — the originating LLM trip index, the raw
9
+ * input the model emitted, the concrete output returned, and the
10
+ * typed error if any.
11
+ *
12
+ * Because `ToolCall` is a `BaseReport`, it drops directly into
13
+ * `AgentReport.children[]` alongside nested agent/workflow/supervisor
14
+ * reports, keeping the recursive tree uniform. It also powers the
15
+ * live `agent.tool.called` event + stream payloads so subscribers see
16
+ * the same shape during execution as they read post-hoc.
17
+ *
18
+ * @example
19
+ * const toolCalls = agentReport.children.filter(
20
+ * (c): c is ToolCall => c.type === "tool",
21
+ * );
22
+ * for (const call of toolCalls) {
23
+ * console.log(call.name, call.tripIndex, call.input, call.output);
24
+ * }
25
+ */
26
+ type ToolCall = BaseReport & {
27
+ /** Discriminator already fixed on BaseReport, narrowed to "tool" here. */type: "tool"; /** Which LLM trip triggered this tool call (0-indexed). */
28
+ tripIndex: number; /** Input passed to the tool (validated args from the model's request). */
29
+ input: unknown; /** Output returned by the tool (undefined if an error occurred). */
30
+ output?: unknown; /** Typed AI error thrown during dispatch (validation or execute), if any. */
31
+ error?: AIError;
32
+ /**
33
+ * Provenance marker copied from the originating
34
+ * `ModelToolCallRequest.recoveredFrom`. Present only when this
35
+ * dispatch came from the streaming tool-call guard recovering a
36
+ * leaked JSON envelope from the text channel; absent for real
37
+ * provider tool-calls. Telemetry consumers branch on this to compute
38
+ * per-model leak rate.
39
+ */
40
+ recoveredFrom?: "stream-text";
41
+ };
42
+ //#endregion
43
+ export { ToolCall };
44
+ //# sourceMappingURL=tool-call.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-call.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/tool-call.type.ts"],"mappings":";;;;;;AAwBA;;;;;;;;;;;;;AAmBe;;;;;;KAnBH,QAAA,GAAW,UAAA;4EAErB,IAAA;EAEA,SAAA;EAEA,KAAA;EAEA,MAAA;EAEA,KAAA,GAAQ,OAAO;;;;;;;;;EASf,aAAA;AAAA"}
@@ -0,0 +1,57 @@
1
+ import { ModelPricing } from "./model-pricing.type.mjs";
2
+
3
+ //#region ../../@warlock.js/ai/src/contracts/result/usage.type.d.ts
4
+ /**
5
+ * Token usage statistics for a single LLM call or aggregated across trips.
6
+ *
7
+ * `cachedTokens` is optional and represents the subset of `input` that
8
+ * was served from the provider's prompt cache (OpenAI's
9
+ * `prompt_tokens_details.cached_tokens`, Anthropic's
10
+ * `cache_read_input_tokens`). Cache-hit tokens are usually billed at
11
+ * a fraction of the full input rate — separate accounting lets cost
12
+ * code price them correctly. Defaults to 0 / undefined when the
13
+ * provider doesn't report it.
14
+ *
15
+ * @example
16
+ * const usage: Usage = {
17
+ * input: 150,
18
+ * output: 320,
19
+ * total: 470,
20
+ * cachedTokens: 120,
21
+ * cost: { input: 0.0000045, output: 0.000192, cachedInput: 0.000009 },
22
+ * };
23
+ */
24
+ type Usage = {
25
+ /** Number of input/prompt tokens consumed (includes cachedTokens). */input: number; /** Number of output/completion tokens generated. */
26
+ output: number; /** Total tokens (input + output). */
27
+ total: number;
28
+ /**
29
+ * Subset of `input` served from the provider's prompt cache. Billed
30
+ * at a discounted rate when cost is computed downstream. Optional —
31
+ * providers that don't report cache hits leave this undefined.
32
+ */
33
+ cachedTokens?: number;
34
+ /**
35
+ * Cost breakdown in USD, computed at emit time from `tokens × pricing[model]`
36
+ * when the model adapter declared a `ModelPricing`. Same shape as
37
+ * `ModelPricing` (input / output / cachedInput / cachedOutput) so
38
+ * dashboards can tell HOW the total was reached — what share was
39
+ * input vs output, how much the prompt cache saved — instead of
40
+ * looking at one opaque number.
41
+ *
42
+ * Captured as a historical fact so stored reports remain accurate
43
+ * even after the pricing table changes upstream.
44
+ *
45
+ * `undefined` when no pricing is available (legacy adapters, unknown
46
+ * model names, intentionally unpriced free-tier runs). Aggregators
47
+ * merge defined fields and leave undefined ones untouched, so an
48
+ * unpriced child cannot erase priced siblings.
49
+ *
50
+ * For a single scalar total, sum the populated fields:
51
+ * `(cost.input ?? 0) + (cost.output ?? 0) + (cost.cachedInput ?? 0) + (cost.cachedOutput ?? 0)`.
52
+ */
53
+ cost?: ModelPricing;
54
+ };
55
+ //#endregion
56
+ export { Usage };
57
+ //# sourceMappingURL=usage.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/usage.type.ts"],"mappings":";;;;;AAsBA;;;;;;;;;;;AAgCqB;;;;;;;KAhCT,KAAA;wEAEV,KAAA;EAEA,MAAA;EAEA,KAAA;;;;;;EAMA,YAAA;;;;;;;;;;;;;;;;;;;;EAoBA,IAAA,GAAO,YAAY;AAAA"}
@@ -0,0 +1,45 @@
1
+ import { AIError } from "../../errors/ai-error.mjs";
2
+ import { BaseResult } from "./base-result.type.mjs";
3
+ import { BaseReport } from "./base-report.type.mjs";
4
+ import { StepSnapshot } from "./step-result.type.mjs";
5
+
6
+ //#region ../../@warlock.js/ai/src/contracts/result/workflow-result.type.d.ts
7
+ /**
8
+ * Workflow-specific execution report — {@link BaseReport} plus
9
+ * per-step snapshots and the final frozen `ctx.state`.
10
+ *
11
+ * `report.children[]` carries every executable (tool, agent,
12
+ * sub-workflow, supervisor) any step invoked, in invocation order.
13
+ * `report.steps` remains the authoritative record of workflow
14
+ * structure — one entry per defined step — while `children` gives
15
+ * the cross-cutting tree view shared with other primitives.
16
+ */
17
+ type WorkflowReport = BaseReport & {
18
+ workflowName: string; /** Structural fingerprint — same value exposed on the workflow instance. */
19
+ signature: string; /** ISO-8601 timestamp when cancellation was observed, if any. */
20
+ cancelledAt?: string; /** Per-step snapshots keyed by step name. */
21
+ steps: Record<string, StepSnapshot>; /** Frozen final `ctx.state` at the moment the workflow terminated. */
22
+ state: Readonly<Record<string, unknown>>;
23
+ };
24
+ /**
25
+ * Result returned by `workflow.execute()` / `workflow.resume()`.
26
+ *
27
+ * Canonical destructuring (mirrors `AgentResult` and
28
+ * `SupervisorResult`):
29
+ *
30
+ * `const { data, report, usage, error } = await workflow.execute(...)`
31
+ *
32
+ * `data` is populated only when the workflow was defined with an
33
+ * `output: { extract, schema? }` spec and completed successfully. On
34
+ * failure or cancellation it is `undefined`; read `error` and
35
+ * `report.status` instead.
36
+ */
37
+ type WorkflowResult<TOutput = unknown> = BaseResult & {
38
+ type: "workflow";
39
+ data?: TOutput;
40
+ report: WorkflowReport;
41
+ error?: AIError;
42
+ };
43
+ //#endregion
44
+ export { WorkflowReport, WorkflowResult };
45
+ //# sourceMappingURL=workflow-result.type.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-result.type.d.mts","names":[],"sources":["../../../../../../../@warlock.js/ai/src/contracts/result/workflow-result.type.ts"],"mappings":";;;;;;;;AAeA;;;;;;;;KAAY,cAAA,GAAiB,UAAA;EAC3B,YAAA,UAD2B;EAG3B,SAAA;EAEA,WAAA,WAEA;EAAA,KAAA,EAAO,MAAA,SAAe,YAAA,GAAA;EAEtB,KAAA,EAAO,QAAA,CAAS,MAAA;AAAA;;;AAAM;AAgBxB;;;;;;;;;;KAAY,cAAA,sBAAoC,UAAA;EAC9C,IAAA;EACA,IAAA,GAAO,OAAA;EACP,MAAA,EAAQ,cAAA;EACR,KAAA,GAAQ,OAAA;AAAA"}
@@ -0,0 +1,77 @@
1
+ import { ModelPricing } from "./result/model-pricing.type.mjs";
2
+ import { EmbedderConfig, EmbedderContract } from "./embedder.contract.mjs";
3
+ import { ModelContract } from "./model.contract.mjs";
4
+
5
+ //#region ../../@warlock.js/ai/src/contracts/sdk-adapter.contract.d.ts
6
+ /**
7
+ * Configuration passed to SDKAdapterContract.model() to create a model instance.
8
+ *
9
+ * @example
10
+ * const model = ai.openai.model({ name: "gpt-4o", temperature: 0.7 });
11
+ *
12
+ * @example
13
+ * // Per-model pricing override (multi-tenant projects where the
14
+ * // rate is contract-specific or runtime-resolved):
15
+ * openai.model({
16
+ * name: "gpt-4o",
17
+ * pricing: { input: 2.5, output: 10 },
18
+ * });
19
+ */
20
+ type ModelConfig = {
21
+ /** Model identifier (e.g. "gpt-4o", "claude-3-5-sonnet-20241022") */name: string; /** Sampling temperature (0–2). Higher = more creative, lower = more focused */
22
+ temperature?: number; /** Maximum tokens to generate in the response */
23
+ maxTokens?: number;
24
+ /**
25
+ * Per-model USD pricing override. Wins over any SDK-level pricing
26
+ * registry — useful in multi-tenant projects where the rate is
27
+ * contract-specific or runtime-resolved. When omitted, the adapter
28
+ * falls back to its SDK-level registry (if any); when neither is
29
+ * configured, `Usage.cost` stays `undefined` (honest absence, not
30
+ * false zero).
31
+ */
32
+ pricing?: ModelPricing; /** Additional provider-specific configuration */
33
+ [key: string]: unknown;
34
+ };
35
+ /**
36
+ * What every SDK adapter factory returns.
37
+ * Becomes `ai.[sdkName]` on the AI namespace (e.g. `ai.openai`, `ai.anthropic`).
38
+ *
39
+ * @example
40
+ * // OpenAI adapter registered as ai.openai
41
+ * const model = ai.openai.model({ name: "gpt-4o" });
42
+ * const tokens = await ai.openai.count("Hello world", "gpt-4o");
43
+ *
44
+ * @example
45
+ * // Mock adapter for tests
46
+ * const mock = MockSDK();
47
+ * const model = mock.model({ name: "mock-model" });
48
+ */
49
+ interface SDKAdapterContract {
50
+ /**
51
+ * Create a model instance with the given configuration.
52
+ * The returned ModelContract is passed to agents, tools, and other primitives.
53
+ */
54
+ model(config: ModelConfig): ModelContract;
55
+ /**
56
+ * Count the number of tokens in the given text.
57
+ * Implementation is deferred to each adapter package.
58
+ *
59
+ * @param text - The text to tokenize and count
60
+ * @param model - Optional model name; affects tokenizer selection for some providers
61
+ * @returns Promise resolving to the token count
62
+ */
63
+ count(text: string, model?: string): Promise<number>;
64
+ /**
65
+ * Create an embedder bound to this SDK's client. Optional — not every
66
+ * provider supports embeddings (e.g. a hypothetical Anthropic adapter
67
+ * today). Consumers should check for presence before calling.
68
+ *
69
+ * @example
70
+ * const embedder = openai.embedder({ name: "text-embedding-3-small" });
71
+ * const { vector } = await embedder.embed("Hello world");
72
+ */
73
+ embedder?(config: EmbedderConfig): EmbedderContract;
74
+ }
75
+ //#endregion
76
+ export { ModelConfig, SDKAdapterContract };
77
+ //# sourceMappingURL=sdk-adapter.contract.d.mts.map