@vib-rato/ai 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (525) hide show
  1. package/CHANGELOG.md +3354 -0
  2. package/README.md +1194 -0
  3. package/dist/types/adapter-internals/provider-safety-stop.d.ts +45 -0
  4. package/dist/types/api-registry.d.ts +30 -0
  5. package/dist/types/auth-broker/client.d.ts +80 -0
  6. package/dist/types/auth-broker/index.d.ts +5 -0
  7. package/dist/types/auth-broker/redact.d.ts +7 -0
  8. package/dist/types/auth-broker/refresher.d.ts +25 -0
  9. package/dist/types/auth-broker/remote-store.d.ts +153 -0
  10. package/dist/types/auth-broker/server.d.ts +32 -0
  11. package/dist/types/auth-broker/types.d.ts +132 -0
  12. package/dist/types/auth-broker/wire-schemas.d.ts +555 -0
  13. package/dist/types/auth-gateway/http.d.ts +40 -0
  14. package/dist/types/auth-gateway/index.d.ts +3 -0
  15. package/dist/types/auth-gateway/server.d.ts +70 -0
  16. package/dist/types/auth-gateway/types.d.ts +129 -0
  17. package/dist/types/auth-storage.d.ts +1074 -0
  18. package/dist/types/cli.d.ts +2 -0
  19. package/dist/types/codex-tools.d.ts +4 -0
  20. package/dist/types/context-cap-policy.d.ts +68 -0
  21. package/dist/types/core.d.ts +35 -0
  22. package/dist/types/index.d.ts +55 -0
  23. package/dist/types/model-cache.d.ts +24 -0
  24. package/dist/types/model-manager.d.ts +77 -0
  25. package/dist/types/model-pricing.d.ts +3 -0
  26. package/dist/types/model-retirements.d.ts +6 -0
  27. package/dist/types/model-thinking.d.ts +100 -0
  28. package/dist/types/models.d.ts +21 -0
  29. package/dist/types/openai-completions-compat.d.ts +34 -0
  30. package/dist/types/provider-details.d.ts +24 -0
  31. package/dist/types/provider-models/bundled-references.d.ts +4 -0
  32. package/dist/types/provider-models/descriptors.d.ts +48 -0
  33. package/dist/types/provider-models/google.d.ts +20 -0
  34. package/dist/types/provider-models/index.d.ts +5 -0
  35. package/dist/types/provider-models/ollama.d.ts +7 -0
  36. package/dist/types/provider-models/openai-compat.d.ts +293 -0
  37. package/dist/types/provider-models/special.d.ts +29 -0
  38. package/dist/types/providers/amazon-bedrock.d.ts +60 -0
  39. package/dist/types/providers/anthropic-messages-server-schema.d.ts +450 -0
  40. package/dist/types/providers/anthropic-messages-server.d.ts +17 -0
  41. package/dist/types/providers/anthropic.d.ts +280 -0
  42. package/dist/types/providers/aws-credential-config.d.ts +19 -0
  43. package/dist/types/providers/aws-credentials.d.ts +43 -0
  44. package/dist/types/providers/aws-eventstream.d.ts +38 -0
  45. package/dist/types/providers/aws-sigv4.d.ts +55 -0
  46. package/dist/types/providers/azure-openai-responses.d.ts +22 -0
  47. package/dist/types/providers/composer-discipline.d.ts +32 -0
  48. package/dist/types/providers/cursor/client-version.d.ts +10 -0
  49. package/dist/types/providers/cursor/exec-modern.d.ts +98 -0
  50. package/dist/types/providers/cursor/gen/agent_pb.d.ts +16769 -0
  51. package/dist/types/providers/cursor-pi-args.d.ts +119 -0
  52. package/dist/types/providers/cursor.d.ts +72 -0
  53. package/dist/types/providers/dashscope-token-plan-headers.d.ts +57 -0
  54. package/dist/types/providers/error-message.d.ts +27 -0
  55. package/dist/types/providers/github-copilot-headers.d.ts +40 -0
  56. package/dist/types/providers/gitlab-duo.d.ts +27 -0
  57. package/dist/types/providers/google-auth.d.ts +26 -0
  58. package/dist/types/providers/google-gemini-cli.d.ts +75 -0
  59. package/dist/types/providers/google-gemini-headers.d.ts +43 -0
  60. package/dist/types/providers/google-shared.d.ts +183 -0
  61. package/dist/types/providers/google-types.d.ts +138 -0
  62. package/dist/types/providers/google-vertex.d.ts +11 -0
  63. package/dist/types/providers/google.d.ts +4 -0
  64. package/dist/types/providers/grammar.d.ts +1 -0
  65. package/dist/types/providers/kimi.d.ts +27 -0
  66. package/dist/types/providers/kiro-api-key.d.ts +50 -0
  67. package/dist/types/providers/kiro-codewhisperer.d.ts +11 -0
  68. package/dist/types/providers/mock.d.ts +189 -0
  69. package/dist/types/providers/ollama.d.ts +41 -0
  70. package/dist/types/providers/openai-anthropic-shim.d.ts +31 -0
  71. package/dist/types/providers/openai-bounded-rate-limits.d.ts +3 -0
  72. package/dist/types/providers/openai-chat-server-schema.d.ts +1733 -0
  73. package/dist/types/providers/openai-chat-server.d.ts +16 -0
  74. package/dist/types/providers/openai-codex/constants.d.ts +26 -0
  75. package/dist/types/providers/openai-codex/request-transformer.d.ts +50 -0
  76. package/dist/types/providers/openai-codex/response-handler.d.ts +18 -0
  77. package/dist/types/providers/openai-codex-responses.d.ts +71 -0
  78. package/dist/types/providers/openai-completions-compat.d.ts +6 -0
  79. package/dist/types/providers/openai-completions.d.ts +35 -0
  80. package/dist/types/providers/openai-opencodex-responses.d.ts +10 -0
  81. package/dist/types/providers/openai-request-transform.d.ts +4 -0
  82. package/dist/types/providers/openai-responses-server-schema.d.ts +392 -0
  83. package/dist/types/providers/openai-responses-server.d.ts +17 -0
  84. package/dist/types/providers/openai-responses-shared.d.ts +106 -0
  85. package/dist/types/providers/openai-responses.d.ts +37 -0
  86. package/dist/types/providers/pi-native-client.d.ts +29 -0
  87. package/dist/types/providers/pi-native-server.d.ts +60 -0
  88. package/dist/types/providers/register-builtins.d.ts +59 -0
  89. package/dist/types/providers/synthetic.d.ts +26 -0
  90. package/dist/types/providers/transform-messages.d.ts +33 -0
  91. package/dist/types/providers/vision-guard.d.ts +8 -0
  92. package/dist/types/rate-limit-utils.d.ts +19 -0
  93. package/dist/types/stream.d.ts +45 -0
  94. package/dist/types/types.d.ts +1073 -0
  95. package/dist/types/usage/claude.d.ts +3 -0
  96. package/dist/types/usage/gemini.d.ts +2 -0
  97. package/dist/types/usage/github-copilot.d.ts +7 -0
  98. package/dist/types/usage/google-antigravity.d.ts +2 -0
  99. package/dist/types/usage/grok-cli.d.ts +17 -0
  100. package/dist/types/usage/kimi.d.ts +4 -0
  101. package/dist/types/usage/minimax-code.d.ts +2 -0
  102. package/dist/types/usage/openai-codex.d.ts +3 -0
  103. package/dist/types/usage/shared.d.ts +1 -0
  104. package/dist/types/usage/zai.d.ts +2 -0
  105. package/dist/types/usage.d.ts +264 -0
  106. package/dist/types/utils/abort.d.ts +19 -0
  107. package/dist/types/utils/anthropic-auth.d.ts +39 -0
  108. package/dist/types/utils/block-symbols.d.ts +6 -0
  109. package/dist/types/utils/discovery/antigravity.d.ts +67 -0
  110. package/dist/types/utils/discovery/codex.d.ts +38 -0
  111. package/dist/types/utils/discovery/cursor.d.ts +49 -0
  112. package/dist/types/utils/discovery/gemini.d.ts +25 -0
  113. package/dist/types/utils/discovery/index.d.ts +4 -0
  114. package/dist/types/utils/discovery/openai-compatible.d.ts +81 -0
  115. package/dist/types/utils/event-stream.d.ts +41 -0
  116. package/dist/types/utils/fallback-transport.d.ts +110 -0
  117. package/dist/types/utils/fireworks-model-id.d.ts +10 -0
  118. package/dist/types/utils/foundry.d.ts +11 -0
  119. package/dist/types/utils/h2-fetch.d.ts +22 -0
  120. package/dist/types/utils/http-inspector.d.ts +59 -0
  121. package/dist/types/utils/idle-iterator.d.ts +122 -0
  122. package/dist/types/utils/json-parse.d.ts +98 -0
  123. package/dist/types/utils/oauth/alibaba-token-plan.d.ts +19 -0
  124. package/dist/types/utils/oauth/anthropic.d.ts +41 -0
  125. package/dist/types/utils/oauth/api-key-login.d.ts +38 -0
  126. package/dist/types/utils/oauth/api-key-validation.d.ts +39 -0
  127. package/dist/types/utils/oauth/bizrouter.d.ts +1 -0
  128. package/dist/types/utils/oauth/callback-server.d.ts +80 -0
  129. package/dist/types/utils/oauth/cerebras.d.ts +1 -0
  130. package/dist/types/utils/oauth/cloudflare-ai-gateway.d.ts +18 -0
  131. package/dist/types/utils/oauth/commandcode.d.ts +1 -0
  132. package/dist/types/utils/oauth/cursor.d.ts +15 -0
  133. package/dist/types/utils/oauth/deepinfra.d.ts +1 -0
  134. package/dist/types/utils/oauth/deepseek.d.ts +10 -0
  135. package/dist/types/utils/oauth/firepass.d.ts +1 -0
  136. package/dist/types/utils/oauth/fireworks.d.ts +1 -0
  137. package/dist/types/utils/oauth/fugu.d.ts +1 -0
  138. package/dist/types/utils/oauth/github-copilot.d.ts +38 -0
  139. package/dist/types/utils/oauth/gitlab-duo.d.ts +3 -0
  140. package/dist/types/utils/oauth/glm-zcode.d.ts +71 -0
  141. package/dist/types/utils/oauth/google-antigravity.d.ts +11 -0
  142. package/dist/types/utils/oauth/google-gemini-cli.d.ts +10 -0
  143. package/dist/types/utils/oauth/google-oauth-shared.d.ts +28 -0
  144. package/dist/types/utils/oauth/huggingface.d.ts +19 -0
  145. package/dist/types/utils/oauth/index.d.ts +39 -0
  146. package/dist/types/utils/oauth/kagi.d.ts +17 -0
  147. package/dist/types/utils/oauth/kilo.d.ts +5 -0
  148. package/dist/types/utils/oauth/kimi.d.ts +17 -0
  149. package/dist/types/utils/oauth/kiro.d.ts +71 -0
  150. package/dist/types/utils/oauth/litellm.d.ts +18 -0
  151. package/dist/types/utils/oauth/lm-studio.d.ts +17 -0
  152. package/dist/types/utils/oauth/mara.d.ts +1 -0
  153. package/dist/types/utils/oauth/minimax-code.d.ts +28 -0
  154. package/dist/types/utils/oauth/moonshot.d.ts +1 -0
  155. package/dist/types/utils/oauth/nanogpt.d.ts +1 -0
  156. package/dist/types/utils/oauth/nvidia.d.ts +18 -0
  157. package/dist/types/utils/oauth/ollama-cloud.d.ts +2 -0
  158. package/dist/types/utils/oauth/ollama.d.ts +18 -0
  159. package/dist/types/utils/oauth/openai-codex.d.ts +21 -0
  160. package/dist/types/utils/oauth/opencode.d.ts +18 -0
  161. package/dist/types/utils/oauth/opengateway.d.ts +1 -0
  162. package/dist/types/utils/oauth/openrouter.d.ts +1 -0
  163. package/dist/types/utils/oauth/parallel.d.ts +17 -0
  164. package/dist/types/utils/oauth/perplexity.d.ts +4 -0
  165. package/dist/types/utils/oauth/pkce.d.ts +8 -0
  166. package/dist/types/utils/oauth/qianfan.d.ts +17 -0
  167. package/dist/types/utils/oauth/qwen-portal.d.ts +19 -0
  168. package/dist/types/utils/oauth/sglang.d.ts +16 -0
  169. package/dist/types/utils/oauth/synthetic.d.ts +1 -0
  170. package/dist/types/utils/oauth/tavily.d.ts +17 -0
  171. package/dist/types/utils/oauth/together.d.ts +1 -0
  172. package/dist/types/utils/oauth/types.d.ts +56 -0
  173. package/dist/types/utils/oauth/venice.d.ts +18 -0
  174. package/dist/types/utils/oauth/vercel-ai-gateway.d.ts +18 -0
  175. package/dist/types/utils/oauth/vllm.d.ts +16 -0
  176. package/dist/types/utils/oauth/xai.d.ts +30 -0
  177. package/dist/types/utils/oauth/xiaomi.d.ts +25 -0
  178. package/dist/types/utils/oauth/zai.d.ts +18 -0
  179. package/dist/types/utils/oauth/zenmux.d.ts +1 -0
  180. package/dist/types/utils/overflow.d.ts +14 -0
  181. package/dist/types/utils/parse-bind.d.ts +26 -0
  182. package/dist/types/utils/provider-response.d.ts +6 -0
  183. package/dist/types/utils/provider-safety-stop.d.ts +8 -0
  184. package/dist/types/utils/proxy.d.ts +7 -0
  185. package/dist/types/utils/retry-after.d.ts +3 -0
  186. package/dist/types/utils/retry-budget.d.ts +1 -0
  187. package/dist/types/utils/retry.d.ts +29 -0
  188. package/dist/types/utils/schema/adapt.d.ts +24 -0
  189. package/dist/types/utils/schema/compatibility.d.ts +30 -0
  190. package/dist/types/utils/schema/dereference.d.ts +11 -0
  191. package/dist/types/utils/schema/draft.d.ts +10 -0
  192. package/dist/types/utils/schema/equality.d.ts +4 -0
  193. package/dist/types/utils/schema/fields.d.ts +49 -0
  194. package/dist/types/utils/schema/index.d.ts +14 -0
  195. package/dist/types/utils/schema/json-schema-validator.d.ts +12 -0
  196. package/dist/types/utils/schema/meta-validator.d.ts +2 -0
  197. package/dist/types/utils/schema/normalize.d.ts +93 -0
  198. package/dist/types/utils/schema/root-combinator.d.ts +12 -0
  199. package/dist/types/utils/schema/spill.d.ts +8 -0
  200. package/dist/types/utils/schema/stamps.d.ts +25 -0
  201. package/dist/types/utils/schema/types.d.ts +4 -0
  202. package/dist/types/utils/schema/wire.d.ts +54 -0
  203. package/dist/types/utils/schema/zod-decontaminate.d.ts +31 -0
  204. package/dist/types/utils/sse-debug.d.ts +10 -0
  205. package/dist/types/utils/tool-call-healing.d.ts +80 -0
  206. package/dist/types/utils/tool-choice-capability.d.ts +57 -0
  207. package/dist/types/utils/tool-choice.d.ts +50 -0
  208. package/dist/types/utils/validation.d.ts +17 -0
  209. package/dist/types/utils.d.ts +117 -0
  210. package/package.json +152 -0
  211. package/src/adapter-internals/provider-safety-stop.d.ts +45 -0
  212. package/src/adapter-internals/provider-safety-stop.ts +156 -0
  213. package/src/api-registry.d.ts +30 -0
  214. package/src/api-registry.ts +96 -0
  215. package/src/auth-broker/client.ts +444 -0
  216. package/src/auth-broker/index.ts +5 -0
  217. package/src/auth-broker/redact.ts +39 -0
  218. package/src/auth-broker/refresher.ts +130 -0
  219. package/src/auth-broker/remote-store.ts +1576 -0
  220. package/src/auth-broker/server.ts +764 -0
  221. package/src/auth-broker/types.ts +164 -0
  222. package/src/auth-broker/wire-schemas.ts +261 -0
  223. package/src/auth-gateway/http.ts +198 -0
  224. package/src/auth-gateway/index.ts +3 -0
  225. package/src/auth-gateway/server.ts +1315 -0
  226. package/src/auth-gateway/types.ts +160 -0
  227. package/src/auth-storage.ts +7312 -0
  228. package/src/cli.ts +269 -0
  229. package/src/codex-tools.d.ts +4 -0
  230. package/src/codex-tools.ts +24 -0
  231. package/src/context-cap-policy.d.ts +68 -0
  232. package/src/context-cap-policy.ts +123 -0
  233. package/src/core.ts +44 -0
  234. package/src/index.ts +61 -0
  235. package/src/model-cache.ts +236 -0
  236. package/src/model-manager.ts +744 -0
  237. package/src/model-pricing.d.ts +3 -0
  238. package/src/model-pricing.ts +68 -0
  239. package/src/model-retirements.d.ts +6 -0
  240. package/src/model-retirements.ts +19 -0
  241. package/src/model-thinking.d.ts +100 -0
  242. package/src/model-thinking.ts +1054 -0
  243. package/src/models.d.ts +21 -0
  244. package/src/models.json +94672 -0
  245. package/src/models.json.d.ts +9 -0
  246. package/src/models.ts +126 -0
  247. package/src/openai-completions-compat.d.ts +34 -0
  248. package/src/openai-completions-compat.ts +383 -0
  249. package/src/prompts/composer-bash-policy-recovery.md +1 -0
  250. package/src/prompts/cursor-composer-bash-policy-recovery.md +1 -0
  251. package/src/prompts/cursor-composer-edit-discipline.md +7 -0
  252. package/src/prompts/turn-aborted-guidance.md +4 -0
  253. package/src/provider-details.ts +90 -0
  254. package/src/provider-models/bundled-references.ts +38 -0
  255. package/src/provider-models/descriptors.ts +392 -0
  256. package/src/provider-models/google.ts +92 -0
  257. package/src/provider-models/index.ts +5 -0
  258. package/src/provider-models/ollama.ts +159 -0
  259. package/src/provider-models/openai-compat.ts +2920 -0
  260. package/src/provider-models/special.ts +185 -0
  261. package/src/providers/amazon-bedrock.d.ts +60 -0
  262. package/src/providers/amazon-bedrock.ts +939 -0
  263. package/src/providers/anthropic-messages-server-schema.ts +229 -0
  264. package/src/providers/anthropic-messages-server.ts +839 -0
  265. package/src/providers/anthropic.d.ts +280 -0
  266. package/src/providers/anthropic.ts +4421 -0
  267. package/src/providers/aws-credential-config.d.ts +19 -0
  268. package/src/providers/aws-credential-config.ts +179 -0
  269. package/src/providers/aws-credentials.d.ts +43 -0
  270. package/src/providers/aws-credentials.ts +457 -0
  271. package/src/providers/aws-eventstream.d.ts +38 -0
  272. package/src/providers/aws-eventstream.ts +185 -0
  273. package/src/providers/aws-sigv4.d.ts +55 -0
  274. package/src/providers/aws-sigv4.ts +218 -0
  275. package/src/providers/azure-openai-responses.d.ts +22 -0
  276. package/src/providers/azure-openai-responses.ts +447 -0
  277. package/src/providers/composer-discipline.d.ts +32 -0
  278. package/src/providers/composer-discipline.ts +95 -0
  279. package/src/providers/cursor/client-version.d.ts +10 -0
  280. package/src/providers/cursor/client-version.ts +10 -0
  281. package/src/providers/cursor/exec-modern.d.ts +98 -0
  282. package/src/providers/cursor/exec-modern.ts +497 -0
  283. package/src/providers/cursor/gen/agent_pb.d.ts +16769 -0
  284. package/src/providers/cursor/gen/agent_pb.ts +19780 -0
  285. package/src/providers/cursor/proto/agent.proto +4533 -0
  286. package/src/providers/cursor/proto/buf.gen.yaml +6 -0
  287. package/src/providers/cursor/proto/buf.yaml +17 -0
  288. package/src/providers/cursor-pi-args.d.ts +119 -0
  289. package/src/providers/cursor-pi-args.ts +187 -0
  290. package/src/providers/cursor.d.ts +72 -0
  291. package/src/providers/cursor.ts +3396 -0
  292. package/src/providers/dashscope-token-plan-headers.d.ts +57 -0
  293. package/src/providers/dashscope-token-plan-headers.ts +84 -0
  294. package/src/providers/error-message.d.ts +27 -0
  295. package/src/providers/error-message.ts +21 -0
  296. package/src/providers/github-copilot-headers.d.ts +40 -0
  297. package/src/providers/github-copilot-headers.ts +140 -0
  298. package/src/providers/gitlab-duo.d.ts +27 -0
  299. package/src/providers/gitlab-duo.ts +393 -0
  300. package/src/providers/google-auth.d.ts +26 -0
  301. package/src/providers/google-auth.ts +262 -0
  302. package/src/providers/google-gemini-cli.d.ts +75 -0
  303. package/src/providers/google-gemini-cli.ts +969 -0
  304. package/src/providers/google-gemini-headers.d.ts +43 -0
  305. package/src/providers/google-gemini-headers.ts +100 -0
  306. package/src/providers/google-shared.d.ts +183 -0
  307. package/src/providers/google-shared.ts +1105 -0
  308. package/src/providers/google-types.d.ts +138 -0
  309. package/src/providers/google-types.ts +167 -0
  310. package/src/providers/google-vertex.d.ts +11 -0
  311. package/src/providers/google-vertex.ts +124 -0
  312. package/src/providers/google.d.ts +4 -0
  313. package/src/providers/google.ts +41 -0
  314. package/src/providers/grammar.d.ts +1 -0
  315. package/src/providers/grammar.ts +70 -0
  316. package/src/providers/kimi.d.ts +27 -0
  317. package/src/providers/kimi.ts +52 -0
  318. package/src/providers/kiro-api-key.d.ts +50 -0
  319. package/src/providers/kiro-api-key.ts +786 -0
  320. package/src/providers/kiro-codewhisperer.d.ts +11 -0
  321. package/src/providers/kiro-codewhisperer.ts +600 -0
  322. package/src/providers/mock.ts +526 -0
  323. package/src/providers/ollama.d.ts +41 -0
  324. package/src/providers/ollama.ts +645 -0
  325. package/src/providers/openai-anthropic-shim.d.ts +31 -0
  326. package/src/providers/openai-anthropic-shim.ts +156 -0
  327. package/src/providers/openai-bounded-rate-limits.d.ts +3 -0
  328. package/src/providers/openai-bounded-rate-limits.ts +57 -0
  329. package/src/providers/openai-chat-server-schema.ts +254 -0
  330. package/src/providers/openai-chat-server.ts +724 -0
  331. package/src/providers/openai-codex/constants.d.ts +26 -0
  332. package/src/providers/openai-codex/constants.ts +43 -0
  333. package/src/providers/openai-codex/request-transformer.d.ts +50 -0
  334. package/src/providers/openai-codex/request-transformer.ts +219 -0
  335. package/src/providers/openai-codex/response-handler.d.ts +18 -0
  336. package/src/providers/openai-codex/response-handler.ts +111 -0
  337. package/src/providers/openai-codex-responses.d.ts +71 -0
  338. package/src/providers/openai-codex-responses.ts +3288 -0
  339. package/src/providers/openai-completions-compat.d.ts +6 -0
  340. package/src/providers/openai-completions-compat.ts +6 -0
  341. package/src/providers/openai-completions.d.ts +35 -0
  342. package/src/providers/openai-completions.ts +2294 -0
  343. package/src/providers/openai-opencodex-responses.ts +174 -0
  344. package/src/providers/openai-request-transform.d.ts +4 -0
  345. package/src/providers/openai-request-transform.ts +136 -0
  346. package/src/providers/openai-responses-server-schema.ts +290 -0
  347. package/src/providers/openai-responses-server.ts +1268 -0
  348. package/src/providers/openai-responses-shared.d.ts +106 -0
  349. package/src/providers/openai-responses-shared.ts +1253 -0
  350. package/src/providers/openai-responses.d.ts +37 -0
  351. package/src/providers/openai-responses.ts +989 -0
  352. package/src/providers/pi-native-client.d.ts +29 -0
  353. package/src/providers/pi-native-client.ts +243 -0
  354. package/src/providers/pi-native-server.ts +488 -0
  355. package/src/providers/register-builtins.d.ts +59 -0
  356. package/src/providers/register-builtins.ts +544 -0
  357. package/src/providers/synthetic.d.ts +26 -0
  358. package/src/providers/synthetic.ts +50 -0
  359. package/src/providers/transform-messages.d.ts +33 -0
  360. package/src/providers/transform-messages.ts +408 -0
  361. package/src/providers/vision-guard.d.ts +8 -0
  362. package/src/providers/vision-guard.ts +31 -0
  363. package/src/rate-limit-utils.d.ts +19 -0
  364. package/src/rate-limit-utils.ts +102 -0
  365. package/src/stream.d.ts +45 -0
  366. package/src/stream.ts +1306 -0
  367. package/src/types.d.ts +1073 -0
  368. package/src/types.ts +1305 -0
  369. package/src/usage/claude.ts +449 -0
  370. package/src/usage/gemini.ts +250 -0
  371. package/src/usage/github-copilot.ts +421 -0
  372. package/src/usage/google-antigravity.ts +201 -0
  373. package/src/usage/grok-cli.ts +259 -0
  374. package/src/usage/kimi.ts +285 -0
  375. package/src/usage/minimax-code.ts +31 -0
  376. package/src/usage/openai-codex.ts +503 -0
  377. package/src/usage/shared.ts +10 -0
  378. package/src/usage/zai.ts +247 -0
  379. package/src/usage.ts +190 -0
  380. package/src/utils/abort.d.ts +19 -0
  381. package/src/utils/abort.ts +51 -0
  382. package/src/utils/anthropic-auth.ts +95 -0
  383. package/src/utils/block-symbols.d.ts +6 -0
  384. package/src/utils/block-symbols.ts +11 -0
  385. package/src/utils/discovery/antigravity.ts +275 -0
  386. package/src/utils/discovery/codex.ts +362 -0
  387. package/src/utils/discovery/cursor.ts +388 -0
  388. package/src/utils/discovery/gemini.ts +248 -0
  389. package/src/utils/discovery/index.ts +4 -0
  390. package/src/utils/discovery/openai-compatible.ts +379 -0
  391. package/src/utils/event-stream.d.ts +41 -0
  392. package/src/utils/event-stream.ts +269 -0
  393. package/src/utils/fallback-transport.d.ts +110 -0
  394. package/src/utils/fallback-transport.ts +411 -0
  395. package/src/utils/fireworks-model-id.d.ts +10 -0
  396. package/src/utils/fireworks-model-id.ts +30 -0
  397. package/src/utils/foundry.d.ts +11 -0
  398. package/src/utils/foundry.ts +18 -0
  399. package/src/utils/h2-fetch.ts +60 -0
  400. package/src/utils/http-inspector.d.ts +59 -0
  401. package/src/utils/http-inspector.ts +380 -0
  402. package/src/utils/idle-iterator.d.ts +122 -0
  403. package/src/utils/idle-iterator.ts +410 -0
  404. package/src/utils/json-parse.d.ts +98 -0
  405. package/src/utils/json-parse.ts +607 -0
  406. package/src/utils/oauth/alibaba-token-plan.ts +60 -0
  407. package/src/utils/oauth/anthropic.ts +233 -0
  408. package/src/utils/oauth/api-key-login.ts +98 -0
  409. package/src/utils/oauth/api-key-validation.ts +344 -0
  410. package/src/utils/oauth/bizrouter.ts +15 -0
  411. package/src/utils/oauth/callback-server.d.ts +80 -0
  412. package/src/utils/oauth/callback-server.ts +359 -0
  413. package/src/utils/oauth/cerebras.ts +16 -0
  414. package/src/utils/oauth/cloudflare-ai-gateway.ts +48 -0
  415. package/src/utils/oauth/commandcode.ts +17 -0
  416. package/src/utils/oauth/cursor.ts +157 -0
  417. package/src/utils/oauth/deepinfra.ts +15 -0
  418. package/src/utils/oauth/deepseek.ts +53 -0
  419. package/src/utils/oauth/firepass.ts +24 -0
  420. package/src/utils/oauth/fireworks.ts +15 -0
  421. package/src/utils/oauth/fugu.ts +15 -0
  422. package/src/utils/oauth/github-copilot.d.ts +38 -0
  423. package/src/utils/oauth/github-copilot.ts +362 -0
  424. package/src/utils/oauth/gitlab-duo.ts +123 -0
  425. package/src/utils/oauth/glm-zcode.d.ts +71 -0
  426. package/src/utils/oauth/glm-zcode.ts +433 -0
  427. package/src/utils/oauth/google-antigravity.ts +200 -0
  428. package/src/utils/oauth/google-gemini-cli.ts +256 -0
  429. package/src/utils/oauth/google-oauth-shared.ts +110 -0
  430. package/src/utils/oauth/huggingface.ts +62 -0
  431. package/src/utils/oauth/index.ts +558 -0
  432. package/src/utils/oauth/kagi.ts +47 -0
  433. package/src/utils/oauth/kilo.ts +87 -0
  434. package/src/utils/oauth/kimi.d.ts +17 -0
  435. package/src/utils/oauth/kimi.ts +275 -0
  436. package/src/utils/oauth/kiro.ts +448 -0
  437. package/src/utils/oauth/litellm.ts +47 -0
  438. package/src/utils/oauth/lm-studio.ts +38 -0
  439. package/src/utils/oauth/mara.ts +16 -0
  440. package/src/utils/oauth/minimax-code.ts +78 -0
  441. package/src/utils/oauth/moonshot.ts +16 -0
  442. package/src/utils/oauth/nanogpt.ts +15 -0
  443. package/src/utils/oauth/nvidia.ts +70 -0
  444. package/src/utils/oauth/oauth.html +199 -0
  445. package/src/utils/oauth/ollama-cloud.ts +28 -0
  446. package/src/utils/oauth/ollama.ts +47 -0
  447. package/src/utils/oauth/openai-codex.ts +299 -0
  448. package/src/utils/oauth/opencode.ts +49 -0
  449. package/src/utils/oauth/opengateway.ts +15 -0
  450. package/src/utils/oauth/openrouter.ts +16 -0
  451. package/src/utils/oauth/parallel.ts +46 -0
  452. package/src/utils/oauth/perplexity.ts +225 -0
  453. package/src/utils/oauth/pkce.ts +18 -0
  454. package/src/utils/oauth/qianfan.ts +58 -0
  455. package/src/utils/oauth/qwen-portal.ts +60 -0
  456. package/src/utils/oauth/sglang.ts +42 -0
  457. package/src/utils/oauth/synthetic.ts +15 -0
  458. package/src/utils/oauth/tavily.ts +46 -0
  459. package/src/utils/oauth/together.ts +16 -0
  460. package/src/utils/oauth/types.d.ts +56 -0
  461. package/src/utils/oauth/types.ts +122 -0
  462. package/src/utils/oauth/venice.ts +59 -0
  463. package/src/utils/oauth/vercel-ai-gateway.ts +47 -0
  464. package/src/utils/oauth/vllm.ts +42 -0
  465. package/src/utils/oauth/xai.ts +246 -0
  466. package/src/utils/oauth/xiaomi.ts +199 -0
  467. package/src/utils/oauth/zai.ts +60 -0
  468. package/src/utils/oauth/zenmux.ts +15 -0
  469. package/src/utils/overflow.ts +275 -0
  470. package/src/utils/parse-bind.ts +81 -0
  471. package/src/utils/provider-response.d.ts +6 -0
  472. package/src/utils/provider-response.ts +30 -0
  473. package/src/utils/provider-safety-stop.ts +8 -0
  474. package/src/utils/proxy.d.ts +7 -0
  475. package/src/utils/proxy.ts +652 -0
  476. package/src/utils/retry-after.d.ts +3 -0
  477. package/src/utils/retry-after.ts +110 -0
  478. package/src/utils/retry-budget.d.ts +1 -0
  479. package/src/utils/retry-budget.ts +4 -0
  480. package/src/utils/retry.d.ts +29 -0
  481. package/src/utils/retry.ts +67 -0
  482. package/src/utils/schema/CONSTRAINTS.md +164 -0
  483. package/src/utils/schema/adapt.d.ts +24 -0
  484. package/src/utils/schema/adapt.ts +36 -0
  485. package/src/utils/schema/compatibility.d.ts +30 -0
  486. package/src/utils/schema/compatibility.ts +435 -0
  487. package/src/utils/schema/dereference.d.ts +11 -0
  488. package/src/utils/schema/dereference.ts +98 -0
  489. package/src/utils/schema/draft.d.ts +10 -0
  490. package/src/utils/schema/draft.ts +341 -0
  491. package/src/utils/schema/equality.d.ts +4 -0
  492. package/src/utils/schema/equality.ts +97 -0
  493. package/src/utils/schema/fields.d.ts +49 -0
  494. package/src/utils/schema/fields.ts +190 -0
  495. package/src/utils/schema/index.d.ts +14 -0
  496. package/src/utils/schema/index.ts +14 -0
  497. package/src/utils/schema/json-schema-validator.d.ts +12 -0
  498. package/src/utils/schema/json-schema-validator.ts +577 -0
  499. package/src/utils/schema/meta-validator.d.ts +2 -0
  500. package/src/utils/schema/meta-validator.ts +167 -0
  501. package/src/utils/schema/normalize.d.ts +93 -0
  502. package/src/utils/schema/normalize.ts +1588 -0
  503. package/src/utils/schema/root-combinator.d.ts +12 -0
  504. package/src/utils/schema/root-combinator.ts +143 -0
  505. package/src/utils/schema/spill.d.ts +8 -0
  506. package/src/utils/schema/spill.ts +43 -0
  507. package/src/utils/schema/stamps.d.ts +25 -0
  508. package/src/utils/schema/stamps.ts +97 -0
  509. package/src/utils/schema/types.d.ts +4 -0
  510. package/src/utils/schema/types.ts +11 -0
  511. package/src/utils/schema/wire.d.ts +54 -0
  512. package/src/utils/schema/wire.ts +213 -0
  513. package/src/utils/schema/zod-decontaminate.d.ts +31 -0
  514. package/src/utils/schema/zod-decontaminate.ts +331 -0
  515. package/src/utils/sse-debug.d.ts +10 -0
  516. package/src/utils/sse-debug.ts +289 -0
  517. package/src/utils/tool-call-healing.d.ts +80 -0
  518. package/src/utils/tool-call-healing.ts +298 -0
  519. package/src/utils/tool-choice-capability.d.ts +57 -0
  520. package/src/utils/tool-choice-capability.ts +633 -0
  521. package/src/utils/tool-choice.d.ts +50 -0
  522. package/src/utils/tool-choice.ts +99 -0
  523. package/src/utils/validation.ts +1080 -0
  524. package/src/utils.d.ts +117 -0
  525. package/src/utils.ts +523 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,3354 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.16.0] - 2026-09-02
6
+
7
+ ## [0.15.6] - 2026-08-30
8
+
9
+ ### Added
10
+
11
+ - `AuthGatewayServerOptions` now requires `providerScope`; `AuthGatewayBootOptions` requires the provider-filtered `listModels` callback and an exact-catalog-object `resolveModel`. Direct `@gajae-code/ai` callers must construct one gateway instance per provider and pass a provider-filtered source catalog. This matches the mandatory `--provider=<id>` CLI migration and prevents cross-provider model and credential ambiguity.
12
+ - `AuthGatewayBootOptions` now requires live authority callbacks (`hasProviderCredential`, `reloadProviderCredentials`, and `validateProviderCredential`). Gateway dispatch holds the authority lease through `streamSimple()` admission and rejects credentials revoked during asynchronous selection instead of sending a stale key.
13
+ - `auth-broker serve` now requires an `AuthCredentialStore` with atomic `allocateMonotonicSequence` support for durable broker incarnation epochs; unsupported custom stores fail closed before binding and must migrate to the durable cache-backed contract.
14
+
15
+ ### Fixed
16
+
17
+ - Cursor HTTP/2 streams now drain admitted exec responses before normal teardown and centralize terminal failures, preventing delayed handlers and retained shell callbacks from writing after the request has ended.
18
+ - Auth-gateway boot and dispatch are now provider-scoped: model catalogs reject cross-provider id ambiguity, Codex rows retain `openai-codex-responses`, and requests cannot borrow credentials from another provider.
19
+ - Broker-backed gateway dispatch leases now remain held until the provider's transport-admission boundary, preventing lazy stream construction from releasing authority before outbound dispatch.
20
+ - Kiro (Amazon Q Developer / CodeWhisperer) OAuth is now fully wired end-to-end: `AuthStorage.login("kiro", ...)` previously had no dispatch case despite `kiro` being advertised in `getOAuthProviders()`, so every advertised login path (`gjc auth-broker login kiro`, the interactive `/login` provider picker, direct `@gajae-code/ai` CLI `login kiro`) failed with `Unknown OAuth provider: kiro`. `mapOptionsForApi()` also had no case for `kiro-codewhisperer-stream`, so any chat call on a Kiro model threw `Unhandled API in mapOptionsForApi` regardless of auth method. The bundled model catalog had no `kiro` entries at all, leaving OAuth-only users with an empty model list; the provider descriptor's default model id also did not match any catalog entry. The OAuth CodeWhisperer request now also carries `modelId` in every wire message, matching the sibling API-key transport's request shape (issue #5064).
21
+
22
+ ## [0.15.5] - 2026-08-29
23
+
24
+ ### Added
25
+
26
+ - The built-in `kiro` provider now accepts long-lived `KIRO_API_KEY` values (`ksk_…` from [app.kiro.dev](https://app.kiro.dev/settings/api-keys)) in addition to AWS Builder ID OAuth. API-key auth talks to the Kiro service root with `tokentype: API_KEY` and discovers the live model catalog via `ListAvailableModels`. Builder ID login (`gjc auth-broker login kiro` / `AWS_BEARER_TOKEN_KIRO`) is unchanged.
27
+
28
+ ### Fixed
29
+
30
+ - The generic OpenAI Responses transport now preserves the typed `server_is_overloaded` code from an HTTP 200 terminal envelope as transport facts (`openaiErrorCode` / `providerCode`), and that statusless code classifies as a `server` fallback trigger. Both terminal shapes that carry the structured failure are covered: `response.failed`, and `response.completed` whose response `status` is `failed` (including the nested `status_details.error` form). Previously the envelope became a plain `Error`, so the only structured evidence of a capacity rejection was lost and consumers had to read provider prose. The code is matched case-sensitively and exactly, so near misses (`server_is_overloaded_now`), case variants (`SERVER_IS_OVERLOADED`), padded variants, and a `cancelled` response carrying the same code all stay untyped and unclassified; the displayed error message is unchanged in every case. The shared Azure Responses path inherits the same parsing. (#5018)
31
+ - Kiro credential selection now rejects control-character injection and keeps non-`ksk_` values on the Builder ID bearer path. API-key failures redact the credential before reaching assistant error output, and the transport accepts provider header overrides without changing the documented endpoint contract.
32
+ - API-key model discovery also retains the contributor-supplied static catalog for offline print-mode resolution, while live `ListAvailableModels` results remain authoritative when available.
33
+ ## [0.15.4] - 2026-08-29
34
+
35
+ ## [0.15.3] - 2026-08-27
36
+
37
+ ### Fixed
38
+
39
+ - Valid JSON `\uXXXX` tool arguments now execute as their canonical decoded strings instead of entering the escaped-non-ASCII resample loop. This intentionally treats every syntactically valid decoded scalar as canonical; runtime validation cannot infer whether a valid hex digit differed from the model's intent. Provider adapters retain guard metadata for malformed escape-bearing JSON, duplicate/deep suspicious escape evidence, and unpaired UTF-16 surrogates, while standard escaped Hangul, emoji surrogate pairs, and printable ASCII no longer consume retries or terminate managed runs.
40
+ - Explicit positive `maxTokens` values declared for custom `models.yml` models
41
+ and model overrides now reach the provider request across the shared stream
42
+ mapping (`max_tokens`, `max_completion_tokens`, and `max_output_tokens`).
43
+ Built-in and discovered metadata retain the conservative 32,000-token default,
44
+ while positive per-request overrides keep precedence; `compat.extraBody` is
45
+ not required to alter the wire budget.
46
+ - `/login vllm` no longer stores the `vllm-local` no-auth sentinel as a persisted API key. `AuthStorage.getApiKey()` resolves stored `api_key` credentials before environment variables, so a stored sentinel from an empty login could outrank a real `VLLM_API_KEY` env var and reach normal inference. `/login vllm` now requires a real API key (empty input throws `vLLM API key is required; local no-auth servers are discovered automatically`); local no-auth servers remain discovered automatically via the descriptor's `allowUnauthenticated` flag and need no login.
47
+ - `classifyContextOverflow` no longer misclassifies Anthropic context overflow as a terminal request error. Anthropic reports overflow inside a generic `invalid_request_error` envelope (`{"type":"invalid_request_error","message":"prompt is too long: 1158066 tokens > 1000000 maximum"}`), and that envelope type was listed as an authoritative non-overflow code, so it vetoed classification before the `prompt is too long` match could run. Overflow was then treated as a terminal 4xx and auto-compaction never ran. The envelope is now separated from cause-naming codes (auth, quota, rate limit), which keep full veto authority. To preserve the existing hostile-prose defense, only Anthropic's self-verifying measured form (`<used> tokens > <limit> maximum`, where the reported usage actually exceeds the reported maximum) can override the envelope; loose prose such as `too many tokens` still cannot flip a typed transport classification.
48
+ - The OpenAI↔Anthropic compatibility shim (Kimi Code, Synthetic) no longer drops the model's `thinking` metadata when routing an OpenAI-compatible model through the Anthropic Messages API. The shim rebuilt the Anthropic model descriptor field-by-field and omitted `thinking`, so a reasoning-capable model such as `kimi-code/k3` failed every effort-qualified request with `Model kimi-code/k3 is missing thinking metadata` (`getSupportedEfforts` throws when a reasoning model lacks thinking metadata). The descriptor now copies `model.thinking` through, restoring effort validation and the effort→`budget_tokens` mapping for the Anthropic-format route.
49
+
50
+ ## [0.15.2] - 2026-08-25
51
+
52
+ ### Changed
53
+
54
+ - Version 0.15.1 was tagged but never published: release automation failed while deriving release notes, before any package reached npm. Everything listed under `## [0.15.1]` below ships in this release.
55
+
56
+ ## [0.15.1] - 2026-08-25
57
+
58
+ ### Added
59
+
60
+ - Added an `sglang` provider for local OpenAI-compatible servers: its bundled provider descriptor discovers a running SGLang server at `http://127.0.0.1:30000/v1` implicitly, with hardened discovery (`redirect: "error"`, a 500ms loopback probe timeout, and `max_model_len` accepted only as a safe positive integer). `SGLANG_API_KEY` / `SGLANG_BASE_URL` follow the trusted env conventions used by vLLM. Local no-auth discovery needs no stored credential; `/login sglang` stores only a supplied API key, and discovery-only SGLang catalogs are never bundled into release defaults.
61
+ - Added Kilo's `stealth/ox-alpha` model with its reviewed 1,048,576-token context, 131,072-token output ceiling, text/image input, and low/high/max reasoning-effort contract.
62
+
63
+ ### Fixed
64
+
65
+ - Exact ID-selected stored literal API keys can now authorize existing model-cache provenance without resolving or exposing secret bytes; command-backed rows, stored environment references, OAuth, runtime overrides, and config overrides remain ineligible, while an explicitly selected stored row keeps precedence over provider environment fallback.
66
+ - Tool-call parsing now preserves bounded, payload-free raw `\uXXXX` position/scalar evidence across provider adapters. Printable ASCII escapes are included because a one-nibble mutation can move an intended non-ASCII scalar into ASCII before decoded-value validation. Process-keyed scalar/path tags, raw and decoded offsets, value ordinals, duplicate-key/depth rejection, total-position accounting, and a process-local integrity tag make partial, altered, malformed, or overflowed evidence explicitly fail-closed without retaining recoverable argument characters or field names (#4927).
67
+ - Hid the non-callable `google-antigravity/gemini-3.7-flash-{low,medium,high}` selectors from bundled, dynamic, and cached catalogs after live Cloud Code Assist calls returned HTTP 404; `google-antigravity/gemini-3.7-flash-tiered` remains available and callable.
68
+ - Ollama Cloud discovery now keeps curated output limits authoritative and gives unknown models a bounded 32,000-token fallback capped by their discovered context window. This replaces the truncation-prone 8,192 fallback without treating the server context length as a verified 131,072-token output capability or sending unbounded `num_predict` requests. Hosted cold starts and long prefills also receive a 300-second first-event window while explicit timeout overrides keep precedence (#4921).
69
+ - Direct model selections now retry zero-token empty OpenAI-compatible responses.
70
+ - OpenAI-compatible chat streams now replay an exact `finish_reason: "network_error"` only when no text, reasoning, refusal, or tool-call delta has been exposed. Retries honor `streamMaxRetries`, exponential backoff, caller cancellation, and managed-fallback ownership; failed-attempt usage, cost, response IDs, and partial chunks are discarded while terminal error wording remains compatible (#4918).
71
+
72
+ - Cursor `requestContext` rules now forward normalized system prompts, Cursor HTTP/2 transport honors standard proxy environment variables, and GPT effort siblings are sent as their base model with the corresponding reasoning parameter.
73
+ - `AuthStorage.getEarliestUnblockAt(provider)` now exposes the earliest stored credential `blockedUntil` instant so quota exhaustion can report when a row becomes usable again without waiting for it (#4908).
74
+ - vLLM's `allowUnauthenticated: true` now lives on the descriptor itself, not only inside its `catalogDiscovery` config. The runtime discovery gate in `packages/coding-agent/src/config/model-registry.ts` checks `isAuthenticated(apiKey) || descriptor.allowUnauthenticated`, so a local no-auth vLLM server previously needed a credential (`VLLM_API_KEY` or `/login vllm`) before its models would be discovered — unlike lm-studio/omlx, which already carry the descriptor-level flag. Catalog-generation behavior is unchanged.
75
+
76
+ ## [0.15.0] - 2026-08-22
77
+ - A failed dynamic-model refresh no longer blanks a legacy cache row in an unbound provider context. `resolveProviderModels` only reused the last-known rows when the latest cache row was provenance-bound to the current discovery context, so a provider that supplies no `cacheDynamicModelProvenance` (e.g. the Codex family) lost every cached model on a refresh failure AND had its row overwritten with an empty snapshot — the stale-while-error fallback the surrounding code documents never applied to it. Legacy rows now serve through a failed refresh whenever the request context is unbound; bound contexts still fail closed on foreign rows.
78
+ - Added OpenRouter as an API-key login provider in `/login` (`openrouter`). Pasting an `sk-or-v1-...` key validates against `https://openrouter.ai/api/v1` (`openrouter/auto` chat completion probe) and stores a reusable `OPENROUTER_API_KEY` credential, closing the gap where OpenRouter had catalog/env support but no interactive login entry point.
79
+ - Fixed `/logout` (and `gjc accounts logout`) silently ignoring stored API-key credentials. Removal-target enumeration and hard removal were both scoped to `credential_type = 'oauth'` rows, so API-key logins (OpenCode Go/Zen, Cursor, Venice, DeepSeek, …) could never be removed and the flow answered `API-key credentials are not managed here`. Removal targets now include every stored row, `removeAuthCredentialsHard` accepts non-OAuth rows, and the interactive/CLI logout removes stored credentials of either kind.
80
+ - The auth-broker presentation sidecar default is now derived when a `RemoteAuthCredentialStore` is constructed instead of once at module import (#4786). The trusted config root has been call-time state since #4761/#4772, so the import-time constant kept pointing at the home in effect when the module first loaded; a process whose home was established or changed after load read and wrote one logical profile through two different roots — the same split that made user-scope skills and MCP disappear, one layer out, with credential-coherence impact since `<configRoot>/.env` is one of the files `$credentialEnv` treats as trusted. Explicit `presentationPath` options are unchanged, and the E2E `testauth.db` helper derives its path at use time for the same reason.
81
+ - OpenAI Responses-family providers (`openai-responses`, `azure-openai-responses`, `openai-codex-responses`) now batch consecutive tool results so every `function_call_output`/`custom_tool_call_output` of one assistant tool-call turn stays contiguous before a single collected image user message, instead of emitting a standalone image user message after each individual output (#4807). The interleaved form made an OpenAI Responses→Anthropic Messages proxy (e.g. `cliproxyapi`) see a `tool_use` without its `tool_result` in the immediately following user message, and every replay of the poisoned tail failed with a deterministic HTTP 400. Call-id pairing, result arrival order (including reverse order), custom-tool outputs, text-only runs, and single-result shapes are unchanged; non-vision models still degrade to the image placeholder. Each result's image group inside the collected message is labeled with its `call_id` so parallel results keep image-to-call attribution.
82
+ - OpenAI-family idle watchdog floors now key on the Grok model as well as the provider: Grok model ids served through any OpenAI-compatible host (openrouter `x-ai/grok-*`, kilo, litellm, zenmux, venice …) get the same 300-second idle window as native xAI and Grok Build, so a long Grok reasoning gap no longer surfaces as `OpenAI completions stream stalled while waiting for the next event` under the 120-second shared default (#4797). Env overrides still win; non-Grok models are unchanged.
83
+ - Codex stale-continuation recovery now also recognizes prose anchor references — `Previous response with id 'resp_1' not found.`, `The previous response 'resp_1' has expired.`, `Unknown previous response 'resp_1'.` — when the specific stale code is masked to `invalid_request_error` by codex-lb (the same masking already handled for `codex_previous_response_stale`) or omitted entirely (#4802). The #4752 matcher required the compact `previous_response_id` field token, so these shapes reached users as fatal `invalid_request_error` events. Prose matching is tempered against sub-field tokens (tool/function/custom-tool call, call/message/item id, output item): a fault naming something INSIDE the previous response (`Unknown item in previous response.`) is a deterministic history fault and stays fatal, since replaying full context re-sends the same offending item. Retry semantics are unchanged and remain one-shot with full context, gated on the failed request actually having carried an anchor.
84
+ - GLM ZCode OAuth now refreshes its authenticated `/v1/models` catalog automatically, so newly available GLM models are selectable without waiting for the bundled catalog to catch up. Discovery preserves bundled model metadata, sanitizes and bounds every remote display name, rejects catalog entries whose model IDs cannot be handled safely (control-bearing, blank, or overlong IDs are dropped, never renamed — model-selector identity is rendered verbatim), uses the same trusted `ZCODE_PLAN_ANTHROPIC_BASE_URL` decision as model requests, and refreshes legacy static-only cache rows once when live discovery becomes available.
85
+ - Terminal provider safety-stop authority is now adapter-minted provenance instead of a wire-assignable field: a package-private, module-branded capability lets only first-party adapter parse sites mint authority from a structured refusal signal they actually validated (Anthropic `stop_reason` refusal/sensitive, OpenAI `content_filter`, Google prompt/candidate block reasons), while the public surface exposes only `isProviderSafetyStopAuthenticated` (#4777). Managed runtime rebuilds keep their own module-private destination set; public consumers cannot transfer authority from a genuine source to an arbitrary object. Unrecognized signals fail closed with no kind and no authority, so an adapter bug degrades to ordinary fallback rather than a forced refusal; clones, JSON/persistence round-trips, reloaded messages, and custom streams cannot mint authority from public imports or structural fields. The anthropic, openai-completions, google-shared, and google-gemini-cli adapters now mint through the private path instead of assigning `errorKind` directly.
86
+ - The safety-stop mint module is now unreachable through the package export map: `./adapter-internals/*` resolves to a null export, so the `"./*"` wildcard can no longer deep-import `mintProviderSafetyStop` or the adapter capability, and public consumers keep only `isProviderSafetyStopAuthenticated` (#4777 review). Pi-native SSE payloads no longer regain safety-stop authority from a caller-controlled fetch or loopback URL; serialized gateway messages stay unauthenticated until the protocol has an authenticated gateway envelope.
87
+ - Public `stream()` callers can no longer clone a bundled model and redirect its `baseUrl` while still receiving the runtime adapter-invocation token. Safety-stop minting now requires an unchanged bundled model identity and endpoint fingerprint; custom, redirected, or mutated models remain fallback-eligible (#4777 review).
88
+ - Low-level public provider adapters are now fail-closed parser seams: only the first-party `stream()` dispatcher supplies adapter provenance, while direct adapter calls (including bundled or manually constructed models) remain fallback-eligible. This prevents mutable global or caller-selected transports from minting terminal safety-stop authority; callers requiring terminal classification should use `stream()`/`streamSimple`.
89
+ - Kimi Code, Synthetic, and GitLab Duo wrapper dispatches now preserve the runtime safety-stop invocation provenance into their inner Anthropic/OpenAI adapters, so genuine structured refusals remain terminal without making wrapper options caller-mintable (#4777 review).
90
+ - Google candidate and prompt safety refusals now remain terminal across later benign finish reasons even when caller-selected transport prevents provenance minting; the result stays an untyped error instead of flipping to `stop`/`toolUse` (#4777 review).
91
+ - Codex stale-continuation recovery now classifies anchor rejections by provider message as well as by error code, so a provider event shaped `{"type":"error","error":{"type":"invalid_request_error","code":"invalid_request_error","message":"Invalid `previous_response_id`."}}` clears `previous_response_id` and the websocket append state and retries exactly once with full conversation context instead of terminating the active session (#4752). Previously only the `previous_response_not_found` and `codex_previous_response_stale` codes (#731) were recognized, and this shape reached users as a fatal `Codex error event: Invalid \`previous_response_id\`. (code=invalid_request_error)`. Three properties bound the new retry: `invalid_request_error` stays in the non-retryable code set so a generic invalid-request failure that does not implicate the anchor remains fatal; classification reads a new `CodexProviderStreamError.providerMessage` (the raw provider text) rather than the display message, because the display message appends `(code=…)` metadata that would otherwise supply a stale qualifier the provider never sent; and the matcher requires the canonical `previous_response_id` field token, so deterministic history faults such as `Previous response's tool call ID is malformed.` stay fatal instead of replaying full context. Recovery additionally requires that the failed request actually carried an anchor (`sentPreviousResponseId`, tracked from the dispatched websocket request), so a rejection naming the field on an anchor-free request — `Invalid request: previous_response_id is required` on a first turn or after an append reset — stays fatal instead of clearing valid session metadata and resending an identical non-retryable body. Recovery is one-shot per turn (`previousResponseRecoveryAttempted`) — once the anchor is cleared the replay carries no anchor, so a repeated rejection surfaces rather than consuming the five-attempt provider retry budget on full-context replays.
92
+ - Anthropic streaming now distinguishes a tool call that merely passed through an incomplete JSON fragment from one orphaned by a duplicate content-block index. Membership in the truncation set alone is not evidence that a terminal `tool_use` call is incomplete, so normally completed calls remain executable while genuine orphaned calls stay blocked.
93
+ - OpenAI-family streams now give xAI Grok and the Grok Build (`grok-cli-responses`) wrapper the same 300-second default idle window as Anthropic, so long Grok reasoning gaps no longer surface as `OpenAI responses stream stalled while waiting for the next event` under the 120-second OpenAI default. Env overrides still win. The observed stall was `grok-build/grok-4.6` on `openai-responses`; keying only `xai` would have left that path on 120s because `streamGrokCli` keeps `model.provider === "grok-build"`.
94
+ - `getCachedUsageReport` now surfaces provider-level cached usage reports for stored API-key credentials, not only OAuth rows. `checkCredentials` fetches and caches usage for API-key providers (for example `zai`, whose login flow stores an API key by design), but the display lookup rejected every non-OAuth row, so `/usage` and account listings could never show usage data that had been successfully fetched and cached. The lookup builds the same cache identity `checkCredentials` writes, and the returned observation stays redacted — credential bytes never appear in the cached report.
95
+ - Anthropic clients now set an SDK request `timeout` derived from the first-event window (`resolveAnthropicSdkRequestTimeoutMs`; 300s by default for Anthropic, floored at the env/default first-event window, disabled by an explicit `streamFirstEventTimeoutMs: 0`). The Anthropic first-event watchdog deliberately arms only after response headers arrive, so a connection that silently died before headers — the exact failure mode of recent Anthropic stream instability right after a completed tool call — was previously bounded only by the SDK's 10-minute default per attempt multiplied by its internal retry budget, observable as an endless "Working…" spinner for up to an hour with no error, no retry indicator, and no automatic recovery. This mirrors the existing `resolveOpenAISdkRequestTimeoutMs` stalled-before-headers bound on the OpenAI family.
96
+ - Anthropic `input_json_delta` and Codex `function_call`/`custom_tool_call` argument increments now fail the turn closed for every non-string value instead of continuing with missing, default, or silently altered tool arguments. Primitive thinking/text/signature anomalies still degrade to an empty string, and each stream emits at most one payload-free diagnostic per increment type naming only the envelope (`deltaType`/`eventType` and `receivedType`).
97
+ - Anthropic-compatible and Codex stream handlers now coerce non-string prose, thinking, and signature increments to an empty string before emitting `*_delta` events, so a Z.AI or Codex thinking delta that arrives as `undefined` or a numeric token count cannot produce a non-string `delta` that managed snapshot staging rejects as `event.delta`. Executable tool-argument fragments remain fail-closed for every non-string shape. Anthropic `signature_delta` likewise appends only string signatures, so a numeric or missing signature cannot pollute `thinkingSignature` as `"1"` / `"[object Object]"`.
98
+ - Added the `ask-round-zero-metadata-requires-full-topology-fields` raw-argument rejection code so the ask tool's Round-0 deep-interview validator can name the omitted topology fields and their correction; previously the incomplete-object failure surfaced only as generic zod issues with a full payload echo (#4649).
99
+ - oMLX OpenAI-compatible completions now send `chat_template_kwargs.reasoning_effort` with `enable_thinking` when `thinkingFormat` is `qwen-chat-template`. Discovered oMLX models are treated as reasoning models with `low`/`medium`/`high` effort so local Qwen presets can differentiate roles without swapping weights.
100
+ - Fixed a resume-breaking HTTP 400 on `google-gemini-cli`/`google-antigravity` replay: assistant thinking blocks whose `thinkingSignature` is missing, empty (persistence clears oversized signatures to `""`), or invalid no longer emit an unsigned `{"thought": true}` part. Cloud Code Assist maps such parts to Anthropic `thinking` blocks and rejects the whole request with `messages.N.content.0.thinking.signature: Field required`, permanently bricking resumed sessions (#4630). Unsigned thinking now degrades to plain text — the same treatment cross-model reasoning already gets — while validly signed thinking still replays natively as a thought part with its `thoughtSignature`.
101
+ - `validateApiKeyAgainstModelsEndpoint` no longer accepts an API key on HTTP status alone. A 200 whose body is not JSON or carries no recognizable model list (OpenAI-compatible `data` array, gateway `models` array, or a bare array) now fails closed with an actionable error — previously a captive portal or broken gateway answering 200 with an HTML page silently validated and stored the key. Affects every provider using `kind: "models-endpoint"` (Synthetic, DeepSeek, DeepInfra, Fireworks, BizRouter, NanoGPT, OpenGateway, ZenMux, Fugu). Upstream bodies echoed into validation errors are now bounded to 200 characters on both validators.
102
+ - `ToolCall.escapedNonAsciiArguments` doc updated: the agent loop resamples unconditionally then rejects terminally, with a single bounded after-budget exception for tools that enumerated display fields (`displaySafeEscapedArgFields`) whose non-ASCII content is benign typographic punctuation. The scanner itself is unchanged and still flags every non-ASCII escape (#4627).
103
+ - The auth-gateway `/v1/chat/completions` request schema now accepts explicit `null` for unset optional fields and for message `content`. Clients that serialize an omitted option as `null` (Aside, LangChain, LiteLLM, Vercel AI SDK style serializers) — a shape api.openai.com accepts — were rejected with a zod `invalid_union` 400 before a single token streamed, surfacing in client UIs as a generic connection failure. `null` is now collapsed to `undefined` at the schema boundary (and to `""` for required `system`/`developer`/`user` content), so every downstream consumer keeps the existing `T | undefined` shape.
104
+
105
+ ## [0.14.2] - 2026-08-20
106
+
107
+ ### Fixed
108
+ - Grok Build now gets the same 300s idle window as other long-turn providers, so turns no longer stall waiting on a shorter default.
109
+ - `getCachedUsageReport` surfaces cached usage for API-key credentials, not only OAuth accounts (#4686).
110
+ - The auth gateway accepts explicit `null` fields on openai-chat requests instead of rejecting the payload (#4667).
111
+
112
+ ## [0.14.1] - 2026-08-18
113
+ - Anthropic clients now set an SDK request `timeout` derived from the first-event window (`resolveAnthropicSdkRequestTimeoutMs`; 300s by default for Anthropic, floored at the env/default first-event window, disabled by an explicit `streamFirstEventTimeoutMs: 0`). The Anthropic first-event watchdog deliberately arms only after response headers arrive, so a connection that silently died before headers — the exact failure mode of recent Anthropic stream instability right after a completed tool call — was previously bounded only by the SDK's 10-minute default per attempt multiplied by its internal retry budget, observable as an endless "Working…" spinner for up to an hour with no error, no retry indicator, and no automatic recovery. This mirrors the existing `resolveOpenAISdkRequestTimeoutMs` stalled-before-headers bound on the OpenAI family.
114
+ - oMLX OpenAI-compatible completions now send `chat_template_kwargs.reasoning_effort` with `enable_thinking` when `thinkingFormat` is `qwen-chat-template`. Discovered oMLX models are treated as reasoning models with `low`/`medium`/`high` effort so local Qwen presets can differentiate roles without swapping weights.
115
+ - Fixed a resume-breaking HTTP 400 on `google-gemini-cli`/`google-antigravity` replay: assistant thinking blocks whose `thinkingSignature` is missing, empty (persistence clears oversized signatures to `""`), or invalid no longer emit an unsigned `{"thought": true}` part. Cloud Code Assist maps such parts to Anthropic `thinking` blocks and rejects the whole request with `messages.N.content.0.thinking.signature: Field required`, permanently bricking resumed sessions (#4630). Unsigned thinking now degrades to plain text — the same treatment cross-model reasoning already gets — while validly signed thinking still replays natively as a thought part with its `thoughtSignature`.
116
+ - `validateApiKeyAgainstModelsEndpoint` no longer accepts an API key on HTTP status alone. A 200 whose body is not JSON or carries no recognizable model list (OpenAI-compatible `data` array, gateway `models` array, or a bare array) now fails closed with an actionable error — previously a captive portal or broken gateway answering 200 with an HTML page silently validated and stored the key. Affects every provider using `kind: "models-endpoint"` (Synthetic, DeepSeek, DeepInfra, Fireworks, BizRouter, NanoGPT, OpenGateway, ZenMux, Fugu). Upstream bodies echoed into validation errors are now bounded to 200 characters on both validators.
117
+
118
+ - OpenAI Codex requests now sanitize OS-derived `User-Agent` components, preventing non-ASCII Android kernel release names from being rejected as invalid HTTP headers.
119
+ - Kimi OAuth requests now sanitize OS-derived `X-Msh-Device-Name`/`X-Msh-Device-Model`/`X-Msh-Os-Version` header values, preventing non-ASCII hostnames and kernel release names (e.g. Android `Minimal™` builds) from being rejected as invalid HTTP headers. `getKimiCommonHeaders` now memoizes a pure `buildKimiCommonHeaders()` builder.
120
+
121
+ ## [0.14.0] - 2026-08-17
122
+ - Cursor native tool calls (shell/read/write/… oneof variants) now convert their protobuf payloads into plain JSON-safe data before attaching them as toolCall `arguments`: `$typeName` markers are stripped, safe-range bigints become numbers (decimal strings beyond `Number.MAX_SAFE_INTEGER`), byte arrays become base64 strings, and cycles/functions collapse to null. Raw protobuf-es payloads carry `bigint` fields (`fileSize`, `durationMs`, `fileOutputThresholdBytes`, …) that defeat `JSON.stringify`, which broke managed snapshot staging, JSONL transcript persistence, and provider replay — the issue #4578 local-snapshot producer defect class fixed at its producer boundary.
123
+ - Generic OpenAI-compatible `/v1/models` discovery now reads served context-window and output-limit metadata instead of defaulting every dynamically listed model to the unknown-window sentinel. `max_model_len` (vLLM/SGLang/oMLX), `context_length`, `context_window`, `max_context_length` (LM Studio), and `max_position_embeddings` populate `contextWindow` in that precedence order, while `max_tokens`/`max_output_tokens` populate `maxTokens`; total-window fields never leak into the output-token ceiling. Malformed values (non-finite, zero, negative, non-numeric) are rejected per-field with fallback to the next candidate, so a `1e400`-style catalog entry can no longer poison compaction thresholds or compact-input budgets.
124
+ - Codex websocket requests now abort and close their transport when the downstream event-stream consumer returns early (including managed provisional-buffer rejection), so the next turn opens a clean connection instead of inheriting `websocket request already in progress` (#4534).
125
+ - Refreshed the bundled ZAI catalog with GLM-5.3 and made it the provider's default model.
126
+ - Added the typed `local_snapshot_failure` and `local_buffer_overflow` assistant error kinds so downstream retry policy can distinguish local event-snapshot and staging-buffer failures from provider failures.
127
+ - Anthropic first-event timeouts now report safe elapsed time, serialized request bytes, canonical-vs-custom endpoint class, and the `PI_STREAM_FIRST_EVENT_TIMEOUT_MS` override without exposing URL credentials, query tokens, or body content. Large requests through custom endpoints receive one bounded two-minute observation grace so a slightly later proxy 529 can surface without extending explicit-zero, small-request, or canonical deadlines; full-window multi-megabyte requests are never automatically re-uploaded and small requests get at most one session replay. Credit: @probepark (#4464).
128
+ - A ceiling-bound Anthropic upload that fails before stream iteration begins (for example an immediate 529 surfacing from response setup) now carries the one-attempt upload ceiling to the outer provider retry loop as well. Previously only the SDK's internal retries were suppressed for these requests, so the multi-megabyte body could still be re-uploaded up to the default `streamMaxRetries` budget. The delayed-setup grace test was also rescaled from a 1ms window/5ms setup pair — which made the grace-boundary outcome a coin flip on runner scheduling latency — to a regime where the contract is decidable, with a new complementary test proving an in-window 529 after delayed setup keeps its ordinary retry budget. Credit: @probepark (#4464).
129
+ - Unknown Anthropic stream rejections are normalized to a mutable `Error` before retry facts are stamped. An injected custom client rejecting `withResponse()` with a primitive string previously had its facts assigned onto a temporary boxed value — silently discarding them — so a ceiling-bound multi-megabyte upload slipped past the one-attempt ceiling and a string-matched corrective branch (CPA tool-alias restore) re-uploaded the body. Credit: @probepark (#4464).
130
+ - Defense-in-depth: a completed Anthropic stream whose assembled assistant content carries directly adjacent `thinking`/`redacted_thinking` blocks now emits a bounded diagnostic per stream invocation naming only the envelope shape (block count, adjacency presence, model, provider), never raw thinking text, signatures, or redacted payloads. The send-boundary collapse remains the wire source of truth; this is a read-only observation that helps surface upstream producers of the rejected shape (#4443).
131
+
132
+ - The adjacent-thinking-block collapse now treats `thinking` and `redacted_thinking` as one adjacency class at the final Anthropic send boundary, matching the maintainer-approved send-time invariant (#4425). The earlier replay-phase collapse (#4418) and its test asserted that a `redacted_thinking` block following a `thinking` block survived; the final send-boundary pass (#4425) correctly collapses that pair, and the replay-phase test and doc comment are reconciled to that authoritative behavior (#4382).
133
+ - Assistant turns that carry two directly adjacent `thinking` blocks are now collapsed to the first block before replay on `anthropic-messages`. Anthropic rejects that shape with `messages.N.content.M: thinking or redacted_thinking blocks in the latest assistant message cannot be modified`, citing the second block of the pair, and because the offending message keeps its index as the transcript grows, one such turn made every later request in the session fail - observed on two live sessions stuck for 9+ hours, each turn spending two rejected ~1.5 MB uploads, with the cited index frozen (`messages.5.content.118`) while the history grew from 103 to 430 messages. Verified against the captured transcript: the unmodified 430-message replay returns 400 and the collapsed replay returns 200. Thinking blocks separated by a `tool_use` are ordinary interleaved-thinking shape and are preserved, and a `redacted_thinking` blob following a thinking block is untouched (#4416).
134
+ - Dev CI now runs each AI test file in a fresh process instead of sharing one Bun test runtime across the package. This prevents leaked fetch spies, fake timers, environment overrides, auth-broker state, and module caches from contaminating later files while using the same bounded, root-preloaded harness as coding-agent shards (#4378).
135
+ - The deterministic Anthropic cache-eval fixture moved from the untracked root `artifacts/` directory to `packages/ai/test/fixtures/issue-3670-anthropic-cache-eval.json` where test fixtures belong. The integration test import path is updated accordingly (#4420).
136
+ - Anthropic thinking-replay repair now fingerprints the exact serialized outbound body before any application-level resend. A no-op latest-assistant transform is skipped in favor of a safe all-assistant transform, and if neither changes the body the turn fails without uploading the same large request again. The rejected request, transform disposition, hashes, sizes, and cited `messages.N.content.M` mismatch are recorded through the existing redacted HTTP-400 capture and warn path; thinking mode and the `context-management-2025-06-27` beta remain unchanged (#4382).
137
+ - Anthropic 400 errors that name a `clear_thinking_*` context-management strategy now explain when GJC's captured outgoing body contains neither `thinking` nor `context_management`: an intermediary at the redacted configured base URL likely injected the strategy. The diagnostic recommends explicitly enabling thinking or fixing/replacing the intermediary, never silently enables thinking or retries, and annotates the sanitized raw-request capture without changing its body. Credit: @probepark (#4380).
138
+ - Anthropic streams now repair the CPA Claude-OAuth "cannot restore tool alias" 500 instead of blindly resending the unchanged request: the exact SSE signature is classified, the base tool name is extracted, and the request is corrected exactly once with steering that names the unique callable tool (or directs tool discovery when no unique match exists). Recurrence surfaces an actionable terminal error with no transport facts, so neither the provider generic 5xx retry nor the managed fallback controller re-sends; managed attempts record the steering against the same turn and the next attempt applies it (#4338).
139
+ - Tool calls whose raw argument JSON spells a printable non-ASCII character as a `\uXXXX` escape instead of literal UTF-8 are now flagged with `ToolCall.escapedNonAsciiArguments`. Such a payload parses cleanly but is unverifiable — one mistyped hex digit decodes to a different, equally valid character — so the agent loop rejects it instead of executing silently corrupted text. Required control escapes and lone surrogates never trip the flag, and `\\uXXXX` (the source syntax of code being written) is not an escape and is ignored. New `findUnnecessaryUnicodeEscape` helper in `utils/json-parse`. The Kimi tool-call healer samples the signal from the raw leaked payload before its normalizing JSON round-trip, which would otherwise decode the escapes and erase the evidence.
140
+ - Persist learned tool-choice incapabilities in a bounded, expiring, digest-keyed cache so fresh processes avoid repeating known-invalid forced-choice probes while retaining automatic revalidation and existing first-discovery fallback behavior. Credit: @probepark (#4319).
141
+
142
+ ### Added
143
+ - Added first-class support for oMLX (Apple Silicon MLX local inference server), including automatic discovery at `http://127.0.0.1:8080/v1`, `OMLX_BASE_URL`, and `OMLX_API_KEY`.
144
+
145
+ - Added first-class direct xAI `grok-4.6` catalog support over the existing xAI OAuth/subscription transport. Grok 4.5 now exposes exactly `low` through `high` reasoning effort, Grok 4.6 exposes exactly `low` through `xhigh`, and both serialize the selected level through `reasoning_effort`.
146
+ - `AuthStorage.switchSessionCredential(provider, sessionId, selector)` forces a running session's OAuth credential for a provider to a specific stored row, independent of quota/rate-limit state — backing the coding-agent `/credential` slash command for a manual mid-session account switch (as opposed to the existing automatic quota-triggered fallback). Mutates only the session-scoped sticky pointer keyed by `sessionId` (never a provider-wide runtime override), so it cannot bleed into other sessions with a different credential identity; subagents/team workers inherit the parent's credential identity by design and switch with it. Fails closed when a stronger override already re-decides the provider's credential every call (`--credential` hard pin, `--api-key` runtime override, or a config-sourced `models.yml` `apiKey`), and deliberately leaves credential-blocked state untouched so a switch to a still-backoff-blocked row safely falls back to a usable account instead of drawing another 429/quota error.
147
+
148
+ - Added the authoritative OpenRouter `meta/muse-spark-1.2` catalog fallback with a 1,048,576-token context window and `minimal` through `xhigh` reasoning effort, so stale or credential-limited catalog generation still closes the Muse Spark preset alias deterministically.
149
+ - `AuthStorage` supports a soft, per-provider preferred OAuth credential (`setRuntimePreferredCredentialSelector` / `hasRuntimePreferredCredentialSelector` / `removeRuntimePreferredCredentialSelector`, plus `AuthApiKeyOptions.preferredCredentialSelector`) that backs the coding-agent `--prefer-credential` CLI flag. A usable preferred row is placed ahead of the provider's normal balanced/earliest-reset ranking; a content-free quota or rate-limit failure marks it blocked and rotates to another active credential immediately, same as the existing session-stickiness fallback. It is mutually exclusive with the existing hard `setRuntimeCredentialSelector` pin (`--credential`) for the same provider, and `resolveRuntimePreferredCredentialSelectorProvider` resolves an unqualified selector to its single matching active OAuth provider or fails closed on ambiguity.
150
+
151
+ ### Changed
152
+
153
+ - Documented multi-account auth behavior: credential ranking (`balanced` or `earliest-reset`) runs at session start or after a blocked preferred account, explicit OAuth checks run sequentially, and API-key sources remain visible/checkable without entering OAuth pooling, pinning, or removal.
154
+
155
+ - Model discovery now retains the authoritative dynamic provider model IDs separately from the merged static/cache catalog. Consumers can distinguish a fresh provider omission from bundled offline availability through `ModelResolutionResult.dynamicModelIds`; cache schema v5 persists those IDs through fresh-cache reuse and static transport re-merges, scoped to the credential-and-endpoint provenance that produced them.
156
+
157
+ ### Fixed
158
+
159
+ - Cursor OAuth `GetUsableModels` discovery now reads the live million-token window from model display names and aliases (`Claude Opus 5 1M Thinking`) instead of keeping the bundled 200k default. `GetUsableModels` still has no numeric `context_window` field, so the named window is the authoritative live signal; larger bundled fallbacks such as Gemini's 1048576-token window are preserved.
160
+ - Grok Build `/usage` now uses the weekly credits quota when the monthly billing endpoint reports a zero limit, avoiding misleading `100% free` and `used/0` output.
161
+ - A deterministic Anthropic thinking-replay rejection now converges under a managed fallback attempt instead of repeating forever (#4262). Every coding-agent turn prompts with `fallbackManaged: true`, and the whole in-provider thinking-replay repair sits behind `!options?.fallbackManaged` because the fallback controller owns retries — the shipping CLI therefore never repaired anything: each turn rebuilt the same replay from the same history, drew the same 400, and the session burned one rejected request per turn without ever self-healing (reported as ~1 rejected 1.3 MB request every 12s, ~300/h, never converging). The provider still does not retry inside a managed attempt — it records the full-history repair escalation on the provider session state instead, so the next managed attempt builds a repaired replay at the cost of zero extra round trips. Only the two deterministic rejections (`blocks ... cannot be modified`, ``Invalid `signature` in `thinking` block``) qualify; the proxy-masked generic `api_error` names no cause and may be a transient blip, so it still never costs the session its native replay.
162
+ - A long-lived process now recovers when the OAuth row it holds in memory is soft-disabled or replaced in the shared store by a peer (`invalid_grant` disable, credential removal, or a re-login that inserts a new row). The refresh lease answers `missing` for a row that is no longer active, which surfaced as `OAuth refresh credential disappeared` — an error the failure classifier reads as transient, so the vanished row was temp-blocked and retried for the life of the process while a valid re-login row sat unused in the store. Resumed sessions therefore failed every request with the misleading `No credentials found for <provider>` until the CLI was restarted, even though `gjc` had just been logged back in (observed as a per-request refresh-failure flood against `anthropic`). `#tryOAuthCredential` now detects that the attempted row is gone from the store, reloads the snapshot, and re-resolves within the existing reload budget, alongside the peer-rotation recovery it already performed.
163
+ - OpenAI Responses streams now preserve canonical terminal function-call arguments when compatible relays such as llama.cpp emit an empty placeholder in `response.output_item.added`. Tool-call correlation also accepts llama.cpp’s `call_id`-only event shape, while conflicting streamed/terminal arguments, malformed terminal JSON, and terminal payloads that decode to something other than a JSON object fail closed instead of reaching execution. Argument source precedence is terminal item, then streamed deltas, then the `output_item.added` snapshot, so a relay that only ever populates the added snapshot keeps its real payload.
164
+
165
+ - Added bundled Gemini 3.7 Flash next to every existing Gemini 3.6 Flash catalog selector (`google`, `google-gemini-cli`, `github-copilot`, `google-antigravity` effort variants, `opencode-zen`, `openrouter`, `vercel-ai-gateway`, `cursor`, `kilo`, `venice`). Gemini 3.7 Flash accepts only `low`, `medium`, and `high` thinking levels; `minimal` is rejected because the official API returns an error, so the Cursor `-minimal` suffix is not cloned.
166
+
167
+ ## [0.13.3] - 2026-08-15
168
+
169
+ ### Added
170
+
171
+ - Added first-class direct xAI `grok-4.6` catalog support over the existing xAI OAuth/subscription transport. Grok 4.5 exposes `low` through `high` reasoning effort and Grok 4.6 exposes `low` through `xhigh`.
172
+ - Added a native TypeScript Kiro (Amazon Q Developer / CodeWhisperer) provider: AWS SSO OIDC device-code login, bearer-token transport to the CodeWhisperer streaming endpoint over `application/vnd.amazon.eventstream`, and a `kiro` model-manager descriptor for Claude 3.7 Sonnet (#4304).
173
+ - Added the authoritative OpenRouter `meta/muse-spark-1.2` catalog fallback with a 1,048,576-token context window and `minimal` through `xhigh` reasoning effort, so stale or credential-limited catalog generation still closes the Muse Spark preset alias deterministically.
174
+
175
+ ### Fixed
176
+ - Validate Synthetic API key via models endpoint, not retired Kimi probe (#4385).
177
+ - Tool-call arguments that spell printable non-ASCII text as `\uXXXX` escapes are now flagged on the raw wire (`escapedNonAsciiArguments`) by the Anthropic, OpenAI Responses, and OpenAI Completions streams — after JSON decode the defect is unobservable, and a mistyped hex nibble silently becomes a different character (#4515).
178
+
179
+ ## [0.13.2] - 2026-08-13
180
+
181
+ ### Fixed
182
+
183
+ - `clear_thinking`-emptied Anthropic thinking blocks now drop stale signatures before replay, preventing the next request from failing with `Invalid signature in thinking block` after a provider-side reasoning clear (#4247, reported by @probepark).
184
+
185
+ ## [0.13.1] - 2026-08-11
186
+
187
+ ### Fixed
188
+
189
+ - Anthropic thinking-replay repairs caused by a deterministic rejection now stay in force for the rest of the session instead of being released as soon as the repaired retry succeeds. `thinking`/`redacted_thinking` blocks that draw a 400 (`blocks ... cannot be modified`, `Invalid \`signature\` in \`thinking\` block`) stay in the session history, so releasing the repair made the very next turn replay the same blocks and spend another rejected round trip — every turn, indefinitely. Observed against a proxied Claude Code session as a sustained ~50% 400 rate that never converged. The speculative masked-`api_error` probe is still released on the first completed stream, since that one may have been a transient blip (#4011).
190
+ - Anthropic requests no longer spend a rejected round trip discovering that the latest assistant turn cannot replay its thinking block. Anthropic streams a `thinking` block as a start/stop pair with no `thinking_delta` and no `signature_delta` when it withholds reasoning, which lands in history empty and unsigned; `convertAnthropicMessages` then dropped it, and the turn went back carrying only its `tool_use`. Anthropic validates the latest assistant message against the turn it produced and rejects the missing block with 400 `blocks ... cannot be modified`. A captured production request showed exactly this shape — 1214 messages, 29 signed-but-empty thinking blocks preserved, and the latest assistant turn reduced to a bare `tool_use`. The condition is visible locally, so the replay now degrades during the first build instead of after the rejection.
191
+ - The unreplayable-thinking detection now correctly excludes non-signing endpoints (DeepSeek, Z.AI), which replay unsigned blocks verbatim and never validate thinking presence, and signed-but-empty blocks, which `convertAnthropicMessages` forwards natively via the signed-thinking path. The original detection treated empty text as always unreplayable, which degraded valid reasoning on non-signing endpoints and dropped natively replayable signed-empty blocks (#4172).
192
+
193
+ ## [0.12.21] - 2026-08-09
194
+
195
+ ## [0.12.20] - 2026-08-09
196
+
197
+ ### Fixed
198
+
199
+ - OpenAI Responses transports no longer send tool declarations whose names the provider reserves for its own built-ins. OpenCode Zen/Go reject `web_search` as a custom function with `invalid tools in request: custom function name "web_search" is reserved`, and that rejection is request-scoped — one colliding declaration failed the entire tools array before any token streamed, so the bundled `critic`, `planner`, and `architect` agents failed 100% of the time on those providers (#4104). The collision is dropped rather than renamed, because a renamed function tool returns as a `function_call` under the wire alias and that path does not populate `Tool.customWireName`, which would leave the agent-loop dispatcher unable to route the call. `compat.reservedToolNames` overrides the per-provider default.
200
+ - Anthropic streams now use a 300-second default idle window so long extended-thinking gaps do not trip the shared 120-second watchdog; explicit stream timeout overrides still take precedence.
201
+ ## [0.12.19] - 2026-08-08
202
+
203
+ ## [0.12.18] - 2026-08-08
204
+
205
+ ## [0.12.17] - 2026-08-08
206
+
207
+ ## [0.12.16] - 2026-08-08
208
+ ### Added
209
+
210
+ - Added opt-in `compat.supportsResponsesSessionAffinity` for OpenAI Responses custom relays. When enabled, supported `openai-responses` models may send `session_id` and `x-client-request-id` affinity headers to a custom endpoint; canonical OpenAI routing remains automatic and known non-OpenAI provider IDs remain excluded.
211
+ - Added the `jetbrains-junie` provider, serving JetBrains-hosted models over the documented Ingrazzio gateway `https://ingrazzio-cloud-prod.labs.jb.gg` (#3626). Auth is the officially documented `JUNIE_API_KEY` access token only — no OAuth login flow and no reverse-engineered client credentials. JetBrains AI rejects requests carrying `x-api-key`, so the provider passes `apiKey: null` to the Anthropic SDK and relies solely on the `Authorization: Bearer` header that `buildAnthropicHeaders` already emits for non-Anthropic hosts. The gateway multiplexes transports by family via the `X-LLM-Model` routing header: 7 Claude models on `anthropic-messages` (1M prompt window), 7 GPT models on `openai-completions` and `gpt-5.3-codex` on `openai-responses` (922K and 272K respectively); all cap output at 128K. The GPT lane pins a `/v1`-suffixed base URL because the OpenAI transports append a bare route while the Anthropic one supplies its own prefix. Ids come from Junie CLI's own catalog cross-checked against the 2470.4 jar; Gemini and Grok are excluded because their Grazie translation protocol is not implemented, and the bare `opus`/`sonnet` aliases are CLI shorthands the gateway rejects. Limits are the gateway's probed ceilings, not Junie CLI's smaller per-request budgets.
212
+
213
+ ### Changed
214
+
215
+ - Forced the OpenAI code (Codex) GPT-5.6 family prompt budget to 372K input tokens: `CODEX_GPT_5_6_CONTEXT_CAP.enforced` is 372K and is applied as a hard override at discovery (`resolveCodexGpt56DiscoveryContext`), generated-catalog policy (`applyGpt56ContextWindow`), and final model-manager cap (`applyFinalCodexGpt56ContextCap`). The live backend metadata still reports the old 272K budget for the tier, so smaller observations are overridden rather than preserved. The bundled `openai-codex` GPT-5.6 Sol/Terra/Luna catalog entries now advertise 372K context (matching `bun run generate-models` output). Non-5.6 codex variants (`gpt-5.5`, `gpt-5.4-codex`, `gpt-5.6-codex`, GPT-5.4 mini/nano) keep the generic 272K budget via the shared `CODEX_GENERIC_CONTEXT_WINDOW`, first-party OpenAI is untouched, and the 272K long-context pricing threshold is unchanged.
216
+
217
+ ### Fixed
218
+
219
+ - Codex named-tool fallback now keeps its downgraded request body across later same-turn provider retries and uses an independent one-shot budget, so retries cannot reintroduce `tool_choice` or suppress a later capability downgrade (#3669).
220
+ - Stored command-backed API keys that resolve empty now fall through to another usable API key or OAuth credential instead of suppressing it. AuthStorage also exposes the credential type its request dispatcher will select, with selector validation, runtime/config overrides, session OAuth stickiness, blocked/expired OAuth retry, command-key recovery, environment fallback, and `openai-codex-device` normalization sharing one precedence contract.
221
+ - `google-generative-ai` and `google-vertex` generate-content streams now consume newline-delimited JSON responses when the response media type declares NDJSON or JSONL, while preserving standard event-stream parsing and diagnostics.
222
+ - Anthropic requests rejected with `A maximum of 4 blocks with cache_control may be provided. Found N.` now step their generated breakpoints down instead of dying on the first attempt (#3934, supersedes #3943). An Anthropic-compatible gateway may attach its own block-level cache markers before forwarding, and those never appear in the params we serialize, so the total is unpredictable locally and the rejection itself is the only usable signal. Because that rejection says "too many", not "none allowed", recovery gives up one breakpoint at a time: explicit mode normally emits two (a conversation-prefix anchor plus a current-turn refresh point), so the first retry keeps the prefix anchor — the higher-value marker — and only a second rejection disables generated caching entirely. The reduced budget persists for the provider session so later turns neither re-trigger the 400 nor lose more caching than the endpoint requires. Only a genuine breakpoint-overflow `invalid_request_error` is claimed — other `cache_control` complaints, unrelated 400s, non-400 statuses, and our own pre-flight validation failure still surface immediately. The classifier is exported as `isAnthropicCacheBreakpointOverflowError`.
223
+ - A stale in-memory OAuth snapshot can no longer replay an already-rotated refresh token at the provider's token endpoint. Several gjc processes share one credential store, but each holds its own in-memory snapshot; when a peer rotated the token, the existing recovery only re-read the row AFTER the failed refresh — by which point the stale token had already been replayed upstream. Providers with refresh-token rotation plus reuse detection (Anthropic) treat that replay as token theft and can revoke the entire grant family, killing the peer's freshly rotated, still-valid tokens mid-request (observed in the wild as a live session dying with 401 `OAuth access token has been revoked` while sibling processes flooded the log with `invalid_grant` / `Refresh token not found or invalid` refresh failures all day). The local refresh path now re-reads the persisted row (via the canonical storage provider, so the `openai-codex-device` alias is covered) before dialing out: if a peer already rotated and the rotated access token is still fresh, it is adopted with no upstream call at all; if the rotated token has also expired — or the caller demanded a force refresh — the refresh spends the newest persisted refresh token instead of the stale snapshot one, and dispatch re-checks the adopted credential's MCP binding so a bound refresh token is only ever sent to its bound token endpoint. Failure recovery now compares the row against the refresh token that was actually sent (not the caller's stale snapshot), so an adoption that fails is classified and disabled instead of looping reload-retry, and a locally failed (credential, token) attempt is memoized for 30s so automatic refresh retries never immediately replay a token the provider may already have consumed after an ambiguous failure (timeout, lost response) — explicit force refreshes are the deliberate exception: they bypass the memo check so an operator/broker retry always reaches the endpoint, while their failures are still recorded. Broker-routed refreshes are unaffected, and the post-failure reload recovery remains as the backstop for rotations that land inside the now-milliseconds-wide window.
224
+ - Codex GPT-5.6 OAuth context windows now follow an explicit acceptance contract: live `/codex/models` `context_window` metadata is the authoritative runtime source, the bundled 272K fallback/ceiling remains the evidence-gated product guard, and explicit user `contextWindow` overrides survive the final cap instead of being silently re-clamped (#3987).
225
+ ## [0.12.15] - 2026-08-06
226
+
227
+ ### Fixed
228
+
229
+ - Anthropic requests rejected with `A maximum of 4 blocks with cache_control may be provided. Found N.` now retry once with generated caching suppressed, instead of dying on the first attempt (#3934). An Anthropic-compatible gateway may attach its own block-level cache markers before forwarding, and those never appear in the params we serialize, so the total is unpredictable locally and the rejection itself is the only usable signal. The retry keeps generated caching off for the rest of the provider session so later turns do not re-trigger the same 400. Only a genuine breakpoint-overflow `invalid_request_error` is claimed — other `cache_control` complaints, unrelated 400s, non-400 statuses, and our own pre-flight validation failure still surface immediately. The classifier is exported as `isAnthropicCacheBreakpointOverflowError`.
230
+
231
+ ## [0.12.14] - 2026-08-06
232
+
233
+ ## [0.12.13] - 2026-08-06
234
+
235
+ ### Changed
236
+
237
+ - Anthropic prompt caching now defaults to top-level automatic caching (`cache_control: { type: "ephemeral" }`) on the canonical Anthropic API and explicit block-level caching for Claude-family models on non-canonical Anthropic-compatible gateways (Cloudflare AI Gateway, GitHub Copilot, GitLab Duo, Vercel AI Gateway, zenmux, CLIProxyAPI, etc.). Explicit mode is the safer compatible default because gateways commonly inject, rewrite, or reject the top-level field; verified gateways can opt into it with `compat.promptCacheMode: "automatic"`. Non-Claude models on unknown compatible endpoints keep the no-cache default; `promptCacheMode: "none"` and configured or per-request `cacheRetention: "none"` still opt out. Non-canonical Claude models get the default ~5m lifetime unless the endpoint sets `compat.supportsLongCacheRetention: true`.
238
+
239
+ ### Added
240
+
241
+ - Added the `@gajae-code/ai/core` entrypoint for shared model and protocol types without loading provider construction code.
242
+
243
+ ### Fixed
244
+
245
+ - `todo_write` raw argument rejections now carry bounded, authority-controlled correction codes for each rejected shape: unknown root keys, unknown operation-entry keys, done/drop entries missing a task or phase target, and unknown init list-entry keys. Each code maps to a fixed correction message naming the accepted shape (never echoing the offending input), so invalid calls surface specific guidance while valid payloads keep the existing passthrough/coercion path (#3916).
246
+ - Anthropic Sonnet 5 now exposes Anthropic's real `xhigh` and `max` thinking efforts on the Messages API (`minimal`/`low`/`medium`/`high`/`xhigh`/`max`), matching official support. The previous generic `kind === opus` gate excluded it from the full preset range; the capability predicate is now an explicit version-scoped list (Opus 4.7+, Sonnet 5+), so older Sonnet generations and Bedrock Converse routes stay fail-closed at their previously advertised levels (issue #3913).
247
+ - Alibaba Token Plan now exposes Qwen 3.8 Max under the provider-supported `qwen3.8-max` wire id instead of the rejected `qwen-3.8-max` spelling; catalog regeneration canonicalizes a legacy discovered alias rather than retaining a broken duplicate (#3909).
248
+ - Canonicalized first-class MiniMax M3 catalog ids (issue #3896). The bundled catalog previously shipped stale lowercase `minimax-m3` duplicates (512K) next to the canonical `MiniMax-M3` (1M) on all four first-class MiniMax providers, plus a non-official `minimax-v3` entry under `minimax-code`. The lowercase `minimax-m3` entries and `minimax-v3` are removed; `MiniMax-M3` is the single canonical first-class id (the regen-safe 1M pin in `applyGeneratedModelPolicy` now keys on `MiniMax-M3` / `MiniMax-M3[1m]` instead of the removed lowercase id), `DEFAULT_MODEL_PER_PROVIDER` points at `MiniMax-M3`, and the official Anthropic Token Plan id `MiniMax-M3[1m]` is first-class on the `minimax` / `minimax-cn` Anthropic routes with 1M context semantics. Unrelated catalog providers keep their own `minimax-m3` contracts.
249
+ - Anthropic thinking-replay repair now also triggers when the mutation/signature `invalid_request_error` arrives as a statusless in-stream SSE `error` event (issue #3900). Proxies such as CLIProxyAPI forward the upstream 400 body over an HTTP 200 SSE stream, so the thrown error carries no HTTP status; the classifiers previously required `status === 400` and let the session loop on an unrecoverable replay rejection. Statusless errors still require the full `invalid_request_error` thinking wording, so unrelated transport failures never claim the one-shot repair.
250
+ - Anthropic thinking-replay repair now also recovers when a proxy masks the rejection entirely (issue #3900). Live CLIProxyAPI captures replace the upstream 400 body with a generic `{"type":"api_error","message":"An error occurred while processing the request."}` SSE event on an HTTP 200 response, which names no cause and matches no transient phrase, so the turn died on the first attempt. Such a masked rejection now takes the same one-shot latest-then-full-history repair, but only before the first token and only while the request actually replays signed `thinking`/`redacted_thinking` blocks; masked failures on requests without replayed thinking still surface immediately. The classifier is exported as `isAnthropicMaskedProxyRejection`.
251
+
252
+ - Anthropic cache-control resolution now falls back to `model.cacheRetention` at the provider boundary, preserving configured retention and request-over-model precedence through special dispatch wrappers such as GitLab Duo. A configured `cacheRetention: "none"` can no longer be dropped and replaced by the new automatic Claude-family cache marker.
253
+ - Anthropic explicit prompt caching now advances its conversation breakpoint during tool-use loops by marking the latest completed assistant tool-use turn while leaving the newest tool result uncached. Previously it kept refreshing only the original human message until another human turn arrived, pinning proxy cache reads to the static tools/system prefix throughout long agentic runs.
254
+ ## [0.12.12] - 2026-08-05
255
+
256
+ ### Fixed
257
+
258
+ - OpenAI Responses and Azure OpenAI Responses now map the first-event timeout into the SDK request/setup timeout the same way Completions does, so a never-resolving pre-headers fetch on a provider-owned lazy stream cannot wait the SDK's 10-minute default before any transport watchdog exists. Alibaba Responses honors an explicit shorter first-event override before headers; Azure/env-pinned setup timeouts normalize to the typed `stream_first_event_timeout` failure.
259
+ - OpenAI Codex cost estimates now treat an explicit response `service_tier` as authoritative, so a request for priority processing that the provider serves at the default tier is no longer charged the priority multiplier; the requested tier remains the fallback when the terminal response omits the field.
260
+ - Added shared `isReasoningContentReplayError` classifier and `stripUnusableReasoningItems` repair for the DeepSeek-family reasoning-content replay rejection ("The `reasoning_content` in the thinking mode must be passed back to the API"). The classifier detects the error across message carrier shapes; the repair removes only `reasoning` items whose `encrypted_content` a proxy stripped to empty, preserving all non-reasoning history (text, tool calls, tool outputs). The agent loop consumes both for a bounded repair-and-resend circuit breaker.
261
+ - Codex statusless HTTP 200 SSE `invalid_request_error` events retry once without a forced named function choice only when the exact rejected name is still present in the request's serialized tools, before any output is emitted (#3669).
262
+
263
+ ## [0.12.11] - 2026-08-03
264
+
265
+ ## [0.12.10] - 2026-08-03
266
+ ### Added
267
+
268
+ - Anthropic OAuth can now pair by pasting the authorization code Anthropic displays (`https://platform.claude.com/oauth/code/callback`) instead of waiting on `http://localhost:54545/callback`, so a browser with no network route back to the machine running gjc can complete the login. Opt in per login with `OAuthLoginOptions.manualCode`; the loopback flow stays the default and is unchanged. Callback flows can now opt out of binding a local listener entirely (`OAuthCallbackFlowOptions.skipCallbackServer`), which fails fast when no manual code handler is supplied instead of idling until the five-minute timeout. The hosted redirect is a hard-coded constant with no env or config override, so it cannot be repointed at an attacker-controlled collector.
269
+
270
+ ### Fixed
271
+
272
+ - Composer shell-policy failures now expose a stable structured marker plus provider-specific recovery guidance, while retaining recognition of prefix-only errors from older sessions. Cursor Composer requests use a native `read`/`grep`/`write`/`delete` discipline prompt rather than the generic hashline-tool vocabulary.
273
+ - Alibaba Token Plan streams now allow 600 seconds for the first semantic event, matching observed long-context TTFT above the previous 300-second cutoff. The outer lazy watchdog and both OpenAI transports share one provider fallback; OpenAI Completions also applies it before response headers, and Alibaba SDK connection timeouts from that pre-stream phase are normalized to the typed first-event failure so session retry policy does not replay the request as an unknown timeout.
274
+ - A plain `forbidden` failure no longer mutates credential state. `classifyFallbackTrigger` still returns the same `auth` class for HTTP 401 and 403, but now carries an `authDisposition` refinement of `"credential"` or `"forbidden"`. The refinement reads every code field (`openaiErrorCode`, `anthropicErrorType`, `providerCode`) and orders by specificity: a concrete credential fault wins, a `forbidden` in any field is otherwise terminal (so `{status: 401, providerCode: "forbidden"}` does not rotate), and the status decides only when no auth code is present. `transportFailureFacts` also reads `anthropicErrorType` back from its own key so re-normalizing already-built facts no longer drops it. `streamSimple` consults the disposition at both auth-capture exits — the error-event path and the thrown-error path, the latter unwrapping a nested `error.transportFailure` carrier that the shared `transportFailureFacts` extractor does not dereference — so a forbidden failure never reaches `onAuthError`, and `createAssistantAuthError` now preserves the structured transport facts on the callback error instead of reducing it to a status. The auth gateway's managed-failure bookkeeping likewise stops invalidating a credential on a forbidden response. Previously a single 403 could block an otherwise-healthy credential, and in a multi-credential pool could cycle through and block every row.
275
+ - `AuthStorage` gains `hasRuntimeCredentialSelector()` and `getSessionCredentialRowId()`. The first reports the `--credential` runtime pin, which lives in a different map from the `--api-key` override and previously had no accessor, so callers that must not rotate away from a pinned credential could not see it. The second returns the opaque stored row id for a session's current credential — never an email, account, project, or key material.
276
+
277
+ ## [0.12.8] - 2026-08-02
278
+ ### Added
279
+
280
+ - Added read-only OpenCodex provider discovery with runtime-port resolution, identity-checked health probing, cached `/api/models` catalogs, raw wire model ids, and `/login opencodex` status reprobes without credential persistence.
281
+ - Added the Alibaba Token Plan `deepseek-v4-flash-0731` model with its 1M context, 384K output limit, OpenAI Completions routing, and documented low/high/max reasoning efforts.
282
+
283
+ ### Changed
284
+
285
+ - OpenAI-compatible discovery and OpenAI Completions/Responses transports now preserve query-bearing endpoint routing, including repeated query parameters. Model resolution records whether a provider discovery result was fetched so consumers can distinguish current discovery evidence from cached data.
286
+
287
+ ### Fixed
288
+
289
+ - Closed the two remaining ingress holes behind bare `Request Blocked` failures on OpenAI codex models. (1) The chatgpt.com/backend-api pre-model gate rejects with an HTTP 400 bare-`detail` body (`{"detail": "Request blocked."}`) carrying no `error.*` envelope and no `code=invalid_prompt`, so `parseCodexError` surfaced an unexplained message, `isInvalidPromptError` and the codex non-retryable classification missed it, and the session-level `invalid_prompt` circuit breaker never attempted a repaired resend. `parseCodexError` now reads top-level `detail` (string or `{message}`) bodies and classifies a leading `Request blocked` message without an explicit provider code as `invalid_prompt`, surfacing `Request blocked (code=invalid_prompt)` so every existing invalid_prompt contract engages. (2) Outgoing tool definitions (descriptions and JSON-schema strings) bypassed every request-boundary sanitizer on both the OpenAI Responses and OpenAI-codex-responses transports, so a `<|channel|>`-quoting MCP/skill tool description poisoned every request on the session in a way no history repair could fix. Both `convertTools` paths now neutralize reserved control tokens across the whole tool payload via the shared idempotent zero-width-space insertion (ref openai/codex#35838).
290
+ - Lazy built-in streams no longer place a normalized-event watchdog in front of providers that already monitor raw transport progress. This prevents active Anthropic, Azure OpenAI, and OpenAI-family streams from being replaced by a blank `Provider stream stalled while waiting for the next event` error when transport-only events refresh the provider watchdog; providers without their own watchdog keep the shared lazy-stream protection.
291
+
292
+ ### Fixed
293
+
294
+ - Updated GPT-5.6 Sol, Terra, and Luna to current OpenAI Standard pricing, including Responses API cache-write attribution and full-request long-context pricing above 272K input tokens.
295
+
296
+ ## [0.12.7] - 2026-07-31
297
+
298
+ ## [0.12.6] - 2026-07-31
299
+
300
+ ## [0.12.5] - 2026-07-30
301
+ ### Fixed
302
+
303
+ - Alibaba Token Plan requests now carry Qwen Code's canonical DashScope request fingerprint on both transports. The built-in `alibaba-token-plan` provider (openai-responses `qwen3.8-max-preview` and openai-completions `glm-5.2`/`deepseek-v4-pro`) now emits the four upstream identity/cache/auth headers (`User-Agent`, `X-DashScope-CacheControl: enable`, `X-DashScope-UserAgent`, `X-DashScope-AuthType: openai`) matching `QwenLM/qwen-code` v0.21.1 (commit `f4cd6e1`) exactly, via a shared helper. DashScope is compatibility-sensitive to this client fingerprint, so a non-identical set can cause request instability and affect first-event latency. Caller headers still win per key (upstream `{...default, ...customHeaders}` precedence); non-Alibaba providers are byte-unchanged (#3557).
304
+
305
+ ### Added
306
+
307
+ - Reproducible Alibaba Token Plan header-parity A/B latency benchmark (`packages/ai/scripts/alibaba-token-plan-latency-ab.ts`): a fixed-seed interleaved A/B comparison of legacy vs Qwen-identical headers against a deterministic local HTTP server, reporting n/success/error/timeout and TTFT/total latency median/p90/p95/mean/stddev. No live credentials are required; a public-safe blocked-live-data receipt is included (`packages/ai/test/fixtures/alibaba-token-plan-latency-blocked-receipt.md`) (#3557).
308
+
309
+ ## [0.12.4] - 2026-07-30
310
+
311
+ ### Fixed
312
+
313
+ - Mara Cloud login now validates pasted credentials against the authenticated chat-completions endpoint instead of the public `/v1/models` catalog. The catalog returns `200` even for random invalid bearer tokens, so the previous check could persist unusable keys.
314
+
315
+ ## [0.12.3] - 2026-07-30
316
+
317
+ ### Added
318
+
319
+ - Added first-class support for **Mara Cloud**, an OpenAI-compatible enterprise AI inference platform. Registers the `mara` provider descriptor, `/login` entry (API-key paste validated against `https://api.cloud.mara.com/v1/models`), `MARA_API_KEY` environment resolution, and bundled `models.json` seed models. Models are discovered dynamically from `GET /v1/models` (base URL `https://api.cloud.mara.com/v1`).
320
+
321
+ ## [0.12.2] - 2026-07-30
322
+
323
+ ## [0.12.1] - 2026-07-29
324
+
325
+ ### Fixed
326
+
327
+ - Lazy-stream first-event timeouts now abort with `FirstEventTimeoutError` so `transportFailure.providerCode` is `stream_first_event_timeout` on the outer watchdog path shared by all bundled providers via `createLazyStream`. Idle stalls remain bare `Error`s (distinct class intentionally) (#3496).
328
+
329
+ - Provider streams now surface first-event watchdog expiry as a typed timeout so callers can apply bounded retry policy without parsing error prose.
330
+ - Codex websocket first-event timeouts now discard the timed-out connection before the outer retry/fallback layer handles the typed failure, preventing late frames from the abandoned request from being consumed by the replayed turn.
331
+ - Codex named-tool requests now recognize provider `Tool choice '<name>' not found in 'tools' parameter` errors as runtime capability failures and retry once without forcing the choice.
332
+ - The Kimi OAuth host (`KIMI_CODE_OAUTH_HOST` / `KIMI_OAUTH_HOST`) is now resolved from trusted environment sources only. That host receives the device-authorization request, the authorization-code exchange, and the refresh call that carries the existing refresh token, so reading it through the merged view that includes the caller's `cwd/.env` let a repository redirect the login flow and collect the user's Kimi credentials. Resolution now uses the non-project resolver; shell and user-level configuration is unchanged.
333
+ - The documented `GJC_NO_STRICT` environment variable now takes effect. `adaptSchemaForStrict` read only the legacy `PI_NO_STRICT`, so an operator hitting a provider that rejects strict function schemas set the documented name and strict mode stayed on. Both names are honoured, canonical name first, and `GJC_NO_STRICT` is now listed in the environment-variable reference rather than only in the schema-normalisation note.
334
+ - The documented `GJC_AUTH_NO_BORROW` environment variable now takes effect. Only the legacy `PI_AUTH_NO_BORROW` was read, so an operator who followed the documentation to disable macOS native-app token borrowing still had a JWT read out of the Perplexity desktop application during login. Both names are now honoured, and the contract stays presence-based as documented so that setting it to `0` cannot silently re-enable borrowing.
335
+ - The Azure client's `AZURE_OPENAI_API_KEY` fallback is now resolved from trusted environment sources only. It read the merged view that includes the caller's `cwd/.env`, so a repository could supply the credential the client authenticates with; provider credential resolution is documented as excluding the project `.env`, and this fallback now matches. An explicit caller-supplied key still takes precedence, and shell / user-level configuration is unchanged.
336
+ - Anthropic and Ollama tool calls cut off by an output-token limit are now marked incomplete before dispatch, so repaired partial JSON is rejected instead of executing with truncated arguments.
337
+ - The Anthropic "thinking blocks in the latest assistant message cannot be modified" 400 now escalates its one-shot replay repair. The error names the latest assistant message but its cited `messages.N.content.M` path can point at an earlier replayed turn, so the latest-only repair was rejected identically and killed the turn; recovery now retries once more with thinking dropped from every replayed assistant message.
338
+ - Anthropic adaptive-thinking `display` support is now decided by the canonical model-version parser instead of a provider-local `claude-opus-(\d+)-(\d+)` regex. The regex only matched two-component ids, so a single-component alias such as `claude-opus-5` was classified as pre-4.7 while its dated snapshot `claude-opus-5-20260101` was not: the alias sent `thinking: { type: "adaptive" }` without `display: "summarized"`, additionally requested the `interleaved-thinking-2025-05-14` beta, and had its returned thinking blocks recorded as raw rather than summarized. Both Anthropic and Bedrock providers now share `supportsAnthropicAdaptiveThinkingDisplay`, so alias and dated ids of the same model send an identical request shape.
339
+ - Anthropic requests that force a tool choice no longer replay signed thinking blocks. Forcing `tool_choice` strips `thinking` from the request (the API rejects the combination), but the converted history still carried native `thinking`/`redacted_thinking` blocks from thinking-enabled turns, so eager tool-forcing turns (e.g. the todo bootstrap) sent a request whose history contradicted its own thinking setting and drew a 400. The replay now degrades in the same rebuild; the forced request trades its prompt-cache prefix for a shape the API accepts.
340
+ - A definitively failed OAuth refresh can no longer loop forever instead of disabling the credential. The refresh-failure path disables the row with a CAS conditioned on its serialized `data`, and treated a lost CAS as proof that a peer had rotated the token: it reloaded the store and re-resolved, without bound. That predicate also misses when nothing was rotated — an account switcher that replaces the provider's rows leaves the attempted id gone, and an unrelated identity-metadata write leaves the row byte-different — so a revoked credential was never disabled and every subsequent request re-issued the same `invalid_grant` refresh (observed in the wild as ~3k `OAuth token refresh failed` / `disable lost CAS` log pairs in 3.5 hours, one wasted refresh round-trip per request). When the row still holds the refresh token that just failed, it is now disabled by id (no peer rotation exists to clobber); otherwise the reload-and-retry recovery is capped, so resolution terminates instead of recursing until the runtime dies.
341
+
342
+ ## [0.12.0] - 2026-07-28
343
+
344
+ ### Added
345
+
346
+ - Added first-class support for **BizRouter**, an OpenAI-compatible Korean enterprise LLM gateway. Registers the `bizrouter` provider descriptor, `/login` entry (API-key paste validated against `https://api.bizrouter.ai/v1/models`), `BIZROUTER_API_KEY` environment resolution, and bundled `models.json` seed models. Models are discovered dynamically from `GET /v1/models` (base URL `https://api.bizrouter.ai/v1`).
347
+ ### Fixed
348
+
349
+ - Anthropic subscription OAuth requests now use the current Claude Code compatibility attribution (`2.1.219`, `sdk-cli`) instead of the stale `2.1.63` CLI fingerprint that Anthropic can misclassify as extra usage.
350
+ - Connection failures now name the transport code and the target URL. Bun reports DNS and socket failures as a bare `Error` whose message is a standalone hint ("Was there a typo in the url or port?", "Unable to connect. Is the computer able to access the url?") and keeps the actionable facts on `code` and `path`, but only `message` reached the assistant message. A provider outage, a local DNS failure, and a mistyped custom base URL therefore all rendered as the same context-free sentence with no host in it. Such failures now read `... (transport=FailedToOpenSocket url=https://chatgpt.com/backend-api/codex/responses)`; the URL is reduced to origin and path so a key carried in the query string is not surfaced.
351
+
352
+ ### Documentation
353
+
354
+ - `docs/environment-variables.md` now names the Anthropic Foundry gateway variables that are actually read: `CLAUDE_CODE_USE_FOUNDRY`, `CLAUDE_CODE_CLIENT_CERT`, and `CLAUDE_CODE_CLIENT_KEY`. The page advertised `ANTHROPIC_MODEL_CODE_*` spellings that no code path reads, so an operator following it could not enable Foundry mode at all, and the mTLS client material was silently ignored.
355
+
356
+ ## [0.11.11] - 2026-07-26
357
+
358
+ ### Fixed
359
+
360
+ - The Kimi usage endpoint base (`KIMI_CODE_BASE_URL`) is now resolved from trusted environment sources only. That base becomes the URL the usage request sends `Authorization: Bearer <accessToken>` to, so reading it through the merged view that includes the caller's `cwd/.env` let a repository collect the user's Kimi access token. An explicit caller-supplied base URL still takes precedence, and shell / user-level configuration is unchanged.
361
+ - The Gemini CLI compatibility version used in the outbound `User-Agent` is refreshed from `0.50.0` to `0.52.0`, matching the current upstream release. The repository ships `check-spoofed-versions` for exactly this, but that check is not wired into CI, so the value had drifted two minor releases behind.
362
+ - The OpenAI and Azure endpoint decisions are now resolved from trusted environment sources only: `OPENAI_BASE_URL` (streaming responses, completions, and the model manager) and `AZURE_OPENAI_BASE_URL`. `Bun.env` is `process.env` and the env module merges the caller's `cwd/.env` into it, so a repository could previously plant a `.env` that redirected authenticated requests; the two provider paths already reached for `$inheritedEnv` but re-admitted the project `.env` through a fallback. Resolution now goes through the non-project resolver (launching shell plus GJC/user-owned `.env` files); shell and user-level configuration is unchanged.
363
+ - The OpenAI and Azure endpoint decisions are now resolved from trusted environment sources only: `OPENAI_BASE_URL` (streaming responses, completions, and the model manager), `AZURE_OPENAI_BASE_URL`, and `AZURE_OPENAI_RESOURCE_NAME` (the alternate constructor for the same Azure host). `Bun.env` is `process.env` and the env module merges the caller's `cwd/.env` into it, so a repository could previously plant a `.env` that redirected authenticated requests; the two provider paths already reached for `$inheritedEnv` but re-admitted the project `.env` through a fallback. Resolution now goes through the non-project resolver (launching shell plus GJC/user-owned `.env` files); shell and user-level configuration is unchanged.
364
+ - Google credential material is now resolved from trusted environment sources only: the `GOOGLE_APPLICATION_CREDENTIALS` service-account / authorized-user file path used by the ADC loader, and `GOOGLE_CLOUD_API_KEY` used as the Vertex API key. Both were read through the merged view that includes the caller's `cwd/.env`, so a repository could ship a key file and point the agent at it, making it authenticate to Google as an identity the repository chose. `stream.ts` already resolved the same ADC variable through the non-project resolver; the two now agree. An explicit caller-supplied API key still takes precedence.
365
+ - The Grok usage token fallback (`GROK_CLI_OAUTH_TOKEN`) is now resolved from trusted environment sources only. It authenticates the billing/usage call, and reading it through the merged view that includes the caller's `cwd/.env` let a repository decide which account that call ran against. Stored credentials keep precedence, and shell / user-level configuration is unchanged.
366
+ - The Vertex AI location (`GOOGLE_CLOUD_LOCATION`) can no longer redirect authenticated requests off Google. It is interpolated into the request host (`${location}-aiplatform.googleapis.com`), so a value containing `/` terminated the authority component and sent the Google access token to an arbitrary origin — and it was read through the merged view that includes the caller's `cwd/.env`. It now resolves from trusted sources only and must be a region label; `GOOGLE_CLOUD_PROJECT` / `GCLOUD_PROJECT` moved to the same trusted resolver.
367
+ - HTTP 400 request dumps are now bounded. Every 400 wrote a file containing the full sanitized request body and nothing ever removed one, so the directory grew without limit — a developer machine reached 27,249 files totalling 7.0 GB, which was 96% of everything under `~/.gjc`. The newest 50 are retained, matching the bounded retention the rotating application log already uses, and pruning stays best-effort so diagnostics never turn a request failure into a second failure.
368
+ - Anthropic `ping` keepalives no longer reset stream progress, so responses that stop producing content now reach the idle timeout instead of hanging indefinitely.
369
+ - The Anthropic endpoint decision is now resolved from trusted environment sources only: `ANTHROPIC_BASE_URL`, `FOUNDRY_BASE_URL`, `ZCODE_PLAN_ANTHROPIC_BASE_URL`, and the `CLAUDE_CODE_USE_FOUNDRY` mode switch. `Bun.env` is `process.env` and the env module merges the caller's `cwd/.env` into it, so a repository could previously plant a `.env` that redirected authenticated Anthropic requests — the resolved base URL becomes `${baseUrl}/v1/messages` while the headers carry the API key or OAuth token. Resolution now goes through the non-project resolver (launching shell plus GJC/user-owned `.env` files); shell and user-level configuration is unchanged.
370
+ - The documented `GJC_OPENAI_STREAM_IDLE_TIMEOUT_MS` environment variable now takes effect: the stream-watchdog idle-timeout helpers resolve it GJC-first before the legacy `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` / `PI_STREAM_IDLE_TIMEOUT_MS` aliases (previously only the `PI_`-prefixed names were read, so setting the documented GJC name was a silent no-op).
371
+ - The documented OpenAI-code provider knobs now take effect: `GJC_OPENAI_CODE_DEBUG`, `GJC_OPENAI_CODE_WEBSOCKET`, `GJC_OPENAI_CODE_WEBSOCKET_IDLE_TIMEOUT_MS`, `GJC_OPENAI_CODE_WEBSOCKET_RETRY_BUDGET`, and `GJC_OPENAI_CODE_WEBSOCKET_RETRY_DELAY_MS` are resolved GJC-first ahead of the legacy `PI_CODEX_*` names. The Codex → OpenAI-code rename had updated the documentation but not the reads, so every documented name was a silent no-op.
372
+
373
+ ## [0.11.9] - 2026-07-24
374
+ ### Fixed
375
+
376
+ - Credential selection and aggregate usage callers now stop awaiting immediately when their own signal aborts without cancelling shared usage fetches, and ranking deadlines no longer re-await the same stalled usage request during credential resolution.
377
+ - Kimi Code now allows one continuous 300-second first-event wait before aborting, while preserving explicit caller and environment timeout overrides and the existing inter-event idle timeout.
378
+
379
+ ### Added
380
+
381
+ - Added first-class support for **OpenGateway by Sionic AI**, an OpenAI-compatible gateway. Registers the `opengateway` provider descriptor, `/login` OAuth entry (API-key paste validated against `https://apis.opengateway.ai/v1/models`), `OPENGATEWAY_API_KEY` environment resolution, and bundled `models.json` seed models. Models are discovered dynamically from the OpenAI-compatible `/v1/models` endpoint (base URL `https://apis.opengateway.ai/v1`).
382
+
383
+ ## [0.11.8] - 2026-07-23
384
+
385
+ ### Fixed
386
+
387
+ - OpenAI Responses / Codex native history replay no longer submits missing resident-image placeholders as `input_image.image_url`. Invalid values (including `[Session resident imageUrl blob missing: …]`) are dropped, or retained as `file_id`-only parts when a non-empty `file_id` is present, so a single unavailable historical image cannot brick `/retry` (#2924).
388
+ - Raised the first-event stream timeout floor to five minutes for `alibaba-token-plan` models at both the OpenAI provider and outer lazy-stream watchdogs, while preserving caller and environment overrides and the existing inter-event idle timeout.
389
+ - OAuth refresh peer-rotation recovery now runs before failure classification instead of only on the definitive-failure path, and the definitive matcher recognizes the "grant is invalid" phrasing. Providers whose invalid-grant response does not contain the literal `invalid_grant` (e.g. Kimi's 400 "The provided authorization grant is invalid") previously had rotation races misclassified as transient, temp-blocking a healthy credential for five minutes on every race; with Kimi's ~12-minute access tokens and multiple processes sharing the credential store this surfaced as repeated logouts. Genuine revocations are now disabled with a cause instead of looping temp-blocks.
390
+ - Anthropic 400 `Invalid \`signature\` in \`thinking\` block` responses now trigger the one-shot thinking replay repair instead of failing the turn. The existing repair matcher only recognized the "latest assistant message ... cannot be modified" wording, so the signature-validation variant — which can cite a `thinking`/`redacted_thinking` block anywhere in the replayed history (e.g. after compaction/pruning rewrote an earlier turn) — was treated as a fatal request error. The retry now rebuilds the request with thinking blocks dropped from every replayed assistant message (`repairAllAssistantThinking`), while the latest-message mutation variant keeps the targeted latest-only repair.
391
+
392
+ ### Changed
393
+
394
+ - Raw tool-argument rejection hooks can now select from bounded, authority-controlled correction codes. Unknown or extension-supplied values retain the byte-for-byte generic rejection instead of reaching model-visible validation errors.
395
+
396
+ ## [0.11.7] - 2026-07-22
397
+
398
+ ### Changed
399
+
400
+ - Replaced the `alibaba-coding-plan` provider with first-class `alibaba-token-plan` support. The `/login` OAuth list, provider descriptor, model manager, models.dev descriptor, and bundled `models.json` now target the maintained Alibaba Token Plan endpoint (`https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1`, env `ALIBABA_TOKEN_PLAN_API_KEY`) and validate logins against `deepseek-v4-pro`. The retired `alibaba-coding-plan` provider pointed at `coding-intl.dashscope.aliyuncs.com`, which rejected real token-plan keys with 401 and was the only Alibaba entry exposed in `/login`.
401
+
402
+ ## [0.11.4] - 2026-07-20
403
+
404
+ ### Added
405
+
406
+ - Added the native Kimi Code `k3` catalog entry with its 1M-token context window, multimodal input, and reasoning support.
407
+
408
+ ## [0.11.2] - 2026-07-19
409
+
410
+ ### Fixed
411
+
412
+ - `transportFailureFacts` now reduces transport headers to a plain record containing only the retained retry signals (`retry-after`, `retry-after-ms`). Providers attach these facts to error `AssistantMessage`s, and the previous shape carried the live fetch/SDK `Headers` instance — which is not structured-cloneable (`structuredClone` throws `DataCloneError`, "The object can not be cloned." under Bun) and not JSON-serializable (persisted as `{}` in session files, silently dropping the retry hint). Under a managed model fallback chain, snapshotting such an error message replaced the real provider failure with the local clone error and exhausted the whole chain. Normalization is idempotent (re-running facts on facts is structurally stable; errors carrying only unretained headers with no status/code now yield no facts instead of an empty facts object), Retry-After classification (`classifyFallbackTrigger`) is unchanged, and arbitrary response headers no longer reach persisted facts.
413
+
414
+ ## [0.11.0] - 2026-07-15
415
+ ### Added
416
+
417
+ - Exported the canonical thinking-control mode runtime vocabulary so packed SDK consumers can validate provider metadata against the same public `@gajae-code/ai` contract.
418
+
419
+ ### Fixed
420
+
421
+ - Fixed frequent `Request blocked (code=invalid_prompt)` failures on gpt-5.6 (Sol/Terra/Luna) subagent, default-agent, and compaction turns (ref openai/codex#32028, oh-my-pi#5184). Leaked Harmony control-token markers (e.g. `<|channel|>analysis`) were only neutralized on the replayed-history payload path, so markers in assistant reasoning summaries, live-converted message/tool-output text, and user-authored content reached the OpenAI Responses and OpenAI-codex-responses transports verbatim and wedged the session (the poisoned item was re-sent every turn). Both transports now neutralize reserved control tokens across the entire outgoing `input` array at the request boundary via an idempotent zero-width-space insertion that keeps the text human-readable.
422
+
423
+ - Closed the remaining `Request blocked (code=invalid_prompt)` wedge on gpt-5.6 caused by header-form leaked Harmony markers. The reserved-control-token sanitizer only matched the simple `<|ident|>` shape, so a header-form marker carrying a recipient (e.g. `<|assistant to=functions.bash|>`) survived every sanitizer path (replay, request boundary, compaction) and kept re-poisoning history even after the earlier fixes. The pattern now also matches the scoped header grammar — a known Harmony role (`system`/`developer`/`user`/`assistant`/`tool`) plus a `to=<recipient>` assignment with unbounded recipient length — while leaving ordinary delimiter/pipe text untouched (arbitrary `<|foo bar=baz|>`, F# `value <| f |> g`, compact `sum<|a+b|>c`, and multi-line bodies never match). The simple branch remains a strict superset of the prior identifier-only pattern (#2267).
424
+
425
+ - Made the `Request blocked (code=invalid_prompt)` classification explicit and shared across transports (#2282). `invalid_prompt` was only non-retryable by omission — it appeared in neither the codex retryable nor non-retryable event set, and the plain OpenAI Responses transport surfaced it as a generic error with no durable marker. It is now in the codex `CODEX_NON_RETRYABLE_EVENT_CODES` set (code and message forms), the Responses error path tags `transportFailure.providerCode = "invalid_prompt"`, and a new exported `isInvalidPromptError` predicate is the single contract both transports and the session-level circuit breaker key on. Ordinary control-token / pipe text (F# `value <| f |> g`, `sum<|a+b|>c`, `<|foo bar=baz|>`) is unaffected; genuinely transient errors (`server_error`, `model_error`) stay retryable.
426
+
427
+ ## [0.10.2] - 2026-07-14
428
+
429
+ ### Fixed
430
+
431
+ - Fixed frequent `Request blocked (code=invalid_prompt)` failures on gpt-5.6 (Sol/Terra/Luna) subagent, default-agent, and compaction turns (ref openai/codex#32028, oh-my-pi#5184). Leaked Harmony control-token markers (e.g. `<|channel|>analysis`) were only neutralized on the replayed-history payload path, so markers in assistant reasoning summaries, live-converted message/tool-output text, and user-authored content reached the OpenAI Responses and OpenAI-codex-responses transports verbatim and wedged the session (the poisoned item was re-sent every turn). Both transports now neutralize reserved control tokens across the entire outgoing `input` array at the request boundary via an idempotent zero-width-space insertion that keeps the text human-readable.
432
+ ### Fixed
433
+
434
+ - Fixed Fable 5 adaptive thinking being billed but never displayed: model discovery now classifies `claude-fable-*` as `anthropic-adaptive` (was cached as `budget`, sending `enabled`+`budget_tokens` that Fable answers with signature-only thinking), and `supportsAdaptiveThinkingDisplay` opts Fable into `display: "summarized"` on both Anthropic Messages and Bedrock Converse transports (#2791).
435
+
436
+ ## [0.10.0] - 2026-07-12
437
+ ### Fixed
438
+
439
+ - Made Bedrock model visibility reflect credential-only static/shared AWS sources with supported profile shapes, authenticated real bearer-token requests, and stopped advertising unsupported ECS/IRSA sources (#1934).
440
+ - Added a typed provider safety-stop classification across Anthropic, OpenAI-compatible, and Google streams so callers can distinguish policy terminations from generic provider errors without parsing display text.
441
+
442
+ ## [0.9.6] - 2026-07-10
443
+ ### Fixed
444
+
445
+ - Normalized the GPT-5.6 Sol/Terra/Luna context window to the 373K usable prompt budget on both OpenAI and OpenAI code transports (was 1,050K / 272K), matching the live openai-codex catalog.
446
+
447
+ ## [0.9.5] - 2026-07-09
448
+ ### Added
449
+
450
+ - Added GPT-5.6 Sol, Terra, and Luna catalog/parser support for OpenAI and OpenAI code transports, including `low` through canonical `max` reasoning efforts, verified pricing/limits, and GPT-5.6 cache-write pricing (#1925; OmX #3103).
451
+
452
+ ### Fixed
453
+
454
+ - Stopped requesting `strict: true` tool use on Anthropic OAuth requests: the Claude Code OAuth surface mishandles strict tools, returning tool calls with empty/undefined arguments and occasionally corrupted tool names. API-key requests keep strict tool use; `PI_NO_STRICT=1` is no longer needed as a workaround.
455
+
456
+ ## [0.9.4] - 2026-07-09
457
+ ### Fixed
458
+
459
+ - Preserved Anthropic OAuth tool-call names and streamed arguments across interleaved tool-use blocks, preventing prefixed tool names and partial JSON deltas from being dropped or misattributed.
460
+ - Embedded `models.json` via a `with { type: "file" }` import so compiled release binaries load the bundled model catalog from bunfs instead of crashing at startup with `Cannot find module './packages/ai/src/models.json'` (v0.9.3 regression, #1914).
461
+
462
+ ## [0.9.2] - 2026-07-09
463
+ ### Added
464
+
465
+ - Added runtime credential selectors so callers can pin stored multi-account credentials by id, email, account id, or project id instead of using automatic rotation/ranking.
466
+
467
+ ### Fixed
468
+
469
+ - Refreshed the default Gemini CLI impersonation version to 0.50.0 so the spoofed User-Agent freshness gate passes for the 0.9.2 release.
470
+ - Hid the non-callable `google-antigravity/gemini-3.1-pro-high` selector from bundled, dynamic, and cached Antigravity catalogs after live Cloud Code Assist calls returned HTTP 400; `google-antigravity/gemini-3.1-pro-low:high` remains the working high-thinking path.
471
+ - Preserved Anthropic tool-use arguments supplied on `content_block_start` when no `input_json_delta` chunks follow, preventing finished tool calls from collapsing back to `{}`.
472
+ - Refreshed the default Gemini CLI impersonation version to 0.50.0 so the spoofed User-Agent freshness gate passes for the 0.9.2 release.
473
+
474
+ ## [0.9.1] - 2026-07-08
475
+
476
+ ### Fixed
477
+
478
+ - Unified the Cursor client version used across provider requests and discovery.
479
+ - Detected ZAI weekly limit exhaustion as a structured rate-limit condition.
480
+ - Pointed Sakana Fugu OAuth/login guidance at the Sakana platform console and documented the `fish_` key prefix expectation.
481
+
482
+ ## [0.9.0] - 2026-07-07
483
+
484
+ ### Fixed
485
+
486
+ - Capped OpenCode Go Kimi reasoning efforts that the Go chat-completions endpoint rejects (`kimi-k2.5:minimal` → `low`, `kimi-k2.7-code:xhigh|max` → `high`) and degraded forced `tool_choice` for those models so Kimi Go sessions and title-generation turns no longer fail with generic upstream 400s.
487
+
488
+ ## [0.8.2] - 2026-07-06
489
+
490
+ ### Fixed
491
+
492
+ - Refreshed matching existing OAuth credentials during `importCredentialIfAbsent` and cleared provider usage caches after the write, so external credential import no longer keeps stale tokens or stale usage-limit reports for the same account.
493
+
494
+ ## [0.7.9] - 2026-07-01
495
+
496
+ ### Fixed
497
+
498
+ - Mapped DeepSeek-style `prompt_cache_hit_tokens` and `prompt_cache_miss_tokens` usage fields into OpenAI-compatible prompt-cache accounting (#1329).
499
+
500
+ ## [0.7.5] - 2026-06-27
501
+
502
+ ### Fixed
503
+
504
+ - Sanitized Codex history replay text fields so malformed/non-string replay text no longer corrupts the rebuilt request payload (#1199).
505
+ - Preserved object-valued tool replay fields when rebuilding Codex history payloads instead of coercing them to strings (#1200).
506
+
507
+ ## [0.7.4] - 2026-06-27
508
+
509
+ ### Fixed
510
+
511
+ - Treated `openai-codex-device` as an auth-storage alias for `openai-codex`, so headless/device Codex logins show as authenticated and logout/remove the stored Codex credential instead of appearing unsaved (#1151).
512
+ - Disabled thinking for OpenCode Go forced tool calls so forced-tool turns no longer emit unsupported thinking content (#1185).
513
+ - Restored the GPT-5.5 context window to its correct size (#1186).
514
+
515
+ ## [0.7.3] - 2026-06-25
516
+ ### Added
517
+
518
+ - Added the Sakana Fugu provider (`fugu`) with API-key auth (`FUGU_API_KEY`) and bundled catalog models (#1086).
519
+
520
+ ### Fixed
521
+
522
+ - Wired Fugu API-key auth login so `gjc login fugu` stores a reusable `FUGU_API_KEY` credential instead of the provider having no supported login flow (#1090).
523
+ - Matched the real google-antigravity IDE request headers, system prompt, and preamble config so requests are accepted by Cloud Code Assist (#1080).
524
+ - `isContextOverflow` now detects a third proxy-level overflow case — an empty response with `stopReason: "stop"` and anomalously low usage (input + output ≤ 5 tokens), as emitted by some proxies (notably LiteLLM) when the upstream context window is exceeded — so callers surface overflow instead of treating it as a clean completion (#1102).
525
+
526
+ ### Security
527
+
528
+ - In no-auth (tokenless) auth-gateway mode, requests carrying a browser `Origin` header are now rejected before CORS preflight handling or route dispatch, while local non-browser CLI clients keep the existing tokenless flow and token-configured browser clients keep the bearer-token/preflight flow (#1115).
529
+
530
+ ## [0.7.2] - 2026-06-24
531
+
532
+ ### Fixed
533
+
534
+ - Reject truncated or incomplete streamed tool calls instead of executing them with partial arguments, so a cut-off tool-call payload fails fast rather than running against a mismatched schema.
535
+
536
+ ## [0.7.1] - 2026-06-23
537
+
538
+ ### Changed
539
+
540
+ - Reworked the unofficial, opt-in `glm-zcode` provider to mirror how the ZCode desktop app actually reaches GLM: after the ZCode OAuth handshake it now auto-provisions a real Z.AI API key and calls `api.z.ai/api/anthropic` directly, instead of the `zcode.z.ai` coding-plan gateway that required an Aliyun captcha and a ZCode-JWT-bound plan entitlement. Requests also carry ZCode client source headers (`User-Agent: ZCode/<ver>`, `X-ZCode-Agent: glm`, plus platform/locale/timezone), so Z.AI recognizes the caller as the ZCode client (#1013, #1016, #1017).
541
+
542
+ ## [0.7.0] - 2026-06-22
543
+
544
+ ### Added
545
+
546
+ - Added the bundled `google-gemini-cli/gemini-3.5-flash` model entry so Gemini CLI users can select the model from the static registry (#965).
547
+
548
+ ## [0.6.4] - 2026-06-20
549
+
550
+ ### Fixed
551
+
552
+ - Fixed argument mis-attribution in the OpenAI-compatible Responses API streaming decoder when a single response emits multiple tool-call items. The decoder buffered streamed argument deltas against a single most-recent item/block slot, so interleaved or back-to-back `function_call`/`custom_tool_call` argument deltas could be applied to the wrong item — finalizing a tool call with another call's arguments (e.g. one tool's payload landing on a different tool's schema and tripping validation). Streamed deltas now accumulate against a per-item buffer keyed on stable item identity (`item_id` primary; positional `output_index` only when finite), each block records its content index at registration time, and finalization writes onto the same block stored in the message content while reading only the matching item's buffer. Single-tool-call streams, reasoning/text streaming, and the Chat Completions path are unchanged.
553
+
554
+ ## [0.6.2] - 2026-06-19
555
+ ### Added
556
+
557
+ - Added opt-in `compat.sendSessionHeaders` for the `openai-completions` provider. When enabled (default off), the agent session id is forwarded as vendor-neutral `session_id` and `x-session-id` request headers to any OpenAI-compatible endpoint, letting relays/proxies do session-affinity routing and reuse a server-side prompt cache keyed by the session. Previously only the `openai-responses` provider injected session headers, and only against a first-party OpenAI base URL. Injection runs after the caller's `headers`/`extraHeaders` are merged and before `requestTransform`, and uses `??=` so any header the caller already set always wins; it is skipped entirely when the flag is off or no session id is available, leaving existing provider behavior byte-identical. The first-party `openai-responses` gating is unchanged.
558
+
559
+ ### Fixed
560
+
561
+ - Prevented OpenAI Codex Responses `invalid_function_parameters` / tool-schema validation error events from being treated as retryable `server_error`s, so malformed request schemas fail fast instead of burning the full retry budget.
562
+ - Read LM Studio `/v1/models` nested metadata such as `meta.n_ctx`, `meta.n_ctx_train`, and `details.max_tokens` when normalizing dynamically discovered GGUF-backed local models.
563
+ - Corrected the bundled `openai-codex/gpt-5.5` context window from an overstated 400K back to its true 272K (272,000-token) window, so context-cap / auto-compaction thresholds no longer let gpt-5.5 sessions overrun the model's real limit before compaction (#873).
564
+
565
+ ## [0.6.1] - 2026-06-18
566
+
567
+ ### Fixed
568
+
569
+ - Generalized tool `input_schema` root-combinator flattening across providers so discriminated-union tool inputs (e.g. the `computer` tool, a `z.union`) no longer ship a bare top-level `anyOf`/`oneOf`/`allOf` root that strict validators reject. The Anthropic-only fix from 0.5.4 is now the shared, provider-agnostic `flattenToolRootCombinators` (in `utils/schema`) and is applied by Amazon Bedrock, OpenAI Chat Completions / Responses / Codex-Responses / Azure-Responses, Ollama, and Cursor. Previously only Anthropic flattened the root, so those providers forwarded the union root verbatim and a union-root tool failed upstream — Bedrock Converse (including via Kiro/CodeWhisperer relays) returned `400 TOOL_SCHEMA_INVALID: The value at toolConfig.tools.N.toolSpec.inputSchema.json.type must be one of the following: object`. Anthropic behavior is unchanged (it now calls the shared util), Google / Cloud Code Assist keep their own object-merge, and object-root tools, nested combinators, and runtime Zod validation are all untouched.
570
+
571
+ ## [0.6.0] - 2026-06-18
572
+ ### Fixed
573
+
574
+ - Corrected the bundled `zai/glm-5.2` context window from 200K to its true 1M (1,000,000-token) lossless window. GLM-5.2 was added in #579 by copying GLM-5.1's 200K entry, and that stale value survived every `generate-models` run because provider-scoped models bypass the models.dev refresh in `applyGlobalModelsDevFallback`. Added a regen-safe pin in `applyGeneratedModelPolicy` (mirroring the Bedrock-Opus-4.6 precedent) so the 1M value persists, and updated the bundled catalog entry. The wrong 200K tripped auto-compaction / context-cap thresholds ~5x early for GLM-5.2 sessions.
575
+ - Corrected the bundled `minimax-m3` context window from 512K to its true 1M (1,000,000-token) window per the official MiniMax docs (platform.minimax.io documents MiniMax-M3 as a 1M-context frontier coding model). All four provider copies (`minimax`, `minimax-cn`, `minimax-code`, `minimax-code-cn`) carried the stale 512K, which survived `generate-models` (provider-scoped models bypass the models.dev refresh in `applyGlobalModelsDevFallback`) and tripped auto-compaction / context-cap thresholds 2x early on MiniMax sessions. Added a regen-safe pin in `applyGeneratedModelPolicy` keyed on `model.id === "minimax-m3"` and updated the bundled entries. `minimax-v3` (an undocumented catalog alias) is intentionally left untouched.
576
+
577
+ ## [0.5.4] - 2026-06-17
578
+
579
+ ### Fixed
580
+
581
+ - Fixed Anthropic tool schema compatibility for discriminated-union tool inputs by flattening only the model-facing input-schema root, avoiding top-level `oneOf`/`anyOf`/`allOf` request rejections while preserving nested combinators and runtime validation authority.
582
+
583
+ - Made the "No API key for provider" error from `stream`/`complete` actionable for OpenCode Go/Zen subscription providers in headless runs (#755). The subscription is itself an API key (`OPENCODE_API_KEY`, created at https://opencode.ai/auth), not a separate OAuth/session token; the new `formatProviderCredentialHint` helper (composed into `formatMissingApiKeyError`) names the env var GJC reads, warns that a project `.env` is intentionally ignored for provider credentials, and points OpenCode users at the one-time interactive `gjc auth-broker login <provider>` credential capture to run before headless/print mode. No auth behavior changed.
584
+
585
+ ## [0.5.3] - 2026-06-16
586
+
587
+ ### Added
588
+
589
+ - Added opt-in `AuthStorageOptions.credentialRankingMode` (`balanced` (default) | `earliest-reset`) for multi-account OAuth credential selection. `earliest-reset` ranks non-blocked credentials earliest-expiry-first — draining the soonest-to-reset account before its perishable tumbling-window quota (e.g. Claude 5h/7d) is lost at reset — keeping the existing drain-rate/used-fraction metrics as tiebreakers. `balanced` is byte-identical to prior behavior, and ranking only runs at session start (or when the session's preferred credential is blocked), so this never thrashes accounts mid-session.
590
+
591
+ ### Fixed
592
+
593
+ - Allowed `openai-codex-responses` custom backends to use opaque `apiKey` bearer tokens by omitting `chatgpt-account-id` when the token does not expose a Codex account id.
594
+ - Fixed OpenAI code websocket continuations to treat codex-lb's `codex_previous_response_stale` response failures as expired `previous_response_id` anchors and retry with full context instead of surfacing the transient failure.
595
+ - Bounded the Cursor provider's conversation cache with an LRU(64) + 1h TTL and added `disposeCursorConversation`, so long-running sessions no longer retain Cursor conversation state without limit (#717).
596
+
597
+ ## [0.5.2] - 2026-06-15
598
+
599
+ ### Changed
600
+
601
+ - Changed the Anthropic provider's default prompt-cache retention to `long` (`ttl: "1h"`) when a request and model omit `cacheRetention`. The previous default (~5m) was too fragile for long-running Codex/Gajae-Code subagent workflows, where the cached prefix was frequently evicted between turns. The 1h `ttl` marker is only emitted on the canonical Anthropic API (`api.anthropic.com`) for models advertising `supportsLongCacheRetention`; proxies, gateways, and models without that capability still fall back to the default ephemeral breakpoint (Anthropic services it at ~5m). Explicit request/model `cacheRetention` and the `GJC_CACHE_RETENTION`/`PI_CACHE_RETENTION` env overrides continue to win, and `resolveCacheRetention` now accepts a `fallback` argument (defaulting to `"short"`) so non-Anthropic providers are unaffected.
602
+
603
+ ## [0.5.1] - 2026-06-14
604
+
605
+ ### Fixed
606
+
607
+ - Classified model/message limit exhaustion as persistent usage-limit errors so hosts fail fast or switch credentials instead of leaving sessions in an unbounded retry/working state.
608
+
609
+ ## [0.5.0] - 2026-06-13
610
+
611
+ ### Added
612
+
613
+ - Added a generic tool-choice capability model: `toolChoiceSupport` compat enum (`none`/`auto`/`required`/`named`) available on every forced-choice-capable API, derived from the legacy `supportsToolChoice`/`supportsForcedToolChoice` booleans when absent, with a shared `resolveToolChoice` helper that clamps requested tool choices (`named` → `required` → omit) and returns structured degradation metadata.
614
+ - Added a transparent one-shot fallback for forced `tool_choice` 400s ("tool_choice forces tool use is not compatible with this model" and equivalents): transports retry once without the forced field at a pre-content streaming boundary, record the discovery in an in-memory per-process incapability registry, and emit an internal non-rendered `toolChoiceIncapability` event. Applies to Anthropic, OpenAI Completions/Responses, Azure Responses, OpenAI code Responses, Bedrock (including event-stream `validationException`), Ollama, Google, and Gemini CLI transports.
615
+ - Added bundled catalog entries for `kimi-code/kimi-k2.7-code`, `minimax-code/minimax-v3`, and `xai/grok-composer-2.5-fast`.
616
+ - Added composer-harness anchor/edit discipline injection for Cursor Composer and Grok Composer models so provider-specific coding harness priors do not override GJC hashline/edit contracts.
617
+
618
+ ### Removed
619
+
620
+ - Removed the retired `anthropic/claude-fable-5` bundled catalog entry.
621
+
622
+ ### Changed
623
+
624
+ - Moved the Claude Mythos forced-tool-use incapability knowledge out of Anthropic request code into catalog compat defaults (`toolChoiceSupport: "auto"`), applied during catalog generation, dynamic discovery, and bundled-model loading via a shared predicate.
625
+ - Google `toolConfig` mapping now sends `FunctionCallingConfig` mode `ANY` for both `required` and `any` requests instead of silently relaxing `required` to `AUTO`.
626
+ - Optimized `EventStream` queue draining with a head-indexed queue to avoid repeated array shifts in hot streaming paths.
627
+ - Clarified lazy builtin provider registration as the main provider loading path.
628
+
629
+ ### Fixed
630
+
631
+ - Stripped `OpenAI-Beta` in the `openai-proxy` request transform profile so OpenAI-compatible proxies do not receive SDK beta headers.
632
+
633
+ ## [0.4.5] - 2026-06-12
634
+
635
+ ### Changed
636
+
637
+ - Bumped the spoofed Gemini CLI User-Agent version to 0.46.0 to track the upstream release.
638
+
639
+ ### Fixed
640
+
641
+ - Fixed direct Anthropic requests for Claude Mythos-style models that support tools but reject forced tool use by omitting forced `tool_choice` while preserving `auto`/`none` choices.
642
+ - Preserved catalog transport metadata for opencode-go `qwen3.7-max` model resolution.
643
+ - Set SQLite auth-store `busy_timeout` before enabling WAL so initialization is reliable under contention.
644
+ - Resolved provider credentials from inherited or GJC-owned environment sources instead of trusting the caller project's `.env` overlays.
645
+ - Rendered and executed Cursor-native tool calls without dropping provider-specific call details.
646
+
647
+ ## [0.4.4] - 2026-06-10
648
+
649
+ - Version aligned with the 0.4.4 monorepo release; no functional changes in this package.
650
+
651
+ ## [0.4.2] - 2026-06-09
652
+
653
+ ### Fixed
654
+
655
+ - Treated `gpt-5.5` as a 400K-context model wherever context caps / auto-promote thresholds are resolved, so a ~272K session is no longer considered over-cap and no longer demotes to `gpt-5.4`. Pinned the OpenAI Codex `gpt-5.5` context window to 400K and removed its `gpt-5.4` promotion target (the smaller window made it a demotion) ([#428](https://github.com/Yeachan-Heo/gajae-code/issues/428)).
656
+
657
+ ## [0.4.0] - 2026-06-06
658
+
659
+ ### Added
660
+
661
+ - Added minimax-m3 model support across MiniMax providers.
662
+ - Honored the `GJC_CACHE_RETENTION` environment variable and `cacheRetention` model config so hosts can control provider prompt-cache retention (#379/#381).
663
+ - Added an Opus max reasoning preset to the model thinking presets (#372).
664
+ - Refreshed the generated models schema for the new model/config surface (#382).
665
+
666
+ ### Changed
667
+
668
+ - Pinned the OpenAI Codex provider default to GPT-5.5 at `xhigh` reasoning effort (#352). This changes the default model and effort for Codex users (latency/cost/quality impact) and is a behavior change, not an API break; pass an explicit model/effort to override.
669
+ - Bumped the spoofed Gemini CLI user-agent version to 0.45.2 to track the upstream release.
670
+
671
+ ## [0.3.0] - 2026-06-03
672
+
673
+ ### Added
674
+
675
+ - Added xAI to the `/login` provider catalog as a Grok OAuth login with PKCE, refresh-token storage, and mocked login/refresh coverage.
676
+
677
+ ## [0.2.4] - 2026-06-02
678
+
679
+ ### Added
680
+
681
+ - Added configurable provider request and stream retry budgets so hosts can bound transient upstream/server retry behavior separately from session-level retries.
682
+
683
+ ## [0.2.2] - 2026-05-31
684
+
685
+ ### Fixed
686
+
687
+ - Fixed Anthropic extended-thinking replay after aborted turns by dropping partial `thinking`/`redacted_thinking` blocks before the next request, preserving/synthesizing matching tool results, and retrying once with repaired latest-assistant thinking when Anthropic rejects a replay with the immutable-thinking HTTP 400 ([#107](https://github.com/Yeachan-Heo/gajae-code/issues/107)).
688
+ - Fixed first-class `azure-openai` catalog models so normal provider auth resolution reads `AZURE_OPENAI_API_KEY` when streaming `azure-openai/gpt-*` models.
689
+
690
+ ## [0.2.1] - 2026-05-30
691
+
692
+ ### Changed
693
+
694
+ - Refreshed AI package metadata for the GJC 0.2.1 release.
695
+
696
+ ## [0.2.0] - 2026-05-28
697
+
698
+ ### Fixed
699
+
700
+ - Fixed OpenAI-compatible base URL handling so configured proxy URLs and inherited environment overrides are respected at model discovery, completions, responses, and streaming call sites.
701
+ - Fixed OpenAI direct-provider feature gates so prompt-cache/session behavior uses the resolved Responses base URL and only treats exact default `api.openai.com` hosts/paths as direct OpenAI.
702
+
703
+ ## [0.1.3] - 2026-05-28
704
+
705
+ ### Changed
706
+
707
+ - Released the current dev branch fixes with refreshed 0.1.3 package metadata.
708
+
709
+ ## [0.1.2] - 2026-05-28
710
+
711
+ ### Changed
712
+
713
+ - Updated package metadata for the Gajae Code npm publication.
714
+
715
+ ## [0.1.1] - 2026-05-28
716
+ ### Breaking Changes
717
+
718
+ - Removed `findAnthropicAuth` from `anthropic-auth` and replaced store-driven auth discovery with `buildAnthropicAuthConfig`, requiring callers to provide an already-resolved API key before building Anthropic auth config
719
+
720
+ ### Added
721
+
722
+ - Added `AuthStorage.getOAuthAccess` to return a refreshed OAuth access token with identity metadata (`accountId`, `email`, `projectId`, `enterpriseUrl`) for callers that need bearer-token headers together
723
+
724
+ ### Changed
725
+
726
+ - Changed OAuth selection in `AuthStorage` to treat credentials as stale when they are within 60 seconds of expiry and rotate them preemptively
727
+ - Changed Google Gemini CLI, Google Gemini usage, Antigravity usage, and Kimi usage flows to stop refreshing OAuth tokens directly and rely on `AuthStorage` for token rotation
728
+
729
+ ### Removed
730
+
731
+ - Removed provider-local OAuth refresh helpers from Google Gemini CLI and Google/Kimi/Antigravity usage probes, preventing direct refresh calls from those usage paths
732
+
733
+ ### Fixed
734
+
735
+ - Fixed expired OAuth handling so provider-level paths no longer attempt direct token refresh calls for expired credentials and instead rely on `AuthStorage` for rotation
736
+ - Fixed `google-gemini-cli` / `google-antigravity` aborting heavy reasoning runs with "Provider stream timed out while waiting for the first event" before the upstream had a chance to emit its first SSE frame. Cloud Code Assist routinely takes >100s on Gemini 3.x Pro at high thinking levels; the lazy-stream wrapper now floors the first-event watchdog at 5 minutes for these two providers when neither `StreamOptions.streamFirstEventTimeoutMs` nor `PI_STREAM_FIRST_EVENT_TIMEOUT_MS` pins a value. Other providers keep the 100s default. Internally, `getStreamIdleTimeoutMs` and `getStreamFirstEventTimeoutMs` now accept an optional per-provider `fallbackMs` so other slow-first-token providers can opt into the same widening without leaking through to the global default.
737
+ - Fixed Anthropic model Opus 4.7 on Amazon Bedrock streaming no reasoning output (and appearing to hang on long reasoning runs) because Anthropic silently switched the adaptive-thinking display default to `"omitted"`. The Bedrock provider now sends `thinking.display = "summarized"` by default on Opus 4.7+ adaptive models and on budget-based Anthropic model models, mirroring the existing direct-Anthropic behavior. `BedrockOptions.thinkingDisplay` (`"summarized" | "omitted"`) is exposed for callers that want to opt out, and `hideThinkingSummary` now wires through to the Bedrock case ([#1373](https://github.com/can1357/gajae-code/issues/1373)).
738
+ - Fixed Cursor Composer resume/tool-continuation turns failing with `Cannot send empty user message to Cursor API`. Empty current user turns now use Cursor's `resumeAction` instead of constructing an invalid `userMessageAction` ([#1376](https://github.com/can1357/gajae-code/issues/1376)).
739
+
740
+ ## [15.3.2] - 2026-05-25
741
+ ### Added
742
+
743
+ - Added `GET /v1/snapshot/stream` for live auth-broker snapshot updates via SSE with `snapshot`, `entry`, and `removed` event frames
744
+ - Added `AuthBrokerClient.openSnapshotStream()` for consuming SSE snapshot streams from `/v1/snapshot/stream`
745
+ - Added `streamSnapshots` option to `RemoteAuthCredentialStore` (default `true`) to enable or disable SSE-based snapshot synchronization
746
+ - Added `streamKeepaliveMs` to `startAuthBroker()` to tune heartbeat frequency for the SSE stream
747
+ - Added `AuthStorage.checkCredentials({ signal?, timeoutMs?, baseUrlResolver? })` that returns a per-credential `CredentialHealthResult` with tri-state `ok` (`true` / `false` / `null`-unverifiable), the credential's identity (provider, type, email/accountId, broker-refresh flag), and the upstream error string when the probe fails. Iterates sequentially over `listAuthCredentials()`, exercises OAuth refresh on expiry, then calls the per-provider `UsageProvider.fetchUsage` without swallowing errors — so callers can identify which row in a multi-account broker is producing 401s instead of getting a silently-deduplicated `fetchUsageReports` list.
748
+ - Added `GET /v1/credentials/check` to `startAuthGateway()` that forwards to `AuthStorage.checkCredentials` and returns `{ generatedAt, credentials }`. Gated by the same bearer as the rest of the gateway.
749
+
750
+ ### Changed
751
+
752
+ - Changed `RemoteAuthCredentialStore` to prefer SSE snapshot streaming and automatically fall back to long-polling when a broker returns 404 for `/v1/snapshot/stream`
753
+ - Changed snapshot write-refresh flow so `RemoteAuthCredentialStore` skips immediate `/v1/snapshot` refreshes when SSE streaming is active
754
+ - Changed broker SSE stream behavior to keep connections open with periodic keepalives and an increased server idle timeout
755
+
756
+ ## [15.3.0] - 2026-05-25
757
+
758
+ ### Added
759
+
760
+ - Added DeepSeek to the built-in API-key login provider catalog so `gjc login deepseek` stores a reusable `DEEPSEEK_API_KEY` credential for the bundled DeepSeek models.
761
+
762
+ ### Fixed
763
+
764
+ - Fixed `openai-responses` requests intermittently 400ing with `No tool call found for function call output with call_id …` after an aborted turn or a locally-rejected tool call (e.g. argument-validation failure). `convertConversationMessages` now folds orphan `function_call_output` / `custom_tool_call_output` items — those whose matching `function_call` was wiped by an earlier `dt: false` snapshot splice or never landed in any persisted provider payload — into assistant text notes, preserving the payload while keeping the request grammatically valid ([#1351](https://github.com/can1357/gajae-code/issues/1351)).
765
+
766
+ ## [15.2.4] - 2026-05-22
767
+
768
+ ### Fixed
769
+
770
+ - Fixed ChatGPT Plus/Pro (OpenAI code) OAuth login returning `Token exchange failed: 403` on Windows. When port 1455 was in use, the callback server silently fell back to a random port; OpenAI's authorization endpoint accepts any localhost redirect URI (loose validation), so the browser callback succeeds and shows "Authentication Successful", but the token endpoint rejects the non-registered port with 403. The `OpenAIOpenAI codeOAuthFlow` now enforces a fixed `redirectUri` option so a busy port immediately surfaces as "port unavailable" instead of producing a confusing 403 ([#1277](https://github.com/can1357/gajae-code/issues/1277)).
771
+ - Improved `exchangeCodeForToken` error diagnostics: the 403 response body (`error` / `error_description` fields) is now included in the thrown message, matching the existing `refreshOpenAIOpenAI codeToken` behaviour.
772
+
773
+ ### Added
774
+
775
+ - Added `ChatGPT Plus/Pro (OpenAI code, headless/device)` (`openai-code-device`) as an alternative login method for the OpenAI code provider. Uses OpenAI's device-code flow (`/api/accounts/deviceauth/usercode` → poll `/api/accounts/deviceauth/token`), which avoids a local callback server and port 1455 entirely. Credentials are stored under the existing `openai-code` provider key so all models and tooling continue to work without reconfiguration ([#1277](https://github.com/can1357/gajae-code/issues/1277)).
776
+
777
+ ## [15.2.2] - 2026-05-22
778
+
779
+ ### Fixed
780
+
781
+ - Fixed `gemini-3.1-pro-high` and `gemini-3.1-pro-low` on the `google-antigravity` provider always returning HTTP 400 from Cloud Code Assist. The `ANTIGRAVITY_SYSTEM_INSTRUCTION` identity header was not injected for these models because the internal check matched the string `"gemini-3-pro-high"` (hyphen) instead of the versioned `"gemini-3.1-pro-..."` form. The guard now matches all `gemini-3` model variants ([#1274](https://github.com/can1357/gajae-code/issues/1274)).
782
+
783
+ ## [15.2.0] - 2026-05-21
784
+
785
+ ### Fixed
786
+
787
+ - Fixed `/login` (and `/logout`, plus any `AuthStorage.set` / `remove` call) against a remote auth-broker throwing `RemoteAuthCredentialStore is read-only on the client. Use 'gjc auth-broker login <provider>' to mutate credentials.` Added three optional async write hooks to `AuthCredentialStore` (`upsertAuthCredentialRemote`, `replaceAuthCredentialsRemote`, `deleteAuthCredentialsRemote`); `RemoteAuthCredentialStore` implements them via the broker's `POST /v1/credential` and `POST /v1/credential/:id/disable` endpoints and applies the broker's authoritative post-write entries to the local snapshot. `AuthStorage` routes through the hooks when present, so OAuth and API-key logins (and logouts) initiated from a broker-backed client now persist server-side and surface immediately without waiting for the long-poll snapshot tick.
788
+
789
+ ## [15.1.9] - 2026-05-21
790
+
791
+ ### Fixed
792
+
793
+ - Fixed Ollama named tool forcing to send only the requested tool when the caller passes a named `toolChoice`, preserving `tool_choice: "required"` while preventing local models from selecting a different tool. ([#1236](https://github.com/can1357/gajae-code/issues/1236))
794
+ - Fixed `/btw` (and IRC background replies) returning a `BedrockException` 400 (`The toolConfig field must be defined when using toolUse and toolResult content blocks.`) on LiteLLM → Bedrock once the session has tool-call history. Two source fixes in `buildParams`: (1) `if (context.tools)` → `if (context.tools?.length)` so an explicit `context.tools = []` (the /btw opt-out) never routes through `convertTools` and never emits an empty `"tools"` array; (2) `else if (hasToolHistory(...))` → `else if (context.tools === undefined && hasToolHistory(...))` so the Anthropic-proxy sentinel that injects `tools: []` for tool-history turns is suppressed when the caller explicitly opted out, preventing it from re-introducing the empty array. As defence-in-depth, `tool_choice: "none"` is also dropped when the resolved tools list is missing or empty. ([#1227](https://github.com/can1357/gajae-code/issues/1227))
795
+
796
+ ## [15.1.8] - 2026-05-20
797
+ ### Added
798
+
799
+ - Added Fireworks Fire Pass as a separate `firepass` provider with API-key login flow, bundled `kimi-k2.6-turbo` model entry (Kimi K2.6 Turbo), and wire-id translation from the friendly catalog id to the `accounts/fireworks/routers/kimi-k2p6-turbo` router endpoint. Fire Pass keys (`fpk_…`) authorize only the dedicated router and reject `/v1/models`, so login validation pings chat completions against the router id directly. Extended the openai-completions Kimi-family safety net so the firepass entry inherits the per-Fireworks-docs "always send `max_tokens`" default ([Kimi K2 guide](https://docs.fireworks.ai/models/kimi-k2)); the router's accepted `reasoning_effort` set includes `xhigh`, so it is forwarded verbatim rather than remapped. See https://docs.fireworks.ai/firepass.
800
+
801
+ ### Fixed
802
+
803
+ - Fixed DeepSeek V4 direct API requests with tools to keep documented thinking mode instead of dropping reasoning: lower GJC efforts now map to DeepSeek's supported `high`, `tool_choice` is omitted, `thinking: { type: "enabled" }` and `max_tokens` are sent, and partial user `reasoningEffortMap` overrides merge with DeepSeek defaults. ([#1207](https://github.com/can1357/gajae-code/issues/1207))
804
+ - Fixed model cache schema v2 databases so offline refreshes preserve cached provider discoveries after upgrading to schema v3 and subsequent online refreshes can overwrite the cache. ([#1219](https://github.com/can1357/gajae-code/issues/1219))
805
+ - Fixed Perplexity OAuth credentials being treated as expired one hour after login. `getJwtExpiry` was fabricating `expires = now + 1h` whenever the JWT had no `exp` claim (the common case — Perplexity sessions are server-side). Once the hour elapsed, `getOAuthApiKey` would mark the cred expired and the search provider's loader would silently skip it, surfacing as "logged out". Logins with no `exp` now persist a far-future sentinel; `getOAuthApiKey` also normalizes any stale `expires` written by older builds.
806
+
807
+ ## [15.1.7] - 2026-05-19
808
+ ### Added
809
+
810
+ - Added Anthropic realization of `serviceTier: "priority"`. The anthropic-messages provider now sets `speed: "fast"` on the request and appends the `fast-mode-2026-02-01` beta to `Anthropic-Beta` whenever the caller passes `serviceTier: "priority"`. When the server rejects an unsupported model with `invalid_request_error`, the provider transparently retries the same turn without the fast-mode signal (mirroring the strict-tools fallback pattern), persists the disable via a new `providerSessionState.fastModeDisabled` flag so subsequent requests in the session skip the field, and surfaces the action via the new `AssistantMessage.disabledFeatures` array (id `"priority"`) so callers can sync user-facing toggles. A new `clearAnthropicFastModeFallback(providerSessionState)` helper lets callers re-arm priority after the auto-fallback fired.
811
+ - Added scoped `ServiceTier` values: `"openai-only"` (priority on `openai`/`openai-code`, ignored elsewhere) and `"anthropic-model-only"` (priority on direct `anthropic`, ignored on Bedrock/Vertex Anthropic model and elsewhere). A new `resolveServiceTier(serviceTier, provider)` helper computes the effective tier for the provider; existing OpenAI/Anthropic provider code routes through it, so `service_tier` and Anthropic fast-mode emission both respect scope. `getPriorityPremiumRequests` now counts Anthropic+priority as one premium request (previously zero) and continues to ignore providers that drop the field on the wire.
812
+
813
+ ### Fixed
814
+
815
+ - Fixed Anthropic fast mode (`serviceTier: "priority"`) looping on 429 `rate_limit_error: "Extra usage is required for fast mode."` for accounts without the extra-usage entitlement. `isAnthropicFastModeUnsupportedError` now matches the 429 phrasing in addition to the 400 `invalid_request_error` "does not support the `speed` parameter" case, so the provider drops `speed: "fast"` on the in-turn retry, sets `providerSessionState.fastModeDisabled` for the remainder of the session, and surfaces `disabledFeatures: ["priority"]` to the caller instead of retrying with the same payload until `PROVIDER_MAX_RETRIES` is exhausted.
816
+ - Fixed MiniMax Coding Plan CN streaming `<think>...</think>` reasoning as visible assistant text. The OpenAI-compatible stream parser now enables the existing MiniMax tag parser for both `minimax-code` and `minimax-code-cn`, so CN responses become structured `thinking` blocks instead of raw text. ([#1203](https://github.com/can1357/gajae-code/issues/1203))
817
+
818
+ ## [15.1.6] - 2026-05-19
819
+
820
+ ### Fixed
821
+
822
+ - Fixed `{}` (empty JSON Schema, the wire representation of `z.unknown()`) being passed verbatim to grammar-constrained samplers (llama.cpp, etc.) in `additionalProperties`, `items`, and other schema-valued positions across **every provider** (OpenAI, Anthropic, Google, Ollama, Bedrock, Cursor). Grammar builders treat `{}` as "generate an empty object" rather than "any JSON value", causing open-typed fields (e.g. `extra.title` from `z.record(z.string(), z.unknown())`) to always emit `{}` instead of the intended string/number/etc. `toolWireSchema` now applies a new `normalizeEmptySchemas` pass (exported) to both the Zod and TypeBox/raw-JSON-Schema branches, converting `{}` → `true` (semantically identical per JSON Schema draft 2020-12 §4.3.1) in all schema-valued positions. Strict-mode opt-out is preserved across all providers: OpenAI's `hasUnrepresentableStrictObjectMap` hits the `=== true` branch instead of the `isJsonObject({})` branch (same result); Anthropic's `normalizeAnthropicStrictSchemaNode` opts out via `additionalProperties !== false` (still true for `true`); Google's `normalizeSchemaForGoogle` strips `additionalProperties` regardless (pre-existing). ([#1179](https://github.com/can1357/gajae-code/issues/1179))
823
+ - Fixed `pi-ai login <provider>` crashing with `Unknown provider` for providers that only the `auth-storage` `login()` switch knew about (perplexity, alibaba-coding-plan, gitlab-duo, huggingface, opencode-zen/go, lm-studio, ollama, cerebras, fireworks, qianfan, synthetic, venice, litellm, moonshot, together, cloudflare/vercel ai gateways, vllm, qwen-portal, nvidia, xiaomi, and any custom OAuth provider). The CLI now delegates to `SqliteAuthCredentialStore.login()` instead of duplicating a smaller switch, so the auth-broker `gjc auth-broker login <provider>` flow works for every registered OAuth provider.
824
+
825
+ ## [15.1.4] - 2026-05-19
826
+ ### Changed
827
+
828
+ - Updated auth-gateway format and pi-native request handling to invalidate the failed API key and retry the provider request with a replacement key when authentication fails
829
+
830
+ ### Fixed
831
+
832
+ - Fixed OpenCode-Go and OpenCode-Zen chat-completions replay to omit stored reasoning fields on Kimi assistant tool-call messages, avoiding provider 400s for rejected `messages[].reasoning` payloads. ([#1157](https://github.com/can1357/gajae-code/issues/1157))
833
+ - Fixed OpenAI Responses and OpenAI code tool schema normalization to emit `properties: {}` for no-argument object schemas without rewriting literal payloads. ([#1147](https://github.com/can1357/gajae-code/issues/1147))
834
+ - Fixed Anthropic 400 (`unexpected tool_use_id found in tool_result blocks ... Each tool_result block must have a corresponding tool_use block in the previous message`) when handoff/compaction folds an assistant `tool_use` into the handoff summary string but leaves the matching user-side `tool_result` message in the history. `transformMessages` now indexes every `tool_use` id surviving the first pass and drops orphan `tool_result` messages whose originator was compacted away, preserving the text payload as a user-level `<stale-tool-result>` note so the model still sees what the tool returned. The note is emitted with `role: "user"` rather than `role: "developer"` so providers that elevate developer-role messages (Ollama: `developer` → `system`; OpenAI chat-completions reasoning models: `developer` → `developer`) cannot lift stale tool output to an instruction-priority tier above the surrounding user/developer messages.
835
+ - Fixed streaming authentication retry to trigger when a provider emits a 401 `error` event after a `start` event but before any replay-unsafe content is emitted
836
+ - Added `credential_process` support to the Bedrock provider's AWS credential resolver so profiles delegating to external brokers (`aws-vault`, `granted`, in-house tools) resolve instead of falling through to `Unable to resolve AWS credentials`. Parses the AWS SDK `Version: 1` JSON envelope, honors `Expiration` in the per-profile cache, propagates `AbortSignal` to the spawned helper, routes Windows `.cmd`/`.bat` helpers through `cmd.exe /c`, and ships a POSIX-shell-style tokenizer that preserves backslashes inside double quotes so Windows paths survive ([#1142](https://github.com/can1357/gajae-code/issues/1142))
837
+
838
+ ## [15.1.3] - 2026-05-17
839
+ ### Breaking Changes
840
+
841
+ - Changed `AuthBrokerClient.fetchSnapshot()` to return status-based results (`200` or `304`) instead of always returning a raw snapshot body, so callers now need to branch on `status`
842
+ - Renamed public schema utilities in `@gajae-code/ai/utils/schema` by replacing `sanitizeSchemaForGoogle`, `sanitizeSchemaForCCA`, `prepareSchemaForCCA`, and `sanitizeSchemaForMCP` with `normalizeSchemaForGoogle`, `normalizeSchemaForCCA`, and `normalizeSchemaForMCP`
843
+ - Added MCP schema normalization via `normalizeSchemaForMCP` for compatibility checks
844
+ - Removed the `StringEnum` helper from `@gajae-code/ai/utils/schema`. Use `z.enum([...])` directly; Zod's emitted JSON Schema is already wire-compatible with Google and other providers.
845
+ - Renamed the concrete SQLite credential store class from `AuthCredentialStore` to `SqliteAuthCredentialStore`. `AuthCredentialStore` is now the persistence interface implemented by both the SQLite store and the new `RemoteAuthCredentialStore`. Update `new AuthCredentialStore(db)` / `AuthCredentialStore.open(...)` call-sites to `SqliteAuthCredentialStore`; type-position uses (`store: AuthCredentialStore`) continue to work unchanged.
846
+
847
+ ### Added
848
+
849
+ - Added `onAuthError` to `StreamOptions` and wired `streamSimple()` to retry once with a replacement API key when the first provider response is a 401 before any assistant events are emitted
850
+ - Added generation-aware snapshot metadata (`generation`, `serverNowMs`, `refresher`, and `rotatesInMs`) to auth-broker snapshot responses to support client-side credential-rotation planning
851
+ - Added `transport: "pi-native"` on `Model` and the matching `streamPiNative` client. When `model.transport === "pi-native"`, `streamSimple` short-circuits the per-provider dispatch and POSTs the canonical `Context` to the auth-gateway's `POST /v1/pi/stream` endpoint. The response is SSE-framed `AssistantMessageEvent`s parsed by `readSseJson` and pushed verbatim into the local `AssistantMessageEventStream` — no wire-format translation, no partial-stripping reconstruction. Used by containerized GJC deployments and swarm extensions to route every LLM call through a credential-holding sidecar; the container never sees the real provider tokens. Server-controlled fields (`apiKey`, `signal`, `fetch`, lifecycle callbacks, the provider-session map) are stripped from the wire body — `apiKey` rides in the `Authorization` header as the gateway bearer.
852
+ - Added `POST /v1/pi/stream` to the auth-gateway. Same auth + abort + model-resolution + openai-code-compat + prefix-cache plumbing as the foreign-wire routes; only the wire-format translation is skipped. Request body is `{ modelId, context, options?, stream? }` where `context` is the canonical pi-ai `Context` and `options` is `SimpleStreamOptions` with non-serializable fields stripped. Response is SSE-framed `AssistantMessageEvent` (terminated by `data: [DONE]`) when streaming, or `{ message: AssistantMessage }` JSON when `stream: false`.
853
+ - Added Vertex AI authentication via Google Application Default Credentials from `GOOGLE_APPLICATION_CREDENTIALS`, `~/.config/gcloud/application_default_credentials.json`, or metadata server tokens, with token caching and refresh skew control via `GOOGLE_VERTEX_REFRESH_SKEW_MS`
854
+ - Added support for Anthropic image message parts with `type: "url"` and `type: "file"` sources
855
+ - Added `stopSequences` and `frequencyPenalty` to shared stream options and wired them through to OpenAI request translation
856
+ - Added optional request cancellation support to auth-broker interactions by propagating `AbortSignal` into health, snapshot, usage, and refresh calls
857
+ - Added `AuthStorage.setConfigApiKey` / `removeConfigApiKey` / `clearConfigApiKeys` for config-sourced per-provider bearers (e.g. `models.yml` `providers.<name>.apiKey`). The new tier sits between runtime `--api-key` and stored credentials in `getApiKey`/`peekApiKey` resolution, so a bearer pinned in config now beats the broker's OAuth access token. Also suppresses OAuth `account_uuid` attribution when active, since outbound auth is the explicit config bearer, not OAuth. `describeCredentialSource` reports `"config override (models.yml)"` for visibility.
858
+ - Added per-model `additional_rate_limits` parsing to `openaiOpenAI codeUsageProvider`. The OpenAI code `wham/usage` endpoint surfaces a separate `GPT-5.3-OpenAI code-Spark` rate limit (`metered_feature: openai-code_bengalfox`) on Pro accounts; these now emit dedicated `openai-code:spark:{primary,secondary}` `UsageLimit` entries with `scope.tier = "spark"`, mirroring how Anthropic exposes `anthropic:7d:sonnet` separately from the umbrella `anthropic:7d` bucket. The osx-widgets client already keyed spark detection off `limit.id.includes("spark")`; this populates that contract end-to-end.
859
+ - Added `GET /v1/usage` to the auth-broker API to expose aggregated usage reports from `AuthStorage.fetchUsageReports`
860
+ - Added auth-broker usage polling response handling that returns normalized usage reports plus generation timestamp for clients (5-min per-credential cache via `AuthStorage`)
861
+ - Added the auth-broker subsystem (`@gajae-code/ai/auth-broker`) for sharing OAuth credentials across machines without leaking refresh tokens.
862
+ - `startAuthBroker(...)` boots a `Bun.serve` HTTP server exposing `GET /v1/healthz`, `GET /v1/snapshot`, `POST /v1/credential` (upsert), `POST /v1/credential/:id/refresh`, and `POST /v1/credential/:id/disable`.
863
+ - `AuthBrokerClient` is the matching HTTP client used by remote clients.
864
+ - `RemoteAuthCredentialStore` is a client-side `AuthCredentialStore` that mirrors a broker snapshot in memory; mutating methods (`replace*`, `upsert*`, `delete*ForProvider`) throw because writes are server-side only.
865
+ - `AuthBrokerRefresher` is the background refresh loop that pre-refreshes credentials within `refreshSkewMs` and disables on definitive failure (`invalid_grant` / non-network 401-403).
866
+ - Added `AuthStorage.exportSnapshot()`, `AuthStorage.upsertCredential(provider, credential)`, `AuthStorage.forceRefreshCredentialById(id)`, and `AuthStorage.disableCredentialById(id, cause)` public methods consumed by the auth-broker server.
867
+ - Added `AuthStorageOptions.refreshOAuthCredential` override so a remote-store client can route every OAuth refresh through the broker instead of the local OAuth endpoint.
868
+ - Added `REMOTE_REFRESH_SENTINEL` (`"__remote__"`) — the wire placeholder substituted for OAuth refresh tokens in broker snapshots; clients never see the real refresh token.
869
+ - Exposed the OAuth provider catalog (`getOAuthProviders`, `OAuthProvider`, `OAuthProviderInfo`) and `refreshOAuthToken` through the package barrel so the coding-agent CLI can target them without reaching into `utils/oauth`.
870
+ - Added the auth-gateway subsystem (`@gajae-code/ai/auth-gateway`) — a forward-proxy that sits between unauthenticated clients (the macOS usage widget, llm-git, containerized GJC deployments, …) and the broker. Clients send standard provider-format requests; the gateway parses them into gjc's canonical `Context`, dispatches through pi-ai's `streamSimple()`, and translates the canonical event stream back to the matching wire format. `Authorization` is injected server-side so access tokens never leave the gateway host. Wire surface:
871
+ - `GET /healthz` — unauth liveness.
872
+ - `GET /v1/usage` — aggregated provider usage; 5-min per-credential cache via `AuthStorage.fetchUsageReports`.
873
+ - `GET /v1/models` — model catalog (scoped to providers with credentials).
874
+ - `POST /v1/chat/completions` — OpenAI chat-completions in/out.
875
+ - `POST /v1/messages` — Anthropic messages in/out (text + thinking + tool_use blocks, SSE event taxonomy preserved).
876
+ - `POST /v1/responses` — OpenAI Responses in/out (reasoning items + function_call output items, SSE pass-through).
877
+ - Added exports from `@gajae-code/ai/auth-gateway`: `startAuthGateway`, `AuthGatewayServerOptions`, `AuthGatewayBootOptions`, `AuthGatewayServerHandle`, `ModelResolver`, `DEFAULT_AUTH_GATEWAY_BIND`. Per-format `parseRequest` / `encodeResponse` / `encodeStream` triples are reachable via the `./providers/*` subpath as `openai-chat-server`, `anthropic-messages-server`, and `openai-responses-server`.
878
+ - Added `listProvidersWithEnvKey()` to enumerate every provider with an env-var fallback (used by the new migrate command in coding-agent).
879
+
880
+ ### Changed
881
+
882
+ - Changed `GET /v1/snapshot` to support generation-based polling with `If-None-Match` and `wait` for long-poll updates and to return `304` when no snapshot changes are available
883
+ - Changed Bedrock credential resolution for streaming calls to prefer environment keys, AWS profile/SSO credentials, and IMDSv2 fallback when available
884
+ - Changed auth-gateway parsing for OpenAI chat-completions and Responses to ignore unsupported SDK-only fields instead of rejecting requests
885
+ - Changed auth-gateway protocol handling to include CORS headers on responses and support browser-origin requests
886
+ - Changed prompt-cache handling to resolve cache keys from request metadata and headers and preserve them through protocol translation
887
+ - Changed Anthropic messages parsing to forward request `metadata` through to downstream execution
888
+ - Changed usage report caching to use a 5-minute per-credential TTL with jittered refresh timing to reduce usage endpoint rate-limit collisions
889
+ - Changed usage polling failure handling so transient errors continue serving the last known report instead of returning null and dropping the credential from usage aggregates after cache expiry
890
+ - Changed `sanitizeSchemaForGoogle` to normalize snake_case schema keys (such as `any_of` and `additional_properties`) to camelCase and auto-generate `propertyOrdering` for multi-property objects
891
+ - Changed strict-mode sanitization to resolve `$ref` nodes with sibling keys by inlining and merging referenced local definitions
892
+ - Changed strict-mode sanitization to flatten single-entry `allOf` nodes and remove the `allOf` wrapper
893
+ - Changed Anthropic tool schema normalization to preserve supported metadata keywords such as `$ref`, `$defs`, `$schema`, `enum`, `const`, `default`, `title`, and `nullable` instead of stripping them
894
+ - Changed string schema processing to retain only supported `format` values (`date-time`, `time`, `date`, `duration`, `email`, `hostname`, `uri`, `ipv4`, `ipv6`, `uuid`) and demote unsupported `format` values to `description` hints
895
+
896
+ ### Fixed
897
+
898
+ - Fixed OAuth credential refresh flow so concurrent manual and background refreshes now share one in-flight attempt per credential, and `RemoteAuthCredentialStore` now re-synchronizes before using near-expiring OAuth credentials
899
+ - Fixed stale-credential handling after auth failures by waiting for updated broker snapshots and refreshing suspect credentials through broker endpoints before continuing
900
+ - Fixed Google Generative AI startup behavior to throw a clear API-key-required error when no key is configured
901
+ - Fixed AWS Bedrock image message serialization to preserve base64 `source.bytes` payloads instead of decoding and rebuilding them
902
+ - Fixed Google provider error handling to extract the API-reported `error.message` from JSON response bodies when available
903
+ - Fixed `RemoteAuthCredentialStore.getUsageReport` to return the matching credential-specific usage report and coalesce parallel callers into one broker `/v1/usage` fetch
904
+ - Fixed auth-broker credential upload validation to reject the remote refresh-token sentinel and prevent storing a non-refresh value
905
+ - Fixed OpenAI Responses streaming output to emit `reasoning_summary_text` events and parse/send `summary_text` reasoning payloads
906
+ - Fixed Anthropic stop-sequence handling by trimming requests to the API limit of four entries before forwarding
907
+ - Fixed prompt caching behavior across protocol translations so cached-token usage is preserved when Anthropic and OpenAI requests are routed through each other
908
+ - Fixed Anthropic model usage fetching to retry transient `429` and `5xx` responses with exponential backoff, respecting `Retry-After` before returning failure
909
+ - Fixed auth-gateway request translation to preserve OpenAI Responses string/system message content, reasoning replay payloads, completed item text in stream item-done events, Anthropic tool-result ordering, and OpenAI Chat/Responses cached-token usage totals
910
+ - Fixed auth-gateway failure handling so unsupported request controls, upstream terminal errors, non-streaming aborts, and already-aborted client requests fail explicitly instead of being accepted, ignored, or encoded as successful HTTP 200 responses
911
+ - Fixed Gemini CLI / Antigravity tool schema normalization to run the full Cloud Code Assist pipeline, matching shared Google schema handling for union/object merging and nullable extraction
912
+ - Fixed stripped validation hints to be preserved as description spill text (`{key: value}` blocks) when `normalizeSchemaForGoogle` and `normalizeSchemaForCCA` drop unsupported schema keywords
913
+ - Fixed `sanitizeSchemaForGoogle` to collapse nullability forms (`type:'null'` and null-bearing `anyOf` variants) into `nullable` while preserving remaining variants
914
+ - Fixed `sanitizeSchemaForGoogle` to inline local `$defs` references instead of dropping `$ref`/`$defs` structure during Google schema sanitization
915
+ - Fixed `normalizeAnthropicToolSchema` to handle self-referential schemas without infinite recursion
916
+ - Fixed object schema normalization so explicit open-map declarations (`additionalProperties: true` and schema-valued `additionalProperties`) are preserved instead of being converted to closed objects
917
+ - Fixed unsupported schema constraints on arrays and strings (`maxItems`, `uniqueItems`, `pattern`, `minLength`, `maxLength`, and `minItems` when greater than 1) by demoting them into `description` rather than dropping them
918
+
919
+ ### Security
920
+
921
+ - Hardened auth-gateway bearer-token checks with constant-time comparison to avoid timing-side-channel leaks
922
+
923
+ ## [15.1.2] - 2026-05-15
924
+ ### Breaking Changes
925
+
926
+ - Rejected draft-07 tuple and dependency keywords (`items` arrays, `dependencies`, `additionalItems`) in JSON Schema validation
927
+
928
+ ### Added
929
+
930
+ - Added `responseHeaders`, `responseStatus`, and `responseRequestId` fields to `MockResponse` so mock providers can provide synthetic `ProviderResponseMetadata`
931
+ - Added `onResponse` metadata emission for mocks that sends lowercased headers and a default status of 200 before streaming when response headers are configured
932
+ - Added recursive strict-mode sanitization for array `prefixItems` entries so tuple schemas now enforce object constraints per item
933
+
934
+ ### Changed
935
+
936
+ - Normalized legacy draft-07 JSON Schema constructs used in tool parameters (`items` arrays, `additionalItems`, `definitions`, `dependencies`) to draft 2020-12 before OpenAI/Google/CCA sanitization, wire conversion, and argument validation
937
+ - Reworked OpenAI response schema adaptation to rewrite `oneOf` into `anyOf` while preserving existing `anyOf` branches
938
+ - Changed tuple array validation to validate per-index schemas from `prefixItems` and apply `items` only to remaining elements
939
+
940
+ ### Fixed
941
+
942
+ - Fixed validation of plain JSON Schema tool arguments that omitted a `$schema` URI so draft-07-shaped schemas now pass validation instead of being rejected
943
+ - Fixed tuple-array validation for legacy JSON Schema tool schemas to enforce `additionalItems: false` and per-position constraints after automatic draft upgrade
944
+ - Fixed Anthropic tool schema normalization to recurse into `prefixItems` so unsupported constraints inside tuple items are stripped in the generated input schema
945
+ - Fixed Anthropic tool-schema normalization stripping the body of explicit open `additionalProperties` (e.g. Zod's `z.record(z.string(), z.unknown())` compiling to `additionalProperties: {}`) by unconditionally overwriting it with `false`, which closed record-style fields and prevented models from supplying any key. The coding-agent's `resolve` tool exposes plan-approval titles via such a field, so Kimi K2 (and any other Anthropic-shaped provider) could not pass `extra: { title }`, blocking plan mode entirely ([#1104](https://github.com/can1357/gajae-code/issues/1104))
946
+ - Fixed Anthropic strict tool planning to leave tools with open `additionalProperties` maps non-strict instead of sending schemas Anthropic rejects.
947
+
948
+ ## [15.1.0] - 2026-05-15
949
+
950
+ ### Breaking Changes
951
+
952
+ - Removed TypeBox root exports (`Type`, `Static`, and `TSchema`) from the package entrypoint, so callers importing those symbols from `@gajae-code/ai` must migrate to `zod` or `@gajae-code/ai/types`
953
+
954
+ ### Added
955
+
956
+ - Added support for defining tool schemas with Zod (`z.object`, `z.string`, etc.) by allowing `Tool.parameters` to be either Zod schemas or legacy JSON Schema objects and converting them to provider wire format automatically
957
+ - Added package-level schema helpers in the `zod/v4` style by exporting `z` and `ZodType` from the root entrypoint
958
+ - Added a `mock` API provider via `createMockModel` to build `Model<"mock">` instances for fully in-memory, deterministic assistant streams in tests
959
+ - Added `streamMock` and `registerMockApi` so mock responses can be consumed through `stream()` and the global custom API registry without an external model backend
960
+ - Added async/sync response scripting with optional context-based handlers, and new `push()`/`reset()` controls to drive multi-turn mock interactions and inspect per-call invocation state
961
+ - Added support in mock responses for simulating tool calls, usage metadata, custom stop reasons, delayed emissions, and terminal error/aborted outcomes
962
+
963
+ ### Changed
964
+
965
+ - Changed Azure OpenAI Responses tool schema conversion to sanitize tool parameter schemas and rewrite `oneOf` branches as `anyOf` so tool calls remain compatible with Azure's schema expectations
966
+ - Changed `Static<S>` to extract a schema object’s `static` type when present, improving inferred tool argument types for non-Zod parameter definitions
967
+ - Changed `Static` typing behavior so it now infers argument types from Zod schemas and defaults to `unknown` for non-Zod JSON Schema parameter definitions
968
+ - Restored the default steady-state stream idle timeout to 120s (regressed in 15.0.0). 30s was too aggressive for reasoning models, slow proxies, and tool-call planning gaps, surfacing as repeated `Provider stream stalled while waiting for the next event` errors. Existing `PI_STREAM_IDLE_TIMEOUT_MS` / `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` overrides are unchanged.
969
+
970
+ ### Fixed
971
+
972
+ - Preserved top-level unknown fields in validated tool-call arguments so extra root properties are retained after schema coercion
973
+ - Fixed coercion for Zod `record` fields by parsing JSON-stringified record arguments into objects
974
+ - Validated legacy draft-07 JSON Schema tool parameters directly instead of converting through Zod, improving support for features like `$ref`, `definitions`, `nullable`, and `uniqueItems`
975
+ - Fixed Cloud Code Assist schema preparation to strip unsupported `propertyNames` and fall back to a minimal tool schema when schema meta-validation detects malformed keywords
976
+ - Fixed OpenAI Completions streaming to avoid treating non-output chunks (including role-only preambles) as progress events so idle-timeout watchdog behavior no longer hangs on no-op streamed chunks
977
+ - Fixed Cloud Code Assist schema compatibility checks by replacing strict AJV meta-schema validation with structural JSON Schema validation to avoid rejecting structurally valid tool schemas
978
+ - Fixed lazy built-in provider streams (`anthropic-messages`, `bedrock-converse-stream`, `cursor-agent`, `google-*`, `ollama-chat`, `openai-*`) prematurely aborting slow first-token responses with `Provider stream stalled while waiting for the next event`. The lazy-stream watchdog wrapper was treating the synthetic `start` event (yielded immediately by every provider before the model emits any tokens) as the first real item, which caused the watchdog to drop from `firstItemTimeoutMs` (100s) to `idleTimeoutMs` (30s) before the upstream model had produced anything. The shared `iterateWithIdleTimeout` now keeps `awaitingFirstItem` true until a real progress item arrives, and the lazy-stream wrapper marks `start` as a non-progress keepalive ([#1073](https://github.com/can1357/gajae-code/pull/1073) regression).
979
+ - Heal leaked Kimi K2 chat-template tool-call tokens (`<|tool_calls_section_begin|>` … `<|tool_call_argument_begin|>` … `<|tool_calls_section_end|>`) that some hosts (native `kimi-code` API, OpenRouter, Fireworks, etc.) emit into `delta.content` instead of structured `tool_calls`. The OpenAI-completions stream consumer now strips the markers from visible text, reconstructs the embedded calls as proper `toolCall` content blocks (stream-aware, token-boundary-safe), and promotes `finish_reason: stop` to `toolUse` when calls were healed.
980
+ - Fixed OpenAI-completions Kimi K2 healed-call promotion clobbering non-stop terminal finish reasons (`error`, `length`, `aborted`); promotion now only fires when the prior stop reason is the natural-completion `stop`
981
+ - Fixed OpenAI-completions duplicate Kimi tool calls when a single chunk delivers both leaked markers and a structured `delta.tool_calls`; the healer now strips visible markers but discards its synthesized calls so structured payloads remain the single source of truth
982
+ - Fixed Kimi tool-call healer synthesizing a bogus empty call when assistant text mentions a literal `<|tool_call_end|>` (or `<|tool_call_begin|>` / `<|tool_call_argument_begin|>`) outside an active `<|tool_calls_section_begin|>…<|tool_calls_section_end|>` section; the tokens now survive as text
983
+ - Fixed OpenAI-completions ignoring per-request `StreamOptions.streamFirstEventTimeoutMs` when configuring the underlying OpenAI SDK HTTP timeout, causing slow-before-headers providers to be aborted at the env default before the wrapping watchdog armed
984
+ - Fixed JSON Schema validator silently accepting values that violate `propertyNames`, `patternProperties`, `dependentRequired`, `dependencies`, `if`/`then`/`else`, `contains`, and `prefixItems`; the in-tree validator now enforces these keywords instead of falling through. `unevaluatedProperties`/`unevaluatedItems` remain permissive but log a one-time warning so tool authors are not surprised.
985
+ - Fixed recursive `$ref` schemas being treated as universally valid: the validator previously short-circuited on the second occurrence of any ref it had already seen, so nested values violating the referenced sub-schema passed. Cycle detection now keys on (ref, value-identity) pairs with a depth cap for primitive values, so genuine sub-tree violations are still caught.
986
+ - Fixed JSON Schema meta-validator accepting malformed `if`/`then`/`else` and `dependencies` keywords; each conditional sub-schema is now structurally validated and draft-07 `dependencies` accepts either a schema or a string array of dependent keys.
987
+ - Fixed Zod-emitted wire schemas dropping null-valued unknown root fields before `preserveUnknownRootFields` could snapshot them, so callers like `task.simple` no longer lose a `schema: null` argument and downstream rejection paths fire as intended.
988
+ - Fixed mock provider partial `Usage` to recompute `totalTokens` (and `cost.total` when cost components are supplied) when omitted, instead of reporting 0
989
+ - Fixed mock provider auto-generated tool-call IDs to use a per-instance counter (now reset by `reset()`), so test order no longer affects IDs across `createMockModel()` instances
990
+
991
+ ## [15.0.2] - 2026-05-15
992
+ ### Fixed
993
+
994
+ - Fixed `StreamOptions.fetch` typing to accept fetch-compatible override functions that do not expose `preconnect`, allowing custom fetch implementations to be used without type errors across runtimes
995
+ - Fixed Moonshot Kimi K2.6 forced tool calls to send `thinking: { type: "disabled" }`, avoiding `tool_choice 'specified' is incompatible with thinking enabled` 400s while preserving the requested named tool ([#1077](https://github.com/can1357/gajae-code/issues/1077)).
996
+
997
+ ## [15.0.1] - 2026-05-14
998
+ ### Breaking Changes
999
+
1000
+ - Increased the minimum Bun runtime version to `>=1.3.14` for the `@aws-?` package
1001
+
1002
+ ### Added
1003
+
1004
+ - Added `installH2Fetch` to patch `globalThis.fetch` so HTTPS requests attempt HTTP/2 over ALPN with automatic HTTP/1.1 fallback when HTTP/2 is unsupported
1005
+ - Added priority service-tier traffic to the `premiumRequests` accounting on OpenAI and OpenAI code provider providers. Sending `serviceTier: "priority"` now increments `usage.premiumRequests` by 1 per request, matching the existing GitHub Copilot premium-request budget semantics so downstream consumers (e.g. the `gjc stats` "Premium Reqs" card and `/usage`) reflect priority traffic alongside Copilot premium calls.
1006
+
1007
+ ## [15.0.0] - 2026-05-13
1008
+
1009
+ ### Added
1010
+
1011
+ - Added `AuthStorage.onCredentialDisabled(listener)` — a multi-subscriber `on/off` API for `credential_disabled` events. Returns an unsubscribe function; calling it more than once is a no-op. Multiple subscribers all receive every disable event, with synchronous and async exceptions isolated per-listener so a misbehaving subscriber cannot starve the rest of the chain. Buffer-and-replay semantics are preserved: events emitted while no listener is subscribed are buffered (FIFO, capped at 32) and replayed once to the listener that triggers the empty→non-empty transition. After every subscriber unsubscribes, subsequent disable events buffer again until the next subscribe.
1012
+
1013
+ ### Fixed
1014
+
1015
+ - Fixed OAuth credentials being silently disabled when two gjc processes (or any two `AuthStorage` instances sharing a `agent.db`) race on token refresh. Anthropic rotates refresh tokens on every use, so the loser's `invalid_grant` response previously soft-deleted the row that the winner just rotated, forcing the user to `/login` again. `#tryOAuthCredential` now re-reads the row from disk before declaring a definitive failure: if the persisted `refresh` differs from the snapshot it tried, the peer-rotated credential is reloaded and the request retries against the fresh token instead of disabling the live row.
1016
+ - Closed a remaining race window in OAuth refresh-failure handling: between re-reading the credential row to check for peer rotation and the subsequent soft-delete, another process could still complete a refresh and rotate the row, leaving us to disable the freshly-rotated credential by `id`. The disable now runs as a single CAS update conditioned on the row's `data` still matching the snapshot we tried to refresh, and on `disabled_cause IS NULL`. If the CAS reports 0 rows changed (peer rotation, or row already disabled by a concurrent failure on the same snapshot), we reload from disk and retry instead of mutating the wrong row or emitting a spurious `credential_disabled` event.
1017
+ ### Changed
1018
+ - Lowered the default steady-state stream idle timeout from 120s to 30s while preserving the existing environment overrides.
1019
+
1020
+ ### Fixed
1021
+ - Lazy built-in provider streams now enforce the shared idle watchdog and abort stalled provider requests, so session auto-retry can continue after transient network drops instead of remaining stuck. Caller aborts still terminate as aborted.
1022
+
1023
+ ## [14.9.3] - 2026-05-10
1024
+
1025
+ ### Fixed
1026
+ - Anthropic provider now retries generic transient connect failures (`unable to connect`, `fetch failed`, `connection error`, etc.) by falling back to the shared `isRetryableError` allowlist after the provider-specific patterns. Previously these errors bypassed the hand-curated regex in `isProviderRetryableError` and aborted the stream on the first attempt, while the OpenAI SDK and OpenAI code `fetchWithRetry` paths already handled them.
1027
+
1028
+ ## [14.9.0] - 2026-05-10
1029
+
1030
+ ### Added
1031
+
1032
+ ### Fixed
1033
+ - Fixed silent forwarding of image content (for example Python plot output rendered in the terminal) to models without vision support, which produced opaque 404 errors from upstream. Image blocks are now stripped and replaced with a `[image omitted: model does not support vision]` placeholder for non-vision models, including tool-result payloads ([#967](https://github.com/can1357/gajae-code/issues/967), [#968](https://github.com/can1357/gajae-code/issues/968)).
1034
+
1035
+ - Added `AuthStorage` `onCredentialDisabled` callback (sync or async) so embedders can react when a credential is automatically disabled (e.g. OAuth refresh fails with `invalid_grant`) — useful for surfacing a banner or auto-launching a re-login flow instead of letting the credential silently disappear. Sync throws and async rejections are both caught and logged so a misbehaving subscriber cannot break the disable path.
1036
+ - Added Anthropic OAuth `account.uuid` and `account.email_address` extraction from the `/v1/oauth/token` exchange and refresh responses; both `AnthropicOAuthFlow.exchangeToken()` and `refreshAnthropicToken()` now populate `OAuthCredentials.{accountId, email}` so downstream consumers can attribute requests to the authenticated account without a separate `/api/oauth/profile` round-trip.
1037
+ - Added `onSseEvent` stream diagnostics so HTTP SSE providers can expose raw SSE frames without changing parsed model output.
1038
+ - Added `streamIdleTimeoutMs` option (and `PI_STREAM_IDLE_TIMEOUT_MS` env override; `PI_OPENAI_STREAM_IDLE_TIMEOUT_MS` remains a backward-compatible alias) for a steady-state inter-event watchdog. Set to `0` to disable.
1039
+ - Added a semantic-progress predicate to OpenAI Responses and OpenAI code SSE/WebSocket transports so `response.in_progress`-style keepalives no longer reset the idle deadline on stalled tool calls.
1040
+
1041
+ ### Changed
1042
+
1043
+ - Anthropic streams now enforce a steady-state idle timeout (defaults to 120s, same control as `PI_STREAM_IDLE_TIMEOUT_MS`) in addition to the first-event watchdog. Long-running responses that go fully silent between events will now surface as `Anthropic stream stalled while waiting for the next event` instead of hanging.
1044
+ - Fixed `resolveAnthropicMetadataUserId()` to accept JSON-format `user_id` values that match real Anthropic Code's payload shape (`{ device_id, account_uuid, session_id, ... }` from `services/api/anthropic-model.ts:getAPIMetadata`). Previously only the synthetic `user_<hex>_account_<uuid>_session_<uuid>` cloaking format was accepted on OAuth, which caused stable session-keyed metadata supplied by callers to be discarded and replaced with fresh random entropy on every request — defeating session-count attribution on the Anthropic model OAuth path.
1045
+
1046
+ ## [14.8.0] - 2026-05-09
1047
+
1048
+ ### Fixed
1049
+ - Fixed Gemini 3 Pro thinking metadata so `medium` effort is rejected with the expected error instead of being silently accepted: `ThinkingConfig` now carries an optional explicit `levels` list that survives `expandEffortRange`, letting non-contiguous supported sets (e.g. `[low, high]`) round-trip through enrichment.
1050
+ - Fixed Kimi Code OAuth expiry handling to refresh access tokens 5 minutes before server expiry, avoiding daily 401s from using tokens right up to the cutoff.
1051
+ - Fixed OpenAI Responses custom tool replay to preserve custom tool call item IDs with the `ctc_` prefix instead of rewriting them as `fc_` function-call IDs ([#977](https://github.com/can1357/gajae-code/issues/977)).
1052
+
1053
+ ## [14.7.6] - 2026-05-07
1054
+
1055
+ ### Added
1056
+
1057
+ - Added `hideThinkingSummary` option to `SimpleStreamOptions`. When true, `streamSimple` requests that the underlying provider omit reasoning/thinking summaries: Anthropic receives `thinking.display = "omitted"` (where supported), and OpenAI Responses / Azure / OpenAI code providers leave `reasoning.summary` unset so the server skips emitting the human-readable summary stream entirely.
1058
+
1059
+ ### Changed
1060
+
1061
+ - Changed OpenAI Responses, Azure OpenAI Responses, and OpenAI code provider providers to omit `reasoning.summary` from requests when `reasoningSummary` is explicitly `null` (previously fell back to `"auto"`).
1062
+ ## [14.7.5] - 2026-05-07
1063
+
1064
+ ### Added
1065
+
1066
+ - Added `OpenAICompat.supportsMultipleSystemMessages` so chat-completions hosts can opt out of separate leading system blocks. Auto-detected as `true` for OpenAI, Azure, OpenRouter, Cerebras, Together, Fireworks, Groq, DeepSeek, Mistral, xAI, Z.ai, GitHub Copilot, and Zenmux; `false` for MiniMax, Alibaba Dashscope, and Qwen Portal whose chat templates reject follow-up system messages. Unknown OpenAI-compatible hosts (custom vLLM/local) default to `false`; users can opt back in via `compat.supportsMultipleSystemMessages: true`.
1067
+
1068
+ ### Fixed
1069
+
1070
+ - Fixed strict-template OpenAI-compatible hosts (e.g. Qwen 3.5+ via vLLM, MiniMax) rejecting follow-up `system`/`developer` messages by coalescing ordered system prompts into a single block joined by `\n\n` when `compat.supportsMultipleSystemMessages` is false. Canonical hosts continue to receive separate blocks so KV-cache reuse stays effective when only the trailing prompt changes ([#958](https://github.com/can1357/gajae-code/issues/958)).
1071
+
1072
+ ## [14.7.2] - 2026-05-06
1073
+
1074
+ ### Fixed
1075
+
1076
+ - Fixed VLLM model discovery to use `max_model_len` as the context window when the endpoint reports it.
1077
+ - Fixed custom Ollama Cloud/local-proxy model aliases (for example `deepseek-v4-pro:cloud`) to inherit bundled cache-pricing metadata when the upstream model is known ([#937](https://github.com/can1357/gajae-code/issues/937)).
1078
+ - Fixed local Ollama model discovery to apply `/api/show` thinking and vision capabilities in addition to native context windows ([#928](https://github.com/can1357/gajae-code/issues/928)).
1079
+
1080
+ ## [14.7.0] - 2026-05-04
1081
+ ### Breaking Changes
1082
+
1083
+ - Changed `Context.systemPrompt` from a string to `string[]`, so callers must now pass an array of prompts instead of a single string
1084
+ - Changed behavior will throw at runtime for non-array system prompts because request builders now normalize system prompts as an array
1085
+
1086
+ ### Added
1087
+
1088
+ - Added support for multiple system prompts by changing `Context.systemPrompt` to an ordered string array and preserving provider-appropriate instruction precedence
1089
+
1090
+ ### Changed
1091
+
1092
+ - Changed request builders for Anthropic, OpenAI, Bedrock, Azure, Cursor, Google, and Ollama to propagate every non-empty system prompt entry without demoting durable instructions into ordinary conversation turns
1093
+
1094
+ ### Fixed
1095
+
1096
+ - Filtered out empty normalized system prompts so blank entries are no longer sent to providers
1097
+ - Removed blank system prompt strings from provider payloads to avoid unnecessary empty instruction messages
1098
+
1099
+ ## [14.6.6] - 2026-05-04
1100
+
1101
+ ### Added
1102
+
1103
+ - Added always-on OpenRouter response caching (1h TTL) by sending `X-OpenRouter-Cache: true` and `X-OpenRouter-Cache-TTL: 3600` on every OpenRouter request — identical requests replay from OpenRouter's edge cache for free. https://openrouter.ai/docs/features/response-caching
1104
+
1105
+ ## [14.6.4] - 2026-05-03
1106
+
1107
+ ### Fixed
1108
+
1109
+ - Fixed OpenAI code provider websocket continuations to retry with full context when `previous_response_id` expires server-side instead of surfacing `previous_response_not_found`.
1110
+
1111
+ ## [14.6.2] - 2026-05-03
1112
+ ### Added
1113
+
1114
+ - Added `EventStream.fail(err)` method to terminate the async iterator with an error, enabling consumers to catch stream-level failures via `for await` without hanging
1115
+
1116
+ ### Fixed
1117
+
1118
+ - Fixed OpenAI Responses tool schema conversion to rewrite non-strict `oneOf` unions to `anyOf` before sending tools to the Responses API ([#920](https://github.com/can1357/gajae-code/issues/920))
1119
+
1120
+ ## [14.6.0] - 2026-05-02
1121
+
1122
+ ### Added
1123
+
1124
+ - Added `disableReasoning` to stream and OpenAI completion options to force reasoning off for models that support it, sending `reasoning: { enabled: false }` for OpenRouter-compatible requests
1125
+ - Added `thinkingDisplay` option to Anthropic options to control whether adaptive and explicit reasoning is returned as `summarized` or `omitted`
1126
+ - Added Anthropic model compatibility flags `supportsEagerToolInputStreaming` and `supportsLongCacheRetention` for API-capability-specific request behavior
1127
+
1128
+ ### Changed
1129
+
1130
+ - Changed Anthropic request payloads to send `thinking: { type: "disabled" }` when `thinkingEnabled` is explicitly `false` on reasoning-enabled models
1131
+ - Changed Anthropic cache retention handling so `cacheRetention: "long"` now uses `ttl: "1h"` only for canonical Anthropic endpoints with long-cache support
1132
+ - Changed Anthropic tool schema generation to include `eager_input_streaming` only on models that advertise support
1133
+ - Changed Anthropic OAuth login flow to include browser fallback guidance and richer error context when token exchange or refresh fails
1134
+
1135
+ ### Fixed
1136
+
1137
+ - Fixed Anthropic non-thinking requests to include the caller-provided `temperature` value in request payloads
1138
+ - Fixed Anthropic `anthropic-model-opus-4-7` non-thinking payloads to omit sampling fields (`temperature`, `top_p`, and `top_k`)
1139
+ - Fixed OpenAI code provider base URL normalization so configured base URLs with or without `/openai-code` or `/openai-code/responses` now resolve to `/openai-code/responses`
1140
+ - Fixed OpenAI code provider websocket handling to parse JSON from non-string message payloads including `ArrayBuffer`, typed arrays, and `Blob` values
1141
+ - Fixed OpenAI code provider websocket handshakes to replace stale `openai-beta` values with the websocket beta and avoid sending request-body headers over websocket transport
1142
+ - Fixed abort tracking so caller-initiated cancellations are treated as user aborts even after local watchdog timeouts, preventing unintended automatic retries
1143
+ - Fixed Anthropic stream handling to parse raw SSE envelopes directly, ignore unrelated events, and repair malformed JSON in SSE payloads
1144
+ - Fixed Anthropic streaming to emit an explicit error when the SSE stream ends without a `message_stop` event
1145
+ - Fixed OpenAI code provider websocket continuations to send true `previous_response_id` deltas for `store: false` transcripts, expose request stats, and default text verbosity to `low` unless explicitly overridden.
1146
+ - Fixed OpenAI code provider websocket append reuse after `response.completed` terminal events.
1147
+
1148
+ ## [14.5.14] - 2026-05-01
1149
+ ### Added
1150
+
1151
+ - Added package-level `google-gemini-headers` exports (`getGeminiCliHeaders`, `getGeminiCliUserAgent`, `getAntigravityHeaders`, `extractRetryDelay`, and `ANTIGRAVITY_SYSTEM_INSTRUCTION`) for header and retry handling reuse without importing full Google providers
1152
+
1153
+ ### Changed
1154
+
1155
+ - Changed package exports and streaming/provider wiring to load heavy Google/Kimi/GitLab/synthetic provider modules lazily through `register-builtins`, reducing startup import overhead from optional provider SDKs
1156
+
1157
+ ### Fixed
1158
+
1159
+ - Fixed DeepSeek V4 tool-call follow-up 400 errors from three root causes:
1160
+ - Mapped `reasoning_effort` "xhigh" to "max" for DeepSeek-family models on any provider (NVIDIA, OpenCode-Go, etc.), not just `deepseek`
1161
+ - Recovered `reasoning_content` from thinking blocks with valid signatures that were filtered by the non-empty-text check
1162
+ - Added empty-string fallback when `reasoning_content` is genuinely absent (e.g. proxy-stripped) but the provider requires the field
1163
+
1164
+ ## [14.5.13] - 2026-05-01
1165
+
1166
+ ### Breaking Changes
1167
+
1168
+ - Removed `utils/oauth` re-exports from the package entrypoint, so OAuth helper imports from the root module must be updated
1169
+
1170
+ ## [14.5.10] - 2026-04-30
1171
+
1172
+ ### Added
1173
+
1174
+ - Added provider response metadata callbacks for Anthropic and OpenAI streaming requests.
1175
+
1176
+ ## [14.5.9] - 2026-04-30
1177
+
1178
+ ### Added
1179
+
1180
+ - Added `usage.reasoningTokens` to OpenAI and Google usage output when providers report reasoning/thinking tokens
1181
+ - Added `usage.cttl.ephemeral5m` and `usage.cttl.ephemeral1h` to report Anthropic cache-write TTL token buckets
1182
+ - Added `usage.server.webSearch` and `usage.server.webFetch` to report Anthropic server tool-call request counts
1183
+
1184
+ ### Fixed
1185
+
1186
+ - Fixed OpenAI usage attribution to avoid double-counting `reasoning_tokens` in output totals
1187
+ - Fixed Anthropic streaming usage handling so a previously populated cache TTL breakdown is preserved when later events omit `cache_creation`
1188
+
1189
+ ## [14.5.4] - 2026-04-28
1190
+
1191
+ ### Changed
1192
+
1193
+ - Changed OpenAI custom Lark grammar payloads to strip comments and blank lines before sending provider requests.
1194
+
1195
+ ### Fixed
1196
+
1197
+ - Fixed OpenAI code provider GPT model pricing by inheriting matching OpenAI catalog rates for zero-priced discovered OpenAI code entries.
1198
+
1199
+ ## [14.5.3] - 2026-04-27
1200
+
1201
+ ### Added
1202
+
1203
+ - Added `fireworks` as a supported provider with API key login flow and credential storage
1204
+ - Added Fireworks model catalog support with `fireworks`-scoped openai-completions models `glm-5`, `glm-5.1`, `kimi-k2.5`, `kimi-k2.6`, and `minimax-m2.7`
1205
+ - Added built-in discovery wiring so providers with base URL `api.fireworks.ai` are recognized as OpenAI-compatible and can use streaming token control
1206
+
1207
+ ### Changed
1208
+
1209
+ - Updated the built-in model catalog to use corrected `contextWindow` and `maxTokens` values for many existing models instead of placeholder limits
1210
+ - Updated several model cost entries, including cache-read pricing, to corrected values
1211
+
1212
+ ### Fixed
1213
+
1214
+ - Fixed Fireworks request formatting by translating between public model IDs and API wire IDs when sending OpenAI-completions requests
1215
+ - Fixed OpenAI-compatible model parameter handling for Fireworks by allowing `max_tokens` to be sent during requests
1216
+
1217
+ ## [14.5.1] - 2026-04-26
1218
+
1219
+ ### Fixed
1220
+
1221
+ - Fixed NVIDIA NIM DeepSeek-V4 models leaking chat-template tool-call markers (e.g. `<|DSML|tool_calls|>`) into visible response text by stripping the special tokens from streamed `delta.content` ([#798](https://github.com/can1357/gajae-code/issues/798))
1222
+
1223
+ ## [14.4.0] - 2026-04-26
1224
+
1225
+ ### Added
1226
+
1227
+ - Added an `examples` option to `StringEnum` to include example values in the generated schema
1228
+
1229
+ ### Changed
1230
+
1231
+ - Changed Anthropic tool schema generation to strip unsupported schema fields (including `patternProperties`), add `additionalProperties: false` for object types, and apply Anthropic strict-mode limits when marking tools as strict
1232
+ - Changed Anthropic strict tool planning to cap strict `tools` at twenty entries and convert excess optional/union parameters to nullable schemas to stay within provider constraints
1233
+
1234
+ ### Fixed
1235
+
1236
+ - Fixed Anthropic tool schema compilation failures by keeping the `write` tool out of the strict-tool allowlist when the full coding-agent tool set is active
1237
+ - Fixed Anthropic 400 `tools.*.custom: For 'object' type, property 'minItems' is not supported` by stripping `minItems` from object-shaped JSON schema nodes (array nodes still keep supported `minItems` values)
1238
+ - Fixed Anthropic tool schemas that used tuple-style arrays by stripping unsupported `maxItems` and only preserving provider-supported `minItems` values
1239
+ - Fixed Anthropic and OpenRouter Anthropic tool calls that previously failed with `compiled grammar is too large` by retrying automatically without strict tool schemas and reusing non-strict mode for subsequent requests in the same provider session
1240
+ - Fixed parsing of JSON tool arguments containing raw control characters inside string values (such as embedded newlines) by escaping them before JSON parsing
1241
+ - Fixed `validateToolArguments` to accept stringified objects and arrays that include literal control characters inside string fields
1242
+ - Fixed OpenAI code provider Spark OAuth selection to fall back to non-Pro accounts when no ChatGPT Pro account is connected, so users without a Pro account can still attempt Spark requests in case the server permits access.
1243
+
1244
+ ## [14.3.0] - 2026-04-25
1245
+
1246
+ ### Added
1247
+
1248
+ - Added support for Anthropic model Opus 4.7 (`anthropic-model-opus-4-7`) model ([#726](https://github.com/can1357/gajae-code/issues/726))
1249
+ - Suppresses sampling parameters (temperature/top_p/top_k) that Opus 4.7 rejects
1250
+ - Enables `display: "summarized"` for adaptive thinking to restore visible thinking content
1251
+
1252
+ ### Fixed
1253
+
1254
+ - Fixed Cursor provider losing conversation history on follow-up turns (model responding "this appears to be the start of our session") by populating `ConversationStateStructure.rootPromptMessagesJson` with JSON blob IDs for the system prompt plus prior user/assistant/tool-result messages. Cursor's server builds the model prompt from `rootPromptMessagesJson`, not from the protobuf `turns[]` tree, so sending only the system prompt there caused prior turns to be dropped
1255
+ - Fixed Cursor provider multi-turn conversations failing with `Connect error internal: Blob not found` on the second message by storing `ConversationStateStructure.turns`, `AgentConversationTurnStructure.user_message`, and `AgentConversationTurnStructure.steps` as content-addressed blob IDs in the KV store (matching the existing handling for `rootPromptMessagesJson`) rather than sending the raw serialized bytes inline ([#678](https://github.com/can1357/gajae-code/issues/678))
1256
+
1257
+ ## [14.2.1] - 2026-04-24
1258
+
1259
+ ### Fixed
1260
+
1261
+ - Fixed OpenAI code provider Spark OAuth selection to require a verified ChatGPT Pro account instead of falling back to Plus or unknown-plan accounts.
1262
+
1263
+ ## [14.2.0] - 2026-04-23
1264
+
1265
+ ### Added
1266
+
1267
+ - Added `gpt-5.5` to the built-in model catalog for both OpenAI Responses (`openai`) and local `litellm` (`openai-completions`) providers
1268
+ - Added `gpt-image-2` to the `litellm` built-in model catalog
1269
+ - Added `isCopilotTransientModelError()` and `callWithCopilotModelRetry()` helpers in `utils/retry` that detect GitHub Copilot's intermittent `HTTP 400 model_not_supported` responses for preview models (`gpt-5.3-openai-code`, `gpt-5.4`, `gpt-5.4-mini`, ...) and retry the request up to three times with backoff. OpenAI Responses, OpenAI Completions, and Anthropic provider paths now participate in this retry when the model is served through Copilot.
1270
+ - Added OpenAI Responses custom-tool grammar support for patch-envelope `apply_patch` calls, including freeform streaming, history replay, and forced tool-choice mapping to the custom wire name.
1271
+
1272
+ ### Changed
1273
+
1274
+ - Updated built-in model metadata with revised `contextWindow`, `maxTokens`, and pricing values for existing entries
1275
+ - Changed generated model policies to assign `applyPatchToolType: "freeform"` for first-party GPT-5 OpenAI Responses and OpenAI code models, so regenerated `models.json` preserves the `apply_patch` custom-tool metadata.
1276
+ - Renamed `rewriteCopilotAuthError` to `rewriteCopilotError` and extended it to rewrite `HTTP 400 model_not_supported` after retries are exhausted with guidance about Copilot's OAuth-client-specific rollout gap (see opencode#13313).
1277
+
1278
+ ### Fixed
1279
+
1280
+ - Fixed Amazon Bedrock proxy handling to honor lowercase `http_proxy`, `https_proxy`, and `all_proxy` environment variables when using HTTP/1 fallback
1281
+ - Fixed Amazon Bedrock streaming behind corporate HTTP proxies by using a proxy-aware HTTP/1 transport when `HTTPS_PROXY`, `HTTP_PROXY`, or `ALL_PROXY` is configured, including AWS SSO credential calls.
1282
+ - Fixed Amazon Bedrock requests to retry once with HTTP/1 when the AWS SDK's default HTTP/2 transport fails before streaming begins.
1283
+ - Fixed OpenAI Responses streaming to display thinking tokens from local providers (llama.cpp, etc.) that send raw `reasoning_text.delta` events and empty `summary` arrays in `output_item.done`. Previously, thinking content was silently dropped during streaming while non-streaming mode worked correctly.
1284
+ - Synced the bundled OpenCode Go catalog with the current docs so `kimi-k2.6`, `mimo-v2.5`, and `mimo-v2.5-pro` appear in offline/default model lists.
1285
+
1286
+ ## [14.1.3] - 2026-04-17
1287
+
1288
+ ### Fixed
1289
+
1290
+ - Preserved user-provided `session_id` and `x-client-request-id` headers in OpenAI Responses requests instead of overriding them with automatic session-derived values
1291
+ - Stopped sending `session_id` and `x-client-request-id` headers for OpenAI Responses requests when `cacheRetention` is set to `none`
1292
+ - Fixed direct OpenAI Responses requests to send `session_id` and `x-client-request-id` from the same session-derived value as `prompt_cache_key`, improving prompt cache affinity for append-only sessions
1293
+
1294
+ ## [14.1.1] - 2026-04-14
1295
+
1296
+ ### Added
1297
+
1298
+ - Added `toolStrictMode` compatibility option (`"all_strict"` or `"none"`) to OpenAI-compatible model config to force tool schemas to be sent uniformly strict, uniformly non-strict, or keep mixed per-tool behavior
1299
+
1300
+ ### Changed
1301
+
1302
+ - Changed Cerebras OpenAI-compatible providers to default `toolStrictMode` to `"all_strict"` unless explicitly overridden
1303
+
1304
+ ### Fixed
1305
+
1306
+ - Fixed OpenAI Completions handling for providers that reject mixed `strict` flags by automatically retrying with non-strict tool schemas when an initial all-strict tool request fails with strict-format 400/422 errors
1307
+ - Fixed OpenAI-completions error reporting by including captured JSON error body details such as type, param, and code when a request fails without a body in the thrown SDK error
1308
+ - Fixed shell execution failure responses to preserve all result fields when sanitizing, preventing truncated metadata in stream results
1309
+ - Fixed context overflow detection to recognize `model_context_window_exceeded` from z.ai / GLM providers, preventing infinite retry loops when context window is exceeded ([#638](https://github.com/can1357/gajae-code/issues/638))
1310
+ - Fixed strict tool schema enforcement to preserve `additionalProperties: false` and required keys for reused nested object schemas, preventing invalid `todo_write` function schemas in OpenAI code/OpenAI requests
1311
+ - Fixed GitHub Copilot reasoning regressions by preserving GPT-5.x / Anthropic model 4.x reasoning controls instead of stripping them from requests ([#773](https://github.com/can1357/gajae-code/issues/773))
1312
+
1313
+ ## [14.1.0] - 2026-04-11
1314
+
1315
+ ### Added
1316
+
1317
+ - Added `accountId` to usage report metadata
1318
+
1319
+ ### Changed
1320
+
1321
+ - Changed usage parsing to emit a usage report with available fields when parsing fails, rather than returning null
1322
+
1323
+ ### Fixed
1324
+
1325
+ - Fixed `planType` resolution to fall back to the raw payload `plan_type` when parsed value is absent
1326
+ - Fixed usage metadata `raw` fallback to preserve the original payload when parsed raw output is missing
1327
+
1328
+ ## [14.0.5] - 2026-04-11
1329
+
1330
+ ### Changed
1331
+
1332
+ - Replaced GitHub Copilot authentication from VSCode extension impersonation to the opencode OAuth flow, eliminating TOS concerns. Existing users will need to re-authenticate once with `/login github-copilot`.
1333
+ - Simplified Copilot token handling: GitHub OAuth token is used directly for all API requests (no JWT exchange or refresh cycle).
1334
+ - Changed GitHub Copilot API base URL from `api.individual.githubcopilot.com` to `api.githubcopilot.com`.
1335
+ - Updated default OpenAI stream idle timeout to 120,000 milliseconds to keep stream generation alive longer
1336
+
1337
+ ### Fixed
1338
+
1339
+ - Fixed duplicate synthetic tool results being generated when a real tool result appears later in message history
1340
+ - Fixed GitHub Copilot `/models` discovery to unwrap structured OAuth credentials before sending the bearer token, preserving dynamic catalog refresh for OAuth-backed callers.
1341
+
1342
+ ### Removed
1343
+
1344
+ - Removed Copilot JWT proxy-ep base URL resolution (no longer needed with opencode auth).
1345
+
1346
+ ## [14.0.3] - 2026-04-09
1347
+
1348
+ ### Fixed
1349
+
1350
+ - Fixed Ollama discovery cache normalization so cached models upgrade to the OpenAI Responses transport after the provider change
1351
+
1352
+ ## [14.0.0] - 2026-04-08
1353
+
1354
+ ### Breaking Changes
1355
+
1356
+ - Removed `coerceNullStrings` function and its automatic null-string coercion behavior from JSON parsing
1357
+
1358
+ ### Added
1359
+
1360
+ - Added support for OpenRouter provider with strict mode detection
1361
+ - Added automatic cleaning of literal escape sequences (`\n`, `\t`, `\r`) in JSON parsing to handle LLM encoding confusion
1362
+ - Added support for healing JSON with trailing junk after balanced containers (e.g., `]\n</invoke>`)
1363
+ - Added `OPENAI_CODE_STARTUP_EVENT_CHANNEL` constant and `OpenAI codeStartupEvent` type for monitoring OpenAI code provider initialization status
1364
+ - Added automatic healing of malformed JSON with single-character bracket errors at the end of strings, improving LLM tool argument parsing robustness
1365
+
1366
+ ## [13.19.0] - 2026-04-05
1367
+
1368
+ ### Fixed
1369
+
1370
+ - Fixed GitHub Copilot model context window detection by correcting fallback priority for maxContextWindowTokens and maxPromptTokens
1371
+ - Fixed Gemini 2.5 Pro context window detection in GitHub Copilot model limits test
1372
+ - Fixed Anthropic model Opus 4.6 context window detection in GitHub Copilot model limits test
1373
+ - Fixed Anthropic streaming to suppress transient SDK console errors for malformed SSE keep-alive frames so the TUI only shows surfaced provider errors
1374
+
1375
+ - Added environment-based credential fallback for the OpenAI code provider provider.
1376
+
1377
+ ## [13.17.6] - 2026-04-01
1378
+
1379
+ ### Fixed
1380
+
1381
+ - Fixed Anthropic first-event timeouts to exclude stream connection setup from the watchdog, preserve timeout-specific retry classification after local aborts, and reset retry state cleanly between attempts
1382
+
1383
+ ## [13.17.5] - 2026-04-01
1384
+
1385
+ ### Changed
1386
+
1387
+ - Increased default first-event timeout from 15s to 45s to better accommodate longer request setup times
1388
+ - Modified first-event watchdog to inherit idle timeout when it exceeds the default, ensuring consistent timeout behavior across different configurations
1389
+
1390
+ ### Fixed
1391
+
1392
+ - Fixed first-event watchdog initialization timing so it no longer starts before the actual stream request is created, preventing premature timeouts during request setup
1393
+ - Fixed first-event watchdog timing so OpenAI-family providers no longer count slow request setup against the first streamed event timeout, and raised the default first-event timeout to avoid false aborts after long tool turns
1394
+
1395
+ ## [13.17.2] - 2026-04-01
1396
+
1397
+ ### Fixed
1398
+
1399
+ - Fixed OpenAI-family first-event timeouts to preserve provider-specific timeout errors for retry classification instead of flattening them to generic aborts ([#591](https://github.com/can1357/gajae-code/issues/591))
1400
+
1401
+ ## [13.17.1] - 2026-04-01
1402
+
1403
+ ### Added
1404
+
1405
+ - Added `thinkingSignature` field to thinking content blocks to preserve the original reasoning field name (e.g., `reasoning_text`, `reasoning_content`) for accurate follow-up requests
1406
+ - Added first-event timeout detection for streaming responses to abort stuck requests before user-visible content arrives
1407
+ - Added `PI_STREAM_FIRST_EVENT_TIMEOUT_MS` environment variable to configure first-event timeout (defaults to 15 seconds or idle timeout, whichever is lower)
1408
+
1409
+ ### Changed
1410
+
1411
+ - Changed thinking block handling to track and distinguish between different reasoning field types, enabling proper field name preservation across multiple turns
1412
+
1413
+ ### Fixed
1414
+
1415
+ - Fixed Anthropic stream timeout errors to be properly retried by recognizing first-event timeout messages
1416
+ - Fixed stream stall detection to distinguish between first-event timeouts and idle timeouts, enabling faster recovery for stuck connections
1417
+
1418
+ ### Added
1419
+
1420
+ - Added Vercel AI Gateway to `/login` providers for interactive API key setup
1421
+
1422
+ ### Fixed
1423
+
1424
+ - Fixed `gjc commit` failing with HTTP 400 errors when using reasoning-enabled models on OpenAI-compatible endpoints that don't support the `developer` role (e.g., GitHub Copilot, custom proxies). Now falls back to `system` role when `developer` is unsupported.
1425
+
1426
+ ## [13.17.0] - 2026-03-30
1427
+
1428
+ ### Changed
1429
+
1430
+ - Bumped zai provider default model from glm-4.6 to glm-5.1
1431
+
1432
+ ## [13.16.5] - 2026-03-29
1433
+
1434
+ ### Added
1435
+
1436
+ - Added Gemma 3 27B model support for Google Generative AI
1437
+
1438
+ ### Changed
1439
+
1440
+ - Updated Kwaipilot KAT-Coder-Pro V2 model display name and pricing information
1441
+ - Updated Kwaipilot KAT-Coder-Pro V2 context window from 222,222 to 256,000 tokens and max tokens from 8,888 to 80,000
1442
+
1443
+ ### Fixed
1444
+
1445
+ - Fixed normalizeAnthropicBaseUrl returning empty string instead of undefined when baseUrl is empty
1446
+
1447
+ ## [13.16.4] - 2026-03-28
1448
+
1449
+ ### Added
1450
+
1451
+ - Added support for Groq Compound and Compound Mini models with extended context window (131K tokens) and configurable thinking levels
1452
+ - Added support for OpenAI GPT-OSS-Safeguard-20B model with reasoning capabilities across multiple providers
1453
+ - Added support for Kwaipilot KAT-Coder-Pro V2 model across Kilo, NanoGPT, and OpenRouter providers
1454
+ - Added support for GLM-5.1 model with extended context window (200K tokens) and max output of 131K tokens
1455
+ - Added support for Qwen3.5-27B-Musica-v1 model
1456
+ - Added support for zai-org/glm-5.1 model with reasoning capabilities
1457
+ - Added support for Sapiens AI Agnes-1.5-Lite model with multimodal input (text and image) and reasoning
1458
+ - Added support for Venice openai-gpt-54-mini model
1459
+
1460
+ ### Changed
1461
+
1462
+ - Updated Qwen QwQ 32B max tokens from 16,384 to 40,960 across multiple providers
1463
+ - Updated OpenAI GPT-OSS-Safeguard-20B model name to 'Safety GPT OSS 20B' and enabled reasoning capabilities
1464
+ - Updated OpenAI GPT-OSS-Safeguard-20B context window from 222,222 to 131,072 tokens and max tokens from 8,888 to 65,536
1465
+ - Updated OpenRouter Qwen QwQ 32B pricing: input from 0.2 to 0.19, output from 1.17 to 1.15, cache read from 0.1 to 0.095
1466
+ - Updated OpenRouter Anthropic model 3.5 Sonnet pricing: input from 0.45 to 0.42, cache read from 0.225 to 0.21
1467
+
1468
+ ## [13.16.3] - 2026-03-28
1469
+
1470
+ ### Changed
1471
+
1472
+ - Modified OAuth credential saving to preserve unrelated identities instead of replacing all credentials for a provider
1473
+ - Updated credential identity resolution to use provider context for more accurate email deduplication
1474
+
1475
+ ### Fixed
1476
+
1477
+ - Fixed OAuth credential updates to replace matching credentials in-place rather than creating disabled rows, preventing unbounded accumulation of soft-deleted credentials
1478
+
1479
+ ## [13.15.0] - 2026-03-23
1480
+
1481
+ ### Added
1482
+
1483
+ - Added `isUsageLimitError()` to `rate-limit-utils` as a single source of truth for detecting usage/quota limit errors across all providers
1484
+
1485
+ ### Fixed
1486
+
1487
+ - Fixed lazy stream forwarding to properly handle final results from source streams with `result()` methods
1488
+ - Fixed lazy stream error handling to convert iterator failures into terminal error results instead of silently failing
1489
+ - Fixed `parseRateLimitReason` to recognize "usage limit" in error messages and correctly classify them as `QUOTA_EXHAUSTED`
1490
+ - Fixed OpenAI code `fetchWithRetry` retrying 429 responses for `usage_limit_reached` errors for up to 5 minutes instead of returning immediately for credential switching
1491
+ - Removed `usage.?limit` from `TRANSIENT_MESSAGE_PATTERN` in retry utils since usage limits are not transient and require credential rotation
1492
+ - Fixed `parseRateLimitReason` not recognizing "usage limit" in OpenAI code error messages, causing incorrect fallback to `UNKNOWN` classification instead of `QUOTA_EXHAUSTED`
1493
+
1494
+ ## [13.14.2] - 2026-03-21
1495
+
1496
+ ### Changed
1497
+
1498
+ - Updated thinking configuration format from `levels` array to `minLevel` and `maxLevel` properties for improved clarity
1499
+ - Corrected context window from 400000 to 272000 tokens for GPT-5.4 mini and nano variants on OpenAI code transport
1500
+ - Normalized GPT-5.4 variant priority handling to use parsed variant instead of special-casing raw model IDs
1501
+ - Added support for `mini` variant in OpenAI model parsing regex
1502
+
1503
+ ### Fixed
1504
+
1505
+ - Fixed inconsistent thinking level configuration across multiple model definitions
1506
+
1507
+ ## [13.14.0] - 2026-03-20
1508
+
1509
+ ### Fixed
1510
+
1511
+ - Fixed resumed OpenAI Responses sessions to avoid replaying stale same-provider native history on the first follow-up after process restart ([#488](https://github.com/can1357/gajae-code/issues/488))
1512
+
1513
+ ### Added
1514
+
1515
+ - Added bundled GPT-5.4 mini model metadata for OpenAI, OpenAI code provider, and GitHub Copilot, including low-to-xhigh thinking support and GitHub Copilot premium multiplier metadata
1516
+ - Added bundled GPT-5.4 nano model metadata for OpenAI and OpenAI code provider, including low-to-xhigh thinking support
1517
+
1518
+ ## [13.13.2] - 2026-03-18
1519
+
1520
+ ### Changed
1521
+
1522
+ - Modified tool result handling for aborted assistant messages to preserve existing tool results when already recorded, instead of always replacing them with synthetic 'aborted' results
1523
+
1524
+ ## [13.13.0] - 2026-03-18
1525
+
1526
+ ### Changed
1527
+
1528
+ - Changed tool argument validation to always normalize optional null values before type coercion, ensuring consistent handling of LLM-generated 'null' strings
1529
+
1530
+ ### Fixed
1531
+
1532
+ - Fixed tool argument validation to properly handle string 'null' values from LLMs on optional fields by stripping them during normalization
1533
+ - Improved type safety of `validateToolCall` and `validateToolArguments` functions by returning properly typed `ToolCall["arguments"]` instead of `any`
1534
+
1535
+ ## [13.12.9] - 2026-03-17
1536
+
1537
+ ### Changed
1538
+
1539
+ - Extracted OpenAI compatibility detection and resolution logic into dedicated `openai-completions-compat` module for improved maintainability and reusability
1540
+
1541
+ ### Fixed
1542
+
1543
+ - Fixed `openai-responses` manual history replay to strip replay-only item IDs and preserve normalized tool `call_id` values for GitHub Copilot follow-up turns ([#457](https://github.com/can1357/gajae-code/issues/457))
1544
+
1545
+ ## [13.12.0] - 2026-03-14
1546
+
1547
+ ### Added
1548
+
1549
+ - Added support for `qwen-chat-template` thinking format to enable reasoning via `chat_template_kwargs.enable_thinking`
1550
+ - Added `reasoningEffortMap` option to `OpenAICompat` for mapping pi-ai reasoning levels to provider-specific `reasoning_effort` values
1551
+ - Added `extraBody` to `OpenAICompat` to support provider-specific request body routing fields in OpenAI-completions requests
1552
+ - Added support for reading token usage from choice-level `usage` field as fallback when root-level usage is unavailable
1553
+ - Added new models: DeepSeek-V3.2 (Bedrock), Llama 3.1 405B Instruct, Magistral Small 1.2, Ministral 3 3B, Mistral Large 3, Pixtral Large (25.02), NVIDIA Nemotron Nano 3 30B, and Qwen3-5-9b
1554
+ - Added `close()` method to `AuthStorage` for properly closing the underlying credential store
1555
+ - Added `initiatorOverride` option in OpenAI and Anthropic providers to customize message attribution
1556
+
1557
+ ### Changed
1558
+
1559
+ - Changed assistant message content serialization to always use plain string format instead of text block arrays to prevent recursive nesting in OpenAI-compatible backends
1560
+ - Changed Bedrock Opus 4.6 context window from 1M to 1M and added max tokens limit of 128K
1561
+ - Changed OpenCode Zen/Go Sonnet 4.0/4.5 context window from 1M to 200K
1562
+ - Changed GitHub Copilot context windows from 200K to 128K for both gpt-4o and gpt-4o-mini
1563
+ - Changed Anthropic model 3.5 Sonnet (Anthropic API) pricing: input from $0.5 to $0.25, output from $3 to $1.5, cache read from $0.05 to $0.025, cache write from $0 to $1
1564
+ - Changed Devstral 2 model name from '135B' to '123B'
1565
+ - Changed ByteDance Seed 2.0-Lite to support reasoning with effort-based thinking mode and image inputs
1566
+ - Changed Qwen3-32b (Groq) reasoning effort mapping to normalize all levels to 'default'
1567
+ - Changed finish_reason 'end' to map to 'stop' for improved compatibility with additional providers
1568
+ - Changed Anthropic reference model merging to prioritize bundled metadata for known models while using models.dev for newly discovered IDs
1569
+
1570
+ ### Fixed
1571
+
1572
+ - Fixed reasoning_effort parameter handling to use provider-specific mappings instead of raw effort values
1573
+ - Fixed assistant content serialization for GitHub Copilot and other OpenAI-compatible backends that mirror array payloads
1574
+ - Fixed token usage calculation to properly extract cached tokens from both root and nested `prompt_tokens_details` fields
1575
+ - Fixed stop reason mapping to handle string values and unknown finish reasons gracefully
1576
+ - Fixed resource cleanup in `AuthCredentialStore.close()` to properly finalize all prepared statements before closing the database
1577
+
1578
+ ## [13.11.1] - 2026-03-13
1579
+
1580
+ ### Fixed
1581
+
1582
+ - Added `llama.cpp` as local provider
1583
+ - Fixed auth schema V0-to-V1 migration crash when the V0 table lacks a `disabled` column
1584
+
1585
+ ## [13.11.0] - 2026-03-12
1586
+
1587
+ ### Added
1588
+
1589
+ - Added support for Parallel AI provider with API key authentication
1590
+ - Added `PARALLEL_API_KEY` environment variable support for Parallel provider configuration
1591
+ - Added automatic websocket reconnection handling for connection limit errors, with fallback to SSE replay when content has already been emitted
1592
+
1593
+ ### Changed
1594
+
1595
+ - Enhanced `OpenAI codeProviderStreamError` to include an optional error code field for better error categorization and handling
1596
+
1597
+ ### Fixed
1598
+
1599
+ - Improved retry logic to handle HTTP/2 stream errors and internal_error responses from Anthropic API
1600
+
1601
+ ## [13.9.16] - 2026-03-10
1602
+
1603
+ ### Added
1604
+
1605
+ - Support for `onPayload` callback to replace provider request payloads before sending, enabling request interception and modification
1606
+ - Support for structured text signature metadata with phase information (commentary/final_answer) in OpenAI and Azure OpenAI Responses providers
1607
+ - Support for OpenAI code provider Spark model selection with plan-based account prioritization
1608
+ - Added `modelId` option to `getApiKey()` to enable model-specific credential ranking
1609
+
1610
+ ### Changed
1611
+
1612
+ - Enhanced `onPayload` callback signature to accept model parameter and support async payload replacement
1613
+ - Improved error messages for `response.failed` events to include detailed error codes, messages, and incomplete reasons
1614
+ - Refactored OpenAI code provider response streaming to improve code organization and maintainability with extracted helper functions and type definitions
1615
+ - Enhanced websocket fallback logic to safely replay buffered output over SSE when websocket connections fail mid-stream
1616
+ - Improved error recovery for websocket streams by distinguishing between fatal connection errors and retryable stream errors
1617
+ - Updated credential ranking strategy to prioritize Pro plan accounts when requesting OpenAI code provider Spark models
1618
+
1619
+ ### Fixed
1620
+
1621
+ - Fixed websocket stream recovery to properly reset output state and clear buffered items when falling back to SSE after partial output
1622
+ - Fixed handling of malformed JSON messages in websocket streams to trigger immediate fallback to SSE without retry attempts
1623
+
1624
+ ## [13.9.13] - 2026-03-10
1625
+
1626
+ ### Added
1627
+
1628
+ - Added `isSpecialServiceTier` utility function to validate OpenAI service tier values
1629
+
1630
+ ## [13.9.12] - 2026-03-09
1631
+
1632
+ ### Added
1633
+
1634
+ - Added Tavily web search provider support with API key authentication
1635
+
1636
+ ### Fixed
1637
+
1638
+ - Fixed OpenAI-family streaming transports to fail with an explicit idle-timeout error instead of hanging indefinitely when the provider stops sending events mid-response
1639
+ - Fixed OpenAI code provider OAuth refresh and usage-limit lookups to respect request timeouts instead of waiting indefinitely during account selection or rotation
1640
+ - Fixed OpenAI code provider prewarmed websocket requests to fall back quickly when the socket connects but never starts the response stream
1641
+
1642
+ ## [13.9.10] - 2026-03-08
1643
+
1644
+ ### Added
1645
+
1646
+ - Added `identity_key` column to auth credentials storage for improved credential deduplication
1647
+ - Added schema versioning system to auth credentials database for safer migrations
1648
+ - Added automatic backfilling of identity keys during database schema migrations
1649
+
1650
+ ### Changed
1651
+
1652
+ - Changed credential deduplication logic to use single identity key instead of multiple identifiers for better performance
1653
+ - Changed database schema to store normalized identity keys alongside credentials
1654
+ - Changed auth schema migration to support upgrading from legacy database versions with automatic data backfill
1655
+
1656
+ ### Fixed
1657
+
1658
+ - Fixed API key credential matching to correctly identify when the same key is re-stored, preventing unnecessary row duplication on re-login
1659
+ - Fixed credential deduplication to correctly handle OAuth accounts with matching emails but different account IDs
1660
+ - Fixed API key replacement to reuse existing stored rows instead of accumulating disabled duplicates
1661
+ - Fixed auth storage to preserve newer recorded schema versions when opened by older binaries
1662
+
1663
+ ## [13.9.8] - 2026-03-08
1664
+
1665
+ ### Fixed
1666
+
1667
+ - Fixed WebSocket stream fallback logic to safely replay buffered output over SSE when WebSocket fails after partial content has been streamed
1668
+
1669
+ ## [13.9.4] - 2026-03-07
1670
+
1671
+ ### Changed
1672
+
1673
+ - Simplified API key credential storage to always replace existing credentials on re-login instead of accumulating multiple keys
1674
+ - Updated Kagi API key placeholder from `kagi_...` to `KG_...` to match current API key format
1675
+ - Updated Kagi login instructions to clarify Search API access is beta-only and provide support contact
1676
+ - Disabled usage reporting in streaming responses for Cerebras models due to compatibility issues
1677
+
1678
+ ### Fixed
1679
+
1680
+ - Fixed Cerebras model compatibility by preventing `stream_options` usage requests in chat completions
1681
+
1682
+ ## [13.9.3] - 2026-03-07
1683
+
1684
+ ### Breaking Changes
1685
+
1686
+ - Changed `reasoning` parameter from `ThinkingLevel | undefined` to `Effort | undefined` in `SimpleStreamOptions`; 'off' is no longer valid (omit the field instead)
1687
+ - Removed `supportsXhigh()` function; check `model.thinking?.maxLevel` instead
1688
+ - Removed `ThinkingLevel` and `ThinkingEffort` types; use `Effort` enum
1689
+ - Removed `getAvailableThinkingLevels()` and `getAvailableThinkingEfforts()` functions
1690
+ - Changed `transformRequestBody()` signature to require `Model` parameter as second argument for effort validation
1691
+ - Removed `thinking.ts` module export; import from `model-thinking.ts` instead
1692
+
1693
+ ### Added
1694
+
1695
+ - Added `incremental` flag to `OpenAIResponsesHistoryPayload` to support building conversation history from multiple assistant messages instead of replacing it
1696
+ - Added `dt` flag to `OpenAIResponsesHistoryPayload` for transport-level metadata
1697
+ - Added `ThinkingConfig` interface to models for canonical thinking transport metadata with min/max effort levels and provider-specific mode
1698
+ - Added `thinking` field to `Model` type containing per-model thinking capabilities used to clamp and map user-facing effort levels
1699
+ - Added `Effort` enum (minimal, low, medium, high, xhigh) as canonical user-facing thinking levels replacing `ThinkingLevel`
1700
+ - Added `enrichModelThinking()` function to automatically populate thinking metadata on models based on their capabilities
1701
+ - Added `mapEffortToAnthropicAdaptiveEffort()` function to map user effort levels to Anthropic adaptive thinking effort
1702
+ - Added `mapEffortToGoogleThinkingLevel()` function to map user effort levels to Google thinking levels
1703
+ - Added `requireSupportedEffort()` function to validate and clamp effort levels per model, throwing errors for unsupported combinations
1704
+ - Added `clampThinkingLevelForModel()` function to clamp thinking levels to model-supported range
1705
+ - Added `applyGeneratedModelPolicies()` and `linkSparkPromotionTargets()` exports from model-thinking module
1706
+ - Added `serviceTier` option to control OpenAI processing priority and cost (auto, default, flex, scale, priority)
1707
+ - Added `providerPayload` field to messages and responses for reconstructing transport-native history
1708
+ - Added Gemini usage provider for tracking quota and tier information
1709
+ - Added `getOpenAI codeAccountId()` utility to extract account ID from OpenAI code JWT tokens
1710
+ - Added email extraction from OpenAI code provider OAuth tokens for credential deduplication
1711
+
1712
+ ### Changed
1713
+
1714
+ - Changed credential disabling mechanism from boolean `disabled` flag to `disabled_cause` text field for tracking why credentials were disabled
1715
+ - Changed `deleteAuthCredential()` and `deleteAuthCredentialsForProvider()` methods to require a `disabledCause` parameter explaining the reason for disabling
1716
+ - Changed Gemini model parsing to strip `-preview` suffix for consistent model identification
1717
+ - Changed OpenAI code provider websocket error handling to detect fatal connection errors and immediately fall back to SSE without retrying
1718
+ - Changed OpenAI code provider to always use websockets v2 protocol (removed v1 support)
1719
+ - Changed `reasoning` parameter type from `ThinkingLevel` to `Effort` in `SimpleStreamOptions`, removing 'off' value (callers should omit the field instead)
1720
+ - Changed thinking configuration to use model-specific metadata instead of hardcoded provider logic for effort mapping
1721
+ - Changed OpenAI code provider request transformer to accept `Model` parameter for effort validation instead of string model ID
1722
+ - Changed Anthropic provider to use model thinking metadata for determining adaptive thinking support instead of model ID pattern matching
1723
+ - Changed Google Vertex and Google providers to use shorter variable names for thinking config construction
1724
+ - Moved thinking-related utilities from `thinking.ts` to new `model-thinking.ts` module with expanded functionality
1725
+ - Moved model policy functions from `provider-models/model-policies.ts` to `model-thinking.ts`
1726
+ - Moved `googleGeminiCliUsageProvider` from `providers/google-gemini-cli-usage.ts` to `usage/gemini.ts`
1727
+ - Changed default OpenAI model from gpt-5.1-openai-code to gpt-5.4 across all providers
1728
+ - Changed `UsageFetchContext` to remove cache and now() dependencies—usage fetchers now use Date.now() directly
1729
+ - Removed `resetInMs` field from usage windows; consumers should calculate from `resetsAt` timestamp
1730
+ - Changed OpenAI code provider credential ranking to deduplicate by email when accountId matches
1731
+ - Improved OpenAI code provider error handling with retryable error detection
1732
+
1733
+ ### Removed
1734
+
1735
+ - Removed `thinking.ts` module; use `model-thinking.ts` instead
1736
+ - Removed `provider-models/model-policies.ts` module; functionality moved to `model-thinking.ts`
1737
+ - Removed `supportsXhigh()` function from models.ts; use model.thinking metadata instead
1738
+ - Removed `ThinkingLevel` and `ThinkingEffort` types; use `Effort` enum instead
1739
+ - Removed `getAvailableThinkingLevels()` and `getAvailableThinkingEfforts()` functions
1740
+ - Removed `model-policies` export from `provider-models/index.ts`
1741
+ - Removed hardcoded thinking level clamping logic from OpenAI code provider request transformer; now uses model metadata
1742
+ - Removed `UsageCache` and `UsageCacheEntry` interfaces—caching is now handled internally by AuthStorage
1743
+ - Removed `google-gemini-cli-usage` export; use new `gemini` usage provider instead
1744
+ - Removed `resetInMs` computation from all usage providers
1745
+ - Removed cache TTL constants and cache management from usage fetchers (anthropic-model, github-copilot, google-antigravity, kimi, openai-code, zai)
1746
+
1747
+ ### Fixed
1748
+
1749
+ - Fixed credential purging to respect disabled credentials when deduplicating by email, preventing re-enablement of intentionally disabled credentials
1750
+ - Fixed OpenAI code provider websocket error reporting to include detailed error messages from error events
1751
+ - Fixed conversation history reconstruction to support incremental updates from multiple assistant messages while maintaining backward compatibility with full-snapshot payloads
1752
+ - Fixed OpenAI code provider to reject unsupported effort levels instead of silently clamping them, providing clear error messages about supported efforts
1753
+ - Fixed model cache normalization to properly apply thinking enrichment when loading cached models
1754
+ - Fixed dynamic model merging to apply thinking enrichment to merged model results
1755
+ - Fixed OpenAI code provider streaming to properly include service_tier in SSE payloads
1756
+ - Fixed type safety in OpenAI responses by removing unsafe type casts on image content blocks
1757
+ - Fixed credential purging to respect disabled credentials when deduplicating by email
1758
+ - Fixed API-key provider re-login to replace the active stored key instead of appending stale credentials that were still selected first
1759
+ - Fixed Kagi login guidance to use the correct `KG_...` key format and mention Search API beta access requirements
1760
+
1761
+ ## [13.9.2] - 2026-03-05
1762
+
1763
+ ### Added
1764
+
1765
+ - Support for redacted thinking blocks in Anthropic messages, enabling secure handling of encrypted reasoning content
1766
+ - Preservation of latest Anthropic thinking blocks and redacted thinking content during message transformation, even when switching between Anthropic models
1767
+
1768
+ ### Changed
1769
+
1770
+ - Assistant message content now includes `RedactedThinkingContent` type alongside existing text, thinking, and tool call blocks
1771
+ - Message transformation logic now preserves signed thinking blocks and redacted thinking for the latest assistant message in Anthropic conversations
1772
+
1773
+ ### Fixed
1774
+
1775
+ - Fixed Unicode normalization to consistently apply `toWellFormed()` to all text content, including thinking blocks, ensuring proper handling of malformed UTF-16 sequences
1776
+
1777
+ ## [13.9.1] - 2026-03-05
1778
+
1779
+ ### Breaking Changes
1780
+
1781
+ - Removed `THINKING_LEVELS`, `ALL_THINKING_LEVELS`, `ALL_THINKING_MODES`, `THINKING_MODE_DESCRIPTIONS`, and `THINKING_MODE_LABELS` exports
1782
+ - Renamed `formatThinking()` to `getThinkingMetadata()` with changed return type from string to `ThinkingMetadata` object
1783
+ - Renamed `getAvailableThinkingLevel()` to `getAvailableThinkingLevels()` and added default parameter
1784
+ - Renamed `getAvailableEffort()` to `getAvailableEfforts()` and added default parameter
1785
+
1786
+ ### Added
1787
+
1788
+ - Added `ThinkingMetadata` type to provide structured access to thinking mode information (value, label, description)
1789
+
1790
+ ## [13.9.0] - 2026-03-05
1791
+
1792
+ ### Added
1793
+
1794
+ - Exported new thinking module with `Effort`, `ThinkingLevel`, and `ThinkingMode` types for managing reasoning effort levels
1795
+ - Added `getAvailableEffort()` function to determine supported thinking effort levels based on model capabilities
1796
+ - Added `parseEffort()`, `parseThinkingLevel()`, and `parseThinkingMode()` functions for parsing thinking configuration strings
1797
+ - Added `THINKING_LEVELS`, `ALL_THINKING_LEVELS`, and `ALL_THINKING_MODES` constants for iterating over available thinking options
1798
+ - Added `THINKING_MODE_DESCRIPTIONS` and `THINKING_MODE_LABELS` for displaying thinking modes in user interfaces
1799
+ - Added `formatThinking()` function to format thinking modes as compact display labels
1800
+
1801
+ ### Changed
1802
+
1803
+ - Refactored thinking level handling to distinguish between `Effort` (provider-level, no "off") and `ThinkingLevel` (user-facing, includes "off")
1804
+ - Updated `ThinkingBudgets` type to use `Effort` instead of `ThinkingLevel` for more precise token budget configuration
1805
+ - Improved reasoning option handling to explicitly support "off" value for disabling reasoning across all providers
1806
+ - Simplified thinking effort mapping logic by centralizing provider-specific clamping behavior
1807
+
1808
+ ## [13.7.8] - 2026-03-04
1809
+
1810
+ ### Added
1811
+
1812
+ - Added ZenMux provider support with mixed API routing: Anthropic-owned models discovered from `https://zenmux.ai/api/v1/models` now use the Anthropic transport (`https://zenmux.ai/api/anthropic`), while other ZenMux models use the OpenAI-compatible transport.
1813
+
1814
+ ## [13.7.7] - 2026-03-04
1815
+
1816
+ ### Changed
1817
+
1818
+ - Modified response ID normalization to preserve existing item ID prefixes when truncating oversized IDs
1819
+ - Updated tool call ID normalization to use `fc_` prefix for generated item IDs instead of `item_` prefix
1820
+
1821
+ ### Fixed
1822
+
1823
+ - Fixed handling of reasoning item IDs to remain untouched during response normalization while function call IDs are properly normalized
1824
+
1825
+ ## [13.7.2] - 2026-03-04
1826
+
1827
+ ### Added
1828
+
1829
+ - Added support for Kagi API key authentication via `login kagi` command
1830
+ - Added Kagi to the list of available OAuth providers
1831
+
1832
+ ### Fixed
1833
+
1834
+ - MCP tool schemas with `$ref`/`$defs` are now dereferenced before being sent to LLM providers, fixing dangling references that left models without type definitions
1835
+ - Ajv schema validation no longer emits `console.warn()` for non-standard format keywords (e.g. `"uint"`) from MCP servers, preventing TUI corruption
1836
+ - Tool schema compilation is now cached per schema identity, eliminating redundant recompilation on every tool call
1837
+
1838
+ ## [13.6.0] - 2026-03-03
1839
+
1840
+ ### Added
1841
+
1842
+ - Added Anthropic Foundry gateway mode controlled by `ANTHROPIC_MODEL_CODE_USE_FOUNDRY`, with support for `FOUNDRY_BASE_URL`, `ANTHROPIC_FOUNDRY_API_KEY`, `ANTHROPIC_CUSTOM_HEADERS`, and optional mTLS material (`ANTHROPIC_MODEL_CODE_CLIENT_CERT`, `ANTHROPIC_MODEL_CODE_CLIENT_KEY`, `NODE_EXTRA_CA_CERTS`)
1843
+ - Added LM Studio provider support with OpenAI-compatible model discovery and OAuth login.
1844
+ - Added support for `LM_STUDIO_API_KEY` and `LM_STUDIO_BASE_URL` environment variables for authentication and custom host configuration.
1845
+
1846
+ ### Changed
1847
+
1848
+ - Anthropic key resolution now prefers `ANTHROPIC_FOUNDRY_API_KEY` over `ANTHROPIC_OAUTH_TOKEN` and `ANTHROPIC_API_KEY` when Foundry mode is enabled
1849
+ - Anthropic auth base-URL fallback now prefers `FOUNDRY_BASE_URL` when `ANTHROPIC_MODEL_CODE_USE_FOUNDRY` is enabled
1850
+
1851
+ ## [13.5.8] - 2026-03-02
1852
+
1853
+ ### Fixed
1854
+
1855
+ - Fixed schema compatibility issue where patternProperties in tool parameters caused failures when converting to legacy Antigravity format
1856
+
1857
+ ## [13.5.5] - 2026-03-01
1858
+
1859
+ ### Changed
1860
+
1861
+ - Anthropic Anthropic model system-block cloaking now leaves the agent identity block uncached and applies `cache_control: { type: "ephemeral" }` to injected user system blocks without forcing `ttl: "1h"`
1862
+
1863
+ ### Fixed
1864
+
1865
+ - Anthropic request payload construction now enforces a maximum of 4 `cache_control` breakpoints (tools/system/messages priority order) before dispatch
1866
+ - Anthropic cache-control normalization now removes later `ttl: "1h"` entries when a default/5m block has already appeared earlier in evaluation order
1867
+
1868
+ ## [13.5.3] - 2026-03-01
1869
+
1870
+ ### Fixed
1871
+
1872
+ - Fixed tool argument coercion to handle malformed JSON with trailing wrapper braces by parsing leading JSON containers
1873
+
1874
+ ## [13.4.0] - 2026-03-01
1875
+
1876
+ ### Breaking Changes
1877
+
1878
+ - Removed `TInput` generic parameter from `ToolResultMessage` interface and removed `$normative` property
1879
+
1880
+ ### Added
1881
+
1882
+ - `hasUnrepresentableStrictObjectMap()` pre-flight check in `tryEnforceStrictSchema`: schemas with `patternProperties` or schema-valued `additionalProperties` now degrade gracefully to non-strict mode instead of throwing during enforcement
1883
+ - `generateAnthropic modelCloakingUserId()` generates structured user IDs for Anthropic OAuth metadata (`user_{hex64}_account_{uuid}_session_{uuid}`)
1884
+ - `isAnthropic modelCloakingUserId()` validates whether a string matches the cloaking user-ID format
1885
+ - `mapStainlessOs()` and `mapStainlessArch()` map `process.platform`/`process.arch` to Stainless header values; X-Stainless-Os and X-Stainless-Arch in `anthropic-modelCodeHeaders` are now runtime-computed
1886
+ - `buildAnthropic modelCodeTlsFetchOptions()` attaches SNI and default TLS ciphers for direct `api.anthropic.com` connections
1887
+ - `createAnthropic modelBillingHeader()` generates the `x-anthropic-billing-header` block (SHA-256 payload fingerprint + random build hash)
1888
+ - `buildAnthropicSystemBlocks()` now injects a billing header block and the Anthropic model Agent SDK identity block with `ephemeral` 1h cache-control when `includeAnthropic modelCodeInstruction` is set
1889
+ - `resolveAnthropicMetadataUserId()` auto-generates a cloaking user ID for OAuth requests when `metadata.user_id` is absent or invalid
1890
+ - `AnthropicOAuthFlow` is now exported for direct use
1891
+ - OAuth callback server timeout extended from 2 min to 5 min
1892
+ - `parseGeminiCliCredentials()` parses Google Cloud credential JSON with support for legacy (`{token,projectId}`), alias (`project_id`/`refresh`/`expires`), and enriched formats
1893
+ - `shouldRefreshGeminiCliCredentials()` and proactive token refresh before requests for both Gemini CLI and Antigravity providers (60s pre-expiry buffer)
1894
+ - `normalizeAntigravityTools()` converts `parametersJsonSchema` → `parameters` in function declarations for Antigravity compatibility
1895
+ - `ANTIGRAVITY_SYSTEM_INSTRUCTION` is now exported for use by search and other consumers
1896
+ - `ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA` constant exported from OAuth module with `ANTIGRAVITY` ideType
1897
+ - Antigravity project onboarding: `onboardProjectWithRetries()` provisions a new project via `onboardUser` LRO when `loadCodeAssist` returns no existing project (up to 5 attempts, 2s interval)
1898
+ - `getOAuthApiKey` now includes `refreshToken`, `expiresAt`, `email`, and `accountId` in the Gemini/Antigravity JSON credential payload to enable proactive refresh
1899
+ - Antigravity model discovery now tries the production daily endpoint first, with sandbox as fallback
1900
+ - `ANTIGRAVITY_DISCOVERY_DENYLIST` filters low-quality/internal models from discovery results
1901
+
1902
+ ### Changed
1903
+
1904
+ - Replaced `sanitizeSurrogates()` utility with native `String.prototype.toWellFormed()` for handling unpaired Unicode surrogates across all providers
1905
+ - Extended `ANTHROPIC_OAUTH_BETA` constant in the OpenAI-compat Anthropic route with `interleaved-thinking-2025-05-14`, `context-management-2025-06-27`, and `prompt-caching-scope-2026-01-05` beta flags
1906
+ - `anthropic-modelCodeVersion` bumped to `2.1.63`; `anthropic-modelCodeSystemInstruction` updated to identify as Anthropic model Agent SDK
1907
+ - `anthropic-modelCodeHeaders`: removed `X-Stainless-Helper-Method`, updated package version to `0.74.0`, runtime version to `v24.3.0`
1908
+ - `applyAnthropic modelToolPrefix` / `stripAnthropic modelToolPrefix` now accept an optional prefix override and skip Anthropic built-in tool names (`web_search`, `code_execution`, `text_editor`, `computer`)
1909
+ - Accept-Encoding header updated to `gzip, deflate, br, zstd`
1910
+ - Non-Anthropic base URLs now receive `Authorization: Bearer` regardless of OAuth status
1911
+ - Prompt-caching logic now skips applying breakpoints when any block already carries `cache_control`, instead of stripping then re-applying
1912
+ - `fine-grained-tool-streaming-2025-05-14` removed from default beta set
1913
+ - Anthropic OAuth token URL changed from `platform.anthropic-model.com` to `api.anthropic.com`
1914
+ - Anthropic OAuth scopes reduced to `org:create_api_key user:profile user:inference`
1915
+ - OAuth code exchange now strips URL fragment from callback code, using the fragment as state override when present
1916
+ - Anthropic model usage headers aligned: user-agent updated to `anthropic-model-cli/2.1.63 (external, cli)`, anthropic-beta extended with full beta set
1917
+ - Antigravity session ID format changed to signed decimal (negative int63 derived from SHA-256 of first user message, or random bounded int63)
1918
+ - Antigravity `requestId` now uses `agent-{uuid}` format; non-Antigravity requests no longer include requestId/userAgent/requestType in the payload
1919
+ - `ANTIGRAVITY_DAILY_ENDPOINT` corrected to `daily-cloudcode-pa.googleapis.com`; sandbox endpoint kept as fallback only
1920
+ - Antigravity discovery: removed `recommended`/`agentModelSorts` filter; now includes all non-internal, non-denylisted models
1921
+ - Antigravity discovery no longer sends `project` in the request body
1922
+ - Gemini/Antigravity OAuth flows no longer use PKCE (code_challenge removed)
1923
+ - Antigravity `loadCodeAssist` metadata ideType changed from `IDE_UNSPECIFIED` to `ANTIGRAVITY`
1924
+ - Antigravity `discoverProject` now uses a single canonical production endpoint; falls back to project onboarding instead of a hardcoded default project ID
1925
+ - `VALIDATED` tool calling config applied to Antigravity requests with Anthropic model models
1926
+ - `maxOutputTokens` removed from Antigravity generation config for non-Anthropic model models
1927
+ - System instruction injection for Antigravity scoped to Anthropic model and `gemini-3-pro-high` models only
1928
+
1929
+ ### Removed
1930
+
1931
+ - Removed `sanitizeSurrogates()` utility function; use native `String.prototype.toWellFormed()` instead
1932
+
1933
+ ## [13.3.14] - 2026-02-28
1934
+
1935
+ ### Added
1936
+
1937
+ - Exported schema utilities from new `./utils/schema` module, consolidating JSON Schema handling across providers
1938
+ - Added `CredentialRankingStrategy` interface for providers to implement usage-based credential selection
1939
+ - Added `anthropic-modelRankingStrategy` for Anthropic OAuth credentials to enable smart multi-account selection based on usage windows
1940
+ - Added `openai-codeRankingStrategy` for OpenAI code provider OAuth credentials with priority boost for fresh 5-hour window starts
1941
+ - Added `adaptSchemaForStrict()` helper for unified OpenAI strict schema enforcement across providers
1942
+ - Added schema equality and merging utilities: `areJsonValuesEqual()`, `mergeCompatibleEnumSchemas()`, `mergePropertySchemas()`
1943
+ - Added Cloud Code Assist schema normalization: `copySchemaWithout()`, `stripResidualCombiners()`, `prepareSchemaForCCA()`
1944
+ - Added `sanitizeSchemaForGoogle()` and `sanitizeSchemaForCCA()` for provider-specific schema sanitization
1945
+ - Added `StringEnum()` helper for creating string enum schemas compatible with Google and other providers
1946
+ - Added `enforceStrictSchema()` and `sanitizeSchemaForStrictMode()` for OpenAI strict mode schema validation
1947
+ - Added package exports for `./utils/schema` and `./utils/schema/*` subpaths
1948
+ - Added `validateSchemaCompatibility()` to statically audit a JSON Schema against provider-specific rules (`openai-strict`, `google`, `cloud-code-assist-anthropic-model`) and return structured violations
1949
+ - Added `validateStrictSchemaEnforcement()` to verify the strict-fail-open contract: enforced schemas pass strict validation, failed schemas return the original object identity
1950
+ - Added `COMBINATOR_KEYS` (`anyOf`, `allOf`, `oneOf`) and `CCA_UNSUPPORTED_SCHEMA_FIELDS` as exported constants in `fields.ts` to eliminate duplication across modules
1951
+ - Added `tryEnforceStrictSchema` result cache (`WeakMap`) to avoid redundant sanitize + enforce work for the same schema object
1952
+ - Added comprehensive schema normalization test suite (`schema-normalization.test.ts`) covering strict mode, Google, and Cloud Code Assist normalization paths
1953
+ - Added schema compatibility validation test suite (`schema-compatibility.test.ts`) covering all three provider targets
1954
+
1955
+ ### Changed
1956
+
1957
+ - Moved schema utilities from `./utils/typebox-helpers` to new `./utils/schema` module with expanded functionality
1958
+ - Refactored OpenAI provider tool conversion to use unified `adaptSchemaForStrict()` helper across openai-code, completions, and responses
1959
+ - Updated `AuthStorage` to support generic credential ranking via `CredentialRankingStrategy` instead of OpenAI code-only logic
1960
+ - Moved Google schema sanitization functions from `google-shared.ts` to `./utils/schema` module
1961
+ - Changed export path: `./utils/typebox-helpers` → `./utils/schema` in main index
1962
+ - `sanitizeSchemaForGoogle()` / `sanitizeSchemaForCCA()` now accept a parameterized `unsupportedFields` set internally, enabling code reuse between the two sanitizers
1963
+ - `copySchemaWithout()` rewritten using object-rest destructuring for clarity
1964
+
1965
+ ### Fixed
1966
+
1967
+ - Fixed cycle detection: `WeakSet` guards added to all recursive schema traversals (`sanitizeSchemaForStrictMode`, `enforceStrictSchema`, `normalizeSchemaForCCA`, `normalizeNullablePropertiesForCloudCodeAssist`, `stripResidualCombiners`, `sanitizeSchemaImpl`, `hasResidualCloudCodeAssistIncompatibilities`) — circular schemas no longer cause infinite loops or stack overflows
1968
+ - Fixed `hasResidualCloudCodeAssistIncompatibilities`: cycle detection now returns `false` (not `true`) for already-visited nodes, eliminating false positives that forced the CCA fallback schema on valid recursive inputs
1969
+ - Fixed `stripResidualCombiners` to iterate to a fixpoint rather than making a single pass, ensuring chained combiner reductions (where one reduction enables another) are fully resolved
1970
+ - Fixed `mergeObjectCombinerVariants` required-field computation: the flattened object now takes the intersection of all variants' `required` arrays (unioned with own-level required properties that exist in the merged schema), preventing required fields from being silently dropped or over-included
1971
+ - Fixed `mergeCompatibleEnumSchemas` to use deep structural equality (`areJsonValuesEqual`) instead of `Object.is` when deduplicating object-valued enum members
1972
+ - Fixed `sanitizeSchemaForGoogle` const-to-enum deduplication to use deep equality instead of reference equality
1973
+ - Fixed `sanitizeSchemaForGoogle` type inference for `anyOf`/`oneOf`-flattened const enums: type is now derived from all variants (must agree), falling back to inference from enum values; mixed null/non-null infers the non-null type and sets `nullable`
1974
+ - Fixed `sanitizeSchemaForGoogle` recursion to spread options when descending (previously only `insideProperties`, `normalizeTypeArrayToNullable`, `stripNullableKeyword` were forwarded; new fields `unsupportedFields` and `seen` were silently dropped)
1975
+ - Fixed `sanitizeSchemaForGoogle` array-valued `type` filtering to exclude non-string entries before processing
1976
+ - Removed incorrect `additionalProperties: false` stripping from `sanitizeSchemaForGoogle` (the field is valid in Google schemas when `false`)
1977
+ - Fixed `sanitizeSchemaForStrictMode` to strip the `nullable` keyword and expand it into `anyOf: [schema, {type: "null"}]` in the output, matching what OpenAI strict mode actually expects
1978
+ - Fixed `sanitizeSchemaForStrictMode` to infer `type: "array"` when `items` is present but `type` is absent
1979
+ - Fixed `sanitizeSchemaForStrictMode` to infer a scalar `type` from uniform `enum` values when `type` is not explicitly set
1980
+ - Fixed `sanitizeSchemaForStrictMode` const-to-enum merge to use deep equality, preventing duplicate enum entries when `const` and `enum` both exist with the same value
1981
+ - Fixed `enforceStrictSchema` to drop `additionalProperties` unconditionally (previously only object-valued `additionalProperties` was recursed into; non-object values were passed through, violating strict schema requirements)
1982
+ - Fixed `enforceStrictSchema` to recurse into `$defs` and `definitions` blocks so referenced sub-schemas are also made strict-compliant
1983
+ - Fixed `enforceStrictSchema` to handle tuple-style `items` arrays (previously only single-schema `items` objects were recursed)
1984
+ - Fixed `enforceStrictSchema` double-wrapping: optional properties already expressed as `anyOf: [..., {type: "null"}]` are not wrapped again
1985
+ - Fixed `enforceStrictSchema` `Array.isArray` type-narrowing for `type` field to filter non-string entries before checking for `"object"`
1986
+
1987
+ ## [13.3.8] - 2026-02-28
1988
+
1989
+ ### Fixed
1990
+
1991
+ - Fixed response body reuse error when handling 429 rate limit responses with retry logic
1992
+
1993
+ ## [13.3.7] - 2026-02-27
1994
+
1995
+ ### Added
1996
+
1997
+ - Added `tryEnforceStrictSchema` function that gracefully downgrades to non-strict mode when schema enforcement fails, enabling better compatibility with malformed or circular schemas
1998
+ - Added `sanitizeSchemaForStrictMode` function to normalize JSON schemas by stripping non-structural keywords, converting `const` to `enum`, and expanding type arrays into `anyOf` variants
1999
+ - Added Kilo Gateway provider support with OpenAI-compatible model discovery, OAuth `/login kilo`, and `KILO_API_KEY` environment variable support ([#193](https://github.com/can1357/gajae-code/issues/193))
2000
+
2001
+ ### Changed
2002
+
2003
+ - Changed strict mode handling in OpenAI providers to use `tryEnforceStrictSchema` for safer schema enforcement with automatic fallback to non-strict mode
2004
+ - Enhanced `enforceStrictSchema` to properly handle schemas with type arrays containing `object` (e.g., `type: ["object", "null"]`)
2005
+
2006
+ ### Fixed
2007
+
2008
+ - Fixed `enforceStrictSchema` to properly handle malformed object schemas with required keys but missing properties
2009
+ - Fixed `enforceStrictSchema` to correctly process nested object schemas within `anyOf`, `allOf`, and `oneOf` combinators
2010
+
2011
+ ## [13.3.1] - 2026-02-26
2012
+
2013
+ ### Added
2014
+
2015
+ - Added `topP`, `topK`, `minP`, `presencePenalty`, and `repetitionPenalty` options to `StreamOptions` for fine-grained control over model sampling behavior
2016
+
2017
+ ## [13.3.0] - 2026-02-26
2018
+
2019
+ ### Changed
2020
+
2021
+ - Allowed OAuth provider logins to supply a manual authorization code handler with a default prompt when none is provided
2022
+
2023
+ ## [13.2.0] - 2026-02-23
2024
+
2025
+ ### Added
2026
+
2027
+ - Added support for GitHub Copilot provider in strict mode for both openai-completions and openai-responses tool schemas
2028
+
2029
+ ### Fixed
2030
+
2031
+ - Fixed tool descriptions being rejected when undefined by providing empty string fallback across all providers
2032
+
2033
+ ## [12.19.1] - 2026-02-22
2034
+
2035
+ ### Added
2036
+
2037
+ - Exported `isProviderRetryableError` function for detecting rate-limit and transient stream errors
2038
+ - Support for retrying malformed JSON stream-envelope parse errors from Anthropic-compatible proxy endpoints
2039
+
2040
+ ### Changed
2041
+
2042
+ - Expanded retry detection to include JSON parse errors (unterminated strings, unexpected end of input) in addition to rate-limit errors
2043
+
2044
+ ## [12.19.0] - 2026-02-22
2045
+
2046
+ ### Added
2047
+
2048
+ - Added GitLab Duo provider with support for Anthropic model, GPT-5, and other models via GitLab AI Gateway
2049
+ - Added OAuth authentication for GitLab Duo with automatic token refresh and direct access caching
2050
+ - Added 16 new GitLab Duo models including Anthropic model Opus/Sonnet/Haiku variants and GPT-5 series models
2051
+ - Added `isOAuth` option to Anthropic provider to force OAuth bearer auth mode for proxy tokens
2052
+ - Added `streamGitLabDuo` function to route requests through GitLab AI Gateway with direct access tokens
2053
+ - Added `getGitLabDuoModels` function to retrieve available GitLab Duo model configurations
2054
+ - Added `clearGitLabDuoDirectAccessCache` function to manually clear cached direct access tokens
2055
+
2056
+ ### Changed
2057
+
2058
+ - Enhanced `getModelMapping()` to support both GitLab Duo alias IDs (e.g., `duo-chat-gpt-5-openai-code`) and canonical model IDs (e.g., `gpt-5-openai-code`) for improved model resolution flexibility
2059
+ - Migrated `AuthCredentialStore` and `AuthStorage` into `@gajae-code/ai` as shared credential primitives for downstream packages
2060
+ - Moved Anthropic auth helpers (`findAnthropicAuth`, `isOAuthToken`, `buildAnthropicSearchHeaders`, `buildAnthropicUrl`) into shared AI utilities for reuse across providers
2061
+ - Replaced `CliAuthStorage` with `AuthCredentialStore` for improved credential management with multiple credentials per provider
2062
+ - Updated models.json pricing for Anthropic model 3.5 Sonnet (input: 0.23→0.45, output: 3→2.2, added cache read: 0.225) and Anthropic model 3 Opus (input: 0.3→0.95)
2063
+ - Moved `mapAnthropicToolChoice` function from gitlab-duo provider to stream module for broader reusability
2064
+ - Enhanced HTTP status code extraction to handle string-formatted status codes in error objects
2065
+
2066
+ ### Removed
2067
+
2068
+ - Removed `CliAuthStorage` class in favor of new `AuthCredentialStore` with enhanced functionality
2069
+
2070
+ ## [12.17.2] - 2026-02-21
2071
+
2072
+ ### Added
2073
+
2074
+ - Exported `getAntigravityUserAgent()` function for constructing Antigravity User-Agent headers
2075
+
2076
+ ### Changed
2077
+
2078
+ - Updated default Antigravity version from 1.15.8 to 1.18.3
2079
+ - Unified User-Agent header generation across Antigravity API calls to use centralized `getAntigravityUserAgent()` function
2080
+
2081
+ ## [12.17.1] - 2026-02-21
2082
+
2083
+ ### Added
2084
+
2085
+ - Added new export paths for provider models via `./provider-models` and `./provider-models/*`
2086
+ - Added new export paths for Cursor and OpenAI code provider providers via `./providers/cursor/gen/*` and `./providers/openai-code/*`
2087
+ - Added new export paths for usage utilities via `./usage/*`
2088
+ - Added new export paths for discovery and OAuth utilities via `./utils/discovery` and `./utils/oauth` with subpath exports
2089
+
2090
+ ### Changed
2091
+
2092
+ - Simplified main export path to use wildcard pattern `./src/*.ts` for broader module access
2093
+ - Updated `models.json` export to include TypeScript declaration file at `./src/models.json.d.ts`
2094
+ - Reorganized package.json field ordering for improved readability
2095
+
2096
+ ## [12.17.0] - 2026-02-21
2097
+
2098
+ ### Fixed
2099
+
2100
+ - Cursor provider: bind `execHandlers` when passing handler methods to the exec protocol so handlers receive correct `this` context (fixes "undefined is not an object (evaluating 'this.options')" when using exec tools such as web search with Cursor)
2101
+
2102
+ ## [12.16.0] - 2026-02-21
2103
+
2104
+ ### Added
2105
+
2106
+ - Exported `readModelCache` and `writeModelCache` functions for direct SQLite-backed model cache access
2107
+ - Added `<turn_aborted>` guidance marker as synthetic user message when assistant messages are aborted or errored, informing the model that tools may have partially executed
2108
+ - Added support for Sonnet 4.6 models in adaptive thinking detection
2109
+
2110
+ ### Changed
2111
+
2112
+ - Updated model cache schema version to support improved global model fallback resolution
2113
+ - Improved GitHub Copilot model resolution to prefer provider-specific model definitions over global references when context window is larger, ensuring optimal model capabilities
2114
+ - Migrated model cache from per-provider JSON files to unified SQLite database (models.db) for atomic cross-process access
2115
+ - Renamed `cachePath` option to `cacheDbPath` in ModelManagerOptions to reflect database-backed storage
2116
+ - Improved non-authoritative cache handling with 5-minute retry backoff instead of retrying on every startup
2117
+ - Modified handling of aborted/errored assistant messages to preserve tool call structure instead of converting to text summaries, with synthetic 'aborted' tool results injected
2118
+ - Updated tool call tracking to use status map (Resolved/Aborted) instead of separate sets for better handling of duplicate and aborted tool results
2119
+
2120
+ ## [12.15.0] - 2026-02-20
2121
+
2122
+ ### Fixed
2123
+
2124
+ - Improved error messages for OAuth token refresh failures by including detailed error information from the provider
2125
+ - Separated rate limit and usage limit error handling to provide distinct user-friendly messages for ChatGPT rate limits vs subscription usage limits
2126
+
2127
+ ### Changed
2128
+
2129
+ - Increased SDK retry attempts to 5 for OpenAI, Azure OpenAI, and Anthropic clients (was SDK default of 2)
2130
+ - Changed 429 retry strategy for OpenAI code provider and Google Gemini CLI to use a 5-minute time budget when the server provides a retry delay, instead of a fixed attempt cap
2131
+
2132
+ ## [12.14.0] - 2026-02-19
2133
+
2134
+ ### Added
2135
+
2136
+ - Added `gemini-3.1-pro` model to opencode provider with text and image input support
2137
+ - Added `trinity-large-preview-free` model to opencode provider
2138
+ - Added `google/gemini-3.1-pro-preview` model to nanogpt provider
2139
+ - Added `google/gemini-3.1-pro-preview` model to openrouter provider with text and image input support
2140
+ - Added `gemini-3.1-pro` model to cursor provider
2141
+ - Added optional `intent` field to `ToolCall` interface for harness-level intent metadata
2142
+
2143
+ ### Changed
2144
+
2145
+ - Changed `big-pickle` model API from `openai-completions` to `anthropic-messages`
2146
+ - Changed `big-pickle` model baseUrl from `https://opencode.ai/zen/v1` to `https://opencode.ai/zen`
2147
+ - Changed `minimax-m2.5-free` model API from `openai-completions` to `anthropic-messages`
2148
+ - Changed `minimax-m2.5-free` model baseUrl from `https://opencode.ai/zen/v1` to `https://opencode.ai/zen`
2149
+
2150
+ ### Fixed
2151
+
2152
+ - Fixed tool argument validation to iteratively coerce nested JSON strings across multiple passes, enabling proper handling of deeply nested JSON-serialized objects and arrays
2153
+
2154
+ ## [12.13.0] - 2026-02-19
2155
+
2156
+ ### Added
2157
+
2158
+ - Added NanoGPT provider support with API-key login, dynamic model discovery from `https://nano-gpt.com/api/v1/models`, and text-model filtering for catalog/runtime discovery ([#111](https://github.com/can1357/gajae-code/issues/111))
2159
+
2160
+ ## [12.12.3] - 2026-02-19
2161
+
2162
+ ### Fixed
2163
+
2164
+ - Fixed retry logic to recognize 'unable to connect' errors as transient failures
2165
+
2166
+ ## [12.11.3] - 2026-02-19
2167
+
2168
+ ### Fixed
2169
+
2170
+ - Fixed OpenAI code provider streaming to fail truncated responses that end without a terminal completion event, preventing partial outputs from being treated as successful completions.
2171
+ - Fixed OpenAI code websocket append fallback by resetting stale turn-state/model-etag session metadata when request shape diverges from appendable history.
2172
+
2173
+ ## [12.11.1] - 2026-02-19
2174
+
2175
+ ### Added
2176
+
2177
+ - Added support for Anthropic model 4.6 Opus and Sonnet models via Cursor API
2178
+ - Added support for Composer 1.5 model via Cursor API
2179
+ - Added support for GPT-5.1 OpenAI code Mini and GPT-5.1 High models via Cursor API
2180
+ - Added support for GPT-5.2 and GPT-5.3 OpenAI code variants (Fast, High, Low, Extra High) via Cursor API
2181
+ - Added HTTP/2 transport support for Cursor API requests (required by Cursor API)
2182
+
2183
+ ### Changed
2184
+
2185
+ - Updated pricing for Anthropic model 3.5 Sonnet model
2186
+ - Updated Anthropic model 3.5 Sonnet context window from 262,144 to 131,072 tokens
2187
+ - Simplified Cursor model display names by removing '(Cursor)' suffix
2188
+ - Changed Cursor API timeout from 15 seconds to 5 seconds
2189
+ - Switched Cursor API transport from HTTP/1.1 to HTTP/2
2190
+
2191
+ ## [12.11.0] - 2026-02-19
2192
+
2193
+ ### Added
2194
+
2195
+ - Added `priority` field to Model interface for provider-assigned model prioritization
2196
+ - Added `CatalogDiscoveryConfig` interface to standardize catalog discovery configuration across providers
2197
+ - Added type guards `isCatalogDescriptor()` and `allowsUnauthenticatedCatalogDiscovery()` for safer descriptor handling
2198
+ - Added `DEFAULT_MODEL_PER_PROVIDER` export from descriptors module for centralized default model management
2199
+ - Support for 11 new AI providers: Cloudflare AI Gateway, Hugging Face Inference, LiteLLM, Moonshot, NVIDIA, Ollama, Qianfan, Qwen Portal, Together, Venice, vLLM, and Xiaomi MiMo
2200
+ - Login flows for new providers with API key validation and OAuth token support
2201
+ - Extended `KnownProvider` type to include all newly supported providers
2202
+ - API key environment variable mappings for all new providers in service provider map
2203
+ - Model discovery and configuration for Cloudflare AI Gateway, Hugging Face, LiteLLM, Moonshot, NVIDIA, Ollama, Qianfan, Qwen Portal, Together, Venice, vLLM, and Xiaomi MiMo
2204
+
2205
+ ### Changed
2206
+
2207
+ - Refactored OAuth credential retrieval to simplify storage lifecycle management in model generation script
2208
+ - Parallelized special model discovery sources (Antigravity, OpenAI code) for improved generation performance
2209
+ - Reorganized model JSON structure to place `contextWindow` and `maxTokens` before `compat` field for consistency
2210
+ - Added `priority` field to OpenAI code provider models for provider-assigned model prioritization
2211
+ - Refactored provider descriptors to use helper functions (`descriptor`, `catalog`, `catalogDescriptor`) for reduced code duplication
2212
+ - Refactored models.dev provider descriptors to use helper functions (`simpleModelsDevDescriptor`, `openAiCompletionsDescriptor`, `anthropicMessagesDescriptor`) for improved maintainability
2213
+ - Unified provider descriptors into single source of truth in `descriptors.ts` for both runtime model discovery and catalog generation, improving maintainability
2214
+ - Refactored model generation script to use declarative `CatalogProviderDescriptor` interface instead of separate descriptor types, reducing code duplication
2215
+ - Reorganized models.dev provider descriptors into logical groups (Bedrock, Core, Coding Plans, Specialized) for better code organization
2216
+ - Simplified API resolution for OpenCode and GitHub Copilot providers using rule-based matching instead of inline conditionals
2217
+ - Refactored model generation script to use declarative provider descriptors instead of inline provider-specific logic, improving maintainability and reducing code duplication
2218
+ - Extracted model post-processing policies (cache pricing corrections, context window normalization) into dedicated `model-policies.ts` module for better testability and clarity
2219
+ - Removed static bundled models for Ollama and vLLM from `models.json` to rely on dynamic discovery instead, reducing static catalog size
2220
+ - Updated `OAuthProvider` type to include new provider identifiers
2221
+ - Expanded model registry (models.json) with thousands of new model entries across all new providers
2222
+ - Modified environment variable resolution to use `$pickenv` for providers with multiple possible env var names
2223
+ - Updated README documentation to list all newly supported providers and their authentication requirements
2224
+
2225
+ ## [12.10.1] - 2026-02-18
2226
+
2227
+ - Added Synthetic provider
2228
+ - Added API-key login helpers for Synthetic and Cerebras providers
2229
+
2230
+ ## [12.10.0] - 2026-02-18
2231
+
2232
+ ### Breaking Changes
2233
+
2234
+ - Renamed public API functions: `getModel()` → `getBundledModel()`, `getModels()` → `getBundledModels()`, `getProviders()` → `getBundledProviders()`
2235
+
2236
+ ### Added
2237
+
2238
+ - Exported `ModelManager` API for runtime-aware model resolution with dynamic endpoint discovery
2239
+ - Exported provider-specific model manager configuration helpers for Google, OpenAI-compatible, OpenAI code, and Cursor providers
2240
+ - Exported discovery utilities for fetching models from Antigravity, OpenAI code, Cursor, Gemini, and OpenAI-compatible endpoints
2241
+ - Added `createModelManager()` function to manage bundled and dynamically discovered models with configurable refresh strategies
2242
+ - Added support for on-disk model caching with TTL-based invalidation
2243
+ - Added `resolveProviderModels()` function for runtime model resolution across multiple providers
2244
+ - Added EU cross-region inference variants for Anthropic model Haiku 3.5 on Bedrock
2245
+ - Added Anthropic model Sonnet 4.6 and Anthropic model Sonnet 4.6 Thinking models to Antigravity provider
2246
+ - Added GLM-5 Free model via OpenCode provider
2247
+ - Added GLM-4.7-FlashX model via ZAI provider
2248
+ - Added MiniMax-M2.5-highspeed model across multiple providers (minimax-code, minimax-code-cn, minimax, minimax-cn)
2249
+ - Added Anthropic model Sonnet 4.6 model to OpenRouter provider
2250
+ - Added Qwen 3.5 Plus model to Vercel AI Gateway provider
2251
+ - Added Anthropic model Sonnet 4.6 model to Vercel AI Gateway provider
2252
+
2253
+ ### Changed
2254
+
2255
+ - Renamed `getModel()` to `getBundledModel()` to clarify it returns compile-time bundled models only
2256
+ - Renamed `getModels()` to `getBundledModels()` for consistency
2257
+ - Renamed `getProviders()` to `getBundledProviders()` for consistency
2258
+ - Refactored model generation script to use modular discovery functions instead of monolithic provider-specific logic
2259
+ - Updated models.json with new model entries and pricing updates across multiple providers
2260
+ - Updated pricing for deepseek/deepseek-v3 model on OpenRouter
2261
+ - Updated maxTokens from 65536 to 4096 for deepseek/deepseek-v3 on OpenRouter
2262
+ - Updated pricing and maxTokens for mistralai/mistral-large-2411 on OpenRouter
2263
+ - Updated pricing for qwen/qwen-max on Together AI
2264
+ - Updated pricing for qwen/qwen-vl-plus on Together AI
2265
+ - Updated pricing for qwen/qwen-plus on Together AI
2266
+ - Updated pricing for qwen/qwen-turbo on Together AI
2267
+ - Expanded EU cross-region inference variant support to all Anthropic model models on Bedrock (previously limited to Haiku, Sonnet, and Opus 4.5)
2268
+
2269
+ ## [12.8.0] - 2026-02-16
2270
+
2271
+ ### Added
2272
+
2273
+ - Added `contextPromotionTarget` model property to specify preferred fallback model when context promotion is triggered
2274
+ - Added automatic context promotion target assignment for Spark models to their base model equivalents
2275
+ - Added support for Brave search provider with BRAVE_API_KEY environment variable
2276
+
2277
+ ### Changed
2278
+
2279
+ - Updated Qwen model context window and max token limits for improved accuracy
2280
+
2281
+ ## [12.7.0] - 2026-02-16
2282
+
2283
+ ### Added
2284
+
2285
+ - Added DeepSeek-V3.2 model support via Amazon Bedrock
2286
+ - Added GLM-5 model support via OpenCode
2287
+ - Added MiniMax M2.5 model support via OpenCode
2288
+
2289
+ ### Changed
2290
+
2291
+ - Updated GLM-4.5, GLM-4.5-Air, GLM-4.5-Flash, GLM-4.5V, GLM-4.6, GLM-4.6V, GLM-4.7, GLM-4.7-Flash, and GLM-5 models to use anthropic-messages API instead of openai-completions
2292
+ - Updated GLM models base URL from https://api.z.ai/api/coding/paas/v4 to https://api.z.ai/api/anthropic
2293
+ - Updated pricing for multiple models including Mistral, Moonshot, and Qwen variants
2294
+ - Updated context window and max tokens for several models to reflect accurate specifications
2295
+
2296
+ ### Removed
2297
+
2298
+ - Removed compat field with supportsDeveloperRole and thinkingFormat properties from GLM models
2299
+
2300
+ ## [12.6.0] - 2026-02-16
2301
+
2302
+ ### Added
2303
+
2304
+ - Added source-scoped custom API and OAuth provider registration helpers for extension-defined providers.
2305
+
2306
+ ### Changed
2307
+
2308
+ - Expanded `Api` typing to allow extension-defined API identifiers while preserving built-in API exhaustiveness checks.
2309
+
2310
+ ### Fixed
2311
+
2312
+ - Fixed custom API registration to reject built-in API identifiers and prevent accidental provider overrides.
2313
+
2314
+ ## [12.2.0] - 2026-02-13
2315
+
2316
+ ### Added
2317
+
2318
+ - Added automatic retry logic for WebSocket stream closures before response completion, with configurable retry budget to improve reliability on flaky connections
2319
+ - Added `providerSessionState` option to enable provider-scoped mutable state persistence across agent turns
2320
+ - Added WebSocket retry logic with configurable retry budget and delay via `PI_OPENAI_CODE_WEBSOCKET_RETRY_BUDGET` and `PI_OPENAI_CODE_WEBSOCKET_RETRY_DELAY_MS` environment variables
2321
+ - Added WebSocket idle timeout detection via `PI_OPENAI_CODE_WEBSOCKET_IDLE_TIMEOUT_MS` environment variable to fail stalled connections
2322
+ - Added WebSocket v2 beta header support via `PI_OPENAI_CODE_WEBSOCKET_V2` environment variable for newer OpenAI API versions
2323
+ - Added WebSocket handshake header capture to extract and replay session metadata (turn state, models etag, reasoning flags) across SSE fallback requests
2324
+ - Added `preferWebsockets` option to enable WebSocket transport for OpenAI code provider responses when supported
2325
+ - Added `prewarmOpenAIOpenAI codeResponses()` function to establish and reuse WebSocket connections across multiple requests
2326
+ - Added `getOpenAIOpenAI codeTransportDetails()` function to inspect transport layer details including WebSocket status and fallback information
2327
+ - Added `getProviderDetails()` function to retrieve formatted provider configuration and transport information
2328
+ - Added automatic fallback from WebSocket to SSE when connection fails, with transparent retry logic
2329
+ - Added session state management to reuse WebSocket connections and enable request appending across turns
2330
+ - Added support for x-openai-code-turn-state header to maintain conversation state across SSE requests
2331
+
2332
+ ### Changed
2333
+
2334
+ - Changed WebSocket session state storage from global maps to provider-scoped session state for multi-agent isolation
2335
+ - Changed WebSocket connection initialization to accept idle timeout configuration and handshake header callbacks
2336
+ - Changed WebSocket error handling to use standardized transport error messages with `OpenAI code websocket transport error` prefix
2337
+ - Changed WebSocket retry behavior to retry transient failures before activating sticky fallback, improving reliability on flaky connections
2338
+ - Changed OpenAI code provider model configuration to prefer WebSocket transport by default with `preferWebsockets: true`
2339
+ - Changed header handling to use appropriate OpenAI-Beta header values for WebSocket vs SSE transports
2340
+ - Perplexity OAuth token refresh now uses JWT expiry extraction instead of Socket.IO RPC, improving reliability when server is unreachable
2341
+ - Removed Socket.IO client implementation for Perplexity token refresh; tokens are now validated using embedded JWT expiry claims
2342
+
2343
+ ### Removed
2344
+
2345
+ - Removed `refreshPerplexityToken` export; token refresh is now handled internally via JWT expiry detection
2346
+
2347
+ ### Fixed
2348
+
2349
+ - Fixed WebSocket stream retry logic to properly handle mid-stream connection closures and retry before falling back to SSE transport
2350
+ - Fixed `preferWebsockets` option handling to correctly respect explicit `false` values when determining transport preference
2351
+ - Fixed WebSocket append state not being reset after aborted requests, preventing stale state from affecting subsequent turns
2352
+ - Fixed WebSocket append state not being reset after stream errors, preventing failed append attempts from blocking future requests
2353
+ - Fixed OpenAI code model context window metadata to use 272000 input tokens (instead of 400000 total budget) for non-Spark OpenAI code variants
2354
+
2355
+ ## [12.0.0] - 2026-02-12
2356
+
2357
+ ### Added
2358
+
2359
+ - Added GPT-5.3 OpenAI code Spark model with 128K context window and extended reasoning capabilities
2360
+ - Added MiniMax M2.5 and M2.5 Lightning models via OpenAI-compatible API (minimax-code provider)
2361
+ - Added MiniMax M2.5 and M2.5 Lightning models via OpenAI-compatible API (minimax-code-cn provider for China region)
2362
+ - Added MiniMax M2.5 and M2.5 Lightning models via Anthropic API (minimax and minimax-cn providers)
2363
+ - Added Llama 3.1 8B model via Cerebras API
2364
+ - Added MiniMax M2.5 model via OpenRouter
2365
+ - Added MiniMax M2.5 model via Vercel AI Gateway
2366
+ - Added MiniMax M2.5 Free model via OpenCode
2367
+ - Added Qwen3 VL 32B Instruct multimodal model via OpenRouter
2368
+
2369
+ ### Changed
2370
+
2371
+ - Updated Z.ai GLM-5 pricing and context window configuration on OpenRouter
2372
+ - Updated Qwen3 Max Thinking max tokens from 32768 to 65536 on OpenRouter
2373
+ - Updated OpenAI GPT-5 Image Mini pricing on OpenRouter
2374
+ - Updated OpenAI GPT-5 Pro pricing and context window on OpenRouter
2375
+ - Updated OpenAI o4-mini pricing and context window on OpenRouter
2376
+ - Updated Anthropic model Opus 4.5 Thinking model name formatting (removed parentheses)
2377
+ - Updated Anthropic model Opus 4.6 Thinking model name formatting (removed parentheses)
2378
+ - Updated Anthropic model Sonnet 4.5 Thinking model name formatting (removed parentheses)
2379
+ - Updated Gemini 2.5 Flash Thinking model name formatting (removed parentheses)
2380
+ - Updated Gemini 3 Pro High and Low model name formatting (removed parentheses)
2381
+ - Updated GPT-OSS 120B Medium model name formatting (removed parentheses) and context window to 131072
2382
+
2383
+ ### Removed
2384
+
2385
+ - Removed GLM-5 model from Z.ai provider
2386
+ - Removed Trinity Large Preview Free model from OpenCode provider
2387
+ - Removed MiniMax M2.1 Free model from OpenCode provider
2388
+ - Removed deprecated Anthropic model entries: `anthropic-model-3-5-haiku-latest`, `anthropic-model-3-5-haiku-20241022`, `anthropic-model-3-7-sonnet-20250219`, `anthropic-model-3-7-sonnet-latest`, `anthropic-model-3-opus-20240229`, `anthropic-model-3-sonnet-20240229` ([#33](https://github.com/can1357/gajae-code/issues/33))
2389
+
2390
+ ### Fixed
2391
+
2392
+ - Added deprecation filter in model generation script to prevent re-adding deprecated Anthropic models ([#33](https://github.com/can1357/gajae-code/issues/33))
2393
+
2394
+ ## [11.14.1] - 2026-02-12
2395
+
2396
+ ### Added
2397
+
2398
+ - Added prompt-caching-scope-2026-01-05 beta feature support
2399
+
2400
+ ### Changed
2401
+
2402
+ - Updated Anthropic Code version header to 2.1.39
2403
+ - Updated runtime version header to v24.13.1 and package version to 0.73.0
2404
+ - Increased request timeout from 60s to 600s
2405
+ - Reordered Accept-Encoding header values for compression preference
2406
+ - Updated OAuth authorization and token endpoints to use platform.anthropic-model.com
2407
+ - Expanded OAuth scopes to include user:sessions:anthropic-model_code and user:mcp_servers
2408
+
2409
+ ### Removed
2410
+
2411
+ - Removed anthropic-model-code-20250219 beta feature from default models
2412
+ - Removed fine-grained-tool-streaming-2025-05-14 beta feature
2413
+
2414
+ ## [11.13.1] - 2026-02-12
2415
+
2416
+ ### Added
2417
+
2418
+ - Added Perplexity (Pro/Max) OAuth login support via native macOS app extraction or email OTP authentication
2419
+ - Added `loginPerplexity` and `refreshPerplexityToken` functions for Perplexity account integration
2420
+ - Added Socket.IO v4 client implementation for authenticated WebSocket communication with Perplexity API
2421
+
2422
+ ## [11.12.0] - 2026-02-11
2423
+
2424
+ ### Changed
2425
+
2426
+ - Increased maximum retry attempts for OpenAI code requests from 2 to 5 to improve reliability on transient failures
2427
+
2428
+ ### Fixed
2429
+
2430
+ - Fixed tool result content handling in Anthropic provider to provide fallback error message when content is empty
2431
+ - Improved retry delay calculation to parse delay values from error response bodies (e.g., 'Please try again in 225ms')
2432
+
2433
+ ## [11.11.0] - 2026-02-10
2434
+
2435
+ ### Breaking Changes
2436
+
2437
+ - Replaced `./models.generated` export with `./models.json` - update imports from `import { MODELS } from './models.generated'` to `import MODELS from './models.json' with { type: 'json' }`
2438
+
2439
+ ### Added
2440
+
2441
+ - Added TypeScript type declarations for `models.json` to enable proper type inference when importing the JSON file
2442
+
2443
+ ### Changed
2444
+
2445
+ - Updated available models in google-antigravity provider with new model variants and updated context window/token limits
2446
+ - Simplified type signatures for `getModel()` and `getModels()` functions for improved usability
2447
+ - Changed models export from TypeScript module to JSON format for improved performance and reduced bundle size
2448
+ - Updated `@anthropic-ai/sdk` dependency from ^0.72.1 to ^0.74.0
2449
+
2450
+ ## [11.10.0] - 2026-02-10
2451
+
2452
+ ### Added
2453
+
2454
+ - Added support for Kimi K2, K2 Turbo Preview, and K2.5 models with reasoning capabilities
2455
+
2456
+ ### Fixed
2457
+
2458
+ - Fixed Anthropic model Opus 4.6 context window to 200K across all providers (was incorrectly set to 1M)
2459
+ - Fixed Anthropic model Sonnet 4 context window to 200K across multiple providers (was incorrectly set to 1M)
2460
+
2461
+ ## [11.8.0] - 2026-02-10
2462
+
2463
+ ### Added
2464
+
2465
+ - Added `auto` model alias for OpenRouter with automatic model routing
2466
+ - Added `openrouter/aurora-alpha` model with reasoning capabilities
2467
+ - Added `qwen/qwen3-max-thinking` model with extended context window support
2468
+ - Added support for `parametersJsonSchema` in Google Gemini tool definitions for improved JSON Schema compatibility
2469
+
2470
+ ### Changed
2471
+
2472
+ - Updated Anthropic model Sonnet 4 and 4.5 context window from 1M to 200K tokens to reflect actual limits
2473
+ - Updated Anthropic model Opus 4.6 context window to 200K tokens across providers
2474
+ - Changed default `reasoningSummary` for OpenAI code provider from `undefined` to `auto`
2475
+ - Updated Qwen model pricing and context window specifications across multiple variants
2476
+ - Modified Google Gemini CLI system instruction to use compact format
2477
+ - Changed tool parameter handling for Anthropic model models on Google Cloud Code Assist to use legacy `parameters` field for API translation
2478
+
2479
+ ### Removed
2480
+
2481
+ - Removed `glm-4.7-free` model from OpenCode provider
2482
+ - Removed `qwen3-coder` model from OpenCode provider
2483
+ - Removed `ai21/jamba-mini-1.7` model from OpenRouter
2484
+ - Removed `stepfun-ai/step3` model from OpenRouter
2485
+ - Removed duplicate test suite for Google Antigravity Provider with `gemini-3-pro-high`
2486
+
2487
+ ### Fixed
2488
+
2489
+ - Fixed Amazon Bedrock HTTP/1.1 handler import to use direct import instead of dynamic import
2490
+ - Fixed Qwen model context window and pricing inconsistencies across OpenRouter
2491
+ - Fixed cache read pricing for multiple Qwen models
2492
+ - Fixed OpenAI code provider reasoning effort clamping for `gpt-5.3-openai-code` model
2493
+
2494
+ ## [11.7.1] - 2026-02-07
2495
+
2496
+ ### Added
2497
+
2498
+ - Added Anthropic model Opus 4.6 Thinking model for Antigravity provider
2499
+ - Added Gemini 2.5 Flash, Gemini 2.5 Flash Thinking, and Gemini 2.5 Pro models for Antigravity provider
2500
+ - Added Pony Alpha model via OpenRouter
2501
+
2502
+ ### Changed
2503
+
2504
+ - Updated Antigravity models to use free tier pricing (0 cost) across all models
2505
+ - Changed Antigravity model fetching to dynamically load from API when credentials are available, with hardcoded fallback models
2506
+ - Updated Anthropic model Opus 4.6 context window from 200,000 to 1,000,000 tokens across Bedrock regions
2507
+ - Updated Anthropic model Opus 4.6 cache pricing from 1.5/18.75 to 0.5/6.25 for EU and US regions
2508
+ - Updated Antigravity model pricing to free tier (0 cost) for Anthropic model Opus 4.5 Thinking, Anthropic model Sonnet 4.5 Thinking, Gemini 3 Flash, Gemini 3 Pro variants, and GPT-OSS 120B Medium
2509
+ - Updated GPT-OSS 120B Medium reasoning capability from false to true
2510
+ - Updated Gemini 3 Flash max tokens from 65,535 to 65,536
2511
+ - Updated Anthropic model Opus 4.5 Thinking display name formatting to include parentheses
2512
+ - Updated various model pricing and context window parameters across OpenRouter and other providers
2513
+ - Removed Anthropic model Opus 4.6 20260205 model from Anthropic provider
2514
+
2515
+ ### Fixed
2516
+
2517
+ - Fixed Anthropic model Opus 4.6 model ID format by removing version suffix (:0) in Bedrock configurations
2518
+ - Fixed Llama 3.1 70B Instruct pricing and context window parameters
2519
+ - Fixed Mistral model pricing and cache read costs
2520
+ - Fixed DeepSeek and other model pricing inconsistencies
2521
+ - Fixed Qwen model pricing and token limits
2522
+ - Fixed GLM model pricing and context window specifications
2523
+
2524
+ ## [11.6.0] - 2026-02-07
2525
+
2526
+ ### Added
2527
+
2528
+ - Added Bedrock cache retention support with `PI_CACHE_RETENTION` env var and per-request `cacheRetention` option
2529
+ - Added adaptive thinking support for Bedrock Opus 4.6+ models
2530
+ - Added `AWS_BEDROCK_SKIP_AUTH` env var to support unauthenticated Bedrock proxies
2531
+ - Added `AWS_BEDROCK_FORCE_HTTP1` env var to force HTTP/1.1 for custom Bedrock endpoints
2532
+ - Re-exported `Static`, `TSchema`, and `Type` from `@sinclair/typebox`
2533
+
2534
+ ### Fixed
2535
+
2536
+ - Fixed OpenAI Responses storage disabled by default (`store: false`)
2537
+ - Fixed reasoning effort clamping for gpt-5.3 OpenAI code models (minimal -> low)
2538
+ - Fixed Bedrock `supportsPromptCaching` to also check model cost fields
2539
+
2540
+ ## [11.5.1] - 2026-02-07
2541
+
2542
+ ### Fixed
2543
+
2544
+ - Fixed schema normalization to handle array-valued `type` fields by converting them to a single type with nullable flag for Google provider compatibility
2545
+
2546
+ ## [11.3.0] - 2026-02-06
2547
+
2548
+ ### Added
2549
+
2550
+ - Added `cacheRetention` option to control prompt cache retention preference ('none', 'short', 'long') across providers
2551
+ - Added `maxRetryDelayMs` option to cap server-requested retry delays and fail fast when delays exceed the limit
2552
+ - Added `effort` option for Anthropic Opus 4.6+ models to control adaptive thinking effort levels ('low', 'medium', 'high', 'max')
2553
+ - Added support for Anthropic Opus 4.6+ adaptive thinking mode that lets Anthropic model decide when and how much to think
2554
+ - Added `PI_AI_ANTIGRAVITY_VERSION` environment variable to customize Antigravity sandbox endpoint version
2555
+ - Exported `convertAnthropicMessages` function for converting message formats to Anthropic API
2556
+ - Automatic fallback for Anthropic assistant-prefill requests: appends synthetic user "Continue." message when conversation ends with assistant turn to maintain API compatibility
2557
+
2558
+ ### Changed
2559
+
2560
+ - Changed `supportsXhigh()` to include GPT-5.1 OpenAI code Max and broaden Anthropic support to all Anthropic Messages API models with budget-based thinking capability
2561
+ - Changed Anthropic thinking mode to use adaptive thinking for Opus 4.6+ models instead of budget-based thinking
2562
+ - Changed `supportsXhigh()` to support GPT-5.2/5.3 and Anthropic Opus 4.6+ models with adaptive thinking
2563
+ - Changed prompt caching to respect `cacheRetention` option and support TTL configuration for Anthropic
2564
+ - Changed OpenAI tool definitions to conditionally include `strict` field only when provider supports it
2565
+ - Changed Qwen model support to use `enable_thinking` boolean parameter instead of OpenAI-style reasoning_effort
2566
+
2567
+ ### Fixed
2568
+
2569
+ - Fixed indentation and formatting in `convertAnthropicMessages` function
2570
+ - Fixed handling of conversations ending with assistant messages on Anthropic-routed models that reject assistant prefill requests
2571
+
2572
+ ## [11.2.3] - 2026-02-05
2573
+
2574
+ ### Added
2575
+
2576
+ - Added Anthropic model Opus 4.6 model support across multiple providers (Anthropic, Amazon Bedrock, GitHub Copilot, OpenRouter, OpenCode, Vercel AI Gateway)
2577
+ - Added GPT-5.3 OpenAI code model support for OpenAI
2578
+ - Added `readSseJson` utility import for improved SSE stream handling in Google Gemini CLI provider
2579
+
2580
+ ### Changed
2581
+
2582
+ - Updated Google Gemini CLI provider to use `readSseJson` utility for cleaner SSE stream parsing
2583
+ - Updated pricing for Llama 3.1 405B model on Vercel AI Gateway (cache read rate adjusted)
2584
+ - Updated Llama 3.1 405B context window and max tokens on Vercel AI Gateway (256000 for both)
2585
+
2586
+ ### Removed
2587
+
2588
+ - Removed Kimi K2, Kimi K2 Turbo Preview, and Kimi K2.5 models
2589
+ - Removed Deep Cogito Cogito V2 Preview models from OpenRouter
2590
+
2591
+ ## [11.0.0] - 2026-02-05
2592
+
2593
+ ### Changed
2594
+
2595
+ - Replaced direct `Bun.env` access with `getEnv()` utility from `@gajae-code/utils` for consistent environment variable handling across all providers
2596
+ - Updated environment variable names from `GJC_*` prefix to `PI_*` prefix for consistency (e.g., `GJC_CODING_AGENT_DIR` → `PI_CODING_AGENT_DIR`)
2597
+
2598
+ ### Removed
2599
+
2600
+ - Removed automatic environment variable migration from `PI_*` to `GJC_*` prefixes via `migrate-env.ts` module
2601
+
2602
+ ## [10.5.0] - 2026-02-04
2603
+
2604
+ ### Changed
2605
+
2606
+ - Updated @anthropic-ai/sdk to ^0.72.1
2607
+ - Updated @aws-sdk/client-bedrock-runtime to ^3.982.0
2608
+ - Updated @google/genai to ^1.39.0
2609
+ - Updated @smithy/node-http-handler to ^4.4.9
2610
+ - Updated openai to ^6.17.0
2611
+ - Updated @types/node to ^25.2.0
2612
+
2613
+ ### Removed
2614
+
2615
+ - Removed proxy-agent dependency
2616
+ - Removed undici dependency
2617
+
2618
+ ## [9.4.0] - 2026-01-31
2619
+
2620
+ ### Added
2621
+
2622
+ - Added `getEnv()` function to retrieve environment variables from Bun.env, cwd/.env, or ~/.env
2623
+ - Added support for reading .env files from home directory and current working directory
2624
+ - Added support for `exa` and `perplexity` as known providers in `getEnvApiKey()`
2625
+
2626
+ ### Changed
2627
+
2628
+ - Changed `getEnvApiKey()` to check Bun.env, cwd/.env, and ~/.env files in order of precedence
2629
+ - Refactored provider API key resolution to use a declarative service provider map
2630
+
2631
+ ## [9.2.2] - 2026-01-31
2632
+
2633
+ ### Added
2634
+
2635
+ - Added OpenCode Zen provider with API key authentication for accessing multiple AI models
2636
+ - Added 4 new free models via OpenCode: glm-4.7-free, kimi-k2.5-free, minimax-m2.1-free, trinity-large-preview-free
2637
+ - Added glm-4.7-flash model via Zai provider
2638
+ - Added Kimi Code provider with OpenAI and Anthropic API format support
2639
+ - Added prompt cache retention support with PI_CACHE_RETENTION env var
2640
+ - Added overflow patterns for Bedrock, MiniMax, Kimi; reclassified 429 as rate limiting
2641
+ - Added profile endpoint integration to resolve user emails with 24-hour caching
2642
+ - Added automatic token refresh for expired Kimi OAuth credentials
2643
+ - Added Kimi Code OAuth handler with device authorization flow
2644
+ - Added Kimi Code usage provider with quota caching
2645
+ - Added 4 new Kimi Code models (kimi-for-coding, kimi-k2, kimi-k2-turbo-preview, kimi-k2.5)
2646
+ - Added Kimi Code provider integration with OAuth and token management
2647
+ - Added tool-choice utility for mapping unified ToolChoice to provider-specific formats
2648
+ - Added ToolChoice type for controlling tool selection (auto, none, any, required, function)
2649
+
2650
+ ### Changed
2651
+
2652
+ - Updated Kimi K2.5 cache read pricing from 0.1 to 0.08
2653
+ - Updated MiniMax M2 pricing: input 0.6→0.6, output 3→3, cache read 0.1→0.09999999999999999
2654
+ - Updated OpenRouter DeepSeek V3.1 pricing and max tokens: input 0.6→0.5, output 3→2.8, maxTokens 262144→4096
2655
+ - Updated OpenRouter DeepSeek R1 pricing and max tokens: input 0.06→0.049999999999999996, output 0.24→0.19999999999999998, maxTokens 262144→4096
2656
+ - Updated Anthropic Anthropic model 3.5 Sonnet max tokens from 256000 to 65536 on OpenRouter
2657
+ - Updated Vercel AI Gateway Anthropic model 3.5 Sonnet cache read pricing from 0.125 to 0.13
2658
+ - Updated Vercel AI Gateway Anthropic model 3.5 Sonnet New cache read pricing from 0.125 to 0.13
2659
+ - Updated Vercel AI Gateway GPT-5.2 cache read pricing from 0.175 to 0.18 and display name to 'GPT 5.2'
2660
+ - Updated Zai GLM-4.6 cache read pricing from 0.024999999999999998 to 0.03
2661
+ - Updated Zai Qwen QwQ max tokens from 66000 to 16384
2662
+ - Added delta event batching and throttling (50ms, 20 updates/sec max) to AssistantMessageEventStream
2663
+ - Updated MiniMax-M2 pricing: input 1.2→0.6, output 1.2→3, cacheRead 0.6→0.1
2664
+
2665
+ ### Removed
2666
+
2667
+ - Removed OpenRouter google/gemini-2.0-flash-exp:free model
2668
+ - Removed Vercel AI Gateway stealth/sonoma-dusk-alpha and stealth/sonoma-sky-alpha models
2669
+
2670
+ ### Fixed
2671
+
2672
+ - Fixed rate limit issues with Kimi models by always sending max_tokens
2673
+ - Added handling for sensitive stop reason from Anthropic API safety filters
2674
+ - Added optional chaining for safer JSON schema property access in Anthropic provider
2675
+
2676
+ ## [8.6.0] - 2026-01-27
2677
+
2678
+ ### Changed
2679
+
2680
+ - Replaced JSON5 dependency with Bun.JSON5 parsing
2681
+
2682
+ ### Fixed
2683
+
2684
+ - Filtered empty user text blocks for OpenAI-compatible completions and normalized Kimi reasoning_content for OpenRouter tool-call messages
2685
+
2686
+ ## [8.4.0] - 2026-01-25
2687
+
2688
+ ### Added
2689
+
2690
+ - Added Azure OpenAI Responses provider with deployment mapping and resource-based base URL support
2691
+
2692
+ ### Changed
2693
+
2694
+ - Added OpenRouter routing preferences for OpenAI-compatible completions
2695
+
2696
+ ### Fixed
2697
+
2698
+ - Defaulted Google tool call arguments to empty objects when providers omit args
2699
+ - Guarded Responses/OpenAI code streaming deltas against missing content parts and handled arguments.done events
2700
+
2701
+ ## [8.2.1] - 2026-01-24
2702
+
2703
+ ### Fixed
2704
+
2705
+ - Fixed handling of streaming function call arguments in OpenAI responses to properly parse arguments when sent via `response.function_call_arguments.done` events
2706
+
2707
+ ## [8.2.0] - 2026-01-24
2708
+
2709
+ ### Changed
2710
+
2711
+ - Migrated node module imports from named to namespace imports across all packages for consistency with project guidelines
2712
+
2713
+ ## [8.0.0] - 2026-01-23
2714
+
2715
+ ### Fixed
2716
+
2717
+ - Fixed OpenAI Responses API 400 error "function_call without required reasoning item" when switching between models (same provider, different model). The fix omits the `id` field for function_calls from different models to avoid triggering OpenAI's reasoning/function_call pairing validation
2718
+ - Fixed 400 errors when reading multiple images via GitHub Copilot's Anthropic model models. Anthropic model requires tool_use -> tool_result adjacency with no user messages interleaved. Images from consecutive tool results are now batched into a single user message
2719
+
2720
+ ## [7.0.0] - 2026-01-21
2721
+
2722
+ ### Added
2723
+
2724
+ - Added usage tracking system with normalized schema for provider quota/limit endpoints
2725
+ - Added Anthropic model usage provider for 5-hour and 7-day quota windows
2726
+ - Added GitHub Copilot usage provider for chat, completions, and premium requests
2727
+ - Added Google Antigravity usage provider for model quota tracking
2728
+ - Added Google Gemini CLI usage provider for tier-based quota monitoring
2729
+ - Added OpenAI code provider usage provider for primary and secondary rate limit windows
2730
+ - Added ZAI usage provider for token and request quota tracking
2731
+
2732
+ ### Changed
2733
+
2734
+ - Updated Anthropic model usage provider to extract account identifiers from response headers
2735
+ - Updated GitHub Copilot usage provider to include account identifiers in usage reports
2736
+ - Updated Google Gemini CLI usage provider to handle missing reset time gracefully
2737
+
2738
+ ### Fixed
2739
+
2740
+ - Fixed GitHub Copilot usage provider to simplify token handling and improve reliability
2741
+ - Fixed GitHub Copilot usage provider to properly resolve account identifiers for OAuth credentials
2742
+ - Fixed API validation errors when sending empty user messages (resume with `.`) across all providers:
2743
+ - Google Cloud Code Assist (google-shared.ts)
2744
+ - OpenAI Responses API (openai-responses.ts)
2745
+ - OpenAI code provider Responses API (openai-code-responses.ts)
2746
+ - Cursor (cursor.ts)
2747
+ - Amazon Bedrock (amazon-bedrock.ts)
2748
+ - Clamped OpenAI code provider reasoning effort "minimal" to "low" for gpt-5.2 models to avoid API errors
2749
+ - Fixed GitHub Copilot usage fallback to internal quota endpoints when billing usage is unavailable
2750
+ - Fixed GitHub Copilot usage metadata to include account identifiers for report dedupe
2751
+ - Fixed Anthropic usage metadata extraction to include account identifiers when provided by the usage endpoint
2752
+ - Fixed Gemini CLI usage windows to consistently label quota windows for display suppression
2753
+
2754
+ ## [6.9.69] - 2026-01-21
2755
+
2756
+ ### Added
2757
+
2758
+ - Added duration and time-to-first-token (ttft) metrics to all AI provider responses
2759
+ - Added performance tracking for streaming responses across all providers
2760
+
2761
+ ## [6.9.0] - 2026-01-21
2762
+
2763
+ ### Removed
2764
+
2765
+ - Removed openai-code provider exports from main package index
2766
+ - Removed openai-code prompt utilities and moved them inline
2767
+ - Removed vitest configuration file
2768
+
2769
+ ## [6.8.4] - 2026-01-21
2770
+
2771
+ ### Changed
2772
+
2773
+ - Updated prompt caching strategy to follow Anthropic's recommended hierarchy
2774
+ - Fixed token usage tracking to properly handle cumulative output tokens from message_delta events
2775
+ - Improved message validation to filter out empty or invalid content blocks
2776
+ - Increased OAuth callback timeout from 120 seconds to 120,000 milliseconds
2777
+
2778
+ ## [6.8.3] - 2026-01-21
2779
+
2780
+ ### Added
2781
+
2782
+ - Added `headers` option to all providers for custom request headers
2783
+ - Added `onPayload` hook to observe provider request payloads before sending
2784
+ - Added `strictResponsesPairing` option for Azure OpenAI Responses API compatibility
2785
+ - Added `originator` option to `loginOpenAIOpenAI code` for custom OAuth flow identification
2786
+ - Added per-request `headers` and `onPayload` hooks to `StreamOptions`
2787
+ - Added `originator` option to `loginOpenAIOpenAI code`
2788
+
2789
+ ### Fixed
2790
+
2791
+ - Fixed tool call ID normalization for OpenAI Responses API cross-provider handoffs
2792
+ - Skipped errored or aborted assistant messages during cross-provider transforms
2793
+ - Detected AWS ECS/IRSA credentials for Bedrock authentication checks
2794
+ - Detected AWS ECS/IRSA credentials for Bedrock authentication checks
2795
+ - Normalized Responses API tool call IDs during handoffs and refreshed handoff tests
2796
+ - Enforced strict tool call/result pairing for Azure OpenAI Responses API
2797
+ - Skipped errored or aborted assistant messages during cross-provider transforms
2798
+
2799
+ ### Security
2800
+
2801
+ - Enhanced AWS credential detection to support ECS task roles and IRSA web identity tokens
2802
+
2803
+ ## [6.8.2] - 2026-01-21
2804
+
2805
+ ### Fixed
2806
+
2807
+ - Improved error handling for aborted requests in Google Gemini CLI provider
2808
+ - Enhanced OAuth callback flow to handle manual input errors gracefully
2809
+ - Fixed login cancellation handling in GitHub Copilot OAuth flow
2810
+ - Removed fallback manual input from OpenAI code provider OAuth flow
2811
+
2812
+ ### Security
2813
+
2814
+ - Hardened database file permissions to prevent credential leakage
2815
+ - Set secure directory permissions (0o700) for credential storage
2816
+
2817
+ ## [6.8.0] - 2026-01-20
2818
+
2819
+ ### Added
2820
+
2821
+ - Added `logout` command to CLI for OAuth provider logout
2822
+ - Added `status` command to show logged-in providers and token expiry
2823
+ - Added persistent credential storage using SQLite database
2824
+ - Added OAuth callback server with automatic port fallback
2825
+ - Added HTML callback page with success/error states
2826
+ - Added support for Cursor OAuth provider
2827
+
2828
+ ### Changed
2829
+
2830
+ - Updated Promise.withResolvers usage for better compatibility
2831
+ - Replaced custom sleep implementations with Bun.sleep and abortableSleep
2832
+ - Simplified SSE stream parsing using readLines utility
2833
+ - Updated test framework from vitest to bun:test
2834
+ - Replaced temp directory creation with TempDir API
2835
+ - Changed credential storage from auth.json to ~/.gjc/agent/agent.db
2836
+ - Changed CLI command examples from npx to bunx
2837
+ - Refactored OAuth flows to use common callback server base class
2838
+ - Updated OAuth provider interfaces to use controller pattern
2839
+
2840
+ ### Fixed
2841
+
2842
+ - Fixed OAuth callback handling with improved error states
2843
+ - Fixed token refresh for all OAuth providers
2844
+
2845
+ ## [6.7.670] - 2026-01-19
2846
+
2847
+ ### Changed
2848
+
2849
+ - Updated Anthropic Code compatibility headers and version
2850
+ - Improved OAuth token handling with proper state generation
2851
+ - Enhanced cache control for tool and user message blocks
2852
+ - Simplified tool name prefixing for OAuth traffic
2853
+ - Updated PKCE verifier generation for better security
2854
+
2855
+ ## [5.7.67] - 2026-01-18
2856
+
2857
+ ### Fixed
2858
+
2859
+ - Added error handling for unknown OAuth providers
2860
+
2861
+ ## [5.6.77] - 2026-01-18
2862
+
2863
+ ### Fixed
2864
+
2865
+ - Prevented duplicate tool results for errored or aborted messages when results already exist
2866
+
2867
+ ## [5.6.7] - 2026-01-18
2868
+
2869
+ ### Added
2870
+
2871
+ - Added automatic retry logic for OpenAI code provider responses with configurable delay and max retries
2872
+ - Added tool call ID sanitization for Amazon Bedrock to ensure valid characters
2873
+ - Added tool argument validation that coerces JSON-encoded strings for expected non-string types
2874
+
2875
+ ### Changed
2876
+
2877
+ - Updated environment variable prefix from PI* to GJC* for better consistency
2878
+ - Added automatic migration for legacy PI* environment variables to GJC* equivalents
2879
+ - Adjusted Bedrock Anthropic model thinking budgets to reserve output tokens when maxTokens is too low
2880
+
2881
+ ### Fixed
2882
+
2883
+ - Fixed orphaned tool call handling to ensure proper tool_use/tool_result pairing for all assistant messages
2884
+ - Fixed message transformation to insert synthetic tool results for errored/aborted assistant messages with tool calls
2885
+ - Fixed tool prefix handling in Anthropic model provider to use case-insensitive comparison
2886
+ - Fixed Gemini 3 model handling to treat unsigned tool calls as context-only with anti-mimicry context
2887
+ - Fixed message transformation to filter out empty error messages from conversation history
2888
+ - Fixed OpenAI completions provider compatibility detection to use provider metadata
2889
+ - Fixed OpenAI completions provider to avoid using developer role for opencode provider
2890
+ - Fixed orphaned tool call handling to skip synthetic results for errored assistant messages
2891
+
2892
+ ## [5.5.0] - 2026-01-18
2893
+
2894
+ ### Changed
2895
+
2896
+ - Updated User-Agent header from 'opencode' to 'pi' for OpenAI code provider requests
2897
+ - Simplified OpenAI code system prompt instructions
2898
+ - Removed bridge text override from OpenAI code system prompt builder
2899
+
2900
+ ## [5.3.0] - 2026-01-15
2901
+
2902
+ ### Changed
2903
+
2904
+ - Replaced detailed OpenAI code system instructions with simplified pi assistant instructions
2905
+ - Updated internal documentation references to use pi-internal:// protocol
2906
+
2907
+ ## [5.1.0] - 2026-01-14
2908
+
2909
+ ### Added
2910
+
2911
+ - Added Amazon Bedrock provider with `bedrock-converse-stream` API for Anthropic model models via AWS
2912
+ - Added MiniMax provider with OpenAI-compatible API
2913
+ - Added EU cross-region inference model variants for Anthropic model models on Bedrock
2914
+
2915
+ ### Fixed
2916
+
2917
+ - Fixed Gemini CLI provider retries with proper error handling, retry delays from headers, and empty stream retry logic
2918
+ - Fixed numbered list items showing "1." for all items when code blocks break list continuity (via `start` property)
2919
+
2920
+ ## [5.0.0] - 2026-01-12
2921
+
2922
+ ### Added
2923
+
2924
+ - Added support for `xhigh` thinking level in `thinkingBudgets` configuration
2925
+
2926
+ ### Changed
2927
+
2928
+ - Changed Anthropic thinking token budgets: minimal (1024→3072), low (2048→6144), medium (8192→12288), high (16384→24576)
2929
+ - Changed Google thinking token budgets: minimal (1024), low (2048→4096), medium (8192), high (16384), xhigh (24575)
2930
+ - Changed `supportsXhigh()` to return true for all Anthropic models
2931
+
2932
+ ## [4.6.0] - 2026-01-12
2933
+
2934
+ ### Fixed
2935
+
2936
+ - Fixed incorrect classification of thought signatures in Google Gemini responses—thought signatures are now correctly treated as metadata rather than thinking content indicators
2937
+ - Fixed thought signature handling in Google Gemini CLI and Vertex AI streaming to properly preserve signatures across text deltas
2938
+ - Fixed Google schema sanitization stripping property names that match schema keywords (e.g., "pattern", "format") from tool definitions
2939
+
2940
+ ## [4.4.9] - 2026-01-12
2941
+
2942
+ ### Fixed
2943
+
2944
+ - Fixed Google provider schema sanitization to strip additional unsupported JSON Schema fields (patternProperties, additionalProperties, min/max constraints, pattern, format)
2945
+
2946
+ ## [4.4.8] - 2026-01-12
2947
+
2948
+ ### Fixed
2949
+
2950
+ - Fixed Google provider schema sanitization to properly collapse `anyOf`/`oneOf` with const values into enum arrays
2951
+ - Fixed const-to-enum conversion to infer type from the const value when type is not specified
2952
+
2953
+ ## [4.4.6] - 2026-01-11
2954
+
2955
+ ### Fixed
2956
+
2957
+ - Fixed tool parameter schema sanitization to only apply Google-specific transformations for Gemini models, preserving original schemas for other model types
2958
+
2959
+ ## [4.4.5] - 2026-01-11
2960
+
2961
+ ### Changed
2962
+
2963
+ - Exported `sanitizeSchemaForGoogle` utility function for external use
2964
+
2965
+ ### Fixed
2966
+
2967
+ - Fixed Google provider schema sanitization to strip additional unsupported JSON Schema fields ($schema, $ref, $defs, format, examples, and others)
2968
+ - Fixed Google provider to ignore `additionalProperties: false` which is unsupported by the API
2969
+
2970
+ ## [4.4.4] - 2026-01-11
2971
+
2972
+ ### Fixed
2973
+
2974
+ - Fixed Cursor todo updates to bridge update_todos tool calls to the local todo_write tool
2975
+
2976
+ ## [4.3.0] - 2026-01-11
2977
+
2978
+ ### Added
2979
+
2980
+ - Added debug log filtering and display script for Cursor JSONL logs with follow mode and coalescing support
2981
+ - Added protobuf definition extractor script to reconstruct .proto files from bundled JavaScript
2982
+ - Added conversation state caching to persist context across multiple Cursor API requests in the same session
2983
+ - Added shell streaming support for real-time stdout/stderr output during command execution
2984
+ - Added JSON5 parsing for MCP tool arguments with Python-style boolean and None value normalization
2985
+ - Added Cursor provider with support for Anthropic model, GPT, and Gemini models via Cursor's agent API
2986
+ - Added OAuth authentication flow for Cursor including login, token refresh, and expiry detection
2987
+ - Added `cursor-agent` API type with streaming support and tool execution handlers
2988
+ - Added Cursor model definitions including Anthropic model 4.5, GPT-5.x, Gemini 3, and Grok variants
2989
+ - Added model generation script to automatically fetch and update AI model definitions from models.dev and OpenRouter APIs
2990
+
2991
+ ### Changed
2992
+
2993
+ - Changed Cursor debug logging to use structured JSONL format with automatic MCP argument decoding
2994
+ - Changed MCP tool argument decoding to use protobuf Value schema for improved type handling
2995
+ - Changed tool advertisement to filter Cursor native tools (bash, read, write, delete, ls, grep, lsp) instead of only exposing mcp\_ prefixed tools
2996
+
2997
+ ### Fixed
2998
+
2999
+ - Fixed Cursor conversation history serialization so subagents retain task context and can call complete
3000
+
3001
+ ## [4.2.1] - 2026-01-11
3002
+
3003
+ ### Changed
3004
+
3005
+ - Updated `reasoningSummary` option to accept only `"auto"`, `"concise"`, `"detailed"`, or `null` (removed `"off"` and `"on"` values)
3006
+ - Changed default `reasoningSummary` from `"auto"` to `"detailed"`
3007
+ - OpenAI code provider: switched to bundled system prompt matching opencode, changed originator to "opencode", simplified prompt handling
3008
+
3009
+ ### Fixed
3010
+
3011
+ - Fixed Cloud Code Assist tool schema conversion to avoid unsupported `const` fields
3012
+
3013
+ ## [4.0.0] - 2026-01-10
3014
+
3015
+ ### Added
3016
+
3017
+ - Added `betas` option in `AnthropicOptions` for passing custom Anthropic beta feature flags
3018
+ - OpenCode Zen provider support with 26 models (Anthropic model, GPT, Gemini, Grok, Kimi, GLM, Qwen, etc.). Set `OPENCODE_API_KEY` env var to use.
3019
+ - `thinkingBudgets` option in `SimpleStreamOptions` for customizing token budgets per thinking level on token-based providers
3020
+ - `sessionId` option in `StreamOptions` for providers that support session-based caching. OpenAI code provider provider uses this to set `prompt_cache_key` and routing headers.
3021
+ - `supportsUsageInStreaming` compatibility flag for OpenAI-compatible providers that reject `stream_options: { include_usage: true }`. Defaults to `true`. Set to `false` in model config for providers like gatewayz.ai.
3022
+ - `GOOGLE_APPLICATION_CREDENTIALS` env var support for Vertex AI credential detection (standard for CI/production)
3023
+ - Exported OpenAI code provider utilities: `CacheMetadata`, `getOpenAI codeInstructions`, `getModelFamily`, `ModelFamily`, `buildOpenAI codePiBridge`, `buildOpenAI codeSystemPrompt`, `OpenAI codeSystemPrompt`
3024
+ - Headless OAuth support for all callback-server providers (Google Gemini CLI, Antigravity, OpenAI code provider): paste redirect URL when browser callback is unreachable
3025
+ - Cancellable GitHub Copilot device code polling via AbortSignal
3026
+ - Improved error messages for OpenRouter providers by including raw metadata from upstream errors
3027
+
3028
+ ### Changed
3029
+
3030
+ - Changed Anthropic provider to include Anthropic Code system instruction for all API key types, not just OAuth tokens (except Haiku models)
3031
+ - Changed Anthropic OAuth tool naming to use `proxy_` prefix instead of mapping to Anthropic Code tool names, avoiding potential name collisions
3032
+ - Changed Anthropic provider to include Anthropic Code headers for all requests, not just OAuth tokens
3033
+ - Anthropic provider now maps tool names to Anthropic Code's exact tool names (Read, Write, Edit, Bash, Grep, Glob) instead of using prefixed names
3034
+ - OpenAI Completions provider now disables strict mode on tools to allow optional parameters without null unions
3035
+
3036
+ ### Fixed
3037
+
3038
+ - Fixed Anthropic OAuth code parsing to accept full redirect URLs in addition to raw authorization codes
3039
+ - Fixed Anthropic token refresh to preserve existing refresh token when server doesn't return a new one
3040
+ - Fixed thinking mode being enabled when tool_choice forces a specific tool, which is unsupported
3041
+ - Fixed max_tokens being too low when thinking budget is set, now auto-adjusts to model's maxTokens
3042
+ - Google Cloud Code Assist OAuth for paid subscriptions: properly handles long-running operations for project provisioning, supports `GOOGLE_CLOUD_PROJECT` / `GOOGLE_CLOUD_PROJECT_ID` env vars for paid tiers
3043
+ - `os.homedir()` calls at module load time; now resolved lazily when needed
3044
+ - OpenAI Responses tool strict flag to use a boolean for LM Studio compatibility
3045
+ - Gemini CLI abort handling: detect native `AbortError` in retry catch block, cancel SSE reader when abort signal fires
3046
+ - Antigravity provider 429 errors by aligning request payload with CLIProxyAPI v6.6.89
3047
+ - Thinking block handling for cross-model conversations: thinking blocks are now converted to plain text when switching models
3048
+ - OpenAI code provider context window from 400,000 to 272,000 tokens to match OpenAI code CLI defaults
3049
+ - OpenAI code SSE error events to surface message, code, and status
3050
+ - Context overflow detection for `context_length_exceeded` error codes
3051
+ - OpenAI code provider now always includes `reasoning.encrypted_content` even when custom `include` options are passed
3052
+ - OpenAI code requests now omit the `reasoning` field entirely when thinking is off
3053
+ - Crash when pasting text with trailing whitespace exceeding terminal width
3054
+
3055
+ ## [3.37.1] - 2026-01-10
3056
+
3057
+ ### Added
3058
+
3059
+ - Added automatic type coercion for tool arguments when LLMs return JSON-encoded strings instead of native types (numbers, booleans, arrays, objects)
3060
+
3061
+ ### Changed
3062
+
3063
+ - Changed tool argument validation to attempt JSON parsing and type coercion before rejecting mismatched types
3064
+ - Changed validation error messages to include both original and normalized arguments when coercion was attempted
3065
+
3066
+ ## [3.37.0] - 2026-01-10
3067
+
3068
+ ### Changed
3069
+
3070
+ - Enabled type coercion in JSON schema validation to automatically convert compatible types
3071
+
3072
+ ## [3.35.0] - 2026-01-09
3073
+
3074
+ ### Added
3075
+
3076
+ - Enhanced error messages to include retry-after timing information from API rate limit headers
3077
+
3078
+ ## [0.42.0] - 2026-01-09
3079
+
3080
+ ### Added
3081
+
3082
+ - Added OpenCode Zen provider support with 26 models (Anthropic model, GPT, Gemini, Grok, Kimi, GLM, Qwen, etc.). Set `OPENCODE_API_KEY` env var to use.
3083
+
3084
+ ## [0.39.0] - 2026-01-08
3085
+
3086
+ ### Fixed
3087
+
3088
+ - Fixed Gemini CLI abort handling: detect native `AbortError` in retry catch block, cancel SSE reader when abort signal fires ([#568](https://github.com/badlogic/pi-mono/pull/568) by [@tmustier](https://github.com/tmustier))
3089
+ - Fixed Antigravity provider 429 errors by aligning request payload with CLIProxyAPI v6.6.89: inject Antigravity system instruction with `role: "user"`, set `requestType: "agent"`, and use `antigravity` userAgent. Added bridge prompt to override Antigravity behavior (identity, paths, web dev guidelines) with Pi defaults. ([#571](https://github.com/badlogic/pi-mono/pull/571) by [@ben-vargas](https://github.com/ben-vargas))
3090
+ - Fixed thinking block handling for cross-model conversations: thinking blocks are now converted to plain text (no `<thinking>` tags) when switching models. Previously, `<thinking>` tags caused models to mimic the pattern and output literal tags. Also fixed empty thinking blocks causing API errors. ([#561](https://github.com/badlogic/pi-mono/issues/561))
3091
+
3092
+ ## [0.38.0] - 2026-01-08
3093
+
3094
+ ### Added
3095
+
3096
+ - `thinkingBudgets` option in `SimpleStreamOptions` for customizing token budgets per thinking level on token-based providers ([#529](https://github.com/badlogic/pi-mono/pull/529) by [@melihmucuk](https://github.com/melihmucuk))
3097
+
3098
+ ### Breaking Changes
3099
+
3100
+ - Removed OpenAI code provider model aliases (`gpt-5`, `gpt-5-mini`, `gpt-5-nano`, `openai-code-mini-latest`, `gpt-5-openai-code`, `gpt-5.1-openai-code`, `gpt-5.1-chat-latest`). Use canonical model IDs: `gpt-5.1`, `gpt-5.1-openai-code-max`, `gpt-5.1-openai-code-mini`, `gpt-5.2`, `gpt-5.2-openai-code`. ([#536](https://github.com/badlogic/pi-mono/pull/536) by [@ghoulr](https://github.com/ghoulr))
3101
+
3102
+ ### Fixed
3103
+
3104
+ - Fixed OpenAI code provider context window from 400,000 to 272,000 tokens to match OpenAI code CLI defaults and prevent 400 errors. ([#536](https://github.com/badlogic/pi-mono/pull/536) by [@ghoulr](https://github.com/ghoulr))
3105
+ - Fixed OpenAI code SSE error events to surface message, code, and status. ([#551](https://github.com/badlogic/pi-mono/pull/551) by [@tmustier](https://github.com/tmustier))
3106
+ - Fixed context overflow detection for `context_length_exceeded` error codes.
3107
+
3108
+ ## [0.37.6] - 2026-01-06
3109
+
3110
+ ### Added
3111
+
3112
+ - Exported OpenAI code provider utilities: `CacheMetadata`, `getOpenAI codeInstructions`, `getModelFamily`, `ModelFamily`, `buildOpenAI codePiBridge`, `buildOpenAI codeSystemPrompt`, `OpenAI codeSystemPrompt` ([#510](https://github.com/badlogic/pi-mono/pull/510) by [@mitsuhiko](https://github.com/mitsuhiko))
3113
+
3114
+ ## [0.37.3] - 2026-01-06
3115
+
3116
+ ### Added
3117
+
3118
+ - `sessionId` option in `StreamOptions` for providers that support session-based caching. OpenAI code provider provider uses this to set `prompt_cache_key` and routing headers.
3119
+
3120
+ ## [0.37.2] - 2026-01-05
3121
+
3122
+ ### Fixed
3123
+
3124
+ - OpenAI code provider now always includes `reasoning.encrypted_content` even when custom `include` options are passed ([#484](https://github.com/badlogic/pi-mono/pull/484) by [@kim0](https://github.com/kim0))
3125
+
3126
+ ## [0.37.0] - 2026-01-05
3127
+
3128
+ ### Breaking Changes
3129
+
3130
+ - OpenAI code provider models no longer have per-thinking-level variants (e.g., `gpt-5.2-openai-code-high`). Use the base model ID and set thinking level separately. The OpenAI code provider clamps reasoning effort to what each model supports internally. (initial implementation by [@ben-vargas](https://github.com/ben-vargas) in [#472](https://github.com/badlogic/pi-mono/pull/472))
3131
+
3132
+ ### Added
3133
+
3134
+ - Headless OAuth support for all callback-server providers (Google Gemini CLI, Antigravity, OpenAI code provider): paste redirect URL when browser callback is unreachable ([#428](https://github.com/badlogic/pi-mono/pull/428) by [@ben-vargas](https://github.com/ben-vargas), [#468](https://github.com/badlogic/pi-mono/pull/468) by [@crcatala](https://github.com/crcatala))
3135
+ - Cancellable GitHub Copilot device code polling via AbortSignal
3136
+
3137
+ ### Fixed
3138
+
3139
+ - OpenAI code requests now omit the `reasoning` field entirely when thinking is off, letting the backend use its default instead of forcing a value. ([#472](https://github.com/badlogic/pi-mono/pull/472))
3140
+
3141
+ ## [0.36.0] - 2026-01-05
3142
+
3143
+ ### Added
3144
+
3145
+ - OpenAI code provider OAuth provider with Responses API streaming support: `openai-code-responses` streaming provider with SSE parsing, tool-call handling, usage/cost tracking, and PKCE OAuth flow ([#451](https://github.com/badlogic/pi-mono/pull/451) by [@kim0](https://github.com/kim0))
3146
+
3147
+ ### Fixed
3148
+
3149
+ - Vertex AI dummy value for `getEnvApiKey()`: Returns `"<authenticated>"` when Application Default Credentials are configured (`~/.config/gcloud/application_default_credentials.json` exists) and both `GOOGLE_CLOUD_PROJECT` (or `GCLOUD_PROJECT`) and `GOOGLE_CLOUD_LOCATION` are set. This allows `streamSimple()` to work with Vertex AI without explicit `apiKey` option. The ADC credentials file existence check is cached per-process to avoid repeated filesystem access.
3150
+
3151
+ ## [0.32.3] - 2026-01-03
3152
+
3153
+ ### Fixed
3154
+
3155
+ - Google Vertex AI models no longer appear in available models list without explicit authentication. Previously, `getEnvApiKey()` returned a dummy value for `google-vertex`, causing models to show up even when Google Cloud ADC was not configured.
3156
+
3157
+ ## [0.32.0] - 2026-01-03
3158
+
3159
+ ### Added
3160
+
3161
+ - Vertex AI provider with ADC (Application Default Credentials) support. Authenticate with `gcloud auth application-default login`, set `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`, and access Gemini models via Vertex AI. ([#300](https://github.com/badlogic/pi-mono/pull/300) by [@default-anton](https://github.com/default-anton))
3162
+
3163
+ ### Fixed
3164
+
3165
+ - **Gemini CLI rate limit handling**: Added automatic retry with server-provided delay for 429 errors. Parses delay from error messages like "Your quota will reset after 39s" and waits accordingly. Falls back to exponential backoff for other transient errors. ([#370](https://github.com/badlogic/pi-mono/issues/370))
3166
+
3167
+ ## [0.31.0] - 2026-01-02
3168
+
3169
+ ### Breaking Changes
3170
+
3171
+ - **Agent API moved**: All agent functionality (`agentLoop`, `agentLoopContinue`, `AgentContext`, `AgentEvent`, `AgentTool`, `AgentToolResult`, etc.) has moved to `@mariozechner/pi-agent-core`. Import from that package instead of `@gajae-code/ai`.
3172
+
3173
+ ### Added
3174
+
3175
+ - **`GoogleThinkingLevel` type**: Exported type that mirrors Google's `ThinkingLevel` enum values (`"THINKING_LEVEL_UNSPECIFIED" | "MINIMAL" | "LOW" | "MEDIUM" | "HIGH"`). Allows configuring Gemini thinking levels without importing from `@google/genai`.
3176
+ - **`ANTHROPIC_OAUTH_TOKEN` env var**: Now checked before `ANTHROPIC_API_KEY` in `getEnvApiKey()`, allowing OAuth tokens to take precedence.
3177
+ - **`event-stream.js` export**: `AssistantMessageEventStream` utility now exported from package index.
3178
+
3179
+ ### Changed
3180
+
3181
+ - **OAuth uses Web Crypto API**: PKCE generation and OAuth flows now use Web Crypto API (`crypto.subtle`) instead of Node.js `crypto` module. This improves browser compatibility while still working in Node.js 20+.
3182
+ - **Deterministic model generation**: `generate-models.ts` now sorts providers and models alphabetically for consistent output across runs. ([#332](https://github.com/badlogic/pi-mono/pull/332) by [@mrexodia](https://github.com/mrexodia))
3183
+
3184
+ ### Fixed
3185
+
3186
+ - **OpenAI completions empty content blocks**: Empty text or thinking blocks in assistant messages are now filtered out before sending to the OpenAI completions API, preventing validation errors. ([#344](https://github.com/badlogic/pi-mono/pull/344) by [@default-anton](https://github.com/default-anton))
3187
+ - **Thinking token duplication**: Fixed thinking content duplication with chutes.ai provider. The provider was returning thinking content in both `reasoning_content` and `reasoning` fields, causing each chunk to be processed twice. Now only the first non-empty reasoning field is used.
3188
+ - **zAi provider API mapping**: Fixed zAi models to use `openai-completions` API with correct base URL (`https://api.z.ai/api/coding/paas/v4`) instead of incorrect Anthropic API mapping. ([#344](https://github.com/badlogic/pi-mono/pull/344), [#358](https://github.com/badlogic/pi-mono/pull/358) by [@default-anton](https://github.com/default-anton))
3189
+
3190
+ ## [0.28.0] - 2025-12-25
3191
+
3192
+ ### Breaking Changes
3193
+
3194
+ - **OAuth storage removed** ([#296](https://github.com/badlogic/pi-mono/issues/296)): All storage functions (`loadOAuthCredentials`, `saveOAuthCredentials`, `setOAuthStorage`, etc.) removed. Callers are responsible for storing credentials.
3195
+ - **OAuth login functions**: `loginAnthropic`, `loginGitHubCopilot`, `loginGeminiCli`, `loginAntigravity` now return `OAuthCredentials` instead of saving to disk.
3196
+ - **refreshOAuthToken**: Now takes `(provider, credentials)` and returns new `OAuthCredentials` instead of saving.
3197
+ - **getOAuthApiKey**: Now takes `(provider, credentials)` and returns `{ newCredentials, apiKey }` or null.
3198
+ - **OAuthCredentials type**: No longer includes `type: "oauth"` discriminator. Callers add discriminator when storing.
3199
+ - **setApiKey, resolveApiKey**: Removed. Callers must manage their own API key storage/resolution.
3200
+ - **getApiKey**: Renamed to `getEnvApiKey`. Only checks environment variables for known providers.
3201
+
3202
+ ## [0.27.7] - 2025-12-24
3203
+
3204
+ ### Fixed
3205
+
3206
+ - **Thinking tag leakage**: Fixed Anthropic model mimicking literal `</thinking>` tags in responses. Unsigned thinking blocks (from aborted streams) are now converted to plain text without `<thinking>` tags. The TUI still displays them as thinking blocks. ([#302](https://github.com/badlogic/pi-mono/pull/302) by [@nicobailon](https://github.com/nicobailon))
3207
+
3208
+ ## [0.25.1] - 2025-12-21
3209
+
3210
+ ### Added
3211
+
3212
+ - **xhigh thinking level support**: Added `supportsXhigh()` function to check if a model supports xhigh reasoning level. Also clamps xhigh to high for OpenAI models that don't support it. ([#236](https://github.com/badlogic/pi-mono/pull/236) by [@theBucky](https://github.com/theBucky))
3213
+
3214
+ ### Fixed
3215
+
3216
+ - **Gemini multimodal tool results**: Fixed images in tool results causing flaky/broken responses with Gemini models. For Gemini 3, images are now nested inside `functionResponse.parts` per the [docs](https://ai.google.dev/gemini-api/docs/function-calling#multimodal). For older models (which don't support multimodal function responses), images are sent in a separate user message.
3217
+
3218
+ - **Queued message steering**: When `getQueuedMessages` is provided, the agent loop now checks for queued user messages after each tool call and skips remaining tool calls in the current assistant message when a queued message arrives (emitting error tool results).
3219
+
3220
+ - **Double API version path in Google provider URL**: Fixed Gemini API calls returning 404 after baseUrl support was added. The SDK was appending its default apiVersion to baseUrl which already included the version path. ([#251](https://github.com/badlogic/pi-mono/pull/251) by [@shellfyred](https://github.com/shellfyred))
3221
+
3222
+ - **Anthropic SDK retries disabled**: Re-enabled SDK-level retries (default 2) for transient HTTP failures. ([#252](https://github.com/badlogic/pi-mono/issues/252))
3223
+
3224
+ ## [0.23.5] - 2025-12-19
3225
+
3226
+ ### Added
3227
+
3228
+ - **Gemini 3 Flash thinking support**: Extended thinking level support for Gemini 3 Flash models (MINIMAL, LOW, MEDIUM, HIGH) to match Pro models' capabilities. ([#212](https://github.com/badlogic/pi-mono/pull/212) by [@markusylisiurunen](https://github.com/markusylisiurunen))
3229
+
3230
+ - **GitHub Copilot thinking models**: Added thinking support for additional Copilot models (o3-mini, o1-mini, o1-preview). ([#234](https://github.com/badlogic/pi-mono/pull/234) by [@aadishv](https://github.com/aadishv))
3231
+
3232
+ ### Fixed
3233
+
3234
+ - **Gemini tool result format**: Fixed tool result format for Gemini 3 Flash Preview which strictly requires `{ output: value }` for success and `{ error: value }` for errors. Previous format using `{ result, isError }` was rejected by newer Gemini models. Also improved type safety by removing `as any` casts. ([#213](https://github.com/badlogic/pi-mono/issues/213), [#220](https://github.com/badlogic/pi-mono/pull/220))
3235
+
3236
+ - **Google baseUrl configuration**: Google provider now respects `baseUrl` configuration for custom endpoints or API proxies. ([#216](https://github.com/badlogic/pi-mono/issues/216), [#221](https://github.com/badlogic/pi-mono/pull/221) by [@theBucky](https://github.com/theBucky))
3237
+
3238
+ - **GitHub Copilot vision requests**: Added `Copilot-Vision-Request` header when sending images to GitHub Copilot models. ([#222](https://github.com/badlogic/pi-mono/issues/222))
3239
+
3240
+ - **GitHub Copilot X-Initiator header**: Fixed X-Initiator logic to check last message role instead of any message in history. This ensures proper billing when users send follow-up messages. ([#209](https://github.com/badlogic/pi-mono/issues/209))
3241
+
3242
+ ## [0.22.3] - 2025-12-16
3243
+
3244
+ ### Added
3245
+
3246
+ - **Image limits test suite**: Added comprehensive tests for provider-specific image limitations (max images, max size, max dimensions). Discovered actual limits: Anthropic (100 images, 5MB, 8000px), OpenAI (500 images, ≥25MB), Gemini (~2500 images, ≥40MB), Mistral (8 images, ~15MB), OpenRouter (~40 images context-limited, ~15MB). ([#120](https://github.com/badlogic/pi-mono/pull/120))
3247
+
3248
+ - **Tool result streaming**: Added `tool_execution_update` event and optional `onUpdate` callback to `AgentTool.execute()` for streaming tool output during execution. Tools can now emit partial results (e.g., bash stdout) that are forwarded to subscribers. ([#44](https://github.com/badlogic/pi-mono/issues/44))
3249
+
3250
+ - **X-Initiator header for GitHub Copilot**: Added X-Initiator header handling for GitHub Copilot provider to ensure correct call accounting (agent calls are not deducted from quota). Sets initiator based on last message role. ([#200](https://github.com/badlogic/pi-mono/pull/200) by [@kim0](https://github.com/kim0))
3251
+
3252
+ ### Changed
3253
+
3254
+ - **Normalized tool_execution_end result**: `tool_execution_end` event now always contains `AgentToolResult` (no longer `AgentToolResult | string`). Errors are wrapped in the standard result format.
3255
+
3256
+ ### Fixed
3257
+
3258
+ - **Reasoning disabled by default**: When `reasoning` option is not specified, thinking is now explicitly disabled for all providers. Previously, some providers like Gemini with "dynamic thinking" would use their default (thinking ON), causing unexpected token usage. This was the original intended behavior. ([#180](https://github.com/badlogic/pi-mono/pull/180) by [@markusylisiurunen](https://github.com/markusylisiurunen))
3259
+
3260
+ ## [0.22.2] - 2025-12-15
3261
+
3262
+ ### Added
3263
+
3264
+ - **Interleaved thinking for Anthropic**: Added `interleavedThinking` option to `AnthropicOptions`. When enabled, Anthropic model 4 models can think between tool calls and reason after receiving tool results. Enabled by default (no extra token cost, just unlocks the capability). Set `interleavedThinking: false` to disable.
3265
+
3266
+ ## [0.22.1] - 2025-12-15
3267
+
3268
+ _Dedicated to Peter's shoulder ([@steipete](https://twitter.com/steipete))_
3269
+
3270
+ ### Added
3271
+
3272
+ - **Interleaved thinking for Anthropic**: Enabled interleaved thinking in the Anthropic provider, allowing Anthropic model models to output thinking blocks interspersed with text responses.
3273
+
3274
+ ## [0.22.0] - 2025-12-15
3275
+
3276
+ ### Added
3277
+
3278
+ - **GitHub Copilot provider**: Added `github-copilot` as a known provider with models sourced from models.dev. Includes Anthropic model, GPT, Gemini, Grok, and other models available through GitHub Copilot. ([#191](https://github.com/badlogic/pi-mono/pull/191) by [@cau1k](https://github.com/cau1k))
3279
+
3280
+ ### Fixed
3281
+
3282
+ - **GitHub Copilot gpt-5 models**: Fixed API selection for gpt-5 models to use `openai-responses` instead of `openai-completions` (gpt-5 models are not accessible via completions endpoint)
3283
+
3284
+ - **GitHub Copilot cross-model context handoff**: Fixed context handoff failing when switching between GitHub Copilot models using different APIs (e.g., gpt-5 to anthropic-model-sonnet-4). Tool call IDs from OpenAI Responses API were incompatible with other models. ([#198](https://github.com/badlogic/pi-mono/issues/198))
3285
+
3286
+ - **Gemini 3 Pro thinking levels**: Thinking level configuration now works correctly for Gemini 3 Pro models. Previously all levels mapped to -1 (minimal thinking). Now LOW/MEDIUM/HIGH properly control test-time computation. ([#176](https://github.com/badlogic/pi-mono/pull/176) by [@markusylisiurunen](https://github.com/markusylisiurunen))
3287
+
3288
+ ## [0.18.2] - 2025-12-11
3289
+
3290
+ ### Changed
3291
+
3292
+ - **Anthropic SDK retries disabled**: Set `maxRetries: 0` on Anthropic client to allow application-level retry handling. The SDK's built-in retries were interfering with coding-agent's retry logic. ([#157](https://github.com/badlogic/pi-mono/issues/157))
3293
+
3294
+ ## [0.18.1] - 2025-12-10
3295
+
3296
+ ### Added
3297
+
3298
+ - **Mistral provider**: Added support for Mistral AI models via the OpenAI-compatible API. Includes automatic handling of Mistral-specific requirements (tool call ID format). Set `MISTRAL_API_KEY` environment variable to use.
3299
+
3300
+ ### Fixed
3301
+
3302
+ - Fixed Mistral 400 errors after aborted assistant messages by skipping empty assistant messages (no content, no tool calls) ([#165](https://github.com/badlogic/pi-mono/issues/165))
3303
+
3304
+ - Removed synthetic assistant bridge message after tool results for Mistral (no longer required as of Dec 2025) ([#165](https://github.com/badlogic/pi-mono/issues/165))
3305
+
3306
+ - Fixed bug where `ANTHROPIC_API_KEY` environment variable was deleted globally after first OAuth token usage, causing subsequent prompts to fail ([#164](https://github.com/badlogic/pi-mono/pull/164))
3307
+
3308
+ ## [0.17.0] - 2025-12-09
3309
+
3310
+ ### Added
3311
+
3312
+ - **`agentLoopContinue` function**: Continue an agent loop from existing context without adding a new user message. Validates that the last message is `user` or `toolResult`. Useful for retry after context overflow or resuming from manually-added tool results.
3313
+
3314
+ ### Breaking Changes
3315
+
3316
+ - Removed provider-level tool argument validation. Validation now happens in `agentLoop` via `executeToolCalls`, allowing models to retry on validation errors. For manual tool execution, use `validateToolCall(tools, toolCall)` or `validateToolArguments(tool, toolCall)`.
3317
+
3318
+ ### Added
3319
+
3320
+ - Added `validateToolCall(tools, toolCall)` helper that finds the tool by name and validates arguments.
3321
+
3322
+ - **OpenAI compatibility overrides**: Added `compat` field to `Model` for `openai-completions` API, allowing explicit configuration of provider quirks (`supportsStore`, `supportsDeveloperRole`, `supportsReasoningEffort`, `maxTokensField`). Falls back to URL-based detection if not set. Useful for LiteLLM, custom proxies, and other non-standard endpoints. ([#133](https://github.com/badlogic/pi-mono/issues/133), thanks @fink-andreas for the initial idea and PR)
3323
+
3324
+ - **xhigh reasoning level**: Added `xhigh` to `ReasoningEffort` type for OpenAI openai-code-max models. For non-OpenAI providers (Anthropic, Google), `xhigh` is automatically mapped to `high`. ([#143](https://github.com/badlogic/pi-mono/issues/143))
3325
+
3326
+ ### Changed
3327
+
3328
+ - **Updated SDK versions**: OpenAI SDK 5.21.0 → 6.10.0, Anthropic SDK 0.61.0 → 0.71.2, Google GenAI SDK 1.30.0 → 1.31.0
3329
+
3330
+ ## [0.13.0] - 2025-12-06
3331
+
3332
+ ### Breaking Changes
3333
+
3334
+ - **Added `totalTokens` field to `Usage` type**: All code that constructs `Usage` objects must now include the `totalTokens` field. This field represents the total tokens processed by the LLM (input + output + cache). For OpenAI and Google, this uses native API values (`total_tokens`, `totalTokenCount`). For Anthropic, it's computed as `input + output + cacheRead + cacheWrite`.
3335
+
3336
+ ## [0.12.10] - 2025-12-04
3337
+
3338
+ ### Added
3339
+
3340
+ - Added `gpt-5.1-openai-code-max` model support
3341
+
3342
+ ### Fixed
3343
+
3344
+ - **OpenAI Token Counting**: Fixed `usage.input` to exclude cached tokens for OpenAI providers. Previously, `input` included cached tokens, causing double-counting when calculating total context size via `input + cacheRead`. Now `input` represents non-cached input tokens across all providers, making `input + output + cacheRead + cacheWrite` the correct formula for total context size.
3345
+
3346
+ - **Fixed Anthropic model Opus 4.5 cache pricing** (was 3x too expensive)
3347
+ - Corrected cache_read: $1.50 → $0.50 per MTok
3348
+ - Corrected cache_write: $18.75 → $6.25 per MTok
3349
+ - Added manual override in `scripts/generate-models.ts` until upstream fix is merged
3350
+ - Submitted PR to models.dev: https://github.com/sst/models.dev/pull/439
3351
+
3352
+ ## [0.9.4] - 2025-11-26
3353
+
3354
+ Initial release with multi-provider LLM support.