@bastani/pi-ai 0.9.45 → 0.9.46-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +20 -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 +2 -0
  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 +25 -1
  11. package/dist/api/bedrock-converse-stream.js.map +1 -1
  12. package/dist/api/google-generative-ai.d.ts.map +1 -1
  13. package/dist/api/google-generative-ai.js +2 -0
  14. package/dist/api/google-generative-ai.js.map +1 -1
  15. package/dist/api/google-shared.d.ts.map +1 -1
  16. package/dist/api/google-shared.js +6 -1
  17. package/dist/api/google-shared.js.map +1 -1
  18. package/dist/api/google-vertex.d.ts.map +1 -1
  19. package/dist/api/google-vertex.js +2 -0
  20. package/dist/api/google-vertex.js.map +1 -1
  21. package/dist/api/mistral-conversations.d.ts.map +1 -1
  22. package/dist/api/mistral-conversations.js +6 -2
  23. package/dist/api/mistral-conversations.js.map +1 -1
  24. package/dist/api/openai-codex-responses.d.ts.map +1 -1
  25. package/dist/api/openai-codex-responses.js +3 -3
  26. package/dist/api/openai-codex-responses.js.map +1 -1
  27. package/dist/api/pi-messages.d.ts +2 -1
  28. package/dist/api/pi-messages.d.ts.map +1 -1
  29. package/dist/api/pi-messages.js +18 -2
  30. package/dist/api/pi-messages.js.map +1 -1
  31. package/dist/auth/helpers.d.ts +2 -1
  32. package/dist/auth/helpers.d.ts.map +1 -1
  33. package/dist/auth/helpers.js +1 -0
  34. package/dist/auth/helpers.js.map +1 -1
  35. package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
  36. package/dist/auth/oauth/github-copilot.js +20 -18
  37. package/dist/auth/oauth/github-copilot.js.map +1 -1
  38. package/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
  39. package/dist/auth/oauth/kimi-coding.js +4 -22
  40. package/dist/auth/oauth/kimi-coding.js.map +1 -1
  41. package/dist/auth/oauth/meta.d.ts.map +1 -1
  42. package/dist/auth/oauth/meta.js +1 -14
  43. package/dist/auth/oauth/meta.js.map +1 -1
  44. package/dist/auth/oauth/radius.d.ts.map +1 -1
  45. package/dist/auth/oauth/radius.js +9 -3
  46. package/dist/auth/oauth/radius.js.map +1 -1
  47. package/dist/auth/oauth/trusted-url.d.ts +7 -0
  48. package/dist/auth/oauth/trusted-url.d.ts.map +1 -0
  49. package/dist/auth/oauth/trusted-url.js +12 -0
  50. package/dist/auth/oauth/trusted-url.js.map +1 -0
  51. package/dist/auth/types.d.ts +6 -0
  52. package/dist/auth/types.d.ts.map +1 -1
  53. package/dist/auth/types.js.map +1 -1
  54. package/dist/cli.js +6 -2
  55. package/dist/cli.js.map +1 -1
  56. package/dist/models.d.ts.map +1 -1
  57. package/dist/models.js +26 -3
  58. package/dist/models.js.map +1 -1
  59. package/dist/providers/data/.manifest.json +1 -1
  60. package/dist/providers/data/amazon-bedrock.json +1 -1
  61. package/dist/providers/data/azure.json +1 -1
  62. package/dist/providers/data/github-copilot.json +1 -1
  63. package/dist/providers/data/huggingface.json +1 -1
  64. package/dist/providers/data/openai-codex.json +1 -1
  65. package/dist/providers/data/openai.json +1 -1
  66. package/dist/providers/data/opencode.json +1 -1
  67. package/dist/providers/data/openrouter.json +1 -1
  68. package/dist/providers/data/vercel-ai-gateway.json +1 -1
  69. package/dist/providers/github-copilot.d.ts.map +1 -1
  70. package/dist/providers/github-copilot.js +13 -1
  71. package/dist/providers/github-copilot.js.map +1 -1
  72. package/dist/providers/openai-mid-convo-effort.d.ts.map +1 -1
  73. package/dist/providers/openai-mid-convo-effort.js +1 -0
  74. package/dist/providers/openai-mid-convo-effort.js.map +1 -1
  75. package/dist/utils/provider-retry.d.ts.map +1 -1
  76. package/dist/utils/provider-retry.js +5 -4
  77. package/dist/utils/provider-retry.js.map +1 -1
  78. package/dist/utils/retry-hints.d.ts +6 -3
  79. package/dist/utils/retry-hints.d.ts.map +1 -1
  80. package/dist/utils/retry-hints.js +98 -18
  81. package/dist/utils/retry-hints.js.map +1 -1
  82. package/dist/utils/retry.js +2 -2
  83. package/dist/utils/retry.js.map +1 -1
  84. package/dist/utils/version.d.ts +1 -1
  85. package/dist/utils/version.d.ts.map +1 -1
  86. package/dist/utils/version.js +1 -1
  87. package/dist/utils/version.js.map +1 -1
  88. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ 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-alpha.1] - 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
+
7
27
  ## [0.9.44] - 2026-10-25
8
28
 
9
29
  ### 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,cA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S,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,CAiZzE,CAAC;AA4BF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAgDlF,CAAC"}
@@ -12,6 +12,7 @@ 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";
@@ -940,6 +941,7 @@ export const stream = (model, context, options) => {
940
941
  }
941
942
  output.stopReason = options?.signal?.aborted ? "aborted" : "error";
942
943
  output.errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
944
+ output.retryAfterMs = error instanceof Error ? getProviderRetryAfterMs(error) : undefined;
943
945
  stream.push({ type: "error", reason: output.stopReason, error: output });
944
946
  stream.end();
945
947
  }