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 dayjs from "dayjs";
3import consola from "consola";
4import Table from "cli-table3";
5import { c } from "../theme";
6import { configureSdk } from "../lib/sdk";
7import { client } from "../client";
8import getAccessToken from "../lib/getAccessToken";
9import { env } from "../lib/env";
10
11export async function listEnvs(sandboxName: string) {
12 await configureSdk();
13 const sandbox = await Sandbox.get(sandboxName);
14 const { variables } = await sandbox.env.list({ limit: 100, offset: 0 });
15
16 const table = new Table({
17 head: [
18 c.primary("ID"),
19 c.primary("NAME"),
20 c.primary("VALUE"),
21 c.primary("CREATED AT"),
22 ],
23 chars: {
24 top: "",
25 "top-mid": "",
26 "top-left": "",
27 "top-right": "",
28 bottom: "",
29 "bottom-mid": "",
30 "bottom-left": "",
31 "bottom-right": "",
32 left: "",
33 "left-mid": "",
34 mid: "",
35 "mid-mid": "",
36 right: "",
37 "right-mid": "",
38 middle: " ",
39 },
40 style: {
41 border: [],
42 head: [],
43 },
44 });
45
46 for (const variable of variables) {
47 table.push([
48 c.secondary(variable.id),
49 c.highlight(variable.name),
50 variable.value,
51 dayjs(variable.createdAt).fromNow(),
52 ]);
53 }
54
55 consola.log(table.toString());
56}
57
58export async function putEnv(sandboxName: string, key: string, value: string) {
59 await configureSdk();
60 const sandbox = await Sandbox.get(sandboxName);
61 await sandbox.env.put(key, value);
62 consola.success("Variable updated successfully");
63}
64
65export async function deleteEnv(id: string) {
66 const token = await getAccessToken();
67
68 try {
69 await client.post("/xrpc/io.pocketenv.variable.deleteVariable", undefined, {
70 params: { id },
71 headers: {
72 Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
73 },
74 });
75
76 consola.success("Variable deleted successfully");
77 } catch {
78 consola.error("Failed to delete variable");
79 }
80}