import type { DaytonaPtyProcess } from "./login-pty.js"; export type { DaytonaPtyCreateOptions, DaytonaPtyHandle, DaytonaPtyProcess, } from "./login-pty.js"; /** * A live duplex channel session for one command. The session allocates a real * pseudo-terminal in raw mode, streams the raw output, accepts host input, and * stops the child. The shape matches the worker duplex channel session, so the * worker forwards the data and the exit with no adapter. */ export interface DuplexChannelSession { /** Registers the one data listener. The session streams each raw byte chunk in order. */ onData(listener: (chunk: Uint8Array) => void): void; /** Writes raw input bytes to the pseudo-terminal. */ write(data: Uint8Array): void; /** * Resolves when the command ends or the transport closes. A numeric `exitCode` * is a real process exit. `transportClosed` is true when the pseudo-terminal * socket closed with no exit data, so the caller can tell a real process exit * from a reason-less transport close. */ wait(): Promise<{ exitCode: number | null; transportClosed: boolean; }>; /** Stops the child process. Safe to call more than one time. */ kill(): void; /** Releases the session resources. Safe to call more than one time. */ close(): Promise; } /** * Opens a {@link DuplexChannelSession} for `command`. The transport calls it one * time. `command` is an argument vector: element 0 is the program and the rest * are its arguments. The session quotes each element, so a shell metacharacter in * an element cannot inject a shell command. */ export type DuplexChannelSessionOpener = (command: readonly string[]) => Promise; /** * The typed, closed reason for a duplex channel write failure. The seam reports * only this constant, never the raw provider error text. It maps to the host * telemetry `write_error` loss reason. */ export declare const DAYTONA_DUPLEX_WRITE_ERROR_REASON: "write_error"; /** The typed reason a rejected host-to-sandbox write reports. */ export type DaytonaDuplexWriteErrorReason = typeof DAYTONA_DUPLEX_WRITE_ERROR_REASON; /** The options for the Daytona duplex channel session. */ export interface DaytonaDuplexChannelOptions { /** The working directory for the duplex channel PTY. Defaults to the sandbox default. */ cwd?: string; /** * The absolute sandbox path for the gateway diagnostics. The wrapper redirects * the terminal's stderr to this path, so a diagnostic line never reaches the * stdout frame stream. Defaults to a per-channel path under `/tmp`. */ diagnosticsPath?: string; /** * The write-error seam. The session calls it one time when a host-to-sandbox * `sendInput` rejects. The session then ends the channel at once. The seam * carries only the typed {@link DaytonaDuplexWriteErrorReason}; the raw provider * error never reaches it. */ onWriteError?: (reason: DaytonaDuplexWriteErrorReason) => void; } /** * Builds the launch wrapper input line for the duplex channel. `command` is an * argument vector: element 0 is the program and the rest are its arguments. * * The wrapper does three steps in order: * 1. `exec 2>''` redirects the shell's stderr to the file. The * later `exec` inherits it, so the gateway diagnostics land in the file and * never on the stdout frame stream. * 2. `stty raw -echo` sets the terminal to raw mode with echo off, so the * terminal neither echoes host input as data nor translates newlines. * 3. `exec '' ''...` replaces the shell with the gateway, so the * PTY runs the gateway directly and the gateway exit code becomes the PTY * exit code. * * The wrapper quotes the diagnostics path and every command argument as a * single-quoted shell word. So a shell metacharacter in a path or an argument * stays literal text and cannot inject a shell command. */ export declare function buildDuplexChannelLaunchWrapper(command: readonly string[], diagnosticsPath: string): string; /** * Opens a Daytona duplex channel PTY session for `command` and returns it as a * {@link DuplexChannelSession}. The session allocates a real pseudo-terminal in * raw mode, streams the raw output, accepts host input, and stops the child. * * The function forwards the terminal bytes unchanged. It buffers the output * until the transport registers the listener, so no early chunk is lost. */ export declare function openDaytonaDuplexChannelSession(process: DaytonaPtyProcess, command: readonly string[], options?: DaytonaDuplexChannelOptions): Promise; /** * Creates a {@link DuplexChannelSessionOpener} bound to a Daytona `process`. Pass * `sandbox.process` from the Daytona SDK. The opener runs the gateway command on a * raw pseudo-terminal, streams the output, accepts host input, and stops the child * for a terminal state. */ export declare function createDaytonaDuplexChannelSessionOpener(process: DaytonaPtyProcess, options?: DaytonaDuplexChannelOptions): DuplexChannelSessionOpener; //# sourceMappingURL=duplex-command-stream.d.ts.map