MCPcopy Create free account
hub / github.com/acoyfellow/cloudbox / getOwnerComputer

Function getOwnerComputer

src/sandbox-computer.ts:26–37  ·  view source on GitHub ↗
(env: SandboxComputerBindings, owner: ComputerOwner)

Source from the content-addressed store, hash-verified

24}
25
26export async function getOwnerComputer(env: SandboxComputerBindings, owner: ComputerOwner): Promise<ComputerSandbox> {
27 const key = `computer-v3:${ownerKey(owner)}`;
28 if (env.getComputerSandbox) return env.getComputerSandbox(key);
29 if (!env.CLOUDBOX_SANDBOX) throw new Error("CLOUDBOX_SANDBOX binding is unavailable");
30 // Keep the Sandbox SDK out of unit-test module evaluation: its upstream
31 // containers package is Workers/bundler-oriented rather than Node ESM-safe.
32 const { getSandbox } = await import("@cloudflare/sandbox");
33 return getSandbox(env.CLOUDBOX_SANDBOX as never, key, {
34 containerTimeouts: { instanceGetTimeoutMS: 120_000, portReadyTimeoutMS: 240_000 },
35 transport: "rpc",
36 }) as unknown as ComputerSandbox;
37}
38
39export function assertComputerPath(path: string): void {
40 if (!path.startsWith(`${COMPUTER_HOME}/`) || path.includes("/../") || path.endsWith("/..") || path.includes("\0")) {

Callers 1

prepareOwnerComputerFunction · 0.85

Calls 1

ownerKeyFunction · 0.85

Tested by

no test coverage detected