Unified WebSocket channel for bidirectional communication between the harness
(local process) and agents running inside
Vercel Sandbox. Handles the WebSocket
protocol, HTTP proxy interception, agent event streaming, and tool round-trips.
This package is used internally by agent-harness-experimental. Most users do not need to
use it directly.
import type { SandboxHostedWorkspace } from "@agent-harness-experimental/sandbox-interface";import { SandboxChannel } from "@agent-harness-experimental/channel";declare const sandbox
Upload the proxy binary into the sandbox, start it, and connect via WebSocket.
AttachOptions:
Option
Type
Default
Description
wsPort
number
required
WebSocket server port on the sandbox
proxyPort
number
41007
HTTP proxy port
debug
boolean
false
Enable debug logging
skipBinaryCheck
boolean
false
Skip binary install (for snapshot boots)
signal
AbortSignal
—
Cancellation signal
onAgentEvent(handler)
Register a callback for agent events. Event types include:
text-delta — streaming text chunk
reasoning-delta — streaming reasoning chunk
tool-call — agent invoked a tool
tool-result — tool execution result
step-finish — step completed
finish — agent finished with usage stats
error — agent error
startAgent(prompt, tools, config)
Send the start command to the bridge with a prompt, tool schemas, and agent
configuration.
sendToolResult(requestId, output)
Send a tool execution result back to the agent.
sendToolDecision(requestId, approved, reason?)
Send a tool approval/denial decision back to the agent.
proxy(handler, connectHandler?, options?)
Register an HTTP proxy handler to intercept outbound HTTP traffic from the
sandbox. Returns a ProxyHandle with environment variables to pass to
sandbox.exec.