Skip to content

An open-source, faster Devin alternative

TypeScript

Deployment region: accept every Modal region; docs and CLI 0.7.19 (#874)

opencomputer-app[bot]e69751f5b3c8
diff --git a/cli/package-lock.json b/cli/package-lock.json
index 74b5889e..05abbe2a 100644
--- a/cli/package-lock.json
+++ b/cli/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@opencomputer/cli",
- "version": "0.7.18",
+ "version": "0.7.19",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@opencomputer/cli",
- "version": "0.7.18",
+ "version": "0.7.19",
"dependencies": {
"@opencode-ai/sdk": "1.18.4",
"ai": "^7.0.45",
diff --git a/cli/package.json b/cli/package.json
index 16aeca7a..de0677a6 100644
--- a/cli/package.json
+++ b/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/cli",
- "version": "0.7.18",
+ "version": "0.7.19",
"description": "Build, test, deploy, and share OpenComputer agents as code.",
"type": "module",
"bin": {
diff --git a/cli/src/project.test.ts b/cli/src/project.test.ts
index cb8fe361..e9a956d7 100644
--- a/cli/src/project.test.ts
+++ b/cli/src/project.test.ts
@@ -3062,7 +3062,7 @@ test("prepareAgent builds into a cache under node_modules, never into the agent'
}
});
-test("opencomputer.toml region is optional, accepts au, and rejects anything else", async () => {
+test("opencomputer.toml region is optional, accepts Modal regions, and rejects anything else", async () => {
const root = await mkdtemp(resolve(tmpdir(), "opencomputer-region-"));
const manifest = (extra: string) =>
writeFile(
@@ -3074,8 +3074,10 @@ test("opencomputer.toml region is optional, accepts au, and rejects anything els
assert.equal((await readManifest(root)).region, undefined);
await manifest('region = "au"\n');
assert.equal((await readManifest(root)).region, "au");
+ await manifest('region = "eu-west"\n');
+ assert.equal((await readManifest(root)).region, "eu-west");
await manifest('region = "us-east-1"\n');
- await assert.rejects(readManifest(root), /region "us-east-1" is not supported; use one of: au/);
+ await assert.rejects(readManifest(root), /region "us-east-1" is not supported; use one of: us, eu, ap, /);
await manifest("region = au\n");
await assert.rejects(readManifest(root), /region must be a quoted string/);
} finally {
diff --git a/cli/src/project.ts b/cli/src/project.ts
index 7e17cce8..1d635516 100644
--- a/cli/src/project.ts
+++ b/cli/src/project.ts
@@ -28,8 +28,34 @@ import {
type MemoryProvider,
} from "./memory.js";
-/** Regions a deployment may name in `opencomputer.toml` (work 057). */
-export const DEPLOYMENT_REGIONS = ["au"] as const;
+/**
+ * Regions a deployment may name in `opencomputer.toml` (work 057): Modal's
+ * sandbox regions, broad then narrow. The service keeps the same list.
+ */
+export const DEPLOYMENT_REGIONS = [
+ "us",
+ "eu",
+ "ap",
+ "us-east",
+ "us-central",
+ "us-south",
+ "us-west",
+ "eu-west",
+ "eu-north",
+ "eu-south",
+ "ap-northeast",
+ "ap-southeast",
+ "ap-south",
+ "ap-melbourne",
+ "jp",
+ "au",
+ "uk",
+ "ca",
+ "me",
+ "sa",
+ "af",
+ "mx",
+] as const;
export type DeploymentRegion = (typeof DEPLOYMENT_REGIONS)[number];
export interface AgentManifest {
diff --git a/cloudflare-workers/api-edge/src/managed_agents.ts b/cloudflare-workers/api-edge/src/managed_agents.ts
index c046004b..a4e56c9c 100644
--- a/cloudflare-workers/api-edge/src/managed_agents.ts
+++ b/cloudflare-workers/api-edge/src/managed_agents.ts
@@ -315,7 +315,7 @@ async function publicErrorResponse(
: backendCode === "invalid_cursor"
? "The cursor is invalid or was issued for different filters. Start again from the first page."
: backendCode === "unsupported_region"
- ? 'The region in opencomputer.toml is not supported. Supported: "au".'
+ ? 'The region in opencomputer.toml is not supported. Use a Modal region, such as "us", "eu-west" or "au".'
: "The agent request was invalid.";
} else if (upstream.status === 401 || upstream.status === 403) {
message = "The agent request was not authorized.";
diff --git a/docs/agents/deployments.mdx b/docs/agents/deployments.mdx
index 7b4abdd3..3418388d 100644
--- a/docs/agents/deployments.mdx
+++ b/docs/agents/deployments.mdx
@@ -41,9 +41,9 @@ the `production` alias to it. Development remains available for further work.
## Choose a region
-By default an agent's sandboxes run in the United States. To run its sessions closer to
-your users or systems, set `region` in the agent's `opencomputer.toml` and
-deploy again:
+By default, an agent's sandbox runs wherever capacity is available, usually in
+the United States. To run sessions closer to your users or systems, set
+`region` in the agent's `opencomputer.toml` and deploy again:
```toml
schema = 1
@@ -52,18 +52,77 @@ name = "Support"
region = "au"
```
-| Region | Where sessions run |
-| --- | --- |
-| `au` | Australia |
+### Allowed values
-The region applies to the agent's sandbox and its session state. It covers
-sessions started after the deploy; existing sessions stay where they started.
-Session state placement is best effort. Account-level data, such as project
-and deployment records, is not moved. An unsupported value fails the deploy
-with `unsupported_region`.
+`region` takes any of [Modal's sandbox regions](https://modal.com/docs/guide/region-selection).
+OpenComputer places the agent's sandbox in that region, and creates session
+state in the nearest Cloudflare location:
-Each agent in a project has its own `opencomputer.toml`, so agents in one
-project can run in different regions.
+| `region` | Sandbox runs in | Session state placed near |
+| --- | --- | --- |
+| omitted | wherever capacity is available, usually the United States | the first request |
+| `"us"` | anywhere in the United States | eastern North America |
+| `"eu"` | anywhere in the European Economic Area | western Europe |
+| `"ap"` | anywhere in Asia-Pacific | Asia-Pacific |
+| `"us-east"`, `"us-central"`, `"us-south"` | that part of the United States | eastern North America |
+| `"us-west"` | western United States | western North America |
+| `"ca"` | Canada | eastern North America |
+| `"mx"` | Mexico | western North America |
+| `"eu-west"`, `"eu-south"` | that part of Europe | western Europe |
+| `"eu-north"` | northern Europe | eastern Europe |
+| `"uk"` | United Kingdom | western Europe |
+| `"ap-northeast"`, `"ap-southeast"`, `"ap-south"` | that part of Asia-Pacific | Asia-Pacific |
+| `"jp"` | Japan | Asia-Pacific |
+| `"au"`, `"ap-melbourne"` | Australia | Oceania |
+| `"me"` | Middle East | Middle East |
+| `"sa"` | South America | South America |
+| `"af"` | Africa | Africa |
+
+A broad region (`us`, `eu`, `ap`) lets the sandbox run anywhere inside it, so
+it starts sooner when capacity is tight. A narrow region pins it more
+precisely.
+
+- Values are lowercase and exact. `"AU"` and cloud zone names such as
+ `"ap-southeast-2"` or `"us-east-1"` are rejected.
+- The value must be a quoted string. `region = au` is rejected.
+- To go back to the default, remove the `region` line and deploy again.
+
+An unsupported value stops the deploy before anything is uploaded:
+
+```text
+opencomputer.toml region "us-east-1" is not supported; use one of: us, eu, ap, us-east, …
+```
+
+The API rejects it too, with `400 unsupported_region`, if you call
+`POST /v1/deployments` directly.
+
+### What the region covers
+
+- **Sandbox.** The agent's sandbox, where `sandbox_exec` and other tools run,
+ is created in the region. Its outbound traffic leaves from that region too.
+- **Session state.** Session state is created near the region. This placement
+ is best effort.
+- **Not moved.** Account-level data, such as project and deployment records,
+ stays where it is.
+
+### Changing the region
+
+A region change applies to sessions started after the deploy. Existing
+sessions stay where they started. Each agent in a project has its own
+`opencomputer.toml`, so agents in one project can run in different regions.
+
+### Cold starts
+
+The first session after you deploy to a new region is slower to start. The
+agent's sandbox image has to be pulled into that region, and the first tool
+call can take a few minutes. Later sessions reuse the cached image and start
+much faster. To take the cold start before your users do, start one session
+that runs a command after the deploy. The sandbox starts only on the first tool
+call, so a session that only chats does not warm it:
+
+```sh
+opencomputer session "Run: echo ready"
+```
## Select an agent and environment