import { type QuestionMode } from "../interpretation/question.js"; import type { SkillsSelection } from "../interpretation/skills-selection.js"; import type { HarnessDescriptor } from "../knowledge/descriptor.js"; import type { RunnerDeps } from "./deps.js"; import { type HarnessEvent } from "./events.js"; /** Grace after stdin EOF before concluding the child will not exit on its * own and escalating signals. */ export declare const CLOSE_GRACE_MS = 5000; export interface SessionSendResult { readonly disposition: "started" | "rejected"; /** Present when rejected. `write-failed` is a broken stdin pipe, which is * a different remedy from a session the caller already closed - the two * must stay distinguishable. */ readonly reason?: "closed" | "native-rejected" | "write-failed"; /** Resolves when a harness with command receipts accepts or rejects the input. */ readonly settled?: Promise; } /** One turn's event stream, tagged with the id of the send that opened it. * `inputId` is present for every turn a consumer send opened, which today is * every turn; a turn opened by anything else (none exists yet) omits it. */ export interface SessionTurn extends AsyncIterable { readonly inputId?: string; /** `${sessionId}:turn-${n}`, matching the runner's turn_start log. */ readonly turnId?: string; } /** A send's payload: the consumer's correlation id travels with the text * from the moment it arrives to the turn it opens and, on death, to the * loss report. */ export interface SessionInput { readonly id: string; readonly text: string; } export interface SessionHandle { /** One inner iterable per turn, each ending in a turn-scoped `done`. * Breaking out of THIS iterable closes the session; breaking out of a * single turn's iterable only stops reading that turn. */ readonly turns: AsyncIterable; send(input: SessionInput): SessionSendResult; close(): Promise; } export interface OpenSessionOptions { readonly sessionId: string; readonly model?: string; /** Working directory for the spawned harness. */ readonly cwd?: string; /** question mode for session (ask/assume/none), default "ask" */ readonly questions?: QuestionMode; /** Provider selector (pi); refused on a harness without one. */ readonly provider?: string; /** Named-agent selection (map #288); refused on a harness without a * spec, the same way a one-shot turn refuses. */ readonly agent?: string; readonly contextWindow?: number; /** Effort level for the session spawn, validated per harness/model the * way a one-shot launch validates it. Undefined means the caller made * no effort decision: the session runs at the harness's own default * effort (sessions carry no profile entry). */ readonly effort?: string; /** True when resuming an existing conversation; controls which flag * (resumeFlag vs idFlag) buildSessionArgv renders. */ readonly isResume?: boolean; /** Persistent-memory dimension (ratified 2026-08-26): the session spawn * honors it the way a one-shot launch does - false renders the * descriptor's disable (claude: CLAUDE_CODE_DISABLE_AUTO_MEMORY env var; * pi: nothing, no built-in memory). Undefined means the caller made no * memory decision; openSession adds no env overlay then. Resumed * sessions get it too - it is a spawn property, not a turn option, so * the launch-only rule never silently re-enables memory on a session. */ readonly memory?: boolean; /** The host's own version, reported to harnesses that ask at session * open (codex app-server's initialize handshake carries clientInfo). */ readonly clientVersion?: string; /** Caller-directed skills allowlist (issue #332), resolved by the CLI * against the registry root. Passed to buildSessionArgv, which renders * it through the same owner a one-shot launch uses; a harness that * cannot enforce an allowlist refuses here, before any spawn. */ readonly skills?: SkillsSelection; } export declare class SessionClosedError extends Error { constructor(); } export declare class SessionSpawnError extends Error { constructor(harness: string, cause: unknown); } export declare const openSession: (h: HarnessDescriptor, opts: OpenSessionOptions, deps: RunnerDeps) => SessionHandle; //# sourceMappingURL=open-session.d.ts.map