@averyyy/pi-coding-agent 1.4.0-piclient.9 → 1.5.0-piclient.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (429) hide show
  1. package/CHANGELOG.md +122 -4
  2. package/dist/bundle/chunks/anthropic-messages-WU4RRDFO.js +6 -0
  3. package/dist/bundle/chunks/azure-openai-responses-M725JFGO.js +2 -0
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +7 -4
  5. package/dist/bundle/chunks/chunk-3UW3IQIY.js +16 -0
  6. package/dist/bundle/chunks/chunk-4RKLODCT.js +2 -0
  7. package/dist/bundle/chunks/{chunk-3LTMO2WY.js → chunk-75IISYAM.js} +2 -2
  8. package/dist/bundle/chunks/{chunk-CF5GWZHW.js → chunk-A3Y7H47A.js} +1 -1
  9. package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  10. package/dist/bundle/chunks/{chunk-D3OXAPLU.js → chunk-G23G7KNC.js} +2 -9
  11. package/dist/bundle/chunks/chunk-GJFZM2RZ.js +129 -0
  12. package/dist/bundle/chunks/chunk-GO33PKBT.js +9 -0
  13. package/dist/bundle/chunks/{chunk-H2AI7MFJ.js → chunk-JM6XUN2B.js} +2 -2
  14. package/dist/bundle/chunks/{chunk-BRYV63PL.js → chunk-LTLKVIE2.js} +8 -7
  15. package/dist/bundle/chunks/chunk-LXHWY6K4.js +1592 -0
  16. package/dist/bundle/chunks/{chunk-MKWEYCNF.js → chunk-N4CTF6DK.js} +2 -2
  17. package/dist/bundle/chunks/chunk-O5CTLHDX.js +82 -0
  18. package/dist/bundle/chunks/chunk-OV4EHN3Q.js +2 -0
  19. package/dist/bundle/chunks/{chunk-3EGEEHMN.js → chunk-OW4KH7CI.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-HZG4C6GI.js → chunk-OXKIVFVM.js} +1 -1
  21. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  22. package/dist/bundle/chunks/chunk-PWQUNMKT.js +4 -0
  23. package/dist/bundle/chunks/{chunk-3NEJV7UG.js → chunk-ULTM5Q67.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-VHUVVKJM.js → chunk-WATJAG5U.js} +1 -1
  25. package/dist/bundle/chunks/{chunk-VYYRESZJ.js → chunk-YH5RGRHQ.js} +3 -3
  26. package/dist/bundle/chunks/{cli-QUNA6INU.js → cli-2Q4CKMZK.js} +11 -9
  27. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-QIIM6OB4.js → cloudflare-workers-ai-system-one-JEJELFEJ.js} +1 -1
  28. package/dist/bundle/chunks/devin.js +1 -1
  29. package/dist/bundle/chunks/{easter-egg-3d-4L2AVJKX.js → easter-egg-3d-UEH5CVEM.js} +1 -1
  30. package/dist/bundle/chunks/{execute-UNST3ORJ.js → execute-BOGNP5CQ.js} +1 -1
  31. package/dist/bundle/chunks/github-copilot.js +1 -1
  32. package/dist/bundle/chunks/google-antigravity-runtime.js +3 -3
  33. package/dist/bundle/chunks/google-antigravity.js +1 -1
  34. package/dist/bundle/chunks/{google-generative-ai-PNRT4EAN.js → google-generative-ai-UTHMOBSC.js} +1 -1
  35. package/dist/bundle/chunks/{google-vertex-ZLSXUSEM.js → google-vertex-MKY2BEE7.js} +1 -1
  36. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  37. package/dist/bundle/chunks/kimi-coding.js +1 -1
  38. package/dist/bundle/chunks/{llama-cpp-classify-U4EH6TAM.js → llama-cpp-classify-CYHVVBOQ.js} +1 -1
  39. package/dist/bundle/chunks/meta.js +1 -1
  40. package/dist/bundle/chunks/mistral-conversations-U2CRJEWX.js +5 -0
  41. package/dist/bundle/chunks/{openai-codex-responses-UIB63WGM.js → openai-codex-responses-DK2NKO47.js} +1 -1
  42. package/dist/bundle/chunks/openai-completions-VPNLDI5K.js +7 -0
  43. package/dist/bundle/chunks/{openai-decisions-Q46R33J3.js → openai-decisions-UZ6HF7LF.js} +1 -1
  44. package/dist/bundle/chunks/{openai-responses-FGTD6NDJ.js → openai-responses-S5QT5K5D.js} +1 -1
  45. package/dist/bundle/chunks/{openrouter-images-WBAVKHHY.js → openrouter-images-P5CYCO4P.js} +1 -1
  46. package/dist/bundle/chunks/pi-messages-XPX326L5.js +8 -0
  47. package/dist/bundle/chunks/radius.js +1 -1
  48. package/dist/bundle/chunks/{runtime-SITSZTHV.js → runtime-2Z3FBQRD.js} +1 -1
  49. package/dist/bundle/chunks/{typesafe-system-one-DFEHTLK5.js → typesafe-system-one-NKVLMGFF.js} +1 -1
  50. package/dist/bundle/chunks/virtual-modules-CR5DUKA3.js +2 -0
  51. package/dist/bundle/cli-runtime.js +1 -1
  52. package/dist/bundle/index.js +1 -1
  53. package/dist/bundle/rpc-entry.js +1 -1
  54. package/dist/cli/args.d.ts.map +1 -1
  55. package/dist/cli/args.js +8 -7
  56. package/dist/cli/args.js.map +1 -1
  57. package/dist/cli/auth-check.d.ts.map +1 -1
  58. package/dist/cli/auth-check.js +12 -1
  59. package/dist/cli/auth-check.js.map +1 -1
  60. package/dist/cli/credential-print.d.ts.map +1 -1
  61. package/dist/cli/credential-print.js +6 -0
  62. package/dist/cli/credential-print.js.map +1 -1
  63. package/dist/config.d.ts +10 -0
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +24 -5
  66. package/dist/config.js.map +1 -1
  67. package/dist/core/agent-session-runtime.js +3 -3
  68. package/dist/core/agent-session-runtime.js.map +1 -1
  69. package/dist/core/agent-session.d.ts +6 -1
  70. package/dist/core/agent-session.d.ts.map +1 -1
  71. package/dist/core/agent-session.js +35 -7
  72. package/dist/core/agent-session.js.map +1 -1
  73. package/dist/core/bug-report.d.ts +4 -4
  74. package/dist/core/compaction/branch-summarization.d.ts +4 -2
  75. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  76. package/dist/core/compaction/branch-summarization.js +14 -5
  77. package/dist/core/compaction/branch-summarization.js.map +1 -1
  78. package/dist/core/exec.d.ts +9 -1
  79. package/dist/core/exec.d.ts.map +1 -1
  80. package/dist/core/exec.js +79 -15
  81. package/dist/core/exec.js.map +1 -1
  82. package/dist/core/export-html/template.css +9 -0
  83. package/dist/core/export-html/template.js +165 -45
  84. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  85. package/dist/core/export-html/tool-renderer.js +3 -0
  86. package/dist/core/export-html/tool-renderer.js.map +1 -1
  87. package/dist/core/extensions/index.d.ts +1 -1
  88. package/dist/core/extensions/index.d.ts.map +1 -1
  89. package/dist/core/extensions/index.js.map +1 -1
  90. package/dist/core/extensions/loader.d.ts.map +1 -1
  91. package/dist/core/extensions/loader.js +7 -6
  92. package/dist/core/extensions/loader.js.map +1 -1
  93. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  94. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  95. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  96. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  97. package/dist/core/extensions/types.d.ts +27 -4
  98. package/dist/core/extensions/types.d.ts.map +1 -1
  99. package/dist/core/extensions/types.js.map +1 -1
  100. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  101. package/dist/core/extensions/virtual-modules.js +8 -7
  102. package/dist/core/extensions/virtual-modules.js.map +1 -1
  103. package/dist/core/mcp-servers.d.ts +11 -4
  104. package/dist/core/mcp-servers.d.ts.map +1 -1
  105. package/dist/core/mcp-servers.js +15 -5
  106. package/dist/core/mcp-servers.js.map +1 -1
  107. package/dist/core/model-config.d.ts +1678 -2029
  108. package/dist/core/model-config.d.ts.map +1 -1
  109. package/dist/core/model-config.js +2 -3
  110. package/dist/core/model-config.js.map +1 -1
  111. package/dist/core/model-registry.d.ts.map +1 -1
  112. package/dist/core/model-registry.js +5 -0
  113. package/dist/core/model-registry.js.map +1 -1
  114. package/dist/core/model-resolver.d.ts.map +1 -1
  115. package/dist/core/model-resolver.js +17 -11
  116. package/dist/core/model-resolver.js.map +1 -1
  117. package/dist/core/model-runtime.d.ts +11 -14
  118. package/dist/core/model-runtime.d.ts.map +1 -1
  119. package/dist/core/model-runtime.js +167 -198
  120. package/dist/core/model-runtime.js.map +1 -1
  121. package/dist/core/package-manager.d.ts +14 -0
  122. package/dist/core/package-manager.d.ts.map +1 -1
  123. package/dist/core/package-manager.js +160 -46
  124. package/dist/core/package-manager.js.map +1 -1
  125. package/dist/core/pi-ai-schemas.d.ts +163 -0
  126. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  127. package/dist/core/pi-ai-schemas.js +21 -0
  128. package/dist/core/pi-ai-schemas.js.map +1 -0
  129. package/dist/core/pi-manifest.d.ts +1 -0
  130. package/dist/core/pi-manifest.d.ts.map +1 -1
  131. package/dist/core/pi-manifest.js +4 -0
  132. package/dist/core/pi-manifest.js.map +1 -1
  133. package/dist/core/pi-server-accounts.d.ts +22 -0
  134. package/dist/core/pi-server-accounts.d.ts.map +1 -0
  135. package/dist/core/pi-server-accounts.js +137 -0
  136. package/dist/core/pi-server-accounts.js.map +1 -0
  137. package/dist/core/pi-server-client.d.ts +15 -7
  138. package/dist/core/pi-server-client.d.ts.map +1 -1
  139. package/dist/core/pi-server-client.js +85 -4
  140. package/dist/core/pi-server-client.js.map +1 -1
  141. package/dist/core/pi-server-observer.d.ts +4 -0
  142. package/dist/core/pi-server-observer.d.ts.map +1 -1
  143. package/dist/core/pi-server-observer.js +24 -0
  144. package/dist/core/pi-server-observer.js.map +1 -1
  145. package/dist/core/pi-server-request.d.ts +1 -1
  146. package/dist/core/pi-server-request.d.ts.map +1 -1
  147. package/dist/core/pi-server-request.js +2 -2
  148. package/dist/core/pi-server-request.js.map +1 -1
  149. package/dist/core/pi-server-subagents.d.ts +26 -0
  150. package/dist/core/pi-server-subagents.d.ts.map +1 -0
  151. package/dist/core/pi-server-subagents.js +112 -0
  152. package/dist/core/pi-server-subagents.js.map +1 -0
  153. package/dist/core/project-trust.js +1 -1
  154. package/dist/core/project-trust.js.map +1 -1
  155. package/dist/core/provider-composer.d.ts +1 -1
  156. package/dist/core/provider-composer.d.ts.map +1 -1
  157. package/dist/core/provider-composer.js +1 -0
  158. package/dist/core/provider-composer.js.map +1 -1
  159. package/dist/core/remote-catalog-provider.d.ts +3 -2
  160. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  161. package/dist/core/remote-catalog-provider.js +32 -16
  162. package/dist/core/remote-catalog-provider.js.map +1 -1
  163. package/dist/core/resource-loader.d.ts +6 -1
  164. package/dist/core/resource-loader.d.ts.map +1 -1
  165. package/dist/core/resource-loader.js +42 -24
  166. package/dist/core/resource-loader.js.map +1 -1
  167. package/dist/core/sdk.d.ts.map +1 -1
  168. package/dist/core/sdk.js +61 -18
  169. package/dist/core/sdk.js.map +1 -1
  170. package/dist/core/session-manager.d.ts +7 -0
  171. package/dist/core/session-manager.d.ts.map +1 -1
  172. package/dist/core/session-manager.js +32 -13
  173. package/dist/core/session-manager.js.map +1 -1
  174. package/dist/core/settings-manager.d.ts +2 -0
  175. package/dist/core/settings-manager.d.ts.map +1 -1
  176. package/dist/core/settings-manager.js +11 -0
  177. package/dist/core/settings-manager.js.map +1 -1
  178. package/dist/core/settings-schema.d.ts +4 -2
  179. package/dist/core/settings-schema.d.ts.map +1 -1
  180. package/dist/core/settings-schema.js +8 -1
  181. package/dist/core/settings-schema.js.map +1 -1
  182. package/dist/core/skills.d.ts.map +1 -1
  183. package/dist/core/skills.js +6 -14
  184. package/dist/core/skills.js.map +1 -1
  185. package/dist/core/slash-commands.js +2 -2
  186. package/dist/core/slash-commands.js.map +1 -1
  187. package/dist/core/source-info.d.ts +9 -0
  188. package/dist/core/source-info.d.ts.map +1 -1
  189. package/dist/core/source-info.js +13 -0
  190. package/dist/core/source-info.js.map +1 -1
  191. package/dist/core/system-prompt.d.ts.map +1 -1
  192. package/dist/core/system-prompt.js +5 -6
  193. package/dist/core/system-prompt.js.map +1 -1
  194. package/dist/core/tools/bash.d.ts +2 -2
  195. package/dist/core/tools/bash.d.ts.map +1 -1
  196. package/dist/core/tools/bash.js.map +1 -1
  197. package/dist/core/tools/edit.d.ts +3 -3
  198. package/dist/core/tools/edit.d.ts.map +1 -1
  199. package/dist/core/tools/edit.js +2 -4
  200. package/dist/core/tools/edit.js.map +1 -1
  201. package/dist/core/tools/find.d.ts +2 -2
  202. package/dist/core/tools/find.d.ts.map +1 -1
  203. package/dist/core/tools/find.js.map +1 -1
  204. package/dist/core/tools/grep.d.ts +2 -2
  205. package/dist/core/tools/grep.d.ts.map +1 -1
  206. package/dist/core/tools/grep.js +1 -1
  207. package/dist/core/tools/grep.js.map +1 -1
  208. package/dist/core/tools/ls.d.ts +2 -2
  209. package/dist/core/tools/ls.d.ts.map +1 -1
  210. package/dist/core/tools/ls.js.map +1 -1
  211. package/dist/core/tools/read.d.ts +2 -2
  212. package/dist/core/tools/read.d.ts.map +1 -1
  213. package/dist/core/tools/read.js.map +1 -1
  214. package/dist/core/tools/render-utils.js +2 -2
  215. package/dist/core/tools/render-utils.js.map +1 -1
  216. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  217. package/dist/core/tools/renderers/write.js +19 -19
  218. package/dist/core/tools/renderers/write.js.map +1 -1
  219. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
  220. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  221. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  222. package/dist/core/tools/write.d.ts +2 -2
  223. package/dist/core/tools/write.d.ts.map +1 -1
  224. package/dist/core/tools/write.js.map +1 -1
  225. package/dist/core/trust-manager.d.ts.map +1 -1
  226. package/dist/core/trust-manager.js +14 -8
  227. package/dist/core/trust-manager.js.map +1 -1
  228. package/dist/core/usage-totals.d.ts.map +1 -1
  229. package/dist/core/usage-totals.js +2 -0
  230. package/dist/core/usage-totals.js.map +1 -1
  231. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  232. package/dist/extensions/codemode/renderer.js +6 -2
  233. package/dist/extensions/codemode/renderer.js.map +1 -1
  234. package/dist/extensions/codemode/tool.d.ts +2 -1
  235. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  236. package/dist/extensions/codemode/tool.js +33 -8
  237. package/dist/extensions/codemode/tool.js.map +1 -1
  238. package/dist/extensions/llama/ui.d.ts.map +1 -1
  239. package/dist/extensions/llama/ui.js +16 -4
  240. package/dist/extensions/llama/ui.js.map +1 -1
  241. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  242. package/dist/extensions/mcp/cli.js +34 -8
  243. package/dist/extensions/mcp/cli.js.map +1 -1
  244. package/dist/extensions/mcp/oauth.d.ts +1 -1
  245. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  246. package/dist/extensions/mcp/oauth.js +36 -13
  247. package/dist/extensions/mcp/oauth.js.map +1 -1
  248. package/dist/extensions/mcp/ui.d.ts +1 -0
  249. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  250. package/dist/extensions/mcp/ui.js +33 -24
  251. package/dist/extensions/mcp/ui.js.map +1 -1
  252. package/dist/extensions/tool-search/tool.d.ts +21 -6
  253. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  254. package/dist/extensions/tool-search/tool.js +104 -36
  255. package/dist/extensions/tool-search/tool.js.map +1 -1
  256. package/dist/index.d.ts +2 -2
  257. package/dist/index.d.ts.map +1 -1
  258. package/dist/index.js.map +1 -1
  259. package/dist/main.d.ts.map +1 -1
  260. package/dist/main.js +30 -7
  261. package/dist/main.js.map +1 -1
  262. package/dist/modes/interactive/components/assistant-message.d.ts +4 -1
  263. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  264. package/dist/modes/interactive/components/assistant-message.js +45 -21
  265. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  266. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  267. package/dist/modes/interactive/components/config-selector.js +4 -17
  268. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  269. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  270. package/dist/modes/interactive/components/custom-editor.js +7 -0
  271. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  272. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  273. package/dist/modes/interactive/components/custom-entry.js +2 -1
  274. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  275. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  276. package/dist/modes/interactive/components/custom-message.js +2 -1
  277. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  278. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  279. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  280. package/dist/modes/interactive/components/extension-editor.js +4 -0
  281. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  282. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  283. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  284. package/dist/modes/interactive/components/login-dialog.js +105 -10
  285. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  286. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  287. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  288. package/dist/modes/interactive/components/markdown-transform.js +3 -2
  289. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  290. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  291. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  292. package/dist/modes/interactive/components/model-selector.js +17 -6
  293. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  294. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
  295. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  296. package/dist/modes/interactive/components/oauth-selector.js +13 -4
  297. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  298. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  299. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  300. package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
  301. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  302. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  303. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  304. package/dist/modes/interactive/components/session-selector-search.js +86 -22
  305. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  306. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  307. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  308. package/dist/modes/interactive/components/session-selector.js +16 -24
  309. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  310. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  311. package/dist/modes/interactive/components/settings-submenu.js +2 -0
  312. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  313. package/dist/modes/interactive/components/tool-execution.d.ts +6 -0
  314. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  315. package/dist/modes/interactive/components/tool-execution.js +14 -2
  316. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  317. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  318. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  319. package/dist/modes/interactive/components/tree-selector.js +5 -6
  320. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  321. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  322. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  323. package/dist/modes/interactive/components/user-message-selector.js +9 -1
  324. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  325. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  326. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  327. package/dist/modes/interactive/components/user-message.js +6 -2
  328. package/dist/modes/interactive/components/user-message.js.map +1 -1
  329. package/dist/modes/interactive/external-editor.d.ts +1 -0
  330. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  331. package/dist/modes/interactive/external-editor.js +10 -4
  332. package/dist/modes/interactive/external-editor.js.map +1 -1
  333. package/dist/modes/interactive/interactive-mode.d.ts +5 -0
  334. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  335. package/dist/modes/interactive/interactive-mode.js +179 -58
  336. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  337. package/dist/modes/interactive/model-search.d.ts +10 -0
  338. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  339. package/dist/modes/interactive/model-search.js +21 -0
  340. package/dist/modes/interactive/model-search.js.map +1 -1
  341. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  342. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  343. package/dist/modes/interactive/theme/theme.js +31 -23
  344. package/dist/modes/interactive/theme/theme.js.map +1 -1
  345. package/dist/package-manager-cli.d.ts.map +1 -1
  346. package/dist/package-manager-cli.js +55 -4
  347. package/dist/package-manager-cli.js.map +1 -1
  348. package/dist/utils/ansi.d.ts.map +1 -1
  349. package/dist/utils/ansi.js +5 -2
  350. package/dist/utils/ansi.js.map +1 -1
  351. package/dist/utils/clipboard-command.d.ts.map +1 -1
  352. package/dist/utils/clipboard-command.js +4 -0
  353. package/dist/utils/clipboard-command.js.map +1 -1
  354. package/dist/utils/git.d.ts +1 -1
  355. package/dist/utils/git.d.ts.map +1 -1
  356. package/dist/utils/git.js.map +1 -1
  357. package/dist/utils/image-resize-core.d.ts.map +1 -1
  358. package/dist/utils/image-resize-core.js +5 -3
  359. package/dist/utils/image-resize-core.js.map +1 -1
  360. package/dist/utils/open-browser.d.ts.map +1 -1
  361. package/dist/utils/open-browser.js +4 -1
  362. package/dist/utils/open-browser.js.map +1 -1
  363. package/dist/utils/paths.d.ts +17 -0
  364. package/dist/utils/paths.d.ts.map +1 -1
  365. package/dist/utils/paths.js +42 -1
  366. package/dist/utils/paths.js.map +1 -1
  367. package/dist/utils/shell.d.ts.map +1 -1
  368. package/dist/utils/shell.js +14 -0
  369. package/dist/utils/shell.js.map +1 -1
  370. package/dist/utils/syntax-highlight.d.ts +5 -0
  371. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  372. package/dist/utils/syntax-highlight.js +7 -0
  373. package/dist/utils/syntax-highlight.js.map +1 -1
  374. package/dist/utils/tools-manager.d.ts.map +1 -1
  375. package/dist/utils/tools-manager.js +30 -35
  376. package/dist/utils/tools-manager.js.map +1 -1
  377. package/docs/cli.md +21 -11
  378. package/docs/custom-provider.md +2 -0
  379. package/docs/environment-variables.md +2 -0
  380. package/docs/extensions.md +3173 -225
  381. package/docs/keybindings.md +1 -1
  382. package/docs/llama-cpp.md +23 -12
  383. package/docs/mcp.md +6 -4
  384. package/docs/message-types.md +1 -1
  385. package/docs/packages.md +24 -0
  386. package/docs/quickstart.md +7 -3
  387. package/docs/sessions.md +11 -3
  388. package/docs/settings.md +5 -4
  389. package/docs/slash-commands.md +3 -2
  390. package/docs/terminal-setup.md +3 -1
  391. package/docs/tmux.md +6 -0
  392. package/docs/tui.md +2 -0
  393. package/docs/windows.md +27 -0
  394. package/examples/extensions/README.md +2 -1
  395. package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  396. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  397. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  398. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  399. package/examples/extensions/debug-provider.ts +2 -2
  400. package/examples/extensions/gondolin/package-lock.json +19 -29
  401. package/examples/extensions/gondolin/package.json +2 -2
  402. package/examples/extensions/preset.ts +2 -0
  403. package/examples/extensions/reload-runtime.ts +17 -5
  404. package/examples/extensions/todo.ts +7 -0
  405. package/examples/extensions/tools.ts +2 -0
  406. package/examples/extensions/with-deps/package-lock.json +2 -2
  407. package/examples/extensions/with-deps/package.json +1 -1
  408. package/examples/tsconfig.json +180 -0
  409. package/package.json +13 -14
  410. package/schemas/models.schema.json +36 -36
  411. package/schemas/settings.schema.json +17 -0
  412. package/dist/bundle/chunks/anthropic-messages-3TZAX2CL.js +0 -6
  413. package/dist/bundle/chunks/azure-openai-responses-5OV6AS44.js +0 -2
  414. package/dist/bundle/chunks/chunk-3V45WARH.js +0 -7
  415. package/dist/bundle/chunks/chunk-GA3MDGH3.js +0 -82
  416. package/dist/bundle/chunks/chunk-H2UJDH5M.js +0 -131
  417. package/dist/bundle/chunks/chunk-H76KZMOI.js +0 -2
  418. package/dist/bundle/chunks/chunk-K47GPRYD.js +0 -1577
  419. package/dist/bundle/chunks/chunk-PG7P2LUM.js +0 -4
  420. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +0 -2
  421. package/dist/bundle/chunks/chunk-TLSZ4DWU.js +0 -16
  422. package/dist/bundle/chunks/chunk-WVXVPMMO.js +0 -2
  423. package/dist/bundle/chunks/mistral-conversations-OJFHLO4F.js +0 -5
  424. package/dist/bundle/chunks/openai-completions-T5JB7LUM.js +0 -7
  425. package/dist/bundle/chunks/pi-messages-S7RKCD5K.js +0 -8
  426. package/dist/bundle/chunks/virtual-modules-2WW4BVZM.js +0 -2
  427. package/examples/extensions/sandbox/index.ts +0 -321
  428. package/examples/extensions/sandbox/package-lock.json +0 -92
  429. package/examples/extensions/sandbox/package.json +0 -19
