@bastani/pi-ai 0.9.45 → 0.9.46

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 (93) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +4 -1
  3. package/dist/api/anthropic-messages.d.ts.map +1 -1
  4. package/dist/api/anthropic-messages.js +6 -12
  5. package/dist/api/anthropic-messages.js.map +1 -1
  6. package/dist/api/azure-openai-responses.d.ts.map +1 -1
  7. package/dist/api/azure-openai-responses.js +2 -0
  8. package/dist/api/azure-openai-responses.js.map +1 -1
  9. package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
  10. package/dist/api/bedrock-converse-stream.js +84 -31
  11. package/dist/api/bedrock-converse-stream.js.map +1 -1
  12. package/dist/api/constrained-sampling.d.ts +4 -0
  13. package/dist/api/constrained-sampling.d.ts.map +1 -1
  14. package/dist/api/constrained-sampling.js +18 -0
  15. package/dist/api/constrained-sampling.js.map +1 -1
  16. package/dist/api/google-generative-ai.d.ts.map +1 -1
  17. package/dist/api/google-generative-ai.js +2 -0
  18. package/dist/api/google-generative-ai.js.map +1 -1
  19. package/dist/api/google-shared.d.ts.map +1 -1
  20. package/dist/api/google-shared.js +6 -1
  21. package/dist/api/google-shared.js.map +1 -1
  22. package/dist/api/google-vertex.d.ts.map +1 -1
  23. package/dist/api/google-vertex.js +2 -0
  24. package/dist/api/google-vertex.js.map +1 -1
  25. package/dist/api/mistral-conversations.d.ts.map +1 -1
  26. package/dist/api/mistral-conversations.js +6 -2
  27. package/dist/api/mistral-conversations.js.map +1 -1
  28. package/dist/api/openai-codex-responses.d.ts.map +1 -1
  29. package/dist/api/openai-codex-responses.js +3 -3
  30. package/dist/api/openai-codex-responses.js.map +1 -1
  31. package/dist/api/pi-messages.d.ts +2 -1
  32. package/dist/api/pi-messages.d.ts.map +1 -1
  33. package/dist/api/pi-messages.js +18 -2
  34. package/dist/api/pi-messages.js.map +1 -1
  35. package/dist/auth/helpers.d.ts +2 -1
  36. package/dist/auth/helpers.d.ts.map +1 -1
  37. package/dist/auth/helpers.js +1 -0
  38. package/dist/auth/helpers.js.map +1 -1
  39. package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  40. package/dist/auth/oauth/github-copilot.js +20 -18
  41. package/dist/auth/oauth/github-copilot.js.map +1 -1
  42. package/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
  43. package/dist/auth/oauth/kimi-coding.js +4 -22
  44. package/dist/auth/oauth/kimi-coding.js.map +1 -1
  45. package/dist/auth/oauth/meta.d.ts.map +1 -1
  46. package/dist/auth/oauth/meta.js +1 -14
  47. package/dist/auth/oauth/meta.js.map +1 -1
  48. package/dist/auth/oauth/radius.d.ts.map +1 -1
  49. package/dist/auth/oauth/radius.js +9 -3
  50. package/dist/auth/oauth/radius.js.map +1 -1
  51. package/dist/auth/oauth/trusted-url.d.ts +7 -0
  52. package/dist/auth/oauth/trusted-url.d.ts.map +1 -0
  53. package/dist/auth/oauth/trusted-url.js +12 -0
  54. package/dist/auth/oauth/trusted-url.js.map +1 -0
  55. package/dist/auth/types.d.ts +6 -0
  56. package/dist/auth/types.d.ts.map +1 -1
  57. package/dist/auth/types.js.map +1 -1
  58. package/dist/cli.js +6 -2
  59. package/dist/cli.js.map +1 -1
  60. package/dist/models.d.ts.map +1 -1
  61. package/dist/models.js +26 -3
  62. package/dist/models.js.map +1 -1
  63. package/dist/providers/data/.manifest.json +1 -1
  64. package/dist/providers/data/amazon-bedrock.json +1 -1
  65. package/dist/providers/data/azure.json +1 -1
  66. package/dist/providers/data/github-copilot.json +1 -1
  67. package/dist/providers/data/huggingface.json +1 -1
  68. package/dist/providers/data/openai-codex.json +1 -1
  69. package/dist/providers/data/openai.json +1 -1
  70. package/dist/providers/data/opencode-go.json +1 -1
  71. package/dist/providers/data/opencode.json +1 -1
  72. package/dist/providers/data/openrouter.json +1 -1
  73. package/dist/providers/data/radius.json +1 -1
  74. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  75. package/dist/providers/github-copilot.d.ts.map +1 -1
  76. package/dist/providers/github-copilot.js +13 -1
  77. package/dist/providers/github-copilot.js.map +1 -1
  78. package/dist/providers/openai-mid-convo-effort.d.ts.map +1 -1
  79. package/dist/providers/openai-mid-convo-effort.js +1 -0
  80. package/dist/providers/openai-mid-convo-effort.js.map +1 -1
  81. package/dist/utils/provider-retry.d.ts.map +1 -1
  82. package/dist/utils/provider-retry.js +5 -4
  83. package/dist/utils/provider-retry.js.map +1 -1
  84. package/dist/utils/retry-hints.d.ts +6 -3
  85. package/dist/utils/retry-hints.d.ts.map +1 -1
  86. package/dist/utils/retry-hints.js +98 -18
  87. package/dist/utils/retry-hints.js.map +1 -1
  88. package/dist/utils/retry.js +2 -2
  89. package/dist/utils/retry.js.map +1 -1
  90. package/dist/utils/version.d.ts +1 -1
  91. package/dist/utils/version.js +1 -1
  92. package/dist/utils/version.js.map +1 -1
  93. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,49 @@ This package is a Bastani fork of `@earendil-works/pi-ai`. Upstream history at t
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.9.46] - 2026-10-27
8
+
9
+ ### Added
10
+
11
+ - Added GPT-6.1 Terra to the OpenAI, Azure OpenAI Responses, and OpenAI Codex providers with official pricing ($1 input, $0.05 cached input, $1.25 cache writes, $5 output, long-context tier above 272k), Fast at twice those rates on the OpenAI API, tool search, and mid-conversation effort changes. Unlike GPT-6.1 Sol it supports `off` (reasoning effort `none`); it rejects `minimal`. Codex serves it with a 500K context window ([pi 363ad78b](https://github.com/earendil-works/pi/commit/363ad78bf0625e1dfbe848429782f5e07bb1584e))
12
+ - `OAuthAuth.needsRefresh()` (optional) reports that an unexpired stored credential lacks data only a refresh restores; `Models.refresh()` with network access then refreshes it once for providers without a model source ([#3998](https://github.com/bastani-inc/atomic/issues/3998))
13
+
14
+ ### Fixed
15
+
16
+ - GitHub Copilot offers fewer models its account can't use: a model enabled during login is offered only if the model list re-read afterwards marks it usable, and an OAuth login without a stored model list re-reads the list on the next `Models.refresh()` with network access (until then it keeps offering the catalog) ([#3998](https://github.com/bastani-inc/atomic/issues/3998))
17
+ - Anthropic Messages, Azure OpenAI Responses, Mistral and pi-messages failures now report the server retry hint (`Retry-After-Ms`, `Retry-After` in seconds or as an HTTP date, or a body `retry_after`) as `AssistantMessage.retryAfterMs`, as the OpenAI providers already did. A hint longer than `maxRetryDelayMs` stays on the failure that rejects it, and HTTP 529 overload responses are retryable like 503 ([#3984](https://github.com/bastani-inc/atomic/issues/3984))
18
+ - OAuth logins accept only `http:` and `https:` URLs from servers. Radius now also checks its browser authorization endpoint and device verification URI, and GitHub Copilot, Kimi Coding and Meta share one check ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
19
+ - pi-messages streams now fail on a `contentIndex` that is not the next or an existing content block, such as `__proto__` or a huge index ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
20
+ - The `pi-ai` CLI writes its `auth.json` with mode `0600`, so other users can no longer read the stored tokens; an existing file is tightened before new tokens are written ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
21
+ - OpenCode DeepSeek V4.1 Flash no longer sends `prompt_cache_retention` with long cache retention, which the OpenCode gateway rejects ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
22
+ - Google Generative AI, Google Vertex and Amazon Bedrock failures now report the server's retry hint as `retryAfterMs`: Google's `RetryInfo.retryDelay` from the error body, and Bedrock's `Retry-After` / `Retry-After-Ms` response headers. A Google request retried by the shared retry policy now waits that delay instead of a guessed backoff, and a delay above the retry-delay cap fails at once with the hint attached.
23
+ - ChatGPT (Codex) HTTP failures other than usage limits now keep the HTTP status in their message (`402: …`), so an exhausted quota or server error is still recognizable from the message.
24
+ - Amazon Bedrock GPT-6.1 Sol (`openai.gpt-6.1-sol`, `us.openai.gpt-6.1-sol`, `global.openai.gpt-6.1-sol`) now offers its published reasoning efforts `low` through `max`, including `xhigh` and `max`, and no longer offers `off` or `minimal`, which the model does not support ([OpenAI](https://developers.openai.com/api/docs/models/gpt-6.1-sol)). Bedrock GPT-6 Sol and GPT-6 Luna routes now offer `xhigh` and `max` and no longer offer `minimal`, matching their AWS model cards ([GPT-6 Sol](https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-openai-gpt-6-sol.html), [GPT-6 Luna](https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-openai-gpt-6-luna.html))
25
+ - Amazon Bedrock OpenAI GPT models with reasoning `off` now send the model's mapped `off` effort, as the OpenAI Responses provider does, so Bedrock GPT-6 Sol and GPT-6 Luna run with `reasoning.effort: "none"` instead of silently using their default `medium`. Models whose map gives `off` no value, such as GPT-6 Astra and GPT-6.1 Sol, still send no reasoning field.
26
+ - OpenCode Zen and OpenCode Go requests use the documented protocol-specific endpoints (`/openai/v1`, `/anthropic`, `/google/v1beta`, and `/systemone/v1` for Jev classifiers) instead of the shared `/inference/v1` base ([pi #11132](https://github.com/earendil-works/pi/issues/11132))
27
+ - GPT-5.4 and GPT-5.5 no longer fail with `Missing namespace for function_call` after switching from another model that called tools. On the OpenAI, OpenCode and GitHub Copilot providers they now declare their tools in the top-level tool list instead of loading them through `additional_tools` or tool search ([pi #11415](https://github.com/earendil-works/pi/issues/11415))
28
+ - Bedrock requests no longer fail when `strict: "prefer"` tools exceed Claude's strict tool limits, such as more than 16 optional parameters across all strict tools. They retry once with preferred tools non-strict and keep `strict: "require"` tools strict, as the Anthropic provider already does ([pi #11416](https://github.com/earendil-works/pi/issues/11416))
29
+
30
+ ## [0.9.46-alpha.1] - 2026-10-27
31
+
32
+ ### Added
33
+
34
+ - Added GPT-6.1 Terra to the OpenAI, Azure OpenAI Responses, and OpenAI Codex providers with official pricing ($1 input, $0.05 cached input, $1.25 cache writes, $5 output, long-context tier above 272k), Fast at twice those rates on the OpenAI API, tool search, and mid-conversation effort changes. Unlike GPT-6.1 Sol it supports `off` (reasoning effort `none`); it rejects `minimal`. Codex serves it with a 500K context window ([pi 363ad78b](https://github.com/earendil-works/pi/commit/363ad78bf0625e1dfbe848429782f5e07bb1584e))
35
+ - `OAuthAuth.needsRefresh()` (optional) reports that an unexpired stored credential lacks data only a refresh restores; `Models.refresh()` with network access then refreshes it once for providers without a model source ([#3998](https://github.com/bastani-inc/atomic/issues/3998))
36
+
37
+ ### Fixed
38
+
39
+ - GitHub Copilot offers fewer models its account can't use: a model enabled during login is offered only if the model list re-read afterwards marks it usable, and an OAuth login without a stored model list re-reads the list on the next `Models.refresh()` with network access (until then it keeps offering the catalog) ([#3998](https://github.com/bastani-inc/atomic/issues/3998))
40
+ - Anthropic Messages, Azure OpenAI Responses, Mistral and pi-messages failures now report the server retry hint (`Retry-After-Ms`, `Retry-After` in seconds or as an HTTP date, or a body `retry_after`) as `AssistantMessage.retryAfterMs`, as the OpenAI providers already did. A hint longer than `maxRetryDelayMs` stays on the failure that rejects it, and HTTP 529 overload responses are retryable like 503 ([#3984](https://github.com/bastani-inc/atomic/issues/3984))
41
+ - OAuth logins accept only `http:` and `https:` URLs from servers. Radius now also checks its browser authorization endpoint and device verification URI, and GitHub Copilot, Kimi Coding and Meta share one check ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
42
+ - pi-messages streams now fail on a `contentIndex` that is not the next or an existing content block, such as `__proto__` or a huge index ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
43
+ - The `pi-ai` CLI writes its `auth.json` with mode `0600`, so other users can no longer read the stored tokens; an existing file is tightened before new tokens are written ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
44
+ - OpenCode DeepSeek V4.1 Flash no longer sends `prompt_cache_retention` with long cache retention, which the OpenCode gateway rejects ([pi 89c921d8](https://github.com/earendil-works/pi/commit/89c921d8b56b59e768b26e7f48b6832978119310))
45
+ - Google Generative AI, Google Vertex and Amazon Bedrock failures now report the server's retry hint as `retryAfterMs`: Google's `RetryInfo.retryDelay` from the error body, and Bedrock's `Retry-After` / `Retry-After-Ms` response headers. A Google request retried by the shared retry policy now waits that delay instead of a guessed backoff, and a delay above the retry-delay cap fails at once with the hint attached.
46
+ - ChatGPT (Codex) HTTP failures other than usage limits now keep the HTTP status in their message (`402: …`), so an exhausted quota or server error is still recognizable from the message.
47
+ - Amazon Bedrock GPT-6.1 Sol (`openai.gpt-6.1-sol`, `us.openai.gpt-6.1-sol`, `global.openai.gpt-6.1-sol`) now offers its published reasoning efforts `low` through `max`, including `xhigh` and `max`, and no longer offers `off` or `minimal`, which the model does not support ([OpenAI](https://developers.openai.com/api/docs/models/gpt-6.1-sol)). Bedrock GPT-6 Sol and GPT-6 Luna routes now offer `xhigh` and `max` and no longer offer `minimal`, matching their AWS model cards ([GPT-6 Sol](https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-openai-gpt-6-sol.html), [GPT-6 Luna](https://docs.aws.amazon.com/bedrock/latest/userguide/model-card-openai-gpt-6-luna.html))
48
+ - Amazon Bedrock OpenAI GPT models with reasoning `off` now send the model's mapped `off` effort, as the OpenAI Responses provider does, so Bedrock GPT-6 Sol and GPT-6 Luna run with `reasoning.effort: "none"` instead of silently using their default `medium`. Models whose map gives `off` no value, such as GPT-6 Astra and GPT-6.1 Sol, still send no reasoning field.
49
+
7
50
  ## [0.9.44] - 2026-10-25
8
51
 
9
52
  ### Breaking Changes
package/README.md CHANGED
@@ -1072,7 +1072,10 @@ for (const block of response.content) {
1072
1072
 
1073
1073
  `xhigh` and `max` are model-specific, opt-in levels. Use `getSupportedThinkingLevels(model)` to determine whether a concrete model exposes either level; models such as GPT-5.6 can expose both.
1074
1074
 
1075
- GPT-6.1 Sol supports `low`, `medium`, `high`, `xhigh` and `max` on OpenAI and Azure Responses. It does not support `off`. The Codex provider also exposes a `minimal` UI alias that sends `low` to the API.
1075
+ | Model | Providers | Levels | `off` | `minimal` |
1076
+ | --- | --- | --- | --- | --- |
1077
+ | GPT-6.1 Sol | OpenAI, Azure and Codex Responses | `low`, `medium`, `high`, `xhigh`, `max` | No | Codex UI alias that sends `low` |
1078
+ | GPT-6.1 Terra | OpenAI, Azure and Codex Responses | `off`, `low`, `medium`, `high`, `xhigh`, `max` | Sends reasoning effort `none` | Codex UI alias that sends `low` |
1076
1079
 
1077
1080
  ### Provider-Specific Options (stream/complete)
1078
1081
 
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAkD,MAAM,mBAAmB,CAAC;AAiBnF,OAAO,KAAK,EASX,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAKb,MAAM,aAAa,CAAC;AA+KrB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAqPhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAsTD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAgZzE,CAAC;AA4BF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAgDlF,CAAC"}
1
+ {"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAkD,MAAM,mBAAmB,CAAC;AAiBnF,OAAO,KAAK,EASX,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAKb,MAAM,aAAa,CAAC;AAkLrB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAqPhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAsTD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CA6YzE,CAAC;AA4BF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAgDlF,CAAC"}
@@ -12,12 +12,13 @@ import { applyOpenRouterReportedCost, isOpenRouterModel, } from "../utils/openro
12
12
  import { getProviderEnvValue } from "../utils/provider-env.js";
13
13
  import { retryProviderRequest } from "../utils/provider-retry.js";
14
14
  import { getFetchAdmission } from "../utils/request-admission.js";
15
+ import { getProviderRetryAfterMs } from "../utils/retry-hints.js";
15
16
  import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
16
17
  import { createStreamDeadline, withStreamDeadline } from "../utils/stream-deadline.js";
17
18
  import { ToolCallArgumentsStream } from "../utils/streaming-json.js";
18
19
  import { getSystemMessageText, renderSystemMessageUpdate } from "../utils/text.js";
19
20
  import { getCurrentTools, getInitialSystemMessage, resolveTranscript, } from "../utils/transcript.js";
20
- import { ANTHROPIC_STRICT_JSON_SCHEMA_PROFILE, getJsonSchemaToolParameters, resolveJsonSchemaStrictSampling, } from "./constrained-sampling.js";
21
+ import { ANTHROPIC_STRICT_JSON_SCHEMA_PROFILE, getJsonSchemaToolParameters, isStrictToolLimitErrorMessage, prefersJsonSchemaStrictSampling, resolveJsonSchemaStrictSampling, } from "./constrained-sampling.js";
21
22
  import { buildCopilotDynamicHeaders, hasCopilotVisionInput, preserveCopilotIntegrationHeader, } from "./github-copilot-headers.js";
22
23
  import { adjustMaxTokensForThinking, buildBaseOptions, clampMaxTokensToContext } from "./simple-options.js";
23
24
  import { splitErrorToolResultImages, transformMessages } from "./transform-messages.js";
@@ -669,11 +670,7 @@ export const stream = (model, context, options) => {
669
670
  !(error instanceof Anthropic.APIError) ||
670
671
  error.status !== 400 ||
671
672
  error.type !== "invalid_request_error" ||
672
- ![
673
- "The compiled grammar is too large",
674
- "Too many strict tools (",
675
- "Schemas contains too many parameters with union types (",
676
- ].some((message) => error.message.includes(message)))
673
+ !isStrictToolLimitErrorMessage(error.message))
677
674
  throw error;
678
675
  disablePreferredStrictTools = true;
679
676
  appendAssistantMessageDiagnostic(output, {
@@ -940,6 +937,7 @@ export const stream = (model, context, options) => {
940
937
  }
941
938
  output.stopReason = options?.signal?.aborted ? "aborted" : "error";
942
939
  output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
940
+ output.retryAfterMs = error instanceof Error ? getProviderRetryAfterMs(error) : undefined;
943
941
  stream.push({ type: "error", reason: output.stopReason, error: output });
944
942
  stream.end();
945
943
  }
@@ -1154,10 +1152,7 @@ function buildParams(model, context, isOAuthToken, options, disablePreferredStri
1154
1152
  if (isOAuthToken)
1155
1153
  tools = [...new Map(tools.map((tool) => [toClaudeCodeName(tool.name), tool])).values()];
1156
1154
  const definitions = convertTools(tools, isOAuthToken, compat.supportsEagerToolInputStreaming, compat.supportsStrictTools, toolCacheControl, disablePreferredStrictTools);
1157
- if (definitions.some((definition, index) => {
1158
- const config = tools[index].constrainedSampling;
1159
- return definition.strict === true && config && config.type === "json_schema" && config.strict === "prefer";
1160
- }))
1155
+ if (definitions.some((definition, index) => definition.strict === true && prefersJsonSchemaStrictSampling(tools[index])))
1161
1156
  hasPreferredStrictTools = true;
1162
1157
  return definitions;
1163
1158
  };
@@ -1633,8 +1628,7 @@ function convertTools(tools, isOAuthToken, supportsEagerToolInputStreaming, supp
1633
1628
  if (!tools)
1634
1629
  return [];
1635
1630
  return tools.map((tool, index) => {
1636
- const config = tool.constrainedSampling;
1637
- const strict = disablePreferredStrictTools && config && config.type === "json_schema" && config.strict === "prefer"
1631
+ const strict = disablePreferredStrictTools && prefersJsonSchemaStrictSampling(tool)
1638
1632
  ? undefined
1639
1633
  : resolveJsonSchemaStrictSampling(tool, supportsStrictTools, ANTHROPIC_STRICT_JSON_SCHEMA_PROFILE);
1640
1634
  const parameters = getJsonSchemaToolParameters(tool, strict, ANTHROPIC_STRICT_JSON_SCHEMA_PROFILE);