@code-yeongyu/senpi 2026.7.14 → 2026.7.16-3

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 (459) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/README.md +6 -6
  3. package/dist/bun/cli.js +2 -0
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/cli/args.js +1 -1
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/list-models.d.ts +2 -2
  8. package/dist/cli/list-models.d.ts.map +1 -1
  9. package/dist/cli/list-models.js +3 -3
  10. package/dist/cli/list-models.js.map +1 -1
  11. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  12. package/dist/core/agent-session-runtime.js +3 -0
  13. package/dist/core/agent-session-runtime.js.map +1 -1
  14. package/dist/core/agent-session-services.d.ts +4 -3
  15. package/dist/core/agent-session-services.d.ts.map +1 -1
  16. package/dist/core/agent-session-services.js +14 -5
  17. package/dist/core/agent-session-services.js.map +1 -1
  18. package/dist/core/agent-session.d.ts +8 -4
  19. package/dist/core/agent-session.d.ts.map +1 -1
  20. package/dist/core/agent-session.js +81 -30
  21. package/dist/core/agent-session.js.map +1 -1
  22. package/dist/core/auth-providers.js +1 -1
  23. package/dist/core/auth-providers.js.map +1 -1
  24. package/dist/core/auth-storage.d.ts +32 -87
  25. package/dist/core/auth-storage.d.ts.map +1 -1
  26. package/dist/core/auth-storage.js +158 -221
  27. package/dist/core/auth-storage.js.map +1 -1
  28. package/dist/core/cache-stats.d.ts +2 -2
  29. package/dist/core/cache-stats.d.ts.map +1 -1
  30. package/dist/core/cache-stats.js +1 -1
  31. package/dist/core/cache-stats.js.map +1 -1
  32. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  33. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  34. package/dist/core/compaction/branch-summarization.js.map +1 -1
  35. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  36. package/dist/core/dynamic-prompt/build.js +6 -1
  37. package/dist/core/dynamic-prompt/build.js.map +1 -1
  38. package/dist/core/extensions/builtin/bash-timeout/timeout.js +2 -2
  39. package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
  40. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.d.ts.map +1 -1
  41. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +22 -13
  42. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  43. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts +1 -1
  44. package/dist/core/extensions/builtin/terminal/runtime-session.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/terminal/runtime-session.js +3 -2
  46. package/dist/core/extensions/builtin/terminal/runtime-session.js.map +1 -1
  47. package/dist/core/extensions/loader.d.ts.map +1 -1
  48. package/dist/core/extensions/loader.js +8 -2
  49. package/dist/core/extensions/loader.js.map +1 -1
  50. package/dist/core/extensions/runner.d.ts +1 -0
  51. package/dist/core/extensions/runner.d.ts.map +1 -1
  52. package/dist/core/extensions/runner.js +3 -0
  53. package/dist/core/extensions/runner.js.map +1 -1
  54. package/dist/core/extensions/types.d.ts +15 -2
  55. package/dist/core/extensions/types.d.ts.map +1 -1
  56. package/dist/core/extensions/types.js.map +1 -1
  57. package/dist/core/model-config.d.ts +589 -0
  58. package/dist/core/model-config.d.ts.map +1 -0
  59. package/dist/core/model-config.js +288 -0
  60. package/dist/core/model-config.js.map +1 -0
  61. package/dist/core/model-registry.d.ts +17 -146
  62. package/dist/core/model-registry.d.ts.map +1 -1
  63. package/dist/core/model-registry.js +69 -943
  64. package/dist/core/model-registry.js.map +1 -1
  65. package/dist/core/model-resolver.d.ts +8 -5
  66. package/dist/core/model-resolver.d.ts.map +1 -1
  67. package/dist/core/model-resolver.js +19 -18
  68. package/dist/core/model-resolver.js.map +1 -1
  69. package/dist/core/model-runtime.d.ts +81 -0
  70. package/dist/core/model-runtime.d.ts.map +1 -0
  71. package/dist/core/model-runtime.js +442 -0
  72. package/dist/core/model-runtime.js.map +1 -0
  73. package/dist/core/models-store.d.ts +17 -0
  74. package/dist/core/models-store.d.ts.map +1 -0
  75. package/dist/core/models-store.js +46 -0
  76. package/dist/core/models-store.js.map +1 -0
  77. package/dist/core/package-manager.d.ts.map +1 -1
  78. package/dist/core/package-manager.js +7 -2
  79. package/dist/core/package-manager.js.map +1 -1
  80. package/dist/core/provider-composer.d.ts +64 -0
  81. package/dist/core/provider-composer.d.ts.map +1 -0
  82. package/dist/core/provider-composer.js +406 -0
  83. package/dist/core/provider-composer.js.map +1 -0
  84. package/dist/core/provider-display-names.d.ts.map +1 -1
  85. package/dist/core/provider-display-names.js +2 -1
  86. package/dist/core/provider-display-names.js.map +1 -1
  87. package/dist/core/radius.d.ts +2 -0
  88. package/dist/core/radius.d.ts.map +1 -0
  89. package/dist/core/radius.js +2 -0
  90. package/dist/core/radius.js.map +1 -0
  91. package/dist/core/remote-catalog-provider.d.ts +5 -0
  92. package/dist/core/remote-catalog-provider.d.ts.map +1 -0
  93. package/dist/core/remote-catalog-provider.js +83 -0
  94. package/dist/core/remote-catalog-provider.js.map +1 -0
  95. package/dist/core/runtime-credentials.d.ts +15 -0
  96. package/dist/core/runtime-credentials.d.ts.map +1 -0
  97. package/dist/core/runtime-credentials.js +35 -0
  98. package/dist/core/runtime-credentials.js.map +1 -0
  99. package/dist/core/sdk.d.ts +11 -20
  100. package/dist/core/sdk.d.ts.map +1 -1
  101. package/dist/core/sdk.js +61 -89
  102. package/dist/core/sdk.js.map +1 -1
  103. package/dist/core/skills.js +1 -1
  104. package/dist/core/skills.js.map +1 -1
  105. package/dist/core/system-prompt.d.ts.map +1 -1
  106. package/dist/core/system-prompt.js +1 -11
  107. package/dist/core/system-prompt.js.map +1 -1
  108. package/dist/index.d.ts +2 -1
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2 -2
  111. package/dist/index.js.map +1 -1
  112. package/dist/main.d.ts.map +1 -1
  113. package/dist/main.js +10 -13
  114. package/dist/main.js.map +1 -1
  115. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  116. package/dist/modes/interactive/components/assistant-message.js +22 -10
  117. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  118. package/dist/modes/interactive/components/footer.js +1 -1
  119. package/dist/modes/interactive/components/footer.js.map +1 -1
  120. package/dist/modes/interactive/components/login-dialog.d.ts +4 -8
  121. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  122. package/dist/modes/interactive/components/login-dialog.js +14 -12
  123. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  124. package/dist/modes/interactive/components/model-selector.d.ts +13 -4
  125. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  126. package/dist/modes/interactive/components/model-selector.js +84 -41
  127. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  128. package/dist/modes/interactive/components/oauth-selector.d.ts +4 -4
  129. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  130. package/dist/modes/interactive/components/oauth-selector.js +14 -25
  131. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  132. package/dist/modes/interactive/interactive-mode.d.ts +5 -1
  133. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  134. package/dist/modes/interactive/interactive-mode.js +155 -129
  135. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  136. package/dist/package-manager-cli.d.ts.map +1 -1
  137. package/dist/package-manager-cli.js +70 -8
  138. package/dist/package-manager-cli.js.map +1 -1
  139. package/docs/custom-provider.md +8 -11
  140. package/docs/extensions.md +78 -555
  141. package/docs/models.md +4 -0
  142. package/docs/packages.md +1 -0
  143. package/docs/providers.md +23 -11
  144. package/docs/sdk.md +79 -105
  145. package/docs/usage.md +1 -0
  146. package/examples/AGENTS.md +34 -0
  147. package/examples/extensions/README.md +1 -0
  148. package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
  149. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  150. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  151. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  152. package/examples/extensions/gondolin/package-lock.json +2 -2
  153. package/examples/extensions/gondolin/package.json +1 -1
  154. package/examples/extensions/kimi-deferred-tools.ts +61 -0
  155. package/examples/extensions/sandbox/package-lock.json +2 -2
  156. package/examples/extensions/sandbox/package.json +1 -1
  157. package/examples/extensions/with-deps/package-lock.json +2 -2
  158. package/examples/extensions/with-deps/package.json +1 -1
  159. package/examples/sdk/02-custom-model.ts +5 -8
  160. package/examples/sdk/09-api-keys-and-oauth.ts +13 -31
  161. package/examples/sdk/12-full-control.ts +8 -13
  162. package/examples/sdk/README.md +14 -18
  163. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +40 -0
  164. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  165. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/local-module-loader.ts +2 -2
  166. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/rewrite-imports.ts +4 -4
  167. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +32 -32
  168. package/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
  169. package/node_modules/@earendil-works/pi-ai/README.md +80 -25
  170. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  171. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +23 -42
  172. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  173. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  174. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js +10 -6
  175. package/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.js.map +1 -1
  176. package/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts.map +1 -1
  177. package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +9 -10
  178. package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js.map +1 -1
  179. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +1 -0
  180. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
  181. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +4 -3
  182. package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
  183. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
  184. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  185. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +54 -5
  186. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  187. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
  188. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +23 -0
  189. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
  190. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +1 -0
  191. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
  192. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +24 -6
  193. package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
  194. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +97 -0
  195. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -0
  196. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +307 -0
  197. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -0
  198. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts +3 -0
  199. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts.map +1 -0
  200. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.js +3 -0
  201. package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.js.map +1 -0
  202. package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts +2 -1
  203. package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts.map +1 -1
  204. package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js +3 -0
  205. package/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.js.map +1 -1
  206. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts +1 -0
  207. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts.map +1 -1
  208. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js +4 -3
  209. package/node_modules/@earendil-works/pi-ai/dist/auth/helpers.js.map +1 -1
  210. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts +9 -0
  211. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.d.ts.map +1 -0
  212. package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/anthropic.js +51 -116
  213. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/anthropic.js.map +1 -0
  214. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.d.ts.map +1 -0
  215. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/device-code.js.map +1 -0
  216. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts +6 -0
  217. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.d.ts.map +1 -0
  218. package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/github-copilot.js +18 -77
  219. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/github-copilot.js.map +1 -0
  220. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts +23 -0
  221. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.d.ts.map +1 -0
  222. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js +49 -0
  223. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/load.js.map +1 -0
  224. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.d.ts.map +1 -0
  225. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/oauth-page.js.map +1 -0
  226. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts +9 -0
  227. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.d.ts.map +1 -0
  228. package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/openai-codex.js +61 -155
  229. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/openai-codex.js.map +1 -0
  230. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/pkce.d.ts.map +1 -0
  231. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/pkce.js.map +1 -0
  232. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts +16 -0
  233. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.d.ts.map +1 -0
  234. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js +316 -0
  235. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/radius.js.map +1 -0
  236. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.d.ts +6 -0
  237. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.d.ts.map +1 -0
  238. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.js +189 -0
  239. package/node_modules/@earendil-works/pi-ai/dist/auth/oauth/xai.js.map +1 -0
  240. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +2 -4
  241. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts.map +1 -1
  242. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js +9 -7
  243. package/node_modules/@earendil-works/pi-ai/dist/auth/resolve.js.map +1 -1
  244. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +49 -10
  245. package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
  246. package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
  247. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts +3 -0
  248. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.d.ts.map +1 -0
  249. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js +17 -0
  250. package/node_modules/@earendil-works/pi-ai/dist/bun-oauth.js.map +1 -0
  251. package/node_modules/@earendil-works/pi-ai/dist/cli.js +58 -76
  252. package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -1
  253. package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +42 -0
  254. package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts.map +1 -0
  255. package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.js +2 -0
  256. package/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.js.map +1 -0
  257. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +2 -0
  258. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  259. package/node_modules/@earendil-works/pi-ai/dist/compat.js +49 -22
  260. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  261. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  262. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +1 -0
  263. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  264. package/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts +4 -2
  265. package/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts.map +1 -1
  266. package/node_modules/@earendil-works/pi-ai/dist/images-models.js +5 -4
  267. package/node_modules/@earendil-works/pi-ai/dist/images-models.js.map +1 -1
  268. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +3 -1
  269. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  270. package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
  271. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  272. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +25 -0
  273. package/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts.map +1 -0
  274. package/node_modules/@earendil-works/pi-ai/dist/models-store.js +16 -0
  275. package/node_modules/@earendil-works/pi-ai/dist/models-store.js.map +1 -0
  276. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +69 -30
  277. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  278. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +372 -120
  279. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  280. package/node_modules/@earendil-works/pi-ai/dist/models.js +217 -31
  281. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  282. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts +2 -1
  283. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -1
  284. package/node_modules/@earendil-works/pi-ai/dist/oauth.js +1 -1
  285. package/node_modules/@earendil-works/pi-ai/dist/oauth.js.map +1 -1
  286. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +11 -6
  287. package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
  288. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +3 -0
  289. package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
  290. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  291. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +51 -10
  292. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  293. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  294. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +1 -1
  295. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  296. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.d.ts.map +1 -1
  297. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js +4 -3
  298. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.js.map +1 -1
  299. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.d.ts.map +1 -1
  300. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js +13 -20
  301. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-auth.js.map +1 -1
  302. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.d.ts +8 -0
  303. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.d.ts.map +1 -0
  304. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.js +21 -0
  305. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-stream.js.map +1 -0
  306. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.d.ts.map +1 -1
  307. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.js +2 -1
  308. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.js.map +1 -1
  309. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.d.ts.map +1 -1
  310. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js +11 -1
  311. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.js.map +1 -1
  312. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +1 -6
  313. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
  314. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +1 -2
  315. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
  316. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
  317. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js +56 -5
  318. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -1
  319. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +66 -0
  320. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
  321. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +42 -0
  322. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
  323. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +36 -0
  324. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
  325. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +19 -0
  326. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
  327. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +36 -0
  328. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
  329. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +19 -0
  330. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
  331. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.d.ts.map +1 -1
  332. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js +1 -1
  333. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.js.map +1 -1
  334. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +44 -0
  335. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
  336. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +36 -0
  337. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
  338. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +57 -0
  339. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
  340. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +19 -0
  341. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
  342. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +42 -0
  343. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
  344. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +175 -139
  345. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  346. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts +26 -0
  347. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.d.ts.map +1 -0
  348. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js +59 -0
  349. package/node_modules/@earendil-works/pi-ai/dist/providers/radius-config.js.map +1 -0
  350. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts +9 -0
  351. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts.map +1 -0
  352. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js +54 -0
  353. package/node_modules/@earendil-works/pi-ai/dist/providers/radius.js.map +1 -0
  354. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +84 -0
  355. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +74 -2
  357. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  358. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.d.ts +1 -1
  359. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.d.ts.map +1 -1
  360. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.js +15 -3
  361. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.js.map +1 -1
  362. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +6 -114
  363. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +3 -92
  365. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
  367. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +9 -0
  368. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
  369. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
  370. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
  371. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +6 -2
  372. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
  373. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts +8 -0
  374. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts.map +1 -0
  375. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js +92 -0
  376. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js.map +1 -0
  377. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts +6 -0
  378. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts.map +1 -0
  379. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js +54 -0
  380. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js.map +1 -0
  381. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.d.ts +4 -0
  382. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.d.ts.map +1 -0
  383. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.js +4 -0
  384. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/index.js.map +1 -0
  385. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.d.ts +7 -0
  386. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.d.ts.map +1 -0
  387. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.js +16 -0
  388. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-match.js.map +1 -0
  389. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +19 -0
  390. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -0
  391. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +217 -0
  392. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -0
  393. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts +4 -0
  394. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts.map +1 -0
  395. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js +46 -0
  396. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js.map +1 -0
  397. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.d.ts +13 -0
  398. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.d.ts.map +1 -0
  399. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.js +144 -0
  400. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream-boundary.js.map +1 -0
  401. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts +5 -0
  402. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -0
  403. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +208 -0
  404. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -0
  405. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts +4 -0
  406. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.d.ts.map +1 -0
  407. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js +17 -0
  408. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/tool-resolver.js.map +1 -0
  409. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.d.ts +5 -0
  410. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.d.ts.map +1 -0
  411. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.js +34 -0
  412. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/xml-entities.js.map +1 -0
  413. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +3 -1
  414. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
  416. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +12 -5
  417. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  418. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  419. package/node_modules/@earendil-works/pi-ai/package.json +6 -1
  420. package/node_modules/@earendil-works/pi-pty/native/prebuilds/darwin-arm64/senpi_pty.darwin-arm64.node +0 -0
  421. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  422. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +1 -1
  423. package/node_modules/@earendil-works/pi-tui/dist/utils.js +22 -4
  424. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  425. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  426. package/package.json +6 -6
  427. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts +0 -27
  428. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +0 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +0 -1
  430. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts.map +0 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js.map +0 -1
  432. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts +0 -32
  433. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +0 -1
  434. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +0 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts +0 -58
  436. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +0 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +0 -122
  438. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +0 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.d.ts +0 -5
  440. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.d.ts.map +0 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.js +0 -22
  442. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/load.js.map +0 -1
  443. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.d.ts.map +0 -1
  444. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/oauth-page.js.map +0 -1
  445. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts +0 -45
  446. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +0 -1
  447. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +0 -1
  448. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.d.ts.map +0 -1
  449. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/pkce.js.map +0 -1
  450. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts +0 -64
  451. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +0 -1
  452. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js +0 -2
  453. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js.map +0 -1
  454. /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/device-code.d.ts +0 -0
  455. /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/device-code.js +0 -0
  456. /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/oauth-page.d.ts +0 -0
  457. /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/oauth-page.js +0 -0
  458. /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/pkce.d.ts +0 -0
  459. /package/node_modules/@earendil-works/pi-ai/dist/{utils → auth}/oauth/pkce.js +0 -0
