fix: suppress OpenAI startup warning and account banner
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitlawb/openclaude",
|
"name": "@gitlawb/openclaude",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"description": "Claude Code opened to any LLM — OpenAI, Gemini, DeepSeek, Ollama, and 200+ models",
|
"description": "Claude Code opened to any LLM — OpenAI, Gemini, DeepSeek, Ollama, and 200+ models",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -41,13 +41,15 @@ import { useShowOverageCreditUpsell, incrementOverageCreditUpsellSeenCount, crea
|
|||||||
import { plural } from '../../utils/stringUtils.js';
|
import { plural } from '../../utils/stringUtils.js';
|
||||||
import { useAppState } from '../../state/AppState.js';
|
import { useAppState } from '../../state/AppState.js';
|
||||||
import { getEffortSuffix } from '../../utils/effort.js';
|
import { getEffortSuffix } from '../../utils/effort.js';
|
||||||
|
import { getAPIProvider } from '../../utils/model/providers.js';
|
||||||
import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';
|
import { useMainLoopModel } from '../../hooks/useMainLoopModel.js';
|
||||||
import { renderModelSetting } from '../../utils/model/model.js';
|
import { renderModelSetting } from '../../utils/model/model.js';
|
||||||
const LEFT_PANEL_MAX_WIDTH = 50;
|
const LEFT_PANEL_MAX_WIDTH = 50;
|
||||||
export function LogoV2() {
|
export function LogoV2() {
|
||||||
const $ = _c(94);
|
const $ = _c(94);
|
||||||
const activities = getRecentActivitySync();
|
const activities = getRecentActivitySync();
|
||||||
const username = getGlobalConfig().oauthAccount?.displayName ?? "";
|
const showAccountIdentity = getAPIProvider() === 'firstParty';
|
||||||
|
const username = showAccountIdentity ? getGlobalConfig().oauthAccount?.displayName ?? "" : "";
|
||||||
const {
|
const {
|
||||||
columns
|
columns
|
||||||
} = useTerminalSize();
|
} = useTerminalSize();
|
||||||
@@ -210,7 +212,7 @@ export function LogoV2() {
|
|||||||
}
|
}
|
||||||
let t18;
|
let t18;
|
||||||
if ($[22] !== announcement || $[23] !== config) {
|
if ($[22] !== announcement || $[23] !== config) {
|
||||||
t18 = announcement && <Box paddingLeft={2} flexDirection="column">{!process.env.IS_DEMO && config.oauthAccount?.organizationName && <Text dimColor={true}>Message from {config.oauthAccount.organizationName}:</Text>}<Text>{announcement}</Text></Box>;
|
t18 = announcement && <Box paddingLeft={2} flexDirection="column">{showAccountIdentity && !process.env.IS_DEMO && config.oauthAccount?.organizationName && <Text dimColor={true}>Message from {config.oauthAccount.organizationName}:</Text>}<Text>{announcement}</Text></Box>;
|
||||||
$[22] = announcement;
|
$[22] = announcement;
|
||||||
$[23] = config;
|
$[23] = config;
|
||||||
$[24] = t18;
|
$[24] = t18;
|
||||||
@@ -329,7 +331,7 @@ export function LogoV2() {
|
|||||||
return <><OffscreenFreeze><Box flexDirection="column" borderStyle="round" borderColor="claude" borderText={t11} paddingX={1} paddingY={1} alignItems="center" width={columns}><Text bold={true}>{welcomeMessage}</Text>{t12}{t13}<Text dimColor={true}>{billingType}</Text><Text dimColor={true}>{agentName ? `@${agentName} · ${truncatedCwd}` : truncatedCwd}</Text></Box></OffscreenFreeze>{t14}{t15}{t16}{t17}{t18}{t19}</>;
|
return <><OffscreenFreeze><Box flexDirection="column" borderStyle="round" borderColor="claude" borderText={t11} paddingX={1} paddingY={1} alignItems="center" width={columns}><Text bold={true}>{welcomeMessage}</Text>{t12}{t13}<Text dimColor={true}>{billingType}</Text><Text dimColor={true}>{agentName ? `@${agentName} · ${truncatedCwd}` : truncatedCwd}</Text></Box></OffscreenFreeze>{t14}{t15}{t16}{t17}{t18}{t19}</>;
|
||||||
}
|
}
|
||||||
const welcomeMessage_0 = formatWelcomeMessage(username);
|
const welcomeMessage_0 = formatWelcomeMessage(username);
|
||||||
const modelLine = !process.env.IS_DEMO && config.oauthAccount?.organizationName ? `${modelDisplayName} · ${billingType} · ${config.oauthAccount.organizationName}` : `${modelDisplayName} · ${billingType}`;
|
const modelLine = showAccountIdentity && !process.env.IS_DEMO && config.oauthAccount?.organizationName ? `${modelDisplayName} · ${billingType} · ${config.oauthAccount.organizationName}` : `${modelDisplayName} · ${billingType}`;
|
||||||
const cwdAvailableWidth_0 = agentName ? LEFT_PANEL_MAX_WIDTH - 1 - stringWidth(agentName) - 3 : LEFT_PANEL_MAX_WIDTH;
|
const cwdAvailableWidth_0 = agentName ? LEFT_PANEL_MAX_WIDTH - 1 - stringWidth(agentName) - 3 : LEFT_PANEL_MAX_WIDTH;
|
||||||
const truncatedCwd_0 = truncatePath(cwd, Math.max(cwdAvailableWidth_0, 10));
|
const truncatedCwd_0 = truncatePath(cwd, Math.max(cwdAvailableWidth_0, 10));
|
||||||
const cwdLine = agentName ? `@${agentName} · ${truncatedCwd_0}` : truncatedCwd_0;
|
const cwdLine = agentName ? `@${agentName} · ${truncatedCwd_0}` : truncatedCwd_0;
|
||||||
@@ -479,7 +481,7 @@ export function LogoV2() {
|
|||||||
}
|
}
|
||||||
let t35;
|
let t35;
|
||||||
if ($[81] !== announcement || $[82] !== config) {
|
if ($[81] !== announcement || $[82] !== config) {
|
||||||
t35 = announcement && <Box paddingLeft={2} flexDirection="column">{!process.env.IS_DEMO && config.oauthAccount?.organizationName && <Text dimColor={true}>Message from {config.oauthAccount.organizationName}:</Text>}<Text>{announcement}</Text></Box>;
|
t35 = announcement && <Box paddingLeft={2} flexDirection="column">{showAccountIdentity && !process.env.IS_DEMO && config.oauthAccount?.organizationName && <Text dimColor={true}>Message from {config.oauthAccount.organizationName}:</Text>}<Text>{announcement}</Text></Box>;
|
||||||
$[81] = announcement;
|
$[81] = announcement;
|
||||||
$[82] = config;
|
$[82] = config;
|
||||||
$[83] = t35;
|
$[83] = t35;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import Anthropic, { type ClientOptions } from '@anthropic-ai/sdk'
|
import Anthropic, { type ClientOptions } from '@anthropic-ai/sdk'
|
||||||
import { randomUUID } from 'crypto'
|
import { randomUUID } from 'crypto'
|
||||||
import type { GoogleAuth } from 'google-auth-library'
|
|
||||||
import {
|
import {
|
||||||
checkAndRefreshOAuthTokenIfNeeded,
|
checkAndRefreshOAuthTokenIfNeeded,
|
||||||
getAnthropicApiKey,
|
getAnthropicApiKey,
|
||||||
@@ -29,6 +28,11 @@ import {
|
|||||||
isEnvTruthy,
|
isEnvTruthy,
|
||||||
} from '../../utils/envUtils.js'
|
} from '../../utils/envUtils.js'
|
||||||
|
|
||||||
|
const importRuntimeModule = new Function(
|
||||||
|
'specifier',
|
||||||
|
'return import(specifier)',
|
||||||
|
) as (specifier: string) => Promise<any>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Environment variables for different client types:
|
* Environment variables for different client types:
|
||||||
*
|
*
|
||||||
@@ -197,7 +201,9 @@ export async function getAnthropicClient({
|
|||||||
return new AnthropicBedrock(bedrockArgs) as unknown as Anthropic
|
return new AnthropicBedrock(bedrockArgs) as unknown as Anthropic
|
||||||
}
|
}
|
||||||
if (isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY)) {
|
if (isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY)) {
|
||||||
const { AnthropicFoundry } = await import('@anthropic-ai/foundry-sdk')
|
const { AnthropicFoundry } = await importRuntimeModule(
|
||||||
|
'@anthropic-ai/foundry-sdk',
|
||||||
|
)
|
||||||
// Determine Azure AD token provider based on configuration
|
// Determine Azure AD token provider based on configuration
|
||||||
// SDK reads ANTHROPIC_FOUNDRY_API_KEY by default
|
// SDK reads ANTHROPIC_FOUNDRY_API_KEY by default
|
||||||
let azureADTokenProvider: (() => Promise<string>) | undefined
|
let azureADTokenProvider: (() => Promise<string>) | undefined
|
||||||
@@ -210,7 +216,7 @@ export async function getAnthropicClient({
|
|||||||
const {
|
const {
|
||||||
DefaultAzureCredential: AzureCredential,
|
DefaultAzureCredential: AzureCredential,
|
||||||
getBearerTokenProvider,
|
getBearerTokenProvider,
|
||||||
} = await import('@azure/identity')
|
} = await importRuntimeModule('@azure/identity')
|
||||||
azureADTokenProvider = getBearerTokenProvider(
|
azureADTokenProvider = getBearerTokenProvider(
|
||||||
new AzureCredential(),
|
new AzureCredential(),
|
||||||
'https://cognitiveservices.azure.com/.default',
|
'https://cognitiveservices.azure.com/.default',
|
||||||
@@ -218,7 +224,7 @@ export async function getAnthropicClient({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const foundryArgs: ConstructorParameters<typeof AnthropicFoundry>[0] = {
|
const foundryArgs = {
|
||||||
...ARGS,
|
...ARGS,
|
||||||
...(azureADTokenProvider && { azureADTokenProvider }),
|
...(azureADTokenProvider && { azureADTokenProvider }),
|
||||||
...(isDebugToStdErr() && { logger: createStderrLogger() }),
|
...(isDebugToStdErr() && { logger: createStderrLogger() }),
|
||||||
@@ -234,8 +240,8 @@ export async function getAnthropicClient({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [{ AnthropicVertex }, { GoogleAuth }] = await Promise.all([
|
const [{ AnthropicVertex }, { GoogleAuth }] = await Promise.all([
|
||||||
import('@anthropic-ai/vertex-sdk'),
|
importRuntimeModule('@anthropic-ai/vertex-sdk'),
|
||||||
import('google-auth-library'),
|
importRuntimeModule('google-auth-library'),
|
||||||
])
|
])
|
||||||
// TODO: Cache either GoogleAuth instance or AuthClient to improve performance
|
// TODO: Cache either GoogleAuth instance or AuthClient to improve performance
|
||||||
// Currently we create a new GoogleAuth instance for every getAnthropicClient() call
|
// Currently we create a new GoogleAuth instance for every getAnthropicClient() call
|
||||||
@@ -277,7 +283,11 @@ export async function getAnthropicClient({
|
|||||||
getClient: () => ({
|
getClient: () => ({
|
||||||
getRequestHeaders: () => ({}),
|
getRequestHeaders: () => ({}),
|
||||||
}),
|
}),
|
||||||
} as unknown as GoogleAuth)
|
} as {
|
||||||
|
getClient: () => {
|
||||||
|
getRequestHeaders: () => Record<string, string>
|
||||||
|
}
|
||||||
|
})
|
||||||
: new GoogleAuth({
|
: new GoogleAuth({
|
||||||
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
|
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
|
||||||
// Only use ANTHROPIC_VERTEX_PROJECT_ID as last resort fallback
|
// Only use ANTHROPIC_VERTEX_PROJECT_ID as last resort fallback
|
||||||
@@ -295,7 +305,7 @@ export async function getAnthropicClient({
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
const vertexArgs: ConstructorParameters<typeof AnthropicVertex>[0] = {
|
const vertexArgs = {
|
||||||
...ARGS,
|
...ARGS,
|
||||||
region: getVertexRegionForModel(model),
|
region: getVertexRegionForModel(model),
|
||||||
googleAuth,
|
googleAuth,
|
||||||
|
|||||||
Reference in New Issue
Block a user