package/CHANGELOG.md CHANGED
@@ -5,7 +5,6 @@
5
5
  ### Breaking Changes
6
6
 
7
7
  - Errors in input, context, agent preparation, and provider request/header transformation handlers stop the affected request instead of continuing with original or partially transformed data.
8
- - `pi.exec()` rejects command startup failures instead of returning an empty failed result.
9
8
 
10
9
  ### Added
11
10
 
@@ -17,6 +16,11 @@
17
16
 
18
17
  ### Fixed
19
18
 
19
+ - Closed session observers before runtime command exits and drained Windows handle cleanup.
20
+ - Fixed steering and follow-up messages queued during manual pi-server compaction failing to send when compaction completed.
21
+ - Released pi-server synchronization tracking when sessions are disposed and temporary streams finish, including failures, cancellation, and recovered responses.
22
+ - Fixed session resume hints being truncated by interactive exit before terminal output completed.
23
+ - Kept pi-server observer socket reconnections quiet while preserving connection, update, and shutdown failure diagnostics.
20
24
  - Used entry commit times for saved observer messages and isolated pending observer responses when switching sessions.
21
25
  - Stopped viewer observer reconnection when the server's presence handshake reports that the session was deleted.
22
26
  - Preserved client identity and attribution settings across pi-server chat, compaction, image, classifier, and deferred requests.
