ai-sdk-sandbox-gce 0.5.1 → 0.5.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # ai-sdk-sandbox-gce
2
2
 
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 455efc2: `deleteGceSandbox({ url, sandboxId })` deletes a sandbox by its id, its machine and its disk, without starting it: `destroy()` needs a session, which resumes a stopped sandbox, a minute of a billed machine only to delete it. A sandbox that does not exist, or no longer does, is no error. It is the `remove` of `sandboxPerSession()` of `ai-sdk-harness-sessions`.
8
+
3
9
  ## 0.5.1
4
10
 
5
11
  ### 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.5.1
138
+ VERSION=0.5.2
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")"
@@ -283,7 +283,7 @@ echo "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.co
283
283
  > /etc/apt/sources.list.d/nodesource.list
284
284
  apt-get update
285
285
  apt-get install -y nodejs
286
- npm install --global ai-sdk-sandbox-gce@0.5.1 pnpm@10
286
+ npm install --global ai-sdk-sandbox-gce@0.5.2 pnpm@10
287
287
 
288
288
  # The sandbox's user: sudo without a password, and Docker.
289
289
  useradd --create-home --shell /bin/bash agent
@@ -311,7 +311,7 @@ The agent runs as root and starts the commands as `agent`, in its own service: `
311
311
 
312
312
  ### 4. The service
313
313
 
314
- 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.5.1 --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.
314
+ 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.5.2 --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.
315
315
 
316
316
  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-`).
317
317
 
@@ -349,7 +349,7 @@ for secret in sandbox-agent-secret sandbox-proxy-token sandbox-service-token; do
349
349
  --member=serviceAccount:sandboxes@$PROJECT.iam.gserviceaccount.com --role=roles/secretmanager.secretAccessor
350
350
  done
351
351
 
352
- gcloud run deploy sandboxes --region=$REGION --image=docker.io/fpasquet/ai-sdk-sandbox-gce:0.5.1 \
352
+ gcloud run deploy sandboxes --region=$REGION --image=docker.io/fpasquet/ai-sdk-sandbox-gce:0.5.2 \
353
353
  --service-account=sandboxes@$PROJECT.iam.gserviceaccount.com \
354
354
  --network=sandboxes --subnet=service --vpc-egress=private-ranges-only \
355
355
  --no-allow-unauthenticated --min-instances=0 --timeout=3600 --concurrency=1000 \
