sandboxedjs 0.1.54 → 0.1.55

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/dist/agent.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Container } from './container-B--ykWn3.cjs';
2
- import './vfs-DzEcPbMY.cjs';
1
+ import { C as Container } from './container-CY_hS650.cjs';
2
+ import './contracts-CVgctitO.cjs';
3
3
 
4
4
  /**
5
5
  * Structural copies of the LangChain Deep Agents backend contract.
package/dist/agent.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Container } from './container-BSW6jjlq.js';
2
- import './vfs-DzEcPbMY.js';
1
+ import { C as Container } from './container-BAgb9I06.js';
2
+ import './contracts-CVgctitO.js';
3
3
 
4
4
  /**
5
5
  * Structural copies of the LangChain Deep Agents backend contract.
@@ -1,4 +1,4 @@
1
- import { V as Vfs, C as Cred, e as RuntimePod, D as DirEntry, o as Stats } from './vfs-DzEcPbMY.cjs';
1
+ import { V as Vfs, C as Cred, f as RuntimePod, D as DirEntry, p as Stats } from './contracts-CVgctitO.js';
2
2
 
3
3
  /**
4
4
  * Byte streams for stdin/stdout/stderr, pipelines and redirections.
@@ -1,4 +1,4 @@
1
- import { V as Vfs, C as Cred, e as RuntimePod, D as DirEntry, o as Stats } from './vfs-DzEcPbMY.js';
1
+ import { V as Vfs, C as Cred, f as RuntimePod, D as DirEntry, p as Stats } from './contracts-CVgctitO.cjs';
2
2
 
3
3
  /**
4
4
  * Byte streams for stdin/stdout/stderr, pipelines and redirections.
@@ -65,141 +65,6 @@ type SyncSpawn = (request: {
65
65
  };
66
66
  declare function createChildProcessModule(spawnChild: SpawnChild, defaultCwd: () => string, syncSpawn?: SyncSpawn, defaultEnv?: () => Record<string, string>): Record<string, unknown>;
67
67
 
68
- /**
69
- * Clean-room contracts between SandboxedJS and its JavaScript runtime.
70
- *
71
- * These deliberately describe only behavior SandboxedJS consumes. Runtime
72
- * implementations may use Web Workers in browsers or worker_threads on Node.
73
- */
74
-
75
- interface VolumeStats {
76
- totalBytes: number;
77
- fileCount: number;
78
- /** New runtime spelling. */
79
- directoryCount?: number;
80
- /** Compatibility spelling used by existing volume implementations. */
81
- dirCount?: number;
82
- }
83
- interface VolumeStat {
84
- mode: number;
85
- size: number;
86
- uid: number;
87
- gid: number;
88
- ino: number;
89
- nlink: number;
90
- atimeMs: number;
91
- mtimeMs: number;
92
- ctimeMs: number;
93
- birthtimeMs: number;
94
- isFile(): boolean;
95
- isDirectory(): boolean;
96
- isSymbolicLink(): boolean;
97
- }
98
- interface RuntimeVolume {
99
- readFileSync(path: string): Uint8Array;
100
- writeFileSync(path: string, data: string | Uint8Array): void;
101
- appendFileSync(path: string, data: string | Uint8Array): void;
102
- readdirSync(path: string): string[];
103
- lstatSync(path: string): VolumeStat;
104
- readlinkSync(path: string): string;
105
- mkdirSync(path: string, options?: {
106
- mode?: number;
107
- }): void;
108
- rmdirSync(path: string): void;
109
- unlinkSync(path: string): void;
110
- renameSync(from: string, to: string): void;
111
- symlinkSync(target: string, path: string): void;
112
- linkSync(existing: string, path: string): void;
113
- truncateSync(path: string, length?: number): void;
114
- chmodSync(path: string, mode: number): void;
115
- lchmodSync(path: string, mode: number): void;
116
- chownSync(path: string, uid: number, gid: number): void;
117
- lchownSync(path: string, uid: number, gid: number): void;
118
- utimesSync(path: string, atime: Date, mtime: Date): void;
119
- getStats(): VolumeStats;
120
- }
121
- interface RuntimeProcessResult {
122
- exitCode: number;
123
- stdout: string;
124
- stderr: string;
125
- }
126
- interface RuntimeProcess {
127
- readonly completion: Promise<RuntimeProcessResult>;
128
- /**
129
- * `output` and `error` carry stdout and stderr; `exit` the code. `rawmode`
130
- * reports the program turning terminal raw mode on or off, which a terminal
131
- * needs so that it stops echoing input the program is drawing itself.
132
- */
133
- on(event: "output" | "error" | "exit" | "rawmode", listener: (...args: any[]) => void): this;
134
- write(data: string): void;
135
- kill(signal?: string): void;
136
- }
137
- interface RuntimeHttpResponse {
138
- statusCode?: number;
139
- statusMessage?: string;
140
- headers?: Record<string, string>;
141
- body?: string | Uint8Array | ArrayBuffer;
142
- }
143
- interface RuntimePackageInstaller {
144
- install(name: string, version?: string, options?: Record<string, unknown>): Promise<unknown>;
145
- installFromManifest(path: string, options?: Record<string, unknown>): Promise<unknown>;
146
- /** Create a view that installs into another project root. */
147
- forCwd?(cwd: string): RuntimePackageInstaller;
148
- }
149
- /** Where bytes written by an upgraded server inside the container come out. */
150
- interface RuntimeSocketPeer {
151
- data(bytes: Uint8Array): void;
152
- close(): void;
153
- }
154
- /** The caller's end of a connection opened with {@link RuntimePod.connect}. */
155
- interface RuntimeConnection {
156
- send(bytes: Uint8Array): void;
157
- close(): void;
158
- }
159
- /** The process-manager protocol a container's kernel bridge substitutes for. */
160
- interface RuntimeProcessManager {
161
- spawn(config: ChildSpawnConfig): ChildHandle;
162
- }
163
- interface RuntimePod {
164
- readonly volume: RuntimeVolume;
165
- readonly packages: RuntimePackageInstaller;
166
- readonly instanceId: string;
167
- readonly processManager: RuntimeProcessManager;
168
- readonly proxy: {
169
- activePorts(instanceId?: string): number[];
170
- };
171
- spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;
172
- request(port: number, init?: Record<string, unknown>): Promise<RuntimeHttpResponse>;
173
- /**
174
- * Open a connection that upgrades out of HTTP, or null if nothing takes one.
175
- *
176
- * Optional because a pod that only ever answers requests is still a usable
177
- * pod — a caller treats the absence as "no WebSocket here" rather than as a
178
- * broken implementation.
179
- */
180
- connect?(port: number, init: Record<string, unknown>, peer: RuntimeSocketPeer): RuntimeConnection | null;
181
- /**
182
- * Bind a port to a server implemented outside the JavaScript runtime.
183
- *
184
- * The pod owns the port table, and a Python process cannot register with it
185
- * the way a Node server does — it has no `http.createServer`. This is the
186
- * seam that lets one exist without a second, divergent port table, so
187
- * `box.request()`, the preview router and `ss` all see the same listeners.
188
- *
189
- * Returns the function that unbinds it. Optional: a pod that cannot host
190
- * foreign servers simply does not offer one.
191
- */
192
- serveExternal?(port: number, owner: string, handler: (request: {
193
- method: string;
194
- path: string;
195
- headers: Record<string, string>;
196
- body: Uint8Array;
197
- }) => Promise<RuntimeHttpResponse>): () => void;
198
- snapshot(options?: Record<string, unknown>): unknown;
199
- restore(snapshot: unknown, options?: Record<string, unknown>): Promise<void>;
200
- teardown(): void;
201
- }
202
-
203
68
  type FileKind = "file" | "directory" | "symlink" | "chardev" | "blockdev" | "fifo" | "socket";
