ai-sdk-sandbox-gce 0.3.2 → 0.3.4
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 +27 -0
- package/README.md +62 -23
- package/dist/client/gce-settings.d.ts +25 -1
- package/dist/client/lifecycle/create-session.d.ts +12 -9
- package/dist/client/lifecycle/create-session.js +17 -7
- package/dist/client/transport/sandbox-service-client.d.ts +9 -2
- package/dist/client/transport/sandbox-service-client.js +10 -3
- package/dist/in-vm/agent-config.js +45 -2
- package/dist/in-vm/agent-server.js +1 -1
- package/dist/in-vm/agent.d.ts +9 -0
- package/dist/in-vm/agent.js +12 -0
- package/dist/in-vm/idle-power-off.d.ts +28 -0
- package/dist/in-vm/idle-power-off.js +46 -0
- package/dist/index.d.ts +1 -1
- package/dist/protocol/agent.d.ts +5 -0
- package/dist/protocol/agent.js +5 -0
- package/dist/server/compute/compute-api.d.ts +10 -1
- package/dist/server/compute/compute-api.js +11 -2
- package/dist/server/config.js +51 -0
- package/dist/server/http/routes.js +7 -2
- package/dist/server/sandboxes/sandboxes.d.ts +140 -17
- package/dist/server/sandboxes/sandboxes.js +463 -79
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# ai-sdk-sandbox-gce
|
|
2
2
|
|
|
3
|
+
## 0.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fb3ec6d: `prepareGceSandboxService()` takes the sandbox's `template` (with its `setup` and `image`), and the service then boots a machine from it ahead of the sandbox, beside the egress proxy, with the `cost` profile too: the creation that follows takes it, in a few seconds rather than some 25 s for its own machine to boot. A person reading a summary before launching a sandbox gets it at once, for no fixed cost.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
void prepareGceSandboxService({
|
|
11
|
+
url,
|
|
12
|
+
auth: 'metadata',
|
|
13
|
+
template: await agent.getSandboxTemplate(),
|
|
14
|
+
}).catch(() => undefined);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
It never builds the template: until the first sandbox made from it, only the proxy boots. One machine at a time: a template whose pool holds one, running or booting, gets none more, however many calls. A prepared machine no creation took powers itself off 16 minutes after its boot: its agent does so, unless a sandbox took it, whether a call comes or not, and the service deletes it as the next creation or preparation meets it once it waited 15 minutes. Rebuild the sandbox image with this version for the agent's bound to apply: a machine of an older image keeps only the service's, and should no call come, `SANDBOX_MAX_RUN_HOURS` is what stops it, so set it when you prepare. The service no longer stops the egress proxy while a prepared machine waits for its sandbox, and a preparation starts a proxy the last sandbox was just stopping once it has stopped: the sandbox that takes the machine no longer waits for the proxy to boot again. A service of an earlier version ignores the template and boots the proxy only.
|
|
18
|
+
- 9c817f6: The condition of the proxy's unit in the README reads the installed version from the package's `package.json`, rather than with `npm ls --global`: npm took some 20 s to start on the proxy's machine as it booted, and the proxy waited for it, some 54 s for a stopped proxy rather than 35 s. Hand the new script to the proxy's machine (`gcloud compute instances add-metadata … --metadata-from-file=startup-script=proxy-startup.sh`).
|
|
19
|
+
|
|
20
|
+
## 0.3.3
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 7afcb0c: The sandbox service takes `SANDBOX_PROFILE=cost|fast`, to trade how fast a sandbox starts against what the service costs at rest. `cost`, the default, is the service as it was: nothing runs but the sandboxes, and a sandbox from a template starts in some 35 to 40 s. `fast` starts one in a few seconds, for one machine of `SANDBOX_MACHINE_TYPE` per template used in the last 24 h and the egress proxy running all the time: the service keeps a machine booted from each template in use, which the next creation from that template takes as it is, booted or still booting, and makes the next one meanwhile. A machine that waited 24 h without a creation is deleted without a replacement: a template no longer used costs a day of its machine at most. See "Speed or cost" in the README.
|
|
25
|
+
|
|
26
|
+
The profile only sets the defaults of two settings, each its own variable: `SANDBOX_WARM_POOL`, how many machines are kept booted per template (`0`, `1` with `fast`), and `SANDBOX_PROXY_ALWAYS_ON`, which never stops the proxy's machine of `SANDBOX_PROXY_INSTANCE` once no sandbox runs (`false`, `true` with `fast`). With `fast` and `SANDBOX_PROXY_INSTANCE`, leave the lines of `SANDBOX_PROXY_IDLE_EXIT_MINUTES` out of the proxy's unit.
|
|
27
|
+
|
|
28
|
+
A sandbox taken from the pool keeps its machine's name, `sbx-pool-<hex>`, since Compute Engine cannot rename a running machine: its sandbox's name is on its label `ai-sdk-sandbox-name`. The service's role needs no new permission: it already has `compute.instances.setLabels`.
|
|
29
|
+
|
|
3
30
|
## 0.3.2
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -135,7 +135,7 @@ gcloud compute instances create sandbox-proxy --zone=$ZONE --machine-type=e2-sma
|
|
|
135
135
|
#!/bin/sh
|
|
136
136
|
set -e
|
|
137
137
|
# The version of the proxy: the one your application depends on.
|
|
138
|
-
VERSION=0.3.
|
|
138
|
+
VERSION=0.3.4
|
|
139
139
|
# Writes $2 to the file $1 when it differs, and says whether it did.
|
|
140
140
|
changed() {
|
|
141
141
|
mkdir -p "$(dirname "$1")"
|
|
@@ -229,7 +229,11 @@ set -e
|
|
|
229
229
|
pinned=$(curl -fsS -H Metadata-Flavor:Google \
|
|
230
230
|
http://metadata.google.internal/computeMetadata/v1/instance/attributes/startup-script \
|
|
231
231
|
| sed -n 's/^VERSION=//p')
|
|
232
|
-
npm
|
|
232
|
+
# Read from its package.json, where Node.js from NodeSource installs it: npm itself takes some 20 s
|
|
233
|
+
# to start on a small machine as it boots.
|
|
234
|
+
installed=$(sed -n 's/^ *"version": *"\([^"]*\)".*/\1/p' \
|
|
235
|
+
/usr/lib/node_modules/ai-sdk-sandbox-gce/package.json | head -n 1)
|
|
236
|
+
[ -n "$pinned" ] && [ "$installed" = "$pinned" ]
|
|
233
237
|
SCRIPT
|
|
234
238
|
chmod 755 /usr/local/bin/ai-sdk-sandbox-proxy-pinned
|
|
235
239
|
# Started by systemd as the machine boots, seconds before this script runs, when its package is
|
|
@@ -250,7 +254,7 @@ gcloud compute instances add-metadata sandbox-proxy --zone=$ZONE \
|
|
|
250
254
|
gcloud compute instances reset sandbox-proxy --zone=$ZONE
|
|
251
255
|
```
|
|
252
256
|
|
|
253
|
-
The proxy need not run when no sandbox does: set `SANDBOX_PROXY_INSTANCE=sandbox-proxy` on the service (step 4), which then starts it with the first sandbox, booting alongside it, and stops it once none runs. A sandbox then waits some 40 s for the proxy to boot: call `prepareGceSandboxService()` (see [Usage](#usage)) as soon as one is likely to be asked for, and it finds the proxy up. Its startup script runs again at each boot, and its registrations, held in memory, are made again by the sandboxes that start.
|
|
257
|
+
The proxy need not run when no sandbox does: set `SANDBOX_PROXY_INSTANCE=sandbox-proxy` on the service (step 4), which then starts it with the first sandbox, booting alongside it, and stops it once none runs and no prepared machine waits for one. A sandbox then waits some 40 s for the proxy to boot: call `prepareGceSandboxService()` (see [Usage](#usage)) as soon as one is likely to be asked for, and it finds the proxy up. Its startup script runs again at each boot, and its registrations, held in memory, are made again by the sandboxes that start.
|
|
254
258
|
|
|
255
259
|
### 3. The sandbox image
|
|
256
260
|
|
|
@@ -276,7 +280,7 @@ echo "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.co
|
|
|
276
280
|
> /etc/apt/sources.list.d/nodesource.list
|
|
277
281
|
apt-get update
|
|
278
282
|
apt-get install -y nodejs
|
|
279
|
-
npm install --global ai-sdk-sandbox-gce@0.3.
|
|
283
|
+
npm install --global ai-sdk-sandbox-gce@0.3.4 pnpm@10
|
|
280
284
|
|
|
281
285
|
# The sandbox's user: sudo without a password, and Docker.
|
|
282
286
|
useradd --create-home --shell /bin/bash agent
|
|
@@ -303,7 +307,7 @@ The agent runs as root and starts the commands as `agent`. It does not wait for
|
|
|
303
307
|
|
|
304
308
|
### 4. The service
|
|
305
309
|
|
|
306
|
-
The service's image is published on Docker Hub with each release, `docker.io/fpasquet/ai-sdk-sandbox-gce:<version>`: Node.js and the package, built by the release workflow from the version on npm. Deploy the version your application depends on. Each image carries a provenance attestation, which `gh attestation verify oci://docker.io/fpasquet/ai-sdk-sandbox-gce:0.3.
|
|
310
|
+
The service's image is published on Docker Hub with each release, `docker.io/fpasquet/ai-sdk-sandbox-gce:<version>`: Node.js and the package, built by the release workflow from the version on npm. Deploy the version your application depends on. Each image carries a provenance attestation, which `gh attestation verify oci://docker.io/fpasquet/ai-sdk-sandbox-gce:0.3.4 --owner fpasquet` checks; its [`Dockerfile`](https://github.com/fpasquet/ai-sdk-harness/blob/main/packages/sandbox-gce/Dockerfile) builds the same image from your own registry.
|
|
307
311
|
|
|
308
312
|
Its service account gets a role of its own, with what the service calls and nothing else, limited by a condition to the names it uses: the sandboxes' machines and disks (`sbx-`), the proxy's machine, the sandbox images and templates (`ai-sdk-`).
|
|
309
313
|
|
|
@@ -341,7 +345,7 @@ for secret in sandbox-agent-secret sandbox-proxy-token sandbox-service-token; do
|
|
|
341
345
|
--member=serviceAccount:sandboxes@$PROJECT.iam.gserviceaccount.com --role=roles/secretmanager.secretAccessor
|
|
342
346
|
done
|
|
343
347
|
|
|
344
|
-
gcloud run deploy sandboxes --region=$REGION --image=docker.io/fpasquet/ai-sdk-sandbox-gce:0.3.
|
|
348
|
+
gcloud run deploy sandboxes --region=$REGION --image=docker.io/fpasquet/ai-sdk-sandbox-gce:0.3.4 \
|
|
345
349
|
--service-account=sandboxes@$PROJECT.iam.gserviceaccount.com \
|
|
346
350
|
--network=sandboxes --subnet=service --vpc-egress=private-ranges-only \
|
|
347
351
|
--no-allow-unauthenticated --min-instances=0 --timeout=3600 --concurrency=1000 \
|
|
@@ -422,18 +426,21 @@ try {
|
|
|
422
426
|
|
|
423
427
|
`auth` takes `'gcloud'` (the default: `gcloud auth print-identity-token`), `'metadata'` (the workload's service account on Google Cloud), `'none'`, or a function returning an identity token for the service's URL, such as one from `google-auth-library`.
|
|
424
428
|
|
|
425
|
-
|
|
429
|
+
A sandbox made after a quiet spell waits for machines to boot: its own, some 25 s, and the egress proxy's when the service starts and stops it (`SANDBOX_PROXY_INSTANCE`). Ask the service to boot them as soon as a sandbox is likely to be asked for, a person reading what is about to run, say, and the sandbox finds them up, created in a few seconds:
|
|
426
430
|
|
|
427
431
|
```ts
|
|
428
432
|
import { prepareGceSandboxService } from 'ai-sdk-sandbox-gce';
|
|
429
433
|
|
|
430
|
-
//
|
|
431
|
-
void prepareGceSandboxService({
|
|
432
|
-
|
|
433
|
-
|
|
434
|
+
// A hint, not awaited: an error changes nothing for the sandboxes.
|
|
435
|
+
void prepareGceSandboxService({
|
|
436
|
+
url: process.env.GCE_SANDBOX_URL!,
|
|
437
|
+
auth: 'metadata',
|
|
438
|
+
// The sandbox's template, setup and image, as it will be created: a machine boots from it.
|
|
439
|
+
template: await agent.getSandboxTemplate(),
|
|
440
|
+
}).catch(() => undefined);
|
|
434
441
|
```
|
|
435
442
|
|
|
436
|
-
|
|
443
|
+
It never builds the template: until the first sandbox made from it, only the proxy boots. A proxy still stopping, the last sandbox just gone, is started once stopped. The service does not stop it while the prepared machine waits for its sandbox: it stops again with the next sandbox that stops once that machine is taken or gone, or by itself after 10 minutes when none comes (`SANDBOX_PROXY_IDLE_EXIT_MINUTES` in its unit); the machine, as [Speed or cost](#speed-or-cost) says. A service of an earlier version boots the proxy only, or nothing.
|
|
437
444
|
|
|
438
445
|
## Images and toolchains
|
|
439
446
|
|
|
@@ -472,6 +479,34 @@ const sandboxSession = await createGceNetworkSandboxSession({
|
|
|
472
479
|
await sandboxSession.destroy();
|
|
473
480
|
```
|
|
474
481
|
|
|
482
|
+
## Speed or cost
|
|
483
|
+
|
|
484
|
+
`SANDBOX_PROFILE` on the service trades how fast a sandbox starts against what the service costs at rest. It only sets defaults: each setting below can be set on its own.
|
|
485
|
+
|
|
486
|
+
| Profile | At rest | A sandbox from a template |
|
|
487
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
488
|
+
| `cost` (default) | Nothing runs: the disks of stopped sandboxes and the templates' images only. With `SANDBOX_PROXY_INSTANCE`, the proxy runs while a sandbox does | Some 35 to 40 s: a machine boots for it |
|
|
489
|
+
| `fast` | One machine of `SANDBOX_MACHINE_TYPE` and its disk for each template used in the last 24 h, all the time, at its Spot price with `SANDBOX_SPOT=true`; and the proxy's machine, always on | A few seconds when the pool's machine has booted, less than a cold start while it boots |
|
|
490
|
+
|
|
491
|
+
`fast` keeps a machine booted from each template in use, the warm pool (`SANDBOX_WARM_POOL=1`, machines per template), and never stops the proxy (`SANDBOX_PROXY_ALWAYS_ON=true`). A creation from a template takes one of its machines as it is, and the service creates the next one in the same request, without waiting for it to boot: Cloud Run throttles the service's CPU once it has answered, so nothing is left to run after. Each machine runs some 730 hours a month: see [Compute Engine's prices](https://cloud.google.com/compute/vm-instance-pricing) for your machine type and region.
|
|
492
|
+
|
|
493
|
+
- Only a creation from a template takes from the pool: `template: await agent.getSandboxTemplate()`. A creation without one, or a resume, boots its machine as before.
|
|
494
|
+
- A machine of the pool never ran an agent: it boots from the template, as a new sandbox does. Once taken it is the sandbox's, and never goes back to the pool.
|
|
495
|
+
- Each template has its pool: two harnesses, Claude Code and Codex say, keep a machine each. A new template (a new version of the package or of the sandbox image) gets its own on its first creation.
|
|
496
|
+
- A machine that waited 24 h without a creation is deleted, without a replacement, by the next creation that meets it, whatever its template: a template no longer used costs a day of its machine at most.
|
|
497
|
+
- A creation takes a running machine of its template first, or else one still booting, the one booting longest: it is ready sooner than a machine booted for the creation. Two creations in a row: the second takes the machine the first one started.
|
|
498
|
+
- A machine taken from the pool keeps its name, `sbx-pool-<hex>`: Compute Engine cannot rename a running machine. The sandbox's name is on its label `ai-sdk-sandbox-name`, by which the service finds it.
|
|
499
|
+
- `SANDBOX_MAX_RUNNING` does not count the pool's machines, and they do not keep the proxy up.
|
|
500
|
+
- `SANDBOX_MAX_RUN_HOURS` applies to the pool's machines as to every other, the bill's guard: for a sandbox taken from the pool, Compute Engine counts it from the machine's boot in the pool, 24 h ago at most. How long a session lasts is the application's to decide, not the limit's. With `SANDBOX_SPOT=true`, Compute Engine may take a machine back. A machine stopped either way is deleted by the next creation that meets it, and the pool fills again.
|
|
501
|
+
- With `SANDBOX_PROXY_INSTANCE`, the service starts the proxy with the first sandbox and leaves it running: leave the three lines of `SANDBOX_PROXY_IDLE_EXIT_MINUTES` out of its unit, or the proxy stops itself after 10 minutes with no sandbox. Without `SANDBOX_PROXY_INSTANCE`, the proxy is always on anyway.
|
|
502
|
+
- Back to `cost`, the next creation from a template takes what is left in its pool, and makes nothing more.
|
|
503
|
+
|
|
504
|
+
With `cost`, a person who reads before a sandbox is launched, a summary of what will run say, gets it in a few seconds too, for no fixed cost: call `prepareGceSandboxService()` with the sandbox's template as the summary opens (see [Usage](#usage)). The service boots one machine from the template, labelled `ai-sdk-sandbox-prepared=true`, and the creation that follows takes it like a machine of the pool. One at a time: a template whose pool holds a machine, running or booting, gets none more, however many people open a summary.
|
|
505
|
+
|
|
506
|
+
A prepared machine no creation takes costs while it runs, and two bounds stop it. Its agent powers it off itself 16 minutes after its boot unless a sandbox took it (`systemctl poweroff`, read from its metadata key `ai-sdk-sandbox-idle-poweroff-minutes`, which only prepared machines have), whether any call comes or not: it then costs its disk alone, until the next creation or preparation that meets it deletes it. And the service deletes it, running or not, as the next creation or preparation meets it once it waited 15 minutes, a minute before its agent would: a creation never takes a machine about to power off.
|
|
507
|
+
|
|
508
|
+
The agent's bound comes with the sandbox image: rebuild it with this version of the package (step 3) for it to apply. A machine of an older image keeps only the service's bound: should no call come, it runs until `SANDBOX_MAX_RUN_HOURS` stops it, or until the next call that meets it after 24 h without the limit; set `SANDBOX_MAX_RUN_HOURS` when you prepare. The proxy the preparation started stops by itself after `SANDBOX_PROXY_IDLE_EXIT_MINUTES`.
|
|
509
|
+
|
|
475
510
|
## Stopping and resuming
|
|
476
511
|
|
|
477
512
|
`stop()` suspends the sandbox: the processes this session started are stopped, the proxy forgets its credentials, then the machine is stopped, its disk kept. Resume it later, from this process or another one:
|
|
@@ -614,7 +649,10 @@ Docker pulls images from Docker Hub through the proxy: allow `registry-1.docker.
|
|
|
614
649
|
| `SANDBOX_MAX_RUNNING` | none | The most sandboxes running at once: a creation or a resume beyond it is answered with a 429. Counted at each call, so two at the same instant may both pass |
|
|
615
650
|
| `SANDBOX_MAX_RUN_HOURS` | none | The longest a machine runs at a time: Compute Engine stops it then (`maxRunDuration`), disk kept, whatever the service or the application do. 30 s at least |
|
|
616
651
|
| `SANDBOX_RECONCILE_MINUTES` | `10` | How often, at most, the service makes the proxy forget the sandboxes whose machine no longer runs, in the background of a creation or a resume. A sandbox of another service sharing the proxy in the zone is left alone, under another `SANDBOX_INSTANCE_PREFIX`. `0` for never: a proxy shared with a service of another zone or project |
|
|
617
|
-
| `SANDBOX_PROXY_INSTANCE` | none | The egress proxy's machine, in the sandboxes' zone: started with the first sandbox that runs, stopped once none does. Always on without it
|
|
652
|
+
| `SANDBOX_PROXY_INSTANCE` | none | The egress proxy's machine, in the sandboxes' zone: started with the first sandbox that runs, stopped once none does and no prepared machine waits for one. Always on without it |
|
|
653
|
+
| `SANDBOX_PROFILE` | `cost` | `cost` or `fast`: the defaults of the two settings below, see [Speed or cost](#speed-or-cost) |
|
|
654
|
+
| `SANDBOX_WARM_POOL` | `0`, `1` with `fast` | How many machines are kept booted from each template used in the last 24 h, for the next creations from it to take at once. Each one is billed all the time |
|
|
655
|
+
| `SANDBOX_PROXY_ALWAYS_ON` | `false`, `true` with `fast` | `true`: the service starts the proxy's machine of `SANDBOX_PROXY_INSTANCE` with the first sandbox, and never stops it. No sandbox waits for it to boot, and it is billed all the time |
|
|
618
656
|
| `SANDBOX_ALLOWED_HOSTS` | none | Hosts every sandbox may reach over HTTPS, comma-separated; `*.domain` allowed. `*`, any host, is logged as a warning at startup |
|
|
619
657
|
| `SANDBOX_BASE_URLS` | `ANTHROPIC_BASE_URL=https://api.anthropic.com,OPENAI_BASE_URL=https://api.openai.com/v1` | Base URL variables routed through the proxy, as `NAME=url` pairs |
|
|
620
658
|
| `SANDBOX_SERVICE_TOKEN` | required on Cloud Run | A secret every call must carry, beside Cloud Run's IAM |
|
|
@@ -636,16 +674,17 @@ Docker pulls images from Docker Hub through the proxy: allow `registry-1.docker.
|
|
|
636
674
|
|
|
637
675
|
### The agent (`agent`)
|
|
638
676
|
|
|
639
|
-
| Variable | Default | Description
|
|
640
|
-
| -------------------------- | -------------------------------------------- |
|
|
641
|
-
| `SANDBOX_USER` | `agent` | The user the commands run as, when the agent is root
|
|
642
|
-
| `SANDBOX_HOME` | `/home/<user>` | Their `HOME`
|
|
643
|
-
| `SANDBOX_WORKDIR` | `/workspace` | Their working directory, made the user's
|
|
644
|
-
| `SANDBOX_PATH` | `/usr/local/sbin:/usr/local/bin:/usr/sbin:…` | Their `PATH`
|
|
645
|
-
| `SANDBOX_AGENT_PORT` | `8100` | Where the agent listens
|
|
646
|
-
| `SANDBOX_AGENT_TOKEN` | the instance's `ai-sdk-sandbox-agent-token` | Its token: the service puts it in the instance metadata
|
|
647
|
-
| `SANDBOX_STATE_DIR` | `/var/lib/ai-sdk-sandbox` | Where it keeps the network configuration, root's
|
|
648
|
-
| `SANDBOX_CONFIGURE_DOCKER` | `true` | `false` to leave Docker's proxy settings alone
|
|
677
|
+
| Variable | Default | Description |
|
|
678
|
+
| -------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
679
|
+
| `SANDBOX_USER` | `agent` | The user the commands run as, when the agent is root |
|
|
680
|
+
| `SANDBOX_HOME` | `/home/<user>` | Their `HOME` |
|
|
681
|
+
| `SANDBOX_WORKDIR` | `/workspace` | Their working directory, made the user's |
|
|
682
|
+
| `SANDBOX_PATH` | `/usr/local/sbin:/usr/local/bin:/usr/sbin:…` | Their `PATH` |
|
|
683
|
+
| `SANDBOX_AGENT_PORT` | `8100` | Where the agent listens |
|
|
684
|
+
| `SANDBOX_AGENT_TOKEN` | the instance's `ai-sdk-sandbox-agent-token` | Its token: the service puts it in the instance metadata |
|
|
685
|
+
| `SANDBOX_STATE_DIR` | `/var/lib/ai-sdk-sandbox` | Where it keeps the network configuration, root's |
|
|
686
|
+
| `SANDBOX_CONFIGURE_DOCKER` | `true` | `false` to leave Docker's proxy settings alone |
|
|
687
|
+
| `SANDBOX_RUN_DIR` | `/run/ai-sdk-sandbox` | Where it marks it was configured since the machine booted, emptied at each boot: an agent restarted then never powers a machine off |
|
|
649
688
|
|
|
650
689
|
A sandbox's commands run with nothing of the agent's environment: only their `PATH`, `HOME`, `USER`, the proxy and base URL variables, and the variables the command sets.
|
|
651
690
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HarnessV1SandboxSessionCreateOptions, HarnessV1SandboxSessionResumeOptions } from '@ai-sdk/harness';
|
|
1
|
+
import type { HarnessV1SandboxSessionCreateOptions, HarnessV1SandboxSessionResumeOptions, HarnessV1SandboxTemplate } from '@ai-sdk/harness';
|
|
2
2
|
/**
|
|
3
3
|
* How calls to the sandbox service are authenticated. The service runs on Cloud Run, deployed with
|
|
4
4
|
* `--no-allow-unauthenticated`: each call carries a Google identity token, granted
|
|
@@ -86,6 +86,30 @@ export interface GceCreationSettings extends GceConnectionSettings {
|
|
|
86
86
|
*/
|
|
87
87
|
setup?: readonly string[];
|
|
88
88
|
}
|
|
89
|
+
/** Options of `prepareGceSandboxService()`: the sandbox likely to be created next. */
|
|
90
|
+
export interface GcePrepareSettings extends GceConnectionSettings {
|
|
91
|
+
/**
|
|
92
|
+
* The template the sandbox will be created from, `await agent.getSandboxTemplate()`: the service
|
|
93
|
+
* boots a machine from it ahead of the sandbox, which the creation takes. Only once the template
|
|
94
|
+
* exists on the service: preparing never builds it. Without it, only the egress proxy is booted.
|
|
95
|
+
*/
|
|
96
|
+
template?: HarnessV1SandboxTemplate;
|
|
97
|
+
/**
|
|
98
|
+
* The `setup` the sandbox will be created with: with the template, what names the template's
|
|
99
|
+
* image.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue `[]`
|
|
102
|
+
*/
|
|
103
|
+
setup?: readonly string[];
|
|
104
|
+
/**
|
|
105
|
+
* The image the sandbox will be created on, by the name the service gives it in `SANDBOX_IMAGES`.
|
|
106
|
+
*
|
|
107
|
+
* @defaultValue the service's `SANDBOX_IMAGE`
|
|
108
|
+
*/
|
|
109
|
+
image?: string;
|
|
110
|
+
/** Aborts the call. */
|
|
111
|
+
abortSignal?: AbortSignal;
|
|
112
|
+
}
|
|
89
113
|
/** Options of `createGceNetworkSandboxSession()`. */
|
|
90
114
|
export type GceNetworkSandboxSessionCreateOptions = HarnessV1SandboxSessionCreateOptions<GceCreationSettings>;
|
|
91
115
|
/** Options of `resumeGceNetworkSandboxSession()`. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GceNetworkSandboxSessionCreateOptions, GceNetworkSandboxSessionResumeOptions, GcePrepareSettings } from '../gce-settings.js';
|
|
2
2
|
import { GceNetworkSandboxSession } from '../session/gce-network-sandbox-session.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates a sandbox, a [Compute Engine](https://cloud.google.com/compute) virtual machine of its
|
|
@@ -16,15 +16,18 @@ import { GceNetworkSandboxSession } from '../session/gce-network-sandbox-session
|
|
|
16
16
|
*/
|
|
17
17
|
export declare function createGceNetworkSandboxSession(options: GceNetworkSandboxSessionCreateOptions): Promise<GceNetworkSandboxSession>;
|
|
18
18
|
/**
|
|
19
|
-
* Has the sandbox service at `url` boot what a sandbox needs,
|
|
20
|
-
* starts and stops it,
|
|
21
|
-
*
|
|
22
|
-
* the
|
|
23
|
-
*
|
|
19
|
+
* Has the sandbox service at `url` boot what a sandbox needs, without waiting for it: its egress
|
|
20
|
+
* proxy when the service starts and stops it, and, given the sandbox's `template` (with its `setup`
|
|
21
|
+
* and `image`), a machine booted from it. Call it as soon as a sandbox is likely to be asked for,
|
|
22
|
+
* the person who launches it still reading what will run, and the creation that follows finds them
|
|
23
|
+
* up. A hint: do not await it, and ignore its errors, which change nothing for the sandboxes.
|
|
24
|
+
*
|
|
25
|
+
* It never builds the template: before the first sandbox made from it, only the proxy is booted.
|
|
26
|
+
* Should no sandbox come, the proxy stops by itself, and the service deletes the machine as it
|
|
27
|
+
* meets it, once it waited 15 minutes. A service of an earlier version boots the proxy only, or
|
|
28
|
+
* nothing.
|
|
24
29
|
*/
|
|
25
|
-
export declare function prepareGceSandboxService(options:
|
|
26
|
-
abortSignal?: AbortSignal;
|
|
27
|
-
}): Promise<void>;
|
|
30
|
+
export declare function prepareGceSandboxService(options: GcePrepareSettings): Promise<void>;
|
|
28
31
|
/**
|
|
29
32
|
* Reattaches to a sandbox made by {@link createGceNetworkSandboxSession}, from this process or
|
|
30
33
|
* another one: a running sandbox as it is, a stopped one started again on its disk. Never creates
|
|
@@ -5,7 +5,7 @@ import { identityToken } from '../transport/identity-token.js';
|
|
|
5
5
|
import { SandboxServiceClient } from '../transport/sandbox-service-client.js';
|
|
6
6
|
import { abortReason } from '../utils/abort.js';
|
|
7
7
|
import { assertRequiredCommands, DEFAULT_REQUIRED_COMMANDS } from './required-commands.js';
|
|
8
|
-
import { ensureTemplate, runSetup } from './sandbox-template.js';
|
|
8
|
+
import { ensureTemplate, runSetup, templateId } from './sandbox-template.js';
|
|
9
9
|
/**
|
|
10
10
|
* What a Compute Engine instance name takes once the service's prefix is put before it, and a URL
|
|
11
11
|
* path as it is: the instance name is at most 63 characters and never ends with a dash.
|
|
@@ -80,14 +80,24 @@ export async function createGceNetworkSandboxSession(options) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Has the sandbox service at `url` boot what a sandbox needs,
|
|
84
|
-
* starts and stops it,
|
|
85
|
-
*
|
|
86
|
-
* the
|
|
87
|
-
*
|
|
83
|
+
* Has the sandbox service at `url` boot what a sandbox needs, without waiting for it: its egress
|
|
84
|
+
* proxy when the service starts and stops it, and, given the sandbox's `template` (with its `setup`
|
|
85
|
+
* and `image`), a machine booted from it. Call it as soon as a sandbox is likely to be asked for,
|
|
86
|
+
* the person who launches it still reading what will run, and the creation that follows finds them
|
|
87
|
+
* up. A hint: do not await it, and ignore its errors, which change nothing for the sandboxes.
|
|
88
|
+
*
|
|
89
|
+
* It never builds the template: before the first sandbox made from it, only the proxy is booted.
|
|
90
|
+
* Should no sandbox come, the proxy stops by itself, and the service deletes the machine as it
|
|
91
|
+
* meets it, once it waited 15 minutes. A service of an earlier version boots the proxy only, or
|
|
92
|
+
* nothing.
|
|
88
93
|
*/
|
|
89
94
|
export async function prepareGceSandboxService(options) {
|
|
90
|
-
|
|
95
|
+
const { template, setup = [], image, abortSignal } = options;
|
|
96
|
+
await clientOf(options).prepare({
|
|
97
|
+
template: template === undefined ? undefined : templateId({ template, setup }),
|
|
98
|
+
image,
|
|
99
|
+
abortSignal,
|
|
100
|
+
});
|
|
91
101
|
}
|
|
92
102
|
/**
|
|
93
103
|
* Reattaches to a sandbox made by {@link createGceNetworkSandboxSession}, from this process or
|
|
@@ -75,8 +75,15 @@ export declare class SandboxServiceClient {
|
|
|
75
75
|
}): Promise<void>;
|
|
76
76
|
/** Whether the template `id` exists, made on the image `image` (the service's default without). */
|
|
77
77
|
templateExists(id: string, image?: string, abortSignal?: AbortSignal): Promise<boolean>;
|
|
78
|
-
/**
|
|
79
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Boots what a sandbox needs ahead of it: a machine from the template `template` of `image` too,
|
|
80
|
+
* when given. A service without the route answers 404: it is fine.
|
|
81
|
+
*/
|
|
82
|
+
prepare({ template, image, abortSignal, }?: {
|
|
83
|
+
template?: string;
|
|
84
|
+
image?: string;
|
|
85
|
+
abortSignal?: AbortSignal;
|
|
86
|
+
}): Promise<void>;
|
|
80
87
|
deleteTemplate(id: string, image?: string): Promise<void>;
|
|
81
88
|
/**
|
|
82
89
|
* Where a port of the sandbox is reached: a WebSocket through the service. The token is read
|
|
@@ -166,9 +166,16 @@ export class SandboxServiceClient {
|
|
|
166
166
|
});
|
|
167
167
|
return response.status !== 404;
|
|
168
168
|
}
|
|
169
|
-
/**
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Boots what a sandbox needs ahead of it: a machine from the template `template` of `image` too,
|
|
171
|
+
* when given. A service without the route answers 404: it is fine.
|
|
172
|
+
*/
|
|
173
|
+
async prepare({ template, image, abortSignal, } = {}) {
|
|
174
|
+
await this.call('POST', 'v1/prepare', {
|
|
175
|
+
body: { template, image },
|
|
176
|
+
abortSignal,
|
|
177
|
+
accept: [404],
|
|
178
|
+
});
|
|
172
179
|
}
|
|
173
180
|
async deleteTemplate(id, image) {
|
|
174
181
|
await this.call('DELETE', templatePath(id, image));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { chownSync, existsSync, mkdirSync } from 'node:fs';
|
|
3
3
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
4
|
-
import { AGENT_TOKEN_METADATA_KEY, DEFAULT_AGENT_PORT } from '../protocol/agent.js';
|
|
4
|
+
import { AGENT_TOKEN_METADATA_KEY, DEFAULT_AGENT_PORT, IDLE_POWER_OFF_METADATA_KEY, } from '../protocol/agent.js';
|
|
5
5
|
const METADATA = 'http://metadata.google.internal/computeMetadata/v1/instance/attributes/';
|
|
6
6
|
/** How long the agent tries to read its token from the metadata server, as the machine boots. */
|
|
7
7
|
const METADATA_ATTEMPTS = 30;
|
|
@@ -25,6 +25,49 @@ async function metadataToken(url) {
|
|
|
25
25
|
await sleep(1000);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The minutes after its boot the machine is powered off unless configured, from its instance
|
|
30
|
+
* metadata: read once, the metadata server having just answered the token. `undefined` when the
|
|
31
|
+
* key is missing, or cannot be read: the machine then runs on, as before the key was.
|
|
32
|
+
*/
|
|
33
|
+
async function metadataIdleMinutes(url, logger) {
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(`${url}${IDLE_POWER_OFF_METADATA_KEY}`, {
|
|
36
|
+
headers: { 'metadata-flavor': 'Google' },
|
|
37
|
+
signal: AbortSignal.timeout(5000),
|
|
38
|
+
});
|
|
39
|
+
if (response.status === 404)
|
|
40
|
+
return undefined;
|
|
41
|
+
const text = (await response.text()).trim();
|
|
42
|
+
const minutes = Number(text);
|
|
43
|
+
if (response.ok && Number.isInteger(minutes) && minutes > 0)
|
|
44
|
+
return minutes;
|
|
45
|
+
logger.warn(`\`${IDLE_POWER_OFF_METADATA_KEY}\` is not a positive integer: \`${text}\`.`);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
logger.warn(`\`${IDLE_POWER_OFF_METADATA_KEY}\` could not be read: ${String(error)}`);
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The token, from the environment or else the instance metadata, and with the latter, as root, when
|
|
54
|
+
* to power the machine off unless configured.
|
|
55
|
+
*/
|
|
56
|
+
async function fromMetadata(env, logger) {
|
|
57
|
+
const given = env['SANDBOX_AGENT_TOKEN'];
|
|
58
|
+
if (given !== undefined)
|
|
59
|
+
return { token: given };
|
|
60
|
+
const url = env['METADATA_URL'] ?? METADATA;
|
|
61
|
+
const token = await metadataToken(url);
|
|
62
|
+
// Only root powers the machine off: an agent run by hand, or in tests, never does.
|
|
63
|
+
if (process.getuid?.() !== 0)
|
|
64
|
+
return { token };
|
|
65
|
+
const minutes = await metadataIdleMinutes(url, logger);
|
|
66
|
+
if (minutes === undefined)
|
|
67
|
+
return { token };
|
|
68
|
+
const runDirectory = env['SANDBOX_RUN_DIR'] ?? '/run/ai-sdk-sandbox';
|
|
69
|
+
return { token, idlePowerOff: { afterMs: minutes * 60_000, runDirectory } };
|
|
70
|
+
}
|
|
28
71
|
/** The ids of `user`, from `id`. */
|
|
29
72
|
function idsOf(user) {
|
|
30
73
|
const id = (flag) => Number(execFileSync('id', [flag, user], { encoding: 'utf8' }).trim());
|
|
@@ -61,7 +104,7 @@ export async function agentSettings(env, logger) {
|
|
|
61
104
|
chownSync(directory, commandUser.uid, commandUser.gid);
|
|
62
105
|
}
|
|
63
106
|
return {
|
|
64
|
-
|
|
107
|
+
...(await fromMetadata(env, logger)),
|
|
65
108
|
user,
|
|
66
109
|
home,
|
|
67
110
|
workingDirectory,
|
|
@@ -46,7 +46,7 @@ export function createAgentServer(settings) {
|
|
|
46
46
|
server,
|
|
47
47
|
processes: agent.processes,
|
|
48
48
|
close: async () => {
|
|
49
|
-
await agent.
|
|
49
|
+
await agent.close();
|
|
50
50
|
server.closeAllConnections();
|
|
51
51
|
await new Promise((resolve) => server.close(() => resolve()));
|
|
52
52
|
},
|
package/dist/in-vm/agent.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
2
2
|
import type { Reply } from '../common/http-reply.js';
|
|
3
3
|
import type { Logger } from '../common/logger.js';
|
|
4
4
|
import type { CommandSettings } from './environment.js';
|
|
5
|
+
import type { IdlePowerOffSettings } from './idle-power-off.js';
|
|
5
6
|
import type { CommandUser } from './processes.js';
|
|
6
7
|
import { Processes } from './processes.js';
|
|
7
8
|
/** What the agent is made with: its machine's to give. */
|
|
@@ -14,6 +15,11 @@ export interface AgentSettings extends CommandSettings {
|
|
|
14
15
|
commandUser?: CommandUser;
|
|
15
16
|
/** Whether to point Docker at the egress proxy: as root, on a machine that has it. */
|
|
16
17
|
configureDocker: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Powers the machine off when the agent is not configured soon enough after its boot: on a
|
|
20
|
+
* machine the service booted ahead of a sandbox. Never without it.
|
|
21
|
+
*/
|
|
22
|
+
idlePowerOff?: Omit<IdlePowerOffSettings, 'logger'>;
|
|
17
23
|
logger: Logger;
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
@@ -25,7 +31,10 @@ export declare class Agent {
|
|
|
25
31
|
private readonly settings;
|
|
26
32
|
readonly processes: Processes;
|
|
27
33
|
private config?;
|
|
34
|
+
private readonly idle?;
|
|
28
35
|
constructor(settings: AgentSettings);
|
|
36
|
+
/** Stops the processes and the idle watch: the agent is closing. */
|
|
37
|
+
close(): Promise<void>;
|
|
29
38
|
private get configFile();
|
|
30
39
|
/** Answers a call, or streams its own answer and replies with nothing. */
|
|
31
40
|
handle(request: IncomingMessage, response: ServerResponse, path: string): Promise<Reply | undefined>;
|
package/dist/in-vm/agent.js
CHANGED
|
@@ -8,6 +8,7 @@ import { MAX_INPUT_WRITE_BYTES } from '../protocol/api.js';
|
|
|
8
8
|
import { encodeData, encodeFrame, FrameType, STDERR, STDOUT } from '../protocol/frames.js';
|
|
9
9
|
import { configureDocker } from './docker-proxy.js';
|
|
10
10
|
import { commandEnvironment } from './environment.js';
|
|
11
|
+
import { watchIdlePowerOff } from './idle-power-off.js';
|
|
11
12
|
import { Processes } from './processes.js';
|
|
12
13
|
/** How long `GET /v1/processes/:id` waits for an exit: less than any request timeout. */
|
|
13
14
|
const WAIT_MS = 5 * 60_000;
|
|
@@ -29,9 +30,13 @@ export class Agent {
|
|
|
29
30
|
settings;
|
|
30
31
|
processes;
|
|
31
32
|
config;
|
|
33
|
+
idle;
|
|
32
34
|
constructor(settings) {
|
|
33
35
|
this.settings = settings;
|
|
34
36
|
this.processes = new Processes(settings.commandUser);
|
|
37
|
+
if (settings.idlePowerOff !== undefined) {
|
|
38
|
+
this.idle = watchIdlePowerOff({ ...settings.idlePowerOff, logger: settings.logger });
|
|
39
|
+
}
|
|
35
40
|
try {
|
|
36
41
|
this.config = toConfig(parseObject(readFileSync(this.configFile, 'utf8')));
|
|
37
42
|
}
|
|
@@ -39,6 +44,11 @@ export class Agent {
|
|
|
39
44
|
// Not configured yet: the service does so before the first command.
|
|
40
45
|
}
|
|
41
46
|
}
|
|
47
|
+
/** Stops the processes and the idle watch: the agent is closing. */
|
|
48
|
+
async close() {
|
|
49
|
+
this.idle?.stop();
|
|
50
|
+
await this.processes.killAll();
|
|
51
|
+
}
|
|
42
52
|
get configFile() {
|
|
43
53
|
return join(this.settings.stateDirectory, 'config.json');
|
|
44
54
|
}
|
|
@@ -74,6 +84,8 @@ export class Agent {
|
|
|
74
84
|
}
|
|
75
85
|
async configure(config) {
|
|
76
86
|
const { settings } = this;
|
|
87
|
+
// A sandbox took the machine: it runs on, whatever the configuration below comes to.
|
|
88
|
+
this.idle?.configured();
|
|
77
89
|
if (settings.configureDocker) {
|
|
78
90
|
await configureDocker(config, { home: settings.home, user: settings.commandUser });
|
|
79
91
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Logger } from '../common/logger.js';
|
|
2
|
+
/** What the agent powers its machine off with, should no sandbox take it. */
|
|
3
|
+
export interface IdlePowerOffSettings {
|
|
4
|
+
/** How long after the machine's boot it waits to be configured. */
|
|
5
|
+
afterMs: number;
|
|
6
|
+
/**
|
|
7
|
+
* Where the agent marks that it was configured since the machine booted: a directory emptied at
|
|
8
|
+
* each boot, `/run`'s, so that an agent restarted by systemd after the sandbox took the machine
|
|
9
|
+
* never powers it off.
|
|
10
|
+
*/
|
|
11
|
+
runDirectory: string;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
/** Powers the machine off: `systemctl poweroff` without it. Tests only. */
|
|
14
|
+
powerOff?: () => void;
|
|
15
|
+
/** How long the machine has been up: the system's uptime without it. Tests only. */
|
|
16
|
+
uptimeMs?: () => number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Powers the machine off once it ran `afterMs` since its boot without the agent being configured:
|
|
20
|
+
* a machine the service booted ahead of a sandbox that never came stops costing but its disk, and
|
|
21
|
+
* the service deletes it as it meets it. Being configured, what the service does for the sandbox
|
|
22
|
+
* that takes the machine, cancels it for the rest of the boot. Returns what marks it configured,
|
|
23
|
+
* and what stops the watch.
|
|
24
|
+
*/
|
|
25
|
+
export declare function watchIdlePowerOff({ afterMs, runDirectory, logger, powerOff, uptimeMs, }: IdlePowerOffSettings): {
|
|
26
|
+
configured(): void;
|
|
27
|
+
stop(): void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { uptime } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
/** Powers the machine off as root, through systemd: the guest halts, and Compute Engine stops it. */
|
|
6
|
+
function systemPowerOff(logger) {
|
|
7
|
+
execFile('systemctl', ['poweroff'], (error) => {
|
|
8
|
+
if (error !== null)
|
|
9
|
+
logger.error(`The machine could not be powered off: ${error.message}`);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Powers the machine off once it ran `afterMs` since its boot without the agent being configured:
|
|
14
|
+
* a machine the service booted ahead of a sandbox that never came stops costing but its disk, and
|
|
15
|
+
* the service deletes it as it meets it. Being configured, what the service does for the sandbox
|
|
16
|
+
* that takes the machine, cancels it for the rest of the boot. Returns what marks it configured,
|
|
17
|
+
* and what stops the watch.
|
|
18
|
+
*/
|
|
19
|
+
export function watchIdlePowerOff({ afterMs, runDirectory, logger, powerOff = () => systemPowerOff(logger), uptimeMs = () => uptime() * 1000, }) {
|
|
20
|
+
const marker = join(runDirectory, 'configured');
|
|
21
|
+
let timer;
|
|
22
|
+
if (!existsSync(marker)) {
|
|
23
|
+
timer = setTimeout(() => {
|
|
24
|
+
logger.info(`Not configured ${afterMs / 60_000} min after boot: powering the machine off`);
|
|
25
|
+
powerOff();
|
|
26
|
+
}, Math.max(0, afterMs - uptimeMs()));
|
|
27
|
+
timer.unref();
|
|
28
|
+
}
|
|
29
|
+
const stop = () => {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
timer = undefined;
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
configured: () => {
|
|
35
|
+
stop();
|
|
36
|
+
try {
|
|
37
|
+
mkdirSync(runDirectory, { recursive: true, mode: 0o700 });
|
|
38
|
+
writeFileSync(marker, '', { mode: 0o600 });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
logger.warn(`The configuration could not be marked in ${runDirectory}: ${String(error)}`);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
stop,
|
|
45
|
+
};
|
|
46
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { GceSandboxImageError } from './client/errors/gce-sandbox-image-error.js';
|
|
2
2
|
export { GceSandboxNotFoundError } from './client/errors/gce-sandbox-not-found-error.js';
|
|
3
3
|
export { GceSandboxServiceError } from './client/errors/gce-sandbox-service-error.js';
|
|
4
|
-
export type { GceAuth, GceConnectionSettings, GceCreationSettings, GceNetworkSandboxSessionCreateOptions, GceNetworkSandboxSessionResumeOptions, } from './client/gce-settings.js';
|
|
4
|
+
export type { GceAuth, GceConnectionSettings, GceCreationSettings, GceNetworkSandboxSessionCreateOptions, GceNetworkSandboxSessionResumeOptions, GcePrepareSettings, } from './client/gce-settings.js';
|
|
5
5
|
export { createGceNetworkSandboxSession, prepareGceSandboxService, resumeGceNetworkSandboxSession, } from './client/lifecycle/create-session.js';
|
|
6
6
|
export { GCE_SANDBOX_PROVIDER_ID } from './client/provider-id.js';
|
|
7
7
|
export { GceNetworkSandboxSession } from './client/session/gce-network-sandbox-session.js';
|
package/dist/protocol/agent.d.ts
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
export declare const AGENT_TOKEN_HEADER = "x-ai-sdk-sandbox-agent-token";
|
|
18
18
|
/** The instance metadata key the agent reads its token from, when its environment has none. */
|
|
19
19
|
export declare const AGENT_TOKEN_METADATA_KEY = "ai-sdk-sandbox-agent-token";
|
|
20
|
+
/**
|
|
21
|
+
* The instance metadata key of a machine booted ahead of a sandbox: the minutes after its boot its
|
|
22
|
+
* agent powers it off unless configured meanwhile. Never without it.
|
|
23
|
+
*/
|
|
24
|
+
export declare const IDLE_POWER_OFF_METADATA_KEY = "ai-sdk-sandbox-idle-poweroff-minutes";
|
|
20
25
|
/** The port the agent listens on, in its machine. */
|
|
21
26
|
export declare const DEFAULT_AGENT_PORT = 8100;
|
|
22
27
|
/** How a sandbox's commands reach the network: what the service tells its agent. */
|