@@ -32,10 +36,8 @@
32
36
  - Kept model resolution errors inside the calling process and returned failed exit status for signal-terminated extension commands.
33
37
  - Connected `/reload` to updated pi-client runtime startup while preserving the session tree, selected branch, and startup options across active sessions.
34
38
  - Restored persisted model and thinking selections before the first prompt and applied runtime API keys to the exact selected provider before session model resolution.
35
- - Kept provider-only credential commands independent of server model catalog access.
36
- - Kept pi-client interactive startup usable when pi-server's model catalog is unavailable, reported catalog failures, and reused the current catalog until an explicit refresh.
39
+ - Kept pi-client model catalogs, availability, provider capabilities, and model selection determined by client configuration, credentials, and native discovery without consulting the server catalog.
37
40
  - Routed model-registry and provider image generation, classification, direct streams, and deferred response fetch/cancel through pi-server, including codemode usage and virtual-model routing.
38
- - Combined the server's typed model catalog and precise availability with configured client models and native account discovery without requiring client-side provider credentials.
39
41
  - Preserved provider sampling options, parsed stream events, payload transformations, and response callbacks across pi-server requests.
40
42
  - Kept help, version, and invalid provider selections independent of server connectivity while preserving extension help flags.
41
43
  - Enabled prompt-cache warming through pi-server during active runs and idle mode, preserving request prefixes, cache options, cancellation, and local usage accounting.
@@ -61,6 +63,122 @@
61
63
  - Preserved oversized-session chunked summarization and pi-server compaction recovery while adopting upstream canonical context projection and extension boundaries.
62
64
  - Preserved eligible provider prompt prefixes during compaction summaries, with explicit reasons when the existing chunked path is required.
63
65
 
