@yolk-sdk/agent 0.1.0-canary.95 → 0.1.0-canary.97

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 (470) hide show
  1. package/README.md +149 -47
  2. package/dist/classification/errors.d.mts +57 -0
  3. package/dist/classification/errors.d.mts.map +1 -0
  4. package/dist/classification/errors.mjs +56 -0
  5. package/dist/classification/errors.mjs.map +1 -0
  6. package/dist/classification/index.d.mts +4 -0
  7. package/dist/classification/index.mjs +4 -0
  8. package/dist/classification/model.d.mts +74 -0
  9. package/dist/classification/model.d.mts.map +1 -0
  10. package/dist/classification/model.mjs +136 -0
  11. package/dist/classification/model.mjs.map +1 -0
  12. package/dist/classification/schema.d.mts +172 -0
  13. package/dist/classification/schema.d.mts.map +1 -0
  14. package/dist/classification/schema.mjs +104 -0
  15. package/dist/classification/schema.mjs.map +1 -0
  16. package/dist/client/state.d.mts +82 -82
  17. package/dist/client/state.d.mts.map +1 -1
  18. package/dist/client/transport.d.mts +2 -2
  19. package/dist/client/transport.mjs +2 -2
  20. package/dist/client/transport.mjs.map +1 -1
  21. package/dist/compaction/retry.d.mts +30 -30
  22. package/dist/compaction/retry.d.mts.map +1 -1
  23. package/dist/compaction/window.d.mts +39 -39
  24. package/dist/compaction/window.d.mts.map +1 -1
  25. package/dist/loop/error.d.mts +1 -1
  26. package/dist/loop/error.mjs +1 -1
  27. package/dist/loop/llm-event.d.mts +1 -1
  28. package/dist/loop/llm-event.mjs +1 -1
  29. package/dist/loop/run.d.mts.map +1 -1
  30. package/dist/loop/run.mjs +27 -11
  31. package/dist/loop/run.mjs.map +1 -1
  32. package/dist/loop/services/llm-provider.d.mts +3 -0
  33. package/dist/loop/services/llm-provider.d.mts.map +1 -1
  34. package/dist/loop/services/llm-provider.mjs.map +1 -1
  35. package/dist/protocol/event.d.mts +1 -1
  36. package/dist/protocol/event.mjs +1 -1
  37. package/dist/protocol/index.d.mts +4 -3
  38. package/dist/protocol/index.d.mts.map +1 -1
  39. package/dist/protocol/index.mjs +4 -3
  40. package/dist/protocol/nested-tool-calls.d.mts +67 -0
  41. package/dist/protocol/nested-tool-calls.d.mts.map +1 -0
  42. package/dist/protocol/nested-tool-calls.mjs +118 -0
  43. package/dist/protocol/nested-tool-calls.mjs.map +1 -0
  44. package/dist/protocol/tool-argument-hints.d.mts +12 -0
  45. package/dist/protocol/tool-argument-hints.d.mts.map +1 -0
  46. package/dist/protocol/tool-argument-hints.mjs +60 -0
  47. package/dist/protocol/tool-argument-hints.mjs.map +1 -0
  48. package/dist/protocol/tool.d.mts +47 -1
  49. package/dist/protocol/tool.d.mts.map +1 -1
  50. package/dist/protocol/tool.mjs +44 -2
  51. package/dist/protocol/tool.mjs.map +1 -1
  52. package/dist/providers/anthropic/claude-provider.d.mts +1 -1
  53. package/dist/providers/anthropic/claude-provider.mjs.map +1 -1
  54. package/dist/providers/anthropic/conformance/cases.d.mts +50 -0
  55. package/dist/providers/anthropic/conformance/cases.d.mts.map +1 -0
  56. package/dist/providers/anthropic/conformance/cases.mjs +248 -0
  57. package/dist/providers/anthropic/conformance/cases.mjs.map +1 -0
  58. package/dist/providers/anthropic/conformance/claude-usage-cases.d.mts +27 -0
  59. package/dist/providers/anthropic/conformance/claude-usage-cases.d.mts.map +1 -0
  60. package/dist/providers/anthropic/conformance/claude-usage-cases.mjs +55 -0
  61. package/dist/providers/anthropic/conformance/claude-usage-cases.mjs.map +1 -0
  62. package/dist/providers/anthropic/conformance/claude-usage-snapshot.d.mts +14 -0
  63. package/dist/providers/anthropic/conformance/claude-usage-snapshot.d.mts.map +1 -0
  64. package/dist/providers/anthropic/conformance/claude-usage-snapshot.mjs +33 -0
  65. package/dist/providers/anthropic/conformance/claude-usage-snapshot.mjs.map +1 -0
  66. package/dist/providers/anthropic/conformance/error-envelope.d.mts +15 -0
  67. package/dist/providers/anthropic/conformance/error-envelope.d.mts.map +1 -0
  68. package/dist/providers/anthropic/conformance/error-envelope.mjs +51 -0
  69. package/dist/providers/anthropic/conformance/error-envelope.mjs.map +1 -0
  70. package/dist/providers/anthropic/conformance/index.d.mts +18 -0
  71. package/dist/providers/anthropic/conformance/index.d.mts.map +1 -0
  72. package/dist/providers/anthropic/conformance/index.mjs +23 -0
  73. package/dist/providers/anthropic/conformance/index.mjs.map +1 -0
  74. package/dist/providers/anthropic/conformance/max-tokens.d.mts +15 -0
  75. package/dist/providers/anthropic/conformance/max-tokens.d.mts.map +1 -0
  76. package/dist/providers/anthropic/conformance/max-tokens.mjs +60 -0
  77. package/dist/providers/anthropic/conformance/max-tokens.mjs.map +1 -0
  78. package/dist/providers/anthropic/conformance/plain-text.d.mts +17 -0
  79. package/dist/providers/anthropic/conformance/plain-text.d.mts.map +1 -0
  80. package/dist/providers/anthropic/conformance/plain-text.mjs +63 -0
  81. package/dist/providers/anthropic/conformance/plain-text.mjs.map +1 -0
  82. package/dist/providers/anthropic/conformance/thinking-before-text.d.mts +16 -0
  83. package/dist/providers/anthropic/conformance/thinking-before-text.d.mts.map +1 -0
  84. package/dist/providers/anthropic/conformance/thinking-before-text.mjs +70 -0
  85. package/dist/providers/anthropic/conformance/thinking-before-text.mjs.map +1 -0
  86. package/dist/providers/anthropic/conformance/tool-use-input-deltas.d.mts +17 -0
  87. package/dist/providers/anthropic/conformance/tool-use-input-deltas.d.mts.map +1 -0
  88. package/dist/providers/anthropic/conformance/tool-use-input-deltas.mjs +79 -0
  89. package/dist/providers/anthropic/conformance/tool-use-input-deltas.mjs.map +1 -0
  90. package/dist/providers/anthropic/usage.d.mts +7 -1
  91. package/dist/providers/anthropic/usage.d.mts.map +1 -1
  92. package/dist/providers/anthropic/usage.mjs +2 -2
  93. package/dist/providers/anthropic/usage.mjs.map +1 -1
  94. package/dist/providers/anthropic-messages-provider-internal.d.mts +7 -1
  95. package/dist/providers/anthropic-messages-provider-internal.d.mts.map +1 -1
  96. package/dist/providers/anthropic-messages-provider-internal.mjs +6 -3
  97. package/dist/providers/anthropic-messages-provider-internal.mjs.map +1 -1
  98. package/dist/providers/anthropic-provider-internal.d.mts +1 -1
  99. package/dist/providers/anthropic-provider-internal.mjs +2 -2
  100. package/dist/providers/anthropic-provider-internal.mjs.map +1 -1
  101. package/dist/providers/openai/codex-provider.d.mts +2 -2
  102. package/dist/providers/openai/codex-provider.d.mts.map +1 -1
  103. package/dist/providers/openai/codex-provider.mjs.map +1 -1
  104. package/dist/providers/openai/codex-usage.d.mts +7 -1
  105. package/dist/providers/openai/codex-usage.d.mts.map +1 -1
  106. package/dist/providers/openai/codex-usage.mjs +2 -2
  107. package/dist/providers/openai/codex-usage.mjs.map +1 -1
  108. package/dist/providers/openai/conformance/cases.d.mts +36 -0
  109. package/dist/providers/openai/conformance/cases.d.mts.map +1 -0
  110. package/dist/providers/openai/conformance/cases.mjs +165 -0
  111. package/dist/providers/openai/conformance/cases.mjs.map +1 -0
  112. package/dist/providers/openai/conformance/codex-cases.d.mts +37 -0
  113. package/dist/providers/openai/conformance/codex-cases.d.mts.map +1 -0
  114. package/dist/providers/openai/conformance/codex-cases.mjs +64 -0
  115. package/dist/providers/openai/conformance/codex-cases.mjs.map +1 -0
  116. package/dist/providers/openai/conformance/codex-error-envelope.d.mts +13 -0
  117. package/dist/providers/openai/conformance/codex-error-envelope.d.mts.map +1 -0
  118. package/dist/providers/openai/conformance/codex-error-envelope.mjs +50 -0
  119. package/dist/providers/openai/conformance/codex-error-envelope.mjs.map +1 -0
  120. package/dist/providers/openai/conformance/codex-function-call-arguments.d.mts +13 -0
  121. package/dist/providers/openai/conformance/codex-function-call-arguments.d.mts.map +1 -0
  122. package/dist/providers/openai/conformance/codex-function-call-arguments.mjs +79 -0
  123. package/dist/providers/openai/conformance/codex-function-call-arguments.mjs.map +1 -0
  124. package/dist/providers/openai/conformance/codex-plain-text.d.mts +13 -0
  125. package/dist/providers/openai/conformance/codex-plain-text.d.mts.map +1 -0
  126. package/dist/providers/openai/conformance/codex-plain-text.mjs +70 -0
  127. package/dist/providers/openai/conformance/codex-plain-text.mjs.map +1 -0
  128. package/dist/providers/openai/conformance/codex-terminal-event.d.mts +13 -0
  129. package/dist/providers/openai/conformance/codex-terminal-event.d.mts.map +1 -0
  130. package/dist/providers/openai/conformance/codex-terminal-event.mjs +67 -0
  131. package/dist/providers/openai/conformance/codex-terminal-event.mjs.map +1 -0
  132. package/dist/providers/openai/conformance/codex-usage-cases.d.mts +28 -0
  133. package/dist/providers/openai/conformance/codex-usage-cases.d.mts.map +1 -0
  134. package/dist/providers/openai/conformance/codex-usage-cases.mjs +55 -0
  135. package/dist/providers/openai/conformance/codex-usage-cases.mjs.map +1 -0
  136. package/dist/providers/openai/conformance/codex-usage-snapshot.d.mts +15 -0
  137. package/dist/providers/openai/conformance/codex-usage-snapshot.d.mts.map +1 -0
  138. package/dist/providers/openai/conformance/codex-usage-snapshot.mjs +34 -0
  139. package/dist/providers/openai/conformance/codex-usage-snapshot.mjs.map +1 -0
  140. package/dist/providers/openai/conformance/error-envelope.d.mts +14 -0
  141. package/dist/providers/openai/conformance/error-envelope.d.mts.map +1 -0
  142. package/dist/providers/openai/conformance/error-envelope.mjs +50 -0
  143. package/dist/providers/openai/conformance/error-envelope.mjs.map +1 -0
  144. package/dist/providers/openai/conformance/index.d.mts +24 -0
  145. package/dist/providers/openai/conformance/index.d.mts.map +1 -0
  146. package/dist/providers/openai/conformance/index.mjs +33 -0
  147. package/dist/providers/openai/conformance/index.mjs.map +1 -0
  148. package/dist/providers/openai/conformance/json-plain-text.d.mts +14 -0
  149. package/dist/providers/openai/conformance/json-plain-text.d.mts.map +1 -0
  150. package/dist/providers/openai/conformance/json-plain-text.mjs +49 -0
  151. package/dist/providers/openai/conformance/json-plain-text.mjs.map +1 -0
  152. package/dist/providers/openai/conformance/plain-text.d.mts +15 -0
  153. package/dist/providers/openai/conformance/plain-text.d.mts.map +1 -0
  154. package/dist/providers/openai/conformance/plain-text.mjs +60 -0
  155. package/dist/providers/openai/conformance/plain-text.mjs.map +1 -0
  156. package/dist/providers/openai/conformance/responses-cases-internal.d.mts +40 -0
  157. package/dist/providers/openai/conformance/responses-cases-internal.d.mts.map +1 -0
  158. package/dist/providers/openai/conformance/responses-cases-internal.mjs +271 -0
  159. package/dist/providers/openai/conformance/responses-cases-internal.mjs.map +1 -0
  160. package/dist/providers/openai/conformance/subscription-usage-cases-internal.d.mts +37 -0
  161. package/dist/providers/openai/conformance/subscription-usage-cases-internal.d.mts.map +1 -0
  162. package/dist/providers/openai/conformance/subscription-usage-cases-internal.mjs +85 -0
  163. package/dist/providers/openai/conformance/subscription-usage-cases-internal.mjs.map +1 -0
  164. package/dist/providers/openai/conformance/tool-call-deltas.d.mts +15 -0
  165. package/dist/providers/openai/conformance/tool-call-deltas.d.mts.map +1 -0
  166. package/dist/providers/openai/conformance/tool-call-deltas.mjs +77 -0
  167. package/dist/providers/openai/conformance/tool-call-deltas.mjs.map +1 -0
  168. package/dist/providers/openai/provider.d.mts +2 -2
  169. package/dist/providers/openai/provider.d.mts.map +1 -1
  170. package/dist/providers/openai/provider.mjs +5 -4
  171. package/dist/providers/openai/provider.mjs.map +1 -1
  172. package/dist/providers/openai/realtime/client-codec.mjs +1 -1
  173. package/dist/providers/openai/realtime/session-config.d.mts +7 -3
  174. package/dist/providers/openai/realtime/session-config.d.mts.map +1 -1
  175. package/dist/providers/openai/realtime/session-config.mjs +9 -4
  176. package/dist/providers/openai/realtime/session-config.mjs.map +1 -1
  177. package/dist/providers/openai/speech.d.mts +1 -1
  178. package/dist/providers/openai/speech.mjs +1 -1
  179. package/dist/providers/openai/speech.mjs.map +1 -1
  180. package/dist/providers/openai-responses-provider-internal.d.mts +2 -2
  181. package/dist/providers/openai-responses-provider-internal.mjs +2 -2
  182. package/dist/providers/openai-responses-provider-internal.mjs.map +1 -1
  183. package/dist/providers/opencode/conformance/cases.d.mts +47 -0
  184. package/dist/providers/opencode/conformance/cases.d.mts.map +1 -0
  185. package/dist/providers/opencode/conformance/cases.mjs +208 -0
  186. package/dist/providers/opencode/conformance/cases.mjs.map +1 -0
  187. package/dist/providers/opencode/conformance/chat-plain-text.d.mts +13 -0
  188. package/dist/providers/opencode/conformance/chat-plain-text.d.mts.map +1 -0
  189. package/dist/providers/opencode/conformance/chat-plain-text.mjs +58 -0
  190. package/dist/providers/opencode/conformance/chat-plain-text.mjs.map +1 -0
  191. package/dist/providers/opencode/conformance/index.d.mts +14 -0
  192. package/dist/providers/opencode/conformance/index.d.mts.map +1 -0
  193. package/dist/providers/opencode/conformance/index.mjs +19 -0
  194. package/dist/providers/opencode/conformance/index.mjs.map +1 -0
  195. package/dist/providers/opencode/conformance/messages-plain-text.d.mts +13 -0
  196. package/dist/providers/opencode/conformance/messages-plain-text.d.mts.map +1 -0
  197. package/dist/providers/opencode/conformance/messages-plain-text.mjs +60 -0
  198. package/dist/providers/opencode/conformance/messages-plain-text.mjs.map +1 -0
  199. package/dist/providers/opencode/conformance/responses-commentary-replay.d.mts +13 -0
  200. package/dist/providers/opencode/conformance/responses-commentary-replay.d.mts.map +1 -0
  201. package/dist/providers/opencode/conformance/responses-commentary-replay.mjs +89 -0
  202. package/dist/providers/opencode/conformance/responses-commentary-replay.mjs.map +1 -0
  203. package/dist/providers/opencode/conformance/responses-plain-text.d.mts +13 -0
  204. package/dist/providers/opencode/conformance/responses-plain-text.d.mts.map +1 -0
  205. package/dist/providers/opencode/conformance/responses-plain-text.mjs +60 -0
  206. package/dist/providers/opencode/conformance/responses-plain-text.mjs.map +1 -0
  207. package/dist/providers/opencode/conformance/usage-snapshot.d.mts +13 -0
  208. package/dist/providers/opencode/conformance/usage-snapshot.d.mts.map +1 -0
  209. package/dist/providers/opencode/conformance/usage-snapshot.mjs +32 -0
  210. package/dist/providers/opencode/conformance/usage-snapshot.mjs.map +1 -0
  211. package/dist/providers/opencode/go-provider.d.mts +1 -1
  212. package/dist/providers/opencode/go-provider.mjs.map +1 -1
  213. package/dist/providers/opencode/usage.d.mts +8 -2
  214. package/dist/providers/opencode/usage.d.mts.map +1 -1
  215. package/dist/providers/opencode/usage.mjs +3 -3
  216. package/dist/providers/opencode/usage.mjs.map +1 -1
  217. package/dist/providers/provider-error.d.mts +5 -3
  218. package/dist/providers/provider-error.d.mts.map +1 -1
  219. package/dist/providers/provider-error.mjs +6 -5
  220. package/dist/providers/provider-error.mjs.map +1 -1
  221. package/dist/providers/subscription-usage-internal.d.mts +1 -1
  222. package/dist/providers/subscription-usage-internal.mjs +1 -1
  223. package/dist/providers/subscription-usage-internal.mjs.map +1 -1
  224. package/dist/providers/vercel/ai-gateway-classifier.d.mts +45 -0
  225. package/dist/providers/vercel/ai-gateway-classifier.d.mts.map +1 -0
  226. package/dist/providers/vercel/ai-gateway-classifier.mjs +253 -0
  227. package/dist/providers/vercel/ai-gateway-classifier.mjs.map +1 -0
  228. package/dist/providers/vercel/ai-gateway-credential-internal.d.mts +12 -0
  229. package/dist/providers/vercel/ai-gateway-credential-internal.d.mts.map +1 -0
  230. package/dist/providers/vercel/ai-gateway-credential-internal.mjs +12 -0
  231. package/dist/providers/vercel/ai-gateway-credential-internal.mjs.map +1 -0
  232. package/dist/providers/vercel/ai-gateway-provider.d.mts +1 -1
  233. package/dist/providers/vercel/ai-gateway-provider.d.mts.map +1 -1
  234. package/dist/providers/vercel/ai-gateway-provider.mjs +3 -2
  235. package/dist/providers/vercel/ai-gateway-provider.mjs.map +1 -1
  236. package/dist/providers/vercel/conformance/cases.d.mts +41 -0
  237. package/dist/providers/vercel/conformance/cases.d.mts.map +1 -0
  238. package/dist/providers/vercel/conformance/cases.mjs +182 -0
  239. package/dist/providers/vercel/conformance/cases.mjs.map +1 -0
  240. package/dist/providers/vercel/conformance/classifier-boolean.d.mts +13 -0
  241. package/dist/providers/vercel/conformance/classifier-boolean.d.mts.map +1 -0
  242. package/dist/providers/vercel/conformance/classifier-boolean.mjs +48 -0
  243. package/dist/providers/vercel/conformance/classifier-boolean.mjs.map +1 -0
  244. package/dist/providers/vercel/conformance/classifier-cases.d.mts +32 -0
  245. package/dist/providers/vercel/conformance/classifier-cases.d.mts.map +1 -0
  246. package/dist/providers/vercel/conformance/classifier-cases.mjs +193 -0
  247. package/dist/providers/vercel/conformance/classifier-cases.mjs.map +1 -0
  248. package/dist/providers/vercel/conformance/classifier-choice.d.mts +16 -0
  249. package/dist/providers/vercel/conformance/classifier-choice.d.mts.map +1 -0
  250. package/dist/providers/vercel/conformance/classifier-choice.mjs +55 -0
  251. package/dist/providers/vercel/conformance/classifier-choice.mjs.map +1 -0
  252. package/dist/providers/vercel/conformance/classifier-error-envelope.d.mts +13 -0
  253. package/dist/providers/vercel/conformance/classifier-error-envelope.d.mts.map +1 -0
  254. package/dist/providers/vercel/conformance/classifier-error-envelope.mjs +48 -0
  255. package/dist/providers/vercel/conformance/classifier-error-envelope.mjs.map +1 -0
  256. package/dist/providers/vercel/conformance/classifier-score.d.mts +16 -0
  257. package/dist/providers/vercel/conformance/classifier-score.d.mts.map +1 -0
  258. package/dist/providers/vercel/conformance/classifier-score.mjs +56 -0
  259. package/dist/providers/vercel/conformance/classifier-score.mjs.map +1 -0
  260. package/dist/providers/vercel/conformance/deepseek-reasoning.d.mts +13 -0
  261. package/dist/providers/vercel/conformance/deepseek-reasoning.d.mts.map +1 -0
  262. package/dist/providers/vercel/conformance/deepseek-reasoning.mjs +64 -0
  263. package/dist/providers/vercel/conformance/deepseek-reasoning.mjs.map +1 -0
  264. package/dist/providers/vercel/conformance/error-envelope.d.mts +13 -0
  265. package/dist/providers/vercel/conformance/error-envelope.d.mts.map +1 -0
  266. package/dist/providers/vercel/conformance/error-envelope.mjs +49 -0
  267. package/dist/providers/vercel/conformance/error-envelope.mjs.map +1 -0
  268. package/dist/providers/vercel/conformance/index.d.mts +20 -0
  269. package/dist/providers/vercel/conformance/index.d.mts.map +1 -0
  270. package/dist/providers/vercel/conformance/index.mjs +29 -0
  271. package/dist/providers/vercel/conformance/index.mjs.map +1 -0
  272. package/dist/providers/vercel/conformance/plain-text.d.mts +13 -0
  273. package/dist/providers/vercel/conformance/plain-text.d.mts.map +1 -0
  274. package/dist/providers/vercel/conformance/plain-text.mjs +53 -0
  275. package/dist/providers/vercel/conformance/plain-text.mjs.map +1 -0
  276. package/dist/providers/vercel/conformance/tool-call-deltas.d.mts +13 -0
  277. package/dist/providers/vercel/conformance/tool-call-deltas.d.mts.map +1 -0
  278. package/dist/providers/vercel/conformance/tool-call-deltas.mjs +63 -0
  279. package/dist/providers/vercel/conformance/tool-call-deltas.mjs.map +1 -0
  280. package/dist/providers/xai/conformance/cases.d.mts +43 -0
  281. package/dist/providers/xai/conformance/cases.d.mts.map +1 -0
  282. package/dist/providers/xai/conformance/cases.mjs +70 -0
  283. package/dist/providers/xai/conformance/cases.mjs.map +1 -0
  284. package/dist/providers/xai/conformance/error-envelope.d.mts +14 -0
  285. package/dist/providers/xai/conformance/error-envelope.d.mts.map +1 -0
  286. package/dist/providers/xai/conformance/error-envelope.mjs +48 -0
  287. package/dist/providers/xai/conformance/error-envelope.mjs.map +1 -0
  288. package/dist/providers/xai/conformance/function-call-arguments.d.mts +14 -0
  289. package/dist/providers/xai/conformance/function-call-arguments.d.mts.map +1 -0
  290. package/dist/providers/xai/conformance/function-call-arguments.mjs +70 -0
  291. package/dist/providers/xai/conformance/function-call-arguments.mjs.map +1 -0
  292. package/dist/providers/xai/conformance/index.d.mts +17 -0
  293. package/dist/providers/xai/conformance/index.d.mts.map +1 -0
  294. package/dist/providers/xai/conformance/index.mjs +21 -0
  295. package/dist/providers/xai/conformance/index.mjs.map +1 -0
  296. package/dist/providers/xai/conformance/plain-text.d.mts +14 -0
  297. package/dist/providers/xai/conformance/plain-text.d.mts.map +1 -0
  298. package/dist/providers/xai/conformance/plain-text.mjs +61 -0
  299. package/dist/providers/xai/conformance/plain-text.mjs.map +1 -0
  300. package/dist/providers/xai/conformance/terminal-event.d.mts +14 -0
  301. package/dist/providers/xai/conformance/terminal-event.d.mts.map +1 -0
  302. package/dist/providers/xai/conformance/terminal-event.mjs +59 -0
  303. package/dist/providers/xai/conformance/terminal-event.mjs.map +1 -0
  304. package/dist/providers/xai/conformance/usage-cases.d.mts +29 -0
  305. package/dist/providers/xai/conformance/usage-cases.d.mts.map +1 -0
  306. package/dist/providers/xai/conformance/usage-cases.mjs +81 -0
  307. package/dist/providers/xai/conformance/usage-cases.mjs.map +1 -0
  308. package/dist/providers/xai/conformance/usage-snapshot.d.mts +15 -0
  309. package/dist/providers/xai/conformance/usage-snapshot.d.mts.map +1 -0
  310. package/dist/providers/xai/conformance/usage-snapshot.mjs +34 -0
  311. package/dist/providers/xai/conformance/usage-snapshot.mjs.map +1 -0
  312. package/dist/providers/xai/grok-provider.d.mts +2 -2
  313. package/dist/providers/xai/grok-provider.d.mts.map +1 -1
  314. package/dist/providers/xai/grok-provider.mjs.map +1 -1
  315. package/dist/providers/xai/usage.d.mts +7 -1
  316. package/dist/providers/xai/usage.d.mts.map +1 -1
  317. package/dist/providers/xai/usage.mjs +2 -2
  318. package/dist/providers/xai/usage.mjs.map +1 -1
  319. package/dist/react/chat-items.d.mts +68 -68
  320. package/dist/react/chat-items.d.mts.map +1 -1
  321. package/dist/react/chat-items.mjs +1 -1
  322. package/dist/react/chat-messages.d.mts +75 -75
  323. package/dist/react/chat-messages.d.mts.map +1 -1
  324. package/dist/react/chat-session-events.d.mts +1 -1
  325. package/dist/react/chat-session-events.mjs +1 -1
  326. package/dist/runtime/error.d.mts +1 -1
  327. package/dist/runtime/error.mjs +1 -1
  328. package/dist/runtime/session-event-store.d.mts +1 -1
  329. package/dist/runtime/session-event-store.mjs +1 -1
  330. package/dist/skillset/merge.d.mts +1 -1
  331. package/dist/skillset/name.d.mts +2 -2
  332. package/dist/skillset/name.d.mts.map +1 -1
  333. package/dist/tools/arguments.d.mts +40 -0
  334. package/dist/tools/arguments.d.mts.map +1 -0
  335. package/dist/tools/arguments.mjs +364 -0
  336. package/dist/tools/arguments.mjs.map +1 -0
  337. package/dist/tools/background.d.mts +3 -2
  338. package/dist/tools/background.d.mts.map +1 -1
  339. package/dist/tools/background.mjs +3 -3
  340. package/dist/tools/background.mjs.map +1 -1
  341. package/dist/tools/index.d.mts +4 -2
  342. package/dist/tools/index.mjs +3 -1
  343. package/dist/tools/input.d.mts +1 -1
  344. package/dist/tools/input.d.mts.map +1 -1
  345. package/dist/tools/input.mjs +4 -2
  346. package/dist/tools/input.mjs.map +1 -1
  347. package/dist/tools/interaction.d.mts +1 -1
  348. package/dist/tools/interaction.d.mts.map +1 -1
  349. package/dist/tools/interaction.mjs +32 -5
  350. package/dist/tools/interaction.mjs.map +1 -1
  351. package/dist/tools/question.d.mts.map +1 -1
  352. package/dist/tools/question.mjs +2 -1
  353. package/dist/tools/question.mjs.map +1 -1
  354. package/dist/tools/registry.d.mts +56 -8
  355. package/dist/tools/registry.d.mts.map +1 -1
  356. package/dist/tools/registry.mjs +129 -51
  357. package/dist/tools/registry.mjs.map +1 -1
  358. package/dist/tools/subagent.d.mts.map +1 -1
  359. package/dist/tools/subagent.mjs +3 -2
  360. package/dist/tools/subagent.mjs.map +1 -1
  361. package/dist/voice/projection.d.mts +1 -1
  362. package/dist/voice/projection.mjs +1 -1
  363. package/dist/voice/protocol.d.mts +1 -1
  364. package/dist/voice/protocol.mjs +1 -1
  365. package/dist/voice/session-log.d.mts +1 -1
  366. package/dist/voice/session-log.mjs +1 -1
  367. package/dist/voice/speech.d.mts +1 -1
  368. package/dist/voice/speech.d.mts.map +1 -1
  369. package/dist/voice/speech.mjs +4 -3
  370. package/dist/voice/speech.mjs.map +1 -1
  371. package/dist/voice/tool-bridge.mjs +1 -1
  372. package/dist/voice/tool-server.d.mts.map +1 -1
  373. package/dist/voice/tool-server.mjs +2 -1
  374. package/dist/voice/tool-server.mjs.map +1 -1
  375. package/dist/voice/websocket.d.mts +1 -1
  376. package/dist/voice/websocket.mjs +1 -1
  377. package/dist/voice/websocket.mjs.map +1 -1
  378. package/package.json +39 -3
  379. package/src/classification/errors.ts +79 -0
  380. package/src/classification/index.ts +53 -0
  381. package/src/classification/model.ts +270 -0
  382. package/src/classification/schema.ts +154 -0
  383. package/src/client/transport.ts +2 -2
  384. package/src/loop/run.ts +55 -11
  385. package/src/loop/services/llm-provider.ts +3 -0
  386. package/src/protocol/index.ts +28 -1
  387. package/src/protocol/nested-tool-calls.ts +230 -0
  388. package/src/protocol/tool-argument-hints.ts +113 -0
  389. package/src/protocol/tool.ts +64 -1
  390. package/src/providers/anthropic/claude-provider.ts +1 -1
  391. package/src/providers/anthropic/conformance/cases.ts +467 -0
  392. package/src/providers/anthropic/conformance/claude-usage-cases.ts +85 -0
  393. package/src/providers/anthropic/conformance/claude-usage-snapshot.ts +36 -0
  394. package/src/providers/anthropic/conformance/error-envelope.ts +56 -0
  395. package/src/providers/anthropic/conformance/index.ts +89 -0
  396. package/src/providers/anthropic/conformance/max-tokens.ts +65 -0
  397. package/src/providers/anthropic/conformance/plain-text.ts +68 -0
  398. package/src/providers/anthropic/conformance/thinking-before-text.ts +75 -0
  399. package/src/providers/anthropic/conformance/tool-use-input-deltas.ts +90 -0
  400. package/src/providers/anthropic/usage.ts +8 -2
  401. package/src/providers/anthropic-messages-provider-internal.ts +9 -2
  402. package/src/providers/anthropic-provider-internal.ts +1 -1
  403. package/src/providers/openai/codex-provider.ts +1 -1
  404. package/src/providers/openai/codex-usage.ts +8 -2
  405. package/src/providers/openai/conformance/cases.ts +290 -0
  406. package/src/providers/openai/conformance/codex-cases.ts +103 -0
  407. package/src/providers/openai/conformance/codex-error-envelope.ts +53 -0
  408. package/src/providers/openai/conformance/codex-function-call-arguments.ts +88 -0
  409. package/src/providers/openai/conformance/codex-plain-text.ts +73 -0
  410. package/src/providers/openai/conformance/codex-terminal-event.ts +70 -0
  411. package/src/providers/openai/conformance/codex-usage-cases.ts +87 -0
  412. package/src/providers/openai/conformance/codex-usage-snapshot.ts +37 -0
  413. package/src/providers/openai/conformance/error-envelope.ts +56 -0
  414. package/src/providers/openai/conformance/index.ts +126 -0
  415. package/src/providers/openai/conformance/json-plain-text.ts +53 -0
  416. package/src/providers/openai/conformance/plain-text.ts +66 -0
  417. package/src/providers/openai/conformance/responses-cases-internal.ts +580 -0
  418. package/src/providers/openai/conformance/subscription-usage-cases-internal.ts +199 -0
  419. package/src/providers/openai/conformance/tool-call-deltas.ts +91 -0
  420. package/src/providers/openai/provider.ts +3 -5
  421. package/src/providers/openai/realtime/session-config.ts +12 -5
  422. package/src/providers/openai/speech.ts +1 -1
  423. package/src/providers/openai-responses-provider-internal.ts +1 -1
  424. package/src/providers/opencode/conformance/cases.ts +372 -0
  425. package/src/providers/opencode/conformance/chat-plain-text.ts +64 -0
  426. package/src/providers/opencode/conformance/index.ts +63 -0
  427. package/src/providers/opencode/conformance/messages-plain-text.ts +65 -0
  428. package/src/providers/opencode/conformance/responses-commentary-replay.ts +96 -0
  429. package/src/providers/opencode/conformance/responses-plain-text.ts +63 -0
  430. package/src/providers/opencode/conformance/usage-snapshot.ts +35 -0
  431. package/src/providers/opencode/go-provider.ts +1 -1
  432. package/src/providers/opencode/usage.ts +9 -3
  433. package/src/providers/provider-error.ts +8 -5
  434. package/src/providers/subscription-usage-internal.ts +1 -1
  435. package/src/providers/vercel/ai-gateway-classifier.ts +492 -0
  436. package/src/providers/vercel/ai-gateway-credential-internal.ts +10 -0
  437. package/src/providers/vercel/ai-gateway-provider.ts +3 -4
  438. package/src/providers/vercel/conformance/cases.ts +319 -0
  439. package/src/providers/vercel/conformance/classifier-boolean.ts +51 -0
  440. package/src/providers/vercel/conformance/classifier-cases.ts +333 -0
  441. package/src/providers/vercel/conformance/classifier-choice.ts +58 -0
  442. package/src/providers/vercel/conformance/classifier-error-envelope.ts +51 -0
  443. package/src/providers/vercel/conformance/classifier-score.ts +56 -0
  444. package/src/providers/vercel/conformance/deepseek-reasoning.ts +72 -0
  445. package/src/providers/vercel/conformance/error-envelope.ts +55 -0
  446. package/src/providers/vercel/conformance/index.ts +99 -0
  447. package/src/providers/vercel/conformance/plain-text.ts +59 -0
  448. package/src/providers/vercel/conformance/tool-call-deltas.ts +78 -0
  449. package/src/providers/xai/conformance/cases.ts +115 -0
  450. package/src/providers/xai/conformance/error-envelope.ts +51 -0
  451. package/src/providers/xai/conformance/function-call-arguments.ts +79 -0
  452. package/src/providers/xai/conformance/index.ts +81 -0
  453. package/src/providers/xai/conformance/plain-text.ts +64 -0
  454. package/src/providers/xai/conformance/terminal-event.ts +62 -0
  455. package/src/providers/xai/conformance/usage-cases.ts +145 -0
  456. package/src/providers/xai/conformance/usage-snapshot.ts +37 -0
  457. package/src/providers/xai/grok-provider.ts +1 -1
  458. package/src/providers/xai/usage.ts +8 -2
  459. package/src/tools/README.md +22 -0
  460. package/src/tools/arguments.ts +743 -0
  461. package/src/tools/background.ts +3 -1
  462. package/src/tools/index.ts +7 -0
  463. package/src/tools/input.ts +6 -3
  464. package/src/tools/interaction.ts +73 -8
  465. package/src/tools/question.ts +5 -1
  466. package/src/tools/registry.ts +362 -79
  467. package/src/tools/subagent.ts +5 -1
  468. package/src/voice/speech.ts +3 -2
  469. package/src/voice/tool-server.ts +5 -0
  470. package/src/voice/websocket.ts +1 -1
