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.

Sync sandbox ports to AT Protocol

+69 -1
+2
apps/api/src/atproto/sandbox.ts
··· 12 12 description?: string | null; 13 13 topics?: string[]; 14 14 repo?: string | null; 15 + ports?: number[]; 15 16 }, 16 17 ) => { 17 18 const res = await agent.com.atproto.repo.getRecord({ ··· 31 32 description: data.description ?? record.description, 32 33 topics: data.topics ?? record.topics, 33 34 repo: data.repo ?? record.repo, 35 + ports: data.ports ?? record.ports, 34 36 }; 35 37 await agent.com.atproto.repo.putRecord({ 36 38 repo: agent.assertDid,
+33
apps/api/src/xrpc/io/pocketenv/sandbox/exposePort.ts
··· 1 1 import { XRPCError, type HandlerAuth } from "@atproto/xrpc-server"; 2 + import { updateSandbox } from "atproto/sandbox"; 3 + import { consola } from "consola"; 2 4 import { Providers } from "consts"; 3 5 import type { Context } from "context"; 4 6 import { and, eq } from "drizzle-orm"; ··· 7 9 QueryParams, 8 10 InputSchema, 9 11 } from "lexicon/types/io/pocketenv/sandbox/exposePort"; 12 + import { createAgent } from "lib/agent"; 10 13 import generateJwt from "lib/generateJwt"; 11 14 import schema from "schema"; 12 15 ··· 20 23 throw new XRPCError(401, "Unauthorized"); 21 24 } 22 25 26 + const agent = await createAgent(ctx.oauthClient, auth.credentials.did); 27 + if (!agent) { 28 + consola.error( 29 + "Failed to create AT Protocol agent for DID:", 30 + auth.credentials.did, 31 + ); 32 + throw new XRPCError( 33 + 500, 34 + "Failed to create AT Protocol agent", 35 + "AgentCreationError", 36 + ); 37 + } 38 + 23 39 await ctx.db.transaction(async (tx) => { 24 40 const [record] = await tx 25 41 .select() ··· 45 61 description: input.description, 46 62 }) 47 63 .execute(); 64 + 65 + const records = await tx 66 + .select() 67 + .from(schema.sandboxPorts) 68 + .where(eq(schema.sandboxPorts.sandboxId, record.sandboxes.id)) 69 + .execute(); 70 + 71 + const ports = records.map((r) => r.exposedPort); 72 + 73 + if (record.sandboxes.uri) { 74 + updateSandbox(agent, { 75 + rkey: record.sandboxes.uri.split("/").pop()!, 76 + ports, 77 + }).catch((err) => { 78 + consola.error("Failed to update sandbox with new ports:", err); 79 + }); 80 + } 48 81 49 82 const sandbox = 50 83 record.sandboxes.provider === Providers.CLOUDFLARE
+33
apps/api/src/xrpc/io/pocketenv/sandbox/unexposePort.ts
··· 1 1 import { XRPCError, type HandlerAuth } from "@atproto/xrpc-server"; 2 + import { updateSandbox } from "atproto/sandbox"; 3 + import { consola } from "consola"; 2 4 import { Providers } from "consts"; 3 5 import type { Context } from "context"; 4 6 import { and, eq } from "drizzle-orm"; ··· 7 9 InputSchema, 8 10 QueryParams, 9 11 } from "lexicon/types/io/pocketenv/sandbox/unexposePort"; 12 + import { createAgent } from "lib/agent"; 10 13 import generateJwt from "lib/generateJwt"; 11 14 import schema from "schema"; 12 15 ··· 20 23 throw new XRPCError(401, "Unauthorized"); 21 24 } 22 25 26 + const agent = await createAgent(ctx.oauthClient, auth.credentials.did); 27 + if (!agent) { 28 + consola.error( 29 + "Failed to create AT Protocol agent for DID:", 30 + auth.credentials.did, 31 + ); 32 + throw new XRPCError( 33 + 500, 34 + "Failed to create AT Protocol agent", 35 + "AgentCreationError", 36 + ); 37 + } 38 + 23 39 await ctx.db.transaction(async (tx) => { 24 40 const [record] = await tx 25 41 .select() ··· 46 62 ), 47 63 ) 48 64 .execute(); 65 + 66 + const records = await tx 67 + .select() 68 + .from(schema.sandboxPorts) 69 + .where(eq(schema.sandboxPorts.sandboxId, record.sandboxes.id)) 70 + .execute(); 71 + 72 + const ports = records.map((r) => r.exposedPort); 73 + 74 + if (record.sandboxes.uri) { 75 + updateSandbox(agent, { 76 + rkey: record.sandboxes.uri.split("/").pop()!, 77 + ports, 78 + }).catch((err) => { 79 + consola.error("Failed to update sandbox with new ports:", err); 80 + }); 81 + } 49 82 50 83 const sandbox = 51 84 record.sandboxes.provider === Providers.CLOUDFLARE
+1 -1
apps/cf-sandbox/src/index.ts
··· 782 782 } 783 783 784 784 await sandbox.unexpose(port); 785 - c.json({}); 785 + return c.json({}); 786 786 } catch (err) { 787 787 const errorMessage = err instanceof Error ? err.message : "Unknown error"; 788 788 consola.error(