runcloud 0.2.207 → 0.2.209
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.
|
@@ -10,7 +10,7 @@ import { requireCredentials } from '../config.js';
|
|
|
10
10
|
import { recordSimulatorAudio } from './run-cloud-audio.js';
|
|
11
11
|
export const IOS_SIMULATOR_CAPABILITIES = ['HealthKit', 'HomeKit', 'WidgetKit', 'SpeechSynthesis', 'Contacts', 'Calendars', 'AppleAccount'];
|
|
12
12
|
export const IOS_PLATFORM_VERSIONS = ['26.5'];
|
|
13
|
-
export const IOS_DEVICE_NAMES = ['iPhone 17e'];
|
|
13
|
+
export const IOS_DEVICE_NAMES = ['iPhone 17e', 'iPad (A16)'];
|
|
14
14
|
export function runCloudIosOptions(opts) {
|
|
15
15
|
const capabilities = [...new Set(opts.capability ?? [])];
|
|
16
16
|
if (!capabilities.length && !opts.platformVersion && !opts.deviceName)
|
package/dist/commands/sandbox.js
CHANGED
|
@@ -51,13 +51,24 @@ export async function pollSandboxReady(api, id, opts = {}) {
|
|
|
51
51
|
const timeoutMs = opts.timeoutMs ?? SANDBOX_WAIT_TIMEOUT_MS;
|
|
52
52
|
const deadline = Date.now() + timeoutMs;
|
|
53
53
|
for (;;) {
|
|
54
|
-
|
|
54
|
+
let record;
|
|
55
|
+
try {
|
|
56
|
+
record = (await api.get(`/run-cloud/sandboxes/${encodeURIComponent(id)}`));
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
const transient = !(err instanceof ApiError) || err.status === 408 || err.status === 429 || err.status >= 500;
|
|
60
|
+
if (!transient || Date.now() > deadline)
|
|
61
|
+
throw err;
|
|
62
|
+
await new Promise((done) => setTimeout(done, intervalMs));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
55
65
|
const state = record.state ?? 'unknown';
|
|
56
66
|
opts.onState?.(state);
|
|
57
67
|
if (READY_STATES.has(state))
|
|
58
68
|
return record;
|
|
59
69
|
if (FAILED_STATES.has(state)) {
|
|
60
|
-
|
|
70
|
+
const reason = typeof record.last_error === 'string' && record.last_error ? `: ${record.last_error}` : '';
|
|
71
|
+
throw new Error(`sandbox ${id} entered ${state.replaceAll('_', ' ')} state${reason}`);
|
|
61
72
|
}
|
|
62
73
|
if (Date.now() > deadline) {
|
|
63
74
|
throw new Error(`Timed out after ${Math.round(timeoutMs / 1000)}s waiting for sandbox ${id} to start`);
|
|
@@ -65,6 +76,29 @@ export async function pollSandboxReady(api, id, opts = {}) {
|
|
|
65
76
|
await new Promise((done) => setTimeout(done, intervalMs));
|
|
66
77
|
}
|
|
67
78
|
}
|
|
79
|
+
async function waitForSandbox(api, record, show) {
|
|
80
|
+
if (!record.state || READY_STATES.has(record.state))
|
|
81
|
+
return record;
|
|
82
|
+
const status = show ? new StatusLine() : undefined;
|
|
83
|
+
status?.update(sandboxStatusMessage(record.state));
|
|
84
|
+
try {
|
|
85
|
+
const ready = await pollSandboxReady(api, record.id, {
|
|
86
|
+
onState: (state) => status?.update(sandboxStatusMessage(state)),
|
|
87
|
+
});
|
|
88
|
+
status?.clear();
|
|
89
|
+
return ready;
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
status?.fail('Sandbox failed to start');
|
|
93
|
+
const destroyed = await api.delete(`/run-cloud/sandboxes/${encodeURIComponent(record.id)}`).then(() => true, () => false);
|
|
94
|
+
if (err instanceof Error) {
|
|
95
|
+
err.message += destroyed
|
|
96
|
+
? ` (destroyed ${record.id})`
|
|
97
|
+
: ` (could not destroy ${record.id}; run: runcloud sandbox destroy ${record.id})`;
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
68
102
|
export async function prepareSandboxShell(api, id, status = new StatusLine()) {
|
|
69
103
|
let record = (await api.get(`/run-cloud/sandboxes/${encodeURIComponent(id)}`));
|
|
70
104
|
if (record.state === 'paused' || record.state === 'archived') {
|
|
@@ -335,6 +369,9 @@ export function registerSandbox(program) {
|
|
|
335
369
|
if (exposed && !opts.name) {
|
|
336
370
|
throw new Error('--expose needs --name <name>, the hostname prefix for <name>-box.run.cloud');
|
|
337
371
|
}
|
|
372
|
+
if (exposed && !opts.wait) {
|
|
373
|
+
throw new Error('--expose attaches the hostname once the sandbox runs; drop --no-wait');
|
|
374
|
+
}
|
|
338
375
|
if ((exposed || opts.persistent) && opts.idlePause !== undefined && opts.idlePause !== 0) {
|
|
339
376
|
throw new Error('--persistent and --expose keep the sandbox running; drop the non-zero --idle-pause');
|
|
340
377
|
}
|
|
@@ -366,24 +403,13 @@ export function registerSandbox(program) {
|
|
|
366
403
|
body.tags = tags;
|
|
367
404
|
Object.assign(body, secretSelector({ ...opts, noSecrets: opts.secrets === false }));
|
|
368
405
|
const api = runCloudApi();
|
|
406
|
+
body.wait = false;
|
|
369
407
|
let created = (await api.post('/run-cloud/sandboxes', body));
|
|
370
408
|
if (typeof created.id !== 'string') {
|
|
371
409
|
throw new Error('sandbox create response did not include an id');
|
|
372
410
|
}
|
|
373
|
-
if (
|
|
374
|
-
|
|
375
|
-
status.update(sandboxStatusMessage(created.state));
|
|
376
|
-
try {
|
|
377
|
-
created = await pollSandboxReady(api, created.id, {
|
|
378
|
-
onState: (state) => status.update(sandboxStatusMessage(state)),
|
|
379
|
-
});
|
|
380
|
-
status.clear();
|
|
381
|
-
}
|
|
382
|
-
catch (err) {
|
|
383
|
-
status.fail('Sandbox failed to start');
|
|
384
|
-
throw err;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
411
|
+
if (opts.wait)
|
|
412
|
+
created = await waitForSandbox(api, created, !opts.json);
|
|
387
413
|
if (!exposed) {
|
|
388
414
|
if (opts.json)
|
|
389
415
|
printJson(created);
|
|
@@ -779,7 +805,8 @@ export function registerSandbox(program) {
|
|
|
779
805
|
.option('--region <region>', 'placement region')
|
|
780
806
|
.option('--secret-group <group>', 'attach a secret group to the fork; a fork inherits NONE by default (secrets live in memory, so a snapshot cannot carry them)', collectRepeatable, [])
|
|
781
807
|
.option('--secret <group/name>', 'attach one secret out of a group; repeatable, order matters', collectRepeatable, [])
|
|
782
|
-
.option('--env <NAME=VALUE>', 'literal value for the fork; applied last; repeatable', collectRepeatable, [])
|
|
808
|
+
.option('--env <NAME=VALUE>', 'literal value for the fork; applied last; repeatable', collectRepeatable, [])
|
|
809
|
+
.option('--no-wait', 'return before the restored sandbox finishes starting')).action((snapshotId, opts) => run(async () => {
|
|
783
810
|
const body = {};
|
|
784
811
|
if (opts.name)
|
|
785
812
|
body.name = opts.name;
|
|
@@ -794,7 +821,11 @@ export function registerSandbox(program) {
|
|
|
794
821
|
if (opts.region)
|
|
795
822
|
body.region = opts.region;
|
|
796
823
|
Object.assign(body, secretSelector(opts));
|
|
797
|
-
|
|
824
|
+
body.wait = false;
|
|
825
|
+
const api = runCloudApi();
|
|
826
|
+
let restored = (await api.post(`/run-cloud/snapshots/${encodeURIComponent(snapshotId)}/restore`, body));
|
|
827
|
+
if (opts.wait)
|
|
828
|
+
restored = await waitForSandbox(api, restored, !opts.json);
|
|
798
829
|
if (opts.json)
|
|
799
830
|
printJson(restored);
|
|
800
831
|
else
|
|
@@ -836,10 +867,12 @@ export function registerSandbox(program) {
|
|
|
836
867
|
sandboxBody.memory = opts.memory;
|
|
837
868
|
if (opts.disk !== undefined)
|
|
838
869
|
sandboxBody.disk = opts.disk;
|
|
870
|
+
sandboxBody.wait = false;
|
|
839
871
|
const created = await api.post('/run-cloud/sandboxes', sandboxBody);
|
|
840
872
|
sandboxId = typeof created?.id === 'string' ? created.id : undefined;
|
|
841
873
|
if (!sandboxId)
|
|
842
874
|
throw new Error('sandbox create response did not include an id');
|
|
875
|
+
await waitForSandbox(api, created, false);
|
|
843
876
|
}
|
|
844
877
|
print(await attachHostname(api, sandboxId, name, opts.port), opts);
|
|
845
878
|
});
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.2.
|
|
1
|
+
export const CLI_VERSION = '0.2.209';
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -366,6 +366,29 @@ Two limits. The agent is part of the image, so a sandbox on an image built
|
|
|
366
366
|
before this existed writes nothing, and silence there proves nothing. And a guest
|
|
367
367
|
that stalls within a few seconds can stop the agent before it writes.
|
|
368
368
|
|
|
369
|
+
### A command that runs out of memory
|
|
370
|
+
|
|
371
|
+
Commands share a memory limit below the sandbox's memory: about 50 MiB less in
|
|
372
|
+
a 128 or 512 MiB sandbox, 190 MiB less at 2 GiB, 370 MiB less at 8 GiB. Each
|
|
373
|
+
command also has a limit of its own: what the other commands leave free. So a
|
|
374
|
+
command that grows reaches its own limit, and the kernel kills one of that
|
|
375
|
+
command's processes, not a process another command left running. A command
|
|
376
|
+
that starts when there is no room left fails at once for the same reason.
|
|
377
|
+
|
|
378
|
+
The command's stderr then ends with
|
|
379
|
+
`guestagent: out of memory: the kernel killed a process of this command`, also
|
|
380
|
+
when the command went on and exited 0. A terminal session gets the line when
|
|
381
|
+
it ends. The console gets a
|
|
382
|
+
`--- guest memory: out of memory …` line for every kill, also when the killed
|
|
383
|
+
process was left running by a command that returned long before. The agent and
|
|
384
|
+
the other commands keep running.
|
|
385
|
+
|
|
386
|
+
Limits of this: a process started over SSH or as a systemd unit is outside the
|
|
387
|
+
groups. Two commands that grow at the same moment can still reach the shared
|
|
388
|
+
limit, and then the kernel kills the largest process. And close below a limit,
|
|
389
|
+
work that reads files can stall with no kill: other commands still answer, and
|
|
390
|
+
the `--- guest memory pressure` lines show it.
|
|
391
|
+
|
|
369
392
|
### Lifecycle markers
|
|
370
393
|
|
|
371
394
|
The host writes a marker into the console on every transition:
|
|
@@ -405,6 +428,15 @@ now rather than clearing it, so a sandbox parked by `timeout-sweep` will park ag
|
|
|
405
428
|
after the same interval; raise the cap first with the SDK's
|
|
406
429
|
`cloud.sandboxes.setTimeout(id, seconds)`, which has no CLI equivalent.
|
|
407
430
|
|
|
431
|
+
**A guest that stopped answering is not parked.** A memory snapshot keeps the
|
|
432
|
+
guest as it is, and a restored guest that does not answer cannot be resumed. So
|
|
433
|
+
the host first checks that the guest answers, and refuses the pause when it does
|
|
434
|
+
not. The sandbox then stays `running` and `Last error` reads
|
|
435
|
+
`pause (idle-sweep): … guest is not answering`. At its `--timeout` it is stopped
|
|
436
|
+
with its disk kept (`stopped`) and not paused. This is a guest fault (most often
|
|
437
|
+
out of memory, see the `--- guest memory pressure` lines in the console), not a
|
|
438
|
+
host fault.
|
|
439
|
+
|
|
408
440
|
**The `--timeout` trap.** `--timeout` is a wall-clock lifetime cap, wholly separate
|
|
409
441
|
from `--idle-pause`. It fires on a fully busy sandbox, and `--persistent` /
|
|
410
442
|
`--idle-pause 0` do **not** hold it off, despite `--persistent` reading as "never
|
package/runcloud-0.2.207.tgz
DELETED
|
Binary file
|