@@ -648,6 +648,8 @@ The MCP servers that [`ai-sdk-harness-plugins`](https://ai-sdk-harness.pages.dev
648
648
 
649
649
  `fork()` lets several harness sessions run side by side in one machine, each with a bridge on its own port, as with `ai-sdk-sandbox-cloud-run`.
650
650
 
651
+ `deleteGceSandbox({ url, sandboxId })` deletes a sandbox by its id, its machine and its disk, without a session: a stopped one is deleted as it is, where `destroy()` needs a session, which resumes it, starting the machine for a minute only to delete it. A sandbox that does not exist, or no longer does, is no error. It is the `remove` of `sandboxPerSession()` of [`ai-sdk-harness-sessions`](https://ai-sdk-harness.pages.dev/docs/packages/harness-sessions#sandboxes), for the sessions closed while suspended.
652
+
651
653
  ## Options
652
654
 
653
655
  `createGceNetworkSandboxSession(options)` takes every option below; `resumeGceNetworkSandboxSession(options)` takes `sandboxId`, `abortSignal` and the connection settings.
@@ -140,6 +140,13 @@ export interface GceTemplateDeletionSettings extends GceConnectionSettings {
140
140
  /** Aborts the call. */
141
141
  abortSignal?: AbortSignal;
142
142
  }
143
+ /** Options of `deleteGceSandbox()`: the sandbox, and the service it was created through. */
144
+ export interface GceSandboxDeletionSettings extends GceConnectionSettings {
145
+ /** The id the sandbox was created with. */
146
+ sandboxId: string;
147
+ /** Aborts the call. */
148
+ abortSignal?: AbortSignal;
149
+ }
143
150
  /** Options of `createGceNetworkSandboxSession()`. */
144
151
  export type GceNetworkSandboxSessionCreateOptions = HarnessV1SandboxSessionCreateOptions<GceCreationSettings>;
145
152
  /** Options of `resumeGceNetworkSandboxSession()`. */
@@ -1,4 +1,4 @@
1
- import type { GceNetworkSandboxSessionCreateOptions, GceNetworkSandboxSessionResumeOptions, GcePrepareSettings, GceTemplateDeletionSettings } from '../gce-settings.js';
1
+ import type { GceNetworkSandboxSessionCreateOptions, GceNetworkSandboxSessionResumeOptions, GcePrepareSettings, GceSandboxDeletionSettings, GceTemplateDeletionSettings } 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
@@ -38,6 +38,14 @@ export declare function prepareGceSandboxService(options: GcePrepareSettings): P
38
38
  * template that does not exist, or no longer does, is no error.
39
39
  */
40
40
  export declare function deleteGceSandboxTemplate(options: GceTemplateDeletionSettings): Promise<void>;
41
+ /**
42
+ * Deletes the sandbox `sandboxId`, its machine and its disk, without starting it: a stopped sandbox,
43
+ * which `destroy()` of a session would first have to resume, a minute of a billed machine for
44
+ * nothing. Deleting a sandbox that does not exist, or no longer does, is no error. The
45
+ * `remove` of `sandboxPerSession()` of `ai-sdk-harness-sessions`, for the sessions closed while
46
+ * suspended.
47
+ */
48
+ export declare function deleteGceSandbox(options: GceSandboxDeletionSettings): Promise<void>;
41
49
  /**
42
50
  * Reattaches to a sandbox made by {@link createGceNetworkSandboxSession}, from this process or
43
51
  * another one: a running sandbox as it is, a stopped one started again on its disk. Never creates
@@ -112,6 +112,20 @@ export async function deleteGceSandboxTemplate(options) {
112
112
  forgetTemplate(client, source);
113
113
  await client.deleteTemplate(templateId(source), image, abortSignal);
114
114
  }
115
+ /**
116
+ * Deletes the sandbox `sandboxId`, its machine and its disk, without starting it: a stopped sandbox,
117
+ * which `destroy()` of a session would first have to resume, a minute of a billed machine for
118
+ * nothing. Deleting a sandbox that does not exist, or no longer does, is no error. The
119
+ * `remove` of `sandboxPerSession()` of `ai-sdk-harness-sessions`, for the sessions closed while
120
+ * suspended.
121
+ */
122
+ export async function deleteGceSandbox(options) {
123
+ const { sandboxId, abortSignal } = options;
124
+ if (abortSignal?.aborted)
125
+ throw abortReason(abortSignal);
126
+ assertSandboxName(sandboxId);
127
+ await clientOf(options).remove(sandboxId, abortSignal);
128
+ }
115
129
  /**
116
130
  * Reattaches to a sandbox made by {@link createGceNetworkSandboxSession}, from this process or
117
131
  * another one: a running sandbox as it is, a stopped one started again on its disk. Never creates
@@ -33,8 +33,8 @@ export declare class SandboxServiceClient {
33
33
  }): Promise<SandboxDescription | undefined>;
34
34
  /** Stops the sandbox's machine, its disk kept. */
35
35
  suspend(name: string): Promise<void>;
36
- /** Deletes the sandbox, its disk included. */
37
- remove(name: string): Promise<void>;
36
+ /** Deletes the sandbox, its disk included, running or stopped: one that does not exist is fine. */
37
+ remove(name: string, abortSignal?: AbortSignal): Promise<void>;
38
38
  /**
39
39
  * Starts `command`, `stdin` as its standard input: the response streams its output as frames,
40
40
  * and names the process in `x-process-id`.
@@ -81,9 +81,9 @@ export class SandboxServiceClient {
81
81
  async suspend(name) {
82
82
  await this.call('POST', `v1/sandboxes/${name}/suspend`);
83
83
  }
84
- /** Deletes the sandbox, its disk included. */
85
- async remove(name) {
86
- await this.call('DELETE', `v1/sandboxes/${name}`);
84
+ /** Deletes the sandbox, its disk included, running or stopped: one that does not exist is fine. */
85
+ async remove(name, abortSignal) {
86
+ await this.call('DELETE', `v1/sandboxes/${name}`, { abortSignal });
87
87
  }
88
88
  /**
89
89
  * Starts `command`, `stdin` as its standard input: the response streams its output as frames,
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
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, GcePrepareSettings, GceTemplateDeletionSettings, } from './client/gce-settings.js';
5
- export { createGceNetworkSandboxSession, deleteGceSandboxTemplate, prepareGceSandboxService, resumeGceNetworkSandboxSession, } from './client/lifecycle/create-session.js';
4
+ export type { GceAuth, GceConnectionSettings, GceCreationSettings, GceNetworkSandboxSessionCreateOptions, GceNetworkSandboxSessionResumeOptions, GcePrepareSettings, GceSandboxDeletionSettings, GceTemplateDeletionSettings, } from './client/gce-settings.js';
5
+ export { createGceNetworkSandboxSession, deleteGceSandbox, deleteGceSandboxTemplate, 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';
8
8
  export { GceSandboxSession } from './client/session/gce-sandbox-session.js';
package/dist/index.js 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 { createGceNetworkSandboxSession, deleteGceSandboxTemplate, prepareGceSandboxService, resumeGceNetworkSandboxSession, } from './client/lifecycle/create-session.js';
4
+ export { createGceNetworkSandboxSession, deleteGceSandbox, deleteGceSandboxTemplate, prepareGceSandboxService, resumeGceNetworkSandboxSession, } from './client/lifecycle/create-session.js';
5
5
  export { GCE_SANDBOX_PROVIDER_ID } from './client/provider-id.js';
6
6
  export { GceNetworkSandboxSession } from './client/session/gce-network-sandbox-session.js';
7
7
  export { GceSandboxSession } from './client/session/gce-sandbox-session.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-sdk-sandbox-gce",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
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",