Skip to content
Source
Sign inSign up
TanStack/ai

fix(ai-sandbox-railway): a project token is enough; require railway 3.17 #2278

Mergedcodyde(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/2278/headmerged by AlemTuzlak View on GitHub

Showing 15 changed files with 9 additions and 5 deletions (loading 11).

x
0 of 15 viewed, 15 left
5 additions and 0 deletions.changeset/railway-project-token-environment.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/ai-sandbox-railway': patch
+---
+​
+Require `railway` 3.17 or newer, which looks up the environment from a project token. With `RAILWAY_TOKEN` set to a project token, `environmentId` and `RAILWAY_ENVIRONMENT_ID` are no longer needed. An account or workspace token (`RAILWAY_API_TOKEN`) still needs one of them.
2 additions and 3 deletionsdocs/sandbox/providers-advanced.mdModified
View file
@@ -322,7 +322,6 @@
import { railwaySandbox } from '@tanstack/ai-sandbox-railway'
​
const railway = railwaySandbox({
- environmentId: process.env.RAILWAY_ENVIRONMENT_ID,
region: 'us-west2',
idleTimeoutMinutes: 30,
resources: { cpu: 2, memoryGB: 4 },
@@ -333,7 +332,7 @@
```
​
- **Isolation:** a managed [Railway](https://railway.com) sandbox in a Railway environment, on a VM that you do not run. Boot from the base image, a named `checkpoint`, or a `Sandbox.template()` recipe (`template`).
-- **Auth:** the SDK reads `RAILWAY_TOKEN` (a project token) or `RAILWAY_API_TOKEN` (an account or workspace token). An explicit `token` uses bearer auth by default. Pass `authType: 'project-token'` for a project token. The scope is the environment (`environmentId` or `RAILWAY_ENVIRONMENT_ID`), fixed for each provider.
+- **Auth:** the SDK reads `RAILWAY_TOKEN` (a project token) or `RAILWAY_API_TOKEN` (an account or workspace token). An explicit `token` uses bearer auth by default. Pass `authType: 'project-token'` for a project token. The scope is the environment, fixed for each provider. A project token is scoped to one environment, which the SDK looks up, so `RAILWAY_TOKEN` alone is enough. An account or workspace token needs `environmentId` or `RAILWAY_ENVIRONMENT_ID`.
- **Secrets:** harness credentials are [workspace secrets](./provisioning). At create and restore they go in as the runtime `env` of the sandbox. Env for each command travels in the exec init frame. No value goes into a command string.
- **Private networking:** with `networkIsolation: 'PRIVATE'`, the sandbox joins the private network of the environment. The agent can then reach your other Railway services (databases, internal APIs) by their private hostnames. The default, `ISOLATED`, has no private network access.
- **Lifetime:** Railway destroys a sandbox after `idleTimeoutMinutes` with no activity. If you omit it, the plan default applies. `0` turns off idle destruction where the plan allows it. Resume resets the idle countdown. `SandboxCreateInput` has no lifecycle hint, so set the timeout here.
@@ -412,7 +411,7 @@
| E2B | `true` | **Measured.** The SDK kill is a SIGKILL to the shell pid, and a background `( ... ) & wait` child survived it. So every command runs as a `setsid` group leader, and `kill()` runs `kill -KILL -- -<pid>` inside the sandbox. The shared journal conformance kill case passes against a real sandbox. Needs `E2B_API_KEY`. |
| Cloudflare | `false` | `kill()` does nothing. The `AbortSignal` of the caller reaches neither `exec` nor `spawn`, because Workers RPC cannot serialize one. |