withruntime 0.11.2 → 0.12.0

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.
Files changed (164) hide show
  1. package/BLAXEL.md +2 -2
  2. package/COMPATIBILITY.md +74 -9
  3. package/DAYTONA.md +33 -5
  4. package/E2B.md +85 -24
  5. package/README.md +9 -8
  6. package/README.src.md +8 -7
  7. package/VERCEL.md +43 -5
  8. package/compatibility-lock.json +58 -49
  9. package/dist/billing-cli.d.ts +1 -1
  10. package/dist/billing-cli.js +77 -1
  11. package/dist/blaxel/errors.d.ts +14 -0
  12. package/dist/blaxel/errors.js +29 -0
  13. package/dist/blaxel/index.d.ts +2 -2
  14. package/dist/blaxel/index.js +4 -4
  15. package/dist/blaxel/interpreter.d.ts +2 -5
  16. package/dist/blaxel/sandbox.d.ts +14 -5
  17. package/dist/blaxel/sandbox.js +63 -7
  18. package/dist/blaxel/snapshot.d.ts +4 -0
  19. package/dist/blaxel/snapshot.js +4 -0
  20. package/dist/cli/logs.d.ts +21 -0
  21. package/dist/cli/logs.js +188 -0
  22. package/dist/cli/logs.test.d.ts +1 -0
  23. package/dist/cli/logs.test.js +272 -0
  24. package/dist/cli-extras.d.ts +3 -3
  25. package/dist/cli-extras.js +17 -12
  26. package/dist/cli-words.d.ts +10 -1
  27. package/dist/cli-words.js +18 -0
  28. package/dist/cli.d.ts +5 -1
  29. package/dist/cli.js +405 -204
  30. package/dist/client.d.ts +2 -4
  31. package/dist/client.js +27 -11
  32. package/dist/cloudflare/errors.d.ts +143 -0
  33. package/dist/cloudflare/errors.js +167 -0
  34. package/dist/cloudflare/index.d.ts +175 -6
  35. package/dist/cloudflare/index.js +416 -26
  36. package/dist/cloudflare/interpreter.d.ts +119 -0
  37. package/dist/cloudflare/interpreter.js +223 -0
  38. package/dist/cloudflare/streams.d.ts +38 -0
  39. package/dist/cloudflare/streams.js +145 -0
  40. package/dist/cloudflare/watch.d.ts +9 -0
  41. package/dist/cloudflare/watch.js +24 -0
  42. package/dist/codesandbox/index.d.ts +216 -28
  43. package/dist/codesandbox/index.js +478 -78
  44. package/dist/compat/core.d.ts +18 -0
  45. package/dist/compat/core.js +29 -0
  46. package/dist/compat/files.d.ts +1 -0
  47. package/dist/compat/files.js +25 -5
  48. package/dist/daytona/computer-use.d.ts +13 -4
  49. package/dist/daytona/computer-use.js +66 -8
  50. package/dist/daytona/daytona.d.ts +6 -0
  51. package/dist/daytona/daytona.js +30 -3
  52. package/dist/daytona/errors.d.ts +11 -0
  53. package/dist/daytona/errors.js +18 -0
  54. package/dist/daytona/filesystem.js +2 -1
  55. package/dist/daytona/image.d.ts +13 -9
  56. package/dist/daytona/image.js +18 -12
  57. package/dist/daytona/index.d.ts +1 -1
  58. package/dist/daytona/sandbox.d.ts +8 -2
  59. package/dist/daytona/sandbox.js +16 -2
  60. package/dist/domains/index.d.ts +9 -0
  61. package/dist/domains/index.js +10 -0
  62. package/dist/e2b/commands.d.ts +1 -1
  63. package/dist/e2b/commands.js +6 -7
  64. package/dist/e2b/errors.d.ts +17 -0
  65. package/dist/e2b/errors.js +40 -1
  66. package/dist/e2b/index.d.ts +2 -2
  67. package/dist/e2b/index.js +1 -1
  68. package/dist/e2b/sandbox.d.ts +27 -21
  69. package/dist/e2b/sandbox.js +34 -8
  70. package/dist/e2b/unsupported.js +1 -1
  71. package/dist/errors.d.ts +10 -1
  72. package/dist/errors.js +16 -4
  73. package/dist/freestyle/index.d.ts +285 -37
  74. package/dist/freestyle/index.js +656 -144
  75. package/dist/identity.d.ts +3 -0
  76. package/dist/identity.js +27 -0
  77. package/dist/images/index.d.ts +9 -0
  78. package/dist/images/index.js +10 -0
  79. package/dist/index.d.ts +1 -0
  80. package/dist/ips/index.d.ts +9 -0
  81. package/dist/ips/index.js +10 -0
  82. package/dist/jobs/index.d.ts +9 -0
  83. package/dist/jobs/index.js +10 -0
  84. package/dist/keys.js +2 -0
  85. package/dist/login.js +2 -0
  86. package/dist/machine.d.ts +12 -3
  87. package/dist/machine.js +20 -3
  88. package/dist/mcp.js +1 -1
  89. package/dist/modal/index.d.ts +339 -61
  90. package/dist/modal/index.js +781 -121
  91. package/dist/network-cli.d.ts +3 -1
  92. package/dist/network-cli.js +78 -36
  93. package/dist/networks/index.d.ts +11 -0
  94. package/dist/networks/index.js +10 -0
  95. package/dist/ports/index.d.ts +9 -0
  96. package/dist/ports/index.js +10 -0
  97. package/dist/product-names.d.ts +52 -0
  98. package/dist/product-names.js +164 -0
  99. package/dist/product-renames.d.ts +103 -0
  100. package/dist/product-renames.js +189 -0
  101. package/dist/products/apps.d.ts +176 -0
  102. package/dist/products/apps.js +165 -0
  103. package/dist/products/billing.d.ts +41 -0
  104. package/dist/products/billing.js +13 -0
  105. package/dist/products/browser.d.ts +10 -0
  106. package/dist/products/browsers.d.ts +71 -0
  107. package/dist/products/browsers.js +102 -0
  108. package/dist/products/builds.d.ts +126 -0
  109. package/dist/products/builds.js +221 -0
  110. package/dist/products/index.d.ts +3 -16
  111. package/dist/products/index.js +3 -14
  112. package/dist/products/jobs.d.ts +17 -0
  113. package/dist/products/jobs.js +27 -10
  114. package/dist/products/logs.d.ts +245 -0
  115. package/dist/products/logs.js +274 -0
  116. package/dist/products/logs.test.d.ts +1 -0
  117. package/dist/products/logs.test.js +343 -0
  118. package/dist/products/network-products.d.ts +38 -7
  119. package/dist/products/network-products.js +31 -18
  120. package/dist/products/observability.d.ts +3 -2
  121. package/dist/products/private-network.js +1 -1
  122. package/dist/products/queues.d.ts +149 -0
  123. package/dist/products/queues.js +213 -0
  124. package/dist/products/referrals.d.ts +21 -7
  125. package/dist/products/referrals.js +3 -3
  126. package/dist/products/secrets.d.ts +7 -3
  127. package/dist/products/secrets.js +39 -18
  128. package/dist/products/signed-requests.d.ts +21 -0
  129. package/dist/products/signed-requests.js +11 -0
  130. package/dist/products/streams.d.ts +73 -0
  131. package/dist/products/streams.js +17 -0
  132. package/dist/products/switching.d.ts +35 -7
  133. package/dist/products/switching.js +4 -3
  134. package/dist/products/volumes.d.ts +3 -0
  135. package/dist/record-cli.d.ts +23 -0
  136. package/dist/record-cli.js +308 -0
  137. package/dist/renamed-products.d.ts +38 -0
  138. package/dist/renamed-products.js +34 -0
  139. package/dist/runloop/index.d.ts +9 -2
  140. package/dist/runloop/index.js +29 -8
  141. package/dist/runloop/sdk.d.ts +131 -0
  142. package/dist/runloop/sdk.js +167 -0
  143. package/dist/sandbox.d.ts +3 -2
  144. package/dist/sandbox.js +14 -9
  145. package/dist/sandboxes/index.d.ts +11 -0
  146. package/dist/sandboxes/index.js +12 -0
  147. package/dist/snapshots/index.d.ts +9 -0
  148. package/dist/snapshots/index.js +11 -0
  149. package/dist/snapshots.d.ts +7 -4
  150. package/dist/sprites/index.d.ts +343 -31
  151. package/dist/sprites/index.js +866 -84
  152. package/dist/ssh.d.ts +1 -1
  153. package/dist/ssh.js +11 -11
  154. package/dist/terminal.d.ts +24 -0
  155. package/dist/terminal.js +32 -0
  156. package/dist/transport.d.ts +15 -1
  157. package/dist/transport.js +56 -3
  158. package/dist/tunnel.js +1 -1
  159. package/dist/types.d.ts +63 -0
  160. package/dist/vercel/sandbox.js +5 -3
  161. package/dist/vercel/snapshot.js +10 -2
  162. package/dist/volumes/index.d.ts +9 -0
  163. package/dist/volumes/index.js +10 -0
  164. package/package.json +48 -2
