ai-sdk-sandbox-gce 0.1.0 → 0.1.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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# ai-sdk-sandbox-gce
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f37b21: Follow the `spawn()` of `@ai-sdk/provider-utils` 5.0.70, which a sandbox session had to implement to type-check with it. `spawn({ command, stdin: true })` hands back a process with a writable `stdin`, whose close is the end of the command's input, in a Docker Sandbox, a microsandbox and an srt sandbox; without `stdin`, standard input stays closed and the process has no `stdin`. A Cloud Run or Compute Engine sandbox refuses `stdin: true` before the command starts, as the contract asks of a sandbox without it: their service carries no input to a process yet.
|
|
8
|
+
|
|
3
9
|
## 0.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -642,6 +642,7 @@ The steps above set up the network, the proxy and the service as they ran on Goo
|
|
|
642
642
|
- **32 MiB per request.** Cloud Run limits HTTP/1 request bodies: a larger file cannot be written in one call.
|
|
643
643
|
- **A process's output stops after an hour**, the request timeout of the service. Its exit code is still found.
|
|
644
644
|
- **One bridge per port.** Run one harness session at a time per sandbox view, and give each session a view of its own with `fork()`.
|
|
645
|
+
- **No writable stdin.** `spawn({ stdin: true })` is refused before the command starts: the service carries no input to a process. Write the input to a file first, or pipe it in the command.
|
|
645
646
|
|
|
646
647
|
## Development
|
|
647
648
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Experimental_SandboxSession as SandboxSession, Experimental_SandboxSpawnOptions as SpawnOptions } from '@ai-sdk/provider-utils';
|
|
2
2
|
import type { SandboxServiceClient } from '../transport/sandbox-service-client.js';
|
|
3
|
-
type ProcessOptions = Parameters<SandboxSession['spawn']>[0];
|
|
4
3
|
type ReadOptions = Parameters<SandboxSession['readFile']>[0];
|
|
5
4
|
type ReadTextOptions = Parameters<SandboxSession['readTextFile']>[0];
|
|
6
5
|
type WriteOptions = Parameters<SandboxSession['writeFile']>[0];
|
|
@@ -25,12 +24,12 @@ export declare class GceSandboxSession implements SandboxSession {
|
|
|
25
24
|
protected readonly handle: GceSandboxHandle;
|
|
26
25
|
constructor(handle: GceSandboxHandle);
|
|
27
26
|
get description(): string;
|
|
28
|
-
run: (options:
|
|
27
|
+
run: (options: SpawnOptions) => Promise<{
|
|
29
28
|
exitCode: number;
|
|
30
29
|
stderr: string;
|
|
31
30
|
stdout: string;
|
|
32
31
|
}>;
|
|
33
|
-
spawn:
|
|
32
|
+
spawn: SandboxSession["spawn"];
|
|
34
33
|
readBinaryFile: ({ path, abortSignal }: ReadOptions) => Promise<null | Uint8Array>;
|
|
35
34
|
readFile: (options: ReadOptions) => Promise<null | ReadableStream<Uint8Array>>;
|
|
36
35
|
readTextFile: ({ encoding, startLine, endLine, ...options }: ReadTextOptions) => Promise<null | string>;
|
|
@@ -70,9 +70,14 @@ export class GceSandboxSession {
|
|
|
70
70
|
]);
|
|
71
71
|
return { exitCode, stdout, stderr };
|
|
72
72
|
};
|
|
73
|
-
spawn
|
|
73
|
+
// The overloads of `spawn` promise a writable stdin when `stdin` is `true`: the protocol of the
|
|
74
|
+
// service carries none yet, so such a call is refused before the command starts.
|
|
75
|
+
spawn = (async ({ command, workingDirectory, env = {}, abortSignal, stdin = false, }) => {
|
|
74
76
|
if (abortSignal?.aborted)
|
|
75
77
|
throw abortReason(abortSignal);
|
|
78
|
+
if (stdin) {
|
|
79
|
+
throw new Error('A Compute Engine sandbox does not give a process a writable stdin yet: spawn it without `stdin`.');
|
|
80
|
+
}
|
|
76
81
|
const invalid = Object.keys(env).find((name) => !ENV_NAME.test(name));
|
|
77
82
|
if (invalid !== undefined)
|
|
78
83
|
throw new Error(`Not an environment variable name: ${invalid}`);
|
|
@@ -83,7 +88,7 @@ export class GceSandboxSession {
|
|
|
83
88
|
const id = response.headers.get('x-process-id') ?? '';
|
|
84
89
|
processes.add(id);
|
|
85
90
|
return this.attach(response, id, abortSignal);
|
|
86
|
-
};
|
|
91
|
+
});
|
|
87
92
|
readBinaryFile = async ({ path, abortSignal }) => {
|
|
88
93
|
const target = this.resolve(path);
|
|
89
94
|
const { exitCode, stdout, stderr } = await this.exec(script(READ, target), { abortSignal });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-sdk-sandbox-gce",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.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",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@ai-sdk/harness": "^1.0.153",
|
|
54
|
-
"@ai-sdk/provider-utils": "^5.0.
|
|
54
|
+
"@ai-sdk/provider-utils": "^5.0.70",
|
|
55
55
|
"@types/node": "^24.19.2",
|
|
56
56
|
"@vitest/coverage-v8": "^5.0.5",
|
|
57
57
|
"typescript": "^6.0.3",
|