/** * xAI / SuperGrok constants. * Verified against grok-cli / opencode / agent-zero integrations. */ /** * Public Grok-CLI OAuth client_id (not a secret). * xAI rejects loopback OAuth from non-allowlisted clients, so third-party tools * reuse this public client + PKCE. Override with SUPERGROK_CLIENT_ID if needed. */ export const CLIENT_ID = process.env.SUPERGROK_CLIENT_ID?.trim() || "b1a00492-073a-47ea-816f-4c329264a828"; export const AUTHORIZE_URL = "https://auth.x.ai/oauth2/authorize"; export const TOKEN_URL = "https://auth.x.ai/oauth2/token"; export const DEVICE_CODE_URL = "https://auth.x.ai/oauth2/device/code"; export const DEVICE_CODE_GRANT = "urn:ietf:params:oauth:grant-type:device_code"; export const SCOPE = "openid profile email offline_access grok-cli:access api:access"; export const API_BASE = "https://api.x.ai/v1"; export const MODELS_URL = `${API_BASE}/models`; /** redirect_uri is part of the client registration — host:port must match exactly. */ export const OAUTH_HOST = "127.0.0.1"; export const OAUTH_PORT = 56121; export const OAUTH_REDIRECT_PATH = "/callback"; export const REDIRECT_URI = `http://${OAUTH_HOST}:${OAUTH_PORT}${OAUTH_REDIRECT_PATH}`; /** Refresh a bit early so a long tool call doesn't hit a mid-flight 401. */ export const REFRESH_SKEW_MS = 2 * 60 * 1000; /** Don't hang startup forever if xAI is slow / unreachable. */ export const MODELS_FETCH_TIMEOUT_MS = 8_000; export const XAI_COMPAT = { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, } as const; export const FORM_HEADERS = { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json", } as const;