pi-anthropic-oauth 0.1.14 → 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/stream.ts +13 -6
package/package.json
CHANGED
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 });
|