/** * Configuration constants for the OpenCode and Command Code providers. * * All URLs, env-var names, and auth-file paths live here so the catalog, * auth, and stream modules share a single source of truth. */ import { getAgentDir } from "@earendil-works/pi-coding-agent" import { join } from "node:path" // --------------------------------------------------------------------------- // OpenCode Zen (public catalog tier) // --------------------------------------------------------------------------- /** * Zen base for OpenAI / Google transports. The SDKs append their own path: * - OpenAI Responses: {base}/responses * - OpenAI Completions: {base}/chat/completions * - Google: {base}/models/{id}:generateContent */ export const ZEN_BASE = "https://opencode.ai/zen/v1" /** * Zen base for the Anthropic transport. The Anthropic SDK appends * `/v1/messages`, so the base must OMIT the trailing `/v1`. */ export const ZEN_ANTHROPIC_BASE = "https://opencode.ai/zen" /** Live model-list endpoint (Zen advertises its full catalog here). */ export const ZEN_MODELS_URL = "https://opencode.ai/zen/v1/models" // --------------------------------------------------------------------------- // OpenCode Go (static tier) // --------------------------------------------------------------------------- /** Go base for OpenAI / Google transports. */ export const GO_BASE = "https://opencode.ai/zen/go/v1" /** Go base for the Anthropic transport (Anthropic SDK appends `/v1/messages`). */ export const GO_ANTHROPIC_BASE = "https://opencode.ai/zen/go" /** Go model-list endpoint (used for the live catalog refresh). */ export const GO_MODELS_URL = "https://opencode.ai/zen/go/v1/models" // --------------------------------------------------------------------------- // Command Code // --------------------------------------------------------------------------- export const CC_BASE = "https://api.commandcode.ai" // --------------------------------------------------------------------------- // Factory Droid // --------------------------------------------------------------------------- export const FACTORY_DROID_BASE = "https://api.factory.ai" export const FACTORY_DROID_API_PREFIX = "/api/v0" // --------------------------------------------------------------------------- // Environment variable names // --------------------------------------------------------------------------- /** OpenCode API key env var (works for both Zen and Go tiers). */ export const OPENCODE_API_KEY_ENV = "OPENCODE_API_KEY" /** Command Code API key env var. */ export const COMMANDCODE_API_KEY_ENV = "COMMANDCODE_API_KEY" /** Factory Droid API key env var (keys have an `fk-` prefix). */ export const FACTORY_API_KEY_ENV = "FACTORY_API_KEY" /** * Auth-file location. pi stores provider credentials under the agent dir. * OpenCode keys may live as `{ "opencode": "" }` or * `{ "openCodeApiKey": "" }`. */ export const AUTH_FILE_PATH = join(getAgentDir(), "auth.json") /** * If a host passes the literal string "$OPENCODE_API_KEY" (or any value * starting with "$") as the resolved key, treat it as "not set" rather than * sending the placeholder upstream. */ export const ENV_LITERAL_PREFIX = "$"