sandbox 3.0.0-beta.6 → 3.0.0-beta.8
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.
|
@@ -7427,7 +7427,7 @@ const scope = {
|
|
|
7427
7427
|
|
|
7428
7428
|
//#endregion
|
|
7429
7429
|
//#region package.json
|
|
7430
|
-
var version = "3.0.0-beta.
|
|
7430
|
+
var version = "3.0.0-beta.8";
|
|
7431
7431
|
|
|
7432
7432
|
//#endregion
|
|
7433
7433
|
//#region src/error.ts
|
|
@@ -11395,11 +11395,16 @@ async function startInteractiveShell(options) {
|
|
|
11395
11395
|
await setupSandboxEnvironment(options.sandbox, progress);
|
|
11396
11396
|
progress.text = "Booting up interactive listener...";
|
|
11397
11397
|
command$1 = await startServerCommand(options.sandbox, listener, options.execution, options.sudo, options.envVars, options.cwd);
|
|
11398
|
+
debug$1("startServerCommand completed, cmdId=%s, interactivePort=%s", command$1.cmdId, options.sandbox.interactivePort);
|
|
11398
11399
|
const waitForProcess = _usingCtx3.u(createAbortController("Connection established successfully"));
|
|
11399
11400
|
listener.connection.then(() => {
|
|
11401
|
+
debug$1("listener.connection resolved");
|
|
11400
11402
|
waitForProcess.abort();
|
|
11401
11403
|
});
|
|
11402
|
-
connect$1(command$1, listener, waitForProcess.signal).catch(
|
|
11404
|
+
connect$1(command$1, listener, waitForProcess.signal).catch((err$1) => {
|
|
11405
|
+
if (waitForProcess.signal.aborted) return;
|
|
11406
|
+
listener.stdoutStream.destroy(err$1 instanceof Error ? err$1 : new Error(String(err$1)));
|
|
11407
|
+
});
|
|
11403
11408
|
await Promise.all([throwIfCommandPrematurelyExited(command$1, waitForProcess.signal), attach({
|
|
11404
11409
|
sandbox: options.sandbox,
|
|
11405
11410
|
progress,
|
|
@@ -11502,6 +11507,7 @@ async function connect$1(command$1, listener, signal) {
|
|
|
11502
11507
|
const stderrStream = _usingCtx5.u(getStderrStream());
|
|
11503
11508
|
for await (const chunk of logs) if (chunk.stream === "stdout") listener.stdoutStream.write(chunk.data);
|
|
11504
11509
|
else stderrStream.write(chunk.data);
|
|
11510
|
+
listener.stdoutStream.end();
|
|
11505
11511
|
} catch (_) {
|
|
11506
11512
|
_usingCtx5.e = _;
|
|
11507
11513
|
} finally {
|
|
@@ -11774,6 +11780,12 @@ const args$2 = {
|
|
|
11774
11780
|
type: ObjectFromKeyValue,
|
|
11775
11781
|
description: "Default environment variables for sandbox commands"
|
|
11776
11782
|
}),
|
|
11783
|
+
tags: import_cjs$14.multioption({
|
|
11784
|
+
long: "tag",
|
|
11785
|
+
short: "t",
|
|
11786
|
+
type: ObjectFromKeyValue,
|
|
11787
|
+
description: "Key-value tags to associate with the sandbox (e.g. --tag env=staging)"
|
|
11788
|
+
}),
|
|
11777
11789
|
...networkPolicyArgs,
|
|
11778
11790
|
scope
|
|
11779
11791
|
};
|
|
@@ -11785,7 +11797,7 @@ const create = import_cjs$14.command({
|
|
|
11785
11797
|
description: "Create and connect to a sandbox without a network access",
|
|
11786
11798
|
command: `sandbox run --network-policy=none --connect`
|
|
11787
11799
|
}],
|
|
11788
|
-
async handler({ name, nonPersistent, ports, scope: scope$1, runtime: runtime$1, timeout: timeout$1, vcpus: vcpus$1, silent, snapshot: snapshot$1, connect: connect$2, envVars, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
11800
|
+
async handler({ name, nonPersistent, ports, scope: scope$1, runtime: runtime$1, timeout: timeout$1, vcpus: vcpus$1, silent, snapshot: snapshot$1, connect: connect$2, envVars, tags, networkPolicy: networkPolicyMode$1, allowedDomains: allowedDomains$1, allowedCIDRs: allowedCIDRs$1, deniedCIDRs: deniedCIDRs$1 }) {
|
|
11789
11801
|
const networkPolicy$1 = buildNetworkPolicy({
|
|
11790
11802
|
networkPolicy: networkPolicyMode$1,
|
|
11791
11803
|
allowedDomains: allowedDomains$1,
|
|
@@ -11794,6 +11806,7 @@ const create = import_cjs$14.command({
|
|
|
11794
11806
|
});
|
|
11795
11807
|
const persistent = !nonPersistent;
|
|
11796
11808
|
const resources = vcpus$1 ? { vcpus: vcpus$1 } : void 0;
|
|
11809
|
+
const tagsObj = Object.keys(tags).length > 0 ? tags : void 0;
|
|
11797
11810
|
const spinner = silent ? void 0 : ora("Creating sandbox...").start();
|
|
11798
11811
|
const sandbox = snapshot$1 ? await sandboxClient.create({
|
|
11799
11812
|
name,
|
|
@@ -11809,6 +11822,7 @@ const create = import_cjs$14.command({
|
|
|
11809
11822
|
resources,
|
|
11810
11823
|
networkPolicy: networkPolicy$1,
|
|
11811
11824
|
env: envVars,
|
|
11825
|
+
tags: tagsObj,
|
|
11812
11826
|
persistent,
|
|
11813
11827
|
__interactive: true
|
|
11814
11828
|
}) : await sandboxClient.create({
|
|
@@ -11822,6 +11836,7 @@ const create = import_cjs$14.command({
|
|
|
11822
11836
|
resources,
|
|
11823
11837
|
networkPolicy: networkPolicy$1,
|
|
11824
11838
|
env: envVars,
|
|
11839
|
+
tags: tagsObj,
|
|
11825
11840
|
persistent,
|
|
11826
11841
|
__interactive: true
|
|
11827
11842
|
});
|
|
@@ -11952,22 +11967,27 @@ const list = import_cjs$12.command({
|
|
|
11952
11967
|
description: "Sort sandboxes by field. Options: createdAt (default), name",
|
|
11953
11968
|
type: import_cjs$12.optional(import_cjs$12.oneOf(["createdAt", "name"]))
|
|
11954
11969
|
}),
|
|
11970
|
+
tags: import_cjs$12.multioption({
|
|
11971
|
+
long: "tag",
|
|
11972
|
+
description: "Filter sandboxes by tag. Format: \"key=value\"",
|
|
11973
|
+
type: ObjectFromKeyValue
|
|
11974
|
+
}),
|
|
11955
11975
|
scope
|
|
11956
11976
|
},
|
|
11957
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, all, namePrefix, sortBy }) {
|
|
11977
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, all, namePrefix, sortBy, tags }) {
|
|
11958
11978
|
const sandboxes = await (async () => {
|
|
11959
11979
|
try {
|
|
11960
11980
|
var _usingCtx$1 = _usingCtx();
|
|
11961
11981
|
const _spinner$1 = _usingCtx$1.u(acquireRelease(() => ora("Fetching sandboxes...").start(), (s$1) => s$1.stop()));
|
|
11962
|
-
|
|
11982
|
+
let { sandboxes: sandboxes$1 } = await sandboxClient.list({
|
|
11963
11983
|
token: token$1,
|
|
11964
11984
|
teamId: team$1,
|
|
11965
11985
|
projectId: project$1,
|
|
11966
11986
|
limit: 100,
|
|
11967
11987
|
...namePrefix && { namePrefix },
|
|
11968
|
-
...sortBy && { sortBy }
|
|
11988
|
+
...sortBy && { sortBy },
|
|
11989
|
+
...Object.keys(tags).length > 0 && { tags }
|
|
11969
11990
|
});
|
|
11970
|
-
let sandboxes$1 = json.sandboxes;
|
|
11971
11991
|
if (!all) sandboxes$1 = sandboxes$1.filter((x) => x.status === "running");
|
|
11972
11992
|
return sandboxes$1;
|
|
11973
11993
|
} catch (_) {
|
|
@@ -11991,7 +12011,8 @@ const list = import_cjs$12.command({
|
|
|
11991
12011
|
VCPUS: { value: (s$1) => s$1.vcpus ?? "-" },
|
|
11992
12012
|
RUNTIME: { value: (s$1) => s$1.runtime ?? "-" },
|
|
11993
12013
|
TIMEOUT: { value: (s$1) => s$1.timeout != null ? timeAgo(s$1.createdAt + s$1.timeout) : "-" },
|
|
11994
|
-
SNAPSHOT: { value: (s$1) => s$1.currentSnapshotId ?? "-" }
|
|
12014
|
+
SNAPSHOT: { value: (s$1) => s$1.currentSnapshotId ?? "-" },
|
|
12015
|
+
TAGS: { value: (s$1) => s$1.tags && Object.keys(s$1.tags).length > 0 ? Object.entries(s$1.tags).map(([k, v]) => `${k}:${v}`).join(", ") : "-" }
|
|
11995
12016
|
};
|
|
11996
12017
|
if (all) {
|
|
11997
12018
|
columns.CPU = { value: (s$1) => s$1.totalActiveCpuDurationMs ? formatRunDuration(s$1.totalActiveCpuDurationMs) : "-" };
|
|
@@ -14333,9 +14354,9 @@ const stop = import_cjs$10.command({
|
|
|
14333
14354
|
scope
|
|
14334
14355
|
},
|
|
14335
14356
|
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandboxName: sandboxName$1, sandboxNames }) {
|
|
14336
|
-
|
|
14357
|
+
const tasks = Array.from(new Set([sandboxName$1, ...sandboxNames]), (sandboxName$2) => {
|
|
14337
14358
|
return {
|
|
14338
|
-
title: `Stopping
|
|
14359
|
+
title: `Stopping active session from ${sandboxName$2}`,
|
|
14339
14360
|
async task() {
|
|
14340
14361
|
await (await sandboxClient.get({
|
|
14341
14362
|
token: token$1,
|
|
@@ -14345,7 +14366,12 @@ const stop = import_cjs$10.command({
|
|
|
14345
14366
|
})).stop();
|
|
14346
14367
|
}
|
|
14347
14368
|
};
|
|
14348
|
-
})
|
|
14369
|
+
});
|
|
14370
|
+
try {
|
|
14371
|
+
await new Listr(tasks, { concurrent: true }).run();
|
|
14372
|
+
} catch {
|
|
14373
|
+
process.exitCode = 1;
|
|
14374
|
+
}
|
|
14349
14375
|
}
|
|
14350
14376
|
});
|
|
14351
14377
|
|
|
@@ -14368,7 +14394,7 @@ const remove = import_cjs$9.command({
|
|
|
14368
14394
|
scope
|
|
14369
14395
|
},
|
|
14370
14396
|
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandboxName: sandboxName$1, sandboxNames }) {
|
|
14371
|
-
|
|
14397
|
+
const tasks = Array.from(new Set([sandboxName$1, ...sandboxNames]), (name) => ({
|
|
14372
14398
|
title: `Removing sandbox ${name}`,
|
|
14373
14399
|
async task() {
|
|
14374
14400
|
await (await sandboxClient.get({
|
|
@@ -14378,7 +14404,12 @@ const remove = import_cjs$9.command({
|
|
|
14378
14404
|
name
|
|
14379
14405
|
})).delete();
|
|
14380
14406
|
}
|
|
14381
|
-
}))
|
|
14407
|
+
}));
|
|
14408
|
+
try {
|
|
14409
|
+
await new Listr(tasks, { concurrent: true }).run();
|
|
14410
|
+
} catch {
|
|
14411
|
+
process.exitCode = 1;
|
|
14412
|
+
}
|
|
14382
14413
|
}
|
|
14383
14414
|
});
|
|
14384
14415
|
|
|
@@ -14560,14 +14591,14 @@ const list$2 = import_cjs$4.command({
|
|
|
14560
14591
|
try {
|
|
14561
14592
|
var _usingCtx$1 = _usingCtx();
|
|
14562
14593
|
const _spinner$1 = _usingCtx$1.u(acquireRelease(() => ora("Fetching snapshots...").start(), (s$1) => s$1.stop()));
|
|
14563
|
-
const {
|
|
14594
|
+
const { snapshots: snapshots$2 } = await snapshotClient.list({
|
|
14564
14595
|
token: token$1,
|
|
14565
14596
|
teamId: team$1,
|
|
14566
14597
|
projectId: project$1,
|
|
14567
14598
|
name,
|
|
14568
14599
|
limit: 100
|
|
14569
14600
|
});
|
|
14570
|
-
return
|
|
14601
|
+
return snapshots$2;
|
|
14571
14602
|
} catch (_) {
|
|
14572
14603
|
_usingCtx$1.e = _;
|
|
14573
14604
|
} finally {
|
|
@@ -14649,7 +14680,7 @@ const remove$1 = import_cjs$4.command({
|
|
|
14649
14680
|
scope
|
|
14650
14681
|
},
|
|
14651
14682
|
async handler({ scope: { team: team$1, token: token$1, project: project$1 }, snapshotId: snapshotId$1, snapshotIds }) {
|
|
14652
|
-
|
|
14683
|
+
const tasks = Array.from(new Set([snapshotId$1, ...snapshotIds]), (snapshotId$2) => {
|
|
14653
14684
|
return {
|
|
14654
14685
|
title: `Deleting snapshot ${snapshotId$2}`,
|
|
14655
14686
|
async task() {
|
|
@@ -14663,7 +14694,12 @@ const remove$1 = import_cjs$4.command({
|
|
|
14663
14694
|
await snapshot$1.delete();
|
|
14664
14695
|
}
|
|
14665
14696
|
};
|
|
14666
|
-
})
|
|
14697
|
+
});
|
|
14698
|
+
try {
|
|
14699
|
+
await new Listr(tasks, { concurrent: true }).run();
|
|
14700
|
+
} catch {
|
|
14701
|
+
process.exitCode = 1;
|
|
14702
|
+
}
|
|
14667
14703
|
}
|
|
14668
14704
|
});
|
|
14669
14705
|
const snapshots = (0, import_cjs$5.subcommands)({
|
|
@@ -14691,20 +14727,25 @@ const list$1 = import_cjs$2.command({
|
|
|
14691
14727
|
aliases: ["ls"],
|
|
14692
14728
|
description: "List sessions from a sandbox",
|
|
14693
14729
|
args: {
|
|
14730
|
+
all: import_cjs$2.flag({
|
|
14731
|
+
long: "all",
|
|
14732
|
+
short: "a",
|
|
14733
|
+
description: "Show all sessions (default shows just running)"
|
|
14734
|
+
}),
|
|
14694
14735
|
sandbox: import_cjs$2.positional({
|
|
14695
14736
|
type: sandboxName,
|
|
14696
14737
|
description: "Sandbox name to list sessions for"
|
|
14697
14738
|
}),
|
|
14698
14739
|
scope
|
|
14699
14740
|
},
|
|
14700
|
-
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, sandbox: name }) {
|
|
14741
|
+
async handler({ scope: { token: token$1, team: team$1, project: project$1 }, all, sandbox: name }) {
|
|
14701
14742
|
const sandbox = await sandboxClient.get({
|
|
14702
14743
|
name,
|
|
14703
14744
|
projectId: project$1,
|
|
14704
14745
|
teamId: team$1,
|
|
14705
14746
|
token: token$1
|
|
14706
14747
|
});
|
|
14707
|
-
|
|
14748
|
+
let { sessions: sessions$1 } = await (async () => {
|
|
14708
14749
|
try {
|
|
14709
14750
|
var _usingCtx$1 = _usingCtx();
|
|
14710
14751
|
const _spinner$1 = _usingCtx$1.u(acquireRelease(() => ora("Fetching sessions...").start(), (s$1) => s$1.stop()));
|
|
@@ -14714,22 +14755,33 @@ const list$1 = import_cjs$2.command({
|
|
|
14714
14755
|
} finally {
|
|
14715
14756
|
_usingCtx$1.d();
|
|
14716
14757
|
}
|
|
14717
|
-
})()
|
|
14758
|
+
})();
|
|
14759
|
+
if (!all) sessions$1 = sessions$1.filter((x) => x.status === "running");
|
|
14760
|
+
const memoryFormatter = new Intl.NumberFormat(void 0, {
|
|
14761
|
+
style: "unit",
|
|
14762
|
+
unit: "megabyte"
|
|
14763
|
+
});
|
|
14764
|
+
const columns = {
|
|
14765
|
+
ID: { value: (s$1) => s$1.id },
|
|
14766
|
+
STATUS: {
|
|
14767
|
+
value: (s$1) => s$1.status,
|
|
14768
|
+
color: (s$1) => SessionStatusColor[s$1.status] ?? source_default.reset
|
|
14769
|
+
},
|
|
14770
|
+
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14771
|
+
MEMORY: { value: (s$1) => memoryFormatter.format(s$1.memory) },
|
|
14772
|
+
VCPUS: { value: (s$1) => s$1.vcpus },
|
|
14773
|
+
RUNTIME: { value: (s$1) => s$1.runtime },
|
|
14774
|
+
TIMEOUT: { value: (s$1) => timeAgo(s$1.createdAt + s$1.timeout) },
|
|
14775
|
+
DURATION: { value: (s$1) => s$1.duration ? formatRunDuration(s$1.duration) : "-" },
|
|
14776
|
+
SNAPSHOT: { value: (s$1) => s$1.sourceSnapshotId ?? "-" }
|
|
14777
|
+
};
|
|
14778
|
+
if (all) {
|
|
14779
|
+
columns.CPU = { value: (s$1) => s$1.activeCpuDurationMs ? formatRunDuration(s$1.activeCpuDurationMs) : "-" };
|
|
14780
|
+
columns["NETWORK (OUT/IN)"] = { value: (s$1) => s$1.networkTransfer?.egress || s$1.networkTransfer?.ingress ? `${formatBytes(s$1.networkTransfer?.egress ?? 0)} / ${formatBytes(s$1.networkTransfer?.ingress ?? 0)}` : "- / -" };
|
|
14781
|
+
}
|
|
14718
14782
|
console.log(table({
|
|
14719
14783
|
rows: sessions$1,
|
|
14720
|
-
columns
|
|
14721
|
-
ID: { value: (s$1) => s$1.id },
|
|
14722
|
-
STATUS: {
|
|
14723
|
-
value: (s$1) => s$1.status,
|
|
14724
|
-
color: (s$1) => SessionStatusColor[s$1.status] ?? source_default.reset
|
|
14725
|
-
},
|
|
14726
|
-
CREATED: { value: (s$1) => timeAgo(s$1.createdAt) },
|
|
14727
|
-
MEMORY: { value: (s$1) => s$1.memory },
|
|
14728
|
-
VCPUS: { value: (s$1) => s$1.vcpus },
|
|
14729
|
-
RUNTIME: { value: (s$1) => s$1.runtime },
|
|
14730
|
-
TIMEOUT: { value: (s$1) => timeAgo(s$1.createdAt + s$1.timeout) },
|
|
14731
|
-
DURATION: { value: (s$1) => s$1.duration ? formatRunDuration(s$1.duration) : "-" }
|
|
14732
|
-
}
|
|
14784
|
+
columns
|
|
14733
14785
|
}));
|
|
14734
14786
|
}
|
|
14735
14787
|
});
|
|
@@ -15009,4 +15061,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
|
|
|
15009
15061
|
|
|
15010
15062
|
//#endregion
|
|
15011
15063
|
export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
|
|
15012
|
-
//# sourceMappingURL=app-
|
|
15064
|
+
//# sourceMappingURL=app-K77UztMr.mjs.map
|