diff --git a/UPSTREAM_SYNC.md b/UPSTREAM_SYNC.md index 205fc028c7..0888c7c240 100644 --- a/UPSTREAM_SYNC.md +++ b/UPSTREAM_SYNC.md @@ -53,6 +53,22 @@ em volta. Use `git grep "VERBOO-BRAND"` para localizar todos os pontos editados. - `src/commands/provider/` — arquivos **NÃO foram deletados** (upstream continua mexendo neles; deletar gera conflitos "deleted file modified upstream"). +#### `/onboard-github` (GitHub Copilot) desregistrado +- `src/commands.ts` — import e entry comentados, como o `/provider`. +- `src/utils/githubModelsCredentials.ts` — leitores e refresh retornam vazio + (`GITHUB_MODELS_LOGIN_RETIRED`); `purgeGithubModelsCredentials` apaga tokens + salvos (cofre nativo e arquivo em texto puro) na inicialização. +- `src/commands/onboard-github/` e `src/integrations/gateways/github.ts` **não + foram deletados**. + +#### Login Claude por assinatura removido (código Verboo, não upstream) +- O OAuth com o client id do Claude Code saiu: `claudeNativeOAuth.ts` e + `useClaudeNativeOAuthFlow.ts` foram deletados (eram nossos, não do upstream). +- `/claude login` conecta a chave de API da Anthropic do usuário; + `retireClaudeOAuthCredentials` remove logins OAuth antigos na inicialização. +- `src/services/api/client.ts` — provedores de terceiros (Codex, chave + Anthropic) recebem só `User-Agent`, sem headers de sessão do Verboo. + #### Mensagens reescritas - `src/utils/providerValidation.ts` (3 ocorrências) - `src/services/api/withRetry.ts` diff --git a/scripts/verify-no-phone-home.ts b/scripts/verify-no-phone-home.ts index 843c5f338b..a42c90f1b4 100644 --- a/scripts/verify-no-phone-home.ts +++ b/scripts/verify-no-phone-home.ts @@ -13,6 +13,8 @@ const BANNED_PATTERNS = [ 'infra.ant.dev', 'claude-code-feedback', 'C07VBSHV7EV', + // Claude Code's OAuth client id: the Claude subscription login was retired. + '9d1c250a-e61b-44d9-88ed-5944d1962f5e', ] as const if (!existsSync(DIST)) { diff --git a/src/commands.ts b/src/commands.ts index edc50a2ec8..c3f7b24584 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -16,6 +16,7 @@ import commitPushPr from './commands/commit-push-pr.js' import compact from './commands/compact/index.js' import codex from './commands/codex/index.js' import claude from './commands/claude/index.js' +import openai from './commands/openai/index.js' import config from './commands/config/index.js' import { context, contextNonInteractive } from './commands/context/index.js' import cost from './commands/cost/index.js' @@ -23,7 +24,9 @@ import diff from './commands/diff/index.js' import dream from './commands/dream/index.js' import ctx_viz from './commands/ctx_viz/index.js' import doctor from './commands/doctor/index.js' -import onboardGithub from './commands/onboard-github/index.js' +// VERBOO-BRAND: /onboard-github desregistrado — usava o app OAuth do GitHub +// Copilot e cabeçalhos do VS Code, e não funciona no modo Verboo. +// import onboardGithub from './commands/onboard-github/index.js' import knowledge from './commands/knowledge/index.js' import memory from './commands/memory/index.js' import help from './commands/help/index.js' @@ -286,6 +289,7 @@ const COMMANDS = memoize((): Command[] => [ color, compact, claude, + openai, codex, commitMessage, config, @@ -315,7 +319,7 @@ const COMMANDS = memoize((): Command[] => [ memory, mobile, model, - onboardGithub, + // onboardGithub, // VERBOO-BRAND: ver import acima outputStyle, remoteEnv, plugin, diff --git a/src/commands/claude/claude.tsx b/src/commands/claude/claude.tsx index 738b435870..456c1a8746 100644 --- a/src/commands/claude/claude.tsx +++ b/src/commands/claude/claude.tsx @@ -1,20 +1,12 @@ import * as React from 'react' -import { Select } from '../../components/CustomSelect/select.js' -import { Dialog } from '../../components/design-system/Dialog.js' -import { useClaudeNativeOAuthFlow } from '../../components/useClaudeNativeOAuthFlow.js' +import TextInput from '../../components/TextInput.js' import { Box, Text, useInput } from '../../ink.js' -import { useKeybinding } from '../../keybindings/useKeybinding.js' import { clearClaudeNativeModelsCache, fetchClaudeNativeModels, getCachedClaudeNativeModels, } from '../../services/api/claudeNativeModels.js' -import { - CLAUDE_CONSUMER_TERMS_URL, - CLAUDE_LEGAL_URL, - CLAUDE_RISK_NOTICE_VERSION, -} from '../../services/api/claudeNativeConfig.js' import { getCachedCodexModels } from '../../services/api/codexModels.js' import { getCachedVerbooModels } from '../../services/api/verbooModels.js' import { ensureVerbooAuthenticated } from '../../services/oauth/verbooStartupAuth.js' @@ -23,166 +15,150 @@ import type { LocalJSXCommandOnDone, } from '../../types/command.js' import { + buildClaudeApiKeyCredential, clearClaudeNativeCredentials, - hasCurrentClaudeRiskAcceptance, + looksLikeAnthropicApiKey, readClaudeNativeCredentialsAsync, - type ClaudeNativeCredentialBlob, + saveClaudeNativeCredentials, } from '../../utils/claudeNativeCredentials.js' import { parseProviderLoginArgs } from '../../utils/providerAccounts/loginArgs.js' import { listProviderAccountSummaries } from '../../utils/providerAccounts/store.js' import { formatProviderAccountStatus } from '../../utils/providerAccounts/status.js' -function ClaudeLogin({ - acceptedAt, +type LoginState = + | { state: 'editing'; error?: string; keepEntry?: boolean } + | { state: 'validating' } + +/** + * Connects the user's own Anthropic API key (Console). Requests made with it + * are billed by Anthropic to that key. The key is validated against the + * Models API before it is stored, and only ever kept in secure storage. + */ +function ClaudeApiKeyLogin({ onDone, - reconnectLocalAccountId, }: { - acceptedAt: string onDone: LocalJSXCommandOnDone - reconnectLocalAccountId?: string }) { - const handleAuthenticated = React.useCallback( - async ( - _tokens: unknown, - persistCredentials: (options?: { reconnectLocalAccountId?: string }) => void, - candidateCredentials: ClaudeNativeCredentialBlob, - ) => { - clearClaudeNativeModelsCache() - const models = await fetchClaudeNativeModels({ - force: true, - credentials: candidateCredentials, - }) - if (models.length === 0) { - throw new Error( - 'Login Claude concluído, mas a Models API não retornou modelos para esta conta.', - ) - } - try { - persistCredentials({ reconnectLocalAccountId }) - } catch (error) { - // Do not leave an in-memory Claude catalog unlocked when secure - // persistence failed. A failed optional login must not affect Verboo. - clearClaudeNativeModelsCache() - throw error - } - onDone( - `Login Claude concluído. ${models.length} modelo(s) adicional(is) liberado(s). O Verboo continua como prioridade; use /model para escolher.`, - { display: 'system' }, - ) - }, - [onDone], - ) - const status = useClaudeNativeOAuthFlow({ - additive: true, - reconnectLocalAccountId, - acceptedAt, - onAuthenticated: handleAuthenticated, - }) - const handleCancel = React.useCallback(() => { - status.cancel() - onDone('Login Claude cancelado. O Verboo continua disponível.', { + const [value, setValue] = React.useState('') + const [cursorOffset, setCursorOffset] = React.useState(0) + const [status, setStatus] = React.useState({ state: 'editing' }) + + // The field is masked: nothing shows that a refused entry is still in it, and + // pasting a corrected key would glue the two together. + React.useEffect(() => { + if (status.state === 'editing' && status.error && !status.keepEntry) { + setValue('') + setCursorOffset(0) + } + }, [status]) + + const cancelledRef = React.useRef(false) + + const cancel = React.useCallback(() => { + cancelledRef.current = true + onDone('Conexão Claude cancelada. O Verboo continua disponível.', { display: 'system', }) - }, [onDone, status]) + }, [onDone]) - useKeybinding('confirm:no', handleCancel, { context: 'Confirmation' }) useInput((input, key, event) => { if (key.escape || (key.ctrl && input === 'c')) { event.stopImmediatePropagation() - handleCancel() + cancel() } }) - if (status.state === 'error') return {status.message} + const submit = React.useCallback( + async (raw: string) => { + const apiKey = raw.trim() + if (!looksLikeAnthropicApiKey(apiKey)) { + setStatus({ + state: 'editing', + error: 'Isso não parece uma chave de API da Anthropic (começa com sk-ant-).', + }) + return + } + setStatus({ state: 'validating' }) + const credentials = buildClaudeApiKeyCredential(apiKey) + try { + // A candidate key never touches the catalog of the key in use: a typo + // here must not break the working session. + const models = await fetchClaudeNativeModels({ force: true, credentials }) + if (cancelledRef.current) return + if (models.length === 0) { + setStatus({ + state: 'editing', + error: 'A chave foi aceita, mas a Anthropic não retornou nenhum modelo para ela.', + }) + return + } + const saved = saveClaudeNativeCredentials(credentials) + if (!saved.success) { + setStatus({ + state: 'editing', + keepEntry: true, + error: saved.warning ?? 'Não foi possível salvar a chave no armazenamento seguro.', + }) + return + } + clearClaudeNativeModelsCache() + await fetchClaudeNativeModels({ force: true }).catch(() => undefined) + if (cancelledRef.current) return + onDone( + `Chave da Anthropic conectada (…${credentials.keyHint}). ${models.length} modelo(s) Claude liberado(s), cobrados pela Anthropic na sua chave. Use /model para escolher.`, + { display: 'system' }, + ) + } catch (error) { + if (cancelledRef.current) return + const status = (error as { status?: number }).status + setStatus({ + state: 'editing', + // A key that could not be checked may be fine: Enter tries it again. + keepEntry: status !== 401 && status !== 403, + error: + status === 401 || status === 403 + ? 'A Anthropic recusou essa chave. Confira a chave no Console da Anthropic.' + : `Não foi possível validar a chave: ${error instanceof Error ? error.message : String(error)}`, + }) + } + }, + [onDone], + ) + return ( - Login Claude nativo + Conectar Claude com sua chave de API - Entre com sua conta Claude. As credenciais ficam somente no armazenamento - seguro do Verboo Code. + Cole uma chave de API da Anthropic (console.anthropic.com → API Keys). O + uso dos modelos Claude é cobrado pela Anthropic nessa chave. A chave fica + somente no armazenamento seguro do Verboo Code. - {status.state === 'starting' ? ( - Preparando o login no navegador… - ) : status.browserOpened === false ? ( - <> - Abra esta URL para continuar: - {status.authUrl} - + {status.state === 'validating' ? ( + Validando a chave com a Anthropic… ) : ( - <> - Conclua o login no navegador. - {status.authUrl} - + + Chave: + void submit(value)} + cursorOffset={cursorOffset} + onChangeCursorOffset={setCursorOffset} + columns={60} + focus={true} + showCursor={true} + mask="*" + /> + )} - Pressione Esc ou Ctrl+C para cancelar. + {status.state === 'editing' && status.error ? ( + {status.error} + ) : null} + Enter para confirmar · Esc para cancelar ) } -function ClaudeRiskDisclosure({ - onDone, - reconnectLocalAccountId, -}: { - onDone: LocalJSXCommandOnDone - reconnectLocalAccountId?: string -}) { - const [acceptedAt, setAcceptedAt] = React.useState(null) - if (acceptedAt) { - return ( - - ) - } - - const cancel = () => - onDone('Claude não habilitado. O Verboo continua disponível.', { - display: 'system', - }) - - return ( - - - - A Anthropic informa que o OAuth de assinaturas Claude é destinado ao - Claude Code e a outros aplicativos nativos. Ela não permite que - terceiros ofereçam login Claude.ai nem roteiem solicitações usando - credenciais Free, Pro ou Max. - - - O Verboo Code não é afiliado nem endossado pela Anthropic. Este uso - pode deixar de funcionar sem aviso e pode resultar em limitação ou - suspensão da conta. Prompts, código e resultados de ferramentas serão - enviados diretamente à Anthropic. - - - O aceite registra apenas sua ciência e não concede permissão da Anthropic. - - Política: {CLAUDE_LEGAL_URL} - Termos: {CLAUDE_CONSUMER_TERMS_URL} -