ai-sdk-sandbox-gce 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +13 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# ai-sdk-sandbox-gce
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f6225e5: The README pins `ai-sdk-sandbox-gce@0.3.0` in the service's Dockerfile, the proxy's startup script and the sandbox image, rather than `0.2.0`: the service of 0.3.0 makes the proxy forget the sandboxes whose machine no longer runs, which takes a proxy of the same version.
|
|
8
|
+
- a9476c5: The READMEs deploy the service with a build account of its own, `--build-service-account` granted `roles/run.builder`, rather than the Compute Engine default service account, which older projects grant `roles/editor`: whatever a build ran could then reach everything in the project, the agents' tokens included. The sandbox-gce README also has the roles inherited from the folder and the organization checked, since they read the machines' metadata as well.
|
|
9
|
+
|
|
3
10
|
## 0.3.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -154,8 +154,8 @@ if ! command -v npm >/dev/null; then
|
|
|
154
154
|
fi
|
|
155
155
|
# Installed again whenever the pinned version changes: the proxy then restarts on it, below.
|
|
156
156
|
restart=false
|
|
157
|
-
if ! npm ls --global ai-sdk-sandbox-gce@0.
|
|
158
|
-
npm install --global ai-sdk-sandbox-gce@0.
|
|
157
|
+
if ! npm ls --global ai-sdk-sandbox-gce@0.3.0 >/dev/null 2>&1; then
|
|
158
|
+
npm install --global ai-sdk-sandbox-gce@0.3.0
|
|
159
159
|
restart=true
|
|
160
160
|
fi
|
|
161
161
|
# Its logs, the refusals among them, sent to Cloud Logging by the Ops Agent.
|
|
@@ -244,7 +244,7 @@ echo "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.co
|
|
|
244
244
|
> /etc/apt/sources.list.d/nodesource.list
|
|
245
245
|
apt-get update
|
|
246
246
|
apt-get install -y nodejs
|
|
247
|
-
npm install --global ai-sdk-sandbox-gce@0.
|
|
247
|
+
npm install --global ai-sdk-sandbox-gce@0.3.0 pnpm@10
|
|
248
248
|
|
|
249
249
|
# The sandbox's user: sudo without a password, and Docker.
|
|
250
250
|
useradd --create-home --shell /bin/bash agent
|
|
@@ -275,7 +275,7 @@ The service's image is the package and Node.js:
|
|
|
275
275
|
|
|
276
276
|
```dockerfile title="Dockerfile"
|
|
277
277
|
FROM node:24-bookworm-slim
|
|
278
|
-
RUN npm install --global --silent ai-sdk-sandbox-gce@0.
|
|
278
|
+
RUN npm install --global --silent ai-sdk-sandbox-gce@0.3.0 && npm cache clean --force
|
|
279
279
|
CMD ["ai-sdk-sandbox-gce", "serve"]
|
|
280
280
|
```
|
|
281
281
|
|
|
@@ -315,8 +315,14 @@ for secret in sandbox-agent-secret sandbox-proxy-token sandbox-service-token; do
|
|
|
315
315
|
--member=serviceAccount:sandboxes@$PROJECT.iam.gserviceaccount.com --role=roles/secretmanager.secretAccessor
|
|
316
316
|
done
|
|
317
317
|
|
|
318
|
+
# What Cloud Build makes the service's image as: the build, and nothing else.
|
|
319
|
+
gcloud iam service-accounts create sandboxes-build
|
|
320
|
+
gcloud projects add-iam-policy-binding $PROJECT \
|
|
321
|
+
--member=serviceAccount:sandboxes-build@$PROJECT.iam.gserviceaccount.com --role=roles/run.builder
|
|
322
|
+
|
|
318
323
|
gcloud run deploy sandboxes --region=$REGION --source=. \
|
|
319
324
|
--service-account=sandboxes@$PROJECT.iam.gserviceaccount.com \
|
|
325
|
+
--build-service-account=projects/$PROJECT/serviceAccounts/sandboxes-build@$PROJECT.iam.gserviceaccount.com \
|
|
320
326
|
--network=sandboxes --subnet=service --vpc-egress=private-ranges-only \
|
|
321
327
|
--no-allow-unauthenticated --min-instances=0 --timeout=3600 --concurrency=1000 \
|
|
322
328
|
--set-env-vars=SANDBOX_ZONE=$ZONE,SANDBOX_IMAGE=family/ai-sdk-sandbox \
|
|
@@ -331,6 +337,7 @@ gcloud run deploy sandboxes --region=$REGION --source=. \
|
|
|
331
337
|
What these settings are for:
|
|
332
338
|
|
|
333
339
|
- `--network`, `--subnet`, `--vpc-egress`: Direct VPC egress, so that the service reaches the agents and the proxy on their internal addresses.
|
|
340
|
+
- `--build-service-account`: Cloud Build makes the image as an account of its own, which only reads the sources, pushes the image and writes the build's logs. Without it, Cloud Build builds as the Compute Engine default service account, which older projects grant `roles/editor`: anything a build runs would then read the agents' tokens, and everything else in the project. Once no build uses it, take `roles/editor` away from that account.
|
|
334
341
|
- `sandboxService`: create, stop, start and delete the machines, save a template as an image, start and stop the proxy; nothing outside the names of the condition. A missing permission shows in `pnpm test:e2e`.
|
|
335
342
|
- `SANDBOX_PROXY_INSTANCE`: the proxy only runs while a sandbox does. `SANDBOX_MAX_RUNNING`: the machines running at once, a cap on the bill. `SANDBOX_MAX_RUN_HOURS`: Compute Engine stops a machine after so long, whatever happens.
|
|
336
343
|
- `SANDBOX_SERVICE_TOKEN`: a second lock beside Cloud Run's IAM, should the service ever be deployed open; the client hands it over as `serviceToken`. The service refuses to start on Cloud Run without it, unless `SANDBOX_INSECURE_NO_TOKEN=true`.
|
|
@@ -347,7 +354,7 @@ gcloud run services add-iam-policy-binding sandboxes --region=$REGION \
|
|
|
347
354
|
--member=serviceAccount:my-app@$PROJECT.iam.gserviceaccount.com --role=roles/run.invoker
|
|
348
355
|
```
|
|
349
356
|
|
|
350
|
-
Anyone with that role and the service token can run commands in every sandbox of the service: grant it to your application, not to people who only need to read logs, and hand the token to the client as `serviceToken` (`gcloud secrets versions access latest --secret=sandbox-service-token`). Each agent's token sits in its machine's metadata, which anyone allowed `compute.instances.get` on the project reads (`roles/viewer`, `roles/compute.viewer`): with a foothold in the `service` subnetwork as well, they run commands in that sandbox as root, until the sandbox is next stopped, which draws it a new token. Grant those roles sparingly, and keep the subnetwork to the service alone.
|
|
357
|
+
Anyone with that role and the service token can run commands in every sandbox of the service: grant it to your application, not to people who only need to read logs, and hand the token to the client as `serviceToken` (`gcloud secrets versions access latest --secret=sandbox-service-token`). Each agent's token sits in its machine's metadata, which anyone allowed `compute.instances.get` on the project reads (`roles/viewer`, `roles/compute.viewer`): with a foothold in the `service` subnetwork as well, they run commands in that sandbox as root, until the sandbox is next stopped, which draws it a new token. Grant those roles sparingly, and keep the subnetwork to the service alone. Roles granted on the project's folder or organization count as well: `gcloud projects get-ancestors-iam-policy $PROJECT` lists them.
|
|
351
358
|
|
|
352
359
|
Read the service's URL with `gcloud run services describe sandboxes --region=$REGION --format='value(status.url)'`; the examples below read it from `GCE_SANDBOX_URL`.
|
|
353
360
|
|
|
@@ -676,7 +683,7 @@ The steps above set up the network, the proxy and the service as they ran on Goo
|
|
|
676
683
|
- [ ] **Set a budget alert** on the project, and keep the region's vCPU quota low: unlike an alert, a quota stops the spending.
|
|
677
684
|
- [ ] **Restrict the service's ingress** when your application runs on Google Cloud: `gcloud run services update sandboxes --region=$REGION --ingress=internal`, the application then reaching it through the VPC (Direct VPC egress with `--vpc-egress=all-traffic`). Called from outside Google Cloud, the service stays public, guarded by IAM and its token.
|
|
678
685
|
- [ ] **Review the allowed hosts**: no `*`, no wildcard on a shared domain, a package registry only where the agent installs packages. Each is a way out for the sandbox's files.
|
|
679
|
-
- [ ] **Grant `roles/viewer` and `roles/compute.viewer` sparingly**: they read the agents' tokens in the machines' metadata.
|
|
686
|
+
- [ ] **Grant `roles/viewer` and `roles/compute.viewer` sparingly**: they read the agents' tokens in the machines' metadata. Check the roles inherited from the folder and the organization too (`gcloud projects get-ancestors-iam-policy $PROJECT`), and that no service account, the Compute Engine default one first, holds `roles/editor`.
|
|
680
687
|
- [ ] **Authenticate your users** before anything reaches the service: whoever can call your application runs commands in its sandboxes. With Google accounts, a sign-in limited to your domain (Google OAuth, the `hd` claim checked on the server); on Google Cloud, [Identity-Aware Proxy](https://cloud.google.com/iap/docs/enabling-cloud-run) in front of the application. Either way, `roles/run.invoker` on the service goes to the application's service account alone, and the application checks on the server, at every call, that the sandbox belongs to the user.
|
|
681
688
|
|
|
682
689
|
## Limitations
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-sdk-sandbox-gce",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Compute Engine sandboxes for AI SDK harness agents: Claude Code, Codex and friends in a virtual machine of their own on Google Cloud, Docker included, stopped between turns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"vitest": "^5.0.5",
|
|
59
59
|
"zod": "^4.6.7",
|
|
60
60
|
"@repo/build": "0.0.0",
|
|
61
|
-
"@repo/eslint-config": "0.0.0",
|
|
62
61
|
"@repo/prettier-config": "0.0.0",
|
|
63
62
|
"@repo/typescript-config": "0.0.0",
|
|
63
|
+
"@repo/eslint-config": "0.0.0",
|
|
64
64
|
"@repo/vitest-config": "0.0.0"
|
|
65
65
|
},
|
|
66
66
|
"author": {
|