the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 100 lines 2.6 kB view raw
1import { Sandbox } from "@pocketenv/sdk"; 2import { password } from "@inquirer/prompts"; 3import chalk from "chalk"; 4import consola from "consola"; 5import Table from "cli-table3"; 6import dayjs from "dayjs"; 7import relativeTime from "dayjs/plugin/relativeTime"; 8import { c } from "../theme"; 9import { configureSdk } from "../lib/sdk"; 10import { client } from "../client"; 11import getAccessToken from "../lib/getAccessToken"; 12import { env } from "../lib/env"; 13 14dayjs.extend(relativeTime); 15 16export async function listSecrets(sandboxName: string) { 17 await configureSdk(); 18 const sandbox = await Sandbox.get(sandboxName); 19 const { secrets } = await sandbox.secret.list({ limit: 100, offset: 0 }); 20 21 const table = new Table({ 22 head: [c.primary("ID"), c.primary("NAME"), c.primary("CREATED AT")], 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 secret of secrets) { 47 table.push([ 48 c.secondary(secret.id), 49 c.highlight(secret.name), 50 dayjs(secret.createdAt).fromNow(), 51 ]); 52 } 53 54 consola.log(table.toString()); 55} 56 57export async function putSecret(sandboxName: string, key: string) { 58 const isStdinPiped = !process.stdin.isTTY; 59 const value = isStdinPiped 60 ? await new Promise<string>((resolve) => { 61 let data = ""; 62 process.stdin.setEncoding("utf8"); 63 process.stdin.on("data", (chunk) => (data += chunk)); 64 process.stdin.on("end", () => resolve(data.trimEnd())); 65 }) 66 : await password({ message: "Enter secret value" }); 67 68 await configureSdk(); 69 70 try { 71 const sandbox = await Sandbox.get(sandboxName); 72 73 if (!sandbox) { 74 consola.error(`Sandbox not found: ${chalk.greenBright(sandboxName)}`); 75 process.exit(1); 76 } 77 78 await sandbox.secret.put(key, value); 79 consola.success("Secret added successfully"); 80 } catch (error) { 81 consola.error("Failed to add secret:", error); 82 } 83} 84 85export async function deleteSecret(id: string) { 86 const token = await getAccessToken(); 87 88 try { 89 await client.post("/xrpc/io.pocketenv.secret.deleteSecret", undefined, { 90 params: { id }, 91 headers: { 92 Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`, 93 }, 94 }); 95 96 consola.success("Secret deleted successfully"); 97 } catch (error) { 98 consola.error("Failed to delete secret:", error); 99 } 100}