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

Function livePreviewTarget

runner/server.mjs:269–281  ·  view source on GitHub ↗
(runId, request, suffix, protocol)

Source from the content-addressed store, hash-verified

267 if (typeof bytes !== "string" || !bytes) throw new Error("snapshot bytes are required");
268 const data = Buffer.from(bytes, "base64");
269 if (!data.length || data.byteLength > 100 * 1024 * 1024) throw new Error("snapshot is empty or too large");
270 const root = await mkdtemp(join(tmpdir(), "cloudbox-"));
271 const archive = join(root, "snapshot.tar.gz");
272 await writeFile(archive, data);
273 const receipt = await run(`tar -xzf ${shell(archive)} -C ${shell(root)}`, root);
274 await rm(archive, { force: true });
275 if (receipt.code !== 0) {
276 await rm(root, { recursive: true, force: true });
277 return { ok: false, runId, error: receipt.stderr || receipt.stdout, receipt };
278 }
279 liveRuns.set(runId, { root, workspace: join(root, "repo"), createdAt: new Date().toISOString() });
280 return { ok: true, runId };
281}
282
283async function handleLiveDelete(runId) {
284 safeRunId(runId);

Callers 2

handleLivePreviewFunction · 0.85
upgradeLivePreviewFunction · 0.85

Calls 2

requireLiveWorkspaceFunction · 0.85
snapshotDevProcessFunction · 0.85

Tested by

no test coverage detected