pi-anthropic-oauth 0.1.13 → 0.1.15
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/package.json +1 -1
- package/src/index.ts +5 -8
- package/src/stream.ts +13 -6
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ const DEFAULT_OPUS_4_8: NonNullable<ProviderConfig["models"]>[number] = {
|
|
|
16
16
|
name: "Claude Opus 4.8",
|
|
17
17
|
api: "anthropic-messages",
|
|
18
18
|
reasoning: true,
|
|
19
|
+
thinkingLevelMap: { xhigh: "xhigh" },
|
|
19
20
|
input: ["text", "image"],
|
|
20
21
|
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
21
22
|
contextWindow: 1000000,
|
|
@@ -38,16 +39,12 @@ function getAnthropicModels(): NonNullable<ProviderConfig["models"]> {
|
|
|
38
39
|
const models: NonNullable<ProviderConfig["models"]> = modelRegistry
|
|
39
40
|
.getAll()
|
|
40
41
|
.filter((model) => model.provider === "anthropic")
|
|
42
|
+
// Spread the full registry model so every field (thinkingLevelMap,
|
|
43
|
+
// baseUrl, headers, compat, and anything added in future) propagates
|
|
44
|
+
// automatically instead of being silently dropped by a hand-picked list.
|
|
41
45
|
.map((model) => ({
|
|
42
|
-
|
|
43
|
-
name: model.name,
|
|
46
|
+
...model,
|
|
44
47
|
api: model.api ?? "anthropic-messages",
|
|
45
|
-
reasoning: model.reasoning,
|
|
46
|
-
input: model.input,
|
|
47
|
-
cost: model.cost,
|
|
48
|
-
contextWindow: model.contextWindow,
|
|
49
|
-
maxTokens: model.maxTokens,
|
|
50
|
-
compat: model.compat,
|
|
51
48
|
}));
|
|
52
49
|
|
|
53
50
|
if (!models.some((model) => model.id === DEFAULT_OPUS_4_8.id)) {
|
package/src/stream.ts
CHANGED
|
@@ -24,7 +24,12 @@ import { buildAnthropicSystemPrompt } from "./prompt.js";
|
|
|
24
24
|
const REQUIRED_BETAS = [
|
|
25
25
|
"claude-code-20250219",
|
|
26
26
|
"oauth-2025-04-20",
|
|
27
|
-
|
|
27
|
+
// fine-grained-tool-streaming removed: it ships the model's raw, unvalidated
|
|
28
|
+
// tool-input JSON. For large edits full of quotes/newlines the streamed
|
|
29
|
+
// string escaping breaks, so a field (e.g. edit.oldText) swallows the rest of
|
|
30
|
+
// the structure — surfacing as either a hard JSON.parse crash or a wrong-shape
|
|
31
|
+
// schema-validation failure. Default streaming has the server validate/buffer
|
|
32
|
+
// tool JSON, guaranteeing well-formed, correctly-structured input.
|
|
28
33
|
"interleaved-thinking-2025-05-14",
|
|
29
34
|
] as const;
|
|
30
35
|
|
|
@@ -57,10 +62,7 @@ function makeDefaultHeaders(
|
|
|
57
62
|
headers["user-agent"] = USER_AGENT;
|
|
58
63
|
headers["x-app"] = "cli";
|
|
59
64
|
} else {
|
|
60
|
-
headers["anthropic-beta"] = [
|
|
61
|
-
"fine-grained-tool-streaming-2025-05-14",
|
|
62
|
-
"interleaved-thinking-2025-05-14",
|
|
63
|
-
].join(",");
|
|
65
|
+
headers["anthropic-beta"] = ["interleaved-thinking-2025-05-14"].join(",");
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
if (options?.headers) {
|
|
@@ -170,7 +172,12 @@ export function streamAnthropicOAuth(
|
|
|
170
172
|
};
|
|
171
173
|
}
|
|
172
174
|
|
|
173
|
-
|
|
175
|
+
// Raw stream instead of the MessageStream helper: MessageStream
|
|
176
|
+
// accumulates tool_use input and JSON.parses it on content_block_stop,
|
|
177
|
+
// which throws under fine-grained-tool-streaming (input may be invalid
|
|
178
|
+
// mid-flight) and aborts the turn. The raw stream yields the same
|
|
179
|
+
// RawMessageStreamEvents; tool args are already parsed leniently below.
|
|
180
|
+
const anthropicStream = await client.messages.create(params, {
|
|
174
181
|
signal: options?.signal,
|
|
175
182
|
});
|
|
176
183
|
stream.push({ type: "start", partial: output });
|