An open-source, faster Devin alternative
TypeScript
fix timeout by using the right connectUrl
motatoes155079d04b9c
diff --git a/sdks/python/opencomputer/sandbox.py b/sdks/python/opencomputer/sandbox.pyindex 1b13694f..f43e734e 100644--- a/sdks/python/opencomputer/sandbox.py+++ b/sdks/python/opencomputer/sandbox.py@@ -161,7 +161,9 @@ class Sandbox:async def set_timeout(self, timeout: int) -> None:"""Update the sandbox timeout in seconds."""- resp = await self._client.post(+ # Route to worker directly (like commands/files/pty) — the control plane+ # rejects this call in server mode.+ resp = await self._ops_client.post(f"/sandboxes/{self.sandbox_id}/timeout",json={"timeout": timeout},)diff --git a/sdks/typescript/src/sandbox.ts b/sdks/typescript/src/sandbox.tsindex 37af3501..9f9cd3e5 100644--- a/sdks/typescript/src/sandbox.ts+++ b/sdks/typescript/src/sandbox.ts@@ -206,12 +206,19 @@ export class Sandbox {}async setTimeout(timeout: number): Promise<void> {- const resp = await fetch(`${this.apiUrl}/sandboxes/${this.sandboxId}/timeout`, {+ // Route to worker directly (like commands/files/pty) — the control plane+ // rejects this call in server mode.+ const url = this.connectUrl || this.apiUrl;+ const headers: Record<string, string> = { "Content-Type": "application/json" };+ if (this.connectUrl && this.token) {+ headers["Authorization"] = `Bearer ${this.token}`;+ } else if (this.apiKey) {+ headers["X-API-Key"] = this.apiKey;+ }++ const resp = await fetch(`${url}/sandboxes/${this.sandboxId}/timeout`, {method: "POST",- headers: {- "Content-Type": "application/json",- ...(this.apiKey ? { "X-API-Key": this.apiKey } : {}),- },+ headers,body: JSON.stringify({ timeout }),});