Networking and ports
Listening ports, public URLs, tunnels, local port forwards, metrics and MCP approvals.
Every method shows the same operation in each SDK; pick a language once and every tab on the site follows it.
PortClient
Section titled “PortClient”The ports listening in the sandbox, and TCP forwards to them.
list()
Section titled “list()”def list(self) -> list[ListeningPort]Returns list[ListeningPort]
sdk/python/svm/dataplane.py:168async list(): Promise<ListeningPort[]>Returns Promise<ListeningPort[]>
sdk/typescript/src/envd.ts:37func (p *PortClient) List(ctx context.Context) ([]ListeningPort, error)List returns the ports listening in the sandbox.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns ([]ListeningPort, error)
sdk/go/envd_extra.go:110def listsdk/ruby/lib/svm/envd_clients.rb:841public List<Map<String, Object>> list()Returns List<Map<String, Object>>
sdk/java/src/main/java/dev/svm/sandbox/PortClient.java:68close()
Section titled “close()”def close(self) -> None_EnvdClose the channel; a later call on this client opens a new one.
Source:sdk/python/svm/dataplane.py:42async close(): Promise<void>Close the gRPC channel; the next call opens a new one (see ProcessClient.close).
sdk/typescript/src/envd.ts:40func (p *PortClient) Close() errorClose releases the data-plane transport (see ProcessClient.Close); open tunnels end with it.
Returns error
sdk/go/envd_extra.go:107def closeEnds this client’s calls in flight; a later call opens a new connection.
Source:sdk/ruby/lib/svm/envd_clients.rb:846public void close()Releases the data-plane connections; a later call on this client opens new ones.
Source:sdk/java/src/main/java/dev/svm/sandbox/PortClient.java:66constructor()
Section titled “constructor()”Not in the Python SDK’s PortClient.
constructor(private readonly access: SandboxAccess | AccessHandle, private readonly allowInsecureHttp = false)| Parameter | Type | Default |
|---|---|---|
access |
SandboxAccess | AccessHandle |
|
allowInsecureHttp |
boolean |
false |
sdk/typescript/src/envd.ts:31Not in the Go SDK’s PortClient.
Not in the Ruby SDK’s PortClient.
Not in the Java SDK’s PortClient.
forward()
Section titled “forward()”def forward(self, port: int) -> PortTunnelOpen a TCP connection to port inside the sandbox; returns once it is open.
| Parameter | Type | Default |
|---|---|---|
port |
int |
Returns PortTunnel
sdk/python/svm/dataplane.py:172async forward(port: number): Promise<PortTunnel>| Parameter | Type | Default |
|---|---|---|
port |
number |
Returns Promise<PortTunnel>
sdk/typescript/src/envd.ts:38func (p *PortClient) Forward(ctx context.Context, port uint32) (*PortTunnel, error)Forward opens a TCP connection to port inside the sandbox and returns once it is open.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
port |
uint32 |
Returns (*PortTunnel, error)
sdk/go/envd_extra.go:132def forward(port)Opens a TCP connection to port (1..65535) inside the sandbox and returns once it is open: a SVM::Tunnel (#write, #read, #close). In this SDK the bytes travel over the sandbox’s WebSocket tunnel (Sandbox#open_tunnel), not the envd ForwardPort stream the Python, TypeScript and Go SDKs use; the meaning is the same.
The edge accepts a tunnel before it dials the guest port, so a closed port would only show at the first #read (close 1011). This method therefore asks #list first: when nothing in the sandbox listens on port it raises SVM::ProcessError with code ERROR_CODE_PORT_UNREACHABLE (gRPC status UNAVAILABLE, so rescue SVM::UnavailableError matches), as the other SDKs do. A listener that closes between the check and the open still ends the tunnel at the first #read.
| Parameter | Type | Default |
|---|---|---|
port |
Raises DataPlaneUnavailableError, ProcessError, UnavailableError
sdk/ruby/lib/svm/envd_clients.rb:831public Tunnel forward(int port)Opens a TCP connection to port (1..65535) inside the sandbox and returns once it is open. In this SDK the bytes travel over the sandbox’s WebSocket tunnel (Sandbox.openTunnel), not the envd ForwardPort stream the Python, TypeScript and Go SDKs use; the meaning is the same.
<p>The edge accepts a tunnel before it dials the guest port, so a closed port would only show at the first Tunnel.read (close 1011). This method therefore asks list() first: when nothing in the sandbox listens on port it throws a ProcessException with code ERROR_CODE_PORT_UNREACHABLE (gRPC status UNAVAILABLE), as the other SDKs do. A listener that closes between the check and the open still ends the tunnel at the first read.
| Parameter | Type | Default |
|---|---|---|
port |
int |
Returns Tunnel
Raises DataPlaneUnavailableException
sdk/java/src/main/java/dev/svm/sandbox/PortClient.java:57initialize()
Section titled “initialize()”Not in the Python SDK’s PortClient.
Not in the TypeScript SDK’s PortClient.
Not in the Go SDK’s PortClient.
def initialize(channel, tunnel: nil)tunnel opens a byte tunnel to a port (the sandbox passes its own open_tunnel).
| Parameter | Type | Default |
|---|---|---|
channel |
||
tunnel |
nil |
sdk/ruby/lib/svm/envd_clients.rb:818Not in the Java SDK’s PortClient.
ListeningPort
Section titled “ListeningPort”ListeningPort is a port something in the sandbox listens on.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
address |
str |
|
pid |
int | None |
|
port |
int |
| Property | Type | Description |
|---|---|---|
address |
string |
|
pid |
number |
|
port |
number |
| Property | Type | Description |
|---|---|---|
Address |
string |
|
PID |
uint32 |
PID is zero when the sandbox did not say which process listens. |
Port |
uint32 |
Not in the Ruby SDK.
Not in the Java SDK.
PortTunnel
Section titled “PortTunnel”A TCP connection to a port inside the sandbox over the envd port forward: send and receive move bytes.
close()
Section titled “close()”def close(self) -> Nonesdk/python/svm/dataplane.py:148close(): voidsdk/typescript/src/envd-node.ts:141func (t *PortTunnel) Close() errorClose ends the forward.
Returns error
sdk/go/envd_extra.go:193Not in the Ruby SDK.
Not in the Java SDK.
constructor()
Section titled “constructor()”Not in the Python SDK’s PortTunnel.
constructor(private readonly call: grpc.ClientDuplexStream<Wire, Wire>, private readonly messages: AsyncIterator<Wire>, private readonly secrets: string[])| Parameter | Type | Default |
|---|---|---|
call |
grpc.ClientDuplexStream<Wire, Wire> |
|
messages |
AsyncIterator<Wire> |
|
secrets |
string[] |
sdk/typescript/src/envd-node.ts:118Not in the Go SDK’s PortTunnel.
Not in the Ruby SDK.
Not in the Java SDK.
read()
Section titled “read()”Not in the Python SDK’s PortTunnel.
Not in the TypeScript SDK’s PortTunnel.
func (t *PortTunnel) Read(buffer []byte) (int, error)Read reads bytes from the port; io.EOF means the port closed.
| Parameter | Type | Default |
|---|---|---|
buffer |
[]byte |
Returns (int, error)
sdk/go/envd_extra.go:171Not in the Ruby SDK.
Not in the Java SDK.
receive()
Section titled “receive()”def receive(self) -> bytes | NoneThe next bytes from the port, or None once the forward closed.
Returns bytes \| None
sdk/python/svm/dataplane.py:133async *receive(): AsyncGenerator<Uint8Array>The bytes from the port, as they arrive, until it closes.
Returns AsyncGenerator<Uint8Array>
sdk/typescript/src/envd-node.ts:128Not in the Go SDK’s PortTunnel.
Not in the Ruby SDK.
Not in the Java SDK.
send()
Section titled “send()”def send(self, data: bytes) -> None| Parameter | Type | Default |
|---|---|---|
data |
bytes |
sdk/python/svm/dataplane.py:129send(data: Uint8Array): void| Parameter | Type | Default |
|---|---|---|
data |
Uint8Array |
sdk/typescript/src/envd-node.ts:123Not in the Go SDK’s PortTunnel.
Not in the Ruby SDK.
Not in the Java SDK.
write()
Section titled “write()”Not in the Python SDK’s PortTunnel.
Not in the TypeScript SDK’s PortTunnel.
func (t *PortTunnel) Write(data []byte) (int, error)Write sends bytes to the port.
| Parameter | Type | Default |
|---|---|---|
data |
[]byte |
Returns (int, error)
sdk/go/envd_extra.go:159Not in the Ruby SDK.
Not in the Java SDK.
Tunnel
Section titled “Tunnel”A byte stream to one port in a sandbox. send and receive move bytes; receive returns None when the port closed.
close()
Section titled “close()”def close(self) -> Nonesdk/python/svm/tunnel.py:41close(code = 1000): void| Parameter | Type | Default |
|---|---|---|
code |
number |
1000 |
sdk/typescript/src/tunnel-node.ts:105Not in the Go SDK’s Tunnel.
def closesdk/ruby/lib/svm/streams.rb:178public void close()sdk/java/src/main/java/dev/svm/sandbox/Tunnel.java:113close_code()
Section titled “close_code()”close_code: int | NoneProperty (read-only).
The WebSocket close code the sandbox ended the tunnel with, or None while it is open.
closeCode: numberProperty.
func (t *Tunnel) CloseCode() intCloseCode is the WebSocket close code the sandbox ended the tunnel with, or zero.
Returns int
sdk/go/rest_stream.go:247close_codeProperty (read-only).
public int closeCode()Returns int
sdk/java/src/main/java/dev/svm/sandbox/Tunnel.java:109close_reason()
Section titled “close_reason()”close_reason: strProperty (read-only).
Why the tunnel ended, when the sandbox said (a refused port, a lost host).
closeReason: stringProperty.
func (t *Tunnel) CloseReason() stringCloseReason is the reason the sandbox gave for ending the tunnel.
Returns string
sdk/go/rest_stream.go:250close_reasonProperty (read-only).
public String closeReason()Returns String
sdk/java/src/main/java/dev/svm/sandbox/Tunnel.java:111constructor()
Section titled “constructor()”Not in the Python SDK’s Tunnel.
constructor(private readonly socket: Duplex, leftover: Buffer)| Parameter | Type | Default |
|---|---|---|
socket |
Duplex |
|
leftover |
Buffer |
sdk/typescript/src/tunnel-node.ts:30Not in the Go SDK’s Tunnel.
Not in the Ruby SDK’s Tunnel.
Not in the Java SDK’s Tunnel.
initialize()
Section titled “initialize()”Not in the Python SDK’s Tunnel.
Not in the TypeScript SDK’s Tunnel.
Not in the Go SDK’s Tunnel.
def initialize(socket)| Parameter | Type | Default |
|---|---|---|
socket |
sdk/ruby/lib/svm/streams.rb:139Not in the Java SDK’s Tunnel.
open()
Section titled “open()”Not in the Python SDK’s Tunnel.
Not in the TypeScript SDK’s Tunnel.
Not in the Go SDK’s Tunnel.
def self.open(url, token)| Parameter | Type | Default |
|---|---|---|
url |
||
token |
Raises TransportError
sdk/ruby/lib/svm/streams.rb:111Not in the Java SDK’s Tunnel.
read()
Section titled “read()”Not in the Python SDK’s Tunnel.
Not in the TypeScript SDK’s Tunnel.
func (t *Tunnel) Read(p []byte) (int, error)| Parameter | Type | Default |
|---|---|---|
p |
[]byte |
Returns (int, error)
sdk/go/rest_stream.go:236def read(max = 64 * 1024)Up to max bytes from the tunnel; nil once the sandbox closed it (see #close_code and #close_reason).
| Parameter | Type | Default |
|---|---|---|
max |
64 * 1024 |
sdk/ruby/lib/svm/streams.rb:160public byte[] read(int max)Up to max bytes from the tunnel; null once the sandbox closed it (see closeCode() and closeReason()).
| Parameter | Type | Default |
|---|---|---|
max |
int |
Returns byte[]
Raises SandboxException
sdk/java/src/main/java/dev/svm/sandbox/Tunnel.java:90receive()
Section titled “receive()”def receive(self) -> bytes | NoneThe next bytes from the port, or None once the tunnel closed (close_code and close_reason say why).
Returns bytes \| None
sdk/python/svm/tunnel.py:27async *receive(): AsyncGenerator<Uint8Array>The bytes from the port, as they arrive, until it closes (closeReason says why when the sandbox did).
Returns AsyncGenerator<Uint8Array>
sdk/typescript/src/tunnel-node.ts:95Not in the Go SDK’s Tunnel.
Not in the Ruby SDK’s Tunnel.
Not in the Java SDK’s Tunnel.
send()
Section titled “send()”def send(self, data: bytes) -> None| Parameter | Type | Default |
|---|---|---|
data |
bytes |
sdk/python/svm/tunnel.py:24send(data: Uint8Array): void| Parameter | Type | Default |
|---|---|---|
data |
Uint8Array |
Raises TransportError
sdk/typescript/src/tunnel-node.ts:89Not in the Go SDK’s Tunnel.
Not in the Ruby SDK’s Tunnel.
Not in the Java SDK’s Tunnel.
write()
Section titled “write()”Not in the Python SDK’s Tunnel.
Not in the TypeScript SDK’s Tunnel.
Not in the Go SDK’s Tunnel.
def write(data)Sends bytes through the tunnel.
| Parameter | Type | Default |
|---|---|---|
data |
sdk/ruby/lib/svm/streams.rb:147public void write(byte[] data)Sends bytes through the tunnel.
| Parameter | Type | Default |
|---|---|---|
data |
byte[] |
Raises SandboxException, TransportException
sdk/java/src/main/java/dev/svm/sandbox/Tunnel.java:74LocalForward
Section titled “LocalForward”A running local listener. port is the local port (useful when 0 asked for any free one); close stops it.
addr()
Section titled “addr()”addr: strProperty (read-only).
host:port of the local listener.
Not in the TypeScript SDK.
func (f *LocalForward) Addr() net.AddrAddr is the local address, with the port that was bound when 0 asked for a free one.
Returns net.Addr
sdk/go/forward_local.go:22Not in the Ruby SDK.
Not in the Java SDK.
close()
Section titled “close()”def close(self) -> Nonesdk/python/svm/forward.py:96Not in the TypeScript SDK.
func (f *LocalForward) Close() errorClose stops listening and closes every open connection.
Returns error
sdk/go/forward_local.go:82Not in the Ruby SDK.
Not in the Java SDK.
url: strProperty (read-only).
Not in the TypeScript SDK.
func (f *LocalForward) URL() stringURL is the http URL of the forward.
Returns string
sdk/go/forward_local.go:25Not in the Ruby SDK.
Not in the Java SDK.
MetricsClient
Section titled “MetricsClient”The sandbox’s own CPU, memory, disk and process figures.
def get(self) -> MetricsReturns Metrics
sdk/python/svm/dataplane.py:102async get(): Promise<Metrics>Returns Promise<Metrics>
sdk/typescript/src/envd.ts:18func (m *MetricsClient) Get(ctx context.Context) (Metrics, error)Get returns one sample.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns (Metrics, error)
sdk/go/envd_extra.go:53def getsdk/ruby/lib/svm/envd_clients.rb:798public Map<String, Object> get()Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/MetricsClient.java:38close()
Section titled “close()”def close(self) -> None_EnvdClose the channel; a later call on this client opens a new one.
Source:sdk/python/svm/dataplane.py:42async close(): Promise<void>Close the gRPC channel; the next call opens a new one (see ProcessClient.close).
sdk/typescript/src/envd.ts:21func (m *MetricsClient) Close() errorClose releases the data-plane transport (see ProcessClient.Close).
Returns error
sdk/go/envd_extra.go:50def closeEnds this client’s calls in flight (a metrics stream included); a later call opens a new connection.
Source:sdk/ruby/lib/svm/envd_clients.rb:803public void close()Releases the data-plane connections; a later call on this client opens new ones.
Source:sdk/java/src/main/java/dev/svm/sandbox/MetricsClient.java:36constructor()
Section titled “constructor()”Not in the Python SDK’s MetricsClient.
constructor(private readonly access: SandboxAccess | AccessHandle, private readonly allowInsecureHttp = false)| Parameter | Type | Default |
|---|---|---|
access |
SandboxAccess | AccessHandle |
|
allowInsecureHttp |
boolean |
false |
sdk/typescript/src/envd.ts:12Not in the Go SDK’s MetricsClient.
Not in the Ruby SDK’s MetricsClient.
Not in the Java SDK’s MetricsClient.
initialize()
Section titled “initialize()”Not in the Python SDK’s MetricsClient.
Not in the TypeScript SDK’s MetricsClient.
Not in the Go SDK’s MetricsClient.
def initialize(channel)| Parameter | Type | Default |
|---|---|---|
channel |
sdk/ruby/lib/svm/envd_clients.rb:794Not in the Java SDK’s MetricsClient.
stream()
Section titled “stream()”def stream(self, interval_seconds: int=1) -> Iterator[Metrics]A sample every interval_seconds (1..3600) until the iterator is closed.
| Parameter | Type | Default |
|---|---|---|
interval_seconds |
int |
1 |
Returns Iterator[Metrics]
sdk/python/svm/dataplane.py:105async *stream(intervalSeconds = 1): AsyncGenerator<Metrics>| Parameter | Type | Default |
|---|---|---|
intervalSeconds |
number |
1 |
Returns AsyncGenerator<Metrics>
sdk/typescript/src/envd.ts:19func (m *MetricsClient) Stream(ctx context.Context, intervalSeconds uint32, handle func(Metrics) error) errorStream calls handle with a sample every intervalSeconds (1..3600) until ctx ends or handle returns an error.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
intervalSeconds |
uint32 |
|
handle |
func(Metrics) error |
Returns error
sdk/go/envd_extra.go:62def stream(interval_seconds = 1)Yields a metrics sample every interval_seconds until the block throws :stop.
| Parameter | Type | Default |
|---|---|---|
interval_seconds |
1 |
sdk/ruby/lib/svm/envd_clients.rb:809public void stream(int intervalSeconds, Predicate<Map<String, Object>> onSample)Hands a metrics sample to onSample every intervalSeconds until it returns false.
| Parameter | Type | Default |
|---|---|---|
intervalSeconds |
int |
|
onSample |
Predicate<Map<String, Object>> |
sdk/java/src/main/java/dev/svm/sandbox/MetricsClient.java:41Metrics
Section titled “Metrics”Metrics is the sandbox’s own CPU, memory, disk and process figures.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
cpu_count |
int |
|
cpu_used_percent |
float |
|
disk_total_bytes |
int |
|
disk_used_bytes |
int |
|
mem_total_bytes |
int |
|
mem_used_bytes |
int |
|
process_count |
int |
|
timestamp |
str | None |
| Property | Type | Description |
|---|---|---|
cpuCount |
number |
|
cpuUsedPercent |
number |
|
diskTotalBytes |
number |
|
diskUsedBytes |
number |
|
memTotalBytes |
number |
|
memUsedBytes |
number |
|
processCount |
number |
|
timestamp |
string |
| Property | Type | Description |
|---|---|---|
CPUCount |
uint32 |
|
CPUUsedPercent |
float64 |
|
DiskTotalBytes |
uint64 |
|
DiskUsedBytes |
uint64 |
|
MemTotalBytes |
uint64 |
|
MemUsedBytes |
uint64 |
|
ProcessCount |
uint32 |
|
Timestamp |
time.Time |
Not in the Ruby SDK.
Not in the Java SDK.
from_proto()
Section titled “from_proto()”def from_proto(cls, m: metrics_pb2.Metrics) -> 'Metrics'| Parameter | Type | Default |
|---|---|---|
m |
metrics_pb2.Metrics |
Returns 'Metrics'
sdk/python/svm/dataplane.py:90Not in the TypeScript SDK’s Metrics.
Not in the Go SDK’s Metrics.
Not in the Ruby SDK.
Not in the Java SDK.
McpApprovals
Section titled “McpApprovals”Decides tool calls the MCP gateway holds for approval and reads its audit log (INT-010). The decisions are written as root into a root-owned directory, so the agent inside the sandbox cannot approve itself.
audit()
Section titled “audit()”def audit(self, limit: int=100) -> list[dict[str, Any]]The newest audit records, oldest first: ts, server, tool, decision, reason, argument names and a hash of the arguments.
| Parameter | Type | Default |
|---|---|---|
limit |
int |
100 |
Returns list[dict[str, Any]]
sdk/python/svm/mcp_approvals.py:39async audit(limit = 100): Promise<AuditRecord[]>The newest audit records, oldest first.
| Parameter | Type | Default |
|---|---|---|
limit |
number |
100 |
Returns Promise<AuditRecord[]>
sdk/typescript/src/mcp-approvals.ts:36Not in the Go SDK.
def audit(limit = 100)The newest limit gateway decisions, oldest first.
| Parameter | Type | Default |
|---|---|---|
limit |
100 |
sdk/ruby/lib/svm/mcp_approvals.rb:27public List<Map<String, Object>> audit(int limit)The newest limit gateway decisions, oldest first.
| Parameter | Type | Default |
|---|---|---|
limit |
int |
Returns List<Map<String, Object>>
sdk/java/src/main/java/dev/svm/sandbox/McpApprovals.java:43constructor()
Section titled “constructor()”Not in the Python SDK’s McpApprovals.
constructor(private readonly sandbox: GuestSandbox)| Parameter | Type | Default |
|---|---|---|
sandbox |
GuestSandbox |
sdk/typescript/src/mcp-approvals.ts:15Not in the Go SDK.
Not in the Ruby SDK’s McpApprovals.
Not in the Java SDK’s McpApprovals.
decide()
Section titled “decide()”def decide(self, approval_id: str, allow: bool) -> NoneAllow (allow=True) or deny the held tool call approval_id.
| Parameter | Type | Default |
|---|---|---|
approval_id |
str |
|
allow |
bool |
sdk/python/svm/mcp_approvals.py:33async decide(id: string, allow: boolean): Promise<void>Allow (true) or deny (false) the held tool call id.
| Parameter | Type | Default |
|---|---|---|
id |
string |
|
allow |
boolean |
sdk/typescript/src/mcp-approvals.ts:30Not in the Go SDK.
def decide(id, allow)Allows or denies one waiting call.
| Parameter | Type | Default |
|---|---|---|
id |
||
allow |
sdk/ruby/lib/svm/mcp_approvals.rb:20public void decide(String id, boolean allow)Allows or denies one waiting call.
| Parameter | Type | Default |
|---|---|---|
id |
String |
|
allow |
boolean |
sdk/java/src/main/java/dev/svm/sandbox/McpApprovals.java:37initialize()
Section titled “initialize()”Not in the Python SDK’s McpApprovals.
Not in the TypeScript SDK’s McpApprovals.
Not in the Go SDK.
def initialize(box)| Parameter | Type | Default |
|---|---|---|
box |
sdk/ruby/lib/svm/mcp_approvals.rb:10Not in the Java SDK’s McpApprovals.
pending()
Section titled “pending()”def pending(self) -> list[dict[str, Any]]Tool calls waiting for a decision: id, server, tool and the argument names (never the values).
Returns list[dict[str, Any]]
sdk/python/svm/mcp_approvals.py:28async pending(): Promise<PendingApproval[]>Tool calls waiting for a decision: id, server, tool and the argument names (never the values).
Returns Promise<PendingApproval[]>
sdk/typescript/src/mcp-approvals.ts:24Not in the Go SDK.
def pendingThe calls waiting for a decision (never their argument values).
Source:sdk/ruby/lib/svm/mcp_approvals.rb:15public List<Map<String, Object>> pending()The calls waiting for a decision (never their argument values).
Returns List<Map<String, Object>>
sdk/java/src/main/java/dev/svm/sandbox/McpApprovals.java:32