pi-anthropic-oauth 0.1.7 → 0.1.8
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/README.md +1 -2
- package/package.json +1 -1
- package/src/convert.ts +0 -2
- package/src/index.ts +22 -4
- package/src/stream.ts +9 -1
package/README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Pi Anthropic OAuth
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/pi-anthropic-oauth) [](https://www.npmjs.com/package/pi-anthropic-oauth) [](https://nodejs.org)
|
|
4
4
|
|
|
5
5
|
Claude Pro/Max OAuth extension for Pi.
|
|
6
6
|
|
|
7
7
|
> [!WARNING]
|
|
8
8
|
> Use this at your own risk. This may go against Anthropic's terms.
|
|
9
|
-
> I do not recommend using this with gsd2 or any extensions that will cause heavy token usage.
|
|
10
9
|
|
|
11
10
|
## Install
|
|
12
11
|
|
package/package.json
CHANGED
package/src/convert.ts
CHANGED
|
@@ -98,8 +98,6 @@ export function convertPiMessagesToAnthropic(
|
|
|
98
98
|
for (const block of message.content) {
|
|
99
99
|
if (block.type === "text" && block.text.trim()) {
|
|
100
100
|
blocks.push({ type: "text", text: sanitizeSurrogates(block.text) });
|
|
101
|
-
} else if (block.type === "thinking" && block.thinking.trim()) {
|
|
102
|
-
blocks.push({ type: "text", text: sanitizeSurrogates(block.thinking) });
|
|
103
101
|
} else if (block.type === "toolCall") {
|
|
104
102
|
blocks.push({
|
|
105
103
|
type: "tool_use",
|
package/src/index.ts
CHANGED
|
@@ -7,12 +7,21 @@ import { loginAnthropic, refreshAnthropicToken } from "./auth.js";
|
|
|
7
7
|
import { streamAnthropicOAuth } from "./stream.js";
|
|
8
8
|
|
|
9
9
|
const MODELS = [
|
|
10
|
+
{
|
|
11
|
+
id: "claude-opus-4-7",
|
|
12
|
+
name: "Claude Opus 4.7",
|
|
13
|
+
reasoning: true,
|
|
14
|
+
input: ["text", "image"] as ("text" | "image")[],
|
|
15
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
16
|
+
contextWindow: 1000000,
|
|
17
|
+
maxTokens: 128000,
|
|
18
|
+
},
|
|
10
19
|
{
|
|
11
20
|
id: "claude-opus-4-6",
|
|
12
21
|
name: "Claude Opus 4.6",
|
|
13
22
|
reasoning: true,
|
|
14
23
|
input: ["text", "image"] as ("text" | "image")[],
|
|
15
|
-
cost: { input:
|
|
24
|
+
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
16
25
|
contextWindow: 1000000,
|
|
17
26
|
maxTokens: 128000,
|
|
18
27
|
},
|
|
@@ -21,7 +30,7 @@ const MODELS = [
|
|
|
21
30
|
name: "Claude Sonnet 4.6",
|
|
22
31
|
reasoning: true,
|
|
23
32
|
input: ["text", "image"] as ("text" | "image")[],
|
|
24
|
-
cost: { input:
|
|
33
|
+
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
|
|
25
34
|
contextWindow: 1000000,
|
|
26
35
|
maxTokens: 64000,
|
|
27
36
|
},
|
|
@@ -30,10 +39,19 @@ const MODELS = [
|
|
|
30
39
|
name: "Claude Haiku 4.5",
|
|
31
40
|
reasoning: true,
|
|
32
41
|
input: ["text", "image"] as ("text" | "image")[],
|
|
33
|
-
cost: { input:
|
|
42
|
+
cost: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 },
|
|
34
43
|
contextWindow: 200000,
|
|
35
44
|
maxTokens: 64000,
|
|
36
45
|
},
|
|
46
|
+
{
|
|
47
|
+
id: "claude-opus-4-5-20251101",
|
|
48
|
+
name: "Claude Opus 4.5",
|
|
49
|
+
reasoning: true,
|
|
50
|
+
input: ["text", "image"] as ("text" | "image")[],
|
|
51
|
+
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
|
|
52
|
+
contextWindow: 200000,
|
|
53
|
+
maxTokens: 64000,
|
|
54
|
+
}
|
|
37
55
|
];
|
|
38
56
|
|
|
39
57
|
function ensureClaudeCodeSymlink() {
|
|
@@ -42,7 +60,7 @@ function ensureClaudeCodeSymlink() {
|
|
|
42
60
|
if (existsSync(target) && !existsSync(link)) {
|
|
43
61
|
try {
|
|
44
62
|
symlinkSync(target, link);
|
|
45
|
-
} catch {}
|
|
63
|
+
} catch { }
|
|
46
64
|
}
|
|
47
65
|
}
|
|
48
66
|
|
package/src/stream.ts
CHANGED
|
@@ -63,8 +63,16 @@ function makeDefaultHeaders(
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (options?.headers) {
|
|
66
|
-
for (const [key, value] of Object.entries(options.headers))
|
|
66
|
+
for (const [key, value] of Object.entries(options.headers)) {
|
|
67
|
+
const normalizedKey = key.toLowerCase();
|
|
68
|
+
if (
|
|
69
|
+
isOAuth &&
|
|
70
|
+
(normalizedKey === "x-api-key" || normalizedKey === "authorization")
|
|
71
|
+
) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
67
74
|
headers[key] = value;
|
|
75
|
+
}
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
return headers;
|