Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.7 KB
Raw Blame
/** Shared types for the embedded-services layer (ServiceSupervisor, installers, registry). */

export interface ServiceConfig {
  tool: string;
  port: number;
  spawnArgs: () => {
    command: string;
    args: string[];
    env: NodeJS.ProcessEnv;
    cwd: string;
  };
  healthUrl: () => string;
  healthIntervalMs: number;
  stopTimeoutMs: number;
  logsBufferBytes: number;
  /**
   * When true (#6205), the supervisor probes the port + health endpoint before
   * spawning: a healthy prior instance is adopted, a held-but-unhealthy port
   * yields a clear error instead of a raw EADDRINUSE stack. Opt-in so the
   * default spawn path (and existing supervisor tests) stays byte-identical —
   * enabled for services that bind a fixed port (e.g. 9router).
   */
  probeBeforeSpawn?: boolean;
}

export type ServiceState =
  "not_installed" | "stopped" | "starting" | "running" | "stopping" | "error";

export type HealthState = "healthy" | "unhealthy" | "unknown";

export interface ServiceStatus {
  tool: string;
  state: ServiceState;
  pid: number | null;
  port: number;
  health: HealthState;
  startedAt: string | null;
  lastError: string | null;
  /**
   * True when the currently-running process was adopted from an
   * already-listening instance rather than spawned by this supervisor. An
   * adopted process has no piped stdout/stderr (the supervisor never called
   * `spawn()` for it), so the Logs panel stays empty until it's replaced by a
   * real spawn — either manually (Stop then Start) or automatically if
   * `autoRestartAdopted` is enabled for this tool.
   */
  adopted: boolean;
}

export interface LogLine {
  ts: number;
  stream: "stdout" | "stderr";
  line: string;
}