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.

Return existing sandbox when repo and DID match

+31 -1
+31 -1
apps/api/src/xrpc/io/pocketenv/sandbox/createSandbox.ts
··· 10 10 import { createAgent } from "lib/agent"; 11 11 import { TID } from "@atproto/common"; 12 12 import schema from "schema"; 13 - import { eq, or } from "drizzle-orm"; 13 + import { and, eq, or } from "drizzle-orm"; 14 14 import { 15 15 validateMain, 16 16 type Main, ··· 29 29 "Authentication failed, invalid challenge", 30 30 "AuthenticationError", 31 31 ); 32 + } 33 + 34 + if (input.repo && credentials?.did) { 35 + const [existingSandbox] = await ctx.db 36 + .select() 37 + .from(sandboxes) 38 + .leftJoin(schema.users, eq(sandboxes.userId, schema.users.id)) 39 + .where( 40 + and( 41 + eq(sandboxes.repo, input.repo), 42 + eq(schema.users.did, credentials.did), 43 + ), 44 + ) 45 + .execute(); 46 + if (existingSandbox) { 47 + return { 48 + id: existingSandbox.sandboxes.id, 49 + name: existingSandbox.sandboxes.name, 50 + provider: input.provider || Providers.CLOUDFLARE, 51 + description: input.description, 52 + topics: input.topics, 53 + repo: input.repo, 54 + vcpus: existingSandbox.sandboxes.vcpus!, 55 + memory: existingSandbox.sandboxes.memory!, 56 + disk: existingSandbox.sandboxes.disk!, 57 + readme: existingSandbox.sandboxes.readme!, 58 + createdAt: existingSandbox.sandboxes.createdAt.toISOString(), 59 + uri: existingSandbox.sandboxes.uri, 60 + }; 61 + } 32 62 } 33 63 34 64 if (!input.base.startsWith("at://")) {