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

Function createDesktopRun

scripts/proof-desktop-shell.mjs:19–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 return body;
18}
19async function createDesktopRun() {
20 let last;
21 for (let attempt = 1; attempt <= 3; attempt++) {
22 try {
23 return await request("/api/runs", {
24 method: "POST",
25 body: JSON.stringify({ repo, verify: ["test -f package.json"], live: true, desktop: true, ttlSeconds: 3600 }),
26 });
27 } catch (error) {
28 last = error;
29 const failedId = error?.body?.runId;
30 if (failedId) await fetch(`${url}/api/runs/${encodeURIComponent(failedId)}`, { method: "DELETE", headers }).catch(() => undefined);
31 const transient = error?.status === 503 || (error?.status === 500 && error?.body?.error === "runner_error" && /container request failed: 503/i.test(error?.body?.detail ?? ""));
32 if (!transient || attempt === 3) throw error;
33 await new Promise((resolve) => setTimeout(resolve, attempt * 5_000));
34 }
35 }
36 throw last;
37}
38
39const created = await createDesktopRun();
40const runId = created.runId;

Callers 1

Calls 2

requestFunction · 0.70
fetchFunction · 0.50

Tested by

no test coverage detected