Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
fix(server): report a sandbox template that is not valid JSON as a SandboxError (#391)
Felix-Ayush8290aeb4c9c9
diff --git a/server/src/computer/sandbox.ts b/server/src/computer/sandbox.tsindex 3169a973..80b76760 100644--- a/server/src/computer/sandbox.ts+++ b/server/src/computer/sandbox.ts@@ -103,13 +103,26 @@ export async function readSandboxTemplate(`COMPUTER_SANDBOX_TEMPLATE_FILE points at ${path}, which cannot be read. That file is what a Bot's computer is cut from; the chart mounts it when computers.mode is sandbox.`,);}- const parsed = JSON.parse(raw) as Record<string, unknown>;- if (!parsed.podTemplate) {+ let parsed: unknown;+ try {+ parsed = JSON.parse(raw);+ } catch {+ throw new SandboxError(+ `${path} is not valid JSON, so there is nothing to make a computer from.`,+ );+ }+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {+ throw new SandboxError(+ `${path} is not valid JSON, so there is nothing to make a computer from.`,+ );+ }+ const podTemplate = (parsed as Record<string, unknown>).podTemplate;+ if (!podTemplate) {throw new SandboxError(`${path} has no podTemplate, so there is nothing to make a computer from.`,);}- return parsed;+ return parsed as Record<string, unknown>;}/** How long a read token is reused before the file is consulted again. */