import type { AuthInteraction } from "@bastani/pi-ai"; import type { AgentSession } from "../../core/agent-session.js"; import { AgentSessionRuntime, type CreateAgentSessionRuntimeFactory } from "../../core/agent-session-runtime.ts"; import type { ResourceOverlap } from "../../core/diagnostics.ts"; import type { WorkflowActivityFrame } from "../../core/extensions/workflow-events.js"; import type { ToolStatusReport } from "../../core/tool-status.js"; import type { RpcClient } from "../rpc/rpc-client.ts"; import type { RpcAutocompleteItem, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResourceExtension, RpcSlashCommand } from "../rpc/rpc-types.ts"; import type { ActivityWatchdogDiagnostic } from "./activity-watchdog.ts"; import type { InteractiveEngineGenerationEndedListener } from "./engine-generation.ts"; import { type EngineDiagnosticListener } from "./engine-health.ts"; import { type AtomicOAuthLoginCallbacks } from "./isolated-auth.ts"; import type { EngineKeybindingState, InteractiveEngineCommand, InteractiveEngineMessage } from "./protocol.ts"; import { type RemoteCommandsListener } from "./remote-command-catalog.ts"; type ResourceExtensionsListener = (extensions: readonly RpcResourceExtension[]) => void; /** * Owns Atomic's local interactive host facade and child-process engine. * * This runtime is deliberately not a RemoteSession adapter. Its JSONL RPC, * rendering, custom UI, and recovery lifecycle stay separate from pi-client's * protocol lease lifecycle. */ export declare class IsolatedInteractiveRuntime extends AgentSessionRuntime { private readonly client; private readonly patchedSessions; private streaming; private compacting; private compactionReason; private readonly activeBashRequestIds; private steeringMessages; private followUpMessages; /** Bumped by every authoritative queue_update. */ private queueUpdateGeneration; /** Bumped by local thinking mutations and thinking_level_changed events. */ private thinkingEpoch; /** Clears started before the next queue_update share one rollback snapshot. */ private pendingQueueClear; private engineCallbackActive; private readonly queuePause; private readonly sessionStats; private autoCompactionEnabled; private autoRetryEnabled; private remoteSessionName; private remoteSessionFile; private readonly health; private readonly remoteCommands; private disposed; private disposePromise; private readonly remoteModelCatalog; private resourceOverlaps; private readonly resourceExtensionsListeners; private resourceExtensions; private resourcesInitializedGeneration; private resourceInitialization; private readonly retiredResourceGenerations; private readonly reportedResourceFailureGenerations; private initializationTail; private engineRecoveryFailure; private promptCancellationEpoch; private hostExtensionUIReset; constructor(localRuntime: AgentSessionRuntime, createRuntime: CreateAgentSessionRuntimeFactory, client: RpcClient); get session(): AgentSession; openTaskInspector(taskId?: string): Promise; /** The engine owns extensions and tools; the host session has neither. */ getToolStatus(): Promise; initializeFromEngine(generation?: number): Promise; private settleEngineResync; private initializeFromEngineGeneration; loginOAuthProvider(provider: string, callbacks: AtomicOAuthLoginCallbacks): Promise<{ modelsRefreshed: true; }>; loginApiKeyProvider(provider: string, interaction: AuthInteraction): Promise<{ modelsRefreshed: true; }>; logoutProvider(provider: string): Promise; onDiagnostic(listener: EngineDiagnosticListener): () => void; /** Fires when fresh engine session stats arrive, so the host can repaint its footer. */ onSessionStatsChanged(listener: () => void): () => void; onEngineMessage(listener: (message: InteractiveEngineMessage) => void): () => void; /** Workflow activity of the engine child, starting from its current snapshot. */ onWorkflowActivity(listener: (frame: WorkflowActivityFrame) => void): () => void; onKeybindingState(listener: (state: EngineKeybindingState) => void): () => void; sendEngineCommand(command: InteractiveEngineCommand): void; /** Report a native host trust dialog to the extension runner in this engine generation. */ withProjectTrustPrompt(kind: "select" | "confirm" | "input", title: string, run: () => Promise): Promise; getRemoteCommands(): readonly RpcSlashCommand[]; onRemoteCommandsChanged(listener: RemoteCommandsListener): () => void; getRemoteCommandCompletions(commandName: string, argumentPrefix: string): Promise; invokeRemoteShortcut(key: string): Promise; waitUntilBound(): Promise; waitUntilProjectTrustSettled(): Promise; waitUntilResourcesReady(): Promise; private isCurrentResourceGeneration; private waitForReplacementGeneration; private throwIfUnavailable; getEnginePid(): number | undefined; getEngineGeneration(): number; isRecovering(): boolean; /** Subscribe to host-local engine generation death (see engine-generation.ts). */ onGenerationEnded(listener: InteractiveEngineGenerationEndedListener): () => void; /** * A heartbeat proves the child's event loop is turning again, so a stall the * watchdog already reported must stop arming the Ctrl+C escape hatch. Fed by a * dedicated client callback rather than a generic engine-message subscriber, * which would consume buffered startup custom-UI messages. */ noteEngineHeartbeat(): void; /** True only when the engine is provably not answering (see EngineHealthController). */ needsExplicitTermination(): boolean; /** Explicit user-driven engine termination and recovery (Ctrl+C escape hatch). */ terminateAndRecover(): Promise; getResourceOverlaps(): readonly ResourceOverlap[]; getResourceExtensions(): readonly RpcResourceExtension[]; onResourceExtensionsChanged(listener: ResourceExtensionsListener): () => void; private updateResourceExtensions; synchronize(): Promise; setEngineCallbackActive(active: boolean): void; interruptBlockedCallback(): boolean; setExtensionUIHandler(handler: (request: RpcExtensionUIRequest) => Promise): () => void; emitDiagnostic(diagnostic: ActivityWatchdogDiagnostic): void; /** * Extension UI belongs to the engine's sessions, not to this host's mirror session. The mirror is torn * down only after the engine has already switched and the new session's `session_start` has set its UI * (see `switchSession`), so a reset tied to that teardown would clear the new session's UI. The reset * therefore follows the engine's own lifecycle: `engine_extension_ui_reset` arrives on the same stream, * ahead of the new session's UI requests. Quitting still resets here, as it always has. */ setBeforeSessionInvalidate(beforeSessionInvalidate?: () => void): void; switchSession(sessionId: string, options?: Parameters[1]): Promise<{ cancelled: boolean; }>; newSession(options?: { parentSession?: string; }): Promise<{ cancelled: boolean; }>; importFromJsonl(inputPath: string, cwdOverride?: string): Promise<{ cancelled: boolean; }>; fork(entryId: string, options?: { position?: "before" | "at"; }): Promise<{ cancelled: boolean; selectedText?: string; }>; /** * The child engine already settled (and persisted) its own turn before it * reported the replacement, and the host facade's `abort()` is `abortAndRecover()` * — an unbounded cooperative round trip. Re-entering it during teardown would * hang session replacement on an unresponsive or dead engine, which is exactly * what engine recovery exists to survive. */ protected settleActiveResponseBeforeTeardown(): Promise; dispose(options?: { fromSignal?: boolean; }): Promise; private patchSession; /** * Cooperative interrupt. Requests the engine's own abort and waits for it — * no timeout, no termination, no restart. A genuinely wedged engine is the * user's call to terminate with Ctrl+C (see terminateAndRecover), never an * automatic consequence of pressing Escape. */ private abortAndRecover; private applyThinkingAck; private dispatchBestEffort; private settleQueueClear; private resetUnpersistedSessionView; private patchSessionManager; private syncPersistedModelCatalog; private refreshSessionView; private observeEvent; } export {}; //# sourceMappingURL=isolated-runtime.d.ts.map