pi-anthropic-oauth 0.2.1 → 0.2.3
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 +3 -4
- package/package.json +3 -3
- package/src/convert.ts +18 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
Use Claude Pro/Max in Pi with browser OAuth.
|
|
6
6
|
|
|
7
7
|
> [!IMPORTANT]
|
|
8
|
-
> This
|
|
8
|
+
> This extension supports Pi 0.80.8 or later.
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
@@ -13,8 +13,7 @@ Use Claude Pro/Max in Pi with browser OAuth.
|
|
|
13
13
|
- Automatic token refresh
|
|
14
14
|
- Claude Code-compatible OAuth headers and prompt shaping
|
|
15
15
|
- No Anthropic API key needed
|
|
16
|
-
- Uses Pi's
|
|
17
|
-
- Adds Claude Opus 4.8 and Claude Fable 5 by default
|
|
16
|
+
- Uses the Anthropic models available in Pi's built-in model registry
|
|
18
17
|
- Auto-creates `~/.Claude Code` → `~/.pi` symlink when missing
|
|
19
18
|
|
|
20
19
|
## Quick start
|
|
@@ -101,7 +100,7 @@ To add another Anthropic model, create `~/.pi/agent/models.json`:
|
|
|
101
100
|
```
|
|
102
101
|
|
|
103
102
|
> [!NOTE]
|
|
104
|
-
> Opus
|
|
103
|
+
> Opus 5 and Fable 5 are included in Pi's built-in Anthropic model catalog as `claude-opus-5` and `claude-fable-5`.
|
|
105
104
|
>
|
|
106
105
|
> Pi requires `baseUrl`, `apiKey`, and `api` when defining custom models in `models.json`. With this extension, requests normally authenticate through Claude Pro/Max OAuth after `/login`, so `apiKey` is only a placeholder to satisfy Pi's config requirements and does not need to be a valid Anthropic API key.
|
|
107
106
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-anthropic-oauth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Claude Pro/Max OAuth extension for Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@earendil-works/pi-ai": "
|
|
42
|
-
"@earendil-works/pi-coding-agent": "
|
|
41
|
+
"@earendil-works/pi-ai": ">=0.80.8",
|
|
42
|
+
"@earendil-works/pi-coding-agent": ">=0.80.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@earendil-works/pi-ai": "^0.80.8",
|
package/src/convert.ts
CHANGED
|
@@ -42,11 +42,28 @@ const claudeCodeTools = [
|
|
|
42
42
|
] as const;
|
|
43
43
|
const claudeCodeToolLookup = new Map(claudeCodeTools.map((name) => [name.toLowerCase(), name]));
|
|
44
44
|
|
|
45
|
+
// Anthropic's OAuth classifier rejects tool definitions with names outside
|
|
46
|
+
// Claude Code's own tool set with a 400 "Third-party apps now draw from your
|
|
47
|
+
// extra usage" error. Claude Code exposes MCP tools as `mcp__<server>__<tool>`,
|
|
48
|
+
// so unknown tools are namespaced under `mcp__pi__`.
|
|
49
|
+
const CLAUDE_CODE_MCP_TOOL_PREFIX = "mcp__pi__";
|
|
50
|
+
|
|
51
|
+
function sanitizeCustomToolName(name: string): string {
|
|
52
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
export function toClaudeCodeToolName(name: string): string {
|
|
46
|
-
return
|
|
56
|
+
return (
|
|
57
|
+
claudeCodeToolLookup.get(name.toLowerCase()) ??
|
|
58
|
+
`${CLAUDE_CODE_MCP_TOOL_PREFIX}${sanitizeCustomToolName(name)}`
|
|
59
|
+
);
|
|
47
60
|
}
|
|
48
61
|
|
|
49
62
|
export function fromClaudeCodeToolName(name: string, tools?: Tool[]): string {
|
|
63
|
+
if (name.startsWith(CLAUDE_CODE_MCP_TOOL_PREFIX)) {
|
|
64
|
+
const stripped = name.slice(CLAUDE_CODE_MCP_TOOL_PREFIX.length);
|
|
65
|
+
return tools?.find((tool) => sanitizeCustomToolName(tool.name) === stripped)?.name ?? stripped;
|
|
66
|
+
}
|
|
50
67
|
const lower = name.toLowerCase();
|
|
51
68
|
return tools?.find((tool) => tool.name.toLowerCase() === lower)?.name ?? name;
|
|
52
69
|
}
|