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": {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -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