204
69
  /** Render as `drwxr-xr-x`, honouring setuid/setgid/sticky. */
205
70
  declare function formatMode(mode: number): string;
@@ -424,4 +289,199 @@ declare class Vfs {
424
289
  };
425
290
  }
426
291
 
427
- export { type Cred as C, type DirEntry as D, type RuntimeVolume as R, type SpawnChild as S, Vfs as V, type WriteOptions as W, type RuntimeHttpResponse as a, type SyncSpawn as b, type VolumeStat as c, type VolumeStats as d, type RuntimePod as e, type RuntimePackageInstaller as f, type ChildSpawnConfig as g, type ChildHandle as h, type RuntimeProcess as i, type RuntimeSocketPeer as j, type RuntimeConnection as k, ROOT_CRED as l, type RuntimeProcessManager as m, type RuntimeProcessResult as n, Stats as o, type VirtualNode as p, type VirtualProvider as q, applyChmod as r, createChildProcessModule as s, formatMode as t, makeCred as u, octalMode as v, parseUmask as w };
292
+ interface VirtualSocketAddress {
293
+ address: string;
294
+ port: number;
295
+ }
296
+ /** One endpoint of a host-owned in-memory TCP stream. */
297
+ declare class VirtualTcpConnection {
298
+ private readonly incoming;
299
+ private peer;
300
+ private readClosed;
301
+ private writeClosed;
302
+ private closed;
303
+ readonly local: VirtualSocketAddress;
304
+ readonly remote: VirtualSocketAddress;
305
+ constructor(local: VirtualSocketAddress, remote: VirtualSocketAddress);
306
+ pairWith(peer: VirtualTcpConnection): void;
307
+ get eof(): boolean;
308
+ get readable(): boolean;
309
+ get writable(): boolean;
310
+ read(maxLength: number): Uint8Array;
311
+ write(bytes: Uint8Array): number;
312
+ waitForChange(): Promise<void>;
313
+ shutdown(read: boolean, write: boolean): void;
314
+ close(): void;
315
+ }
316
+ interface VirtualTcpAccepted {
317
+ connection: VirtualTcpConnection;
318
+ peer: VirtualSocketAddress;
319
+ }
320
+ /** A host-owned TCP listener with a POSIX-style accept backlog. */
321
+ declare class VirtualTcpListener {
322
+ readonly port: number;
323
+ readonly address: string;
324
+ readonly backlog: number;
325
+ private readonly pending;
326
+ private readonly waiters;
327
+ private closed;
328
+ constructor(port: number, address?: string, backlog?: number);
329
+ enqueue(connection: VirtualTcpConnection): void;
330
+ accept(): VirtualTcpAccepted;
331
+ get readable(): boolean;
332
+ get isClosed(): boolean;
333
+ waitForChange(): Promise<void>;
334
+ close(): void;
335
+ private wake;
336
+ }
337
+ /** Shared port authority for all in-container TCP listeners. */
338
+ declare class VirtualTcpNetwork {
339
+ private readonly occupied?;
340
+ private readonly listeners;
341
+ constructor(occupied?: ((port: number) => boolean) | undefined);
342
+ listen(port: number, address?: string, backlog?: number): VirtualTcpListener;
343
+ close(listener: VirtualTcpListener): void;
344
+ connect(port: number, localPort?: number, localAddress?: string): VirtualTcpConnection;
345
+ hasListener(port: number): boolean;
346
+ ports(): number[];
347
+ closeAll(): void;
348
+ }
349
+
350
+ /**
351
+ * Clean-room contracts between SandboxedJS and its JavaScript runtime.
352
+ *
353
+ * These deliberately describe only behavior SandboxedJS consumes. Runtime
354
+ * implementations may use Web Workers in browsers or worker_threads on Node.
355
+ */
356
+
357
+ interface VolumeStats {
358
+ totalBytes: number;
359
+ fileCount: number;
360
+ /** New runtime spelling. */
361
+ directoryCount?: number;
362
+ /** Compatibility spelling used by existing volume implementations. */
363
+ dirCount?: number;
364
+ }
365
+ interface VolumeStat {
366
+ mode: number;
367
+ size: number;
368
+ uid: number;
369
+ gid: number;
370
+ ino: number;
371
+ nlink: number;
372
+ atimeMs: number;
373
+ mtimeMs: number;
374
+ ctimeMs: number;
375
+ birthtimeMs: number;
376
+ isFile(): boolean;
377
+ isDirectory(): boolean;
378
+ isSymbolicLink(): boolean;
379
+ }
380
+ interface RuntimeVolume {
381
+ readFileSync(path: string): Uint8Array;
382
+ writeFileSync(path: string, data: string | Uint8Array): void;
383
+ appendFileSync(path: string, data: string | Uint8Array): void;
384
+ readdirSync(path: string): string[];
385
+ lstatSync(path: string): VolumeStat;
386
+ readlinkSync(path: string): string;
387
+ mkdirSync(path: string, options?: {
388
+ mode?: number;
389
+ }): void;
390
+ rmdirSync(path: string): void;
391
+ unlinkSync(path: string): void;
392
+ renameSync(from: string, to: string): void;
393
+ symlinkSync(target: string, path: string): void;
394
+ linkSync(existing: string, path: string): void;
395
+ truncateSync(path: string, length?: number): void;
396
+ chmodSync(path: string, mode: number): void;
397
+ lchmodSync(path: string, mode: number): void;
398
+ chownSync(path: string, uid: number, gid: number): void;
399
+ lchownSync(path: string, uid: number, gid: number): void;
400
+ utimesSync(path: string, atime: Date, mtime: Date): void;
401
+ getStats(): VolumeStats;
402
+ }
403
+ interface RuntimeProcessResult {
404
+ exitCode: number;
405
+ stdout: string;
406
+ stderr: string;
407
+ }
408
+ interface RuntimeProcess {
409
+ readonly completion: Promise<RuntimeProcessResult>;
410
+ /**
411
+ * `output` and `error` carry stdout and stderr; `exit` the code. `rawmode`
412
+ * reports the program turning terminal raw mode on or off, which a terminal
413
+ * needs so that it stops echoing input the program is drawing itself.
414
+ */
415
+ on(event: "output" | "error" | "exit" | "rawmode", listener: (...args: any[]) => void): this;
416
+ write(data: string): void;
417
+ kill(signal?: string): void;
418
+ }
419
+ interface RuntimeHttpResponse {
420
+ statusCode?: number;
421
+ statusMessage?: string;
422
+ headers?: Record<string, string>;
423
+ body?: string | Uint8Array | ArrayBuffer;
424
+ }
425
+ interface RuntimePackageInstaller {
426
+ install(name: string, version?: string, options?: Record<string, unknown>): Promise<unknown>;
427
+ installFromManifest(path: string, options?: Record<string, unknown>): Promise<unknown>;
428
+ /** Create a view that installs into another project root. */
429
+ forCwd?(cwd: string): RuntimePackageInstaller;
430
+ }
431
+ /** Where bytes written by an upgraded server inside the container come out. */
432
+ interface RuntimeSocketPeer {
433
+ data(bytes: Uint8Array): void;
434
+ close(): void;
435
+ }
436
+ /** The caller's end of a connection opened with {@link RuntimePod.connect}. */
437
+ interface RuntimeConnection {
438
+ send(bytes: Uint8Array): void;
439
+ close(): void;
440
+ }
441
+ /** The process-manager protocol a container's kernel bridge substitutes for. */
442
+ interface RuntimeProcessManager {
443
+ spawn(config: ChildSpawnConfig): ChildHandle;
444
+ }
445
+ interface RuntimePod {
446
+ readonly volume: RuntimeVolume;
447
+ readonly packages: RuntimePackageInstaller;
448
+ readonly instanceId: string;
449
+ readonly processManager: RuntimeProcessManager;
450
+ /** Shared host-owned TCP authority used by Node and Python servers. */
451
+ readonly sockets?: VirtualTcpNetwork;
452
+ readonly proxy: {
453
+ activePorts(instanceId?: string): number[];
454
+ };
455
+ spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;
456
+ request(port: number, init?: Record<string, unknown>): Promise<RuntimeHttpResponse>;
457
+ /**
458
+ * Open a connection that upgrades out of HTTP, or null if nothing takes one.
459
+ *
460
+ * Optional because a pod that only ever answers requests is still a usable
461
+ * pod — a caller treats the absence as "no WebSocket here" rather than as a
462
+ * broken implementation.
463
+ */
464
+ connect?(port: number, init: Record<string, unknown>, peer: RuntimeSocketPeer): RuntimeConnection | null;
465
+ /**
466
+ * Bind a port to a server implemented outside the JavaScript runtime.
467
+ *
468
+ * The pod owns the port table, and a Python process cannot register with it
469
+ * the way a Node server does — it has no `http.createServer`. This is the
470
+ * seam that lets one exist without a second, divergent port table, so
471
+ * `box.request()`, the preview router and `ss` all see the same listeners.
472
+ *
473
+ * Returns the function that unbinds it. Optional: a pod that cannot host
474
+ * foreign servers simply does not offer one.
475
+ */
476
+ serveExternal?(port: number, owner: string, handler: (request: {
477
+ method: string;
478
+ path: string;
479
+ headers: Record<string, string>;
480
+ body: Uint8Array;
481
+ }) => Promise<RuntimeHttpResponse>): () => void;
482
+ snapshot(options?: Record<string, unknown>): unknown;
483
+ restore(snapshot: unknown, options?: Record<string, unknown>): Promise<void>;
484
+ teardown(): void;
485
+ }
486
+
487
+ export { type Cred as C, type DirEntry as D, type RuntimeVolume as R, type SpawnChild as S, Vfs as V, type WriteOptions as W, VirtualTcpNetwork as a, type RuntimeHttpResponse as b, type SyncSpawn as c, type VolumeStat as d, type VolumeStats as e, type RuntimePod as f, type RuntimePackageInstaller as g, type ChildSpawnConfig as h, type ChildHandle as i, type RuntimeProcess as j, type RuntimeSocketPeer as k, type RuntimeConnection as l, ROOT_CRED as m, type RuntimeProcessManager as n, type RuntimeProcessResult as o, Stats as p, type VirtualNode as q, type VirtualProvider as r, applyChmod as s, createChildProcessModule as t, formatMode as u, makeCred as v, octalMode as w, parseUmask as x };