Skip to main content
Version: 0.1.22
Last Verified: 2025-01-27
Package: @hopx-ai/sdk on npm

Overview

The Terminal resource provides interactive terminal access via WebSocket.

Methods

connect

Connect to interactive terminal.
async terminal.connect(): Promise<WebSocket>
Returns: Promise<WebSocket> - WebSocket connection

sendInput

Send input to terminal.
terminal.sendInput(ws: WebSocket, data: string): void

resize

Resize terminal.
terminal.resize(ws: WebSocket, cols: number, rows: number): void

output

Async iterator for terminal output.
async *terminal.output(ws: WebSocket): AsyncIterableIterator<TerminalMessage>
Example:
const ws = await sandbox.terminal.connect();
sandbox.terminal.sendInput(ws, "echo 'Hello'\n");

for await (const message of sandbox.terminal.output(ws)) {
    if (message.type === 'stdout') {
        console.log(message.data);
    }
}

  • Sandbox - Main sandbox class
  • Types - TypeScript type definitions

See Also

Next Steps

Now that you understand terminal access, explore: