PtyClient
Source: src/services/pty.ts
Signature
Section titled “Signature”PtyClient(transport: Leap0Transport)Overview
Section titled “Overview”Creates and manages PTY sessions for interactive terminals.
Throws
Section titled “Throws”Leap0Error: If API calls or response validation fail.
Methods
Section titled “Methods”async list(sandbox: SandboxRef, options: RequestOptions = {}): Promise<PtySession[]>Lists PTY sessions for a sandbox.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The PTY sessions in the sandbox.
create
Section titled “create”async create(sandbox: SandboxRef, params: CreatePtySessionParams = {}, options: RequestOptions = {}): Promise<PtySession>Creates a PTY session.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.params: PTY session creation parameters.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The created PTY session.
async get(sandbox: SandboxRef, sessionId: string, options: RequestOptions = {}): Promise<PtySession>Fetches a PTY session by ID.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.sessionId: PTY session identifier.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The requested PTY session.
delete
Section titled “delete”async delete(sandbox: SandboxRef, sessionId: string, options: RequestOptions = {}): Promise<void>Deletes a PTY session.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.sessionId: PTY session identifier.options: Optional request settings such as timeout and query params.
resize
Section titled “resize”async resize(sandbox: SandboxRef, sessionId: string, cols: number, rows: number, options: RequestOptions = {}): Promise<PtySession>Resizes an existing PTY session.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.sessionId: PTY session identifier.cols: Terminal column count.rows: Terminal row count.options: Optional request settings such as timeout and query params.
Returns
Section titled “Returns”- The updated PTY session.
websocketUrl
Section titled “websocketUrl”websocketUrl(sandbox: SandboxRef, sessionId: string): stringReturns the websocket URL for a PTY session.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.sessionId: PTY session identifier.
Returns
Section titled “Returns”- The PTY websocket URL.
websocketHeaders
Section titled “websocketHeaders”websocketHeaders(): Record<string, string>Returns auth headers to use when opening the PTY websocket manually.
Returns
Section titled “Returns”- Headers required for PTY websocket authentication.
connect
Section titled “connect”connect(sandbox: SandboxRef, sessionId: string): PtyConnectionOpens a websocket connection for an existing PTY session.
Parameters
Section titled “Parameters”sandbox: Sandbox ID or sandbox-like object.sessionId: PTY session identifier.
Returns
Section titled “Returns”- The PTY websocket connection wrapper.
Throws
Section titled “Throws”Leap0WebSocketError: If subsequent websocket reads fail.
Examples
Section titled “Examples”const pty = sandbox.pty.connect("shell");pty.send("ls\n");const output = await pty.recv();