withruntime 0.10.0 → 0.11.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/BLAXEL.md +7 -8
- package/DAYTONA.md +40 -35
- package/E2B.md +70 -57
- package/README.md +3 -3
- package/README.src.md +3 -3
- package/VERCEL.md +23 -20
- package/compatibility-lock.json +63 -84
- package/dist/api-defaults.d.ts +1 -1
- package/dist/api-defaults.js +1 -1
- package/dist/blaxel/lookup.d.ts +2 -1
- package/dist/blaxel/lookup.js +2 -1
- package/dist/blaxel/sandbox.d.ts +7 -5
- package/dist/blaxel/sandbox.js +15 -10
- package/dist/cli.js +112 -17
- package/dist/client.d.ts +17 -1
- package/dist/client.js +46 -3
- package/dist/compat/files.js +5 -1
- package/dist/compat/lease.d.ts +37 -0
- package/dist/compat/lease.js +93 -0
- package/dist/credentials.d.ts +9 -0
- package/dist/credentials.js +26 -4
- 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 +150 -26
- package/dist/daytona/filesystem.js +8 -0
- package/dist/daytona/index.d.ts +2 -26
- 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 +25 -6
- package/dist/daytona/sandbox.js +60 -27
- package/dist/e2b/client.d.ts +5 -0
- package/dist/e2b/client.js +5 -1
- package/dist/e2b/commands.d.ts +15 -6
- package/dist/e2b/commands.js +83 -18
- 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 +2 -2
- package/dist/e2b/index.js +1 -1
- package/dist/e2b/pty.js +6 -3
- package/dist/e2b/sandbox.d.ts +20 -6
- package/dist/e2b/sandbox.js +207 -31
- package/dist/e2b/users.d.ts +30 -0
- package/dist/e2b/users.js +185 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/identity.js +2 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +6 -1
- package/dist/modal/index.js +6 -2
- package/dist/network-cli.js +33 -5
- package/dist/products/browser.d.ts +61 -0
- package/dist/products/browser.js +27 -0
- package/dist/products/desktop.d.ts +4 -3
- package/dist/products/desktop.js +7 -32
- package/dist/products/images.d.ts +3 -1
- package/dist/products/images.js +14 -2
- package/dist/products/index.d.ts +2 -0
- package/dist/products/index.js +2 -0
- package/dist/products/jobs.d.ts +7 -5
- package/dist/products/jobs.js +7 -3
- package/dist/products/mcp.d.ts +5 -1
- package/dist/products/mcp.js +29 -8
- package/dist/products/network-products.d.ts +8 -1
- package/dist/products/network-products.js +4 -1
- package/dist/products/observability.d.ts +1 -1
- package/dist/products/private-network.d.ts +22 -0
- package/dist/products/private-network.js +10 -0
- package/dist/products/secrets.d.ts +2 -2
- package/dist/runloop/index.js +6 -2
- package/dist/sandbox.d.ts +44 -14
- package/dist/sandbox.js +162 -48
- package/dist/tar.d.ts +2 -0
- package/dist/tar.js +74 -16
- package/dist/transport.d.ts +33 -7
- package/dist/transport.js +171 -36
- package/dist/types.d.ts +59 -11
- package/dist/vercel/filesystem.js +3 -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 +57 -15
- package/dist/vercel/sandbox.js +219 -47
- package/dist/wait.d.ts +12 -0
- package/dist/wait.js +47 -0
- package/package.json +1 -1
package/dist/daytona/daytona.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { clientFor, } from "./client.js";
|
|
2
2
|
import { DaytonaError, DaytonaNotFoundError, guard, NotSupportedError } from "./errors.js";
|
|
3
|
-
import {
|
|
3
|
+
import { LEASE_MAX_SECONDS } from "../compat/lease.js";
|
|
4
|
+
import { idlePauseOf, idleSeconds, networkRules, notFound, retentionDays, Sandbox, windowSeconds, } from "./sandbox.js";
|
|
4
5
|
/* Daytona's client over Runtime's. `new Daytona()` then `daytona.create()`
|
|
5
6
|
makes a Runtime sandbox with Daytona's defaults. */
|
|
6
7
|
/** Daytona's default machine: 1 vCPU, 1 GiB memory, 3 GiB disk (checked
|
|
@@ -14,6 +15,10 @@ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
14
15
|
const STOCK_SNAPSHOT = /^daytona(io)?[-/:]|^daytona$/;
|
|
15
16
|
/** Daytona's label for a sandbox's code language. */
|
|
16
17
|
export const LANGUAGE_LABEL = "code-toolbox-language";
|
|
18
|
+
/** The Linux user given at create, so get() and list() run as it too. */
|
|
19
|
+
export const USER_LABEL = "compat.daytona-user";
|
|
20
|
+
/** The sandbox owner's names: Daytona's and Runtime's. */
|
|
21
|
+
const OWNER = new Set(["daytona", "runtime"]);
|
|
17
22
|
export var CodeLanguage;
|
|
18
23
|
(function (CodeLanguage) {
|
|
19
24
|
CodeLanguage["PYTHON"] = "python";
|
|
@@ -190,11 +195,15 @@ export class Daytona {
|
|
|
190
195
|
const network = networkRules(params);
|
|
191
196
|
// Daytona keeps the language in this label, so a sandbox found later with
|
|
192
197
|
// get() or list() runs codeRun in the language it was made for.
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
:
|
|
198
|
+
const user = params.user !== undefined && !OWNER.has(params.user) ? params.user : undefined;
|
|
199
|
+
const tagged = {
|
|
200
|
+
...params.labels,
|
|
201
|
+
...(params.language && params.language !== "python"
|
|
202
|
+
? { [LANGUAGE_LABEL]: params.language }
|
|
203
|
+
: {}),
|
|
204
|
+
...(user ? { [USER_LABEL]: user } : {}),
|
|
205
|
+
};
|
|
206
|
+
const labels = Object.keys(tagged).length ? tagged : undefined;
|
|
198
207
|
const input = {
|
|
199
208
|
...(source.snapshot
|
|
200
209
|
? {}
|
|
@@ -203,9 +212,15 @@ export class Daytona {
|
|
|
203
212
|
memoryMiB: Math.round(resources.memory * 1024),
|
|
204
213
|
diskMiB: Math.round(resources.disk * 1024),
|
|
205
214
|
}),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
// A time to live is a time limit, kept by the lease. Without one there
|
|
216
|
+
// is none: it runs while it works and autoStopInterval is its idle
|
|
217
|
+
// pause, counted by the sandbox itself, so a long command is never
|
|
218
|
+
// frozen for want of calls from this client (0300).
|
|
219
|
+
...(lifecycle.deadline
|
|
220
|
+
? {
|
|
221
|
+
timeoutSeconds: Math.max(60, Math.min(lifecycle.windowSeconds, Math.floor((lifecycle.deadline - Date.now()) / 1000))),
|
|
222
|
+
}
|
|
223
|
+
: { idlePauseSeconds: idlePauseOf(lifecycle.autoStopInterval) }),
|
|
209
224
|
onLeaseEnd: lifecycle.ephemeral || lifecycle.deadline ? "stop" : "pause",
|
|
210
225
|
...(params.name ? { name: params.name } : {}),
|
|
211
226
|
...(labels ? { labels } : {}),
|
|
@@ -216,6 +231,8 @@ export class Daytona {
|
|
|
216
231
|
...params.withruntime?.create,
|
|
217
232
|
};
|
|
218
233
|
const runtime = await guard("sandbox", () => client.sandboxes.create(input));
|
|
234
|
+
if (user)
|
|
235
|
+
await asUser(runtime, user);
|
|
219
236
|
if (lifecycle.autoDeleteInterval > 0)
|
|
220
237
|
await guard("sandbox", () => runtime.setRetention(retentionDays(lifecycle.autoDeleteInterval))).catch(async (error) => {
|
|
221
238
|
await runtime.stop({ wait: false }).catch(() => undefined);
|
|
@@ -233,6 +250,7 @@ export class Daytona {
|
|
|
233
250
|
public: params.public ?? false,
|
|
234
251
|
lifecycle,
|
|
235
252
|
...("snapshot" in params && params.snapshot ? { snapshot: params.snapshot } : {}),
|
|
253
|
+
...(user ? { user } : {}),
|
|
236
254
|
});
|
|
237
255
|
}
|
|
238
256
|
async #source(client, params, onLogs) {
|
|
@@ -286,26 +304,44 @@ export class Daytona {
|
|
|
286
304
|
}
|
|
287
305
|
#adopt(runtime) {
|
|
288
306
|
const onLeaseEnd = runtime.info.onLeaseEnd;
|
|
307
|
+
const user = runtime.info.labels[USER_LABEL];
|
|
289
308
|
return new Sandbox(runtime, this.#client, {
|
|
290
309
|
env: {},
|
|
291
310
|
language: runtime.info.labels[LANGUAGE_LABEL] ?? "python",
|
|
292
311
|
public: false,
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
312
|
+
...(user ? { user } : {}),
|
|
313
|
+
lifecycle: runtime.info.timeoutSeconds
|
|
314
|
+
? {
|
|
315
|
+
windowSeconds: runtime.info.timeoutSeconds,
|
|
316
|
+
idleSeconds: runtime.info.timeoutSeconds,
|
|
317
|
+
ephemeral: onLeaseEnd === "stop",
|
|
318
|
+
autoStopInterval: Math.round(runtime.info.timeoutSeconds / 60),
|
|
319
|
+
autoArchiveInterval: 0,
|
|
320
|
+
autoDeleteInterval: -1,
|
|
321
|
+
}
|
|
322
|
+
: {
|
|
323
|
+
// No time limit: its idle pause is its autoStopInterval.
|
|
324
|
+
windowSeconds: LEASE_MAX_SECONDS,
|
|
325
|
+
idleSeconds: Infinity,
|
|
326
|
+
ephemeral: onLeaseEnd === "stop",
|
|
327
|
+
autoStopInterval: Math.round((runtime.info.idlePauseSeconds ?? 0) / 60),
|
|
328
|
+
autoArchiveInterval: 0,
|
|
329
|
+
autoDeleteInterval: -1,
|
|
330
|
+
},
|
|
300
331
|
});
|
|
301
332
|
}
|
|
302
333
|
/** Live and stopped (paused) sandboxes, oldest first. Await it for the old
|
|
303
334
|
* paginated shape, `{ items, total, page, totalPages }`. */
|
|
304
335
|
list(query = {}) {
|
|
305
|
-
const
|
|
306
|
-
const other = Object.keys(query).find((key) => query[key] !== undefined && !known.has(key));
|
|
336
|
+
const other = Object.keys(query).find((key) => query[key] !== undefined && !LISTED.has(key));
|
|
307
337
|
if (other)
|
|
308
|
-
throw new NotSupportedError(`Listing sandboxes by ${other}`,
|
|
338
|
+
throw new NotSupportedError(`Listing sandboxes by ${other}`, other === "isPublic"
|
|
339
|
+
? "Runtime previews are public or private per port: filter by a label you set at create."
|
|
340
|
+
: "Filter by a label you set at create, or narrow the result yourself.");
|
|
341
|
+
if (query.sort !== undefined && !SORTS[query.sort])
|
|
342
|
+
throw new RangeError(`sort is one of ${Object.keys(SORTS).join(", ")}.`);
|
|
343
|
+
if (query.order !== undefined && query.order !== "asc" && query.order !== "desc")
|
|
344
|
+
throw new RangeError('order is "asc" or "desc".');
|
|
309
345
|
const states = query.states?.flatMap((state) => state === "started"
|
|
310
346
|
? ["running"]
|
|
311
347
|
: state === "starting"
|
|
@@ -315,15 +351,24 @@ export class Daytona {
|
|
|
315
351
|
: state === "stopped" || state === "paused"
|
|
316
352
|
? ["paused"]
|
|
317
353
|
: []);
|
|
318
|
-
const client = this.#client;
|
|
319
|
-
const adopt = (runtime) => this.#adopt(runtime);
|
|
320
354
|
const filter = {
|
|
321
355
|
...(query.labels ? { labels: query.labels } : {}),
|
|
322
|
-
...(query.name ? { name: query.name } : {}),
|
|
323
356
|
...(states ? { state: states } : {}),
|
|
324
357
|
...(query.limit ? { limit: Math.min(query.limit, 100) } : {}),
|
|
325
358
|
};
|
|
359
|
+
const here = Object.keys(query).some((key) => query[key] !== undefined && !["limit", "labels", "states"].includes(key));
|
|
360
|
+
const client = this.#client;
|
|
361
|
+
const adopt = (runtime) => this.#adopt(runtime);
|
|
362
|
+
const everything = async () => {
|
|
363
|
+
const page = await guard("other", () => client.sandboxes.list(filter));
|
|
364
|
+
return arrange(await page.toArray(10_000), query);
|
|
365
|
+
};
|
|
326
366
|
async function* iterate() {
|
|
367
|
+
if (here) {
|
|
368
|
+
for (const runtime of await everything())
|
|
369
|
+
yield adopt(runtime);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
327
372
|
const page = await guard("other", () => client.sandboxes.list(filter));
|
|
328
373
|
for await (const runtime of page)
|
|
329
374
|
yield adopt(runtime);
|
|
@@ -332,8 +377,7 @@ export class Daytona {
|
|
|
332
377
|
return Object.assign(iterator, {
|
|
333
378
|
then(onFulfilled, onRejected) {
|
|
334
379
|
const all = (async () => {
|
|
335
|
-
const
|
|
336
|
-
const items = (await page.toArray(10_000)).map(adopt);
|
|
380
|
+
const items = (await everything()).map(adopt);
|
|
337
381
|
return { items, total: items.length, page: 1, totalPages: 1 };
|
|
338
382
|
})();
|
|
339
383
|
return all.then(onFulfilled, onRejected);
|
|
@@ -391,8 +435,8 @@ function refuseCreate(params) {
|
|
|
391
435
|
for (const [field, feature, alternative] of refusals)
|
|
392
436
|
if (params[field] !== undefined)
|
|
393
437
|
throw new NotSupportedError(feature, alternative);
|
|
394
|
-
if (params.user !== undefined && params.user
|
|
395
|
-
throw new
|
|
438
|
+
if (params.user !== undefined && !/^[a-z_][a-z0-9_-]{0,31}$/.test(params.user))
|
|
439
|
+
throw new DaytonaError(`Invalid user name ${JSON.stringify(params.user)}.`, 400);
|
|
396
440
|
if (params.language !== undefined &&
|
|
397
441
|
!["python", "javascript", "typescript"].includes(params.language))
|
|
398
442
|
throw new NotSupportedError(`The language ${params.language}`, "Use python, javascript or typescript; run anything else with process.executeCommand.");
|
|
@@ -408,6 +452,7 @@ export function lifecycleOf(params) {
|
|
|
408
452
|
const autoDelete = params.ephemeral ? 0 : (params.autoDeleteInterval ?? -1);
|
|
409
453
|
return {
|
|
410
454
|
windowSeconds: windowSeconds(autoStop),
|
|
455
|
+
idleSeconds: idleSeconds(autoStop),
|
|
411
456
|
...(params.ttlMinutes ? { deadline: Date.now() + params.ttlMinutes * 60_000 } : {}),
|
|
412
457
|
ephemeral: autoDelete === 0,
|
|
413
458
|
autoStopInterval: autoStop,
|
|
@@ -415,6 +460,85 @@ export function lifecycleOf(params) {
|
|
|
415
460
|
autoDeleteInterval: autoDelete,
|
|
416
461
|
};
|
|
417
462
|
}
|
|
463
|
+
/** What list() takes; isPublic, snapshots and autoDestroyAt are refused. */
|
|
464
|
+
const LISTED = new Set([
|
|
465
|
+
"limit",
|
|
466
|
+
"sort",
|
|
467
|
+
"order",
|
|
468
|
+
"id",
|
|
469
|
+
"name",
|
|
470
|
+
"labels",
|
|
471
|
+
"states",
|
|
472
|
+
"targets",
|
|
473
|
+
"minCpu",
|
|
474
|
+
"maxCpu",
|
|
475
|
+
"minMemoryGib",
|
|
476
|
+
"maxMemoryGib",
|
|
477
|
+
"minDiskGib",
|
|
478
|
+
"maxDiskGib",
|
|
479
|
+
"isRecoverable",
|
|
480
|
+
"createdAtAfter",
|
|
481
|
+
"createdAtBefore",
|
|
482
|
+
"lastActivityAfter",
|
|
483
|
+
"lastActivityBefore",
|
|
484
|
+
]);
|
|
485
|
+
const lastActivity = (one) => Date.parse(one.info.lastActiveAt ?? one.info.readyAt ?? one.info.createdAt);
|
|
486
|
+
const SORTS = {
|
|
487
|
+
name: (one) => one.info.name ?? one.id,
|
|
488
|
+
cpu: (one) => one.info.vcpu,
|
|
489
|
+
memoryGib: (one) => one.info.memoryMiB / 1024,
|
|
490
|
+
diskGib: (one) => one.info.diskMiB / 1024,
|
|
491
|
+
lastActivityAt: lastActivity,
|
|
492
|
+
createdAt: (one) => Date.parse(one.info.createdAt),
|
|
493
|
+
};
|
|
494
|
+
/** Daytona's list filters and sorting, applied here: Runtime filters by
|
|
495
|
+
* labels and state only. Sorted descending unless `order` says, as Daytona
|
|
496
|
+
* does; unsorted lists keep Runtime's order, oldest first. */
|
|
497
|
+
function arrange(all, query) {
|
|
498
|
+
const within = (value, min, max) => (min === undefined || value >= min) && (max === undefined || value <= max);
|
|
499
|
+
const time = (date) => (date === undefined ? undefined : date.getTime());
|
|
500
|
+
const kept = all.filter((one) => (query.id === undefined || one.id.toLowerCase().startsWith(query.id.toLowerCase())) &&
|
|
501
|
+
(query.name === undefined ||
|
|
502
|
+
(one.info.name ?? one.id).toLowerCase().startsWith(query.name.toLowerCase())) &&
|
|
503
|
+
(query.targets === undefined || query.targets.includes("us")) &&
|
|
504
|
+
(query.isRecoverable === undefined || query.isRecoverable === false) &&
|
|
505
|
+
within(one.info.vcpu, query.minCpu, query.maxCpu) &&
|
|
506
|
+
within(one.info.memoryMiB / 1024, query.minMemoryGib, query.maxMemoryGib) &&
|
|
507
|
+
within(one.info.diskMiB / 1024, query.minDiskGib, query.maxDiskGib) &&
|
|
508
|
+
within(Date.parse(one.info.createdAt), time(query.createdAtAfter), time(query.createdAtBefore)) &&
|
|
509
|
+
within(lastActivity(one), time(query.lastActivityAfter), time(query.lastActivityBefore)));
|
|
510
|
+
const key = query.sort === undefined ? undefined : SORTS[query.sort];
|
|
511
|
+
if (!key)
|
|
512
|
+
return query.order === "desc" ? kept.reverse() : kept;
|
|
513
|
+
const sign = query.order === "asc" ? 1 : -1;
|
|
514
|
+
return kept.sort((a, b) => {
|
|
515
|
+
const x = key(a);
|
|
516
|
+
const y = key(b);
|
|
517
|
+
return sign * (typeof x === "string" ? x.localeCompare(y) : x - y);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
/** Readies a new sandbox to run as `user`: the user must be in the image, as
|
|
521
|
+
* on Daytona. It joins the owner's group, and the working directory takes
|
|
522
|
+
* that group for what is made in it, so both may change each other's files.
|
|
523
|
+
* A user the image lacks ends the sandbox and says how to add it. */
|
|
524
|
+
async function asUser(runtime, user) {
|
|
525
|
+
const ready = await guard("sandbox", () => runtime.exec([
|
|
526
|
+
"sh",
|
|
527
|
+
"-c",
|
|
528
|
+
'id -u "$1" >/dev/null 2>&1 || exit 3; [ "$1" = root ] || { sudo usermod -aG runtime "$1" && sudo chmod 2775 /workspace; }',
|
|
529
|
+
"sh",
|
|
530
|
+
user,
|
|
531
|
+
])).catch(async (error) => {
|
|
532
|
+
await runtime.stop({ wait: false }).catch(() => undefined);
|
|
533
|
+
throw error;
|
|
534
|
+
});
|
|
535
|
+
if (ready.exitCode === 0)
|
|
536
|
+
return;
|
|
537
|
+
await runtime.stop({ wait: false }).catch(() => undefined);
|
|
538
|
+
throw new DaytonaError(ready.exitCode === 3
|
|
539
|
+
? `The user "${user}" does not exist in this sandbox's image. Add it to the image (RUN useradd -m ${user}), or leave user out to run as the sandbox owner, who has passwordless sudo.`
|
|
540
|
+
: `The sandbox could not be readied for the user "${user}": ${ready.stderr.trim() || `exit ${ready.exitCode}`}`, 400);
|
|
541
|
+
}
|
|
418
542
|
/** The sandbox with this Runtime id, or the newest live one with this name. */
|
|
419
543
|
async function find(client, idOrName) {
|
|
420
544
|
if (UUID.test(idOrName))
|
|
@@ -81,6 +81,13 @@ export class FileSystem {
|
|
|
81
81
|
async createFolder(path, mode) {
|
|
82
82
|
const target = await this.#path(path);
|
|
83
83
|
await this.#run(["mkdir", "-p", "-m", mode, "--", target]);
|
|
84
|
+
await this.#own(target);
|
|
85
|
+
}
|
|
86
|
+
/** Gives what this client wrote to create's `user`, so its commands may
|
|
87
|
+
* change it; the owner's files stay the owner's. */
|
|
88
|
+
async #own(target) {
|
|
89
|
+
if (this.#ctx.user)
|
|
90
|
+
await this.#run(["sudo", "chown", this.#ctx.user, "--", target]);
|
|
84
91
|
}
|
|
85
92
|
async deleteFile(path, recursive = false) {
|
|
86
93
|
const target = await this.#path(path);
|
|
@@ -261,6 +268,7 @@ export class FileSystem {
|
|
|
261
268
|
...request,
|
|
262
269
|
...(onProgress ? { onProgress } : {}),
|
|
263
270
|
}));
|
|
271
|
+
await this.#own(target);
|
|
264
272
|
}
|
|
265
273
|
finally {
|
|
266
274
|
request.signal?.removeEventListener("abort", stopInput);
|
package/dist/daytona/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { Daytona, CodeLanguage, SnapshotService, VolumeService, DEFAULT_RESOURCES, DEFAULT_AUTO_STOP_MINUTES, lifecycleOf, type CreateSandboxBaseParams, type CreateSandboxFromImageParams, type CreateSandboxFromSnapshotParams, type CreateSnapshotParams, type ForkSandboxParams, type ListSandboxesQuery, type PaginatedSnapshots, type Resources, type Snapshot, type Volume, type VolumeMount, } from "./daytona.js";
|
|
2
2
|
export { Sandbox, CodeInterpreter, networkRules, windowSeconds, type ExecutionError, type ExecutionResult, type InterpreterContext, type OutputMessage, type PortPreviewUrl, } from "./sandbox.js";
|
|
3
|
-
export { Process, CodeRunParams, type Command, type ExecuteResponse, type Session, type SessionCommandLogsResponse, type SessionExecuteRequest, type SessionExecuteResponse, } from "./process.js";
|
|
3
|
+
export { Process, CodeRunParams, PtyHandle, type PtyConnectOptions, type PtyCreateOptions, type PtyResult, type PtySessionInfo, type Command, type ExecuteResponse, type Session, type SessionCommandLogsResponse, type SessionExecuteRequest, type SessionExecuteResponse, } from "./process.js";
|
|
4
4
|
export { FileSystem, type FileDownloadRequest, type FileDownloadResponse, type FileInfo, type FilePermissionsParams, type FileUpload, type Match, type ReplaceResult, type SearchFilesResponse, type UploadSource, type UploadProgress, type UploadStreamOptions, } from "./filesystem.js";
|
|
5
5
|
export { Git, type GitStatus, type ListBranchResponse } from "./git.js";
|
|
6
|
+
export { Accessibility, ComputerUse, Display, Keyboard, Mouse, RecordingService, Screenshot, type ComputerUseStartResponse, type ComputerUseStatusResponse, type ComputerUseStopResponse, type DisplayInfo, type ListRecordingsResponse, type Recording, type ScreenshotOptions, type ScreenshotRegion, type ScreenshotResponse, type WindowInfo, } from "./computer-use.js";
|
|
6
7
|
export { Image } from "./image.js";
|
|
7
8
|
export { resolvePath } from "./context.js";
|
|
8
9
|
export type { DaytonaConfig, WithRuntime } from "./client.js";
|
|
@@ -18,31 +19,6 @@ export declare const SandboxState: {
|
|
|
18
19
|
readonly DESTROYED: "destroyed";
|
|
19
20
|
};
|
|
20
21
|
export type SandboxState = (typeof SandboxState)[keyof typeof SandboxState];
|
|
21
|
-
export declare const ComputerUse: {
|
|
22
|
-
(...args: unknown[]): never;
|
|
23
|
-
new (...args: unknown[]): never;
|
|
24
|
-
readonly [key: string]: (...args: unknown[]) => never;
|
|
25
|
-
};
|
|
26
|
-
export declare const Mouse: {
|
|
27
|
-
(...args: unknown[]): never;
|
|
28
|
-
new (...args: unknown[]): never;
|
|
29
|
-
readonly [key: string]: (...args: unknown[]) => never;
|
|
30
|
-
};
|
|
31
|
-
export declare const Keyboard: {
|
|
32
|
-
(...args: unknown[]): never;
|
|
33
|
-
new (...args: unknown[]): never;
|
|
34
|
-
readonly [key: string]: (...args: unknown[]) => never;
|
|
35
|
-
};
|
|
36
|
-
export declare const Screenshot: {
|
|
37
|
-
(...args: unknown[]): never;
|
|
38
|
-
new (...args: unknown[]): never;
|
|
39
|
-
readonly [key: string]: (...args: unknown[]) => never;
|
|
40
|
-
};
|
|
41
|
-
export declare const Display: {
|
|
42
|
-
(...args: unknown[]): never;
|
|
43
|
-
new (...args: unknown[]): never;
|
|
44
|
-
readonly [key: string]: (...args: unknown[]) => never;
|
|
45
|
-
};
|
|
46
22
|
export declare const LspLanguageId: {
|
|
47
23
|
(...args: unknown[]): never;
|
|
48
24
|
new (...args: unknown[]): never;
|
package/dist/daytona/index.js
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
import { NotSupportedError } from "./errors.js";
|
|
10
10
|
export { Daytona, CodeLanguage, SnapshotService, VolumeService, DEFAULT_RESOURCES, DEFAULT_AUTO_STOP_MINUTES, lifecycleOf, } from "./daytona.js";
|
|
11
11
|
export { Sandbox, CodeInterpreter, networkRules, windowSeconds, } from "./sandbox.js";
|
|
12
|
-
export { Process, CodeRunParams, } from "./process.js";
|
|
12
|
+
export { Process, CodeRunParams, PtyHandle, } from "./process.js";
|
|
13
13
|
export { FileSystem, } from "./filesystem.js";
|
|
14
14
|
export { Git } from "./git.js";
|
|
15
|
+
export { Accessibility, ComputerUse, Display, Keyboard, Mouse, RecordingService, Screenshot, } from "./computer-use.js";
|
|
15
16
|
export { Image } from "./image.js";
|
|
16
17
|
export { resolvePath } from "./context.js";
|
|
17
18
|
export * from "./errors.js";
|
|
@@ -41,10 +42,4 @@ function unsupportedExport(name, alternative) {
|
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
const DESKTOP = "Use Runtime's desktop: `await sandbox.withruntime.desktop.start()`.";
|
|
45
|
-
export const ComputerUse = unsupportedExport("computer use", DESKTOP);
|
|
46
|
-
export const Mouse = unsupportedExport("computer use (Mouse)", DESKTOP);
|
|
47
|
-
export const Keyboard = unsupportedExport("computer use (Keyboard)", DESKTOP);
|
|
48
|
-
export const Screenshot = unsupportedExport("computer use (Screenshot)", DESKTOP);
|
|
49
|
-
export const Display = unsupportedExport("computer use (Display)", DESKTOP);
|
|
50
45
|
export const LspLanguageId = unsupportedExport("language servers", "Start one in a session with process.executeSessionCommand(..., { runAsync: true }).");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Terminal } from "../sandbox.js";
|
|
1
2
|
import { quote, type SandboxContext } from "./context.js";
|
|
2
3
|
/** Daytona's ExecuteResponse. `result` is the command's stdout and stderr
|
|
3
4
|
* together, in the order they were written. */
|
|
@@ -76,11 +77,67 @@ export declare class Process {
|
|
|
76
77
|
deleteSession(sessionId: string): Promise<void>;
|
|
77
78
|
getEntrypointSession(): Promise<never>;
|
|
78
79
|
getEntrypointLogs(): Promise<never>;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
/** Starts an interactive shell on a terminal (a PTY) that outlives this
|
|
81
|
+
* connection: disconnect() leaves it running, connectPty(id) attaches
|
|
82
|
+
* again, killPtySession(id) ends it. On Runtime it is a process started
|
|
83
|
+
* with a terminal, found again by its id among the sandbox's processes. */
|
|
84
|
+
createPty(options: PtyCreateOptions & Partial<PtyConnectOptions>): Promise<PtyHandle>;
|
|
85
|
+
/** Attaches to a running PTY session. Output it printed before arrives
|
|
86
|
+
* first, then what it prints from now on. */
|
|
87
|
+
connectPty(sessionId: string, options?: Partial<PtyConnectOptions>): Promise<PtyHandle>;
|
|
88
|
+
listPtySessions(): Promise<PtySessionInfo[]>;
|
|
89
|
+
getPtySessionInfo(sessionId: string): Promise<PtySessionInfo>;
|
|
90
|
+
/** Ends the session's shell and everything it runs. */
|
|
91
|
+
killPtySession(sessionId: string): Promise<void>;
|
|
92
|
+
resizePtySession(sessionId: string, cols: number, rows: number): Promise<PtySessionInfo>;
|
|
93
|
+
}
|
|
94
|
+
/** Daytona's PtyCreateOptions. */
|
|
95
|
+
export interface PtyCreateOptions {
|
|
96
|
+
id: string;
|
|
97
|
+
cwd?: string;
|
|
98
|
+
envs?: Record<string, string>;
|
|
99
|
+
cols?: number;
|
|
100
|
+
rows?: number;
|
|
101
|
+
}
|
|
102
|
+
/** Daytona's PtyConnectOptions. */
|
|
103
|
+
export interface PtyConnectOptions {
|
|
104
|
+
onData: (data: Uint8Array) => void | Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
/** Daytona's PtyResult. */
|
|
107
|
+
export interface PtyResult {
|
|
108
|
+
exitCode?: number;
|
|
109
|
+
error?: string;
|
|
110
|
+
}
|
|
111
|
+
/** Daytona's PtySessionInfo. */
|
|
112
|
+
export interface PtySessionInfo {
|
|
113
|
+
active: boolean;
|
|
114
|
+
cols: number;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
cwd: string;
|
|
117
|
+
envs: Record<string, string>;
|
|
118
|
+
id: string;
|
|
119
|
+
lazyStart: boolean;
|
|
120
|
+
rows: number;
|
|
121
|
+
}
|
|
122
|
+
/** One connection to a PTY session, Daytona's PtyHandle over Runtime's
|
|
123
|
+
* terminal WebSocket. */
|
|
124
|
+
export declare class PtyHandle {
|
|
125
|
+
#private;
|
|
126
|
+
readonly sessionId: string;
|
|
127
|
+
/** Use process.createPty or process.connectPty. */
|
|
128
|
+
constructor(terminal: Terminal, sessionId: string, resize: (cols: number, rows: number) => Promise<PtySessionInfo>, kill: () => Promise<void>);
|
|
129
|
+
get exitCode(): number | undefined;
|
|
130
|
+
get error(): string | undefined;
|
|
131
|
+
isConnected(): boolean;
|
|
132
|
+
/** Resolves at once: the handle is returned connected. */
|
|
133
|
+
waitForConnection(): Promise<void>;
|
|
134
|
+
sendInput(data: string | Uint8Array): Promise<void>;
|
|
135
|
+
resize(cols: number, rows: number): Promise<PtySessionInfo>;
|
|
136
|
+
/** Closes this connection; the session keeps running. */
|
|
137
|
+
disconnect(): Promise<void>;
|
|
138
|
+
/** Resolves when the session ends (or this connection closes) with its
|
|
139
|
+
* exit code, or `error` saying why there is none. */
|
|
140
|
+
wait(): Promise<PtyResult>;
|
|
141
|
+
kill(): Promise<void>;
|
|
85
142
|
}
|
|
86
143
|
export { quote };
|