operon-sandbox 0.1.0-alpha.30 → 0.1.0-alpha.31

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/README.md CHANGED
@@ -15,8 +15,10 @@ import { E2BWorkspace } from "operon-sandbox";
15
15
  const workspace = await E2BWorkspace.open({ sandbox: Sandbox, template: "node20" });
16
16
 
17
17
  const harness = createHarness({
18
- model,
19
- environment: workspace.environment, // tools now run inside the sandbox
18
+ config: { defaults: { model } },
19
+ // Every session's tools now run inside the sandbox. For a sandbox per session, hand each one
20
+ // its own instead: `createSession({ bindings: { environment } })`, or `resolveSession`.
21
+ infrastructure: () => ({ environment: workspace.environment }),
20
22
  });
21
23
 
22
24
  // … run sessions …
@@ -73,7 +73,7 @@ export declare class CloudflareEnvironment extends SandboxEnvironment {
73
73
  existOk?: boolean;
74
74
  }): Promise<void>;
75
75
  readBytes(path: string, range?: ByteRange): Promise<Buffer>;
76
- protected writeBytesRaw(path: string, data: Buffer): Promise<void>;
76
+ writeBytes(path: string, data: Buffer): Promise<void>;
77
77
  /**
78
78
  * Always `undefined` on this transport: the SDK implements tunnels over RPC only, and the
79
79
  * route transport's `tunnels` accessor throws. Saying so plainly beats inventing a URL that
@@ -251,7 +251,7 @@ export class CloudflareEnvironment extends SandboxEnvironment {
251
251
  const { content } = await this.client.files.readFile(this.resolve(path), this.sessionId, { encoding: "base64" });
252
252
  return sliceRange(Buffer.from(content, "base64"), range);
253
253
  }
254
- async writeBytesRaw(path, data) {
254
+ async writeBytes(path, data) {
255
255
  // base64 is the only binary-safe route on this transport (writeFileStream is RPC-only).
256
256
  await this.client.files.writeFile(this.resolve(path), data.toString("base64"), this.sessionId, {
257
257
  encoding: "base64",
@@ -72,7 +72,7 @@ export interface E2BFilesystemApi {
72
72
  /**
73
73
  * `data` is deliberately NOT `Uint8Array`: the SDK takes `string | ArrayBuffer | Blob |
74
74
  * ReadableStream`, so declaring the wider type here would let a `Buffer` typecheck against
75
- * a signature that rejects it. See `writeBytesRaw` for the conversion.
75
+ * a signature that rejects it. See `E2BEnvironment.writeBytes` for the conversion.
76
76
  */
77
77
  write(path: string, data: string | ArrayBuffer, opts?: Record<string, unknown>): Promise<unknown>;
78
78
  /** Creates missing parents too. `false` = the path already existed (the SDK maps AlreadyExists). */
@@ -1,4 +1,4 @@
1
- import type { DirEntry, OsInfo, FileInfo, FileVersion, Environment, ByteRange, RunCommandOptions, RunCommandResult } from "operon-agents-core";
1
+ import type { DirEntry, OsInfo, FileInfo, Environment, ByteRange, RunCommandOptions, RunCommandResult } from "operon-agents-core";
2
2
  import type { E2BSandbox, SandboxRef } from "./e2b-api.ts";
3
3
  import { SandboxEnvironment } from "../shared/sandbox-environment.ts";
4
4
  export interface E2BEnvironmentOptions {
@@ -53,13 +53,6 @@ export declare class E2BEnvironment extends SandboxEnvironment {
53
53
  fileInfo(path: string, options?: {
54
54
  followSymlinks?: boolean;
55
55
  }): Promise<FileInfo>;
56
- /**
57
- * The version a write produced, from one `getInfo` — the same source `fileInfo` reads, so the
58
- * two compare equal. Without it every E2B write left the read-state record versionless, and
59
- * the next Write had to download the file to compare contents. Symlinked targets report
60
- * nothing: their `fileInfo` comes from `stat(1)`, a different source.
61
- */
62
- protected versionAfterWrite(path: string): Promise<FileVersion | undefined>;
63
56
  /**
64
57
  * One `files.list()` round trip — the vendor listing already carries each entry's kind, so there
65
58
  * is no stat per entry. A symlink is reported as `"symlink"` (lstat semantics, per `DirEntry`)
@@ -75,7 +68,7 @@ export declare class E2BEnvironment extends SandboxEnvironment {
75
68
  existOk?: boolean;
76
69
  }): Promise<void>;
77
70
  readBytes(path: string, range?: ByteRange): Promise<Buffer>;
78
- protected writeBytesRaw(path: string, data: Buffer): Promise<void>;
71
+ writeBytes(path: string, data: Buffer): Promise<void>;
79
72
  /** Public URL for a port listening inside the sandbox (dev servers, previews). */
80
73
  exposedPortUrl(port: number, scheme?: "http" | "https"): Promise<string | undefined>;
81
74
  protected resolve(path: string): string;
@@ -216,24 +216,6 @@ export class E2BEnvironment extends SandboxEnvironment {
216
216
  ...mtimeOf(entry),
217
217
  };
218
218
  }
219
- /**
220
- * The version a write produced, from one `getInfo` — the same source `fileInfo` reads, so the
221
- * two compare equal. Without it every E2B write left the read-state record versionless, and
222
- * the next Write had to download the file to compare contents. Symlinked targets report
223
- * nothing: their `fileInfo` comes from `stat(1)`, a different source.
224
- */
225
- async versionAfterWrite(path) {
226
- const getInfo = this.sandbox.files.getInfo;
227
- if (getInfo === undefined)
228
- return undefined;
229
- try {
230
- const entry = await getInfo.call(this.sandbox.files, this.resolve(path));
231
- return entry.symlinkTarget === undefined ? mtimeOf(entry) : undefined;
232
- }
233
- catch {
234
- return undefined; // the write succeeded; this only costs the fast path
235
- }
236
- }
237
219
  /**
238
220
  * One `files.list()` round trip — the vendor listing already carries each entry's kind, so there
239
221
  * is no stat per entry. A symlink is reported as `"symlink"` (lstat semantics, per `DirEntry`)
@@ -297,7 +279,7 @@ export class E2BEnvironment extends SandboxEnvironment {
297
279
  const bytes = typeof payload === "string" ? Buffer.from(payload, "utf8") : Buffer.from(payload);
298
280
  return sliceRange(bytes, range);
299
281
  }
300
- async writeBytesRaw(path, data) {
282
+ async writeBytes(path, data) {
301
283
  await this.sandbox.files.write(this.resolve(path), toArrayBuffer(data));
302
284
  }
303
285
  /** Public URL for a port listening inside the sandbox (dev servers, previews). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "operon-sandbox",
3
- "version": "0.1.0-alpha.30",
3
+ "version": "0.1.0-alpha.31",
4
4
  "description": "Host-side sandbox lifecycle for operon-agents: create, snapshot, pause and destroy a vendor sandbox, and hand the framework an Environment driven by the vendor SDK directly (native per-command timeout, incremental output, real kill).",
5
5
  "type": "module",
6
6
  "engines": {
@@ -25,7 +25,7 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "operon-agents-core": "0.1.0-alpha.30"
28
+ "operon-agents-core": "0.1.0-alpha.31"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@cloudflare/sandbox": ">=0.12",