@@ -2,8 +2,173 @@ import { EventEmitter } from "node:events";
2
2
  import { PassThrough, Writable } from "node:stream";
3
3
  import type { Runtime } from "../client.js";
4
4
  import type { Sandbox } from "../sandbox.js";
5
- import { CompatibilityError, type ClientOptions as RuntimeClientOptions } from "../compat/core.js";
5
+ import { CompatibilityError, type ClientOptions as RuntimeClientOptions, type Refused, type RefusedAsync } from "../compat/core.js";
6
6
  export { CompatibilityError };
7
+ export declare const ERR_CODE_CREATION_RATE_LIMITED = "sprite_creation_rate_limited";
8
+ export declare const ERR_CODE_CONCURRENT_LIMIT_EXCEEDED = "concurrent_sprite_limit_exceeded";
9
+ export interface URLSettings {
10
+ auth?: string;
11
+ privateAccess?: "admins" | "org_users";
12
+ }
13
+ export interface Checkpoint {
14
+ id: string;
15
+ createTime: Date;
16
+ comment?: string;
17
+ history?: string[];
18
+ isAuto?: boolean;
19
+ sourceId?: string;
20
+ health?: string;
21
+ }
22
+ export interface StreamMessage {
23
+ type: "info" | "stdout" | "stderr" | "error" | "complete";
24
+ data?: string;
25
+ error?: string;
26
+ }
27
+ export interface PortMapping {
28
+ localPort: number;
29
+ remotePort: number;
30
+ remoteHost?: string;
31
+ }
32
+ export interface PolicyRule {
33
+ domain?: string;
34
+ action?: "allow" | "deny";
35
+ include?: string;
36
+ }
37
+ export interface NetworkPolicy {
38
+ rules: PolicyRule[];
39
+ }
40
+ export interface PrivilegesPolicy {
41
+ profile?: "" | "minimal" | "standard" | "privileged";
42
+ devices?: string[];
43
+ noNewPrivileges?: boolean;
44
+ }
45
+ export interface ResourcesPolicy {
46
+ memory?: {
47
+ limitMB: number;
48
+ autoscale?: boolean;
49
+ };
50
+ }
51
+ export interface ServiceRequest {
52
+ cmd: string;
53
+ args?: string[];
54
+ env?: Record<string, string>;
55
+ dir?: string;
56
+ needs?: string[];
57
+ httpPort?: number;
58
+ }
59
+ export interface ServiceLogEvent {
60
+ type: "stdout" | "stderr" | "exit" | "error" | "complete" | "started" | "stopping" | "stopped";
61
+ data?: string;
62
+ exitCode?: number;
63
+ timestamp: number;
64
+ logFiles?: Record<string, string>;
65
+ }
66
+ export interface SessionKillEvent {
67
+ type: "signal" | "timeout" | "exited" | "killed" | "error" | "complete";
68
+ message?: string;
69
+ signal?: string;
70
+ pid?: number;
71
+ exitCode?: number;
72
+ }
73
+ export interface SpriteCheck {
74
+ spriteName: string;
75
+ spriteId: string;
76
+ status: string;
77
+ reason?: string;
78
+ checkedAt: Date;
79
+ elapsed?: number;
80
+ }
81
+ export interface SpriteStateEvent {
82
+ type?: "heartbeat";
83
+ name?: string;
84
+ status?: string;
85
+ organization: {
86
+ running: number;
87
+ warm: number;
88
+ cold: number;
89
+ };
90
+ }
91
+ export interface PortNotification {
92
+ type: "port_opened" | "port_closed";
93
+ port: number;
94
+ address: string;
95
+ pid: number;
96
+ }
97
+ export interface PortList {
98
+ type: "port_list";
99
+ ports: PortNotification[];
100
+ }
101
+ export type PortWatchEvent = PortList | PortNotification;
102
+ export interface FilesystemWatchEvent {
103
+ type: "subscribed" | "event" | "error";
104
+ paths?: string[];
105
+ path?: string;
106
+ event?: "write" | "create" | "remove" | "rename" | "chmod";
107
+ timestamp?: string;
108
+ size?: number;
109
+ isDir?: boolean;
110
+ message?: string;
111
+ }
112
+ /** A Sprites progress or event stream: the work behind it runs whether or
113
+ * not anyone reads, as the vendor's server-side operation does; `next()`
114
+ * answers null at the end, `close()` stops reading (and stops a watch). */
115
+ declare class Feed<T> {
116
+ #private;
117
+ constructor(source?: AsyncIterable<T>);
118
+ protected push(item: T): void;
119
+ protected end(error?: unknown): void;
120
+ /** Called once by close(); a watch stops its native watch here. */
121
+ protected stop(): void;
122
+ next(): Promise<T | null>;
123
+ processAll(handler: (item: T) => void | Promise<void>): Promise<void>;
124
+ close(): void;
125
+ isClosed(): boolean;
126
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
127
+ }
128
+ export declare class CheckpointStream extends Feed<StreamMessage> {
129
+ }
130
+ export declare class RestoreStream extends Feed<StreamMessage> {
131
+ }
132
+ export declare class ServiceLogStream extends Feed<ServiceLogEvent> {
133
+ }
134
+ export declare class SessionKillStream extends Feed<SessionKillEvent> {
135
+ }
136
+ export declare class SpriteListStream extends Feed<SpriteStateEvent> {
137
+ }
138
+ export declare class APIError extends Error {
139
+ readonly errorCode?: string;
140
+ readonly statusCode?: number;
141
+ readonly limit?: number;
142
+ readonly windowSeconds?: number;
143
+ readonly retryAfterSeconds?: number;
144
+ readonly currentCount?: number;
145
+ readonly upgradeAvailable?: boolean;
146
+ readonly upgradeUrl?: string;
147
+ readonly retryAfterHeader?: number;
148
+ readonly rateLimitLimit?: number;
149
+ readonly rateLimitRemaining?: number;
150
+ readonly rateLimitReset?: number;
151
+ constructor(message: string, options?: {
152
+ errorCode?: string;
153
+ statusCode?: number;
154
+ limit?: number;
155
+ windowSeconds?: number;
156
+ retryAfterSeconds?: number;
157
+ currentCount?: number;
158
+ upgradeAvailable?: boolean;
159
+ upgradeUrl?: string;
160
+ retryAfterHeader?: number;
161
+ rateLimitLimit?: number;
162
+ rateLimitRemaining?: number;
163
+ rateLimitReset?: number;
164
+ });
165
+ isRateLimitError(): boolean;
166
+ isCreationRateLimited(): boolean;
167
+ isConcurrentLimitExceeded(): boolean;
168
+ getRetryAfterSeconds(): number | undefined;
169
+ }
170
+ /** The vendor's parser, for callers that read Sprites-shaped answers themselves. */
171
+ export declare function parseAPIError(statusCode: number, body: string | undefined, headers?: Record<string, string>): APIError | undefined;
7
172
  export interface ClientOptions extends RuntimeClientOptions {
8
173
  baseURL?: string;
9
174
  timeout?: number;
@@ -68,13 +233,45 @@ export interface ReaddirOptions {
68
233
  encoding?: BufferEncoding;
69
234
  }
70
235
  export declare class ExecError extends Error {
71
- readonly exitCode: number;
72
- readonly stdout: string | Buffer;
73
- readonly stderr: string | Buffer;
74
- constructor(message: string, exitCode: number, stdout: string | Buffer, stderr: string | Buffer);
236
+ readonly result: ExecResult;
237
+ constructor(message: string, result: ExecResult);
238
+ get exitCode(): number;
239
+ get stdout(): string | Buffer;
240
+ get stderr(): string | Buffer;
241
+ }
242
+ export declare class OpConn extends EventEmitter {
243
+ readonly write: Refused;
244
+ readonly sendEOF: Refused;
245
+ readonly resize: Refused;
246
+ readonly signal: Refused;
247
+ readonly handleData: Refused;
248
+ readonly handleText: Refused;
249
+ readonly complete: Refused;
250
+ readonly close: Refused;
251
+ readonly isClosed: Refused;
252
+ readonly getExitCode: Refused;
253
+ readonly wait: RefusedAsync;
254
+ }
255
+ export declare class ControlConnection extends EventEmitter {
256
+ readonly isActive: Refused;
257
+ readonly setActive: Refused;
258
+ readonly clearOpConn: Refused;
259
+ readonly connect: RefusedAsync;
260
+ readonly startOp: RefusedAsync;
261
+ readonly sendData: Refused;
262
+ readonly close: Refused;
263
+ readonly isClosed: Refused;
75
264
  }
76
265
  export declare class SpritesClient {
77
266
  readonly runtime: Runtime;
267
+ /** The Runtime API the calls go to. */
268
+ readonly baseURL: string;
269
+ /** The Runtime key given, if any; otherwise RUNTIME_API_KEY or the saved login is used. */
270
+ readonly token: string;
271
+ /** Always false: true is refused (control mode). */
272
+ readonly controlMode = false;
273
+ static readonly createToken: RefusedAsync;
274
+ readonly watchSprites: RefusedAsync;
78
275
  constructor(token?: string, options?: ClientOptions);
79
276
  sprite(name: string): Sprite;
80
277
  createSprite(name: string, input?: SpriteConfig | CreateSpriteOptions, extra?: Omit<CreateSpriteOptions, "config">): Promise<Sprite>;
@@ -108,28 +305,71 @@ export declare class SpritesClient {
108
305
  machineId: string;
109
306
  message: string;
110
307
  }>;
308
+ /** Its state as Runtime reports it now; `elapsed` is the lookup's milliseconds. */
309
+ checkSprite(name: string): Promise<SpriteCheck>;
310
+ /** Runtime keeps each sandbox's system current itself, so there is nothing
311
+ * to move to: this checks that the Sprite exists, as the vendor's call does. */
312
+ upgradeSprite(name: string): Promise<void>;
313
+ updateSprite(name: string, options: {
314
+ urlSettings?: URLSettings;
315
+ labels?: string[];
316
+ }): Promise<Sprite>;
111
317
  updateURLSettings(name: string, settings: {
112
318
  auth?: string;
113
319
  privateAccess?: string;
114
320
  }): Promise<void>;
115
321
  }
116
322
  export declare class Sprite {
323
+ #private;
117
324
  readonly name: string;
118
325
  readonly client: SpritesClient;
119
326
  id?: string;
327
+ /** Runtime does not send the organization's name with a sandbox. */
328
+ organizationName?: string;
120
329
  status?: string;
121
330
  config?: SpriteConfig;
331
+ /** Set by createSprite; Runtime keeps it in the sandbox, not in its listing. */
332
+ environment?: Record<string, string>;
122
333
  createdAt?: Date;
123
334
  updatedAt?: Date;
124
335
  url?: string;
336
+ urlSettings?: URLSettings;
337
+ /** Vendor storage and version fields; Runtime has no equivalent to report. */
338
+ bucketName?: string;
339
+ primaryRegion?: string;
340
+ version?: string;
341
+ environmentVersion?: string;
125
342
  labels: string[];
343
+ lastRunningAt?: Date;
344
+ lastWarmingAt?: Date;
345
+ readonly restoreCheckpoint: RefusedAsync;
346
+ readonly getControlConnection: RefusedAsync;
347
+ readonly listServices: RefusedAsync;
348
+ readonly getService: RefusedAsync;
349
+ readonly createService: RefusedAsync;
350
+ readonly deleteService: RefusedAsync;
351
+ readonly startService: RefusedAsync;
352
+ readonly stopService: RefusedAsync;
353
+ readonly restartService: RefusedAsync;
354
+ readonly getServiceLogs: RefusedAsync;
355
+ readonly signalService: RefusedAsync;
356
+ readonly getPrivilegesPolicy: RefusedAsync;
357
+ readonly updatePrivilegesPolicy: RefusedAsync;
358
+ readonly deletePrivilegesPolicy: RefusedAsync;
359
+ readonly getResourcesPolicy: RefusedAsync;
360
+ readonly updateResourcesPolicy: RefusedAsync;
361
+ readonly deleteResourcesPolicy: RefusedAsync;
126
362
  constructor(name: string, client: SpritesClient);
127
363
  hydrate(s: Sandbox): void;
128
364
  native(): Promise<Sandbox>;
129
365
  spawn(command: string, args?: string[], options?: SpawnOptions): SpriteCommand;
130
366
  exec(command: string, options?: ExecOptions): Promise<ExecResult>;
131
367
  execFile(file: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
132
- execFileHTTP(file: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
368
+ /** Runtime's commands are HTTP calls already; `input` is written to stdin
369
+ * and stdin closed, and without it stdin is closed at once. */
370
+ execFileHTTP(file: string, args?: string[], options?: Omit<ExecOptions, "tty" | "sessionId" | "controlMode" | "detachable"> & {
371
+ input?: string | Buffer;
372
+ }): Promise<ExecResult>;
133
373
  createSession(command: string, args?: string[], options?: SpawnOptions): SpriteCommand;
134
374
  attachSession(sessionId: string, options?: SpawnOptions): SpriteCommand;
135
375
  listSessions(): Promise<{
@@ -148,9 +388,34 @@ export declare class Sprite {
148
388
  message: string;
149
389
  }>;
150
390
  filesystem(workingDir?: string): SpriteFilesystem;
151
- createCheckpoint(_comment?: string): Promise<never>;
152
- listCheckpoints(): Promise<never>;
153
- getCheckpoint(_id: string): Promise<never>;
391
+ /** Ends a session: `signal` (SIGTERM by default; "TERM" works too), then
392
+ * SIGKILL if it has not exited within `timeout` ("10s" by default). */
393
+ killSession(sessionId: string, signal?: string, timeout?: string): Promise<SessionKillStream>;
394
+ /** Ports listening in the Sprite now, then each one opened or closed. */
395
+ watchPorts(): Promise<PortWatcher>;
396
+ /** Runtime keeps each sandbox's system current itself; this checks it exists. */
397
+ upgrade(): Promise<void>;
398
+ check(): Promise<SpriteCheck>;
399
+ /** A checkpoint is a Runtime disk snapshot: the files, not the running
400
+ * processes. The Sprite is paused for the moment it takes, then woken.
401
+ * Progress arrives as the vendor's stream; a refusal is an `error` message. */
402
+ createCheckpoint(comment?: string): Promise<CheckpointStream>;
403
+ /** This Sprite's disk snapshots, newest first. */
404
+ listCheckpoints(historyFilter?: string): Promise<Checkpoint[]>;
405
+ getCheckpoint(id: string): Promise<Checkpoint>;
406
+ /** Forwards localhost:`localPort` here to `remotePort` in the Sprite. */
407
+ proxyPort(localPort: number, remotePort: number, remoteHost?: string): Promise<ProxySession>;
408
+ proxyPorts(mappings: PortMapping[]): Promise<ProxySession[]>;
409
+ /** Runtime's network rules as Sprites rules: `* deny` closes the internet,
410
+ * allow rules are the only destinations reachable, deny rules are refused. */
411
+ getNetworkPolicy(): Promise<NetworkPolicy>;
412
+ /** Replaces the rules, keeping any host:port openings set through Runtime. */
413
+ updateNetworkPolicy(policy: NetworkPolicy): Promise<void>;
414
+ /** Control mode is never on: Runtime refuses `controlMode: true`. */
415
+ useControlMode(): boolean;
416
+ hasControlConnection(): boolean;
417
+ /** Nothing to close: no control connection is ever opened. */
418
+ closeControlConnection(): void;
154
419
  updateURLSettings(settings: {
155
420
  auth?: string;
156
421
  privateAccess?: string;
@@ -163,6 +428,55 @@ export declare class Sprite {
163
428
  };
164
429
  }): Promise<this>;
165
430
  }
431
+ /** A local listener that carries each connection to a port in the Sprite,
432
+ * over Runtime's tunnel. Node and Bun. */
433
+ export declare class ProxySession extends EventEmitter {
434
+ #private;
435
+ readonly localPort: number;
436
+ readonly remotePort: number;
437
+ readonly remoteHost: string;
438
+ constructor(client: SpritesClient | {
439
+ baseURL: string;
440
+ token: string;
441
+ }, spriteName: string, mapping: PortMapping);
442
+ start(): Promise<void>;
443
+ localAddr(): string | null;
444
+ close(): void;
445
+ wait(): Promise<void>;
446
+ }
447
+ export declare class ProxyManager {
448
+ #private;
449
+ addSession(session: ProxySession): void;
450
+ closeAll(): void;
451
+ waitAll(): Promise<void>;
452
+ }
453
+ export declare function proxyPort(client: SpritesClient | {
454
+ baseURL: string;
455
+ token: string;
456
+ }, spriteName: string, localPort: number, remotePort: number, remoteHost?: string): Promise<ProxySession>;
457
+ /** All or none: a mapping that cannot start closes the ones before it. */
458
+ export declare function proxyPorts(client: SpritesClient | {
459
+ baseURL: string;
460
+ token: string;
461
+ }, spriteName: string, mappings: PortMapping[]): Promise<ProxySession[]>;
462
+ /** Polls the Sprite's listening TCP sockets once a second with `ss` (as
463
+ * Sprites' own watcher keeps a connection open, this keeps it awake). */
464
+ export declare class PortWatcher extends Feed<PortWatchEvent> {
465
+ #private;
466
+ constructor(client: SpritesClient, spriteName: string);
467
+ connect(): Promise<void>;
468
+ protected stop(): void;
469
+ }
470
+ /** Runtime's file watch, one per path, as Sprites' watch events. */
471
+ export declare class FilesystemWatcher extends Feed<FilesystemWatchEvent> {
472
+ #private;
473
+ private readonly sandbox;
474
+ private readonly paths;
475
+ private readonly recursive;
476
+ constructor(sandbox: () => Promise<Sandbox>, paths: string[], workingDir: string, recursive: boolean);
477
+ connect(): Promise<void>;
478
+ protected stop(): void;
479
+ }
166
480
  export declare class SpriteCommand extends EventEmitter {
167
481
  readonly stdout: PassThrough;
168
482
  readonly stderr: PassThrough;
@@ -182,7 +496,9 @@ export declare class SpriteCommand extends EventEmitter {
182
496
  exitCode(): number;
183
497
  }
184
498
  export declare class SpriteFilesystem {
499
+ #private;
185
500
  private readonly get;
501
+ private readonly cwd;
186
502
  private readonly files;
187
503
  constructor(get: () => Promise<Sandbox>, cwd?: string);
188
504
  readFile(path: string, encoding: "utf8"): Promise<string>;
@@ -203,6 +519,7 @@ export declare class SpriteFilesystem {
203
519
  rm(path: string, options?: {
204
520
  recursive?: boolean;
205
521
  force?: boolean;
522
+ asRoot?: boolean;
206
523
  }): Promise<void>;
207
524
  stat(path: string): Promise<{
208
525
  size: number;
@@ -214,13 +531,29 @@ export declare class SpriteFilesystem {
214
531
  isFile: () => boolean;
215
532
  isSymbolicLink: () => boolean;
216
533
  }>;
217
- rename(from: string, to: string): Promise<void>;
534
+ rename(from: string, to: string, options?: {
535
+ asRoot?: boolean;
536
+ }): Promise<void>;
218
537
  copyFile(from: string, to: string, options?: {
219
538
  recursive?: boolean;
539
+ preserveAttrs?: boolean;
540
+ asRoot?: boolean;
220
541
  }): Promise<void>;
221
542
  chmod(path: string, mode: number, options?: {
222
543
  recursive?: boolean;
544
+ asRoot?: boolean;
223
545
  }): Promise<void>;
546
+ /** By number or name, as the Sprite's user unless `asRoot` (sudo). */
547
+ chown(path: string, options: {
548
+ uid?: number | string;
549
+ gid?: number | string;
550
+ recursive?: boolean;
551
+ asRoot?: boolean;
552
+ }): Promise<void>;
553
+ /** Changes to these paths until the watcher is closed. */
554
+ watch(paths: string | string[], options?: {
555
+ recursive?: boolean;
556
+ }): Promise<FilesystemWatcher>;
224
557
  exists(path: string): Promise<boolean>;
225
558
  appendFile(path: string, data: string | Uint8Array): Promise<void>;
226
559
  readJSON<T = unknown>(path: string): Promise<T>;
@@ -228,24 +561,3 @@ export declare class SpriteFilesystem {
228
561
  spaces?: number;
229
562
  }): Promise<void>;
230
563
  }
231
- export declare class CheckpointStream {
232
- private readonly messages;
233
- private index;
234
- constructor(messages: {
235
- type: "complete" | "error" | "info";
236
- data?: string;
237
- error?: string;
238
- }[]);
239
- next(): Promise<{
240
- type: "complete" | "error" | "info";
241
- data?: string;
242
- error?: string;
243
- } | null>;
244
- processAll(handler: (message: (typeof this.messages)[number]) => void | Promise<void>): Promise<void>;
245
- close(): void;
246
- [Symbol.asyncIterator](): AsyncGenerator<{
247
- type: "complete" | "error" | "info";
248
- data?: string;
249
- error?: string;
250
- }, void, unknown>;
251
- }