Revert "Remove Anthropic OAuth support"

This reverts commit f5e6bcac1b.
This commit is contained in:
Mario Zechner 2026-01-09 06:00:20 +01:00
parent f745321169
commit 19b5663340
10 changed files with 159 additions and 84 deletions

View file

@ -158,7 +158,7 @@ Add API keys to `~/.pi/agent/auth.json`:
| Provider | Auth Key | Environment Variable |
|----------|--------------|---------------------|
| Anthropic | `anthropic` | `ANTHROPIC_API_KEY`, `ANTHROPIC_OAUTH_TOKEN` |
| Anthropic | `anthropic` | `ANTHROPIC_API_KEY` |
| OpenAI | `openai` | `OPENAI_API_KEY` |
| Google | `google` | `GEMINI_API_KEY` |
| Mistral | `mistral` | `MISTRAL_API_KEY` |
@ -176,6 +176,7 @@ Use `/login` to authenticate with subscription-based or free-tier providers:
| Provider | Models | Cost |
|----------|--------|------|
| Anthropic (Claude Pro/Max) | Claude models via your subscription | Subscription |
| GitHub Copilot | GPT-4o, Claude, Gemini via Copilot subscription | Subscription |
| Google Gemini CLI | Gemini 2.0/2.5 models | Free (Google account) |
| Google Antigravity | Gemini 3, Claude, GPT-OSS | Free (Google account) |

View file

@ -156,23 +156,9 @@ class SnakeComponent {
this.onClose();
return;
}
// Any other key resumes (including P)
// Any other key resumes
this.paused = false;
this.startGame();
this.version++;
this.tui.requestRender();
return;
}
// P to pause without closing
if (data === "p" || data === "P") {
this.paused = true;
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
this.version++;
this.tui.requestRender();
return;
}
@ -289,7 +275,7 @@ class SnakeComponent {
} else if (this.state.gameOver) {
footer = `${red(bold("GAME OVER!"))} Press ${bold("R")} to restart, ${bold("Q")} to quit`;
} else {
footer = `↑↓←→ or WASD to move, ${bold("P")} pause, ${bold("ESC")} save+quit, ${bold("Q")} quit`;
footer = `↑↓←→ or WASD to move, ${bold("ESC")} pause, ${bold("Q")} quit`;
}
lines.push(this.padLine(boxLine(footer), width));

View file

@ -9,6 +9,7 @@
import {
getEnvApiKey,
getOAuthApiKey,
loginAnthropic,
loginAntigravity,
loginGeminiCli,
loginGitHubCopilot,
@ -169,6 +170,12 @@ export class AuthStorage {
let credentials: OAuthCredentials;
switch (provider) {
case "anthropic":
credentials = await loginAnthropic(
(url) => callbacks.onAuth({ url }),
() => callbacks.onPrompt({ message: "Paste the authorization code:" }),
);
break;
case "github-copilot":
credentials = await loginGitHubCopilot({
onAuth: (url, instructions) => callbacks.onAuth({ url, instructions }),

View file

@ -303,6 +303,5 @@ Documentation:
prompt += `\nCurrent date and time: ${dateTime}`;
prompt += `\nCurrent working directory: ${resolvedCwd}`;
prompt = "You are a helpful assistant. Be concise.";
return prompt;
}