import { C as CustomModelConfig, D as Permission, E as McpConfigEntry, S as CoderConfig, T as McpAddOptions, _ as RunnerRow, b as RunnerUpdate, c as TurnResult, d as LocalFolder, f as LocalFolders, g as RunnerPairing, h as RunnerKind, l as TaskLogEntry, m as RunnerInput, n as Availability, o as Task, p as ProbeResult, s as TaskStatus$1, t as Approval, u as TokenUsage, v as RunnerSpec, w as Effort, x as TaskTurn, y as RunnerTest } from "./types-I5Cwtl_K.js"; import { ReviewArgs, ReviewResult } from "./flow/builtin/review.js"; import { a as readTurnResults, b as FlowRecord, c as archiveRuns, d as RunSummary, f as StopSummary, i as readTask, l as deleteRuns, n as flowSdk, o as CoderError, r as TaskResult, s as RunResult$1, u as RunOptions, v as DiscoveredFlow, x as FlowStep, y as FlowEvent } from "./index-CZjFX5zV.js"; import "zod/mini"; import { Message, SerializedMessage, SerializedThread } from "chat"; import "drizzle-orm"; import "drizzle-orm/postgres-js"; import "drizzle-orm/pg-core"; import postgres from "postgres"; import "jose"; //#region src/core/engines/codex/index.d.ts declare function getCodexAvailability(cwd: string): Availability; //#endregion //#region src/core/task/actions.d.ts /** How a steer was applied to a task. */ type SteerOutcome = 'live' | 'queued' | 'resumed'; /** Filters for the task list, mirroring the CLI flags. */ interface ListOptions { running?: boolean; stopped?: boolean; archived?: boolean; /** Narrow to a workspace (matched by git root). */ dir?: string; /** Max rows; 'all' or undefined means no limit. */ limit?: number | 'all'; } //#endregion //#region src/agent/types.d.ts type Preset = 'observe' | 'comment' | 'write'; /** Per-integration wiring in a definition. `triggers` list = default behavior, map = event -> flow. */ /** Event value in a definition map: a flow name, or options. */ interface AgentEventOptions { /** Flow to run; omit for the default agent. */ flow?: string; /** Regex the event text must match (e.g. keywords on Slack `message`). */ match?: string; /** May only narrow the agent's default permission for this event. */ permissions?: Permission; /** `requester`: the task acts with the linked requester's own platform token. */ actAs?: 'requester'; } interface AgentDefinitionIntegration { triggers?: string[] | Record; /** Platform tools the agent uses: a preset or an explicit tool list. */ tools?: Preset | string[]; } /** What an agent IS: `.coder/agents//agent.json` beside its system.md. */ interface AgentDefinition { /** Display name used in replies; defaults to the id. */ name?: string; description?: string; engine?: string; runner?: string; model?: string; effort?: Effort; permissions?: Permission; /** MCP servers every task of this agent attaches, in the `.mcp.json` entry shape. */ mcp?: Record; integrations: Record; } /** Per-integration caps in usage: `allowedTools` and `allowedEvents` intersect the definition's. */ interface AgentUsageIntegration { allowedTools?: Preset | string[]; allowedEvents?: string[]; } /** How a repo RUNS an agent: one entry under `agents` in .coder/config.json. */ interface AgentUsage { engine?: string; model?: string; effort?: Effort; permissions?: Permission; integrations?: Record; } interface Agent { id: string; /** definition.name ?? id. */ name: string; definition: AgentDefinition; usage?: AgentUsage; /** Absolute folder path when the agent's body is on disk; remote agents have none. */ dir?: string; /** Stored agent body, including system.md, when there is no on-disk folder. */ files?: Record; builtin: boolean; } /** A platform event, already typed by its integration. */ interface AgentEvent { integration: string; /** Catalog name, e.g. `pull_request` or `mention`. */ type: string; /** `AgentApp.id` the webhook was addressed to. */ appId: string; installationId: string; deliveryId: string; actor: { id: string; login?: string; role?: string; agent?: boolean; }; /** Human text attached to the event: mention body, comment, PR title + body. */ text: string; /** What the platform tells an agent about where the event happened, such as a Linear issue; bounded. */ promptContext?: string; /** The Chat SDK thread and message it happened in, without raw platform payloads; replies go to this thread. */ chat?: { thread: SerializedThread; message?: SerializedMessage; }; repo?: { owner: string; name: string; cloneUrl: string; ref: string; defaultBranch: string; }; } /** Where a task came from: a Coder surface, or the id of the integration whose event started it. */ type TaskSource = 'dashboard' | 'cli' | 'schedule' | (string & {}); interface AgentTask { cwd?: string; id: string; name?: string; source: TaskSource; agent: string; /** Flow name, or `default` for the built-in single-task behavior. */ flow: string; runner: RunnerKind; /** Registered `http` runner the task routes to. */ runnerId?: string; /** Effective permission after host, usage, and event narrowing. */ permissions?: Permission; /** The platform event, or for a dashboard or CLI task on a repo, that repo through its install. */ event?: AgentEvent; /** What a dashboard or CLI task asks; the newest turn after a continue. */ prompt?: string; /** Flow arguments given directly, instead of derived from the event. */ args?: Record; /** Workspace MCP servers the task attaches, by name. */ mcp?: string[]; /** Handle the task posts as (GitHub `slug[bot]`, Slack bot user), so flows can trust only their own comments. */ author?: string; definition: AgentDefinition; /** Frozen id of the credential selected for this task. */ credential?: string; /** Wular user who asked, when known; their personal credential comes first. */ requester?: string; /** Stored agent body for runners whose checkout does not contain the agent. */ files?: Record; usage?: AgentUsage; /** Effective tools per integration the task may act on (event integration + connections). */ tools: Record; /** Frozen per-integration write targets. Missing scope means read-only tools only. */ toolScopes?: Record; /** Conversation context gathered by the receiver: recent thread messages and the stored note. */ context?: TaskContext; } interface TaskContext { outputSchema?: object; /** Most recent thread messages, oldest first. */ messages?: Array<{ user: string; text: string; ts: string; }>; /** Completed turns of this task, kept across dashboard continuations. */ turns?: TaskTurn[]; /** Rolling note the agent wrote at the end of its previous turn in this thread. */ note?: string; /** Extra instructions from the config repo (`.coder/.md`). */ instructions?: string; /** The Coder account behind the event's actor, when they connected it. */ user?: { name: string; email: string; }; } //#endregion //#region src/server/settings/logins.d.ts type LoginEngine = 'claude' | 'codex'; interface EngineLogin { owner: string; engine: LoginEngine; state: 'starting' | 'open' | 'verifying' | 'done' | 'failed'; url?: string; /** The device code Codex shows. */ code?: string; /** The code the user pasted for Claude, sealed until the runner takes it. */ input?: string; error?: string; /** The stored credential's label once signed in. */ label?: string; tokenHash: string; runner: RunnerKind; handle?: string; createdAt: number; expiresAt: number; } interface LoginView { id: string; engine: LoginEngine; state: EngineLogin['state']; expiresAt: number; url?: string; code?: string; error?: string; label?: string; } //#endregion //#region src/server/store/types.d.ts interface AgentRecord { id: string; name: string; description?: string; source: 'repo' | 'home' | 'upload' | 'builtin'; repo?: string; path?: string; currentVersion: number; settings?: AgentUsage; /** A local server's agent: read from its folder, with no version history. */ local?: true; /** The last commit of a local agent's folder. */ commit?: string; createdAt: number; updatedAt: number; } interface AgentVersionRecord { agent: string; version: number; definition: AgentDefinition; systemPrompt: string; files?: Record; commit?: string; /** Where a repository import read this version. */ source?: { repo: string; ref: string; commit: string; }; importedFrom: string; createdAt: number; } type ServerAgent = AgentRecord & { definition?: AgentVersionRecord['definition']; }; type PushResult = { id: string; version: number; unchanged: boolean; }; interface TaskOutcome { ok: boolean; exitCode: number | null; output: string; /** `git diff` of the checkout when the task ran on a repo. */ diff?: string; } type TaskState = 'queued' | 'running' | 'waiting' | 'completed' | 'failed' | 'cancelled'; /** A task's record: the queue row while it waits, the outcome afterwards. */ interface TaskStatus { task: AgentTask; status: TaskState; /** Times the worker picked it up; a runner crash earns one retry. */ attempts: number; generation?: number; inboxSeq?: number; inboxAck?: { generation: number; seq: number; }; result?: TaskOutcome; error?: string; tokens?: unknown; /** Included by admin task responses; the secret remains in the runner context only. */ credential?: string; /** Opaque runner-owned identifier. Never accepted from an HTTP caller. */ handle?: string; /** SHA-256 of the current attempt's bearer token. */ tokenHash?: string; /** Latest authenticated callback from the current attempt. */ lastSeenAt?: number; /** Persisted runner/log cursors survive a warm-process or serverless restart. */ logCursor?: number; logSeq?: number; logBytes?: number; archivedAt?: number; approval?: unknown; /** Ask-sidecar answers in arrival order. */ answer?: unknown[]; createdAt: number; startedAt?: number; finishedAt?: number; /** Set by a cancel request while the task runs; the worker stops it at the next check. */ cancelRequestedAt?: number; updatedAt: number; /** A read-only row for a task the CLI ran on this machine. */ local?: true; turns?: TaskTurn[]; fallbacks?: Task['fallbacks']; } /** One line of a task's output, streamed by the runner while it runs. */ interface TaskLogLine { seq: number; at: number; /** `out` and `err` from the runner, `sys` from the worker (retries, timeouts). */ level: 'out' | 'err' | 'sys'; line: string; entry?: TaskLogEntry; } interface EngineCredential { engine: 'claude' | 'codex' | 'custom'; env: Record; } //#endregion //#region src/server/dash/serve.d.ts declare global { var __coder: { handle(request: Request): Promise; } | undefined; } //#endregion //#region src/server/settings/credentials.d.ts interface CredentialAccount { email?: string; plan?: string; } interface CredentialSummary { label: string; engine: EngineCredential['engine']; scope: 'personal' | 'workspace'; isDefault: boolean; createdAt: number; env: string[]; /** The secret with all but its ends hidden. */ masked: string; account?: CredentialAccount; } //#endregion //#region src/server/tasks/usage.d.ts type UsageGroup = 'agent' | 'installation' | 'engine'; type UsageTotal = { key: string; tasks: number; runnerMs: number; tokens?: unknown; }; type UsageTotals = { since: number; totals: UsageTotal[] | Record; }; //#endregion //#region src/core/remote.d.ts interface ServerOptions { /** `true` for the default server (CODER_SERVER, else hosted); a URL for another. */ server?: string | true; token?: string; yes?: boolean; /** Organization slug for this call; overrides the saved choice. */ organization?: string; } interface CredentialAddOptions extends ServerOptions { engine?: string; /** The values by name, or names whose values come from `value` (`-` reads stdin), else this environment. */ env: Record | string[]; value?: string; workspace?: boolean; noCheck?: boolean; default?: boolean; } /** Add an API key or other engine environment values as a personal or workspace credential. */ declare function addCredential(label: string | undefined, options: CredentialAddOptions): Promise<{ ok: true; label: string; }>; interface CredentialLoginOptions extends ServerOptions { /** Gets a cancel for the started sign-in. */ onStart?(cancel: () => Promise): void; /** Shows the sign-in link and code once the runner has them. */ onOpen?(login: LoginView): void; /** Asks for the code Claude's sign-in page shows. */ code?(): Promise; } /** Sign in to a Claude or Codex subscription through the server's runner; resolves once it is done or failed. */ declare function loginCredential(engine: string | undefined, options?: CredentialLoginOptions): Promise; //#endregion //#region src/core/task/index.d.ts /** Where a task call runs: this machine's tasks under `cwd`, or the server named by `server`. */ type TaskOptions = { cwd?: string; } & ServerOptions; interface TaskRunOptions { /** Run as a local agent; the other options override its definition. */ agent?: string; outputSchema?: object; engine?: string; model?: string; effort?: string; permissions?: string; name?: string; system?: string; resume?: string; /** Extra directories the task may reach, resolved against cwd. */ addDirs?: string[]; /** MCP servers to attach, by name from config. */ mcp?: string; /** Block until the task finishes, walking the engine chain when a turn fails to start. */ wait?: boolean; simulateApproval?: boolean; /** Server tasks: the repository and runner to use. */ repo?: string; runner?: string; onFallback?: (fallback: { engine: string; detail: string; next: string; }) => void; onNote?: (note: string) => void; /** Each time a wait starts on a task id. */ onWaiting?: (taskId: string) => void; /** Server task log lines while waiting. */ onLog?: (line: TaskLogLine) => void; } interface RunResult { taskId: string; status: string; startupCheck?: 'passed' | 'pending'; commands?: Record<'result' | 'steer' | 'stop' | 'list', string>; finalMessage?: string | null; error?: string; tokens?: TokenUsage | null; model?: string | null; } interface TaskInspection { taskId: string; status: string; task: Task; result: ReturnType['result']; steps: TaskLogEntry[]; turns: ReturnType; pendingApprovals: Array<{ id: string; summary: string; cwd: string | null; }>; /** While running: time since the last sign of life, and whether it looks stalled. */ idleMs?: number; lastActivityAt?: string | null; stalled?: boolean; /** While running: the last progress entry and the latest token snapshot. */ lastLog?: TaskLogEntry; liveTokens?: TokenUsage | null; } interface TaskRow { taskId: string; status: Task['status'] | 'waiting-approval'; pendingApprovals: number; engine: string | null; model: string | null; effort: string | null; name: string | null; cwd: string | null; prompt: string; updatedAt: string | undefined; archived: boolean; flowRunId: string | null; idleMs: number | null; } interface TaskWatch { task: Task | TaskStatus; /** Progress entries as they land, ending when the task is terminal. */ events: AsyncGenerator; /** The task once the stream ends. */ final(): Promise<{ taskId: string; status: string; result: any; task: Task; } | TaskStatus>; } interface ApprovalRow { taskId: string; id: string; summary: string; cwd?: string | null; createdAt?: string; answered?: string | null; } //#endregion //#region src/core/hosts.d.ts /** Result of a plugin install/refresh attempt. */ interface PluginResult { marketplace: string; installed: boolean; note: string; } /** Outcome of the codex auto-update check; null when nothing to do. */ type CodexUpdateResult = { updated: true; from: string; } | { updated: false; from: string; note: string; } | null; /** Outcome of an on-demand codex install; null when codex was already present. */ type CodexInstallResult = { installed: boolean; note: string; } | null; declare function ensureCodexInstalled(availability: Availability): CodexInstallResult; declare function ensureCodexUpToDate(availability: Availability): CodexUpdateResult; interface SetupHostReport { codex: { available: boolean; detail: string; auth: string; loggedIn: boolean; }; codexUpdate?: ReturnType; claude: { available: boolean; detail: string; auth: string; loggedIn: boolean; }; configFile: string; runtime: string; claudePlugin?: PluginResult; agentsSkill?: PluginResult; config: CoderConfig; ready: boolean; } interface UpgradeReport { cli?: { pm: string; from: string | null; to: string | null; changed: boolean; }; claudePlugin?: { installed: boolean; note: string; from: string | null; to: string | null; }; agentsSkill?: { installed: boolean; note: string; from: string | null; to: string | null; }; } //#endregion //#region src/core/models.d.ts interface PersistedModel { name: string; entry: CustomModelConfig; file: string; probe: ProbeResult; codex: ReturnType; install: ReturnType; nativeResponses: boolean; keyMissing: boolean; ready: boolean; } interface ModelWriteOptions { baseUrl?: string; model?: string; envKey?: string; workspace?: boolean; } //#endregion //#region src/client/auth/session.d.ts interface Session { /** Wular Auth access token for this server. */ token: string; refreshToken: string; /** When `token` expires, epoch milliseconds. */ expiresAt: number; /** The Wular Auth issuer that signed the tokens. */ issuer: string; user: { name: string; email: string; }; organization?: { id: string; name: string; slug: string; }; at: number; } //#endregion //#region src/client/auth/sign-in.d.ts type LoginOrganization = NonNullable; interface SignInOptions { device?: boolean; open?: (url: string) => void; onCode?: (code: string, url: string) => void; organization?: string; chooseOrganization?: (organizations: LoginOrganization[]) => Promise; } //#endregion //#region src/agent/exec.d.ts interface ExecResult { ok: boolean; flow: string; /** Default flow: the engine's answer, posted to the platform unless `post` was false. */ reply?: string; note?: string; posted?: boolean; taskId?: string; runId?: string; result?: unknown; tokens?: unknown; } //#endregion //#region src/agent/index.d.ts /** Where an agent call runs: this repo's agents under `cwd`, or the server named by `server`. */ type AgentOptions = { cwd?: string; } & ServerOptions; /** What an interactive `agent init` picked; flags fill these otherwise. */ interface AgentPicks { name?: string; integrations: string[]; events: Record; matches: Record>; tools: Preset; } interface AgentInitOptions { cwd?: string; name?: string; description?: string; permissions?: AgentDefinition['permissions']; integrations?: string | string[]; triggers?: string | string[]; tools?: string; /** `event=regex` pairs. */ match?: string | string[]; /** Asks for the id when none is given. */ askId?: (validate: (id: string) => string | undefined) => Promise; /** Asks for the picks instead of reading them from the options. */ askPicks?: (id: string) => Promise; } //#endregion //#region src/runner/serve.d.ts interface RunnerServeOptions extends ServerOptions { port?: number; /** The public URL a tunnel gives the local port. */ url?: string; name?: string; workspace?: boolean; runnerUrl?: string; } type RunnerServeResult = RunnerRow & { port: number; server: string; /** Mark the runner offline on the server and stop listening. */ close(): Promise; }; /** Serve a server's tasks from this machine; the runner keeps its id and secret per server across restarts. */ declare function serveRunner(options?: RunnerServeOptions): Promise; //#endregion //#region src/server/agents/apps.d.ts interface ServerAppOptions { /** Where the app lives, such as a GitHub organization; the operator's own account when absent. */ owner?: string; name?: string; env?: Record; } /** The one-time page that creates the built-in agent's public app on `integration`, stored for the whole server. */ declare function serverAppLink(integration: string, options?: ServerAppOptions): Promise<{ url: string; }>; //#endregion //#region src/server/maintenance.d.ts interface MaintenanceOptions { env?: Record; } /** Apply pending server migrations and return how many were applied. */ declare function migrate(options?: MaintenanceOptions): Promise<{ applied: number; }>; /** Re-seal every stored secret with the current encryption key. */ declare function rotateKey(options?: MaintenanceOptions): Promise<{ moved: number; }>; //#endregion //#region src/core/cache.d.ts interface CacheMigration { cache: string; tasks: number; flows: number; files: number; } //#endregion //#region src/server/routes/guards.d.ts type ServerMode = 'local' | 'memory' | 'cloud'; //#endregion //#region src/server/serve.d.ts /** Serverless request handler with a lazily initialized, reused backend. */ declare function serverHandler(env?: Record, host?: 'node' | 'vercel'): { (request: Request, waitUntil?: (work: Promise) => void): Promise; scheduled(): Promise; close(): Promise; }; interface ServeOptions { cwd?: string; env?: Record; port?: number; /** Interface to listen on: 127.0.0.1 by default without a database, else every interface. */ host?: string; /** A throwaway test server that keeps everything in memory. */ memory?: boolean; runner?: RunnerKind; } interface ServeResult { address: string; publicUrl: string; warnings: string[]; close(): Promise; } type ServeDetails = ServeResult & { runner: RunnerKind; store: 'memory' | 'postgres'; mode: ServerMode; cacheMigration?: Promise; maxTasks: number; signIn?: string; mintedToken?: string; /** Where DATABASE_URL points. */ database?: string; /** The dashboard link, with the memory server's token, when the server is on this machine. */ dashboard?: string; }; declare function serve(options?: ServeOptions): Promise; //#endregion //#region src/sdk.d.ts /** Run and control coder tasks. Mirrors `coder task`. */ declare const task: { run: (prompt: string, opts?: TaskRunOptions & TaskOptions) => Promise; result: (id?: string, opts?: TaskOptions & { wait?: boolean; tail?: number | "all"; onWaiting?: (taskId: string) => void; }) => Promise; list: (opts?: TaskOptions & ListOptions) => Promise<(TaskRow[] & { clipped: number; archived: number; }) | TaskStatus[]>; watch: (id?: string, opts?: TaskOptions & { tail?: number | "all"; }) => Promise; stream: (id?: string, opts?: TaskOptions & { tail?: number | "all"; }) => AsyncGenerator; steer: (id: string, text: string, opts?: TaskOptions & { model?: string; effort?: string; permissions?: string; wait?: boolean; }) => Promise | { taskId: string; steered: SteerOutcome; } | { status: TaskStatus$1 | null; finalMessage: any; taskId: string; steered: SteerOutcome; }>; ask: (id: string, question: string, opts?: TaskOptions & { model?: string; effort?: string; onAsking?: (taskId: string) => void; }) => Promise>; approvals: (id?: string, opts?: TaskOptions) => Promise[]>; approve: (reference: string | undefined, approvalId?: string, opts?: TaskOptions & { deny?: boolean; }) => Promise; stop: (id?: string, opts?: TaskOptions) => Promise<{ ok: true; } | { taskId: string; status: "cancelled"; interrupt: string; }>; archive: (id?: string, opts?: TaskOptions & { allStopped?: boolean; }) => Promise<{ archived: string[]; count: number; taskId?: undefined; } | { taskId: string; archived: true; count?: undefined; }>; delete: (id?: string, opts?: TaskOptions & { allArchived?: boolean; }) => Promise<{ deleted: string[]; count: number; taskId?: undefined; } | { taskId: string; deleted: true; count?: undefined; }>; }; /** Manage models: custom endpoints, engine aliases, disable toggles. Mirrors `coder model`. */ declare const model: { /** Register a custom OpenAI-compatible endpoint model. */ add: (name: string, opts: ModelWriteOptions & { cwd?: string; }) => Promise; /** Update fields of a configured model entry. */ update: (name: string, opts: ModelWriteOptions & { cwd?: string; }) => Promise; /** Remove a configured model entry. */ remove: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { removed: string; file: string; }; /** Every dispatchable model: built-ins, aliases, custom endpoints. */ list: (opts?: { cwd?: string; }) => Promise<{ toggles?: { name: string; disabled: boolean; }[] | undefined; codex: ({ alias: string; model: string; builtin: boolean; disabled: boolean; spec?: undefined; overrides?: undefined; } | { alias: string; spec: string; disabled: boolean; })[]; claude: ({ alias: string; model: string; builtin: boolean; disabled: boolean; spec?: undefined; overrides?: undefined; } | { alias: string; spec: string; disabled: boolean; })[]; custom: { probe: ProbeResult; baseUrl: string; model: string; envKey?: string | undefined; wireApi?: "chat" | "responses" | undefined; disabled?: boolean | undefined; name: string; }[]; }>; /** Alias a name to an engine spec, e.g. alias('fast', 'codex:luna'). */ alias: (name: string, spec: string, opts?: { workspace?: boolean; cwd?: string; }) => { provider: "codex" | "claude"; model: string; effort?: "low" | "medium" | "high" | undefined; disabled?: boolean | undefined; } & { alias: string; file: string; }; /** Remove a user-defined alias. */ unalias: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { unaliased: string; file: string; }; /** Disable a model name (built-in, alias, or raw slug) without removing it. */ disable: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { name: string; disabled: boolean; file: string; }; /** Re-enable a disabled model name. */ enable: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { name: string; disabled: boolean; file: string; }; }; /** Read and write coder configuration. Mirrors `coder config`. */ declare const config: { /** A config value by dotted key (or the whole effective config). */ get: (key?: string, opts?: { cwd?: string; }) => unknown; /** Set a config value; `workspace` targets the repo file instead of the user file. */ set: (key: string, value: unknown, opts?: { workspace?: boolean; cwd?: string; }) => { file: string; key: string; effective: unknown; value?: unknown; unset?: boolean; }; }; /** Configure MCP servers in `.coder/config.json`, or the user file with `user`. Mirrors `coder mcp`. */ declare const mcp: { /** Save a stdio (`command`) or remote (`url`) server; `env`, `header` and `tools` are comma lists. */ add: (name: string, opts: McpAddOptions & { cwd?: string; }) => { name: string; file: string; }; /** Save an entry from any `.mcp.json`, as an object or JSON text. */ addJson: (name: string, entry: string | Record, opts?: { user?: boolean; cwd?: string; }) => { name: string; file: string; }; /** The configured servers by name. */ list: (opts?: { cwd?: string; }) => Record | undefined; url?: string | undefined; type?: "stdio" | "http" | "sse" | undefined; headers?: Record | undefined; tools?: string[] | undefined; description?: string | undefined; }>; /** Remove a server. */ remove: (name: string, opts?: { user?: boolean; cwd?: string; }) => { name: string; file: string; }; }; /** Probe engines, seed the chain, install requested host plugins. */ declare function setupHost(hosts?: string[], opts?: { cwd?: string; }): Promise; /** Update the CLI and/or host plugin installs; returns what moved. */ declare function upgrade(opts?: { cliOnly?: boolean; pluginsOnly?: boolean; }): Promise; /** List bundled docs, or return one topic's raw markdown; `claude` picks the Claude Code flavor of the skill. */ declare function docs(topic?: string, opts?: { claude?: boolean; }): { topics: { name: string; description: string; }[]; } | { name: string; content: string; }; /** Run the built-in read-only code-review flow. */ declare const review: { run(options?: ReviewArgs): Promise; }; /** Sign in and manage saved sessions. Mirrors `coder auth`. */ declare const auth: { login(options?: SignInOptions & { server?: string | true; yes?: boolean; save?: boolean; }): Promise; logout: (options?: { server?: string | true; yes?: boolean; }) => Promise<{ ok: true; server: string; }>; status: () => { [k: string]: { user: { name: string; email: string; }; organization: { id: string; name: string; slug: string; } | undefined; at: number; }; }; }; /** Run and host a Coder server. Mirrors `coder server`. */ declare const server: { serve: typeof serve; migrate: typeof migrate; rotateKey: typeof rotateKey; /** The GitHub Actions workflow the `github-actions` runner dispatches. */ workflow: () => string; app: { /** A link, valid 10 minutes, to the page that creates the built-in agent's public app on a platform. */ create: typeof serverAppLink; }; handler: typeof serverHandler; }; /** Engine credentials on a Coder server. Mirrors `coder credentials`. */ declare const credentials: { list: (options?: ServerOptions) => Promise; add: typeof addCredential; remove: (label: string, options?: ServerOptions & { workspace?: boolean; }) => Promise<{ ok: true; }>; default: (label: string, options?: ServerOptions & { workspace?: boolean; }) => Promise<{ ok: true; }>; login: typeof loginCredential; }; declare const folders: { list: (options?: ServerOptions) => Promise; check: (path: string, options?: ServerOptions) => Promise<{ ok: true; folder: LocalFolder; } | { ok: false; detail: string; }>; }; /** Your own runners for a Coder server. Mirrors `coder runner`. */ declare const runner: { list: (options?: ServerOptions) => Promise<{ items: RunnerRow[]; catalog: RunnerSpec[]; }>; add: (input: RunnerInput, options?: ServerOptions) => Promise; pair: (input: { name?: string; scope: RunnerInput["scope"]; }, options?: ServerOptions) => Promise; update: (id: string, input: RunnerUpdate, options?: ServerOptions) => Promise; default: (id: string, options?: ServerOptions) => Promise; test: (id: string, options?: ServerOptions) => Promise; rename: (id: string, name: string, options?: ServerOptions) => Promise; remove: (id: string, options?: ServerOptions) => Promise<{ ok: true; }>; serve: typeof serveRunner; }; /** Manage and run agents. Each function mirrors one `coder agent` command. */ declare const agent: { list: (opts?: AgentOptions) => Promise; show(id: string | undefined, opts?: AgentOptions): Promise>; }>; init: (id: string | undefined, opts?: AgentInitOptions) => Promise<{ id: string; dir: string; files: string[]; samples: string[]; integrations: string[]; }>; push: (id?: string, opts?: AgentOptions) => Promise; run(name: string | undefined, event: AgentEvent | string | undefined, opts?: AgentOptions & { flow?: string; wait?: boolean; onLog?: (line: TaskLogLine) => void; onDone?: (status: TaskStatus) => void; }): Promise; runTask(id: string, opts?: { cwd?: string; }): Promise; usage(opts?: AgentOptions & { since?: number | string; by?: string; }): Promise; integrations: { list: () => { id: string; description: string; events: string[]; tools: string[]; }[]; show(id: string | undefined): { id: string; events: { [k: string]: string; }; tools: Record; }; }; }; declare const _default: { task: { run: (prompt: string, opts?: TaskRunOptions & TaskOptions) => Promise; result: (id?: string, opts?: TaskOptions & { wait?: boolean; tail?: number | "all"; onWaiting?: (taskId: string) => void; }) => Promise; list: (opts?: TaskOptions & ListOptions) => Promise<(TaskRow[] & { clipped: number; archived: number; }) | TaskStatus[]>; watch: (id?: string, opts?: TaskOptions & { tail?: number | "all"; }) => Promise; stream: (id?: string, opts?: TaskOptions & { tail?: number | "all"; }) => AsyncGenerator; steer: (id: string, text: string, opts?: TaskOptions & { model?: string; effort?: string; permissions?: string; wait?: boolean; }) => Promise | { taskId: string; steered: SteerOutcome; } | { status: TaskStatus$1 | null; finalMessage: any; taskId: string; steered: SteerOutcome; }>; ask: (id: string, question: string, opts?: TaskOptions & { model?: string; effort?: string; onAsking?: (taskId: string) => void; }) => Promise>; approvals: (id?: string, opts?: TaskOptions) => Promise[]>; approve: (reference: string | undefined, approvalId?: string, opts?: TaskOptions & { deny?: boolean; }) => Promise; stop: (id?: string, opts?: TaskOptions) => Promise<{ ok: true; } | { taskId: string; status: "cancelled"; interrupt: string; }>; archive: (id?: string, opts?: TaskOptions & { allStopped?: boolean; }) => Promise<{ archived: string[]; count: number; taskId?: undefined; } | { taskId: string; archived: true; count?: undefined; }>; delete: (id?: string, opts?: TaskOptions & { allArchived?: boolean; }) => Promise<{ deleted: string[]; count: number; taskId?: undefined; } | { taskId: string; deleted: true; count?: undefined; }>; }; flow: { run(nameOrPath: string, opts?: RunOptions): Promise; list(opts?: { archived?: boolean; limit?: number | "all"; }): FlowRecord[]; discover(cwd?: string): DiscoveredFlow[]; result(runId?: string, opts?: { tail?: number | "all"; }): RunResult$1 | null; stream(runId?: string, opts?: { tail?: number | "all"; }): AsyncGenerator; stop(runId?: string, opts?: { keepTasks?: boolean; }): Promise; resume(runId?: string, opts?: RunOptions): Promise; archive: typeof archiveRuns; delete: typeof deleteRuns; }; model: { /** Register a custom OpenAI-compatible endpoint model. */ add: (name: string, opts: ModelWriteOptions & { cwd?: string; }) => Promise; /** Update fields of a configured model entry. */ update: (name: string, opts: ModelWriteOptions & { cwd?: string; }) => Promise; /** Remove a configured model entry. */ remove: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { removed: string; file: string; }; /** Every dispatchable model: built-ins, aliases, custom endpoints. */ list: (opts?: { cwd?: string; }) => Promise<{ toggles?: { name: string; disabled: boolean; }[] | undefined; codex: ({ alias: string; model: string; builtin: boolean; disabled: boolean; spec?: undefined; overrides?: undefined; } | { alias: string; spec: string; disabled: boolean; })[]; claude: ({ alias: string; model: string; builtin: boolean; disabled: boolean; spec?: undefined; overrides?: undefined; } | { alias: string; spec: string; disabled: boolean; })[]; custom: { probe: ProbeResult; baseUrl: string; model: string; envKey?: string | undefined; wireApi?: "chat" | "responses" | undefined; disabled?: boolean | undefined; name: string; }[]; }>; /** Alias a name to an engine spec, e.g. alias('fast', 'codex:luna'). */ alias: (name: string, spec: string, opts?: { workspace?: boolean; cwd?: string; }) => { provider: "codex" | "claude"; model: string; effort?: "low" | "medium" | "high" | undefined; disabled?: boolean | undefined; } & { alias: string; file: string; }; /** Remove a user-defined alias. */ unalias: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { unaliased: string; file: string; }; /** Disable a model name (built-in, alias, or raw slug) without removing it. */ disable: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { name: string; disabled: boolean; file: string; }; /** Re-enable a disabled model name. */ enable: (name: string, opts?: { workspace?: boolean; cwd?: string; }) => { name: string; disabled: boolean; file: string; }; }; config: { /** A config value by dotted key (or the whole effective config). */ get: (key?: string, opts?: { cwd?: string; }) => unknown; /** Set a config value; `workspace` targets the repo file instead of the user file. */ set: (key: string, value: unknown, opts?: { workspace?: boolean; cwd?: string; }) => { file: string; key: string; effective: unknown; value?: unknown; unset?: boolean; }; }; mcp: { /** Save a stdio (`command`) or remote (`url`) server; `env`, `header` and `tools` are comma lists. */ add: (name: string, opts: McpAddOptions & { cwd?: string; }) => { name: string; file: string; }; /** Save an entry from any `.mcp.json`, as an object or JSON text. */ addJson: (name: string, entry: string | Record, opts?: { user?: boolean; cwd?: string; }) => { name: string; file: string; }; /** The configured servers by name. */ list: (opts?: { cwd?: string; }) => Record | undefined; url?: string | undefined; type?: "stdio" | "http" | "sse" | undefined; headers?: Record | undefined; tools?: string[] | undefined; description?: string | undefined; }>; /** Remove a server. */ remove: (name: string, opts?: { user?: boolean; cwd?: string; }) => { name: string; file: string; }; }; setupHost: typeof setupHost; upgrade: typeof upgrade; docs: typeof docs; review: { run(options?: ReviewArgs): Promise; }; auth: { login(options?: SignInOptions & { server?: string | true; yes?: boolean; save?: boolean; }): Promise; logout: (options?: { server?: string | true; yes?: boolean; }) => Promise<{ ok: true; server: string; }>; status: () => { [k: string]: { user: { name: string; email: string; }; organization: { id: string; name: string; slug: string; } | undefined; at: number; }; }; }; agent: { list: (opts?: AgentOptions) => Promise; show(id: string | undefined, opts?: AgentOptions): Promise>; }>; init: (id: string | undefined, opts?: AgentInitOptions) => Promise<{ id: string; dir: string; files: string[]; samples: string[]; integrations: string[]; }>; push: (id?: string, opts?: AgentOptions) => Promise; run(name: string | undefined, event: AgentEvent | string | undefined, opts?: AgentOptions & { flow?: string; wait?: boolean; onLog?: (line: TaskLogLine) => void; onDone?: (status: TaskStatus) => void; }): Promise; runTask(id: string, opts?: { cwd?: string; }): Promise; usage(opts?: AgentOptions & { since?: number | string; by?: string; }): Promise; integrations: { list: () => { id: string; description: string; events: string[]; tools: string[]; }[]; show(id: string | undefined): { id: string; events: { [k: string]: string; }; tools: Record; }; }; }; credentials: { list: (options?: ServerOptions) => Promise; add: typeof addCredential; remove: (label: string, options?: ServerOptions & { workspace?: boolean; }) => Promise<{ ok: true; }>; default: (label: string, options?: ServerOptions & { workspace?: boolean; }) => Promise<{ ok: true; }>; login: typeof loginCredential; }; folders: { list: (options?: ServerOptions) => Promise; check: (path: string, options?: ServerOptions) => Promise<{ ok: true; folder: LocalFolder; } | { ok: false; detail: string; }>; }; runner: { list: (options?: ServerOptions) => Promise<{ items: RunnerRow[]; catalog: RunnerSpec[]; }>; add: (input: RunnerInput, options?: ServerOptions) => Promise; pair: (input: { name?: string; scope: RunnerInput["scope"]; }, options?: ServerOptions) => Promise; update: (id: string, input: RunnerUpdate, options?: ServerOptions) => Promise; default: (id: string, options?: ServerOptions) => Promise; test: (id: string, options?: ServerOptions) => Promise; rename: (id: string, name: string, options?: ServerOptions) => Promise; remove: (id: string, options?: ServerOptions) => Promise<{ ok: true; }>; serve: typeof serveRunner; }; server: { serve: typeof serve; migrate: typeof migrate; rotateKey: typeof rotateKey; /** The GitHub Actions workflow the `github-actions` runner dispatches. */ workflow: () => string; app: { /** A link, valid 10 minutes, to the page that creates the built-in agent's public app on a platform. */ create: typeof serverAppLink; }; handler: typeof serverHandler; }; }; //#endregion export { type Approval, CoderError, type FlowEvent, type FlowStep, type LocalFolder, type LocalFolders, type ReviewArgs, type ReviewResult, type RunnerInput, type RunnerKind, type RunnerPairing, type RunnerRow, type RunnerSpec, type RunnerTest, type RunnerUpdate, type ServerOptions, type Session, type SteerOutcome, type Task, type TaskLogEntry, type TaskResult, type TaskRunOptions, type TurnResult, agent, auth, config, credentials, _default as default, docs, flowSdk as flow, folders, mcp, model, review, runner, server, setupHost, task, upgrade };