/** * Configuration constants for the Factory Droid provider. * * Factory is a session-based agent orchestration API — NOT OpenAI-compatible. * All provider behavior (base URL, env var names, poll timing, computer * auto-creation) is pinned here so the client, stream engine, and tests share * a single source of truth. * * Wire model (verified against docs.factory.ai/api-reference and the * @factory/droid-sdk REST helpers): * * POST /api/v0/sessions → create session (computerId required) * POST /api/v0/sessions/{id}/messages → fire-and-forget user message * GET /api/v0/sessions/{id} → status (idle|pending|running) + tokenUsage * GET /api/v0/sessions/{id}/messages?role=assistant → assistant content blocks * POST /api/v0/sessions/{id}/interrupt → stop a running agent loop * GET /api/v0/computers → list computers * POST /api/v0/computers → create computer (provider e2b / byom) * GET /api/v0/machines/templates → list cloud machine templates */ export const FACTORY_DROID_BASE = "https://api.factory.ai" export const FACTORY_DROID_API_PREFIX = "/api/v0" /** Session status values returned by the API. */ export const SESSION_STATUS_IDLE = "idle" export const SESSION_STATUS_PENDING = "pending" export const SESSION_STATUS_RUNNING = "running" /** Computer status values. */ export const COMPUTER_STATUS_PROVISIONING = "provisioning" export const COMPUTER_STATUS_ACTIVE = "active" export const COMPUTER_STATUS_ERROR = "error" // --------------------------------------------------------------------------- // Environment variable names // --------------------------------------------------------------------------- /** Factory API key env var (keys have an `fk-` prefix). */ export const FACTORY_API_KEY_ENV = "FACTORY_API_KEY" /** * Optional explicit computer id. When set, the provider uses this computer * instead of auto-discovering/creating one. */ export const FACTORY_COMPUTER_ID_ENV = "FACTORY_DROID_COMPUTER_ID" /** * Optional machine template id for auto-creating an e2b computer. When unset * and no reusable computer exists, the provider picks the first successfully * built cloud template. */ export const FACTORY_MACHINE_TEMPLATE_ID_ENV = "FACTORY_DROID_MACHINE_TEMPLATE_ID" /** Override for the API base URL (testing / EU deployments). */ export const FACTORY_DROID_BASE_ENV = "FACTORY_DROID_BASE" /** Default name used when auto-creating a computer. */ export const FACTORY_DROID_COMPUTER_NAME = "pi-other-provider" // --------------------------------------------------------------------------- // Poll loop timing // --------------------------------------------------------------------------- /** Poll interval while waiting for the agent loop to finish (ms). */ export const DEFAULT_POLL_INTERVAL_MS = 1_000 /** Hard cap on how long one turn may run before we give up (ms). */ export const DEFAULT_POLL_TIMEOUT_MS = 10 * 60_000 /** Computer provisioning wait timeout (ms). */ export const DEFAULT_COMPUTER_PROVISION_TIMEOUT_MS = 5 * 60_000