mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
feat: /login支持codex订阅登录
This commit is contained in:
@@ -155,7 +155,7 @@ export async function call(onDone: LocalJSXCommandOnDone, _context: unknown, arg
|
||||
|
||||
if (COMMON_HELP_ARGS.includes(args)) {
|
||||
onDone(
|
||||
'Usage: /effort [low|medium|high|max|auto]\n\nEffort levels:\n- low: Quick, straightforward implementation\n- medium: Balanced approach with standard testing\n- high: Comprehensive implementation with extensive testing\n- max: Maximum capability with deepest reasoning (Opus 4.6/4.7, DeepSeek V4 Pro)\n- auto: Use the default effort level for your model',
|
||||
'Usage: /effort [low|medium|high|xhigh|max|auto]\n\nEffort levels:\n- low: Quick, straightforward implementation\n- medium: Balanced approach with standard testing\n- high: Comprehensive implementation with extensive testing\n- xhigh: Extra high reasoning for supported models, including ChatGPT Codex models\n- max: Maximum capability with deepest reasoning where supported (Opus 4.6/4.7, DeepSeek V4 Pro); maps to xhigh for ChatGPT Codex models\n- auto: Use the default effort level for your model',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { isEnvTruthy } from '../../utils/envUtils.js'
|
||||
export default {
|
||||
type: 'local-jsx',
|
||||
name: 'logout',
|
||||
description: 'Sign out from your Anthropic account',
|
||||
description: 'Sign out from your configured account',
|
||||
isEnabled: () => !isEnvTruthy(process.env.DISABLE_LOGOUT_COMMAND),
|
||||
load: () => import('./logout.js'),
|
||||
} satisfies Command
|
||||
|
||||
@@ -6,11 +6,13 @@ import { getGroveNoticeConfig, getGroveSettings } from '../../services/api/grove
|
||||
import { clearPolicyLimitsCache } from '../../services/policyLimits/index.js';
|
||||
// flushTelemetry is loaded lazily to avoid pulling in ~1.1MB of OpenTelemetry at startup
|
||||
import { clearRemoteManagedSettingsCache } from '../../services/remoteManagedSettings/index.js';
|
||||
import { removeChatGPTAuth } from '../../services/api/openai/chatgptAuth.js';
|
||||
import { getClaudeAIOAuthTokens, removeApiKey } from '../../utils/auth.js';
|
||||
import { clearBetasCaches } from '../../utils/betas.js';
|
||||
import { saveGlobalConfig } from '../../utils/config.js';
|
||||
import { gracefulShutdownSync } from '../../utils/gracefulShutdown.js';
|
||||
import { getSecureStorage } from '../../utils/secureStorage/index.js';
|
||||
import { getSettingsForSource, updateSettingsForSource } from '../../utils/settings/settings.js';
|
||||
import { clearToolSchemaCache } from '../../utils/toolSchemaCache.js';
|
||||
import { resetUserCache } from '../../utils/user.js';
|
||||
|
||||
@@ -20,6 +22,8 @@ export async function performLogout({ clearOnboarding = false }): Promise<void>
|
||||
await flushTelemetry();
|
||||
|
||||
await removeApiKey();
|
||||
await removeChatGPTAuth();
|
||||
clearChatGPTSettingsAuthMode();
|
||||
|
||||
// Wipe all secure storage data on logout
|
||||
const secureStorage = getSecureStorage();
|
||||
@@ -44,6 +48,24 @@ export async function performLogout({ clearOnboarding = false }): Promise<void>
|
||||
});
|
||||
}
|
||||
|
||||
function clearChatGPTSettingsAuthMode(): void {
|
||||
delete process.env.OPENAI_AUTH_MODE;
|
||||
const userSettings = getSettingsForSource('userSettings') ?? {};
|
||||
const env = userSettings.env ?? {};
|
||||
const hasOpenAICompatibleConfig =
|
||||
Boolean(env.OPENAI_API_KEY ?? process.env.OPENAI_API_KEY) &&
|
||||
Boolean(env.OPENAI_BASE_URL ?? process.env.OPENAI_BASE_URL);
|
||||
const settingsUpdate: Parameters<typeof updateSettingsForSource>[1] = {
|
||||
...(userSettings.modelType === 'openai' && !hasOpenAICompatibleConfig
|
||||
? { modelType: undefined }
|
||||
: {}),
|
||||
env: {
|
||||
OPENAI_AUTH_MODE: undefined,
|
||||
} as unknown as Record<string, string>,
|
||||
};
|
||||
updateSettingsForSource('userSettings', settingsUpdate);
|
||||
}
|
||||
|
||||
// clearing anything memoized that must be invalidated when user/session/auth changes
|
||||
export async function clearAuthRelatedCaches(): Promise<void> {
|
||||
// Clear the OAuth token cache
|
||||
@@ -70,7 +92,7 @@ export async function clearAuthRelatedCaches(): Promise<void> {
|
||||
export async function call(): Promise<React.ReactNode> {
|
||||
await performLogout({ clearOnboarding: true });
|
||||
|
||||
const message = <Text>Successfully logged out from your Anthropic account.</Text>;
|
||||
const message = <Text>Successfully logged out.</Text>
|
||||
|
||||
setTimeout(() => {
|
||||
gracefulShutdownSync(0, 'logout');
|
||||
|
||||
@@ -81,9 +81,10 @@ const call: LocalCommandCall = async (args, _context) => {
|
||||
// Check env vars when switching to openai (including settings.env)
|
||||
if (arg === 'openai') {
|
||||
const mergedEnv = getMergedEnv()
|
||||
const hasChatGPTAuth = mergedEnv.OPENAI_AUTH_MODE === 'chatgpt'
|
||||
const hasKey = !!mergedEnv.OPENAI_API_KEY
|
||||
const hasUrl = !!mergedEnv.OPENAI_BASE_URL
|
||||
if (!hasKey || !hasUrl) {
|
||||
if (!hasChatGPTAuth && (!hasKey || !hasUrl)) {
|
||||
updateSettingsForSource('userSettings', { modelType: 'openai' })
|
||||
const missing = []
|
||||
if (!hasKey) missing.push('OPENAI_API_KEY')
|
||||
|
||||
Reference in New Issue
Block a user