An open-source, faster Devin alternative
TypeScript
sse in sdk
Brian Reardon385ac8524cc7
diff --git a/sdks/python/opencomputer/sandbox.py b/sdks/python/opencomputer/sandbox.pyindex 28caebea..3313b132 100644--- a/sdks/python/opencomputer/sandbox.py+++ b/sdks/python/opencomputer/sandbox.py@@ -70,7 +70,9 @@ class Sandbox:if key:headers["X-API-Key"] = key- use_sse = on_build_log is not None and (image is not None or snapshot is not None)+ # Always use SSE for image/snapshot creation to keep the connection alive+ # through proxies (Cloudflare has a 100s idle timeout).+ use_sse = image is not None or snapshot is not Noneif use_sse:headers["Accept"] = "text/event-stream"diff --git a/sdks/typescript/src/sandbox.ts b/sdks/typescript/src/sandbox.tsindex e3dbadf4..cc9badce 100644--- a/sdks/typescript/src/sandbox.ts+++ b/sdks/typescript/src/sandbox.ts@@ -148,7 +148,9 @@ export class Sandbox {if (opts.image) body.image = opts.image.toJSON();if (opts.snapshot) body.snapshot = opts.snapshot;- const useSSE = opts.onBuildLog && (opts.image || opts.snapshot);+ // Always use SSE for image/snapshot creation to keep the connection alive+ // through proxies (Cloudflare has a 100s idle timeout).+ const useSSE = !!(opts.image || opts.snapshot);const headers: Record<string, string> = {"Content-Type": "application/json",@@ -170,7 +172,8 @@ export class Sandbox {}if (useSSE && resp.headers.get("content-type")?.includes("text/event-stream")) {- const data = await parseSSEStream<SandboxData>(resp, opts.onBuildLog!);+ const onLog = opts.onBuildLog ?? (() => {});+ const data = await parseSSEStream<SandboxData>(resp, onLog);return new Sandbox(data, apiUrl, apiKey);}