import type { AgentRuntime, AgentRuntimeIdentity, AgentRuntimeInterruptOutcome, AgentRuntimeStartOutcome, AgentRuntimeSubmissionInput, RuntimeAdmission } from '@excitedjs/dreamux-types'; import type { CodexRuntimeDeps } from './runtime-deps.js'; export declare class CodexRuntime implements AgentRuntime { private readonly identity; private readonly deps; private process; private client; private turnManager; private threadId; private threadResumed; private startOutcome; /** * The provider-local fatal path for authoritative state writes. Any failure * to persist — a revoked lease or a plain write failure — fences input, stops * the restart loop, and tears the app-server child down; the runtime never * keeps running against a state record it could not update. */ private readonly fence; private status; private readonly log; private stopping; private restarting; private generation; private startupTask; private stopTask; private restartAttempts; private restartTimer; private readonly state; private readonly paths; constructor(identity: AgentRuntimeIdentity, deps: CodexRuntimeDeps); /** * The host-supplied runtime id, used for this package's own paths and log * fields. Private: the live handle Core holds is `start`/`submit`/`stop`, and * a runtime answers no questions about itself. */ private get dispatcherId(); start(): Promise; private startRuntime; private startCodexRuntime; private applySkillExtraRoots; /** * Establish the native thread for this generation. * * Recovery is continuous by contract: when a prior session exists, a failed * `thread/resume` rejects rather than silently becoming a fresh thread. Only * a mid-life restart — where start has already resolved and the caller can no * longer be told — may fall back to a fresh thread, and it must publish the * loss before publishing the replacement session. */ private resolveThread; submit(input: AgentRuntimeSubmissionInput): Promise; interrupt(): Promise; stop(): Promise; /** Single-flight the stop task, releasing the slot so a failure can retry. */ private track; /** * Converge a stop that arrived after the fence already started the fatal * teardown. A teardown that succeeded left the runtime stopped; one that * failed retained the client, turn manager, and child process, so this * retries against that retained authority and rejects if the retry fails too. */ private stopAfterFatalTeardown; private stopRuntime; private cleanupOnFailure; private teardownCodexRuntime; private handleChildExit; private handleClientClose; private scheduleRestart; private restartCodexRuntime; private restartDelayMs; private clearRestartTimer; private markReady; /** * Push one authoritative fact into the leased sink. Core resolves `publish` * only after the durable write, so awaiting it is what makes the session and * ready state durable before `start` resolves. Every failure is terminal and * runs through the fence — a revoked lease means a newer generation already * owns the entity, and any other failure means Core's record of this runtime * can no longer be repaired from here. */ private publish; /** * Persist a fact the caller's own outcome does not depend on, but whose * ordering does: `stop` must not resolve before its terminal write lands, * because Core keeps this generation's lease valid exactly until stop settles * and a detached write would race the revocation that follows. * * The error is not rethrown. The fence has already made it terminal, and * these callers report something else — whether the app-server child * terminated, or the original start/restart failure — which a state-write * failure does not change. */ private settleState; /** * The fence's native teardown. Deliberately not `stop()`: `stop()` publishes * `stopping`/`stopped` through the very sink that just proved unusable and * would only produce a second failure. This closes the client, turn manager, * and child process, and nothing else. * * It runs synchronously up to its first await, so the stop fence and bumped * generation refuse new input and cancel any pending restart immediately. */ private terminateForFence; private setStatus; private assertGeneration; } //# sourceMappingURL=runtime.d.ts.map