πŸ“„ File detail

bridge/bridgeConfig.ts

🧩 .tsπŸ“ 49 linesπŸ’Ύ 1,695 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œbridge/”, which covers the bridge between the UI/shell and the agent (IPC, REPL hooks, permissions, session glue). On the API surface it exposes getBridgeTokenOverride, getBridgeBaseUrlOverride, getBridgeAccessToken, and getBridgeBaseUrl β€” mainly functions, hooks, or classes. It composes internal code from constants and utils (relative imports). What the file header says: Shared bridge auth/URL resolution. Consolidates the ant-only CLAUDE_BRIDGE_* dev overrides that were previously copy-pasted across a dozen files β€” inboundAttachments, BriefTool/upload, bridgeMain, initReplBridge, remoteBridgeCore, daemon workers, /rename, /remote-control. Two lay.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Shared bridge auth/URL resolution. Consolidates the ant-only CLAUDE_BRIDGE_* dev overrides that were previously copy-pasted across a dozen files β€” inboundAttachments, BriefTool/upload, bridgeMain, initReplBridge, remoteBridgeCore, daemon workers, /rename, /remote-control. Two layers: *Override() returns the ant-only env var (or undefined); the non-Override versions fall through to the real OAuth store/config. Callers that compose with a different auth source (e.g. daemon workers using IPC auth) use the Override getters directly.

πŸ“€ Exports (heuristic)

  • getBridgeTokenOverride
  • getBridgeBaseUrlOverride
  • getBridgeAccessToken
  • getBridgeBaseUrl

πŸ–₯️ Source preview

/**
 * Shared bridge auth/URL resolution. Consolidates the ant-only
 * CLAUDE_BRIDGE_* dev overrides that were previously copy-pasted across
 * a dozen files β€” inboundAttachments, BriefTool/upload, bridgeMain,
 * initReplBridge, remoteBridgeCore, daemon workers, /rename,
 * /remote-control.
 *
 * Two layers: *Override() returns the ant-only env var (or undefined);
 * the non-Override versions fall through to the real OAuth store/config.
 * Callers that compose with a different auth source (e.g. daemon workers
 * using IPC auth) use the Override getters directly.
 */

import { getOauthConfig } from '../constants/oauth.js'
import { getClaudeAIOAuthTokens } from '../utils/auth.js'

/** Ant-only dev override: CLAUDE_BRIDGE_OAUTH_TOKEN, else undefined. */
export function getBridgeTokenOverride(): string | undefined {
  return (
    (process.env.USER_TYPE === 'ant' &&
      process.env.CLAUDE_BRIDGE_OAUTH_TOKEN) ||
    undefined
  )
}

/** Ant-only dev override: CLAUDE_BRIDGE_BASE_URL, else undefined. */
export function getBridgeBaseUrlOverride(): string | undefined {
  return (
    (process.env.USER_TYPE === 'ant' && process.env.CLAUDE_BRIDGE_BASE_URL) ||
    undefined
  )
}

/**
 * Access token for bridge API calls: dev override first, then the OAuth
 * keychain. Undefined means "not logged in".
 */
export function getBridgeAccessToken(): string | undefined {
  return getBridgeTokenOverride() ?? getClaudeAIOAuthTokens()?.accessToken
}

/**
 * Base URL for bridge API calls: dev override first, then the production
 * OAuth config. Always returns a URL.
 */
export function getBridgeBaseUrl(): string {
  return getBridgeBaseUrlOverride() ?? getOauthConfig().BASE_API_URL
}