@bastani/pi-ai 0.9.37-alpha.1 → 0.9.38-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.
- package/CHANGELOG.md +27 -0
- package/README.md +1 -1
- package/dist/api/anthropic-messages.js +8 -3
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/bedrock-converse-stream.js +2 -2
- package/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/api/google-shared.d.ts.map +1 -1
- package/dist/api/google-shared.js +1 -0
- package/dist/api/google-shared.js.map +1 -1
- package/dist/api/mistral-conversations.js +2 -2
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +5 -1
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts +1 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +31 -29
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses-shared.d.ts +10 -0
- package/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/dist/api/openai-responses-shared.js +15 -2
- package/dist/api/openai-responses-shared.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +25 -6
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/openai-retry-hint-client.d.ts +10 -0
- package/dist/api/openai-retry-hint-client.d.ts.map +1 -0
- package/dist/api/openai-retry-hint-client.js +17 -0
- package/dist/api/openai-retry-hint-client.js.map +1 -0
- package/dist/auth/oauth/kimi-coding.d.ts +1 -1
- package/dist/auth/oauth/kimi-coding.js +1 -1
- package/dist/auth/oauth/kimi-coding.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/model-catalog.d.ts +1 -1
- package/dist/model-catalog.d.ts.map +1 -1
- package/dist/model-catalog.js +32 -2
- package/dist/model-catalog.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +3 -0
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +8 -0
- package/dist/providers/compat-schema.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/kimi-coding.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/radius.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/kimi-coding.d.ts +1 -1
- package/dist/providers/kimi-coding.js +3 -3
- package/dist/providers/kimi-coding.js.map +1 -1
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/providers/openai-mid-convo-effort.d.ts +2 -0
- package/dist/providers/openai-mid-convo-effort.d.ts.map +1 -0
- package/dist/providers/openai-mid-convo-effort.js +7 -0
- package/dist/providers/openai-mid-convo-effort.js.map +1 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +11 -2
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/opencode-go.d.ts +3 -1
- package/dist/providers/opencode-go.d.ts.map +1 -1
- package/dist/providers/opencode-go.js +2 -0
- package/dist/providers/opencode-go.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/json-parse.d.ts +2 -0
- package/dist/utils/json-parse.d.ts.map +1 -1
- package/dist/utils/json-parse.js +18 -1
- package/dist/utils/json-parse.js.map +1 -1
- package/dist/utils/retry-hints.d.ts +12 -0
- package/dist/utils/retry-hints.d.ts.map +1 -0
- package/dist/utils/retry-hints.js +50 -0
- package/dist/utils/retry-hints.js.map +1 -0
- package/dist/utils/retry.d.ts +20 -2
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +28 -3
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +3 -0
- package/dist/utils/validation.js.map +1 -1
- package/package.json +1 -1
- package/dist/utils/assistant-message-frame.d.ts +0 -77
- package/dist/utils/assistant-message-frame.d.ts.map +0 -1
- package/dist/utils/assistant-message-frame.js +0 -439
- package/dist/utils/assistant-message-frame.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,33 @@ 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.38-alpha.1] - 2026-10-15
|
|
8
|
+
|
|
9
|
+
### Breaking Changes
|
|
10
|
+
|
|
11
|
+
- Removed `AssistantMessageFrame`, `AssistantMessageFrameEncoder`, and `reduceAssistantMessageFrames()`. Use `AssistantMessageEventStream` events for streaming progress and `result()` for the final message instead.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Added cache-preserving thinking-level changes for GPT-6 models on `openai` and `openai-api` with API-key authentication, controlled by `compat.supportsMidConvoEffort` ([#10853](https://github.com/earendil-works/pi/issues/10853)).
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Changed `kimi-coding` to OpenAI Chat Completions at `https://api.kimi.com/coding/v1`, matching the official Kimi Code client. K3, K3-256K, and Kimi For Coding support tools added mid-conversation without invalidating the prompt cache. Custom `models.json` base URLs for this provider must include `/v1` ([#10720](https://github.com/earendil-works/pi/issues/10720)).
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Fixed OpenCode Go Gemini models failing with a 404, and builds failing when the OpenCode Go catalog lists Gemini models, by moving OpenCode Zen and OpenCode Go to the `opencode.ai/inference` endpoints and registering the Google Generative AI API on the `opencode-go` provider, matching OpenCode Zen.
|
|
24
|
+
- Fixed OpenCode Go MiniMax M2.7 failing with "Model does not support this protocol" by using the Anthropic Messages API.
|
|
25
|
+
- Fixed tool-call argument parsing dropping fields when a string contains an invalid `\u` escape such as `\usepackage` ([#10868](https://github.com/earendil-works/pi/issues/10868)).
|
|
26
|
+
- Fixed Anthropic requests failing with a 400 when an error tool result contains images; images are now replaced with a text note ([#10794](https://github.com/earendil-works/pi/issues/10794)).
|
|
27
|
+
- Fixed automatic retry not triggering for gateway `Unable to forward upstream stream` errors ([#10920](https://github.com/earendil-works/pi/issues/10920)).
|
|
28
|
+
- Fixed OpenAI-compatible responses showing thinking after the answer when a proxy such as LiteLLM sends reasoning and content in the same stream chunk ([#10926](https://github.com/earendil-works/pi/issues/10926)).
|
|
29
|
+
- Fixed Gemini 4 Argon requests on Google Vertex failing with "Thinking budget is not supported", and its thinking level being ignored on the Gemini API, by sending `thinkingLevel` for Gemini 4 and later models ([#10890](https://github.com/earendil-works/pi/issues/10890)).
|
|
30
|
+
- Fixed Xiaomi MiMo models failing with a 400 at the `minimal` thinking level by sending only the documented thinking on/off toggle and exposing only the `off` and `high` levels ([#10818](https://github.com/earendil-works/pi/issues/10818)).
|
|
31
|
+
- Fixed tool calls with malformed final JSON arguments silently running with only a parsed prefix. These calls now fail validation with the original arguments so the model can correct them ([#10897](https://github.com/earendil-works/pi/issues/10897)).
|
|
32
|
+
- Fixed `retryAssistantCall()` ignoring server retry hints. A failed response's `Retry-After-Ms`, `Retry-After` (seconds or HTTP date) or Cloudflare body `retry_after` is reported as `AssistantMessage.retryAfterMs` by the OpenAI Responses, OpenAI Completions and ChatGPT (Codex) providers, and replaces the exponential backoff for that retry, capped by the new `RetryPolicy.maxRetryDelayMs` (60 seconds by default). Cloudflare 521-523 responses and connection resets are now retryable ([#3623](https://github.com/bastani-inc/atomic/issues/3623))
|
|
33
|
+
|
|
7
34
|
## [0.9.36] - 2026-10-13
|
|
8
35
|
|
|
9
36
|
### Fixed
|
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ Unified LLM API with provider collections, automatic auth resolution, token and
|
|
|
93
93
|
- **OpenCode Zen**
|
|
94
94
|
- **OpenCode Go**
|
|
95
95
|
- **Fireworks** (uses OpenAI- and Anthropic-compatible APIs)
|
|
96
|
-
- **Kimi For Coding** (Moonshot AI subscription endpoint, uses
|
|
96
|
+
- **Kimi For Coding** (Moonshot AI subscription endpoint, uses OpenAI Chat Completions)
|
|
97
97
|
- **Meta** (Model API, uses OpenAI Responses-compatible API)
|
|
98
98
|
- **Qwen Token Plan** (separate Individual and existing catalogs, with a separate China provider)
|
|
99
99
|
- **Xiaomi MiMo** (defaults to API billing endpoint, with separate Token Plan providers for `cn`/`ams`/`sgp` regions)
|
|
@@ -5,7 +5,7 @@ import { appendAssistantMessageDiagnostic } from "../utils/diagnostics.js";
|
|
|
5
5
|
import { assertSupportedDocumentMimeType } from "../utils/document-input.js";
|
|
6
6
|
import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|
7
7
|
import { headersToRecord } from "../utils/headers.js";
|
|
8
|
-
import { parseJsonWithRepair, parseStreamingJson } from "../utils/json-parse.js";
|
|
8
|
+
import { parseJsonWithRepair, parseStreamingJson, parseToolCallArguments } from "../utils/json-parse.js";
|
|
9
9
|
import { getPiUserAgent } from "../utils/pi-user-agent.js";
|
|
10
10
|
import { getProviderEnvValue } from "../utils/provider-env.js";
|
|
11
11
|
import { retryProviderRequest } from "../utils/provider-retry.js";
|
|
@@ -827,7 +827,7 @@ export const stream = (model, context, options) => {
|
|
|
827
827
|
});
|
|
828
828
|
}
|
|
829
829
|
else if (block.type === "toolCall") {
|
|
830
|
-
block
|
|
830
|
+
Object.assign(block, parseToolCallArguments(block.partialJson));
|
|
831
831
|
// Finalize in-place and strip the scratch buffer so replay only
|
|
832
832
|
// carries parsed arguments.
|
|
833
833
|
delete block.partialJson;
|
|
@@ -1308,10 +1308,15 @@ function normalizeToolCallId(id) {
|
|
|
1308
1308
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
1309
1309
|
}
|
|
1310
1310
|
function convertToolResult(msg) {
|
|
1311
|
+
const content = msg.isError
|
|
1312
|
+
? msg.content.map((block) => block.type === "image"
|
|
1313
|
+
? { type: "text", text: "[image omitted: error tool results cannot contain images]" }
|
|
1314
|
+
: block)
|
|
1315
|
+
: msg.content;
|
|
1311
1316
|
return {
|
|
1312
1317
|
type: "tool_result",
|
|
1313
1318
|
tool_use_id: msg.toolCallId,
|
|
1314
|
-
content: convertContentBlocks(
|
|
1319
|
+
content: convertContentBlocks(content),
|
|
1315
1320
|
is_error: msg.isError,
|
|
1316
1321
|
};
|
|
1317
1322
|
}
|