From 26fc3ff3228c956473911a2ae62404c9d3870aab Mon Sep 17 00:00:00 2001 From: KeXin95 Date: Sat, 25 Apr 2026 22:12:09 -0700 Subject: [PATCH] feat: pass ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN into agent containers Users with a custom Anthropic-compatible endpoint (ANTHROPIC_BASE_URL) were getting 401s because the OneCLI proxy injects ANTHROPIC_API_KEY=placeholder and forwards to api.anthropic.com, overriding the custom endpoint and key. Add a claude provider host config that reads ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC from .env and passes them into the container. Also sets NO_PROXY for the custom host so the OneCLI proxy doesn't intercept those requests. Co-Authored-By: Claude Sonnet 4.6 --- src/providers/claude.ts | 16 ++++++++++++++++ src/providers/index.ts | 1 + 2 files changed, 17 insertions(+) create mode 100644 src/providers/claude.ts diff --git a/src/providers/claude.ts b/src/providers/claude.ts new file mode 100644 index 0000000..7252da8 --- /dev/null +++ b/src/providers/claude.ts @@ -0,0 +1,16 @@ +import { readEnvFile } from '../env.js'; +import { registerProviderContainerConfig } from './provider-container-registry.js'; + +registerProviderContainerConfig('claude', () => { + const dotenv = readEnvFile(['ANTHROPIC_BASE_URL', 'ANTHROPIC_AUTH_TOKEN', 'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC']); + const env: Record = {}; + if (dotenv.ANTHROPIC_BASE_URL) { + env.ANTHROPIC_BASE_URL = dotenv.ANTHROPIC_BASE_URL; + const host = new URL(dotenv.ANTHROPIC_BASE_URL).hostname; + env.NO_PROXY = host; + env.no_proxy = host; + } + if (dotenv.ANTHROPIC_AUTH_TOKEN) env.ANTHROPIC_AUTH_TOKEN = dotenv.ANTHROPIC_AUTH_TOKEN; + if (dotenv.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC) env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = dotenv.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC; + return { env }; +}); diff --git a/src/providers/index.ts b/src/providers/index.ts index 3ec9512..1a3a638 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -4,3 +4,4 @@ // needs (claude, mock) don't appear here. // // Skills add a new provider by appending one import line below. +import './claude.js';