withruntime 0.9.0 → 0.11.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.
- package/BLAXEL.md +4 -4
- package/DAYTONA.md +52 -40
- package/E2B.md +65 -62
- package/README.md +15 -7
- package/README.src.md +15 -7
- package/VERCEL.md +34 -22
- package/compatibility-lock.json +16 -16
- package/dist/blaxel/errors.js +1 -1
- package/dist/blaxel/lookup.d.ts +3 -2
- package/dist/blaxel/lookup.js +3 -2
- package/dist/blaxel/pagination.d.ts +2 -2
- package/dist/blaxel/pagination.js +45 -17
- package/dist/blaxel/preview.d.ts +2 -1
- package/dist/blaxel/preview.js +15 -13
- package/dist/blaxel/process.js +56 -10
- package/dist/blaxel/sandbox.d.ts +2 -0
- package/dist/blaxel/sandbox.js +2 -0
- package/dist/blaxel/snapshot.js +3 -5
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +262 -56
- package/dist/client.d.ts +41 -3
- package/dist/client.js +67 -11
- package/dist/cloudflare/identity.d.ts +7 -0
- package/dist/cloudflare/identity.js +13 -0
- package/dist/cloudflare/index.d.ts +9 -0
- package/dist/cloudflare/index.js +47 -9
- package/dist/cloudflare/worker.d.ts +4 -0
- package/dist/cloudflare/worker.js +166 -16
- package/dist/codesandbox/guest-service.js +57 -20
- package/dist/codesandbox/index.js +42 -8
- package/dist/compat/core.d.ts +9 -8
- package/dist/compat/core.js +60 -21
- package/dist/compat/files.js +22 -4
- package/dist/compat/lease.d.ts +36 -0
- package/dist/compat/lease.js +87 -0
- package/dist/credentials.d.ts +6 -1
- package/dist/credentials.js +107 -38
- package/dist/daytona/computer-use.d.ts +162 -0
- package/dist/daytona/computer-use.js +324 -0
- package/dist/daytona/context.d.ts +10 -0
- package/dist/daytona/context.js +24 -0
- package/dist/daytona/daytona.d.ts +20 -0
- package/dist/daytona/daytona.js +134 -20
- package/dist/daytona/filesystem.d.ts +17 -4
- package/dist/daytona/filesystem.js +129 -38
- package/dist/daytona/index.d.ts +3 -27
- package/dist/daytona/index.js +2 -7
- package/dist/daytona/process.d.ts +63 -6
- package/dist/daytona/process.js +224 -23
- package/dist/daytona/sandbox.d.ts +20 -6
- package/dist/daytona/sandbox.js +55 -32
- package/dist/e2b/client.d.ts +5 -0
- package/dist/e2b/client.js +6 -2
- package/dist/e2b/commands.d.ts +43 -12
- package/dist/e2b/commands.js +217 -64
- package/dist/e2b/errors.d.ts +7 -0
- package/dist/e2b/errors.js +20 -0
- package/dist/e2b/filesystem.d.ts +2 -1
- package/dist/e2b/filesystem.js +43 -6
- package/dist/e2b/index.d.ts +3 -2
- package/dist/e2b/index.js +2 -1
- package/dist/e2b/pty.d.ts +24 -0
- package/dist/e2b/pty.js +83 -0
- package/dist/e2b/sandbox.d.ts +17 -6
- package/dist/e2b/sandbox.js +239 -43
- package/dist/e2b/users.d.ts +30 -0
- package/dist/e2b/users.js +185 -0
- package/dist/file-source.d.ts +16 -0
- package/dist/file-source.js +162 -0
- package/dist/freestyle/index.d.ts +9 -1
- package/dist/freestyle/index.js +38 -5
- package/dist/index.d.ts +3 -1
- package/dist/login.js +16 -10
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +6 -1
- package/dist/modal/index.js +2 -1
- package/dist/network-cli.js +139 -43
- package/dist/openai-agents/index.js +9 -45
- package/dist/page.d.ts +1 -1
- package/dist/page.js +2 -2
- package/dist/products/browser.d.ts +60 -0
- package/dist/products/browser.js +37 -0
- package/dist/products/desktop.d.ts +2 -2
- package/dist/products/desktop.js +2 -2
- package/dist/products/images.d.ts +3 -1
- package/dist/products/images.js +14 -2
- package/dist/products/index.d.ts +14 -0
- package/dist/products/index.js +12 -0
- package/dist/products/network-products.d.ts +7 -0
- package/dist/products/network-products.js +3 -0
- package/dist/products/observability.d.ts +44 -0
- package/dist/products/observability.js +6 -0
- package/dist/products/previews.d.ts +8 -2
- package/dist/products/previews.js +11 -3
- package/dist/products/private-network.d.ts +22 -0
- package/dist/products/private-network.js +10 -0
- package/dist/products/volumes.d.ts +42 -0
- package/dist/products/volumes.js +36 -0
- package/dist/products/watch.js +61 -8
- package/dist/proxy.js +3 -1
- package/dist/runloop/index.d.ts +13 -27
- package/dist/runloop/index.js +149 -52
- package/dist/sandbox.d.ts +59 -8
- package/dist/sandbox.js +479 -68
- package/dist/snapshots.d.ts +9 -4
- package/dist/sprites/index.js +69 -33
- package/dist/tar.d.ts +3 -1
- package/dist/tar.js +140 -14
- package/dist/transport.d.ts +4 -7
- package/dist/transport.js +205 -122
- package/dist/types.d.ts +5 -2
- package/dist/vercel/command.d.ts +1 -1
- package/dist/vercel/command.js +3 -2
- package/dist/vercel/errors.d.ts +1 -1
- package/dist/vercel/errors.js +7 -1
- package/dist/vercel/index.d.ts +1 -7
- package/dist/vercel/index.js +1 -3
- package/dist/vercel/sandbox-user.d.ts +70 -0
- package/dist/vercel/sandbox-user.js +206 -0
- package/dist/vercel/sandbox.d.ts +55 -20
- package/dist/vercel/sandbox.js +353 -99
- package/dist/vercel/snapshot.d.ts +3 -2
- package/dist/vercel/snapshot.js +9 -5
- package/package.json +2 -1
package/dist/daytona/sandbox.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LeaseKeeper } from "../compat/lease.js";
|
|
2
|
+
import { ComputerUse } from "./computer-use.js";
|
|
2
3
|
import { HOME, HOME_LINK } from "./context.js";
|
|
3
4
|
import { DaytonaError, DaytonaNotFoundError, guard, NotSupportedError } from "./errors.js";
|
|
4
5
|
import { FileSystem } from "./filesystem.js";
|
|
@@ -22,11 +23,18 @@ export class CodeInterpreter {
|
|
|
22
23
|
const env = this.#env();
|
|
23
24
|
if (!Object.keys(env).length)
|
|
24
25
|
return "python";
|
|
25
|
-
this.#envContext
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (!this.#envContext) {
|
|
27
|
+
const pending = (async () => {
|
|
28
|
+
const runtime = await this.#sandbox();
|
|
29
|
+
const made = await guard("sandbox", () => runtime.interpreter.contexts.create({ language: "python", cwd: HOME, env }));
|
|
30
|
+
return made.id;
|
|
31
|
+
})();
|
|
32
|
+
this.#envContext = pending;
|
|
33
|
+
pending.catch(() => {
|
|
34
|
+
if (this.#envContext === pending)
|
|
35
|
+
this.#envContext = undefined;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
30
38
|
return this.#envContext;
|
|
31
39
|
}
|
|
32
40
|
async runCode(code, options = {}) {
|
|
@@ -89,6 +97,10 @@ export class Sandbox {
|
|
|
89
97
|
#options;
|
|
90
98
|
#home;
|
|
91
99
|
#pausedByPause = false;
|
|
100
|
+
#computerUse;
|
|
101
|
+
/** When this client last made a call: autoStopInterval counts from it. */
|
|
102
|
+
#lastActive = Date.now();
|
|
103
|
+
#keeper;
|
|
92
104
|
/** Use daytona.create or daytona.get. */
|
|
93
105
|
constructor(runtime, client, options) {
|
|
94
106
|
this.#rt = runtime;
|
|
@@ -97,9 +109,20 @@ export class Sandbox {
|
|
|
97
109
|
this.env = { ...options.env };
|
|
98
110
|
this.public = options.public;
|
|
99
111
|
this.snapshot = options.snapshot;
|
|
112
|
+
this.#keeper = new LeaseKeeper({
|
|
113
|
+
sandbox: () => this.#rt,
|
|
114
|
+
until: () => {
|
|
115
|
+
const lifecycle = this.#options.lifecycle;
|
|
116
|
+
return Math.min(this.#lastActive + (lifecycle.idleSeconds ?? lifecycle.windowSeconds) * 1000, lifecycle.deadline ?? Infinity);
|
|
117
|
+
},
|
|
118
|
+
// Renewed when less than half the window is left, so a run of calls
|
|
119
|
+
// costs one extend per half window.
|
|
120
|
+
marginMs: () => this.#options.lifecycle.windowSeconds * 500,
|
|
121
|
+
});
|
|
100
122
|
const ctx = {
|
|
101
123
|
live: () => this.#live(),
|
|
102
124
|
language: options.language,
|
|
125
|
+
...(options.user ? { user: options.user } : {}),
|
|
103
126
|
ensureHome: (text) => this.#ensureHome(text),
|
|
104
127
|
};
|
|
105
128
|
// A getter, so the modules see the environment updateEnv sets.
|
|
@@ -124,9 +147,10 @@ export class Sandbox {
|
|
|
124
147
|
return "";
|
|
125
148
|
}
|
|
126
149
|
/** Daytona's user name, so `/home/${sandbox.user}` leads to the working
|
|
127
|
-
* directory
|
|
150
|
+
* directory, and commands run as Runtime's sandbox owner, with passwordless
|
|
151
|
+
* sudo; or the user given at create, whose commands run through sudo. */
|
|
128
152
|
get user() {
|
|
129
|
-
return "daytona";
|
|
153
|
+
return this.#options.user ?? "daytona";
|
|
130
154
|
}
|
|
131
155
|
get labels() {
|
|
132
156
|
return { ...this.#rt.info.labels };
|
|
@@ -188,29 +212,13 @@ export class Sandbox {
|
|
|
188
212
|
}
|
|
189
213
|
/** The sandbox, its lease moved on when less than half of the autoStop
|
|
190
214
|
* window is left: every call through this object counts as activity, as
|
|
191
|
-
* Daytona's API calls do.
|
|
215
|
+
* Daytona's API calls do. An autoStopInterval past an hour, or 0, is kept
|
|
216
|
+
* by renewing the lease while this object lives. */
|
|
192
217
|
async #live(force = false) {
|
|
193
|
-
const lifecycle = this.#options.lifecycle;
|
|
194
218
|
if (this.#rt.state !== "running")
|
|
195
219
|
return this.#rt;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return this.#rt;
|
|
199
|
-
let seconds = Math.ceil(lifecycle.windowSeconds - left / 1000);
|
|
200
|
-
if (lifecycle.deadline !== undefined)
|
|
201
|
-
seconds = Math.min(seconds, Math.floor((lifecycle.deadline - Date.now() - left) / 1000));
|
|
202
|
-
if (seconds < 1)
|
|
203
|
-
return this.#rt;
|
|
204
|
-
try {
|
|
205
|
-
await this.#rt.extend(seconds);
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
// The lease may have ended since this object last looked; the call
|
|
209
|
-
// itself then says what state the sandbox is in.
|
|
210
|
-
if (!(error instanceof RuntimeError && error.status === 409))
|
|
211
|
-
throw error;
|
|
212
|
-
await this.#rt.refresh().catch(() => undefined);
|
|
213
|
-
}
|
|
220
|
+
this.#lastActive = Date.now();
|
|
221
|
+
await this.#keeper.check(force);
|
|
214
222
|
return this.#rt;
|
|
215
223
|
}
|
|
216
224
|
#ensureHome(text) {
|
|
@@ -241,6 +249,7 @@ export class Sandbox {
|
|
|
241
249
|
if (state === "stopped" || state === "stopping")
|
|
242
250
|
return;
|
|
243
251
|
if (this.#options.lifecycle.ephemeral) {
|
|
252
|
+
this.#keeper.end();
|
|
244
253
|
await guard("sandbox", () => this.#rt.stop());
|
|
245
254
|
return;
|
|
246
255
|
}
|
|
@@ -262,6 +271,7 @@ export class Sandbox {
|
|
|
262
271
|
}
|
|
263
272
|
/** Ends the sandbox for good. */
|
|
264
273
|
async delete(_timeout) {
|
|
274
|
+
this.#keeper.end();
|
|
265
275
|
await guard("sandbox", () => this.#rt.refresh());
|
|
266
276
|
if (this.#rt.state !== "stopped")
|
|
267
277
|
await guard("sandbox", () => this.#rt.stop({ wait: false }));
|
|
@@ -282,11 +292,12 @@ export class Sandbox {
|
|
|
282
292
|
await guard("sandbox", () => this.#live(true));
|
|
283
293
|
}
|
|
284
294
|
/** The sandbox pauses after `interval` minutes without a call from this
|
|
285
|
-
* client
|
|
295
|
+
* client; 0 never. Past an hour, while this object lives. */
|
|
286
296
|
async setAutostopInterval(interval) {
|
|
287
297
|
const lifecycle = this.#options.lifecycle;
|
|
288
298
|
lifecycle.autoStopInterval = interval;
|
|
289
299
|
lifecycle.windowSeconds = windowSeconds(interval);
|
|
300
|
+
lifecycle.idleSeconds = idleSeconds(interval);
|
|
290
301
|
await guard("sandbox", () => this.#live());
|
|
291
302
|
}
|
|
292
303
|
setAutoPauseInterval(interval) {
|
|
@@ -370,11 +381,16 @@ export class Sandbox {
|
|
|
370
381
|
return this.createSnapshot(name, timeout);
|
|
371
382
|
}
|
|
372
383
|
// ---- what Runtime does differently -----------------------------------------
|
|
384
|
+
/** Daytona's computer use over Runtime's desktop: `await
|
|
385
|
+
* sandbox.computerUse.start()`, then the mouse, keyboard and screenshots. */
|
|
373
386
|
get computerUse() {
|
|
374
|
-
|
|
387
|
+
this.#computerUse ??= new ComputerUse(() => this.#live());
|
|
388
|
+
return this.#computerUse;
|
|
375
389
|
}
|
|
376
|
-
setLabels() {
|
|
377
|
-
|
|
390
|
+
async setLabels(labels) {
|
|
391
|
+
const internal = Object.fromEntries(Object.entries(this.#rt.info.labels).filter(([key]) => key === "code-toolbox-language" || key.startsWith("compat.")));
|
|
392
|
+
await guard("sandbox", () => this.#rt.update({ labels: { ...labels, ...internal } }));
|
|
393
|
+
return this.labels;
|
|
378
394
|
}
|
|
379
395
|
recover() {
|
|
380
396
|
return refusal("Recovering a failed sandbox", "Create a new sandbox, or start one from a snapshot.");
|
|
@@ -428,6 +444,13 @@ export function windowSeconds(autoStopMinutes) {
|
|
|
428
444
|
return 3600;
|
|
429
445
|
return Math.min(3600, Math.max(60, Math.round(autoStopMinutes * 60)));
|
|
430
446
|
}
|
|
447
|
+
/** Daytona's autoStopInterval (minutes; 0 is never) as seconds without a
|
|
448
|
+
* call before the sandbox pauses. */
|
|
449
|
+
export function idleSeconds(autoStopMinutes) {
|
|
450
|
+
if (autoStopMinutes <= 0)
|
|
451
|
+
return Infinity;
|
|
452
|
+
return Math.max(60, Math.round(autoStopMinutes * 60));
|
|
453
|
+
}
|
|
431
454
|
/** Minutes as Runtime's retention: whole days, 1 to 365. */
|
|
432
455
|
export function retentionDays(minutes) {
|
|
433
456
|
return Math.min(365, Math.max(1, Math.ceil(minutes / 1440)));
|
package/dist/e2b/client.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { Runtime } from "../client.js";
|
|
|
3
3
|
export type RuntimeSandbox = Awaited<ReturnType<Runtime["sandboxes"]["create"]>>;
|
|
4
4
|
/** What `Sandbox.create` sends to Runtime. */
|
|
5
5
|
export type RuntimeCreate = NonNullable<Parameters<Runtime["sandboxes"]["create"]>[0]>;
|
|
6
|
+
/** E2B's HTTP version for its API and sandboxes (e2b 2.52.0). */
|
|
7
|
+
export type HttpVersion = "1.1" | "2";
|
|
6
8
|
/** E2B's connection options, as far as they mean anything on Runtime. */
|
|
7
9
|
export interface ConnectionOpts {
|
|
8
10
|
/** A Runtime key. Default: RUNTIME_API_KEY, then E2B_API_KEY if it holds a
|
|
@@ -18,6 +20,9 @@ export interface ConnectionOpts {
|
|
|
18
20
|
retries?: number;
|
|
19
21
|
/** Accepted and ignored: Runtime's SDK does not take a logger. */
|
|
20
22
|
logger?: unknown;
|
|
23
|
+
/** Checked as E2B checks it (and E2B_HTTP_VERSION), then left to Runtime's
|
|
24
|
+
* SDK, which picks its own transport. */
|
|
25
|
+
httpVersion?: HttpVersion;
|
|
21
26
|
/** E2B endpoints. Refused: this package only talks to Runtime. */
|
|
22
27
|
domain?: string;
|
|
23
28
|
apiUrl?: string;
|
package/dist/e2b/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Runtime } from "../client.js";
|
|
2
|
-
import { AuthenticationError, NotSupportedError } from "./errors.js";
|
|
2
|
+
import { AuthenticationError, InvalidArgumentError, NotSupportedError } from "./errors.js";
|
|
3
3
|
const env = (name) => typeof process === "undefined" ? undefined : process.env[name];
|
|
4
4
|
const isE2BKey = (key) => key.startsWith("e2b_");
|
|
5
5
|
/** Refuses the E2B-only connection options: they point at E2B, and quietly
|
|
@@ -18,6 +18,10 @@ export function refuseE2BConnection(opts = {}) {
|
|
|
18
18
|
? "Set HTTPS_PROXY in the environment instead; Runtime's SDK reads it."
|
|
19
19
|
: "Remove it: this package talks only to Runtime (RUNTIME_API_URL overrides the API origin).");
|
|
20
20
|
}
|
|
21
|
+
// E2B refuses any other version, from the option or the environment.
|
|
22
|
+
const version = opts.httpVersion ?? (env("E2B_HTTP_VERSION") || undefined);
|
|
23
|
+
if (version !== undefined && version !== "1.1" && version !== "2")
|
|
24
|
+
throw new InvalidArgumentError(`${opts.httpVersion === undefined ? "E2B_HTTP_VERSION" : "httpVersion"} must be '1.1' or '2', got '${version}'`);
|
|
21
25
|
if (opts.debug)
|
|
22
26
|
throw new NotSupportedError("E2B's debug mode (a local envd)", "Remove debug: true; there is no local Runtime guest to connect to.");
|
|
23
27
|
}
|
|
@@ -60,7 +64,7 @@ export function resetClients() {
|
|
|
60
64
|
/** Request options for a Runtime call from E2B's. */
|
|
61
65
|
export function request(opts = {}) {
|
|
62
66
|
return {
|
|
63
|
-
...(opts.requestTimeoutMs ? { timeoutMs: opts.requestTimeoutMs }
|
|
67
|
+
...(opts.requestTimeoutMs === undefined ? {} : { timeoutMs: opts.requestTimeoutMs }),
|
|
64
68
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
65
69
|
};
|
|
66
70
|
}
|
package/dist/e2b/commands.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Process } from "../sandbox.js";
|
|
2
|
+
import type { OutputEvent, ProcessInfo as RuntimeProcessInfo } from "../types.js";
|
|
3
|
+
import type { RequestOptions } from "../transport.js";
|
|
2
4
|
import type { RuntimeSandbox } from "./client.js";
|
|
3
|
-
import { type CommandResult } from "./errors.js";
|
|
5
|
+
import { TimeoutError, type CommandResult } from "./errors.js";
|
|
4
6
|
export type { CommandResult };
|
|
5
7
|
export type Username = "user" | "root" | (string & {});
|
|
6
8
|
export interface CommandRequestOpts {
|
|
@@ -10,9 +12,9 @@ export interface CommandRequestOpts {
|
|
|
10
12
|
export interface CommandStartOpts extends CommandRequestOpts {
|
|
11
13
|
background?: boolean;
|
|
12
14
|
cwd?: string;
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
15
|
+
/** "user" (the default) is the sandbox's own user, `runtime`; any other
|
|
16
|
+
* user that exists in the sandbox, `root` included, runs it through
|
|
17
|
+
* `sudo -u`. An unknown user is refused, never created. */
|
|
16
18
|
user?: Username;
|
|
17
19
|
envs?: Record<string, string>;
|
|
18
20
|
onStdout?: (data: string) => void | Promise<void>;
|
|
@@ -37,13 +39,28 @@ export interface ProcessInfo {
|
|
|
37
39
|
* keep: it is the sandbox's own `env`, added to every command there. */
|
|
38
40
|
export interface SandboxContext {
|
|
39
41
|
readonly runtime: RuntimeSandbox;
|
|
42
|
+
readonly requestTimeoutMs?: number;
|
|
40
43
|
/** Makes /home/user (E2B's home) lead to /workspace (Runtime's), once, when
|
|
41
44
|
* something names it. */
|
|
42
|
-
ensureHome(text: string | undefined): Promise<void>;
|
|
45
|
+
ensureHome(text: string | undefined, options?: RequestOptions): Promise<void>;
|
|
43
46
|
}
|
|
44
47
|
/** E2B's pids are numbers; Runtime's process ids are strings. The number is a
|
|
45
48
|
* 31-bit FNV-1a hash of the id, so every client derives the same one. */
|
|
46
49
|
export declare function pidOf(processId: string): number;
|
|
50
|
+
export declare function timeoutFor(timeoutMs: number | undefined): number;
|
|
51
|
+
/** One budget for lookup and mutation, including retries and queued input. */
|
|
52
|
+
export declare function commandRequest(opts: CommandRequestOpts, defaultTimeoutMs?: number): RequestOptions;
|
|
53
|
+
export declare function findProcess(ctx: SandboxContext, pid: number, options: RequestOptions): Promise<RuntimeProcessInfo | undefined>;
|
|
54
|
+
export declare function resolveProcess(ctx: SandboxContext, pid: number, options: RequestOptions): Promise<Process>;
|
|
55
|
+
export declare function killProcess(ctx: SandboxContext, pid: number, options: RequestOptions): Promise<boolean>;
|
|
56
|
+
export declare function timedOut(timeoutMs: number): TimeoutError;
|
|
57
|
+
/** The subscription deadline includes the opening handshake. */
|
|
58
|
+
export declare function connectionRequest(opts: CommandConnectOpts, defaultTimeoutMs?: number): {
|
|
59
|
+
timeoutMs: number;
|
|
60
|
+
deadline: number | undefined;
|
|
61
|
+
request: RequestOptions;
|
|
62
|
+
failure: (error: unknown) => never;
|
|
63
|
+
};
|
|
47
64
|
/** `sandbox.commands`: E2B's command module over Runtime's exec and processes. */
|
|
48
65
|
export declare class Commands {
|
|
49
66
|
#private;
|
|
@@ -61,28 +78,42 @@ export declare class Commands {
|
|
|
61
78
|
background?: boolean;
|
|
62
79
|
}): Promise<CommandHandle | CommandResult>;
|
|
63
80
|
/** Running commands. */
|
|
64
|
-
list(
|
|
81
|
+
list(opts?: CommandRequestOpts): Promise<ProcessInfo[]>;
|
|
65
82
|
/** Kills a command with SIGKILL, as E2B does. False when there is none. */
|
|
66
|
-
kill(pid: number,
|
|
83
|
+
kill(pid: number, opts?: CommandRequestOpts): Promise<boolean>;
|
|
67
84
|
/** Sends input to a command started with `stdin: true`. */
|
|
68
|
-
sendStdin(pid: number, data: string | Uint8Array,
|
|
69
|
-
closeStdin(pid: number,
|
|
85
|
+
sendStdin(pid: number, data: string | Uint8Array, opts?: CommandRequestOpts): Promise<void>;
|
|
86
|
+
closeStdin(pid: number, opts?: CommandRequestOpts): Promise<void>;
|
|
70
87
|
/** Attaches to a running command; output from now on reaches the handle. */
|
|
71
88
|
connect(pid: number, opts?: CommandConnectOpts): Promise<CommandHandle>;
|
|
72
89
|
}
|
|
90
|
+
/** A command whose output this handle reads from the request that started
|
|
91
|
+
* it: its process id, the rest of its events, the controller that ends the
|
|
92
|
+
* read, and the Runtime process, fetched only when something needs it. */
|
|
93
|
+
export interface StartedStream {
|
|
94
|
+
started: true;
|
|
95
|
+
id: string;
|
|
96
|
+
events: AsyncIterator<OutputEvent>;
|
|
97
|
+
abort: AbortController;
|
|
98
|
+
process: () => Promise<Process>;
|
|
99
|
+
}
|
|
73
100
|
/** A command started in the background: E2B's CommandHandle over a Runtime
|
|
74
101
|
* process. Output streams into `stdout`/`stderr` and the callbacks as it
|
|
75
102
|
* arrives. */
|
|
76
103
|
export declare class CommandHandle {
|
|
77
104
|
#private;
|
|
78
105
|
readonly pid: number;
|
|
79
|
-
constructor(
|
|
106
|
+
constructor(source: Process | StartedStream, options: {
|
|
80
107
|
stdin: boolean;
|
|
81
108
|
timeoutMs: number;
|
|
82
109
|
cursor?: number;
|
|
83
110
|
signal?: AbortSignal;
|
|
84
111
|
onStdout?: (data: string) => void | Promise<void>;
|
|
85
112
|
onStderr?: (data: string) => void | Promise<void>;
|
|
113
|
+
onData?: (data: Uint8Array) => void | Promise<void>;
|
|
114
|
+
pty?: boolean;
|
|
115
|
+
requestTimeoutMs?: number;
|
|
116
|
+
deadline?: number;
|
|
86
117
|
});
|
|
87
118
|
/** The exit code, or undefined while the command runs. */
|
|
88
119
|
get exitCode(): number | undefined;
|
|
@@ -96,6 +127,6 @@ export declare class CommandHandle {
|
|
|
96
127
|
disconnect(): Promise<void>;
|
|
97
128
|
/** Kills the command with SIGKILL. False when it had already ended. */
|
|
98
129
|
kill(): Promise<boolean>;
|
|
99
|
-
sendStdin(data: string | Uint8Array,
|
|
100
|
-
closeStdin(
|
|
130
|
+
sendStdin(data: string | Uint8Array, opts?: CommandRequestOpts): Promise<void>;
|
|
131
|
+
closeStdin(opts?: CommandRequestOpts): Promise<void>;
|
|
101
132
|
}
|