runcloud 0.2.221 → 0.2.223
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/dist/commands/run-cloud.js +112 -0
- package/dist/commands/sandbox.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/runcloud-0.2.223.tgz +0 -0
- package/skills/run-cloud-ios-simulator/SKILL.md +22 -1
- package/skills/run-cloud-sandboxes/SKILL.md +16 -0
- package/runcloud-0.2.221.tgz +0 -0
|
@@ -1185,6 +1185,73 @@ async function simulatorSessionSettings(platform, sessionId, softKeyboard) {
|
|
|
1185
1185
|
throw error;
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
|
+
export const SIMULATOR_APPEARANCES = ['light', 'dark'];
|
|
1189
|
+
export const SIMULATOR_PERMISSION_SERVICES = [
|
|
1190
|
+
'camera', 'microphone', 'location', 'location-always', 'notifications', 'photos',
|
|
1191
|
+
'contacts', 'calendar', 'reminders', 'motion', 'media-library', 'siri',
|
|
1192
|
+
];
|
|
1193
|
+
export const SIMULATOR_PERMISSION_ACTIONS = ['grant', 'revoke', 'reset'];
|
|
1194
|
+
const SIMULATOR_APP_ID_PATTERN = /^[A-Za-z0-9._-]{1,255}$/;
|
|
1195
|
+
const SIMULATOR_PUSH_MAX_BYTES = 4096;
|
|
1196
|
+
function parseSimulatorAppId(value) {
|
|
1197
|
+
if (!SIMULATOR_APP_ID_PATTERN.test(value)) {
|
|
1198
|
+
throw new InvalidArgumentError("must be 1-255 characters of A-Z, a-z, 0-9, '.', '_' or '-'");
|
|
1199
|
+
}
|
|
1200
|
+
return value;
|
|
1201
|
+
}
|
|
1202
|
+
function parseAllowed(allowed, value, field) {
|
|
1203
|
+
if (!allowed.includes(value)) {
|
|
1204
|
+
throw new InvalidArgumentError(`${field} must be one of ${allowed.join(', ')}`);
|
|
1205
|
+
}
|
|
1206
|
+
return value;
|
|
1207
|
+
}
|
|
1208
|
+
export function readSimulatorPushPayload(file, readStdin = () => readFileSync(0)) {
|
|
1209
|
+
const raw = file === '-' ? readStdin() : readFileSync(resolve(file));
|
|
1210
|
+
let payload;
|
|
1211
|
+
try {
|
|
1212
|
+
payload = JSON.parse(raw.toString('utf8'));
|
|
1213
|
+
}
|
|
1214
|
+
catch {
|
|
1215
|
+
throw new Error('The push payload must be valid JSON');
|
|
1216
|
+
}
|
|
1217
|
+
const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1218
|
+
if (!isObject(payload) || !isObject(payload.aps))
|
|
1219
|
+
throw new Error('The push payload must be a JSON object with an "aps" object');
|
|
1220
|
+
const bytes = Buffer.byteLength(JSON.stringify(payload), 'utf8');
|
|
1221
|
+
if (bytes > SIMULATOR_PUSH_MAX_BYTES)
|
|
1222
|
+
throw new Error(`The push payload is ${bytes} bytes; the limit is ${SIMULATOR_PUSH_MAX_BYTES}`);
|
|
1223
|
+
return payload;
|
|
1224
|
+
}
|
|
1225
|
+
async function simulatorDeviceControl(platform, sessionId, kind, body) {
|
|
1226
|
+
const path = `/run-cloud/${platform}/${encodeURIComponent(sessionId)}/${kind}`;
|
|
1227
|
+
try {
|
|
1228
|
+
const response = await client().post(path, body);
|
|
1229
|
+
const result = typeof response === 'object' && response !== null && !Array.isArray(response)
|
|
1230
|
+
? response
|
|
1231
|
+
: {};
|
|
1232
|
+
if (result.ok !== true || result.platform !== platform || result.sessionId !== sessionId || typeof result.device !== 'string') {
|
|
1233
|
+
throw new ApiError(0, `Simulator ${kind} returned an invalid acknowledgement`, path, {
|
|
1234
|
+
code: 'device_control_invalid_response', retryable: true, sessionId, platform, action: kind,
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
return result;
|
|
1238
|
+
}
|
|
1239
|
+
catch (error) {
|
|
1240
|
+
if (error instanceof ApiTransportError) {
|
|
1241
|
+
throw new ApiError(0, `Simulator ${kind} could not reach the run.cloud API`, path, {
|
|
1242
|
+
code: 'device_control_transport_error', retryable: true, sessionId, platform, action: kind,
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
if (error instanceof ApiError) {
|
|
1246
|
+
Object.assign(error, {
|
|
1247
|
+
sessionId: error.sessionId ?? sessionId,
|
|
1248
|
+
platform: error.platform ?? platform,
|
|
1249
|
+
action: error.action ?? kind,
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
throw error;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1188
1255
|
function registerSimulatorCommands(program, platform) {
|
|
1189
1256
|
const label = platform === 'android' ? 'Android emulator' : 'iOS simulator';
|
|
1190
1257
|
const article = platform === 'android' ? 'an' : 'an';
|
|
@@ -1329,6 +1396,51 @@ function registerSimulatorCommands(program, platform) {
|
|
|
1329
1396
|
.action((id, opts) => action(async () => {
|
|
1330
1397
|
print(await simulatorSessionSettings(platform, id, opts.softKeyboard), opts);
|
|
1331
1398
|
}, opts));
|
|
1399
|
+
simulator
|
|
1400
|
+
.command('appearance')
|
|
1401
|
+
.description(`Switch ${article} ${label} session to light or dark appearance`)
|
|
1402
|
+
.argument('<id>', 'session id')
|
|
1403
|
+
.argument('<mode>', 'light or dark', (value) => parseAllowed(SIMULATOR_APPEARANCES, value, 'mode'))
|
|
1404
|
+
.option('--json', 'output JSON', false)
|
|
1405
|
+
.action((id, mode, opts) => action(async () => {
|
|
1406
|
+
print(await simulatorDeviceControl(platform, id, 'appearance', { mode }), opts);
|
|
1407
|
+
}, opts));
|
|
1408
|
+
const appKey = platform === 'android' ? 'packageName' : 'bundleId';
|
|
1409
|
+
const permissions = simulator
|
|
1410
|
+
.command('permissions')
|
|
1411
|
+
.alias('permission')
|
|
1412
|
+
.description(`Grant, revoke, or reset app privacy permissions in ${article} ${label} session`);
|
|
1413
|
+
for (const verb of SIMULATOR_PERMISSION_ACTIONS) {
|
|
1414
|
+
permissions
|
|
1415
|
+
.command(verb)
|
|
1416
|
+
.description(verb === 'reset'
|
|
1417
|
+
? 'Reset permissions so the app asks again'
|
|
1418
|
+
: `${verb === 'grant' ? 'Grant' : 'Revoke'} permissions for an app`)
|
|
1419
|
+
.argument('<id>', 'session id')
|
|
1420
|
+
.argument('<services...>', `one or more of ${SIMULATOR_PERMISSION_SERVICES.join(', ')}`, (value, previous = []) => [...previous, parseAllowed(SIMULATOR_PERMISSION_SERVICES, value, 'service')])
|
|
1421
|
+
.requiredOption('--app <id>', platform === 'android' ? 'Android package name' : 'iOS bundle identifier', parseSimulatorAppId)
|
|
1422
|
+
.option('--json', 'output JSON', false)
|
|
1423
|
+
.action((id, services, opts) => action(async () => {
|
|
1424
|
+
const results = [];
|
|
1425
|
+
for (const service of services) {
|
|
1426
|
+
results.push(await simulatorDeviceControl(platform, id, 'permissions', { [appKey]: opts.app, service, action: verb }));
|
|
1427
|
+
}
|
|
1428
|
+
print(results.length === 1 ? results[0] : results, opts);
|
|
1429
|
+
}, opts));
|
|
1430
|
+
}
|
|
1431
|
+
if (platform === 'ios') {
|
|
1432
|
+
simulator
|
|
1433
|
+
.command('push')
|
|
1434
|
+
.description('Deliver a simulated APNs push notification to an app (simctl push)')
|
|
1435
|
+
.argument('<id>', 'session id')
|
|
1436
|
+
.argument('<payload>', 'APNs JSON file with an "aps" object (max 4 KiB), or - for stdin')
|
|
1437
|
+
.requiredOption('--app <bundle-id>', 'iOS bundle identifier', parseSimulatorAppId)
|
|
1438
|
+
.option('--json', 'output JSON', false)
|
|
1439
|
+
.action((id, file, opts) => action(async () => {
|
|
1440
|
+
const payload = readSimulatorPushPayload(file);
|
|
1441
|
+
print(await simulatorDeviceControl(platform, id, 'push', { bundleId: opts.app, payload }), opts);
|
|
1442
|
+
}, opts));
|
|
1443
|
+
}
|
|
1332
1444
|
addInteractionOptions(simulator
|
|
1333
1445
|
.command('tap')
|
|
1334
1446
|
.description(`Tap normalized display coordinates in ${article} ${label} session`)
|
package/dist/commands/sandbox.js
CHANGED
|
@@ -690,7 +690,7 @@ export function registerSandbox(program) {
|
|
|
690
690
|
.command('desktop')
|
|
691
691
|
.description('Open a signed browser desktop for a runcloud/desktop sandbox')
|
|
692
692
|
.argument('<id>', 'sandbox id')
|
|
693
|
-
.option('--url', 'print the signed
|
|
693
|
+
.option('--url', 'print the signed desktop URL instead of opening it', false)
|
|
694
694
|
.option('--view-only', 'disable keyboard and pointer input', false)).action((id, opts) => run(async () => {
|
|
695
695
|
const desktop = await runCloudApi().post(`/run-cloud/sandboxes/${encodeURIComponent(id)}/desktop`, { viewOnly: opts.viewOnly });
|
|
696
696
|
if (typeof desktop?.url !== 'string' || !desktop.url.startsWith('https://')) {
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.2.
|
|
1
|
+
export const CLI_VERSION = '0.2.223';
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -40,7 +40,7 @@ runcloud ios get "$SESSION_ID" --json
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Replace `ios` with `android` for an Android artifact. The shared lifecycle is
|
|
43
|
-
`create`, `list`, `get`, `open-url`, `location set|clear`, `settings`, `logs`, and `delete` (with `--save-state`). Use `--json` whenever
|
|
43
|
+
`create`, `list`, `get`, `open-url`, `location set|clear`, `settings`, `appearance`, `permissions`, `logs`, and `delete` (with `--save-state`; `push` on iOS). Use `--json` whenever
|
|
44
44
|
another program consumes output, and inspect `runcloud ios|android --help` for
|
|
45
45
|
create and log options.
|
|
46
46
|
|
|
@@ -72,6 +72,27 @@ runcloud states delete "$STATE_ID"
|
|
|
72
72
|
- SDK: `delete(id, { saveState: true })`, `create({ restoreState })`,
|
|
73
73
|
`cloud.states.get(stateId, { waitMs })`, and `cloud.states.delete(stateId)`.
|
|
74
74
|
|
|
75
|
+
## Appearance, Permissions, and Push
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
runcloud ios appearance "$SESSION_ID" dark --json
|
|
79
|
+
runcloud ios permissions grant "$SESSION_ID" --app com.example.App camera location notifications --json
|
|
80
|
+
runcloud ios permissions reset "$SESSION_ID" --app com.example.App camera --json
|
|
81
|
+
runcloud ios push "$SESSION_ID" --app com.example.App payload.json --json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- `appearance` takes `light` or `dark`; `permissions grant|revoke|reset` takes
|
|
85
|
+
`--app` (bundle id or Android package) and one or more of `camera`,
|
|
86
|
+
`microphone`, `location`, `location-always`, `notifications`, `photos`,
|
|
87
|
+
`contacts`, `calendar`, `reminders`, `motion`, `media-library`, `siri`.
|
|
88
|
+
- Grant permissions before the app asks, so no system prompt blocks a run.
|
|
89
|
+
On Android the app must declare the permission (`permission_not_declared`).
|
|
90
|
+
- `push` is iOS only: an APNs JSON object with `aps`, at most 4 KiB, from a
|
|
91
|
+
file or `-` for stdin. Android returns `push_unsupported` (501): emulators
|
|
92
|
+
have no FCM delivery, so send a real FCM message from your server instead.
|
|
93
|
+
- SDK: `setAppearance(id, mode)`, `setPermission(id, { app, service, action })`,
|
|
94
|
+
`grantPermissions(id, app, services)`, and `sendPush(id, { app, payload })`.
|
|
95
|
+
|
|
75
96
|
## Control a Session
|
|
76
97
|
|
|
77
98
|
Both platform groups expose acknowledged controls:
|
|
@@ -389,6 +389,22 @@ limit, and then the kernel kills the largest process. And close below a limit,
|
|
|
389
389
|
work that reads files can stall with no kill: other commands still answer, and
|
|
390
390
|
the `--- guest memory pressure` lines show it.
|
|
391
391
|
|
|
392
|
+
### A command that reaches its timeout
|
|
393
|
+
|
|
394
|
+
A command run without streaming that reaches its `timeout_seconds` returns exit
|
|
395
|
+
code -1, the output it wrote so far, and a stderr that ends with
|
|
396
|
+
`guestagent: timeout: the command did not end within N s and was killed`. The
|
|
397
|
+
agent kills the command's whole process group, so the programs a shell started
|
|
398
|
+
end with it. A process that left the group (`setsid`) stays.
|
|
399
|
+
|
|
400
|
+
A command that ends by itself and leaves a background process returns at once.
|
|
401
|
+
That process keeps running, but its output goes nowhere: redirect it to a file
|
|
402
|
+
(`server >/tmp/server.log 2>&1 &`) if it writes anything.
|
|
403
|
+
|
|
404
|
+
An agent older than this gave a `vsock: … i/o timeout` error (HTTP 502) for
|
|
405
|
+
both cases and left the processes running. A sandbox keeps the agent it was
|
|
406
|
+
created with.
|
|
407
|
+
|
|
392
408
|
### Lifecycle markers
|
|
393
409
|
|
|
394
410
|
The host writes a marker into the console on every transition:
|
package/runcloud-0.2.221.tgz
DELETED
|
Binary file
|