/** * PTY session spawning logic — extracted from PTYService for maintainability. * * Contains the deferred task delivery, retry logic, per-agent settle delays, * and session buffer setup that runs during spawnSession(). * * @module services/pty-spawn */ import type { AdapterType, BaseCodingAdapter } from "coding-agent-adapters"; import type { BunCompatiblePTYManager, PTYManager, SessionHandle, SpawnConfig, WorkerSessionHandle } from "pty-manager"; import type { PTYServiceConfig, SessionInfo, SpawnSessionOptions } from "./pty-types.js"; /** * Build a sanitized base environment from process.env, keeping only * safe system variables. Agent-specific credentials are injected * separately by the adapter's getEnv(). */ export declare function buildSanitizedBaseEnv(): Record; export interface SpawnContext { manager: PTYManager | BunCompatiblePTYManager; usingBunWorker: boolean; serviceConfig: PTYServiceConfig; sessionMetadata: Map>; sessionWorkdirs: Map; sessionOutputBuffers: Map; outputUnsubscribers: Map void>; taskResponseMarkers: Map; getAdapter: (agentType: AdapterType) => BaseCodingAdapter; sendToSession: (sessionId: string, input: string) => Promise; sendKeysToSession: (sessionId: string, keys: string | string[]) => Promise; pushDefaultRules: (sessionId: string, agentType: string) => Promise; toSessionInfo: (session: SessionHandle | WorkerSessionHandle, workdir?: string) => SessionInfo; log: (msg: string) => void; /** Mark a session's task as delivered in the coordinator. */ markTaskDelivered: (sessionId: string) => void; } /** * Set up session output buffering for Bun worker path. */ export declare function setupOutputBuffer(ctx: SpawnContext, sessionId: string): void; /** * Set up deferred task delivery with retry logic. * IMPORTANT: Must be called BEFORE pushDefaultRules (which has a 1500ms sleep), * otherwise session_ready fires during pushDefaultRules and the listener misses it. */ export declare function setupDeferredTaskDelivery(ctx: SpawnContext, session: SessionHandle | WorkerSessionHandle, task: string, agentType: string): void; /** * Build the SpawnConfig and env vars from SpawnSessionOptions. */ export declare function buildSpawnConfig(sessionId: string, options: SpawnSessionOptions, workdir: string): SpawnConfig & { id: string; }; //# sourceMappingURL=pty-spawn.d.ts.map