Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(okx-chat-bot): prefer Vertex-authenticated Claude so the reply lane needs no API key
nirholas33be46ec799e
diff --git a/workers/okx-chat-bot/config.js b/workers/okx-chat-bot/config.jsindex 41311e9a9..1a68d8779 100644--- a/workers/okx-chat-bot/config.js+++ b/workers/okx-chat-bot/config.js@@ -14,7 +14,8 @@ const num = (v, fallback) => {};/**- * Pick the AI provider the okx-a2a adapter should spawn for chat replies.+ * Pick the AI provider the okx-a2a adapter should spawn for chat replies, and+ * say which transport authenticates it.** The adapter does NOT read a reply out of the CLI's stdout, the spawned AI* subsession sends the reply itself through the `okx-a2a` CLI and drives the@@ -25,10 +26,15 @@ const num = (v, fallback) => {* to authenticate, and produces the exact symptom this worker exists to kill:* silence on the buyer's side.*- * OKX_BOT_AI_PROVIDER pin explicitly (claude | codex | hermes | openclaw)+ * OKX_BOT_AI_PROVIDER pin explicitly (claude | codex | hermes | openclaw)+ * CLAUDE_CODE_USE_VERTEX=1 → claude on Vertex AI, authenticated by the+ * runtime service account through ADC. No secret+ * exists to leak, rotate, or forget, and the spend+ * lands on the GCP credit pool the platform already+ * prefers, so this transport wins over every key.* ANTHROPIC_API_KEY /- * CLAUDE_CODE_OAUTH_TOKEN → claude- * OPENAI_API_KEY → codex+ * CLAUDE_CODE_OAUTH_TOKEN → claude on api.anthropic.com+ * OPENAI_API_KEY → codex** A headless host is credentialed by env alone, but a developer host running the* stopgap has no key at all: its claude CLI was logged in interactively and keeps@@ -37,49 +43,57 @@ const num = (v, fallback) => {* replies, which is a false red, and a false red trains people to ignore the* signal that this worker exists to raise.*+ * `credentialed` only answers "is a credential configured". Whether that+ * credential still WORKS is a different question, and on this project both+ * answers have differed: the GCP project's Vertex access and the OpenAI key are+ * each present and each refuse to serve. probeProvider() in provider.js asks the+ * provider itself, and its verdict is what readiness is judged on.+ ** @param {NodeJS.ProcessEnv} env* @param {string} [home] where the CLI keeps an interactive login- * @returns {{ provider: string, reason: string, credentialed: boolean }}+ * @returns {{ provider: string, transport: string, reason: string, credentialed: boolean }}*/export function resolveProvider(env = process.env, home = env.OKX_BOT_HOME || homedir()) {const pinned = (env.OKX_BOT_AI_PROVIDER || '').trim().toLowerCase();+ const onVertex =+ (env.CLAUDE_CODE_USE_VERTEX === '1' || env.CLAUDE_CODE_USE_VERTEX === 'true') &&+ !!(env.ANTHROPIC_VERTEX_PROJECT_ID || env.GOOGLE_CLOUD_PROJECT);const hasClaudeKey = !!(env.ANTHROPIC_API_KEY || env.CLAUDE_CODE_OAUTH_TOKEN);const hasClaudeLogin = existsSync(join(home, '.claude', '.credentials.json'));- const hasClaude = hasClaudeKey || hasClaudeLogin;- const hasCodex = !!env.OPENAI_API_KEY;+ const claude = onVertex+ ? { transport: 'vertex', reason: 'Vertex AI, authenticated by the runtime service account (no key to rotate)' }+ : hasClaudeKey+ ? { transport: 'api-key', reason: 'ANTHROPIC_API_KEY present' }+ : hasClaudeLogin+ ? { transport: 'oauth-login', reason: 'claude CLI holds an interactive login' }+ : { transport: 'none', reason: 'no Anthropic credential' };+ const codex = env.OPENAI_API_KEY+ ? { transport: 'api-key', reason: 'OPENAI_API_KEY present' }+ : { transport: 'none', reason: 'no OpenAI credential' };+if (pinned) {- const credentialed = pinned === 'claude' ? hasClaude : pinned === 'codex' ? hasCodex : true;- return { provider: pinned, reason: 'pinned by OKX_BOT_AI_PROVIDER', credentialed };+ const t = pinned === 'claude' ? claude : pinned === 'codex' ? codex : { transport: 'external', reason: 'provider supplies its own auth' };+ return {+ provider: pinned,+ transport: t.transport,+ reason: `pinned by OKX_BOT_AI_PROVIDER (${t.reason})`,+ credentialed: t.transport !== 'none',+ };+ }+ if (claude.transport !== 'none') {+ return { provider: 'claude', transport: claude.transport, reason: claude.reason, credentialed: true };}- if (hasClaudeKey) return { provider: 'claude', reason: 'ANTHROPIC_API_KEY present', credentialed: true };- if (hasClaudeLogin) {- return { provider: 'claude', reason: 'claude CLI holds an interactive login', credentialed: true };+ if (codex.transport !== 'none') {+ return { provider: 'codex', transport: codex.transport, reason: `${codex.reason} (no Anthropic credential)`, credentialed: true };}- if (hasCodex) return { provider: 'codex', reason: 'OPENAI_API_KEY present (no Anthropic key)', credentialed: true };return {provider: 'claude',+ transport: 'none',reason: 'no AI-provider credential found, chat replies will fail until one is set',credentialed: false,};}-/**- * Name the host this process is beating from, and say whether that host survives- * without a human.- *- * The heartbeat is the fleet's only view of this bot, and "online" from a- * developer codespace means something completely different from "online" on- * Cloud Run: the first dies with the workspace and takes marketplace chat with- * it. Reporting both the same way would rebuild, one level up, exactly the- * false-green this worker exists to kill.- *- * K_SERVICE set by Cloud Run, the durable posture- * OKX_BOT_HOST_LABEL name another host (a VM, a box under a desk)- * OKX_BOT_HOST_DURABLE=1 claim that host survives on its own- *- * @param {NodeJS.ProcessEnv} env- * @returns {{ label: string, durable: boolean }}- */export function resolveHost(env = process.env) {if (env.K_SERVICE) {return { label: `cloudrun:${env.K_SERVICE}${env.K_REVISION ? ` (${env.K_REVISION})` : ''}`, durable: true };@@ -115,9 +129,16 @@ export function loadConfig(env = process.env) {stateObject: env.OKX_BOT_STATE_OBJECT || 'okx-chat-bot/state.tar.gz',provider: provider.provider,+ providerTransport: provider.transport,providerReason: provider.reason,providerCredentialed: provider.credentialed,+ // How often the provider's own API is asked whether the credential still+ // works. A configured credential is not a working one: on this project the+ // GCP billing hold and the OpenAI account both answer "denied" to a key+ // that is present and well-formed. Kept slow because it is a real call.+ providerProbeMs: num(env.OKX_BOT_PROVIDER_PROBE_MS, 15 * 60_000),+// Where this process runs, and whether that place stays up on its own.// Reported on every beat so /api/healthz can tell a durable host from a// stopgap instead of calling both "online".