An open-source, faster Devin alternative
TypeScript
Edge: pass Work-As-Of back and expose it to CORS (work tracking 3.10, S4)
Igor Zalutski via Computer894e5b567a94
diff --git a/cloudflare-workers/api-edge/src/computer_api.test.ts b/cloudflare-workers/api-edge/src/computer_api.test.tsindex e554df60..1ce62529 100644--- a/cloudflare-workers/api-edge/src/computer_api.test.ts+++ b/cloudflare-workers/api-edge/src/computer_api.test.ts@@ -434,6 +434,7 @@ describe("computer API proxy to blue", () => {"x-opc-latest": "0.9.0",etag: '"v1"',"retry-after": "1",+ "work-as-of": "2026-11-19T10:00:00.000Z","set-cookie": "nope=1",},}),@@ -462,6 +463,7 @@ describe("computer API proxy to blue", () => {["x-opc-latest", "0.9.0"],["etag", '"v1"'],["retry-after", "1"],+ ["work-as-of", "2026-11-19T10:00:00.000Z"],]) {expect(res.headers.get(name)).toBe(value);}@@ -602,7 +604,7 @@ describe("computer API proxy to blue", () => {it("returns a 304 with no body", async () => {const db = new FakeDB();const key = await addKey(db);- vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response(null, { status: 304, headers: { etag: '"v1"' } })));+ vi.stubGlobal("fetch", vi.fn().mockResolvedValue(new Response(null, { status: 304, headers: { etag: '"v1"', "work-as-of": "2026-11-19T10:00:00.000Z" } })));const res = await worker.fetch(api("/sessions/cs_1", { headers: { "x-api-key": key, "if-none-match": '"v1"' } }),testEnv(db),@@ -610,6 +612,7 @@ describe("computer API proxy to blue", () => {);expect(res.status).toBe(304);expect(res.headers.get("etag")).toBe('"v1"');+ expect(res.headers.get("work-as-of")).toBe("2026-11-19T10:00:00.000Z");});it("keeps the dashboard mount's computer list on the dashboard family", async () => {@@ -790,7 +793,7 @@ describe("computer API CORS", () => {);expect(res.headers.get("access-control-allow-origin")).toBe(ORIGIN);expect(res.headers.get("access-control-expose-headers")).toBe(- "server-timing, x-request-id, x-opc-latest, retry-after, etag",+ "server-timing, x-request-id, x-opc-latest, retry-after, etag, work-as-of",);expect(res.headers.get("server-timing")).toBe("x;dur=1");});diff --git a/cloudflare-workers/api-edge/src/computer_api.ts b/cloudflare-workers/api-edge/src/computer_api.tsindex e9023df6..807ac09e 100644--- a/cloudflare-workers/api-edge/src/computer_api.ts+++ b/cloudflare-workers/api-edge/src/computer_api.ts@@ -167,6 +167,8 @@ const API_RESPONSE_HEADERS = ["x-opc-latest","retry-after","etag",+ // When the Work index last saw the branch head (work tracking 3.10), on 200 and 304.+ "work-as-of",];/** Request headers passed to the wire Worker, beside the caller's key. */@@ -312,7 +314,7 @@ const CORS_ALLOW_HEADERS ="authorization, content-type, idempotency-key, x-request-id, if-none-match";const CORS_ALLOW_METHODS = "GET, POST, PATCH, PUT, DELETE";const CORS_EXPOSE_HEADERS =- "server-timing, x-request-id, x-opc-latest, retry-after, etag";+ "server-timing, x-request-id, x-opc-latest, retry-after, etag, work-as-of";/*** Whether a browser origin may call the computer API: the edge's own origin