Reference
ComputeSDK reference
Use the provider, typed API client, and session client from TypeScript.
On this page
Use the ComputeSDK provider
Run portable ComputeSDK code against Zeish.
Call zeish with apiKey, baseUrl, and optional defaultTemplateId. The provider implements sandbox create, list, get, destroy, runCommand, getInfo, getUrl, filesystem operations, and snapshot creation.
The standard provider uses cwd, timeout, env, and background in command options. It intentionally does not expose standard snapshot list and delete because Zeish snapshots are sandbox-scoped.
1import { zeish } from "@zeish/computesdk-provider";23const compute = zeish({4 apiKey: process.env.ZEISH_API_KEY!,5 baseUrl: "https://api.zei.sh/api/v1",6 defaultTemplateId: process.env.ZEISH_TEMPLATE_ID!,7});Use the typed API client
Call the public control plane from TypeScript.
createZeishApi exposes typed methods for resources, sandboxes, lifecycle, access, ingress, logs, events, snapshots, and secrets.
Pass the production baseUrl explicitly. The API client handles X-API-Key authentication and typed ZeishApiError responses.
1import { createZeishApi } from "@zeish/computesdk-provider";23const api = createZeishApi({4 apiKey: process.env.ZEISH_API_KEY!,5 baseUrl: "https://api.zei.sh/api/v1",6});78const page = await api.listSandboxes({ limit: 20 });Use the Zeish session client
Use one agent-friendly object for control and data-plane work.
createZeishSandboxClient returns sessions with waitForAccess, credential refresh, commands, files, desktop actions, lifecycle, logs, events, previews, ports, terminal URLs, and sandbox-scoped snapshots.
The session client uses workingDirectory, timeoutMs, and environment. It is the easiest path for a long-running agent workflow.
1import { createZeishSandboxClient } from "@zeish/computesdk-provider";23const client = createZeishSandboxClient({4 apiKey: process.env.ZEISH_API_KEY!,5 baseUrl: "https://api.zei.sh/api/v1",6 defaultTemplateId: process.env.ZEISH_TEMPLATE_ID!,7});89const sandbox = await client.create({ name: "agent-run" });10await sandbox.waitForAccess();Create and wait for a sandbox
Use the retrying lifecycle helper for agent startup.
createAndStartSandbox creates a sandbox, waits for running, destroys a failed attempt, and retries. Its defaults are three attempts, a 90 second ready timeout, and a two second poll interval.
A normal create request already asks for a running runtime. Use the helper when startup reliability matters.
1import { createAndStartSandbox } from "@zeish/computesdk-provider";23const sandbox = await createAndStartSandbox(api, {4 name: "agent-run",5 templateId: process.env.ZEISH_TEMPLATE_ID!,6 maxAttempts: 3,7 readyTimeoutMs: _000,8});Run commands with the SDK
Stream command output through the sandbox data plane.
The provider uses sandboxd gRPC ExecStream. Pass cwd, timeout, env, and background using standard ComputeSDK names. The session client maps these to workingDirectory, timeoutMs, and environment.
Treat stdout, stderr, and exit codes as untrusted workload data.
1const result = await compute.sandbox.runCommand(sandbox, "python agent.py", {2 cwd: "/workspace",3 timeout: _000,4 env: { RUN_ID: runId },5});6console.log(result.stdout, result.exitCode);Use SDK filesystem operations
Read and write files inside the sandbox root.
The provider maps readFile, writeFile, mkdir, readdir, exists, and remove to sandboxd. The session client adds readText, writeText, makeDirectory, listDirectory, stat, exists, and remove.
Paths are checked for traversal and symlink escapes. Use a volume or snapshot for data that must outlive the sandbox.
1await sandbox.files.makeDirectory("/workspace/results");2await sandbox.files.writeText("/workspace/results/status.json", JSON.stringify({ ok: true }));3const status = await sandbox.files.readText("/workspace/results/status.json");Create and resolve preview access
Use temporary HTTP access for browser and agent clients.
createPreviewCode returns browser and agent access forms. fetchPreviewJsonVersion uses baseUrl with the bearer code. resolveCdpEndpoint converts Chrome's loopback WebSocket URL into a preview endpoint.
1const preview = await api.createPreviewCode(sandboxId, { port: 9222, ttl_seconds: 3600 });2const version = await fetchPreviewJsonVersion(preview);3const endpoint = resolveCdpEndpoint({ preview, webSocketDebuggerUrl: String(version.webSocketDebuggerUrl) });Bridge a TCP tunnel
Connect local clients to exposed sandbox TCP ports.
createTunnelBridge and createCdpTunnelBridge bind to loopback only. Close the bridge when the operation ends and treat the local port as an active capability while it is open.
1const access = await api.createTunnelAccess(sandboxId, { ttl_seconds: 60 });2const bridge = await createTunnelBridge(access, 5432);3console.log(bridge.localPort);4await bridge.close();Control a desktop session
Use screenshots and native Wayland input for GUI agents.
Desktop actions are available on the first-party session client. Use screenshot, move, click, scroll, type, and key with a template that includes a desktop agent.
1const png = await sandbox.desktop.screenshot();2await sandbox.desktop.move(340, 210);3await sandbox.desktop.click({ x: 340, y: 210 });4await sandbox.desktop.type("hello");5await sandbox.desktop.key("ENTER");