package/README.md CHANGED
@@ -1,57 +1,66 @@
1
1
  # @yolk-sdk/agent
2
2
 
3
- Domain-free agent protocol, loop, runtime, Effect-native client, compaction, tools, React, providers, OAuth, skillset, and voice primitives.
3
+ Domain-free agent protocol, loop, runtime, Effect-native client, compaction, classifier models, tools, React, providers, OAuth, skillset, and voice primitives.
4
4
 
5
5
  Root export is intentionally empty. Import feature APIs from explicit subpaths.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- pnpm add @yolk-sdk/agent@canary effect@4.0.0-rc.115
10
+ pnpm add @yolk-sdk/agent@canary effect@4.0.0
11
11
  ```
12
12
 
13
13
  Add `react` if you use `@yolk-sdk/agent/react` or `@yolk-sdk/agent/voice/react`.
14
14
 
15
+ Running the experimental `@yolk-sdk/agent/providers/*/conformance` cases? Also add `@yolk-sdk/conformance@canary` (usually as a dev dependency); the cases run through `@yolk-sdk/conformance/runner`.
16
+
15
17
  Canary APIs are unstable. Keep all `@yolk-sdk/*` packages on the same version.
16
- Use the SDK's matching Effect version (`4.0.0-rc.115`) in host code.
18
+ Use the SDK's matching Effect version (`4.0.0`) in host code.
17
19
  Published package metadata requires Node.js 22+.
18
20
 
19
21
  ## Subpaths
20
22
 
21
- | Subpath | Purpose |
22
- | ------------------------------------------------------ | -------------------------------------------------------------- |
23
- | `@yolk-sdk/agent/protocol` | Wire messages, events, content, usage, tool schemas |
24
- | `@yolk-sdk/agent/loop` | Stateless LLM/tool loop |
25
- | `@yolk-sdk/agent/loop/testing` | Faux provider and tool executor test helpers |
26
- | `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration |
27
- | `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
28
- | `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
29
- | `@yolk-sdk/agent/tools` | Tool registry, typed inputs, interactions, subagents/questions |
30
- | `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
31
- | `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
32
- | `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
33
- | `@yolk-sdk/agent/providers/openai/codex` | OpenAI Codex request and auth helpers |
34
- | `@yolk-sdk/agent/providers/openai/codex-usage` | Codex subscription-allowance snapshots |
35
- | `@yolk-sdk/agent/providers/openai/codex-provider` | Codex LLM provider factory |
36
- | `@yolk-sdk/agent/providers/openai/provider` | OpenAI-compatible LLM provider factory |
37
- | `@yolk-sdk/agent/providers/openai/realtime` | OpenAI Realtime session config and event codecs |
38
- | `@yolk-sdk/agent/providers/openai/speech` | OpenAI text-to-speech and transcription adapters |
39
- | `@yolk-sdk/agent/providers/vercel/ai-gateway-provider` | Vercel AI Gateway Chat Completions provider factory |
40
- | `@yolk-sdk/agent/providers/opencode/go-provider` | OpenCode Go Chat Completions, Messages, and Responses provider |
41
- | `@yolk-sdk/agent/providers/opencode/usage` | OpenCode Go subscription-allowance snapshots |
42
- | `@yolk-sdk/agent/providers/anthropic` | Anthropic/Claude OAuth and broker helpers |
43
- | `@yolk-sdk/agent/providers/anthropic/claude` | Claude request and auth helpers |
44
- | `@yolk-sdk/agent/providers/anthropic/usage` | Claude subscription-allowance snapshots |
45
- | `@yolk-sdk/agent/providers/anthropic/claude-provider` | Claude LLM provider factory |
46
- | `@yolk-sdk/agent/providers/xai` | Grok subscription OAuth and token broker helpers |
47
- | `@yolk-sdk/agent/providers/xai/grok` | Grok subscription request and auth helpers |
48
- | `@yolk-sdk/agent/providers/xai/grok-provider` | Grok subscription LLM provider factory |
49
- | `@yolk-sdk/agent/providers/xai/usage` | Grok subscription-allowance snapshots |
50
- | `@yolk-sdk/agent/providers/subscription-usage` | Shared allowance snapshot and safe error schemas |
51
- | `@yolk-sdk/agent/skillset` | Portable skill and slash-command parsing/catalogs |
52
- | `@yolk-sdk/agent/voice` | Voice protocol, controller, tool handler, projection, speech |
53
- | `@yolk-sdk/agent/voice/browser` | Browser WebRTC voice transport |
54
- | `@yolk-sdk/agent/voice/react` | Headless browser voice React hook |
23
+ | Subpath | Purpose |
24
+ | -------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
25
+ | `@yolk-sdk/agent/protocol` | Wire messages, events, content, usage, tool schemas |
26
+ | `@yolk-sdk/agent/loop` | Stateless LLM/tool loop |
27
+ | `@yolk-sdk/agent/loop/testing` | Faux provider and tool executor test helpers |
28
+ | `@yolk-sdk/agent/runtime` | Transcript or append-backed runtime orchestration |
29
+ | `@yolk-sdk/agent/client` | HTTP/NDJSON transport, HITL resume, retry/error state helpers |
30
+ | `@yolk-sdk/agent/compaction` | Host-owned compaction budgets, checkpoints, formatting, retry |
31
+ | `@yolk-sdk/agent/classification` | Classifier model contract: typed questions, answers, usage, errors |
32
+ | `@yolk-sdk/agent/tools` | Tool registry, typed inputs, interactions, subagents/questions |
33
+ | `@yolk-sdk/agent/react` | Headless React chat hook, reducer, selectors, and render model |
34
+ | `@yolk-sdk/agent/oauth` | Provider-neutral OAuth token and broker contracts |
35
+ | `@yolk-sdk/agent/providers/openai` | OpenAI/Codex OAuth and broker helpers |
36
+ | `@yolk-sdk/agent/providers/openai/codex` | OpenAI Codex request and auth helpers |
37
+ | `@yolk-sdk/agent/providers/openai/codex-usage` | Codex subscription-allowance snapshots |
38
+ | `@yolk-sdk/agent/providers/openai/codex-provider` | Codex LLM provider factory |
39
+ | `@yolk-sdk/agent/providers/openai/provider` | OpenAI-compatible LLM provider factory |
40
+ | `@yolk-sdk/agent/providers/openai/conformance` | Synthetic OpenAI chat, Codex Responses, and Codex usage fixtures and conformance cases |
41
+ | `@yolk-sdk/agent/providers/openai/realtime` | OpenAI Realtime session config and event codecs |
42
+ | `@yolk-sdk/agent/providers/openai/speech` | OpenAI text-to-speech and transcription adapters |
43
+ | `@yolk-sdk/agent/providers/vercel/ai-gateway-provider` | Vercel AI Gateway Chat Completions provider factory |
44
+ | `@yolk-sdk/agent/providers/vercel/ai-gateway-classifier` | Vercel AI Gateway classifier (`POST /v1/evaluate`) layer |
45
+ | `@yolk-sdk/agent/providers/vercel/conformance` | Verified Gateway chat fixtures, synthetic classifier fixtures, and conformance cases |
46
+ | `@yolk-sdk/agent/providers/opencode/go-provider` | OpenCode Go Chat Completions, Messages, and Responses provider |
47
+ | `@yolk-sdk/agent/providers/opencode/usage` | OpenCode Go subscription-allowance snapshots |
48
+ | `@yolk-sdk/agent/providers/opencode/conformance` | Synthetic OpenCode Go (per protocol, commentary replay, usage) fixtures and conformance cases |
49
+ | `@yolk-sdk/agent/providers/anthropic` | Anthropic/Claude OAuth and broker helpers |
50
+ | `@yolk-sdk/agent/providers/anthropic/claude` | Claude request and auth helpers |
51
+ | `@yolk-sdk/agent/providers/anthropic/usage` | Claude subscription-allowance snapshots |
52
+ | `@yolk-sdk/agent/providers/anthropic/claude-provider` | Claude LLM provider factory |
53
+ | `@yolk-sdk/agent/providers/anthropic/conformance` | Synthetic Anthropic Messages and Claude usage fixtures and conformance cases |
54
+ | `@yolk-sdk/agent/providers/xai` | Grok subscription OAuth and token broker helpers |
55
+ | `@yolk-sdk/agent/providers/xai/grok` | Grok subscription request and auth helpers |
56
+ | `@yolk-sdk/agent/providers/xai/grok-provider` | Grok subscription LLM provider factory |
57
+ | `@yolk-sdk/agent/providers/xai/usage` | Grok subscription-allowance snapshots |
58
+ | `@yolk-sdk/agent/providers/xai/conformance` | Synthetic Grok Responses and Grok usage fixtures and conformance cases |
59
+ | `@yolk-sdk/agent/providers/subscription-usage` | Shared allowance snapshot and safe error schemas |
60
+ | `@yolk-sdk/agent/skillset` | Portable skill and slash-command parsing/catalogs |
61
+ | `@yolk-sdk/agent/voice` | Voice protocol, controller, tool handler, projection, speech |
62
+ | `@yolk-sdk/agent/voice/browser` | Browser WebRTC voice transport |
63
+ | `@yolk-sdk/agent/voice/react` | Headless browser voice React hook |
55
64
 
56
65
  ## Imports
57
66
 
@@ -88,7 +97,9 @@ import {
88
97
  modelVisibleToolError,
89
98
  modelVisibleToolErrorStructuredContent,
90
99
  makeQuestionToolModule,
91
- resolveTools
100
+ omitNullOptionalToolArguments,
101
+ resolveTools,
102
+ withToolArgumentsErrorHint
92
103
  } from '@yolk-sdk/agent/tools'
93
104
  import {
94
105
  AgentChatAction,
@@ -212,7 +223,7 @@ Server-side configuration fragment (the host supplies credentials and model poli
212
223
 
213
224
  ```ts
214
225
  import { Layer, Redacted } from 'effect'
215
- import { FetchHttpClient } from 'effect/unstable/http'
226
+ import { FetchHttpClient } from 'effect/http'
216
227
  import { makeOpenCodeGoProviderLayer } from '@yolk-sdk/agent/providers/opencode/go-provider'
217
228
 
218
229
  const GoLayer = makeOpenCodeGoProviderLayer({
@@ -240,7 +251,7 @@ Read Go subscription allowance separately from per-request token usage (server-s
240
251
 
241
252
  ```ts
242
253
  import { Effect, Redacted } from 'effect'
243
- import { FetchHttpClient } from 'effect/unstable/http'
254
+ import { FetchHttpClient } from 'effect/http'
244
255
  import { fetchOpenCodeGoSubscriptionUsage } from '@yolk-sdk/agent/providers/opencode/usage'
245
256
 
246
257
  const usageEffect = fetchOpenCodeGoSubscriptionUsage(Redacted.make(hostOpenCodeGoApiKey), {
@@ -248,7 +259,7 @@ const usageEffect = fetchOpenCodeGoSubscriptionUsage(Redacted.make(hostOpenCodeG
248
259
  }).pipe(Effect.provide(FetchHttpClient.layer))
249
260
  ```
250
261
 
251
- The fixed API-key endpoint returns used percentages/reset instants for `five-hour`, `seven-day`, and
262
+ The API-key endpoint (default `openCodeGoSubscriptionUsageUrl`) returns used percentages/reset instants for `five-hour`, `seven-day`, and
252
263
  `monthly` windows. Monthly resets follow the subscription's anniversary, not the first of the month;
253
264
  the adapter preserves the provider's timestamp. Missing/invalid percentages are omitted, not treated
254
265
  as zero. Treat snapshots as best-effort; hosts own polling, stale-data policy, persistence, and UI.
@@ -293,7 +304,8 @@ for unions, refinements, and tuples. The Claude adapter therefore projects tool
293
304
  provider-compatible object schema without `anyOf`, `oneOf`, `allOf`, or tuple-only `prefixItems`.
294
305
  When a constraint cannot be represented faithfully, the projection widens the model-facing schema
295
306
  rather than excluding a valid call. Tool execution remains safe because `makeTool` validates the
296
- returned arguments against the original Effect Schema before invoking the executor.
307
+ returned arguments against the original Effect Schema (through its JSON codec) before invoking the
308
+ executor.
297
309
 
298
310
  Before projection, `toAnthropicClaudeRequestBody` and the Claude provider decode `ToolDef.parameters`
299
311
  and `ToolCall.params` as `Schema.Json`. Non-JSON values fail as non-retryable `LLMError` with
@@ -317,7 +329,28 @@ remain opaque. Background wrapping preserves boolean `true`/`false` as the argum
317
329
  reference/resource restrictions still apply at activation. `makeTool` may add root `type: "object"`
318
330
  to typeless `anyOf`/`oneOf` unions whose members are all object schemas, as required by strict
319
331
  OpenAI-compatible upstreams; primitives, unknown, and already-typed roots are unchanged, and call
320
- validation still uses the original Effect Schema.
332
+ validation still decodes through the original Effect Schema's JSON codec. Effect 4.0.0 exports
333
+ `Schema.isPattern` to JSON Schema only for `u`-flag regexes (optionally with `d`, `g`, or `y`);
334
+ add `u` to keep model-visible `pattern` hints.
335
+
336
+ ### Tool arguments: `null` and unknown keys
337
+
338
+ Tool arguments are accepted exactly as advertised: unambiguous `null`s are normalized, and keys
339
+ that would be silently lost are rejected. `ToolDef.parameters` describes the schema's canonical JSON codec, so `Schema.optional(X)` is
340
+ advertised as `X | null`. `makeTool` (validate and execute), `makeInputTool`/`makeInteractionTool`
341
+ call params, and the loop `question` decode model arguments with `Schema.toCodecJson(parameters)`:
342
+ `null` on `Schema.optional(X)` decodes as absent and `withDecodingDefault` still applies,
343
+ `Schema.optional(Schema.NullOr(X))` keeps `null`, and required non-nullable fields still reject it.
344
+ `undefined`-valued keys from in-process callers count as absent.
345
+ Non-finite numbers (the codec's `"NaN"`/`"Infinity"` strings) are validation errors. Objects are
346
+ advertised closed (`additionalProperties: false`), so unknown keys at any depth are model-visible
347
+ validation errors instead of being stripped (also through closed-input declarations whose JSON codec
348
+ bypasses their own parser). Their error message names each unknown key and lists the allowed keys at that path; this includes
349
+ a `null` on another union member's field.
350
+ `resolveTools` also drops `null` where the advertised schema declares a property optional without
351
+ admitting `null` (for example `Schema.optionalKey(X)`, the subagent `model`, or raw MCP schemas)
352
+ before any registration sees the call; `omitNullOptionalToolArguments` (`@yolk-sdk/agent/tools`) exposes that step for hosts
353
+ that dispatch registrations themselves. User-submitted input/interaction responses are unchanged.
321
354
 
322
355
  ### OpenAI Chat Completions, Responses, and extraBody
323
356
 
@@ -410,7 +443,7 @@ Effect `HttpClient`:
410
443
 
411
444
  ```ts
412
445
  import { Effect } from 'effect'
413
- import { FetchHttpClient } from 'effect/unstable/http'
446
+ import { FetchHttpClient } from 'effect/http'
414
447
  import { fetchOpenAiCodexSubscriptionUsage } from '@yolk-sdk/agent/providers/openai/codex-usage'
415
448
 
416
449
  const snapshot = await fetchOpenAiCodexSubscriptionUsage(hostOAuthAccessToken).pipe(
@@ -430,7 +463,8 @@ version.
430
463
  Provider adapters return an immutable Effect `Chunk` of semantic window ids, percentages, and
431
464
  optional reset/duration fields; hosts own labels, polling, persistence, stale-data policy, alert
432
465
  thresholds, billing interpretation, and UI. Configure `requestTimeoutMs` at the server integration
433
- boundary. Endpoint origins stay fixed, and `FetchHttpClient.layer` is configured for manual
466
+ boundary. Each fetcher defaults to its exported URL constant; the optional `url` override is only
467
+ for a trusted proxy or local emulator, because the credential is sent to it. `FetchHttpClient.layer` is configured for manual
434
468
  redirects. A custom `HttpClient` must not follow redirects for these credential-bearing requests.
435
469
 
436
470
  Subscription allowance snapshots are separate from protocol `AgentUsage`, which accounts for tokens
@@ -748,6 +782,47 @@ handler, approval HITL, transcript projection, and one-shot TTS/STT contracts.
748
782
  overflow such as `{"n":1e999}` takes the same mapper-specific fallbacks. Approval identifiers,
749
783
  gates, deny, and execution schema validation are unchanged.
750
784
 
785
+ ## Classifier models
786
+
787
+ `@yolk-sdk/agent/classification` is a provider-neutral contract for classifier models such as
788
+ TypeSafe's Jev: one `state` (a string, JSON object, or JSON array) and named `boolean`, `choice`
789
+ (2-255 options), or `score` (2-10 levels, lowest first) questions, answered together with
790
+ probabilities. `classify` types each answer from its question (a choice answer's `choice` is the
791
+ union of its option keys) and checks every answer against its question. Probabilities are kept as
792
+ returned, never renormalized. Failures are typed (`ClassificationRequestInvalid`,
793
+ `ClassificationProviderError`, `ClassificationResponseInvalid`); a response that fails to decode
794
+ keeps the billed `usage`. Classification is a read; authorization stays host policy.
795
+
796
+ `@yolk-sdk/agent/providers/vercel/ai-gateway-classifier` calls AI Gateway `POST /v1/evaluate`
797
+ (Gateway calls this evaluation) with `typesafe-ai/jev` by default and the same Gateway credential
798
+ as the chat provider:
799
+
800
+ ```ts
801
+ import { Effect, Redacted } from 'effect'
802
+ import { FetchHttpClient } from 'effect/http'
803
+ import { classify } from '@yolk-sdk/agent/classification'
804
+ import { makeVercelAiGatewayClassifierLayer } from '@yolk-sdk/agent/providers/vercel/ai-gateway-classifier'
805
+
806
+ const program = classify({
807
+ state: { subject: 'Invoice question', body: 'I was charged twice.' },
808
+ questions: {
809
+ route: {
810
+ type: 'choice',
811
+ instructions: 'Which team should handle this ticket?',
812
+ criteria: { billing: 'Payments and refunds.', bug: 'Product defects.' }
813
+ }
814
+ }
815
+ }).pipe(
816
+ Effect.map(result => result.answers.route.choice), // 'billing' | 'bug'
817
+ Effect.provide(makeVercelAiGatewayClassifierLayer({ apiKey: Redacted.make(gatewayKey) })),
818
+ Effect.provide(FetchHttpClient.layer)
819
+ )
820
+ ```
821
+
822
+ `providerOptions` passes through unchanged (for example `{ gateway: { zeroDataRetention: true } }`).
823
+ `providerMetadata.gateway.cost` becomes `usage.costUsd`, and `x-ai-gateway-evaluation-fallback-*`
824
+ response headers are kept in `providerMetadata.evaluationFallbackHeaders`.
825
+
751
826
  ## Subagents
752
827
 
753
828
  `subagent` is the package-owned contract for child-agent delegation. The SDK provides schema,
@@ -838,6 +913,28 @@ Without a host, definitions, approval ids, and inline behavior are unchanged.
838
913
  - Hosts own authorization, status/wait tools, cancellation, terminal storage, usage, and delivery.
839
914
  Never append a second result for the original call.
840
915
 
916
+ ## Code mode tool contract
917
+
918
+ These options are the tool contract that [`@yolk-sdk/codemode`](../codemode/README.md) builds on.
919
+ This package declares them; it does not run scripts.
920
+
921
+ - `makeTool({ output })` adds declaration-only `ToolDef.outputSchema`, lowered like `parameters`.
922
+ - `callableBy: 'all' | 'model' | 'codemode'` (default `all`) decides who may call a tool. For
923
+ `codemode` only, `discovery: 'listed' | 'search'` (default `listed`) decides how scripts find it.
924
+ Codemode-only tools never reach providers. Approval, input, interaction, activated background,
925
+ `question`, `subagent`, and nested-access tools never run from code mode; `resolveTools` rejects
926
+ `callableBy: 'codemode'` on them.
927
+ - `nestedToolAccess: true` gives a registration's `execute` a `nested` executor over the other
928
+ code-mode-callable tools of the same resolution and host context. Nested calls run through the
929
+ resolved execute path and fail closed with model-visible error results. Assign nested call ids as
930
+ `<parentToolCallId>/<seq>`.
931
+ - `describe: ({ tools }) => string` on a nested-access registration computes its resolved
932
+ description from those nested tools; `def.description` stays the static fallback.
933
+ - Report nested calls with protocol `recordNestedToolCall` and `nestedToolCallResultFields`. The
934
+ bounded `ToolResult.nestedCalls` record and summed `ToolResult.usage` never reach the model:
935
+ `toolResultMessageFromResult` drops both, and the loop does not add `ToolResult.usage` to run
936
+ usage. Capture them from the `ToolResult` or tool events when you need audit or billing records.
937
+
841
938
  ## Tool failures
842
939
 
843
940
  Use `modelVisibleToolError(...)` for expected tool-domain failures the model can recover
@@ -847,9 +944,10 @@ see the message and continue. The result includes structured content with `type`
847
944
  `reason`, `message`, and optional `details` for UI/runtime handling.
848
945
 
849
946
  Optional `makeTool({ invalidParamsMessage })` receives the `Schema.SchemaError` produced by
850
- `Schema.decodeUnknownEffect` on `parameters` (validate and execute). The decode error is passed
947
+ decoding `parameters` through its JSON codec (validate and execute). The decode error is passed
851
948
  through unwrapped. Default text is `Invalid ${name} arguments: ${String(error)}`, which keeps the
852
- `SchemaError(...)` wrapper. In Effect rc.115, `SchemaError` extends native `Error`, but the
949
+ `SchemaError(...)` wrapper, followed by one line per object (path and allowed-key set) naming its unknown keys and
950
+ listing the allowed keys. Custom callbacks can append the same hint with `withToolArgumentsErrorHint(message, error)`. In Effect 4, `SchemaError` extends native `Error`, but the
853
951
  wrapper remains part of this tool-message contract; do not default to `.message`.
854
952
  Existing `(error: unknown) => string` callbacks remain assignable.
855
953
 
@@ -867,12 +965,16 @@ aborts, and implementation bugs outside typed tool execution.
867
965
  - Persist/return one `ToolResultMessage` for every host tool call, including `isError` failures.
868
966
  - Persist terminal provider failures and clear active run ids where applicable.
869
967
  - Provide tools, approval policy, auth, storage, and observability.
968
+ - If you send `ToolDef`s to providers yourself (outside `run`/`runModelTurn`), filter them with
969
+ protocol `providerToolDefs`; codemode-only tools must never reach providers. Executor decorators
970
+ outside `ResolvedToolSet.execute` do not see nested code mode calls.
870
971
  - Compact context and decide memory/search policy.
871
972
 
872
973
  ## Boundaries
873
974
 
874
975
  - Core loop/protocol/runtime/tools have no React, Next.js, provider SDKs, auth, storage drivers, or app concepts.
875
976
  - `@yolk-sdk/agent/compaction` combines pure planning/formatting helpers with Effect-native transformer and retry adapters; hosts own thresholds, summaries, compaction payloads, and durable compactor policy.
977
+ - `@yolk-sdk/agent/classification` is provider-neutral (no Node, React, or provider code); provider subpaths supply `ClassifierModel` layers.
876
978
  - `@yolk-sdk/agent/react` is headless and uses React as an optional peer.
877
979
  - Provider subpaths own vendor wire/auth mechanics only; hosts own token storage, refresh, routing, and policy.
878
980
  - `@yolk-sdk/agent/providers/openai/speech` is server integration requiring runtime
@@ -0,0 +1,57 @@
1
+ import * as Schema from "effect/Schema";
2
+ import { ProviderErrorInfo } from "@yolk-sdk/agent/protocol";
3
+
4
+ //#region src/classification/errors.d.ts
5
+ /**
6
+ * Why an answer does not fit its question:
7
+ *
8
+ * - `missing_answer`: a question has no answer.
9
+ * - `unexpected_answer`: an answer names no question that was asked.
10
+ * - `type_mismatch`: the answer's `type` is not the question's.
11
+ * - `invalid_probability`: a probability is missing, not a number, non-finite, or outside `[0, 1]`.
12
+ * - `invalid_confidence`: a confidence is not a finite number in `[0, 1]`.
13
+ * - `invalid_choice`: a choice answer names no option of its question.
14
+ * - `invalid_score`: a score answer has no finite `score`.
15
+ * - `malformed_answer`: the answer is not an object.
16
+ */
17
+ declare const ClassificationAnswerIssueReason: Schema.Literals<readonly ["missing_answer", "unexpected_answer", "type_mismatch", "invalid_probability", "invalid_confidence", "invalid_choice", "invalid_score", "malformed_answer"]>;
18
+ type ClassificationAnswerIssueReason = typeof ClassificationAnswerIssueReason.Type;
19
+ /** `malformed_response`: the response body is not the provider's documented envelope. */
20
+ declare const ClassificationResponseIssue: Schema.Literals<readonly ["malformed_response", "missing_answer", "unexpected_answer", "type_mismatch", "invalid_probability", "invalid_confidence", "invalid_choice", "invalid_score", "malformed_answer"]>;
21
+ type ClassificationResponseIssue = typeof ClassificationResponseIssue.Type;
22
+ declare const ClassificationRequestInvalid_base: Schema.Class<ClassificationRequestInvalid, Schema.TaggedStruct<"ClassificationRequestInvalid", {
23
+ readonly message: Schema.String;
24
+ }>, import("effect/Cause").YieldableError>;
25
+ /** The request does not satisfy the classification contract; nothing was sent. */
26
+ declare class ClassificationRequestInvalid extends ClassificationRequestInvalid_base {}
27
+ declare const ClassificationProviderError_base: Schema.Class<ClassificationProviderError, Schema.TaggedStruct<"ClassificationProviderError", {
28
+ readonly message: Schema.String;
29
+ readonly retryable: Schema.Boolean;
30
+ readonly provider: typeof ProviderErrorInfo;
31
+ }>, import("effect/Cause").YieldableError>;
32
+ /**
33
+ * The provider could not be reached or rejected the request. `message` is safe to show: it never
34
+ * carries provider bodies, headers, or credentials. `provider` classifies the failure (status,
35
+ * provider error code, retry delay).
36
+ */
37
+ declare class ClassificationProviderError extends ClassificationProviderError_base {}
38
+ declare const ClassificationResponseInvalid_base: Schema.Class<ClassificationResponseInvalid, Schema.TaggedStruct<"ClassificationResponseInvalid", {
39
+ readonly message: Schema.String; /** Provider id, when a provider (not the typed `classify` check) found the issue. */
40
+ readonly provider: Schema.optional<Schema.String>;
41
+ readonly reason: Schema.Literals<readonly ["malformed_response", "missing_answer", "unexpected_answer", "type_mismatch", "invalid_probability", "invalid_confidence", "invalid_choice", "invalid_score", "malformed_answer"]>;
42
+ readonly questionId: Schema.optional<Schema.String>;
43
+ readonly usage: Schema.optional<Schema.Struct<{
44
+ readonly inputTokens: Schema.Int;
45
+ readonly outputTokens: Schema.Int;
46
+ readonly costUsd: Schema.optionalKey<Schema.Finite>;
47
+ }>>;
48
+ }>, import("effect/Cause").YieldableError>;
49
+ /**
50
+ * The provider answered, but the response or one of its answers does not fit the request.
51
+ * `usage` is kept when the provider reported it, because the request was billed.
52
+ */
53
+ declare class ClassificationResponseInvalid extends ClassificationResponseInvalid_base {}
54
+ type ClassificationError = ClassificationRequestInvalid | ClassificationProviderError | ClassificationResponseInvalid;
55
+ //#endregion
56
+ export { ClassificationAnswerIssueReason, ClassificationError, ClassificationProviderError, ClassificationRequestInvalid, ClassificationResponseInvalid, ClassificationResponseIssue };
57
+ //# sourceMappingURL=errors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/classification/errors.ts"],"mappings":";;;;;;AAgBA;;;;AAA4C;AAW5C;;;;AAAyF;cAX5E,+BAAA,EAA+B,MAAA,CAAA,QAAA;AAAA,KAWhC,+BAAA,UAAyC,+BAAA,CAAgC,IAAI;;cAG5E,2BAAA,EAA2B,MAAA,CAAA,QAAA;AAAA,KAK5B,2BAAA,UAAqC,2BAAA,CAA4B,IAAI;AAAA,cAAA,iCAAA;;;;cAGpE,4BAAA,SAAqC,iCAKjD;AAAA,cAAG,gCAAA;;;;;;;;;;cAOS,2BAAA,SAAoC,gCAOhD;AAAA,cAAG,kCAAA;;;;;;;;;;;AAdA;;;;AAAA,cAoBS,6BAAA,SAAsC,kCAUlD;AAAA,KAEW,mBAAA,GACR,4BAAA,GACA,2BAAA,GACA,6BAAA"}
@@ -0,0 +1,56 @@
1
+ import { ClassificationUsage } from "./schema.mjs";
2
+ import * as Schema from "effect/Schema";
3
+ import { ProviderErrorInfo } from "@yolk-sdk/agent/protocol";
4
+ //#region src/classification/errors.ts
5
+ /**
6
+ * Why an answer does not fit its question:
7
+ *
8
+ * - `missing_answer`: a question has no answer.
9
+ * - `unexpected_answer`: an answer names no question that was asked.
10
+ * - `type_mismatch`: the answer's `type` is not the question's.
11
+ * - `invalid_probability`: a probability is missing, not a number, non-finite, or outside `[0, 1]`.
12
+ * - `invalid_confidence`: a confidence is not a finite number in `[0, 1]`.
13
+ * - `invalid_choice`: a choice answer names no option of its question.
14
+ * - `invalid_score`: a score answer has no finite `score`.
15
+ * - `malformed_answer`: the answer is not an object.
16
+ */
17
+ const ClassificationAnswerIssueReason = Schema.Literals([
18
+ "missing_answer",
19
+ "unexpected_answer",
20
+ "type_mismatch",
21
+ "invalid_probability",
22
+ "invalid_confidence",
23
+ "invalid_choice",
24
+ "invalid_score",
25
+ "malformed_answer"
26
+ ]);
27
+ /** `malformed_response`: the response body is not the provider's documented envelope. */
28
+ const ClassificationResponseIssue = Schema.Literals(["malformed_response", ...ClassificationAnswerIssueReason.literals]);
29
+ /** The request does not satisfy the classification contract; nothing was sent. */
30
+ var ClassificationRequestInvalid = class extends Schema.TaggedError()("ClassificationRequestInvalid", { message: Schema.String }) {};
31
+ /**
32
+ * The provider could not be reached or rejected the request. `message` is safe to show: it never
33
+ * carries provider bodies, headers, or credentials. `provider` classifies the failure (status,
34
+ * provider error code, retry delay).
35
+ */
36
+ var ClassificationProviderError = class extends Schema.TaggedError()("ClassificationProviderError", {
37
+ message: Schema.String,
38
+ retryable: Schema.Boolean,
39
+ provider: ProviderErrorInfo
40
+ }) {};
41
+ /**
42
+ * The provider answered, but the response or one of its answers does not fit the request.
43
+ * `usage` is kept when the provider reported it, because the request was billed.
44
+ */
45
+ var ClassificationResponseInvalid = class extends Schema.TaggedError()("ClassificationResponseInvalid", {
46
+ message: Schema.String,
47
+ /** Provider id, when a provider (not the typed `classify` check) found the issue. */
48
+ provider: Schema.optional(Schema.String),
49
+ reason: ClassificationResponseIssue,
50
+ questionId: Schema.optional(Schema.String),
51
+ usage: Schema.optional(ClassificationUsage)
52
+ }) {};
53
+ //#endregion
54
+ export { ClassificationAnswerIssueReason, ClassificationProviderError, ClassificationRequestInvalid, ClassificationResponseInvalid, ClassificationResponseIssue };
55
+
56
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../src/classification/errors.ts"],"sourcesContent":["import * as Schema from 'effect/Schema'\nimport { ProviderErrorInfo } from '@yolk-sdk/agent/protocol'\nimport { ClassificationUsage } from './schema.ts'\n\n/**\n * Why an answer does not fit its question:\n *\n * - `missing_answer`: a question has no answer.\n * - `unexpected_answer`: an answer names no question that was asked.\n * - `type_mismatch`: the answer's `type` is not the question's.\n * - `invalid_probability`: a probability is missing, not a number, non-finite, or outside `[0, 1]`.\n * - `invalid_confidence`: a confidence is not a finite number in `[0, 1]`.\n * - `invalid_choice`: a choice answer names no option of its question.\n * - `invalid_score`: a score answer has no finite `score`.\n * - `malformed_answer`: the answer is not an object.\n */\nexport const ClassificationAnswerIssueReason = Schema.Literals([\n 'missing_answer',\n 'unexpected_answer',\n 'type_mismatch',\n 'invalid_probability',\n 'invalid_confidence',\n 'invalid_choice',\n 'invalid_score',\n 'malformed_answer'\n])\n\nexport type ClassificationAnswerIssueReason = typeof ClassificationAnswerIssueReason.Type\n\n/** `malformed_response`: the response body is not the provider's documented envelope. */\nexport const ClassificationResponseIssue = Schema.Literals([\n 'malformed_response',\n ...ClassificationAnswerIssueReason.literals\n])\n\nexport type ClassificationResponseIssue = typeof ClassificationResponseIssue.Type\n\n/** The request does not satisfy the classification contract; nothing was sent. */\nexport class ClassificationRequestInvalid extends Schema.TaggedError<ClassificationRequestInvalid>()(\n 'ClassificationRequestInvalid',\n {\n message: Schema.String\n }\n) {}\n\n/**\n * The provider could not be reached or rejected the request. `message` is safe to show: it never\n * carries provider bodies, headers, or credentials. `provider` classifies the failure (status,\n * provider error code, retry delay).\n */\nexport class ClassificationProviderError extends Schema.TaggedError<ClassificationProviderError>()(\n 'ClassificationProviderError',\n {\n message: Schema.String,\n retryable: Schema.Boolean,\n provider: ProviderErrorInfo\n }\n) {}\n\n/**\n * The provider answered, but the response or one of its answers does not fit the request.\n * `usage` is kept when the provider reported it, because the request was billed.\n */\nexport class ClassificationResponseInvalid extends Schema.TaggedError<ClassificationResponseInvalid>()(\n 'ClassificationResponseInvalid',\n {\n message: Schema.String,\n /** Provider id, when a provider (not the typed `classify` check) found the issue. */\n provider: Schema.optional(Schema.String),\n reason: ClassificationResponseIssue,\n questionId: Schema.optional(Schema.String),\n usage: Schema.optional(ClassificationUsage)\n }\n) {}\n\nexport type ClassificationError =\n | ClassificationRequestInvalid\n | ClassificationProviderError\n | ClassificationResponseInvalid\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,kCAAkC,OAAO,SAAS;CAC7D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAKD,MAAa,8BAA8B,OAAO,SAAS,CACzD,sBACA,GAAG,gCAAgC,QACrC,CAAC;;AAKD,IAAa,+BAAb,cAAkD,OAAO,YAA0C,EACjG,gCACA,EACE,SAAS,OAAO,OAClB,CACF,EAAE,CAAC;;;;;;AAOH,IAAa,8BAAb,cAAiD,OAAO,YAAyC,EAC/F,+BACA;CACE,SAAS,OAAO;CAChB,WAAW,OAAO;CAClB,UAAU;AACZ,CACF,EAAE,CAAC;;;;;AAMH,IAAa,gCAAb,cAAmD,OAAO,YAA2C,EACnG,iCACA;CACE,SAAS,OAAO;;CAEhB,UAAU,OAAO,SAAS,OAAO,MAAM;CACvC,QAAQ;CACR,YAAY,OAAO,SAAS,OAAO,MAAM;CACzC,OAAO,OAAO,SAAS,mBAAmB;AAC5C,CACF,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ClassificationAnswerIssueReason, ClassificationError, ClassificationProviderError, ClassificationRequestInvalid, ClassificationResponseInvalid, ClassificationResponseIssue } from "./errors.mjs";
2
+ import { BooleanClassifierAnswer, BooleanClassifierQuestion, ChoiceClassifierAnswer, ChoiceClassifierQuestion, ClassificationRequest, ClassificationResult, ClassificationUsage, ClassifierAnswer, ClassifierCriterion, ClassifierProbabilities, ClassifierProbability, ClassifierQuestion, ClassifierQuestionType, ClassifierQuestions, ClassifierState, ScoreClassifierAnswer, ScoreClassifierQuestion, maxClassifierChoiceOptions, maxClassifierScoreLevels, minClassifierChoiceOptions, minClassifierScoreLevels } from "./schema.mjs";
3
+ import { ClassificationAnswerIssue, ClassificationRequestFor, ClassificationResultFor, ClassifierAnswerFor, ClassifierAnswersFor, ClassifierModel, ClassifierQuestionsInput, classificationAnswersIssue, classify, decodeClassificationRequest, decodeClassifierAnswer, decodeClassifierAnswers, isClassificationResultFor } from "./model.mjs";
4
+ export { BooleanClassifierAnswer, BooleanClassifierQuestion, ChoiceClassifierAnswer, ChoiceClassifierQuestion, type ClassificationAnswerIssue, ClassificationAnswerIssueReason, type ClassificationError, ClassificationProviderError, ClassificationRequest, type ClassificationRequestFor, ClassificationRequestInvalid, ClassificationResponseInvalid, ClassificationResponseIssue, ClassificationResult, type ClassificationResultFor, ClassificationUsage, ClassifierAnswer, type ClassifierAnswerFor, type ClassifierAnswersFor, ClassifierCriterion, ClassifierModel, ClassifierProbabilities, ClassifierProbability, ClassifierQuestion, type ClassifierQuestionType, ClassifierQuestions, type ClassifierQuestionsInput, ClassifierState, ScoreClassifierAnswer, ScoreClassifierQuestion, classificationAnswersIssue, classify, decodeClassificationRequest, decodeClassifierAnswer, decodeClassifierAnswers, isClassificationResultFor, maxClassifierChoiceOptions, maxClassifierScoreLevels, minClassifierChoiceOptions, minClassifierScoreLevels };
@@ -0,0 +1,4 @@
1
+ import { BooleanClassifierAnswer, BooleanClassifierQuestion, ChoiceClassifierAnswer, ChoiceClassifierQuestion, ClassificationRequest, ClassificationResult, ClassificationUsage, ClassifierAnswer, ClassifierCriterion, ClassifierProbabilities, ClassifierProbability, ClassifierQuestion, ClassifierQuestions, ClassifierState, ScoreClassifierAnswer, ScoreClassifierQuestion, maxClassifierChoiceOptions, maxClassifierScoreLevels, minClassifierChoiceOptions, minClassifierScoreLevels } from "./schema.mjs";
2
+ import { ClassificationAnswerIssueReason, ClassificationProviderError, ClassificationRequestInvalid, ClassificationResponseInvalid, ClassificationResponseIssue } from "./errors.mjs";
3
+ import { ClassifierModel, classificationAnswersIssue, classify, decodeClassificationRequest, decodeClassifierAnswer, decodeClassifierAnswers, isClassificationResultFor } from "./model.mjs";
4
+ export { BooleanClassifierAnswer, BooleanClassifierQuestion, ChoiceClassifierAnswer, ChoiceClassifierQuestion, ClassificationAnswerIssueReason, ClassificationProviderError, ClassificationRequest, ClassificationRequestInvalid, ClassificationResponseInvalid, ClassificationResponseIssue, ClassificationResult, ClassificationUsage, ClassifierAnswer, ClassifierCriterion, ClassifierModel, ClassifierProbabilities, ClassifierProbability, ClassifierQuestion, ClassifierQuestions, ClassifierState, ScoreClassifierAnswer, ScoreClassifierQuestion, classificationAnswersIssue, classify, decodeClassificationRequest, decodeClassifierAnswer, decodeClassifierAnswers, isClassificationResultFor, maxClassifierChoiceOptions, maxClassifierScoreLevels, minClassifierChoiceOptions, minClassifierScoreLevels };
@@ -0,0 +1,74 @@
1
+ import { ClassificationAnswerIssueReason, ClassificationError, ClassificationRequestInvalid } from "./errors.mjs";
2
+ import { BooleanClassifierAnswer, ChoiceClassifierAnswer, ClassificationRequest, ClassificationResult, ClassifierAnswer, ClassifierQuestion, ScoreClassifierAnswer } from "./schema.mjs";
3
+ import { Context, Effect, Result } from "effect";
4
+
5
+ //#region src/classification/model.d.ts
6
+ declare const ClassifierModel_base: Context.ServiceClass<ClassifierModel, "@yolk-sdk/agent/classification/ClassifierModel", {
7
+ readonly classify: (request: ClassificationRequest) => Effect.Effect<ClassificationResult, ClassificationError>;
8
+ }>;
9
+ /**
10
+ * Answers typed questions about one state. Classification is a read: it has no side effects.
11
+ * Providers supply layers; `classify` is the typed entry point.
12
+ */
13
+ declare class ClassifierModel extends ClassifierModel_base {}
14
+ /** Named questions, typed for inference. */
15
+ type ClassifierQuestionsInput = {
16
+ readonly [questionId: string]: ClassifierQuestion;
17
+ };
18
+ /** The answer type a question gets; a choice answer's `choice` is the union of its option keys. */
19
+ type ClassifierAnswerFor<Q extends ClassifierQuestion> = Q extends {
20
+ readonly type: 'boolean';
21
+ } ? BooleanClassifierAnswer : Q extends {
22
+ readonly type: 'choice';
23
+ readonly criteria: infer Criteria;
24
+ } ? ChoiceClassifierAnswer & {
25
+ readonly choice: Extract<keyof Criteria, string>;
26
+ } : ScoreClassifierAnswer;
27
+ type ClassifierAnswersFor<Q extends ClassifierQuestionsInput> = { readonly [K in keyof Q]: ClassifierAnswerFor<Q[K]> };
28
+ type ClassificationRequestFor<Q extends ClassifierQuestionsInput> = Omit<ClassificationRequest, 'questions'> & {
29
+ readonly questions: Q;
30
+ };
31
+ type ClassificationResultFor<Q extends ClassifierQuestionsInput> = ClassificationResult & {
32
+ readonly answers: ClassifierAnswersFor<Q>;
33
+ };
34
+ /** Where an answer leaves its question. */
35
+ type ClassificationAnswerIssue = {
36
+ readonly reason: ClassificationAnswerIssueReason;
37
+ readonly questionId: string;
38
+ };
39
+ /**
40
+ * Decode one raw provider answer against the question it answers. The answer must be an object
41
+ * whose `type` is the question's; probabilities and confidence must be finite numbers in `[0, 1]`
42
+ * and are kept exactly as given (never renormalized); a choice must name one of the question's
43
+ * options; a score must be finite. Only the contract fields are kept.
44
+ */
45
+ declare const decodeClassifierAnswer: (question: ClassifierQuestion, raw: unknown) => Result.Result<ClassifierAnswer, ClassificationAnswerIssueReason>;
46
+ /**
47
+ * Decode raw provider answers (a JSON object keyed by question id) against the questions asked:
48
+ * every question needs exactly one answer of its type, and no answer may name a question that was
49
+ * not asked. Fails with the first issue, in question order (then unexpected answers); answers that
50
+ * are not an object fail as the first question's `malformed_answer`.
51
+ */
52
+ declare const decodeClassifierAnswers: (questions: ClassifierQuestionsInput, raw: unknown) => Result.Result<Record<string, ClassifierAnswer>, ClassificationAnswerIssue>;
53
+ /** The first way `answers` leaves `questions`, or undefined when every answer fits its question. */
54
+ declare const classificationAnswersIssue: (questions: ClassifierQuestionsInput, answers: {
55
+ readonly [questionId: string]: ClassifierAnswer;
56
+ }) => ClassificationAnswerIssue | undefined;
57
+ /** Narrow a result to the answer types its questions infer, after checking every answer. */
58
+ declare const isClassificationResultFor: <const Q extends ClassifierQuestionsInput>(questions: Q, result: ClassificationResult) => result is ClassificationResultFor<Q>;
59
+ /**
60
+ * Validate a request against the classification contract before anything is sent. Fails with
61
+ * `ClassificationRequestInvalid` (for example a choice with more than 255 options, or a score with
62
+ * more than 10 levels).
63
+ */
64
+ declare const decodeClassificationRequest: (request: unknown) => Effect.Effect<ClassificationRequest, ClassificationRequestInvalid>;
65
+ /**
66
+ * Classify with the `ClassifierModel` in context, typing each answer from its question: a choice
67
+ * answer's `choice` is the union of that question's option keys. Every answer is checked against
68
+ * its question; a provider that returns a mismatching answer fails with
69
+ * `ClassificationResponseInvalid` (keeping usage).
70
+ */
71
+ declare const classify: <const Q extends ClassifierQuestionsInput>(request: ClassificationRequestFor<Q>) => Effect.Effect<ClassificationResultFor<Q>, ClassificationError, ClassifierModel>;
72
+ //#endregion
73
+ export { ClassificationAnswerIssue, ClassificationRequestFor, ClassificationResultFor, ClassifierAnswerFor, ClassifierAnswersFor, ClassifierModel, ClassifierQuestionsInput, classificationAnswersIssue, classify, decodeClassificationRequest, decodeClassifierAnswer, decodeClassifierAnswers, isClassificationResultFor };
74
+ //# sourceMappingURL=model.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.mts","names":[],"sources":["../../src/classification/model.ts"],"mappings":";;;;;cAiBoB,oBAAA;sBAUd,OAAA,EAAS,qBAAA,KACN,MAAA,CAAO,MAAA,CAAO,oBAAA,EAAsB,mBAAA;AAAA;;;;;cALhC,eAAA,SAAwB,oBAOgB;;KAGzC,wBAAA;EAAA,UAAuC,UAAA,WAAqB,kBAAkB;AAAA;;KAG9E,mBAAA,WAA8B,kBAAA,IAAsB,CAAA;EAAA,SACrD,IAAA;AAAA,IAEP,uBAAA,GACA,CAAA;EAAA,SAAqB,IAAA;EAAA,SAAyB,QAAA;AAAA,IAC5C,sBAAA;EAAA,SAAoC,MAAA,EAAQ,OAAA,OAAc,QAAA;AAAA,IAC1D,qBAAA;AAAA,KAEM,oBAAA,WAA+B,wBAAA,2BACpB,CAAA,GAAI,mBAAA,CAAoB,CAAA,CAAE,CAAA;AAAA,KAGrC,wBAAA,WAAmC,wBAAA,IAA4B,IAAA,CACzE,qBAAA;EAAA,SAEa,SAAA,EAAW,CAAA;AAAA;AAAA,KAEd,uBAAA,WAAkC,wBAAA,IAA4B,oBAAA;EAAA,SAC/D,OAAA,EAAS,oBAAA,CAAqB,CAAA;AAAA;;KAI7B,yBAAA;EAAA,SACD,MAAA,EAAQ,+BAA+B;EAAA,SACvC,UAAA;AAAA;;;;;;;cAuDE,sBAAA,GACX,QAAA,EAAU,kBAAA,EACV,GAAA,cACC,MAAA,CAAO,MAAA,CAAO,gBAAA,EAAkB,+BAAA;;;;;;;cAwDtB,uBAAA,GACX,SAAA,EAAW,wBAAA,EACX,GAAA,cACC,MAAA,CAAO,MAAA,CAAO,MAAA,SAAe,gBAAA,GAAmB,yBAAA;;cAkCtC,0BAAA,GACX,SAAA,EAAW,wBAAA,EACX,OAAA;EAAA,UAAqB,UAAA,WAAqB,gBAAA;AAAA,MACzC,yBAAA;;cAOU,yBAAA,mBAA6C,wBAAA,EACxD,SAAA,EAAW,CAAA,EACX,MAAA,EAAQ,oBAAA,KACP,MAAA,IAAU,uBAAA,CAAwB,CAAA;;;;;;cAQxB,2BAAA,GACX,OAAA,cACC,MAAA,CAAO,MAAA,CAAO,qBAAA,EAAuB,4BAAA;;AAhMb;AAE3B;;;;cA6Ma,QAAA,mBAA4B,wBAAA,EACvC,OAAA,EAAS,wBAAA,CAAyB,CAAA,MACjC,MAAA,CAAO,MAAA,CAAO,uBAAA,CAAwB,CAAA,GAAI,mBAAA,EAAqB,eAAA"}