the universal sandbox runtime for agents and humans.
pocketenv.io
sandbox
openclaw
agent
claude-code
vercel-sandbox
deno-sandbox
cloudflare-sandbox
atproto
sprites
daytona
1import { Sandbox } from "@pocketenv/sdk";
2import CliTable3 from "cli-table3";
3import consola from "consola";
4import { c } from "../theme";
5import { configureSdk } from "../lib/sdk";
6
7export async function listPorts(sandboxName: string) {
8 await configureSdk();
9
10 const sandbox = await Sandbox.get(sandboxName);
11 const ports = await sandbox.ports.list();
12
13 const table = new CliTable3({
14 head: [
15 c.primary("PORT"),
16 c.primary("DESCRIPTION"),
17 c.primary("PREVIEW URL"),
18 ],
19 chars: {
20 top: "",
21 "top-mid": "",
22 "top-left": "",
23 "top-right": "",
24 bottom: "",
25 "bottom-mid": "",
26 "bottom-left": "",
27 "bottom-right": "",
28 left: "",
29 "left-mid": "",
30 mid: "",
31 "mid-mid": "",
32 right: "",
33 "right-mid": "",
34 middle: " ",
35 },
36 style: {
37 border: [],
38 head: [],
39 },
40 });
41
42 for (const port of ports) {
43 table.push([
44 c.secondary(port.port),
45 port.description || "-",
46 c.link(port.previewUrl || "-"),
47 ]);
48 }
49
50 consola.log(table.toString());
51}