@@ -330,40 +330,40 @@ function statusIcon(op: string): string {
330
330
  function formatStatusEvent(event: EvalStatusEvent, theme: Theme | undefined): string {
331
331
  const op = event.op;
332
332
  const icon = style(theme, "muted", statusIcon(op));
333
- const error = eventString(event["error"]);
333
+ const error = eventString(event.error);
334
334
  if (error !== undefined) return `${icon} ${style(theme, "warning", op)}: ${style(theme, "dim", error)}`;
335
335
  const parts: string[] = [];
336
336
  switch (op) {
337
337
  case "read": {
338
- parts.push(`${eventNumber(event["chars"] ?? event["bytes"])} chars`);
339
- const path = eventString(event["path"]);
338
+ parts.push(`${eventNumber(event.chars ?? event.bytes)} chars`);
339
+ const path = eventString(event.path);
340
340
  if (path !== undefined) parts.push(`from ${path}`);
341
341
  break;
342
342
  }
343
343
  case "write": {
344
- parts.push(`${eventNumber(event["chars"] ?? event["bytes"])} chars`);
345
- const path = eventString(event["path"]);
344
+ parts.push(`${eventNumber(event.chars ?? event.bytes)} chars`);
345
+ const path = eventString(event.path);
346
346
  if (path !== undefined) parts.push(`to ${path}`);
347
347
  break;
348
348
  }
349
349
  case "cat":
350
- parts.push(plural(eventNumber(event["files"]), "file", "files"));
351
- parts.push(`${eventNumber(event["chars"])} chars`);
350
+ parts.push(plural(eventNumber(event.files), "file", "files"));
351
+ parts.push(`${eventNumber(event.chars)} chars`);
352
352
  break;
353
353
  case "ls":
354
- parts.push(plural(eventNumber(event["count"]), "entry", "entries"));
354
+ parts.push(plural(eventNumber(event.count), "entry", "entries"));
355
355
  break;
356
356
  case "env": {
357
- const action = eventString(event["action"]);
358
- const key = eventString(event["key"]);
359
- const value = eventString(event["value"]) ?? "";
357
+ const action = eventString(event.action);
358
+ const key = eventString(event.key);
359
+ const value = eventString(event.value) ?? "";
360
360
  if (action === "set" && key !== undefined) parts.push(`set ${key}=${value.slice(0, 30)}`);
361
361
  else if (action === "get" && key !== undefined) parts.push(`${key}=${value.slice(0, 30)}`);
362
- else parts.push(plural(eventNumber(event["count"]), "variable", "variables"));
362
+ else parts.push(plural(eventNumber(event.count), "variable", "variables"));
363
363
  break;
364
364
  }
365
365
  case "git_status": {
366
- if (event["clean"] === true) parts.push("clean");
366
+ if (event.clean === true) parts.push("clean");
367
367
  else {
368
368
  const changes: string[] = [];
369
369
  for (const key of ["staged", "modified", "untracked"] as const) {
@@ -372,41 +372,41 @@ function formatStatusEvent(event: EvalStatusEvent, theme: Theme | undefined): st
372
372
  }
373
373
  parts.push(changes.join(", ") || "unknown");
374
374
  }
375
- const branch = eventString(event["branch"]);
375
+ const branch = eventString(event.branch);
376
376
  if (branch !== undefined) parts.push(`on ${branch}`);
377
377
  break;
378
378
  }
379
379
  case "git_diff":
380
- parts.push(plural(eventNumber(event["lines"]), "line", "lines"));
381
- if (event["staged"] === true) parts.push("staged");
380
+ parts.push(plural(eventNumber(event.lines), "line", "lines"));
381
+ if (event.staged === true) parts.push("staged");
382
382
  break;
383
383
  case "git_log":
384
- parts.push(plural(eventNumber(event["commits"]), "commit", "commits"));
384
+ parts.push(plural(eventNumber(event.commits), "commit", "commits"));
385
385
  break;
386
386
  case "run":
387
387
  case "sh": {
388
- const command = eventString(event["command"] ?? event["cmd"]);
388
+ const command = eventString(event.command ?? event.cmd);
389
389
  if (command !== undefined) parts.push(command);
390
- if (typeof event["exitCode"] === "number") parts.push(`exit ${event["exitCode"]}`);
390
+ if (typeof event.exitCode === "number") parts.push(`exit ${event.exitCode}`);
391
391
  break;
392
392
  }
393
393
  case "completion": {
394
- const model = eventString(event["model"]);
395
- const tier = eventString(event["tier"]);
394
+ const model = eventString(event.model);
395
+ const tier = eventString(event.tier);
396
396
  if (model !== undefined) parts.push(model);
397
397
  if (tier !== undefined && tier !== model) parts.push(tier);
398
- parts.push(`${eventNumber(event["chars"])} chars`);
398
+ parts.push(`${eventNumber(event.chars)} chars`);
399
399
  break;
400
400
  }
401
401
  case "log":
402
- parts.push(eventString(event["message"]) ?? "");
402
+ parts.push(eventString(event.message) ?? "");
403
403
  break;
404
404
  case "phase":
405
- parts.push(eventString(event["title"]) ?? "");
405
+ parts.push(eventString(event.title) ?? "");
406
406
  break;
407
407
  default: {
408
- if (event["count"] !== undefined) parts.push(String(event["count"]));
409
- const path = eventString(event["path"]);
408
+ if (event.count !== undefined) parts.push(String(event.count));
409
+ const path = eventString(event.path);
410
410
  if (path !== undefined) parts.push(path);
411
411
  }
412
412
  }
@@ -443,7 +443,7 @@ function coalesceAgentEvents(events: readonly EvalStatusEvent[]): EvalStatusEven
443
443
  const rows: EvalStatusEvent[] = [];
444
444
  const indexes = new Map<string, number>();
445
445
  for (const event of events) {
446
- const id = eventString(event["id"]);
446
+ const id = eventString(event.id);
447
447
  if (id === undefined) {
448
448
  rows.push(event);
449
449
  continue;
@@ -480,13 +480,13 @@ function renderAgentProgressEvents(events: readonly EvalStatusEvent[], environme
480
480
  // Senpi Theme has no tree-token API; fixed ├/└/│ glyphs intentionally mirror omp.
481
481
  for (const [index, event] of rows.entries()) {
482
482
  const isLast = index === rows.length - 1;
483
- const status = agentStatus(event["status"]);
483
+ const status = agentStatus(event.status);
484
484
  const presentation = agentPresentation(status, environment.spinnerFrame);
485
- const id = eventString(event["id"]) ?? "agent";
485
+ const id = eventString(event.id) ?? "agent";
486
486
  const styledId = environment.theme === undefined ? id : environment.theme.bold(id);
487
487
  let body = `${style(environment.theme, presentation.color, presentation.icon)} ${styledId} ${presentation.label}`;
488
488
  if (status === "completed" || status === "failed" || status === "aborted") {
489
- const duration = eventNumber(event["durationMs"]);
489
+ const duration = eventNumber(event.durationMs);
490
490
  if (duration > 0) body += ` · ${style(environment.theme, "dim", formatDuration(duration))}`;
491
491
  }
492
492
  const branch = isLast ? "└ " : "├ ";
@@ -496,8 +496,8 @@ function renderAgentProgressEvents(events: readonly EvalStatusEvent[], environme
496
496
  renderPrefixed(body, environment, { prefix: branch, continuation: continuation, color: "dim" }),
497
497
  );
498
498
  if (status !== "running") continue;
499
- const currentTool = eventString(event["currentTool"]);
500
- const lastIntent = eventString(event["lastIntent"]);
499
+ const currentTool = eventString(event.currentTool);
500
+ const lastIntent = eventString(event.lastIntent);
501
501
  if (currentTool === undefined && lastIntent === undefined) continue;
502
502
  const detail =
503
503
  currentTool === undefined
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-agent-core",
3
3
  "private": true,
4
- "version": "2026.7.14",
4
+ "version": "2026.7.16-3",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "prepublishOnly": "npm run clean && npm run build"
31
31
  },
32
32
  "dependencies": {
33
- "@earendil-works/pi-ai": "^2026.7.14",
33
+ "@earendil-works/pi-ai": "^2026.7.16-3",
34
34
  "ignore": "7.0.5",
35
35
  "typebox": "1.1.38",
36
36
  "yaml": "2.9.0"
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/node": "25.9.1",
57
- "@vitest/coverage-v8": "4.1.8",
57
+ "@vitest/coverage-v8": "4.1.9",
58
58
  "typescript": "6.0.3",
59
- "vitest": "4.1.8"
59
+ "vitest": "4.1.9"
60
60
  }
61
61
  }
@@ -17,6 +17,7 @@ Unified LLM API with provider collections, automatic auth resolution, token and
17
17
  - [Dynamic Providers](#dynamic-providers)
18
18
  - [Auth](#auth)
19
19
  - [How Auth Resolves](#how-auth-resolves)
20
+ - [Transforming Request Headers](#transforming-request-headers)
20
21
  - [Credential Store](#credential-store)
21
22
  - [Environment Variables](#environment-variables)
22
23
  - [Tools](#tools)
@@ -334,18 +335,45 @@ await models.complete(model, context);
334
335
  await models.complete(model, context, { apiKey: 'sk-explicit' });
335
336
  ```
336
337
 
337
- You can inspect resolution without making a request useful for status UIs:
338
+ You can inspect resolution without making a request. Pass a provider ID for provider-scoped auth, or a model to include its static `model.headers`:
338
339
 
339
340
  ```typescript
340
- const auth = await models.getAuth(model);
341
- if (auth) {
342
- console.log(`configured via ${auth.source}`); // e.g. "ANTHROPIC_API_KEY", "OAuth", "stored credential"
341
+ const providerAuth = await models.getAuth(model.provider);
342
+ const modelAuth = await models.getAuth(model);
343
+
344
+ if (modelAuth) {
345
+ console.log(`configured via ${modelAuth.source}`); // e.g. "ANTHROPIC_API_KEY", "OAuth", "stored credential"
346
+ console.log(modelAuth.auth.headers); // Provider auth headers + model.headers
343
347
  } else {
344
348
  console.log('not configured');
345
349
  }
346
350
  ```
347
351
 
348
- `getAuth()` resolves `undefined` for unconfigured providers and rejects with `ModelsError` when something is actually broken (`"oauth"`: token refresh failed, credential preserved for re-login; `"auth"`: key resolution or credential store failure). Request paths surface the same failures as stream errors.
352
+ Both overloads resolve credentials, refresh expired OAuth when necessary, and may return an auth-derived `apiKey`, `headers`, or `baseUrl`. `getAuth()` resolves `undefined` for unconfigured providers and rejects with `ModelsError` when something is actually broken (`"oauth"`: token refresh failed, credential preserved for re-login; `"auth"`: key resolution or credential store failure). Request paths surface the same failures as stream errors.
353
+
354
+ ### Transforming Request Headers
355
+
356
+ `Models.stream()`, `complete()`, `streamSimple()`, and `completeSimple()` accept a Models-only `transformHeaders` option. It runs once after provider auth, `model.headers`, and explicit `options.headers` have been merged, but before provider dispatch:
357
+
358
+ ```typescript
359
+ const response = await models.completeSimple(model, context, {
360
+ headers: { "X-Client": "my-app" },
361
+ transformHeaders: async (headers) => ({
362
+ ...headers,
363
+ "X-Request-ID": crypto.randomUUID(),
364
+ }),
365
+ });
366
+ ```
367
+
368
+ The ordering is:
369
+
370
+ ```text
371
+ provider auth headers -> model.headers -> explicit options.headers -> transformHeaders -> Provider.stream*()
372
+ ```
373
+
374
+ Header names are merged case-insensitively. Explicit headers override auth/model headers, and the transform has final control; returning `null` for a header suppresses lower-level defaults that support deletion.
375
+
376
+ `transformHeaders` belongs to `Models`, not `Provider`. A `Models` implementation must consume it and remove it before calling `Provider.stream*()`. Provider implementations continue receiving ordinary `ApiStreamOptions` or `SimpleStreamOptions` and never handle the transform themselves. Use this option instead of calling `getAuth(model)` before `stream*()`, which would resolve request auth twice.
349
377
 
350
378
  ### Credential Store
351
379
 
@@ -359,7 +387,7 @@ const models = createModels({ credentials: myFileBackedStore });
359
387
  // const models = builtinModels({ credentials: myFileBackedStore });
360
388
  ```
361
389
 
362
- The contract is small: `read(providerId)`, `modify(providerId, fn)` (the only write path — a serialized read-modify-write), and `delete(providerId)`. OAuth token refresh runs inside `modify`, so concurrent requests and processes cannot double-refresh a rotated token. A stored credential *owns* its provider: environment variables are only consulted when nothing is stored, and a failed refresh never silently falls back to an env key.
390
+ The contract is small: `read(providerId)`, `list()` for non-secret `{ providerId, type }` metadata, `modify(providerId, fn)` (the only write path — a serialized read-modify-write), and `delete(providerId)`. Enumeration must not resolve secrets or execute configured key commands. OAuth token refresh runs inside `modify`, so concurrent requests and processes cannot double-refresh a rotated token. A stored credential *owns* its provider: environment variables are only consulted when nothing is stored, and a failed refresh never silently falls back to an env key.
363
391
 
364
392
  API-key credentials use the same discriminator as pi's `auth.json` and can carry provider-scoped env/config values:
365
393
 
@@ -412,7 +440,7 @@ Built-in providers resolve these env vars (Node.js; in browsers pass `apiKey` ex
412
440
  | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` |
413
441
  | GitHub Copilot | `COPILOT_GITHUB_TOKEN` |
414
442
 
415
- Amazon Bedrock resolves ambient AWS credentials (`AWS_PROFILE`, access key pairs, `AWS_BEARER_TOKEN_BEDROCK`, ECS task roles, web identity tokens). Vertex AI resolves either an explicit key or gcloud Application Default Credentials plus project/location.
443
+ Amazon Bedrock resolves ambient AWS credentials (`AWS_PROFILE`, access key pairs, `AWS_BEARER_TOKEN_BEDROCK`, ECS task roles, web identity tokens); its provider-owned login flow supports bearer tokens, AWS profiles, and the existing credential chain. Vertex AI resolves either an explicit key or gcloud Application Default Credentials plus project/location, with a provider-owned login flow for API keys, ADC, and service-account files.
416
444
 
417
445
  ## Tools
418
446
 
@@ -660,7 +688,7 @@ for (const block of result.output) {
660
688
  }
661
689
  ```
662
690
 
663
- Like the chat side, you can build the collection from parts: `createImagesModels({ credentials?, authContext? })`, the `openrouterImagesProvider()` factory from `@earendil-works/pi-ai/providers/openrouter-images`, and `createImagesProvider({ id, auth, models, refreshModels?, api })` for custom image providers (with `imagesModels.refresh(provider?)` for dynamic lists). Failures never reject — they return an `AssistantImages` with `stopReason: "error"`. The collection's `getAuth(model)` works exactly like the chat-side one.
691
+ Like the chat side, you can build the collection from parts: `createImagesModels({ credentials?, authContext? })`, the `openrouterImagesProvider()` factory from `@earendil-works/pi-ai/providers/openrouter-images`, and `createImagesProvider({ id, auth, models, refreshModels?, api })` for custom image providers (with `imagesModels.refresh(provider?)` for dynamic lists). Failures never reject — they return an `AssistantImages` with `stopReason: "error"`. The collection's provider-scoped `getAuth(providerId)` works exactly like the chat-side one.
664
692
 
665
693
  The old global API (`getImageModel()` / `getImageModels()` / `getImageProviders()` / `generateImages()`) remains available on the [compat entrypoint](#migrating-from-the-old-global-api):
666
694
 
@@ -719,7 +747,7 @@ Many models support thinking/reasoning capabilities where they can show their in
719
747
  const model = models.getModel('anthropic', 'claude-sonnet-4-5')!;
720
748
  // or models.getModel('openai', 'gpt-5-mini');
721
749
  // or models.getModel('google', 'gemini-2.5-flash');
722
- // or models.getModel('xai', 'grok-code-fast-1');
750
+ // or models.getModel('xai', 'grok-4.5');
723
751
 
724
752
  // Check if model supports reasoning
725
753
  if (model.reasoning) {
@@ -982,22 +1010,46 @@ const gateway = createProvider({
982
1010
  });
983
1011
  ```
984
1012
 
985
- Dynamic model lists use `refreshModels`; the provider lists empty until the first `models.refresh()`:
1013
+ Provider-wide endpoint or request transformations belong in the provider's API implementation: wrap the `ProviderStreams` you pass as `api` so every request goes through the transformation before dispatch. The Cloudflare providers do this to materialize account/gateway endpoint placeholders from the resolved provider env:
986
1014
 
987
1015
  ```typescript
1016
+ function tenantStreams(streams: ProviderStreams): ProviderStreams {
1017
+ const withTenant = (model: Model<Api>) => ({ ...model, baseUrl: model.baseUrl.replace('{tenant}', tenantId) });
1018
+ return {
1019
+ stream: (model, context, options) => streams.stream(withTenant(model), context, options),
1020
+ streamSimple: (model, context, options) => streams.streamSimple(withTenant(model), context, options),
1021
+ };
1022
+ }
1023
+
1024
+ const tenantGateway = createProvider({
1025
+ id: 'tenant-gateway',
1026
+ auth: { apiKey: envApiKeyAuth('Gateway key', ['GATEWAY_API_KEY']) },
1027
+ models: [/* ... */],
1028
+ api: tenantStreams(openAICompletionsApi()),
1029
+ });
1030
+ ```
1031
+
1032
+ Dynamic model lists use `fetchModels`. `Models.refresh()` refreshes every configured dynamic provider, passing its effective API-key or refreshed OAuth credential. A `ModelsStore` persists dynamic catalogs; both stores default to in-memory implementations.
1033
+
1034
+ ```typescript
1035
+ const models = createModels({ credentials, modelsStore });
988
1036
  const llamacpp = createProvider({
989
1037
  id: 'llamacpp',
990
1038
  auth: { apiKey: { name: 'llama.cpp', resolve: async () => ({ auth: {} }) } },
991
1039
  models: [],
992
- refreshModels: async () => fetchModelsFromServer('http://localhost:8080'),
1040
+ fetchModels: async ({ signal }) => fetchModelsFromServer('http://localhost:8080', signal),
993
1041
  api: openAICompletionsApi(),
994
1042
  });
995
1043
 
996
1044
  models.setProvider(llamacpp);
997
- await models.refresh('llamacpp');
1045
+ const result = await models.refresh({ signal });
1046
+ if (result.aborted) console.log('refresh cancelled');
1047
+ for (const [provider, error] of result.errors) console.error(provider, error);
998
1048
  ```
999
1049
 
1000
- Custom models can carry `headers` (e.g. proxies behind bot detection) and `compat` flags see [OpenAI Compatibility Settings](#openai-compatibility-settings).
1050
+ Use `models.refresh({ allowNetwork: false })` to restore persisted catalogs without network access, or `models.refresh({ force: true })` to bypass provider freshness checks. Model reads stay synchronous and return the last restored or refreshed list.
1051
+
1052
+ Custom models can carry `headers` (e.g. proxies behind bot detection) and `compat` flags. `Models.getAuth(model)` includes those model headers, and stream methods merge them before explicit request headers and `transformHeaders`. See [OpenAI Compatibility Settings](#openai-compatibility-settings).
1001
1053
 
1002
1054
  Some OpenAI-compatible servers do not understand the `developer` role used for reasoning-capable models. For those providers, set `compat.supportsDeveloperRole` to `false` so the system prompt is sent as a `system` message instead. If the server also does not support `reasoning_effort`, set `compat.supportsReasoningEffort` to `false` too. This commonly applies to Ollama, vLLM, SGLang, and similar OpenAI-compatible servers.
1003
1055
 
@@ -1070,7 +1122,8 @@ interface OpenAICompletionsCompat {
1070
1122
  supportsReasoningEffort?: boolean; // Whether provider supports `reasoning_effort` (default: true)
1071
1123
  supportsUsageInStreaming?: boolean; // Whether provider supports `stream_options: { include_usage: true }` (default: true)
1072
1124
  supportsStrictMode?: boolean; // Whether provider supports `strict` in tool definitions (default: true)
1073
- sendSessionAffinityHeaders?: boolean; // Whether to send `session_id`, `x-client-request-id`, and `x-session-affinity` from `sessionId` when caching is enabled (default: false)
1125
+ sendSessionAffinityHeaders?: boolean; // Send session-affinity data from `sessionId` (default: false)
1126
+ sessionAffinityFormat?: 'openai' | 'openai-nosession' | 'openrouter'; // Format for session affinity: 'openai' uses `prompt_cache_key`, `session_id`, `x-client-request-id`, and `x-session-affinity`; 'openai-nosession' uses `prompt_cache_key`, `x-client-request-id`, and `x-session-affinity`; 'openrouter' uses `x-session-id` (default: auto-detected)
1074
1127
  maxTokensField?: 'max_completion_tokens' | 'max_tokens'; // Which field name to use (default: max_completion_tokens)
1075
1128
  requiresToolResultName?: boolean; // Whether tool results require the `name` field (default: false)
1076
1129
  requiresAssistantAfterToolResult?: boolean; // Whether tool results must be followed by an assistant message (default: false)
@@ -1085,7 +1138,7 @@ interface OpenAICompletionsCompat {
1085
1138
 
1086
1139
  interface OpenAIResponsesCompat {
1087
1140
  supportsDeveloperRole?: boolean; // Whether provider supports `developer` role vs `system` (default: true)
1088
- sendSessionIdHeader?: boolean; // Whether to send `session_id` from `sessionId` when caching is enabled (default: true)
1141
+ sessionAffinityFormat?: 'openai' | 'openai-nosession' | 'openrouter'; // Session-affinity header format: 'openai' sends `session_id` and `x-client-request-id`; 'openai-nosession' sends `x-client-request-id`; 'openrouter' sends `x-session-id`. Does not affect the `prompt_cache_key` body param (default: auto-detected)
1089
1142
  supportsLongCacheRetention?: boolean; // Whether provider supports `prompt_cache_retention: "24h"` (default: true)
1090
1143
  }
1091
1144
  ```
@@ -1368,7 +1421,7 @@ Several providers support OAuth authentication instead of static API keys:
1368
1421
  - **OpenAI Codex** (ChatGPT Plus/Pro subscription, access to GPT-5.x Codex models)
1369
1422
  - **GitHub Copilot** (Copilot subscription)
1370
1423
 
1371
- Each of these providers carries an `OAuthAuth` on `provider.auth.oauth` with three operations: `login(callbacks)` runs the interactive flow and returns a credential, `refresh(credential)` exchanges the refresh token, and `toAuth(credential)` derives request auth (GitHub Copilot's per-account base URL comes from here). Refresh is automatic: `models.getAuth()` and the request paths refresh expired tokens under a credential-store lock, so concurrent requests and processes cannot double-refresh.
1424
+ Each of these providers carries an `OAuthAuth` on `provider.auth.oauth` with three operations: `login(interaction)` uses the provider-neutral `AuthInteraction.prompt()`/`notify()` protocol and returns a credential, `refresh(credential)` exchanges the refresh token, and `toAuth(credential)` derives request auth (GitHub Copilot's per-account base URL comes from here). Refresh is automatic: `models.getAuth(providerId)` and request paths refresh expired tokens under a credential-store lock, so concurrent requests and processes cannot double-refresh.
1372
1425
 
1373
1426
  ```typescript
1374
1427
  import { createModels } from '@earendil-works/pi-ai';
@@ -1377,34 +1430,36 @@ import { anthropicProvider } from '@earendil-works/pi-ai/providers/anthropic';
1377
1430
  const models = createModels({ credentials: myStore }); // persistent CredentialStore
1378
1431
  models.setProvider(anthropicProvider());
1379
1432
 
1380
- // Login: drive the flow with prompt()/notify() callbacks, persist the credential
1381
- const provider = models.getProvider('anthropic')!;
1382
- const credential = await provider.auth.oauth!.login({
1433
+ // Login: Models drives the flow and persists the credential
1434
+ await models.login('anthropic', 'oauth', {
1383
1435
  prompt: async (p) => {
1384
1436
  // p.type: 'text' | 'secret' | 'select' | 'manual_code'
1385
1437
  // manual_code prompts race a local callback server; p.signal aborts them when the server wins
1386
1438
  return await askUser(p.message);
1387
1439
  },
1388
1440
  notify: (event) => {
1389
- // event.type: 'auth_url' | 'device_code' | 'progress'
1441
+ // event.type: 'info' | 'auth_url' | 'device_code' | 'progress'
1442
+ if (event.type === 'info') {
1443
+ console.log(event.message);
1444
+ for (const link of event.links ?? []) console.log(`${link.label ?? 'More information'}: ${link.url}`);
1445
+ }
1390
1446
  if (event.type === 'auth_url') console.log(`Open: ${event.url}`);
1391
1447
  if (event.type === 'device_code') console.log(`Code: ${event.userCode} at ${event.verificationUri}`);
1392
1448
  if (event.type === 'progress') console.log(event.message);
1393
1449
  },
1394
1450
  });
1395
- await myStore.modify('anthropic', async () => credential);
1396
1451
 
1397
1452
  // From here on, requests resolve and refresh the token automatically
1398
1453
  const model = models.getModel('anthropic', 'claude-sonnet-4-5')!;
1399
1454
  await models.complete(model, context);
1400
1455
 
1401
1456
  // Logout
1402
- await myStore.delete('anthropic');
1457
+ await models.logout('anthropic');
1403
1458
  ```
1404
1459
 
1405
1460
  ### Vertex AI
1406
1461
 
1407
- Vertex AI models support either a Google Cloud API key or Application Default Credentials (ADC):
1462
+ Vertex AI models support either a Google Cloud API key or Application Default Credentials (ADC). Its provider-owned API-key login flow can configure either method:
1408
1463
 
1409
1464
  - **API key**: Set `GOOGLE_CLOUD_API_KEY` or pass `apiKey` in the call options.
1410
1465
  - **Local development (ADC)**: Run `gcloud auth application-default login`
@@ -1438,7 +1493,7 @@ Credentials are saved to `auth.json` in the current directory.
1438
1493
 
1439
1494
  ### Programmatic OAuth
1440
1495
 
1441
- The legacy flow functions remain available via the `@earendil-works/pi-ai/oauth` entry point (`loginAnthropic`, `loginOpenAICodex`, `loginGitHubCopilot`, `refreshOAuthToken`, `getOAuthApiKey`); credential storage is the caller's responsibility there. New code should prefer the provider-owned `OAuthAuth` shown above it composes with the credential store and gets locked auto-refresh for free.
1496
+ Built-in login and refresh flows are private provider implementations. Use provider-owned `OAuthAuth`, which composes with `CredentialStore` and gets locked auto-refresh through `Models`. The `@earendil-works/pi-ai/oauth` entry point retains only type declarations required by coding-agent extension OAuth compatibility.
1442
1497
 
1443
1498
  Provider notes:
1444
1499
 
@@ -1468,7 +1523,7 @@ Compat is a strict superset of the root entrypoint, so a file can switch its imp
1468
1523
  | `getModels('anthropic')` / `getProviders()` | `models.getModels('anthropic')` / `models.getProviders()` or `getBuiltin*` |
1469
1524
  | `stream(model, ctx, opts)` (env-key injection) | `models.stream(model, ctx, opts)` (provider auth resolution) |
1470
1525
  | `registerApiProvider({ api, stream, streamSimple })` | `createProvider({ id, auth, models, api })` + `models.setProvider()` |
1471
- | `getEnvApiKey('openai')` | `await models.getAuth(model)` |
1526
+ | `getEnvApiKey('openai')` | `await models.getAuth(model.provider)` |
1472
1527
  | `streamAnthropic(model, ctx, opts)` | `stream` from `@earendil-works/pi-ai/api/anthropic-messages`, or a provider in a collection |
1473
1528
  | `registerFauxProvider()` | `fauxProvider()` + `models.setProvider()` |
1474
1529
 
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAU1C,OAAO,KAAK,EAWX,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAMb,MAAM,aAAa,CAAC;AAgKrB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAuDhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAkiBD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAoTzE,CAAC;AAoEF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CA2ClF,CAAC"}
1
+ {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAU1C,OAAO,KAAK,EAWX,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAMb,MAAM,aAAa,CAAC;AAgKrB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAuDhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAghBD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAsTzE,CAAC;AAoEF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CA2ClF,CAAC"}
@@ -200,24 +200,6 @@ const REPLAYABLE_ANTHROPIC_PROVIDER_NATIVE_TYPES = new Set([
200
200
  function isReplayableAnthropicProviderNativeBlock(raw) {
201
201
  return isRecord(raw) && typeof raw.type === "string" && REPLAYABLE_ANTHROPIC_PROVIDER_NATIVE_TYPES.has(raw.type);
202
202
  }
203
- function stripEncryptedContentFromWebSearchResult(raw) {
204
- const { encrypted_content: _encryptedContent, ...rest } = raw;
205
- return rest;
206
- }
207
- function sanitizeReplayableAnthropicProviderNativeBlock(raw) {
208
- if (!isReplayableAnthropicProviderNativeBlock(raw))
209
- return undefined;
210
- if (!isRecord(raw) || raw.type !== "web_search_tool_result" || !Array.isArray(raw.content))
211
- return raw;
212
- return {
213
- ...raw,
214
- content: raw.content.map((item) => {
215
- if (!isRecord(item) || item.type !== "web_search_result")
216
- return item;
217
- return stripEncryptedContentFromWebSearchResult(item);
218
- }),
219
- };
220
- }
221
203
  function isSameAnthropicModel(message, model) {
222
204
  return message.provider === model.provider && message.api === model.api && message.model === model.id;
223
205
  }
@@ -837,25 +819,27 @@ export const stream = (model, context, options) => {
837
819
  }
838
820
  // Only update usage fields if present (not null).
839
821
  // Preserves input_tokens from message_start when proxies omit it in message_delta.
840
- if (event.usage.input_tokens != null) {
841
- output.usage.input = event.usage.input_tokens;
842
- }
843
- if (event.usage.output_tokens != null) {
844
- output.usage.output = event.usage.output_tokens;
845
- }
846
- if (event.usage.cache_read_input_tokens != null) {
847
- output.usage.cacheRead = event.usage.cache_read_input_tokens;
848
- }
849
- if (event.usage.cache_creation_input_tokens != null) {
850
- output.usage.cacheWrite = event.usage.cache_creation_input_tokens;
851
- }
852
- // Anthropic reports reasoning tokens in `output_tokens_details.thinking_tokens` on the
853
- // final message_delta usage (a subset of output_tokens). SDK 0.91.1 omits the field from
854
- // its Usage type, so read it through a narrow cast. Verified against the live API.
855
- const thinkingTokens = event.usage
856
- .output_tokens_details?.thinking_tokens;
857
- if (thinkingTokens != null) {
858
- output.usage.reasoning = thinkingTokens;
822
+ if (event.usage) {
823
+ if (event.usage.input_tokens != null) {
824
+ output.usage.input = event.usage.input_tokens;
825
+ }
826
+ if (event.usage.output_tokens != null) {
827
+ output.usage.output = event.usage.output_tokens;
828
+ }
829
+ if (event.usage.cache_read_input_tokens != null) {
830
+ output.usage.cacheRead = event.usage.cache_read_input_tokens;
831
+ }
832
+ if (event.usage.cache_creation_input_tokens != null) {
833
+ output.usage.cacheWrite = event.usage.cache_creation_input_tokens;
834
+ }
835
+ // Anthropic reports reasoning tokens in `output_tokens_details.thinking_tokens` on the
836
+ // final message_delta usage (a subset of output_tokens). SDK 0.91.1 omits the field from
837
+ // its Usage type, so read it through a narrow cast. Verified against the live API.
838
+ const thinkingTokens = event.usage
839
+ .output_tokens_details?.thinking_tokens;
840
+ if (thinkingTokens != null) {
841
+ output.usage.reasoning = thinkingTokens;
842
+ }
859
843
  }
860
844
  // Anthropic doesn't provide total_tokens, compute from components
861
845
  output.usage.totalTokens =
@@ -1336,11 +1320,8 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
1336
1320
  });
1337
1321
  }
1338
1322
  else if (block.type === "providerNative") {
1339
- if (isSameModel) {
1340
- const replayableBlock = sanitizeReplayableAnthropicProviderNativeBlock(block.raw);
1341
- if (replayableBlock)
1342
- blocks.push(replayableBlock);
1343
- }
1323
+ if (isSameModel && isReplayableAnthropicProviderNativeBlock(block.raw))
1324
+ blocks.push(block.raw);
1344
1325
  }
1345
1326
  }
1346
1327
  if (blocks.length === 0)