Skip to content

An open-source, faster Devin alternative

TypeScript

Upgrade guide (#712)

Brian Reardon1fe33858ab02
diff --git a/docs/migrating-from-v1.mdx b/docs/migrating-from-v1.mdx
index 9dd4deca..61d00620 100644
--- a/docs/migrating-from-v1.mdx
+++ b/docs/migrating-from-v1.mdx
@@ -1,17 +1,134 @@
---
title: "Migrating from v1"
-description: "Every breaking change between v1 and v2, and how to find out whether you are affected"
+description: "Upgrade the SDK, verify it worked, and every behaviour that differs"
---
-v2 is the same API with the same SDK calls. Most code runs unchanged. What follows is the
-complete list of behaviour that differs, ordered by how likely it is to matter.
+**Upgrading the SDK is the migration.** There is no ticket to file and no setting to change:
+v1 and v2 are chosen by the major version of the SDK you have installed. Install `1.x` and your
+new sandboxes run on v2. Go back to `0.x` and they run on v1 again.
-Nothing changes for you until your org is moved to v2. The v1 documentation stays accurate
-until then and is archived permanently at [docs-v1.opencomputer.dev](https://docs-v1.opencomputer.dev).
+Existing sandboxes never move. The version decides where **new** sandboxes are created, so a
+rollback is a reinstall, not a recovery.
+
+## Upgrade
+
+<CodeGroup>
+```bash TypeScript
+npm install @opencomputer/sdk@^1.1.0
+```
+
+```bash Python
+pip install --upgrade "opencomputer-sdk>=1.1.0"
+```
+</CodeGroup>
+
+Your API key and your existing sandboxes are unaffected. `1.1.0` is the floor only because the
+check below reads `endAt`, which was added there; any `1.x` routes to v2.
+
+<Note>
+If you asked us to pin your org to a runtime, the pin wins and the SDK version is ignored. That
+is deliberate: it stops one stale service in your fleet from quietly creating sandboxes on the
+other version. Ask us to remove the pin if you want version-based switching.
+</Note>
+
+## Verify the upgrade
+
+A v2 sandbox carries `endAt` — the hard deadline its host will be destroyed at. A v1 sandbox has
+no such deadline and omits the field entirely. That single difference is the check.
+
+<CodeGroup>
+```typescript TypeScript
+import { Sandbox } from "@opencomputer/sdk";
+
+const sandbox = await Sandbox.create();
+
+console.log("version:", sandbox.endAt ? "v2" : "v1");
+if (sandbox.endAt) {
+ const hours = (Date.parse(sandbox.endAt) - Date.now()) / 3_600_000;
+ console.log(`endAt=${sandbox.endAt} ends in ${hours.toFixed(1)}h`);
+}
+
+// The rest is a normal smoke test — identical on both versions.
+const result = await sandbox.exec.run("node -v");
+console.log("exec:", result.exitCode === 0 ? "ok" : "FAILED", result.stdout.trim());
+
+await sandbox.kill();
+```
+
+```python Python
+import asyncio
+from opencomputer import Sandbox
+
+async def main():
+ sandbox = await Sandbox.create()
+
+ # getattr, not sandbox.end_at: the 0.x SDK has no such attribute, so a
+ # direct read raises AttributeError instead of reporting v1.
+ end_at = getattr(sandbox, "end_at", None)
+ print("version:", "v2" if end_at else "v1")
+ if end_at:
+ print("endAt =", end_at)
+
+ result = await sandbox.exec.run("python3 -V")
+ print("exec:", "ok" if result.exit_code == 0 else "FAILED", result.stdout.strip())
+
+ await sandbox.kill()
+
+asyncio.run(main())
+```
+</CodeGroup>
+
+Expect exactly this:
+
+```
+version: v2
+endAt=2026-09-05T05:22:59Z ends in 8.0h
+exec: ok v18.20.8
+```
+
+If you see `version: v1` after upgrading, your org is pinned — see the note above.
+
+### Then run your own test suite
+
+The genuine check is your code, unchanged, against v2. The SDK surface is identical, so your
+existing tests are the migration test. Point a non-production service at it for a day before
+moving anything that matters.
+
+The three failures worth watching for, because they are silent in a short test and obvious in a
+long one:
+
+<Steps>
+ <Step title="A sandbox disappears after 8 hours">
+ Expected. See [Sandboxes end after 8 hours](#sandboxes-end-after-8-hours).
+ </Step>
+ <Step title="A restored checkpoint has your files but not your process">
+ Expected. See [Checkpoints are filesystem-only](#checkpoints-are-filesystem-only).
+ </Step>
+ <Step title="A create fails naming a template">
+ Expected for templates built on v1. See [Templates](#templates-built-on-v1-are-refused).
+ </Step>
+</Steps>
+
+## Rolling back
+
+Reinstall the previous major. New sandboxes go back to v1 immediately; nothing needs to drain.
+
+<CodeGroup>
+```bash TypeScript
+npm install @opencomputer/[email protected]
+```
+
+```bash Python
+pip install "opencomputer-sdk==0.6.9"
+```
+</CodeGroup>
+
+Sandboxes you already created on v2 keep running on v2 until they end. Rolling back does not
+move them, and it does not shorten their 8-hour lifetime.
## Am I affected?
-Seven questions. If every answer is "no", your migration is a configuration change.
+Seven questions. If every answer is "no", upgrading is the whole migration.
<Steps>
<Step title="Does any sandbox need to live longer than 8 hours?">
@@ -42,9 +159,10 @@ Seven questions. If every answer is "no", your migration is a configuration chan
</Step>
</Steps>
-## Finding the calls in your code
+### Finding the calls in your code
-```bash
+<CodeGroup>
+```bash TypeScript
# Hard failures in v2
rg -n "\.scale\(|setAutoscale|\.mounts\b|createFromCheckpoint|buildImage|image:"
@@ -52,6 +170,15 @@ rg -n "\.scale\(|setAutoscale|\.mounts\b|createFromCheckpoint|buildImage|image:"
rg -n "createCheckpoint|restoreCheckpoint|\.hibernate\(|setTimeout|cpuCount|diskMB"
```
+```bash Python
+# Hard failures in v2
+rg -n "\.scale\(|set_autoscale|\.mounts\b|create_from_checkpoint|build_image|image="
+
+# Behaviour changes — review these
+rg -n "create_checkpoint|restore_checkpoint|\.hibernate\(|set_timeout|cpu_count|disk_mb"
+```
+</CodeGroup>
+
## The breaking changes
### Sandboxes end after 8 hours
@@ -61,14 +188,16 @@ A v2 sandbox is destroyed 8 hours after its host started, counting running **and
time. It cannot be extended, and the disk goes with it.
</Warning>
-Read `endAt` on the sandbox rather than computing a deadline — sandboxes come from a warm pool,
-so the host often started before your create did:
+Read `endAt` rather than computing a deadline — sandboxes come from a warm pool, so the host
+often started before your create did:
```typescript
-const info = await getSandbox(sandbox.sandboxId);
-const msLeft = Date.parse(info.endAt) - Date.now();
+const sandbox = await Sandbox.create();
+const msLeft = Date.parse(sandbox.endAt!) - Date.now();
```
+`endAt` is on the sandbox from `create()` and from `connect()`. It is `undefined` on v1.
+
Work that assumed a long-lived sandbox needs to checkpoint and roll over, or keep its state
outside the sandbox.
@@ -144,20 +273,10 @@ that sandbox. See [Secrets](/sandboxes/secrets).
Each of these is **refused** rather than silently ignored.
-## What improves
-
-- Creates are served from a warm pool, so they start faster and more consistently.
-- Deploys no longer disturb running sandboxes.
-- An unavailable size is refused with the sizes that exist, instead of being reported as a
- capacity problem.
-- A sandbox that reports `running` is running — rows can no longer outlive their host.
-
-## Testing before you move
-
-Ask us to move a non-production org first. The same SDK and the same code run against both
-versions, so your existing test suite is the test.
-
<Note>
If something in your workload is blocked by the "in progress" items above, tell us. That list is
prioritised work, not a fixed decision.
</Note>
+
+The v1 documentation stays accurate for `0.x` and is archived permanently at
+[docs-v1.opencomputer.dev](https://docs-v1.opencomputer.dev).
diff --git a/sdks/python/opencomputer/sandbox.py b/sdks/python/opencomputer/sandbox.py
index d5c61cb5..b6d097f7 100644
--- a/sdks/python/opencomputer/sandbox.py
+++ b/sdks/python/opencomputer/sandbox.py
@@ -77,6 +77,18 @@ class Sandbox:
#: a successful ``rotate_preview_auth_token()`` this value is replaced
#: with the new token. Empty string when not enabled or when reconnecting.
preview_auth_token: str = ""
+ #: RFC3339 instant at which the provider destroys this sandbox's host, or
+ #: ``None`` when the runtime imposes no lifetime.
+ #:
+ #: Two uses. It is the deadline to plan against — checkpoint and roll over
+ #: before it, because the disk goes with the host. And because only some
+ #: runtimes have one, its presence identifies which runtime served the
+ #: create, which is what the upgrade guide's smoke test checks.
+ #:
+ #: Read this rather than computing a deadline from the create time:
+ #: sandboxes are served from a warm pool, so the host is usually older
+ #: than the create.
+ end_at: str | None = None
_api_url: str = ""
_api_key: str = ""
_connect_url: str = ""
@@ -219,6 +231,7 @@ class Sandbox:
status=data.get("status", "running"),
template=template,
preview_auth_token=data.get("previewAuthToken", ""),
+ end_at=data.get("endAt"),
_api_url=url,
_api_key=key,
_connect_url=connect_url,
@@ -278,6 +291,7 @@ class Sandbox:
sandbox_id=sandbox_id,
status=data.get("status", "running"),
template=data.get("templateID", ""),
+ end_at=data.get("endAt"),
_api_url=url,
_api_key=key,
_connect_url=connect_url,
@@ -748,6 +762,10 @@ class Sandbox:
return cls(
sandbox_id=data["sandboxID"],
status=data.get("status", "running"),
+ # Absent on the runtime that serves this call today, but populated
+ # rather than dropped so a reader does not have to wonder why one
+ # constructor omits it.
+ end_at=data.get("endAt"),
_api_url=url,
_api_key=key,
_connect_url=connect_url,
diff --git a/sdks/python/opencomputer/version.py b/sdks/python/opencomputer/version.py
index 7c9443f7..5af1b28d 100644
--- a/sdks/python/opencomputer/version.py
+++ b/sdks/python/opencomputer/version.py
@@ -26,7 +26,7 @@ this docstring start with that name: two readers of this file are greps.
from __future__ import annotations
-__version__ = "1.0.0"
+__version__ = "1.1.0"
#: Header carrying the version above. Lower-case to match the TypeScript SDK;
#: HTTP/2 requires it there and consistency costs nothing here.
diff --git a/sdks/typescript/package-lock.json b/sdks/typescript/package-lock.json
index f02535fa..0cb95118 100644
--- a/sdks/typescript/package-lock.json
+++ b/sdks/typescript/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@opencomputer/sdk",
- "version": "1.0.0",
+ "version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/sdk",
- "version": "1.0.0",
+ "version": "1.1.0",
"license": "MIT",
"dependencies": {
"undici": "^6.0.0 || ^7.0.0"
diff --git a/sdks/typescript/package.json b/sdks/typescript/package.json
index 71afaf62..165c4e77 100644
--- a/sdks/typescript/package.json
+++ b/sdks/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/sdk",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "TypeScript SDK for OpenComputer - cloud sandbox platform",
"type": "module",
"main": "dist/index.js",
diff --git a/sdks/typescript/src/sandbox.ts b/sdks/typescript/src/sandbox.ts
index d76ba484..8633bd79 100644
--- a/sdks/typescript/src/sandbox.ts
+++ b/sdks/typescript/src/sandbox.ts
@@ -82,6 +82,17 @@ interface SandboxData {
connectURL?: string;
token?: string;
sandboxDomain?: string;
+ /**
+ * RFC3339 instant at which the provider will destroy this sandbox's host.
+ *
+ * Present only when the runtime imposes one. A sandbox on the QEMU fleet has
+ * no provider-imposed lifetime and omits the field entirely, so its presence
+ * is also how you tell which runtime served a create.
+ *
+ * Read this rather than computing a deadline from the create time: sandboxes
+ * are served from a warm pool, so the host is usually older than the create.
+ */
+ endAt?: string;
/** Plaintext preview-URL bearer token. Returned exactly once on the create
* or rotate response when `previewAuth` was requested. */
previewAuthToken?: string;
@@ -298,6 +309,24 @@ export class Sandbox {
*/
readonly webhooks: Array<{ id: string; url: string; secret?: string }>;
+ /**
+ * RFC3339 instant at which the provider destroys this sandbox's host, or
+ * `undefined` when the runtime imposes no lifetime.
+ *
+ * Two uses. It is the deadline to plan against — checkpoint and roll over
+ * before it, because the disk goes with the host. And because only some
+ * runtimes have one, its presence identifies which runtime served the
+ * create, which is what the upgrade guide's smoke test checks.
+ *
+ * ```ts
+ * const sandbox = await Sandbox.create();
+ * if (sandbox.endAt) {
+ * const msLeft = Date.parse(sandbox.endAt) - Date.now();
+ * }
+ * ```
+ */
+ readonly endAt?: string;
+
private constructor(data: SandboxData, apiUrl: string, apiKey: string) {
this.sandboxId = data.sandboxID;
this.id = this.sandboxId;
@@ -308,6 +337,7 @@ export class Sandbox {
this.token = data.token || "";
this.previewAuthToken = data.previewAuthToken || "";
this.webhooks = data.webhooks ?? [];
+ this.endAt = data.endAt;
this._sandboxDomain = data.sandboxDomain || "";
// Always route through the CP — it handles readiness waiting and proxies to workers.
diff --git a/sdks/typescript/src/version.ts b/sdks/typescript/src/version.ts
index c81c574d..ff06c05a 100644
--- a/sdks/typescript/src/version.ts
+++ b/sdks/typescript/src/version.ts
@@ -27,7 +27,7 @@ export const SDK_VERSION_HEADER = "x-oc-sdk-version";
* only failure mode that matters — a stale constant here would silently route a
* v2 caller to the old runtime.
*/
-export const SDK_VERSION = "1.0.0";
+export const SDK_VERSION = "1.1.0";
/** The identifying header, as a spreadable object. */
export function sdkVersionHeaders(): Record<string, string> {