runcloud 0.2.240 → 0.2.243
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/README.md +14 -0
- package/dist/commands/credentials.js +494 -0
- package/dist/commands/image.js +2 -1
- package/dist/commands/sandbox.js +3 -0
- package/dist/config.js +4 -1
- package/dist/credentials/agent.js +180 -0
- package/dist/credentials/config.js +304 -0
- package/dist/credentials/engine.js +209 -0
- package/dist/credentials/install.js +160 -0
- package/dist/credentials/items.js +232 -0
- package/dist/credentials/lockFile.js +23 -0
- package/dist/credentials/presets.js +106 -0
- package/dist/credentials/privateFile.js +10 -0
- package/dist/credentials/schedule.js +26 -0
- package/dist/credentials/state.js +83 -0
- package/dist/credentials/status.js +69 -0
- package/dist/credentials/tokenStore.js +87 -0
- package/dist/run-cloud.js +2 -0
- package/dist/version.js +1 -1
- package/package.json +3 -2
- package/runcloud-0.2.243.tgz +0 -0
- package/skills/run-cloud-ios-simulator/SKILL.md +30 -0
- package/runcloud-0.2.240.tgz +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { expandPreset } from '../credentials/presets.js';
|
|
2
|
+
import { effectiveOrg, groupKeyOf } from '../credentials/schedule.js';
|
|
3
|
+
import { parseGroupKey } from '../credentials/state.js';
|
|
4
|
+
const SIZE_LIMIT_BYTES = 64 * 1024;
|
|
5
|
+
export function buildStatus(config, state, agent = { installed: false, running: false }, loginWarning = null) {
|
|
6
|
+
const configured = new Set();
|
|
7
|
+
const groups = config.groups.map((group) => {
|
|
8
|
+
const key = groupKeyOf(config, group.name, group.org);
|
|
9
|
+
configured.add(key);
|
|
10
|
+
const refresh = group.entries.flatMap((entry, index) => (entry.kind === 'preset' ? expandPreset(entry.preset, entry.options) : [entry])
|
|
11
|
+
.filter((item) => item.kind === 'command')
|
|
12
|
+
.map((item) => ({ entry: index, target: targetOf(item), every: formatInterval(item.kind === 'command' ? item.refreshMs : 0) })));
|
|
13
|
+
const org = effectiveOrg(config, group);
|
|
14
|
+
return { group: group.name, ...(org !== undefined && { org }), ...stateFields(state.groups[key]), refresh };
|
|
15
|
+
});
|
|
16
|
+
for (const [key, gs] of Object.entries(state.groups)) {
|
|
17
|
+
if (configured.has(key))
|
|
18
|
+
continue;
|
|
19
|
+
const { org, name } = parseGroupKey(key);
|
|
20
|
+
groups.push({ group: name, ...(org !== undefined && { org }), ...stateFields(gs), refresh: [], removed: true });
|
|
21
|
+
}
|
|
22
|
+
return { groups, limitBytes: SIZE_LIMIT_BYTES, agent, loginWarning };
|
|
23
|
+
}
|
|
24
|
+
function stateFields(gs) {
|
|
25
|
+
const items = Object.entries(gs?.written ?? {}).map(([name, s]) => ({ name, pushedAt: s.pushedAt }));
|
|
26
|
+
const sizes = Object.values(gs?.written ?? {}).map((s) => s.bytes);
|
|
27
|
+
const totalBytes = sizes.some((b) => b === undefined) ? 'unknown' : sizes.reduce((sum, b) => sum + (b ?? 0), 0);
|
|
28
|
+
const lastPushAt = items.map((i) => i.pushedAt).sort().at(-1);
|
|
29
|
+
return {
|
|
30
|
+
...(lastPushAt && { lastPushAt }),
|
|
31
|
+
...(gs?.lastAttemptAt && { lastAttemptAt: gs.lastAttemptAt }),
|
|
32
|
+
...(gs?.lastOutcome && { lastOutcome: gs.lastOutcome }),
|
|
33
|
+
items,
|
|
34
|
+
totalBytes,
|
|
35
|
+
warnings: gs?.warnings ?? [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function targetOf(item) {
|
|
39
|
+
if (item.kind === 'command' && item.format === 'dotenv')
|
|
40
|
+
return '(variables named in the output)';
|
|
41
|
+
return item.env ?? item.to ?? '(unnamed)';
|
|
42
|
+
}
|
|
43
|
+
function formatInterval(ms) {
|
|
44
|
+
if (ms % 3_600_000 === 0)
|
|
45
|
+
return `${ms / 3_600_000}h`;
|
|
46
|
+
if (ms % 60_000 === 0)
|
|
47
|
+
return `${ms / 60_000}m`;
|
|
48
|
+
return `${Math.round(ms / 1000)}s`;
|
|
49
|
+
}
|
|
50
|
+
export function printStatus(model) {
|
|
51
|
+
if (model.groups.length === 0)
|
|
52
|
+
console.log('No credential groups configured.');
|
|
53
|
+
for (const g of model.groups) {
|
|
54
|
+
console.log(`${g.group}${g.org ? ` (org ${g.org})` : ''}${g.removed ? ' (no longer in credentials.yaml)' : ''}`);
|
|
55
|
+
console.log(` last push: ${g.lastPushAt ?? 'never'}`);
|
|
56
|
+
console.log(` last attempt: ${g.lastAttemptAt ?? 'never'}${g.lastOutcome ? ` (${g.lastOutcome})` : ''}`);
|
|
57
|
+
console.log(` size: ${g.totalBytes} / ${model.limitBytes} bytes`);
|
|
58
|
+
for (const item of g.items)
|
|
59
|
+
console.log(` ${item.name} pushed ${item.pushedAt}`);
|
|
60
|
+
for (const r of g.refresh)
|
|
61
|
+
console.log(` entry ${r.entry} ${r.target} refreshes every ${r.every}`);
|
|
62
|
+
for (const warning of g.warnings)
|
|
63
|
+
console.log(` warning: ${warning}`);
|
|
64
|
+
}
|
|
65
|
+
console.log(`agent: ${model.agent.installed ? `installed, ${model.agent.running ? 'running' : 'not running'}` : 'not installed'}`);
|
|
66
|
+
if (model.loginWarning)
|
|
67
|
+
console.log(`warning: ${model.loginWarning}`);
|
|
68
|
+
console.log(`Sandboxes take at most ${model.limitBytes / 1024} KiB of secrets across all groups.`);
|
|
69
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { closeSync, mkdtempSync, openSync, readFileSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { credentialsHome } from '../config.js';
|
|
6
|
+
import { writePrivateFileAtomic } from './privateFile.js';
|
|
7
|
+
const SERVICE = 'runcloud-claude-token';
|
|
8
|
+
const SECRET_TOOL_LABEL = 'run.cloud Claude token';
|
|
9
|
+
const STORE_TIMEOUT_MS = 30_000;
|
|
10
|
+
export function shellQuote(value) {
|
|
11
|
+
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
12
|
+
}
|
|
13
|
+
function tokenFile() {
|
|
14
|
+
return join(credentialsHome(), 'claude-token');
|
|
15
|
+
}
|
|
16
|
+
function secretToolReadCommand() {
|
|
17
|
+
return `secret-tool lookup service ${SERVICE}`;
|
|
18
|
+
}
|
|
19
|
+
export function claudeTokenReadCommand(platform = process.platform, hasSecretTool) {
|
|
20
|
+
if (platform === 'darwin')
|
|
21
|
+
return `security find-generic-password -s ${SERVICE} -w`;
|
|
22
|
+
const fileRead = `cat ${shellQuote(tokenFile())}`;
|
|
23
|
+
if (platform === 'linux') {
|
|
24
|
+
if (hasSecretTool === true)
|
|
25
|
+
return secretToolReadCommand();
|
|
26
|
+
if (hasSecretTool === undefined)
|
|
27
|
+
return `${secretToolReadCommand()} 2>/dev/null || ${fileRead}`;
|
|
28
|
+
}
|
|
29
|
+
return fileRead;
|
|
30
|
+
}
|
|
31
|
+
function doubleQuote(value) {
|
|
32
|
+
return `"${value.replace(/[\\"]/g, '\\$&')}"`;
|
|
33
|
+
}
|
|
34
|
+
export async function storeClaudeToken(token, run, platform = process.platform) {
|
|
35
|
+
if (token === '' || /[\r\n\0]/.test(token))
|
|
36
|
+
throw new Error('the Claude token must be one non-empty line');
|
|
37
|
+
if (platform === 'darwin') {
|
|
38
|
+
const input = `add-generic-password -U -s ${SERVICE} -a runcloud -w ${doubleQuote(token)}\n`;
|
|
39
|
+
const result = await run('security -i', { timeoutMs: STORE_TIMEOUT_MS, input });
|
|
40
|
+
if (result.code !== 0)
|
|
41
|
+
throw new Error('could not store the Claude token in the macOS keychain');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (platform === 'linux') {
|
|
45
|
+
const probe = await run('command -v secret-tool', { timeoutMs: STORE_TIMEOUT_MS });
|
|
46
|
+
if (probe.code === 0) {
|
|
47
|
+
const result = await run(`secret-tool store --label='${SECRET_TOOL_LABEL}' service ${SERVICE}`, {
|
|
48
|
+
timeoutMs: STORE_TIMEOUT_MS,
|
|
49
|
+
input: token,
|
|
50
|
+
});
|
|
51
|
+
if (result.code !== 0)
|
|
52
|
+
throw new Error('could not store the Claude token with secret-tool');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
writePrivateFileAtomic(tokenFile(), token);
|
|
57
|
+
}
|
|
58
|
+
const SETUP_TOKEN_RE = /sk-ant-oat\d+-[A-Za-z0-9_-]{20,}/;
|
|
59
|
+
const ANSI_RE = /\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g;
|
|
60
|
+
export function extractSetupToken(text) {
|
|
61
|
+
return SETUP_TOKEN_RE.exec(text.replace(ANSI_RE, ''))?.[0] ?? null;
|
|
62
|
+
}
|
|
63
|
+
const runInTerminal = (command, args) => new Promise((resolve, reject) => {
|
|
64
|
+
const child = spawn(command, args, { stdio: 'inherit' });
|
|
65
|
+
child.once('error', reject);
|
|
66
|
+
child.once('exit', (code) => resolve(code));
|
|
67
|
+
});
|
|
68
|
+
export async function runClaudeSetupToken(opts = {}) {
|
|
69
|
+
const platform = opts.platform ?? process.platform;
|
|
70
|
+
const run = opts.run ?? runInTerminal;
|
|
71
|
+
const dir = mkdtempSync(join(tmpdir(), 'runcloud-setup-token-'));
|
|
72
|
+
try {
|
|
73
|
+
const log = join(dir, 'session.log');
|
|
74
|
+
closeSync(openSync(log, 'wx', 0o600));
|
|
75
|
+
const args = platform === 'darwin' ? ['-q', log, 'claude', 'setup-token'] : ['-q', '-c', 'claude setup-token', log];
|
|
76
|
+
try {
|
|
77
|
+
await run('script', args);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return extractSetupToken(readFileSync(log, 'utf8'));
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
rmSync(dir, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
}
|
package/dist/run-cloud.js
CHANGED
|
@@ -5,6 +5,7 @@ import { registerLogin } from './commands/login.js';
|
|
|
5
5
|
import { registerRunCloud } from './commands/run-cloud.js';
|
|
6
6
|
import { registerRunCloudFleet } from './commands/run-cloud-fleet.js';
|
|
7
7
|
import { registerSandbox } from './commands/sandbox.js';
|
|
8
|
+
import { registerCredentials } from './commands/credentials.js';
|
|
8
9
|
import { registerSecrets } from './commands/secrets.js';
|
|
9
10
|
import { registerToken } from './commands/token.js';
|
|
10
11
|
import { registerUpdate, runCloudSource } from './commands/update.js';
|
|
@@ -26,6 +27,7 @@ registerRunCloud(program);
|
|
|
26
27
|
registerRunCloudFleet(program);
|
|
27
28
|
registerSandbox(program);
|
|
28
29
|
registerSecrets(program);
|
|
30
|
+
registerCredentials(program);
|
|
29
31
|
registerToken(program);
|
|
30
32
|
registerXcode(program);
|
|
31
33
|
registerImage(program);
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CLI_VERSION = '0.2.
|
|
1
|
+
export const CLI_VERSION = '0.2.243';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "runcloud",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.243",
|
|
4
4
|
"description": "Create and control run.cloud remote mobile simulators and cloud sandboxes",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"commander": "^12.1.0",
|
|
50
50
|
"ignore": "^7.0.5",
|
|
51
51
|
"tar": "^7.4.3",
|
|
52
|
-
"ws": "^8.21.0"
|
|
52
|
+
"ws": "^8.21.0",
|
|
53
|
+
"yaml": "^2"
|
|
53
54
|
}
|
|
54
55
|
}
|
|
Binary file
|
|
@@ -238,6 +238,36 @@ runcloud ios tunnel-status --json
|
|
|
238
238
|
Do not expose an unauthenticated third-party tunnel. If the sidecar is
|
|
239
239
|
unavailable, report that requirement instead of guessing a public URL.
|
|
240
240
|
|
|
241
|
+
## Stream Codec and Browsers
|
|
242
|
+
|
|
243
|
+
Keep the default codec, `auto`. It selects the run.cloud streaming protocol:
|
|
244
|
+
low-latency H.264 over MoQ, with H.264 over HTTP as the fallback. Do not set
|
|
245
|
+
`--codec mjpeg` unless the client cannot decode H.264. MJPEG is a fallback
|
|
246
|
+
only. On Android it sends PNG screenshots at approximately 1.5 fps. It does not
|
|
247
|
+
turn off MoQ; codec and transport are separate choices.
|
|
248
|
+
|
|
249
|
+
To see or check the device, use `screenshot`, `accessibility-tree`, or
|
|
250
|
+
`recording`. These do not need a browser.
|
|
251
|
+
|
|
252
|
+
To watch a session in an automated browser, open the signed session URL as
|
|
253
|
+
the page itself. This works in installed Chrome, also headless. Do not build
|
|
254
|
+
an automated page that embeds viewers in iframes, especially in headless
|
|
255
|
+
Chrome:
|
|
256
|
+
|
|
257
|
+
- Chrome can stop painting a cross-origin iframe that is hidden or off-screen,
|
|
258
|
+
for example with `display: none`. Do not wait for a live status to show it.
|
|
259
|
+
- A `first_frame` report or live status does not prove that a picture is
|
|
260
|
+
visible. A hidden iframe can decode H.264 and report both. Check a screenshot.
|
|
261
|
+
- A localStorage `SecurityError` in a viewer iframe does not by itself stop the
|
|
262
|
+
video. Look for another cause.
|
|
263
|
+
- Check H.264 support with `VideoDecoder.isConfigSupported`, not by browser
|
|
264
|
+
name. `VideoDecoder` can exist without the codec, and builds differ.
|
|
265
|
+
- Playwright's bundled Chromium does not play the `auto` stream reliably. Use
|
|
266
|
+
installed Chrome (Playwright `channel: 'chrome'`).
|
|
267
|
+
|
|
268
|
+
If you must embed viewers, use installed Chrome in a visible window, keep each
|
|
269
|
+
iframe visible, and serve the page from an `http://` or `https://` origin.
|
|
270
|
+
|
|
241
271
|
## Embed a Session
|
|
242
272
|
|
|
243
273
|
- Use `RemoteControl` from `@run-cloud/ui` with the signed session URL.
|
package/runcloud-0.2.240.tgz
DELETED
|
Binary file
|