Skip to content

feat(providers): Claude e OpenAI por chave de API; login por assinatura Claude e Copilot removidos - #75

Open
savass33 wants to merge 8 commits into
mainfrom
feat/provider-accounts-byok
Open

savass33 wants to merge 8 commits into
mainfrom
feat/provider-accounts-byok

Conversation

@savass33

@savass33 savass33 commented Nov 3, 2026

Copy link
Copy Markdown

Resumo

O usuário passa a conectar as próprias contas OpenAI e Anthropic de forma permitida e usa GPT e Claude dentro da Verboo Code CLI.

Claude

  • O login por assinatura (Pro/Max) usava o client ID OAuth do próprio Claude Code. O próprio aviso da CLI já dizia que a Anthropic não permite isso.
  • Agora /claude login conecta a chave de API da Anthropic do usuário:
    • a chave é validada em GET /v1/models;
    • fica só no armazenamento seguro, sem cópia em texto puro;
    • as requisições usam x-api-key, sem o beta OAuth;
    • o uso é cobrado pela Anthropic na chave do usuário.
  • Na inicialização, logins OAuth antigos são removidos (chaves de API e contas Codex continuam), e o usuário vê um aviso único.
  • Os arquivos do fluxo OAuth (claudeNativeOAuth.ts, useClaudeNativeOAuthFlow.ts) eram nossos e foram apagados. As janelas de uso por assinatura não existem para chave de API.

OpenAI por chave de API (novo)

  • /openai login|status|logout conecta a chave de API da OpenAI do usuário, com a mesma validação e o mesmo armazenamento.
  • Os modelos de chat e raciocínio aparecem no /model com o prefixo openai-api/. Assim não colidem com o mesmo GPT oferecido pelo Codex ou pelo roteador.
  • As requisições passam pelo shim OpenAI-compatível.

Codex

  • Sem mudança funcional. A Verboo vai pedir acesso ao "Sign in with ChatGPT" e migrar depois.
  • Provedores de terceiros (Codex e as chaves) passam a receber só o User-Agent, sem o id de sessão, x-app ou headers customizados.

Copilot

  • /onboard-github foi desregistrado: usava o app OAuth do GitHub Copilot e headers do VS Code, e nunca serviu inferência no modo Verboo.
  • Tokens salvos são ignorados e apagados do cofre nativo e do arquivo em texto puro.
  • O verificador de privacidade passa a barrar o client ID OAuth do Claude Code no bundle.

Testes

  • Novos:
    • claudeNativeCredentials.test.ts e .retire.test.ts (remoção de OAuth mantendo chave e Codex);
    • claudeLoginRetiredNotice.test.ts;
    • githubModelsCredentials.purge.test.ts;
    • openaiApiModels.test.ts e openaiApiKeyCredentials.test.ts;
    • caso OpenAI em activeModelIdentity.test.ts.
  • Atualizados: testes do Copilot (token ignorado) e o teste de dica de token expirado (sem /onboard-github).
  • Local, com Bun 1.3.13:
    • check-cli-quality --suite: 365/365 arquivos, build, self-test e pack;
    • --terminal: 36/36 e2e;
    • verify:privacy passa.

Observações

🤖 Generated with Claude Code

savass33 and others added 3 commits November 3, 2026 16:35
…ription logins

Anthropic does not allow third parties to offer Claude.ai login, and the
Claude subscription login used Claude Code's OAuth client id. It is gone:
/claude login now connects the user's own Anthropic API key (validated
against the Models API, kept only in secure storage, billed by Anthropic),
and requests use x-api-key with no OAuth beta header.

On startup, stored Claude OAuth logins are removed (API keys and other
providers' accounts are kept) and the user sees a one-time notice. Claude
subscription usage windows no longer apply to API keys.

The GitHub Copilot login (/onboard-github) is unregistered: it used
GitHub's Copilot OAuth app and VS Code headers and never served inference
in Verboo mode. Stored Copilot tokens are ignored and purged from both the
native vault and the plain-text fallback.

Codex is unchanged except that third-party providers (Codex and the
Anthropic key) now receive only a User-Agent instead of the Verboo
session id, x-app and custom headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/openai login connects the user's own OpenAI API key (validated against
the Models API, kept only in secure storage, billed by OpenAI). Chat and
reasoning models from api.openai.com/v1/models show up in /model with an
openai-api/ prefix, so they never collide with the same GPT model offered
through Codex (ChatGPT plan) or the Verboo router; the prefix is stripped
before the request. Requests go through the OpenAI-compatible shim with
only a User-Agent header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
savass33 and others added 5 commits November 4, 2026 09:42
Found by end-to-end validation of the 0.15.42 integration:

- API-key forms no longer cancel on a typed "n", which sent the rest of
  the key to the main prompt in clear text. Esc during validation no
  longer saves the key anyway.
- A new Anthropic key replaces the stored one; it used to be reported as
  connected while requests kept using the old key. Logout removes all.
- A candidate key never touches the catalog, so a typo no longer breaks
  the working session and a failed save leaves no unusable models.
- Requests on own accounts stop identifying as Claude Code (User-Agent,
  beta header, attribution block) and carry no device/account/session ids.
- A 401 on an own key no longer rotates the Verboo token, fails fast and
  tells the user how to replace the key.
- One malformed account no longer disables every provider's accounts.
- Catalog requests have a 10 s timeout, so startup cannot hang on them.
- OpenAI-key models use their real limits; /model hides Responses-only
  and legacy models. /openai logout fails when the vault cannot be read.
- The retired-login notice now fits an 80-column footer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found by the human e2e scenarios:
- Esc or Ctrl+C on /claude, /openai or /model printed "Interrupted": a dialog
  waiting for its answer holds the query guard, which looked like a turn.
- A key typed as an argument stayed on screen, in history and in the transcript.
- A refused entry stayed in the masked field and glued itself to the next paste.
- Storage failures showed internal codes; logout claimed to remove a key that
  did not exist; /claude status still offered to add a second key.
- The claude-code beta still went out on agentic queries.
- The retired-login notice lost the command when cut on an 80-column footer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clearing the field on every error broke the retry when the API or the keyring is
down. Only an entry that was actually refused is cleared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
savass33 added a commit that referenced this pull request Nov 4, 2026
…fects

Merges the own-key fixes from #75. Found by end-to-end validation:

- withRetry replaced the ChatGPT and OpenAI limit errors with a generic
  one, so the dialog only ever opened for Anthropic.
- /compact on an exhausted account kept the limit message as the summary
  and destroyed the conversation context.
- A limit hit after tools ran sent the prompt again, repeating their side
  effects. Now nothing is resent and the dialog says so. When nothing ran,
  the failed attempt leaves history so the model gets the request once.
- The compaction summary, images and task notifications are no longer
  taken for what the user typed, nor replaced by an older prompt.
- The dialog was opened as a hidden slash command, which wiped the prompt
  draft, polluted history and the transcript, could be shadowed by a skill
  and broke with --disable-slash-commands. The REPL now renders it directly.
- /resume no longer reopens the dialog for an old error.
- "Last Verboo model first" tracks a real router model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant