/** * The closed set of login command identities. The worker maps each key to a * compile-time command. A value outside this set fails closed before the module * touches the filesystem. */ export type LoginCommandKey = "claude" | "codex" | "grok"; /** * The host-resolved launch descriptor. It carries the closed command key and the * server-controlled session home. It holds no command string. */ export interface LoginPtyLaunchDescriptor { /** The host-resolved fixed command identity. */ loginCommandKey: LoginCommandKey; /** * The server-controlled session home. The shape is exact: * `/tmp/paperclip-adapter-login/`. */ sessionHome: string; } /** The fixed non-secret error a rejected launch descriptor or session home returns. */ export declare const LOGIN_PTY_DESCRIPTOR_REJECTED = "LOGIN_PTY_DESCRIPTOR_REJECTED"; /** The fixed non-secret error a rejected session home directory returns. */ export declare const LOGIN_PTY_HOME_REJECTED = "LOGIN_PTY_HOME_REJECTED"; /** * Encodes one value as a single POSIX shell argument. It wraps the value in * single quotes and escapes each embedded single quote. The shell treats every * other character inside single quotes as a literal, so an encoded value cannot * add a second shell token or a second command. */ export declare function encodePosixShellArg(value: string): string; /** Reports whether a value is a member of the closed login command key set. */ export declare function isLoginCommandKey(value: unknown): value is LoginCommandKey; /** * Composes the launch line for the descriptor. The module reads only * {@link LOGIN_COMMAND_BY_KEY} and the closed command key on the descriptor, so * a command string smuggled onto the descriptor object confers no authority. * For the Codex key it prefixes one safely encoded `CODEX_HOME` assignment with * `env`. For the Grok key it prefixes one safely encoded `GROK_HOME` assignment * with `env`. For the Claude key it adds no home variable. It replaces the * interactive shell with the command through `exec`, so the pseudo-terminal * runs the command directly and its exit code becomes the PTY exit code. */ export declare function composeLaunchLine(descriptor: LoginPtyLaunchDescriptor): string; /** * A live pseudo-terminal session for one login command. The session allocates a * real pseudo-terminal, streams the raw terminal output, accepts delayed input, * and stops the child. The shape matches the `LoginPtySession` interface in * `@penclipai/adapter-utils`, so the transport factory there accepts a session * opener that returns this session. */ export interface LoginPtySession { /** Registers the one output listener. The session streams each raw chunk in order. */ onData(listener: (chunk: string) => void): void; /** Writes raw input bytes to the pseudo-terminal. */ write(data: string): void; /** Resolves with the child exit code when the command ends. */ wait(): Promise<{ exitCode: number | null; }>; /** 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 LoginPtySession} for `descriptor`. The transport calls it one time. */ export type LoginPtySessionOpener = (descriptor: LoginPtyLaunchDescriptor) => Promise; /** * The subset of the Daytona SDK `PtyHandle` that the session uses. The SDK * `PtyHandle` satisfies this interface, so a caller passes the real handle with * no adapter. */ export interface DaytonaPtyHandle { /** Resolves when the PTY socket connection is ready for input and output. */ waitForConnection(): Promise; /** Sends raw input bytes to the pseudo-terminal. */ sendInput(data: string | Uint8Array): Promise; /** Resolves with the exit result when the pseudo-terminal process ends. */ wait(): Promise<{ exitCode?: number; error?: string; }>; /** Kills the pseudo-terminal process. */ kill(): Promise; /** Closes the PTY socket and releases the resources. */ disconnect(): Promise; } /** * The options the session passes to `createPty`. The session sets a fixed * terminal size and one output callback. It sets the working directory when the * caller provides one. */ export interface DaytonaPtyCreateOptions { id: string; cwd?: string; cols: number; rows: number; onData: (data: Uint8Array) => void | Promise; } /** * The subset of the Daytona SDK `Process` that the session uses. The SDK * `Process` satisfies this interface, so a caller passes `sandbox.process`. */ export interface DaytonaPtyProcess { createPty(options: DaytonaPtyCreateOptions): Promise; } /** The result of one command run on the sandbox. */ export interface DaytonaExecResult { exitCode?: number; result?: string; } /** * The subset of the Daytona SDK `Process` that the filesystem helper uses. The * SDK `Process` satisfies this interface through `executeCommand`, so a caller * passes `sandbox.process`. */ export interface DaytonaSandboxExec { executeCommand(command: string, cwd?: string, env?: Record, timeout?: number): Promise; } /** * The narrow filesystem surface the session home operation needs. The production * surface runs a command on the sandbox; a unit test injects a fake. */ export interface DaytonaLoginHomeFs { /** * Creates `path` as a directory, plus a missing parent directory. It does not * fail when the directory already exists. */ createDirectory(path: string): Promise; } /** The options for the Daytona login PTY session. */ export interface DaytonaLoginPtyOptions { /** The working directory for the login PTY. Defaults to the sandbox default. */ cwd?: string; } /** * Opens a Daytona PTY session for `descriptor` and returns it as a * {@link LoginPtySession}. The function revalidates the descriptor and the home * shape, creates the session home, opens a real pseudo-terminal, composes the * safe launch line, and sends it. The session streams the raw terminal output, * delivers delayed input, and stops the child. * * The function decodes the terminal bytes as a UTF-8 stream, so a multibyte * character that splits across two output chunks stays whole. It buffers the * output until the transport registers the listener, so no early chunk is lost. */ export declare function openDaytonaLoginPtySession(process: DaytonaPtyProcess, fs: DaytonaLoginHomeFs, descriptor: LoginPtyLaunchDescriptor, options?: DaytonaLoginPtyOptions): Promise; /** * Creates a {@link DaytonaLoginHomeFs} bound to a Daytona `process`. It runs one * `mkdir -p` command on the sandbox to create the session home. The command runs * inside the sandbox, so it holds no authority over a host file and no authority * to call the Paperclip API. The real command lands against a live sandbox; a * unit test injects a fake surface instead. */ export declare function createDaytonaLoginHomeFs(exec: DaytonaSandboxExec): DaytonaLoginHomeFs; /** * Creates a {@link LoginPtySessionOpener} bound to a Daytona `process` and a * {@link DaytonaLoginHomeFs}. The opener runs the login command on a real * pseudo-terminal, streams the terminal output, delivers the delayed browser code * plus the Enter byte, and stops the child for a terminal state. */ export declare function createDaytonaLoginPtySessionOpener(process: DaytonaPtyProcess, fs: DaytonaLoginHomeFs, options?: DaytonaLoginPtyOptions): LoginPtySessionOpener; //# sourceMappingURL=login-pty.d.ts.map