66
+ ## [1.5.0] - 2026-11-02
67
+
68
+ ### New Features
69
+
70
+ - **Extension update changelogs**: see what changed in installed extension packages on the next fresh launch after an update. Package authors can choose the changelog path, and `collapseChangelog` condenses the notices. See [Show a changelog](docs/packages.md#show-a-changelog).
71
+ - **Faster streaming**: large tool calls are parsed incrementally, and code-heavy answers and tool rows reuse highlighting and rendered Markdown instead of repeating the work on every update. See [Keep rendering responsive](docs/tui.md#keep-rendering-responsive).
72
+ - **Custom self-update commands**: use `PI_SELF_UPDATE_COMMAND` or `selfUpdateCommand` to update pi through a wrapper or another package manager. See [Custom update command](docs/cli.md#custom-update-command).
73
+ - **GPT-6.1 Terra**: available through OpenAI, Azure OpenAI Responses, and OpenAI Codex, with tool search, mid-conversation thinking-level changes, and thinking `off`. Codex offers a 500K context window. See [Models](docs/cli.md#models).
74
+
75
+ ### Breaking Changes
76
+
77
+ - Tool argument validation runs on `@earendil-works/pi-schema`. TypeBox features outside JSON Schema (`Type.Refine()`, `Type.BigInt()`, `Type.Undefined()`, codecs, `Format.Set()` formats) no longer apply to tool arguments; see [Tool parameter schemas and TypeBox](docs/extensions.md#tool-parameter-schemas-and-typebox). Plain JSON Schema tools, including MCP tools, now get the same coercion as TypeBox tools, such as converting numeric strings and wrapping a single value into an array. Validation failures the model sees list pi-schema's messages (`- path: missing`, `- limit: expected number, got string`) instead of TypeBox's (`must have required properties path`, `must be number`).
78
+
79
+ ### Added
80
+
81
+ - Extension packages can now show their changelog after an update. Pi reads `pi.changelogPath` from the package's `package.json`, or `CHANGELOG.md` in the package root, and on the next fresh launch shows entries newer than the last seen version under "Extension Updates". The `collapseChangelog` setting condenses this to one line per package ([#5958](https://github.com/earendil-works/pi/issues/5958), [#8790](https://github.com/earendil-works/pi/pull/8790))
82
+ - `pi.exec()` accepts a `maxBuffer` option that limits stdout and stderr combined, and its result has a `truncated` field that is true when output exceeded the limit ([#11360](https://github.com/earendil-works/pi/issues/11360))
83
+ - Device-code login (for example GitHub Copilot) now opens the verification page and copies the code when you press Enter. Providers can turn either action off with `openBrowserOnConfirm: false` or `copyCodeOnConfirm: false` ([#9282](https://github.com/earendil-works/pi/issues/9282), [#9301](https://github.com/earendil-works/pi/pull/9301))
84
+ - `pi update` can update Pi through a wrapper or another package manager. Set `PI_SELF_UPDATE_COMMAND` (for example `mise use -g npm:{packageName}@{version}`) or the global `selfUpdateCommand` setting; `pi update` runs it when pi.dev reports a newer release and fills `{packageName}`, `{version}`, and `{installSpec}` from that release. See [Custom update command](docs/cli.md#custom-update-command) ([#7756](https://github.com/earendil-works/pi/issues/7756), [#5607](https://github.com/earendil-works/pi/issues/5607))
85
+ - Extensions can format the user's configured keybindings with `keyText()` and `keyHint()` from the tool render context and the message and entry renderer options. Importing these functions from `@earendil-works/pi-coding-agent` can resolve the extension's own copy of the package, which does not see pi's keybindings, so hints such as `keyHint("app.tools.expand", "to expand")` rendered without the key. The docs now recommend the injected functions ([#4748](https://github.com/earendil-works/pi/issues/4748))
86
+ - Added persisted session-entry `messageId` and ISO `timestamp` to `MarkdownTransformContext`. They are available when rendering saved entries and undefined for live rendering ([#7952](https://github.com/earendil-works/pi/pull/7952) by [@vipentti](https://github.com/vipentti))
87
+ - Added a `blocked` option to inline `ctx.ui.custom()` components so approval prompts and other custom dialogs can report that pi is waiting for user input. Overlays ignore the option. See [Custom screens and overlays](docs/tui.md#use-custom-screens-and-overlays) ([#11428](https://github.com/earendil-works/pi/issues/11428))
88
+ - Added `Usage.cost.totalFromProvider` to distinguish billed totals from catalog estimates in SDK and extension usage data; combined usage is marked provider-reported only when every part is ([#11178](https://github.com/earendil-works/pi/pull/11178))
89
+ - Added concrete `responseModel` metadata to messages from pi-messages providers such as Radius, including when a virtual model is requested. See [AssistantMessage](docs/message-types.md#assistantmessage) ([#11265](https://github.com/earendil-works/pi/pull/11265))
90
+ - Added GPT-6.1 Terra for OpenAI, Azure OpenAI Responses, and OpenAI Codex, with tool search and mid-conversation thinking-level changes. It supports thinking `off`; Codex offers a 500K context window
91
+
92
+ ### Changed
93
+
94
+ - Extensions keep importing `Type`, `Static` and `TSchema` from `@earendil-works/pi-ai`: Pi maps that import to pi-ai's compat entry plus the TypeBox it bundles, now that pi-ai itself no longer re-exports TypeBox, and its `StringEnum` there stays a TypeBox `TUnsafe<T>`. The built-in tool factories (`createReadTool()` and the others) return `TypeBoxAgentTool<typeof schema>`, which keeps `params` typed for TypeBox.
95
+ - Tightened system prompt
96
+ - `pi update` for installs from the pi.dev installer no longer passes `--min-release-age=0` to `npm ci`. The release lockfile pins every package, so the flag had no effect, and security scanners that block it stopped the update ([#11262](https://github.com/earendil-works/pi/issues/11262))
97
+ - `/model` and `/scoped-models` now show a model's name next to its ID when the name adds words the ID lacks, such as a renamed `models.json` override ([#5916](https://github.com/earendil-works/pi/issues/5916), [#11347](https://github.com/earendil-works/pi/pull/11347))
98
+ - MCP OAuth sign-in now uses pi's Client ID Metadata Document by default when the authorization server supports it for public clients, and registers a client dynamically otherwise, like Codex, Claude Code, and opencode. Clients registered before stay in use while their redirect URI matches. The new default `oauth.clientRegistration: "auto"` registers when `clientName` or a non-default `callbackUrl` is set; `"dcr"` always registers. `pi mcp add --oauth-client-registration` sets the mode ([#11426](https://github.com/earendil-works/pi/issues/11426))
99
+ - Changed the default OpenAI model from `gpt-5.5` to `gpt-6.1-sol`, including after ChatGPT sign-in when no model is selected ([#11442](https://github.com/earendil-works/pi/issues/11442))
100
+ - Updated the built-in model catalog to models.dev v2. Realtime and image-only models are no longer offered as chat models; newer OpenAI and Google chat models are included
101
+
102
+ ### Fixed
103
+
104
+ - Updated glob matching to prevent denial of service from amplified glob patterns.
105
+ - Fixed a saved "Do not trust" decision being ignored for projects without trust-requiring resources, for example a folder with only `AGENTS.md`. pi auto-trusted such projects, so `ctx.isProjectTrusted()` returned true and package commands treated them as trusted. A saved decision in `trust.json` now takes precedence; auto-trust applies only when no decision is saved ([#10947](https://github.com/earendil-works/pi/issues/10947))
106
+ - Fixed `Shift+Enter` queueing a follow-up instead of inserting a newline in Apple Terminal setups that send `ESC` + Return. pi now checks the local Shift key state for that sequence, as it already did for plain Return; `Alt+Enter` without Shift still queues a follow-up ([#11559](https://github.com/earendil-works/pi/issues/11559))
107
+ - Fixed the working status (OSC 7501) disappearing in Rex and iTerm2 during runs in regular TUI mode. Rendered messages wrote OSC 133 prompt markers to the terminal, which the terminal treats as a new shell prompt; regular mode no longer writes them ([#11519](https://github.com/earendil-works/pi/issues/11519))
108
+ - Fixed compaction, branch summaries, and bug-report summaries in SDK sessions passing the stored OAuth token back to the model runtime as an explicit API key. Provider auth that treats explicit keys differently from stored OAuth now sees the OAuth login, as normal prompts do ([#11520](https://github.com/earendil-works/pi/issues/11520))
109
+ - Fixed a redundant system prompt update (tools, rules) when an extension set the same active tools in a different order, for example a reversed `pi.setActiveTools()` list. Tools that stay active now keep their order and newly activated tools are appended ([#11495](https://github.com/earendil-works/pi/issues/11495))
110
+ - Fixed `pi.exec()` crashing pi with `RangeError: Invalid string length` when a command printed more output than fits in a string. The default output cap is the smaller of 256 MiB and the runtime string limit; past the cap, the command is terminated and the result has `truncated: true` and a nonzero exit code ([#11360](https://github.com/earendil-works/pi/issues/11360))
111
+ - Fixed `pi.exec()` never returning when a command ignored SIGTERM after a timeout or abort. pi now sends SIGKILL 5 seconds later, as intended
112
+ - Fixed `pi install` and `pi remove` adding ever deeper nested entries to the npm `package-lock.json` when the agent directory is reached through a symlink, such as `~/.pi` linked into a dotfiles repo. pi now passes the resolved real path to npm ([#11358](https://github.com/earendil-works/pi/issues/11358))
113
+ - MCP sign-in now rejects authorization endpoints and other OAuth metadata URLs that are not `http:` or `https:`. Before, a malicious MCP server could supply a `file:` or custom protocol URL, which pi passed to the platform URL handler.
114
+ - Automatic `fd` and `rg` downloads no longer fetch x86-64 binaries on ARM32 and other architectures without a prebuilt release. pi now warns and recommends installing the tool with the system package manager ([#11209](https://github.com/earendil-works/pi/issues/11209))
115
+ - Fixed `/model` search ranking letters scattered over an earlier part of an entry above a real match, for example `opus` listing `gpt-oss-120b` and `claude-sonnet-4.5` before `claude-opus-4.1` ([#11220](https://github.com/earendil-works/pi/issues/11220), [#11296](https://github.com/earendil-works/pi/pull/11296))
116
+ - Fixed `/resume` search matching scattered letters anywhere in session messages and IDs, for example `1024` matching inside a session UUID. Session names and working directories still match fuzzily; IDs and message text now match only as exact substrings ([#11220](https://github.com/earendil-works/pi/issues/11220), [#11024](https://github.com/earendil-works/pi/issues/11024), [#11296](https://github.com/earendil-works/pi/pull/11296))
117
+ - Fixed HTML export showing a blank page for sessions with thousands of entries ([#11225](https://github.com/earendil-works/pi/issues/11225), [#11293](https://github.com/earendil-works/pi/pull/11293))
118
+ - Fixed HTML export not showing system messages: the system prompt and tools, and later section updates such as after `/reload`. `pi --export` now includes the system prompt and tools too ([#11261](https://github.com/earendil-works/pi/issues/11261), [#3464](https://github.com/earendil-works/pi/issues/3464), [#11290](https://github.com/earendil-works/pi/pull/11290))
119
+ - Fixed aborting a bash command on macOS sometimes running the next command of a list such as `long_step; next_step`. pi now stops the process group before killing it ([#11252](https://github.com/earendil-works/pi/issues/11252), [#11289](https://github.com/earendil-works/pi/pull/11289))
120
+ - Fixed large streamed tool calls taking excessive CPU time and memory because every delta re-parsed the accumulated arguments. Providers and agent proxy streams now parse each delta once, grammar tools no longer copy their entire input per delta, and interactive tool renderers run at most once per frame ([#9265](https://github.com/earendil-works/pi/issues/9265))
121
+ - Fixed the login dialog opening sign-in URLs that are not web URLs, and printing control characters from sign-in, device-code, and info URLs, which could end a terminal hyperlink and send escape sequences to the terminal
122
+ - Fixed `tui.select.pageUp` and `tui.select.pageDown` being ignored in slash command and file autocomplete, `/settings`, and the model, scoped models, login, fork, `/mcp`, and llama.cpp selectors. In fullscreen mode, PageUp/PageDown now move an open list or autocomplete menu instead of scrolling the transcript, and a page key bound to Ctrl+V pages autocomplete instead of pasting an image ([#7629](https://github.com/earendil-works/pi/issues/7629), based on [#7680](https://github.com/earendil-works/pi/pull/7680) by [@muyiyr](https://github.com/muyiyr))
123
+ - Fixed tool output and `!` command output showing the parameters of control sequences with a `<`, `=` or `>` prefix as text, for example `35;59;1M` from a mouse report `ESC[<35;59;1M` or `0;276;0c` from a terminal reply `ESC[>0;276;0c`. Text after the keypad-mode sequences `ESC=` and `ESC>` is still kept ([#11377](https://github.com/earendil-works/pi/issues/11377))
124
+ - Fixed `pi -e npm:<pkg>` staying on the version from the first download. On each start and `/reload`, pi now reinstalls an `-e` npm package without an exact version when the registry has a newer matching version. `pi -e git:<repo>@<branch>` likewise stayed on its first checkout and is now fetched and reset to the branch; a commit-hash ref that is already checked out is not fetched. Offline mode and failed checks keep the cached copy ([#11375](https://github.com/earendil-works/pi/issues/11375), [#11590](https://github.com/earendil-works/pi/pull/11590))
125
+ - Fixed Windows paths being compared case-sensitively. When the working directory and home directory differed only in drive-letter casing (`c:\Users\me` vs `C:\Users\me`), skills in `~/.agents/skills` loaded twice, as project and user skills, and were reported as name collisions. The same mismatch also re-asked for saved project trust, hid sessions in a custom session directory from `--continue` and `/resume`, and stopped `pi remove` from matching configured local packages ([#10488](https://github.com/earendil-works/pi/issues/10488))
126
+ - Fixed paths next to the home directory being shown with a broken `~` prefix, for example `/home/me2/project` shown as `~2/project` when home is `/home/me`
127
+ - Fixed `pi mcp login -l` and `pi mcp logout -l` failing with `Unknown option --local.` although `pi mcp add` and `pi mcp remove` accept `-l`. With `-l`, they now require the server to be a project server. Unknown options are now reported as typed, and a mistyped server name gets a suggestion, for example `Did you mean "gurker"?`
128
+ - Fixed `pi update` naming pnpm for installs that only live under `PNPM_HOME`, for example a wrapper under `$PNPM_HOME/global-nub/`. pi said "not managed by a global pnpm install"; it now names the package manager only when that manager owns the install ([#7756](https://github.com/earendil-works/pi/issues/7756))
129
+ - Fixed image paste, copy, and opening the browser for sign-in failing silently on WSL when the working directory is deep. Windows programs such as `powershell.exe` and `explorer.exe` cannot start from a directory whose `\\wsl.localhost\...` path exceeds 260 characters; pi now starts these helpers from `/` ([#11592](https://github.com/earendil-works/pi/issues/11592))
130
+ - Fixed the external editor failing silently, for example when the editor command is wrong or a Windows editor cannot start from a deep WSL directory. pi now shows a status message such as `External editor exited with code 1; prompt unchanged` ([#11592](https://github.com/earendil-works/pi/issues/11592))
131
+ - Fixed `tool_search` and codemode `searchTools()` ranking a tool below tools that only mention its name in their descriptions, for example `peekaboo app` ranking `mcp__peekaboo__app` 14th. A tool matching more of the query's words now ranks above one matching fewer, a query word in a tool's name scores more than any number of mentions in its description, a tool whose whole name is in the query gets a large bonus, and long server instructions no longer lower the scores of that server's tools ([#11331](https://github.com/earendil-works/pi/issues/11331))
132
+ - Fixed `tool_search` and codemode `searchTools()` finding nothing for Chinese, Japanese, Thai, and other non-ASCII queries, because the tokenizer kept only ASCII letters and digits. Words in any script now match, text without spaces between words such as `搜索记录` is split into words, and canonically equivalent text such as `café` and `cafe\u0301` matches ([#10816](https://github.com/earendil-works/pi/issues/10816), [#11037](https://github.com/earendil-works/pi/pull/11037) by [@haoqixu](https://github.com/haoqixu))
133
+ - Fixed `pi update` stopping with `git clean -fdx failed with code 1` on Windows when another pi session had a git extension's native module or executable open. Windows cannot delete such files, so the update left the new code with the old dependencies. pi now warns, installs the dependencies anyway, and retries the clean on the next update ([#11597](https://github.com/earendil-works/pi/issues/11597))
134
+ - Fixed tool rows and streamed answers highlighting the same code again on every redraw. A running codemode row highlighted its whole script on every progress update and timer tick, a complete `write` row its whole file on every update and expand toggle, a streamed `write` its first 50 lines on every delta, and a streamed answer every earlier code block on every delta. Rows now reuse their last highlighting until the code, theme, or loaded grammars change, and assistant messages keep their rendered Markdown blocks while streaming ([#10971](https://github.com/earendil-works/pi/issues/10971))
135
+ - Fixed resized photos being sent as multi-megabyte PNGs even when JPEG was much smaller, causing large requests to fail or time out. Image resizing now tries the smaller encoding first ([#11551](https://github.com/earendil-works/pi/issues/11551))
136
+ - Fixed `pi update --extensions` reporting success without warning when npm's stale registry metadata left a package at its old version. pi now reports the installed and expected versions ([#11536](https://github.com/earendil-works/pi/issues/11536))
137
+ - Fixed skill validation warnings being labeled `[Skill conflicts]` even when there was no name collision. They are now shown under `[Skill warnings]` ([#11521](https://github.com/earendil-works/pi/issues/11521))
138
+ - Fixed codemode tool descriptions including entire union and multi-line output types in every request. Object unions now summarize their fields and discriminators; other multi-line types point to `describeTool()` for the full declaration ([#11501](https://github.com/earendil-works/pi/issues/11501))
139
+ - Fixed the model-scope startup notice being left in the shell after exiting fullscreen mode. It now appears inside pi's fullscreen header ([#11508](https://github.com/earendil-works/pi/issues/11508))
140
+ - Fixed startup from a deleted working directory crashing with an uncaught `uv_cwd` stack trace. pi now asks the user to change to an existing directory ([#11509](https://github.com/earendil-works/pi/issues/11509))
141
+ - Fixed failed session writes leaving entries in memory that were absent from disk, so later entries pointed to missing parents and resumed sessions lost earlier history and tools ([#11460](https://github.com/earendil-works/pi/issues/11460))
142
+ - Fixed `/tree` branch summaries ignoring the session's thinking level, which could make reasoning models reject summary requests with an unsupported `none` effort ([#11444](https://github.com/earendil-works/pi/issues/11444))
143
+ - Fixed hidden thinking with an empty hidden-thinking label still adding blank rows before answers and tool calls ([#11402](https://github.com/earendil-works/pi/issues/11402))
144
+ - Fixed package installation and removal printing npm audit and funding advice, including `npm audit fix` instructions that could install a second copy of pi into the package directory ([#11409](https://github.com/earendil-works/pi/issues/11409))
145
+ - Fixed replacing an extension editor while a dialog was open hiding the dialog and leaving it unanswerable. The new editor now appears after the dialog closes ([#11431](https://github.com/earendil-works/pi/issues/11431))
146
+ - Fixed `grep` context lines being offset from ripgrep's match line numbers when a file contains a lone carriage return ([#11398](https://github.com/earendil-works/pi/issues/11398))
147
+ - Fixed `--model <provider>/<id>` failing for provider IDs containing slashes, such as URL-derived llama.cpp provider IDs ([#11394](https://github.com/earendil-works/pi/issues/11394))
148
+ - Fixed slow session forking on filesystems where opening files is expensive by writing the fork through one file handle ([#11253](https://github.com/earendil-works/pi/issues/11253))
149
+ - Fixed `pi.exec()` corrupting UTF-8 characters split across stdout or stderr chunks ([#11312](https://github.com/earendil-works/pi/issues/11312))
150
+ - Fixed `pi.exec()` returning empty stderr when a command could not be spawned, such as a missing executable. It now preserves the spawn error message ([#11257](https://github.com/earendil-works/pi/pull/11257) by [@muyiyr](https://github.com/muyiyr))
151
+ - Fixed a configured package failing to install crashing startup. pi now skips the package, reports an extension warning, and retries on the next start or `/reload`; explicit install and update commands still fail with a nonzero exit ([#11304](https://github.com/earendil-works/pi/pull/11304) by [@Lincoln504](https://github.com/Lincoln504))
152
+ - Fixed the todo extension example crashing the TUI when a tool call failed argument validation ([#8057](https://github.com/earendil-works/pi/pull/8057) by [@cyzlmh](https://github.com/cyzlmh))
153
+ - Updated `undici` to 8.12.3 and the Gondolin extension example to 0.14.0 for security advisories
154
+ - Fixed OpenRouter cost totals using catalog estimates instead of reported billing for Chat Completions and Anthropic Messages. BYOK totals include both OpenRouter charges and reported upstream costs; component costs remain catalog estimates ([#9980](https://github.com/earendil-works/pi/issues/9980))
155
+ - Fixed OpenCode Zen and OpenCode Go requests using shared endpoints instead of their protocol-specific OpenAI, Anthropic, Google, and System One endpoints ([#11434](https://github.com/earendil-works/pi/pull/11434) by [@vimtor](https://github.com/vimtor))
156
+ - Fixed Zhipu/Z.ai usage-limit errors (code `1308`) being treated as transient HTTP 429 errors, causing automatic retries that cannot succeed until the usage cap resets ([#11537](https://github.com/earendil-works/pi/issues/11537))
157
+ - Fixed LiteLLM's `ContextWindowExceededError` not being recognized as context overflow ([#11492](https://github.com/earendil-works/pi/issues/11492))
158
+ - Fixed Gemini tool schemas sending unsupported `const` keywords. They are now converted to single-value `enum` schemas without rewriting literal data in defaults, examples, or enum values, or losing properties named `__proto__` ([#11308](https://github.com/earendil-works/pi/issues/11308))
159
+ - Fixed the faux provider counting simulated cache-write tokens as both input and cache writes
160
+ - Fixed Orca terminals falling back to text for inline images. Orca is now recognized as supporting true color and hyperlinks, and Kitty images when it advertises `ORCA_IMAGE_PROTOCOL=kitty` ([#9329](https://github.com/earendil-works/pi/pull/9329) by [@XRX193](https://github.com/XRX193))
161
+ - Fixed bare Markdown URLs swallowing following CJK punctuation and text; explicit Markdown links and angle autolinks are unchanged ([#10934](https://github.com/earendil-works/pi/pull/10934) by [@haoqixu](https://github.com/haoqixu))
162
+ - Fixed Kitty-protocol F1–F12 shortcuts, including modified function keys, not being recognized, and F13+ and other functional keys inserting invisible private-use characters into the editor ([#11419](https://github.com/earendil-works/pi/issues/11419), [#11345](https://github.com/earendil-works/pi/issues/11345))
163
+ - Fixed Kitty images inside padded or colored boxes disappearing when their first row scrolled above the fullscreen viewport. Partially visible images are now cropped correctly, including beside other text
164
+ - Fixed deeply nested Markdown blockquotes producing exponentially many lines, hanging or crashing rendering once their borders exhausted the available width ([#11272](https://github.com/earendil-works/pi/issues/11272))
165
+ - Fixed Claude sessions failing with `role 'system' must precede an 'assistant' message` when a system update was followed by an empty or reasoning-only assistant reply ([#11091](https://github.com/earendil-works/pi/issues/11091))
166
+ - Fixed Claude mid-conversation thinking-level changes failing with `Invalid effort level` on accounts whose organization caps effort below `high` ([#10063](https://github.com/earendil-works/pi/issues/10063))
167
+ - Fixed Kimi K3.1 Pro models using Kimi K2 request settings on Kimi Coding, Moonshot, and OpenCode Go. They now send the correct reasoning effort, preserve earlier thinking, accept tools added mid-conversation, and use K3-family pricing
168
+ - Fixed OpenCode DeepSeek V4.1 Flash requests failing when long cache retention sent the unsupported `prompt_cache_retention` parameter
169
+ - Fixed GPT-5.4 and GPT-5.5 failing with `Missing namespace for function_call` after switching from a model that had called tools ([#11415](https://github.com/earendil-works/pi/issues/11415))
170
+ - Fixed Bedrock Claude requests failing when preferred strict tools exceed the provider's strict-tool limits. Requests now retry once with preferred tools non-strict while keeping required strict tools strict ([#11416](https://github.com/earendil-works/pi/issues/11416))
171
+ - Fixed OpenRouter's `~anthropic/claude-*-latest` aliases losing earlier thinking after tool calls by using the Anthropic Messages API ([#9534](https://github.com/earendil-works/pi/issues/9534))
172
+ - Fixed terminal titles containing control characters being able to inject terminal escape sequences, and pi-messages streams accepting invalid content-block indices
173
+ - Fixed fullscreen double-click selection splitting paths and tokens at `~`, `.`, `\`, and `+`; word characters now match iTerm2's defaults ([#10980](https://github.com/earendil-works/pi/issues/10980))
174
+ - Fixed display math wider than the content area being split apart by line wrapping; it now falls back to raw LaTeX ([#11483](https://github.com/earendil-works/pi/issues/11483))
175
+ - Fixed styled words ending exactly at the wrap width adding a leading space on the next line, and strikethrough leaking into wrapped-line padding ([#10925](https://github.com/earendil-works/pi/issues/10925))
176
+ - Fixed `/tree` branch summaries including failed assistant replies and original content that context edits had hidden or replaced. Summaries now honor the same context edits as live requests and compaction ([#11602](https://github.com/earendil-works/pi/issues/11602))
177
+
178
+ ### Removed
179
+
180
+ - Removed the native OS `sandbox/` extension example and its dependency. Use the [Gondolin example](examples/extensions/gondolin/) or the [containerization guide](docs/containerization.md).
181
+
64
182
  ## [1.4.0] - 2026-10-21
65
183
 
66
184
  ### New Features
@@ -0,0 +1,6 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{ANTHROPIC_FEDERATION_RULE_ID_ENV,ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,ANTHROPIC_ORGANIZATION_ID_ENV,ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,ANTHROPIC_WORKSPACE_ID_ENV}from"./chunk-UKVNB6C4.js";import{applyOpenRouterReportedCost,isOpenRouterModel}from"./chunk-P7FPUEYA.js";import{buildCopilotDynamicHeaders,hasCopilotVisionInput}from"./chunk-PGXDEOVV.js";import{Anthropic}from"./chunk-7CBJINYJ.js";import{retryProviderRequest}from"./chunk-PMRZO46Y.js";import{adjustMaxTokensForThinking,buildBaseOptions,clampMaxTokensToContext,getJsonSchemaToolParameters,isStrictToolLimitErrorMessage,prefersJsonSchemaStrictSampling,resolveJsonSchemaStrictSampling,splitErrorToolResultImages,transformMessages}from"./chunk-4RKLODCT.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import{headersToRecord}from"./chunk-UTB4DTYQ.js";import{getProviderEnvValue}from"./chunk-7DDKXS2Q.js";import{ToolCallArgumentsStream,parseJsonWithRepair}from"./chunk-FFMDRXC4.js";import{calculateCost,getCurrentTools,getInitialSystemMessage,resolveTranscript}from"./chunk-G23G7KNC.js";import{AssistantMessageEventStream,appendAssistantMessageDiagnostic}from"./chunk-LPXNMA2W.js";import{getIdentityHeaders,getSystemMessageText,renderSystemMessageUpdate}from"./chunk-GO33PKBT.js";import"./chunk-JXWJOIH4.js";function resolveCacheRetention(cacheRetention,env){return cacheRetention||(getProviderEnvValue("PI_CACHE_RETENTION",env)==="long"?"long":"short")}function getCacheControl(model,cacheRetention,env){let retention=resolveCacheRetention(cacheRetention,env);if(retention==="none")return{retention};let ttl=retention==="long"&&getAnthropicCompat(model).supportsLongCacheRetention?"1h":void 0;return{retention,cacheControl:{type:"ephemeral",...ttl&&{ttl}}}}var claudeCodeVersion="2.1.280",claudeCodeTools=["Read","Write","Edit","Bash","Grep","Glob","AskUserQuestion","EnterPlanMode","ExitPlanMode","KillShell","NotebookEdit","Skill","Task","TaskOutput","TodoWrite","WebFetch","WebSearch"],ccToolLookup=new Map(claudeCodeTools.map(t=>[t.toLowerCase(),t])),toClaudeCodeName=name=>ccToolLookup.get(name.toLowerCase())??name,fromClaudeCodeName=(name,tools)=>{if(tools&&tools.length>0){let lowerName=name.toLowerCase(),matchedTool=tools.find(tool=>tool.name.toLowerCase()===lowerName);if(matchedTool)return matchedTool.name}return name};function convertImageBlock(image){return{type:"image",source:{type:"base64",media_type:image.mimeType,data:image.data}}}function convertContentBlocks(content){if(!content.some(c=>c.type==="image"))return sanitizeSurrogates(content.map(c=>c.text).join(`
3
+ `));let blocks=content.map(block=>block.type==="text"?{type:"text",text:sanitizeSurrogates(block.text)}:convertImageBlock(block));return blocks.some(b=>b.type==="text")||blocks.unshift({type:"text",text:"(see attached image)"}),blocks}var FINE_GRAINED_TOOL_STREAMING_BETA="fine-grained-tool-streaming-2025-05-14",INTERLEAVED_THINKING_BETA="interleaved-thinking-2025-05-14",SERVER_SIDE_FALLBACK_BETA="server-side-fallback-2026-07-01",MID_CONVERSATION_OUTPUT_CONFIG_BETA="mid-conversation-output-config-2026-07-01",THINKING_BINDING_CONTROLS_BETA="thinking-binding-controls-2026-08-01",INLINE_TOOLS_BETA="inline-tools-2026-09-15",DEFERRED_TOOL_PLACEHOLDER={name:"__pi_deferred_placeholder__",description:"Reserved placeholder. Never available. Never call this.",input_schema:{type:"object",properties:{},required:[]},defer_loading:!0};function shouldUseServerSideFallbackBeta(model){return(model.compat?.allowedFallbackModels?.length??0)>0}function getAnthropicCompat(model){let isOpenRouter=model.provider==="openrouter"||model.baseUrl.includes("openrouter.ai");return{supportsEagerToolInputStreaming:model.compat?.supportsEagerToolInputStreaming??!0,supportsLongCacheRetention:model.compat?.supportsLongCacheRetention??!0,sendSessionAffinityHeaders:model.compat?.sendSessionAffinityHeaders??isOpenRouter,sessionAffinityFormat:model.compat?.sessionAffinityFormat??(isOpenRouter?"openrouter":void 0),supportsCacheControlOnTools:model.compat?.supportsCacheControlOnTools??!0,supportsTemperature:model.compat?.supportsTemperature??!0,allowEmptySignature:model.compat?.allowEmptySignature??!1,supportsStrictTools:model.compat?.supportsStrictTools??!1,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsMidConvoToolChanges:model.compat?.supportsMidConvoToolChanges??!1}}function mergeHeaders(...headerSources){let merged={};for(let headers of headerSources)headers&&Object.assign(merged,headers);return merged}function hasHeader(headers,name){if(!headers)return!1;let expected=name.toLowerCase();for(let[key,value]of Object.entries(headers))if(key.toLowerCase()===expected&&value!==null&&value.trim().length>0)return!0;return!1}function hasRequestAuth(apiKey,headers){return!!apiKey||hasHeader(headers,"authorization")||hasHeader(headers,"x-api-key")||hasHeader(headers,"cf-aig-authorization")}function assertRequestAuth(provider,apiKey,headers){if(!hasRequestAuth(apiKey,headers))throw new Error(`No API key for provider: ${provider}`)}var PiAnthropic=class extends Anthropic{_shouldResolveDefaultCredentials(){return!1}};function getAnthropicFederation(model,apiKey,headers,env){if(model.provider!=="anthropic"||hasRequestAuth(apiKey,headers))return;let federationRuleId=getProviderEnvValue(ANTHROPIC_FEDERATION_RULE_ID_ENV,env),organizationId=getProviderEnvValue(ANTHROPIC_ORGANIZATION_ID_ENV,env),identityTokenFile=getProviderEnvValue(ANTHROPIC_IDENTITY_TOKEN_FILE_ENV,env);if(!(!federationRuleId||!organizationId||!identityTokenFile))return{organization_id:organizationId,workspace_id:getProviderEnvValue(ANTHROPIC_WORKSPACE_ID_ENV,env),authentication:{type:"oidc_federation",federation_rule_id:federationRuleId,service_account_id:getProviderEnvValue(ANTHROPIC_SERVICE_ACCOUNT_ID_ENV,env),identity_token:{source:"file",path:identityTokenFile}}}}var federationClient,ANTHROPIC_MESSAGE_EVENTS=new Set(["message_start","message_delta","message_stop","content_block_start","content_block_delta","content_block_stop"]);function flushSseEvent(state){if(!state.event&&state.data.length===0)return null;let event={event:state.event,data:state.data.join(`
4
+ `),raw:[...state.raw]};return state.event=null,state.data=[],state.raw=[],event}function decodeSseLine(line,state){if(line==="")return flushSseEvent(state);if(state.raw.push(line),line.startsWith(":"))return null;let delimiterIndex=line.indexOf(":"),fieldName=delimiterIndex===-1?line:line.slice(0,delimiterIndex),value=delimiterIndex===-1?"":line.slice(delimiterIndex+1);return value.startsWith(" ")&&(value=value.slice(1)),fieldName==="event"?state.event=value:fieldName==="data"&&state.data.push(value),null}function nextLineBreakIndex(text){let carriageReturnIndex=text.indexOf("\r"),newlineIndex=text.indexOf(`
5
+ `);return carriageReturnIndex===-1?newlineIndex:newlineIndex===-1?carriageReturnIndex:Math.min(carriageReturnIndex,newlineIndex)}function consumeLine(text){let lineBreakIndex=nextLineBreakIndex(text);if(lineBreakIndex===-1)return null;let nextIndex=lineBreakIndex+1;return text[lineBreakIndex]==="\r"&&text[nextIndex]===`
6
+ `&&(nextIndex+=1),{line:text.slice(0,lineBreakIndex),rest:text.slice(nextIndex)}}async function*iterateSseMessages(body,signal){let reader=body.getReader(),decoder=new TextDecoder,state={event:null,data:[],raw:[]},buffer="";try{for(;;){if(signal?.aborted)throw new Error("Request was aborted");let{value,done}=await reader.read();if(done)break;buffer+=decoder.decode(value,{stream:!0});let consumed2=consumeLine(buffer);for(;consumed2;){buffer=consumed2.rest;let event=decodeSseLine(consumed2.line,state);event&&(yield event),consumed2=consumeLine(buffer)}}buffer+=decoder.decode();let consumed=consumeLine(buffer);for(;consumed;){buffer=consumed.rest;let event=decodeSseLine(consumed.line,state);event&&(yield event),consumed=consumeLine(buffer)}if(buffer.length>0){let event=decodeSseLine(buffer,state);event&&(yield event)}let trailingEvent=flushSseEvent(state);trailingEvent&&(yield trailingEvent)}finally{reader.releaseLock()}}async function*iterateAnthropicEvents(response,signal){if(!response.body)throw new Error("Attempted to iterate over an Anthropic response with no body");let sawMessageStart=!1,sawMessageEnd=!1;for await(let sse of iterateSseMessages(response.body,signal)){if(sse.event==="error")throw new Error(sse.data);if(ANTHROPIC_MESSAGE_EVENTS.has(sse.event??""))try{let event=parseJsonWithRepair(sse.data);event.type==="message_start"?sawMessageStart=!0:event.type==="message_stop"&&(sawMessageEnd=!0),yield event}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Could not parse Anthropic SSE event ${sse.event}: ${message}; data=${sse.data}; raw=${sse.raw.join("\\n")}`)}}if(sawMessageStart&&!sawMessageEnd)throw new Error("Anthropic stream ended before message_stop")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,getAnthropicCompat(model).supportsMidConvoSystemMessages),currentTools=getCurrentTools(normalizedContext.messages);return(async()=>{let output={role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let client,isOAuth,usageModel=model,inputTransformations;if(options?.client)client=options.client,isOAuth=!1;else{let apiKey=options?.apiKey,federation=getAnthropicFederation(model,apiKey,options?.headers,options?.env);federation||assertRequestAuth(model.provider,apiKey,options?.headers);let copilotDynamicHeaders;if(model.provider==="github-copilot"){let hasImages=hasCopilotVisionInput(normalizedContext.messages);copilotDynamicHeaders=buildCopilotDynamicHeaders({messages:normalizedContext.messages,hasImages})}let cacheSessionId=resolveCacheRetention(options?.cacheRetention,options?.env)==="none"?void 0:options?.sessionId,created=createClient(model,apiKey,options?.headers,options?.fetch,copilotDynamicHeaders,cacheSessionId,federation,options?.identity);client=created.client,isOAuth=created.isOAuthToken}let requestOptions={...options?.signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},maxRetries:0},disablePreferredStrictTools=!1,response;for(;;){options?.signal?.throwIfAborted();let built=buildParams(model,normalizedContext,isOAuth,options,disablePreferredStrictTools);built.providerThinkingLevel&&(output.providerThinkingLevel=built.providerThinkingLevel);let params=built.params,nextParams=await options?.onPayload?.(params,model);nextParams!==void 0&&(params={...nextParams,stream:!0});try{response=await retryProviderRequest(()=>client.beta.messages.create(params,requestOptions).asResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});break}catch(error){if(options?.signal?.aborted||disablePreferredStrictTools||!built.hasPreferredStrictTools||!(error instanceof Anthropic.APIError)||error.status!==400||error.type!=="invalid_request_error"||!isStrictToolLimitErrorMessage(error.message))throw error;disablePreferredStrictTools=!0,appendAssistantMessageDiagnostic(output,{type:"anthropic_strict_tools_fallback",timestamp:Date.now(),error:{message:error.message},details:{reason:"strict_tool_limits_exceeded"}})}}await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),stream2.push({type:"start",partial:output});let openBlocks=new Map,openBlock=anthropicIndex=>{let open=openBlocks.get(anthropicIndex);return open===void 0?void 0:{...open,block:output.content[open.contentIndex]}};for await(let event of iterateAnthropicEvents(response,options?.signal))if(await options?.onProviderStreamEvent?.(event,model),event.type==="message_start"){output.responseId=event.message.id;let transformations=event.message.input_transformations;Array.isArray(transformations)&&(inputTransformations=transformations);let responseModel=event.message.model;responseModel!==model.id&&(output.responseModel=responseModel);let fallbackCost=responseModel===model.id?void 0:model.compat?.allowedFallbackModels?.find(fallback=>fallback.provider===model.provider&&fallback.model===responseModel)?.cost;usageModel=fallbackCost?{...model,id:responseModel,cost:fallbackCost}:model,output.usage.input=event.message.usage.input_tokens||0,output.usage.output=event.message.usage.output_tokens||0,output.usage.cacheRead=event.message.usage.cache_read_input_tokens||0,output.usage.cacheWrite=event.message.usage.cache_creation_input_tokens||0,output.usage.cacheWrite1h=event.message.usage.cache_creation?.ephemeral_1h_input_tokens||0,output.usage.totalTokens=output.usage.input+output.usage.output+output.usage.cacheRead+output.usage.cacheWrite,calculateCost(usageModel,output.usage)}else if(event.type==="content_block_start"){if(event.content_block.type==="fallback"){if(output.content.length>0)throw new Error("Anthropic performed an unsupported mid-output model fallback");continue}event.content_block.type==="text"?(output.content.push({type:"text",text:event.content_block.text??""}),openBlocks.set(event.index,{contentIndex:output.content.length-1}),stream2.push({type:"text_start",contentIndex:output.content.length-1,partial:output})):event.content_block.type==="thinking"?(output.content.push({type:"thinking",thinking:event.content_block.thinking??"",thinkingSignature:event.content_block.signature??""}),openBlocks.set(event.index,{contentIndex:output.content.length-1}),stream2.push({type:"thinking_start",contentIndex:output.content.length-1,partial:output})):event.content_block.type==="redacted_thinking"?(output.content.push({type:"thinking",thinking:"[Reasoning redacted]",thinkingSignature:event.content_block.data,redacted:!0}),openBlocks.set(event.index,{contentIndex:output.content.length-1}),stream2.push({type:"thinking_start",contentIndex:output.content.length-1,partial:output})):event.content_block.type==="tool_use"&&(output.content.push({type:"toolCall",id:event.content_block.id,name:isOAuth?fromClaudeCodeName(event.content_block.name,currentTools):event.content_block.name,arguments:event.content_block.input??{}}),openBlocks.set(event.index,{contentIndex:output.content.length-1,arguments:new ToolCallArgumentsStream}),stream2.push({type:"toolcall_start",contentIndex:output.content.length-1,partial:output}))}else if(event.type==="content_block_delta"){let open=openBlock(event.index);event.delta.type==="text_delta"?open?.block.type==="text"&&(open.block.text+=event.delta.text,stream2.push({type:"text_delta",contentIndex:open.contentIndex,delta:event.delta.text,partial:output})):event.delta.type==="thinking_delta"?open?.block.type==="thinking"&&(open.block.thinking+=event.delta.thinking,stream2.push({type:"thinking_delta",contentIndex:open.contentIndex,delta:event.delta.thinking,partial:output})):event.delta.type==="input_json_delta"?open?.block.type==="toolCall"&&open.arguments!==void 0&&(open.block.arguments=open.arguments.append(event.delta.partial_json),stream2.push({type:"toolcall_delta",contentIndex:open.contentIndex,delta:event.delta.partial_json,partial:output})):event.delta.type==="signature_delta"&&open?.block.type==="thinking"&&(open.block.thinkingSignature=open.block.thinkingSignature||"",open.block.thinkingSignature+=event.delta.signature)}else if(event.type==="content_block_stop"){let open=openBlock(event.index);if(openBlocks.delete(event.index),open){let{block,contentIndex:index}=open;block.type==="text"?stream2.push({type:"text_end",contentIndex:index,content:block.text,partial:output}):block.type==="thinking"?stream2.push({type:"thinking_end",contentIndex:index,content:block.thinking,partial:output}):block.type==="toolCall"&&open.arguments!==void 0&&(Object.assign(block,open.arguments.finish()),stream2.push({type:"toolcall_end",contentIndex:index,toolCall:block,partial:output}))}}else if(event.type==="message_delta"){let transformations=event.input_transformations;if(Array.isArray(transformations)&&(inputTransformations=transformations),event.delta.stop_reason){output.rawStopReason=event.delta.stop_reason;let stopReasonResult=mapStopReason(event.delta.stop_reason,event.delta.stop_details);output.stopReason=stopReasonResult.stopReason,stopReasonResult.errorMessage&&(output.errorMessage=stopReasonResult.errorMessage)}if(event.usage){event.usage.input_tokens!=null&&(output.usage.input=event.usage.input_tokens),event.usage.output_tokens!=null&&(output.usage.output=event.usage.output_tokens),event.usage.cache_read_input_tokens!=null&&(output.usage.cacheRead=event.usage.cache_read_input_tokens),event.usage.cache_creation_input_tokens!=null&&(output.usage.cacheWrite=event.usage.cache_creation_input_tokens);let cacheCreation=event.usage.cache_creation;cacheCreation?.ephemeral_1h_input_tokens!=null&&(output.usage.cacheWrite1h=cacheCreation.ephemeral_1h_input_tokens);let thinkingTokens=event.usage.output_tokens_details?.thinking_tokens;thinkingTokens!=null&&(output.usage.reasoning=thinkingTokens)}output.usage.totalTokens=output.usage.input+output.usage.output+output.usage.cacheRead+output.usage.cacheWrite,calculateCost(usageModel,output.usage),isOpenRouterModel(model)&&event.usage&&applyOpenRouterReportedCost(output.usage,event.usage)}if(options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Anthropic stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason==="error")throw new Error(output.errorMessage||"An unknown error occurred");inputTransformations&&inputTransformations.length>0&&appendAssistantMessageDiagnostic(output,{type:"anthropic_input_transformations",timestamp:Date.now(),details:{transformations:inputTransformations.map(transformation=>({type:transformation.type??void 0,path:transformation.path??void 0,reason:transformation.reason??void 0}))}}),stream2.push({type:"done",reason:output.stopReason,message:output}),stream2.end()}catch(error){output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=error instanceof Error?error.message:JSON.stringify(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2};function mapThinkingLevelToEffort(model,level){let mapped=level?model.thinkingLevelMap?.[level]:void 0;if(typeof mapped=="string")return mapped;switch(level){case"minimal":case"low":return"low";case"medium":return"medium";case"high":return"high";default:return"high"}}var streamSimple=(model,context,options)=>{getAnthropicFederation(model,options?.apiKey,options?.headers,options?.env)||assertRequestAuth(model.provider,options?.apiKey,options?.headers);let base={...buildBaseOptions(model,context,options,options?.apiKey),toolChoice:options?.toolChoice};if(!options?.reasoning)return stream(model,context,{...base,thinkingEnabled:!1});if(model.compat?.forceAdaptiveThinking===!0){let effort=mapThinkingLevelToEffort(model,options.reasoning);return stream(model,context,{...base,thinkingEnabled:!0,effort})}let adjusted=adjustMaxTokensForThinking(base.maxTokens,model.maxTokens,options.reasoning,options.thinkingBudgets),maxTokens=clampMaxTokensToContext(model,context,adjusted.maxTokens);return stream(model,context,{...base,maxTokens,thinkingEnabled:!0,thinkingBudgetTokens:Math.min(adjusted.thinkingBudget,Math.max(0,maxTokens-1024))})};function isOAuthToken(apiKey){return apiKey.includes("sk-ant-oat")}function createClient(model,apiKey,optionsHeaders,fetch,dynamicHeaders,sessionId,federation,identity){if(model.provider==="github-copilot")return{client:new PiAnthropic({apiKey:null,authToken:apiKey??null,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:mergeHeaders(getIdentityHeaders(model,identity),{accept:"application/json","anthropic-dangerous-direct-browser-access":"true"},model.headers,dynamicHeaders,optionsHeaders)}),isOAuthToken:!1};if(apiKey&&isOAuthToken(apiKey))return{client:new PiAnthropic({apiKey:null,authToken:apiKey,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders:mergeHeaders({accept:"application/json","anthropic-dangerous-direct-browser-access":"true","user-agent":`claude-cli/${claudeCodeVersion}`,"x-app":"cli"},model.headers,optionsHeaders)}),isOAuthToken:!0};let compat=getAnthropicCompat(model),sessionAffinityHeaders={};if(sessionId&&compat.sendSessionAffinityHeaders){let header=compat.sessionAffinityFormat==="openrouter"?"x-session-id":"x-session-affinity";sessionAffinityHeaders[header]=sessionId}let defaultHeaders=mergeHeaders(getIdentityHeaders(model,identity),{accept:"application/json","anthropic-dangerous-direct-browser-access":"true"},sessionAffinityHeaders,model.headers,optionsHeaders);if(federation){let key=JSON.stringify([model.baseUrl,federation]);if(federationClient?.key!==key||federationClient.fetch!==fetch){let client2=new PiAnthropic({apiKey:null,authToken:null,config:federation,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch});federationClient={key,fetch,client:client2}}return{client:federationClient.client.withOptions({defaultHeaders}),isOAuthToken:!1}}return{client:new PiAnthropic({apiKey:apiKey??null,authToken:null,baseURL:model.baseUrl,dangerouslyAllowBrowser:!0,fetch,defaultHeaders}),isOAuthToken:!1}}function getBetaFeatures(model,context,isOAuthToken2,nativeToolChanges,options){let configuredFeatures;for(let headers of[model.headers,options?.headers])for(let[name,value]of Object.entries(headers??{}))name.toLowerCase()==="anthropic-beta"&&(configuredFeatures=value);if(configuredFeatures===null)return[];if(configuredFeatures!==void 0)return[...new Set(configuredFeatures.split(",").map(feature=>feature.trim()).filter(feature=>feature.length>0))];let features=[];return isOAuthToken2&&features.push("claude-code-20250219","oauth-2025-04-20"),shouldUseFineGrainedToolStreamingBeta(model,context)&&features.push(FINE_GRAINED_TOOL_STREAMING_BETA),model.reasoning&&options?.thinkingEnabled===!0&&(options.interleavedThinking??!0)&&model.compat?.forceAdaptiveThinking!==!0&&features.push(INTERLEAVED_THINKING_BETA),shouldUseServerSideFallbackBeta(model)&&features.push(SERVER_SIDE_FALLBACK_BETA),model.compat?.supportsMidConvoEffort===!0&&features.push(MID_CONVERSATION_OUTPUT_CONFIG_BETA,THINKING_BINDING_CONTROLS_BETA),nativeToolChanges&&features.push(INLINE_TOOLS_BETA),[...new Set(features)]}function buildParams(model,context,isOAuthToken2,options,disablePreferredStrictTools=!1){let{cacheControl}=getCacheControl(model,options?.cacheRetention,options?.env),compat=getAnthropicCompat(model),initialSystemMessage=getInitialSystemMessage(context.messages),initialSystemText=initialSystemMessage?getSystemMessageText(initialSystemMessage):"",transformedMessages=transformMessages(context.messages,model,normalizeToolCallId),conversationMessages=initialSystemMessage?transformedMessages.slice(1):transformedMessages,hasPreferredStrictTools=!1,convertToolDefinitions=(tools,toolCacheControl2)=>{let definitions=convertTools(tools,isOAuthToken2,compat.supportsEagerToolInputStreaming,compat.supportsStrictTools,toolCacheControl2,disablePreferredStrictTools);return definitions.some((definition,index)=>definition.strict===!0&&prefersJsonSchemaStrictSampling(tools[index]))&&(hasPreferredStrictTools=!0),definitions},initialTools=initialSystemMessage?.toolsAdded??[],nativeToolChanges=compat.supportsMidConvoSystemMessages&&compat.supportsMidConvoToolChanges&&initialTools.length>0,thinkingDisabled=model.reasoning&&options?.thinkingEnabled===!1&&model.thinkingLevelMap?.off!==null,effortMessages=model.compat?.supportsMidConvoEffort===!0&&!thinkingDisabled,converted=convertMessages(conversationMessages,isOAuthToken2,cacheControl,compat.allowEmptySignature,effortMessages?model.provider:void 0,nativeToolChanges?convertToolDefinitions:void 0),activeEffort=options?.effort??"high",betaFeatures=getBetaFeatures(model,context,isOAuthToken2,nativeToolChanges,options),params={model:model.id,messages:effortMessages?insertThinkingLevelMessages(converted,activeEffort):converted.messages,max_tokens:options?.maxTokens??model.maxTokens,stream:!0,...betaFeatures.length>0?{betas:betaFeatures}:{}};isOAuthToken2?(params.system=[{type:"text",text:"You are Claude Code, Anthropic's official CLI for Claude.",...cacheControl?{cache_control:cacheControl}:{}}],initialSystemText&&params.system.push({type:"text",text:sanitizeSurrogates(initialSystemText),...cacheControl?{cache_control:cacheControl}:{}})):initialSystemText&&(params.system=[{type:"text",text:sanitizeSurrogates(initialSystemText),...cacheControl?{cache_control:cacheControl}:{}}]),options?.temperature!==void 0&&!options?.thinkingEnabled&&model.compat?.supportsMidConvoEffort!==!0&&compat.supportsTemperature&&(params.temperature=options.temperature);let toolCacheControl=compat.supportsCacheControlOnTools?cacheControl:void 0;if(nativeToolChanges)params.tools=[...convertToolDefinitions(initialTools,toolCacheControl),DEFERRED_TOOL_PLACEHOLDER];else{let tools=getCurrentTools(context.messages);tools.length>0&&(params.tools=convertToolDefinitions(tools,toolCacheControl))}if(thinkingDisabled)params.thinking={type:"disabled"};else if(effortMessages)params.thinking={type:"adaptive",display:options?.thinkingDisplay??"summarized",block_binding:{prefix_mismatch_behavior:"drop_block"}},params.output_config={effort:"low"};else if(model.reasoning&&options?.thinkingEnabled){let display=options.thinkingDisplay??"summarized";model.compat?.forceAdaptiveThinking===!0?(params.thinking={type:"adaptive",display},options.effort&&(params.output_config={effort:options.effort})):params.thinking={type:"enabled",budget_tokens:options.thinkingBudgetTokens||1024,display}}if(options?.metadata){let userId=options.metadata.user_id;typeof userId=="string"&&(params.metadata={user_id:userId})}options?.toolChoice&&(typeof options.toolChoice=="string"?params.tool_choice={type:options.toolChoice}:params.tool_choice=options.toolChoice);let allowedFallbackModels=model.compat?.allowedFallbackModels;return allowedFallbackModels&&allowedFallbackModels.length>0&&(params.fallbacks=allowedFallbackModels.map(fallback=>({model:fallback.model}))),{params,hasPreferredStrictTools,providerThinkingLevel:effortMessages?activeEffort:void 0}}function normalizeToolCallId(id){return id.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,64)}function convertToolResult(msg,content=msg.content){return{type:"tool_result",tool_use_id:msg.toolCallId,content:convertContentBlocks(content),is_error:msg.isError}}function convertMessages(transformedMessages,isOAuthToken2,cacheControl,allowEmptySignature=!1,managedProvider,convertToolDefinitions){let params=[],assistantLevels=new Map,pendingSystemMessages=[],flushPendingSystemMessages=()=>{params.push(...pendingSystemMessages),pendingSystemMessages.length=0};for(let i=0;i<transformedMessages.length;i++){let msg=transformedMessages[i];if(msg.role==="system"){let text=renderSystemMessageUpdate(msg),blocks=[];if(text.length>0&&blocks.push({type:"text",text:sanitizeSurrogates(text)}),convertToolDefinitions){let added=msg.toolsAdded??[],redefined=new Set(added.map(tool=>tool.name));for(let tool of msg.toolsRemoved??[])redefined.has(tool.name)||blocks.push({type:"tool_removal",tool:{type:"tool_reference",name:isOAuthToken2?toClaudeCodeName(tool.name):tool.name}});for(let definition of convertToolDefinitions(added))blocks.push({type:"tool_addition",tool:{type:"tool_definition",definition}})}blocks.length>0&&pendingSystemMessages.push({role:"system",content:blocks})}else if(msg.role==="user")if(typeof msg.content=="string")msg.content.trim().length>0&&params.push({role:"user",content:sanitizeSurrogates(msg.content)});else{let filteredBlocks=msg.content.map(item=>item.type==="text"?{type:"text",text:sanitizeSurrogates(item.text)}:convertImageBlock(item)).filter(b=>b.type==="text"?b.text.trim().length>0:!0);if(filteredBlocks.length===0)continue;params.push({role:"user",content:filteredBlocks})}else if(msg.role==="assistant"){let blocks=[];for(let block of msg.content)if(block.type==="text"){if(block.text.trim().length===0)continue;blocks.push({type:"text",text:sanitizeSurrogates(block.text)})}else if(block.type==="thinking"){if(block.redacted){blocks.push({type:"redacted_thinking",data:block.thinkingSignature});continue}let thinkingSignature=block.thinkingSignature,hasThinkingSignature=!!thinkingSignature&&thinkingSignature.trim().length>0;if(block.thinking.trim().length===0&&!hasThinkingSignature)continue;hasThinkingSignature?blocks.push({type:"thinking",thinking:sanitizeSurrogates(block.thinking),signature:thinkingSignature}):blocks.push(allowEmptySignature?{type:"thinking",thinking:sanitizeSurrogates(block.thinking),signature:""}:{type:"text",text:sanitizeSurrogates(block.thinking)})}else block.type==="toolCall"&&blocks.push({type:"tool_use",id:block.id,name:isOAuthToken2?toClaudeCodeName(block.name):block.name,input:block.arguments??{}});if(blocks.length===0)continue;flushPendingSystemMessages();let messageIndex=params.length;params.push({role:"assistant",content:blocks}),managedProvider!==void 0&&msg.api==="anthropic-messages"&&msg.provider===managedProvider&&isAnthropicEffort(msg.providerThinkingLevel)&&assistantLevels.set(messageIndex,msg.providerThinkingLevel)}else if(msg.role==="toolResult"){let toolResults=[],errorImages=[],j=i;for(;j<transformedMessages.length&&transformedMessages[j].role==="toolResult";){let toolMsg=transformedMessages[j],split=splitErrorToolResultImages(toolMsg);toolResults.push(convertToolResult(toolMsg,split?.content)),split&&errorImages.push({type:"text",text:split.caption},...split.images.map(convertImageBlock)),j++}i=j-1,params.push({role:"user",content:[...toolResults,...errorImages]})}}if(flushPendingSystemMessages(),cacheControl&&params.length>0){let lastMessage=params[params.length-1];if(lastMessage.role==="user"||lastMessage.role==="system")if(Array.isArray(lastMessage.content)){let lastBlock=lastMessage.content[lastMessage.content.length-1];lastBlock&&(lastBlock.type==="text"||lastBlock.type==="image"||lastBlock.type==="tool_result"||lastBlock.type==="tool_addition"||lastBlock.type==="tool_removal")&&(lastBlock.cache_control=cacheControl)}else typeof lastMessage.content=="string"&&(lastMessage.content=[{type:"text",text:lastMessage.content,cache_control:cacheControl}])}return{messages:params,assistantLevels}}function isAnthropicEffort(value){return value==="low"||value==="medium"||value==="high"||value==="xhigh"||value==="max"}function insertThinkingLevelMessages(converted,activeEffort){let messages=[];for(let index=0;index<converted.messages.length;index++){let historicalEffort=converted.assistantLevels.get(index);historicalEffort!==void 0&&messages.push({role:"system",content:[],output_config:{effort:historicalEffort}}),messages.push(converted.messages[index])}return messages.push({role:"system",content:[],output_config:{effort:activeEffort}}),messages}function shouldUseFineGrainedToolStreamingBeta(model,context){return getCurrentTools(context.messages).length>0&&!getAnthropicCompat(model).supportsEagerToolInputStreaming}var ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS=new Set(["minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","maxItems","uniqueItems","minContains","maxContains","minProperties","maxProperties"]),ANTHROPIC_STRICT_STRING_FORMATS=new Set(["date-time","time","date","duration","email","hostname","uri","ipv4","ipv6","uuid"]),isAnthropicStrictUnsupportedKeyword=(key,value)=>ANTHROPIC_STRICT_UNSUPPORTED_KEYWORDS.has(key)?!0:key==="minItems"?value!==0&&value!==1:key==="format"?typeof value!="string"||!ANTHROPIC_STRICT_STRING_FORMATS.has(value):!1;function convertTools(tools,isOAuthToken2,supportsEagerToolInputStreaming,supportsStrictTools,cacheControl,disablePreferredStrictTools=!1){return tools?tools.map((tool,index)=>{let strict=disablePreferredStrictTools&&prefersJsonSchemaStrictSampling(tool)?void 0:resolveJsonSchemaStrictSampling(tool,supportsStrictTools,isAnthropicStrictUnsupportedKeyword),parameters=getJsonSchemaToolParameters(tool,strict),schema=parameters,legacyInputSchema={type:"object",properties:schema.properties??{},required:schema.required??[]},inputSchema=strict===!0?{...parameters,...legacyInputSchema}:legacyInputSchema;return{name:isOAuthToken2?toClaudeCodeName(tool.name):tool.name,description:tool.description,...supportsEagerToolInputStreaming?{eager_input_streaming:!0}:{},...strict===!0?{strict:!0}:{},input_schema:inputSchema,...cacheControl&&index===tools.length-1?{cache_control:cacheControl}:{}}}):[]}function mapStopReason(reason,stopDetails){switch(reason){case"end_turn":return{stopReason:"stop"};case"max_tokens":return{stopReason:"length"};case"tool_use":return{stopReason:"toolUse"};case"refusal":return{stopReason:"error",errorMessage:stopDetails?.explanation||"The model refused to complete the request"};case"pause_turn":return{stopReason:"stop"};case"stop_sequence":return{stopReason:"stop"};case"sensitive":return{stopReason:"error",errorMessage:"Provider stopped with: sensitive"};default:throw new Error(`Unhandled stop reason: ${reason}`)}}export{stream,streamSimple};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{convertResponsesMessages,convertResponsesTools,getResponsesToolSupport,processResponsesStream}from"./chunk-3UW3IQIY.js";import{resolveAzureConfig,resolveDeploymentName}from"./chunk-TMTOQ7H7.js";import{clampOpenAIPromptCacheKey}from"./chunk-PRRNXB7S.js";import{AzureOpenAI}from"./chunk-A3Y7H47A.js";import"./chunk-PJACZCIR.js";import{formatProviderError,normalizeProviderError}from"./chunk-OV4EHN3Q.js";import{retryProviderRequest}from"./chunk-PMRZO46Y.js";import{buildBaseOptions,createGrammarToolInputProperties,resolveSamplingParams}from"./chunk-4RKLODCT.js";import"./chunk-L2ZPNLYD.js";import{headersToRecord}from"./chunk-UTB4DTYQ.js";import"./chunk-7DDKXS2Q.js";import"./chunk-FFMDRXC4.js";import{clampThinkingLevel,getDeclaredTools,resolveTranscript,resolveTranscriptTools}from"./chunk-G23G7KNC.js";import{AssistantMessageEventStream}from"./chunk-LPXNMA2W.js";import{getIdentityHeaders}from"./chunk-GO33PKBT.js";import"./chunk-JXWJOIH4.js";var AZURE_TOOL_CALL_PROVIDERS=new Set(["openai","openai-codex","opencode","azure"]),OPENAI_RESPONSES_MIN_OUTPUT_TOKENS=16;function formatAzureOpenAIError(error){return formatProviderError(normalizeProviderError(error),"Azure OpenAI API error")}var stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=resolveTranscript(context,model.compat?.supportsMidConvoSystemMessages);return(async()=>{let deploymentName=resolveDeploymentName(model,options),output={role:"assistant",content:[],api:"azure-openai-responses",provider:model.provider,model:model.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let client=createClient(model,apiKey,options),grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages),model.compat?.supportsOpenAIGrammarTools??!1),params=buildParams(model,normalizedContext,options,deploymentName,grammarToolInputProperties),nextParams=await options?.onPayload?.(params,model);nextParams!==void 0&&(params=nextParams);let requestOptions={...options?.signal?{signal:options.signal}:{},...options?.timeoutMs!==void 0?{timeout:options.timeoutMs}:{},maxRetries:0},{data:openaiStream,response}=await retryProviderRequest(()=>client.responses.create(params,requestOptions).withResponse(),{maxRetries:options?.maxRetries,maxRetryDelayMs:options?.maxRetryDelayMs,signal:options?.signal});if(await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),stream2.push({type:"start",partial:output}),await processResponsesStream(openaiStream,output,stream2,model,{onProviderStreamEvent:options?.onProviderStreamEvent,grammarToolInputProperties}),options?.signal?.aborted)throw new Error("Request was aborted");if(output.stopReason==="pending")throw new Error("Azure OpenAI Responses stream ended without a stop reason");if(output.stopReason==="aborted"||output.stopReason==="error")throw new Error(output.errorMessage||"An unknown error occurred");stream2.push({type:"done",reason:output.stopReason,message:output}),stream2.end()}catch(error){output.stopReason=options?.signal?.aborted?"aborted":"error",output.errorMessage=formatAzureOpenAIError(error),stream2.push({type:"error",reason:output.stopReason,error:output}),stream2.end()}})(),stream2},streamSimple=(model,context,options)=>{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let base={...buildBaseOptions(model,context,options,apiKey),toolChoice:options?.toolChoice},clampedReasoning=options?.reasoning?clampThinkingLevel(model,options.reasoning):void 0;return stream(model,context,{...base,reasoningEffort:clampedReasoning==="off"?void 0:clampedReasoning})};function createClient(model,apiKey,options){let headers={...getIdentityHeaders(model,options?.identity),...model.headers};options?.headers&&Object.assign(headers,options.headers);let{baseUrl,apiVersion}=resolveAzureConfig(model,options);return new AzureOpenAI({apiKey,apiVersion,dangerouslyAllowBrowser:!0,fetch:options?.fetch,defaultHeaders:headers,baseURL:baseUrl})}function buildParams(model,context,options,deploymentName,grammarToolInputProperties=createGrammarToolInputProperties(getDeclaredTools(context.messages),model.compat?.supportsOpenAIGrammarTools??!1)){let supportsAdditionalTools=model.compat?.supportsAdditionalTools??!1,supportsToolSearch=model.compat?.supportsToolSearch??!1,transcriptTools=resolveTranscriptTools(context.messages,getResponsesToolSupport({supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools,supportsToolSearch})),messages=convertResponsesMessages(model,context,AZURE_TOOL_CALL_PROVIDERS,{grammarToolInputProperties,supportsMidConvoSystemMessages:model.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools,supportsToolSearch,toolOptions:{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1}}),params={model:deploymentName,input:messages,stream:!0,prompt_cache_key:clampOpenAIPromptCacheKey(options?.sessionId),store:!1};options?.maxTokens&&(params.max_output_tokens=Math.max(options.maxTokens,OPENAI_RESPONSES_MIN_OUTPUT_TOKENS)),options?.temperature!==void 0&&(params.temperature=options?.temperature),transcriptTools.requestTools.length>0&&(params.tools=convertResponsesTools(transcriptTools.requestTools,{supportsStrictMode:model.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:model.compat?.supportsOpenAIGrammarTools??!1})),options?.toolChoice!==void 0&&(params.tool_choice=options.toolChoice);let reasoningEffort=options?.reasoningEffort??(options?.reasoningSummary?"medium":void 0);if(model.reasoning)if(reasoningEffort){let effort=options?.reasoningEffort?model.thinkingLevelMap?.[options.reasoningEffort]??options.reasoningEffort:reasoningEffort;params.reasoning={effort,summary:options?.reasoningSummary||"auto"},params.include=["reasoning.encrypted_content"]}else model.thinkingLevelMap?.off!==null&&(params.reasoning={effort:model.thinkingLevelMap?.off??"none"});let samplingParams=resolveSamplingParams(model,reasoningEffort??"off",options?.samplingParams);return samplingParams&&Object.assign(params,samplingParams),params}export{stream,streamSimple};