@nomac/cli 0.20.0 → 0.21.0
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/package.json +1 -1
- package/skill/SKILL.md +7 -3
- package/src/hosted-sessions.mjs +42 -3
- package/src/mcp.mjs +1 -1
- package/src/phone-tools.json +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomac/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "A real cloud Mac for AI agents: Xcode, the iOS Simulator, signing, TestFlight and App Store publishing, by the minute, over MCP, SSH and HTTPS.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
package/skill/SKILL.md
CHANGED
|
@@ -47,7 +47,8 @@ Store screenshots start the phone with `device: "iphone-pro-max"` (6.9-inch,
|
|
|
47
47
|
Run commands with `nomac exec -- COMMAND`: it prints the output as it
|
|
48
48
|
arrives and exits with the command's code, waiting at most 30 s (or the
|
|
49
49
|
`--timeout` given, up to 600 s). For builds and tests use
|
|
50
|
-
`nomac exec --wait 600 -- COMMAND`.
|
|
50
|
+
`nomac exec --wait 600 -- COMMAND`. What is piped in is the command's stdin
|
|
51
|
+
(`cat build.sh | nomac exec -- bash -s`). Exit code 75 means still running: wait
|
|
51
52
|
with `nomac job JOB_ID --wait 600`, never rerun. In scripts add
|
|
52
53
|
`--request-key stable-key-0001`. A command may run an hour (`--timeout
|
|
53
54
|
3600`); longer, use `nomac ssh -- COMMAND`. A command ends with everything
|
|
@@ -104,14 +105,17 @@ keyboard and mouse, also on the lock screen and in password dialogs, use
|
|
|
104
105
|
`mac_input`): each answers with a screenshot. Drive the Simulator with
|
|
105
106
|
simulator-use, preinstalled: `simulator-use look` reads the screen as text,
|
|
106
107
|
`simulator-use act 'tap "Sign In"'` taps and types by label, `simulator-use run`
|
|
107
|
-
builds, installs and launches (simctl works too)
|
|
108
|
+
builds, installs and launches (simctl works too), and `simulator-use app
|
|
109
|
+
storekit Products.storekit --app ID` tests in-app purchases from the app's
|
|
110
|
+
`.storekit` file (the App Store's sandbox cannot buy in a Simulator). Give the human
|
|
108
111
|
`open_mac_desktop` when they want to see the screen.
|
|
109
112
|
`get_mac_session` (and `nomac status --json`) lists what
|
|
110
113
|
is installed: Node, Python, uv, nvm, Ruby with CocoaPods, xcbeautify, xcodegen,
|
|
111
114
|
gh, Git LFS, jq and simulator-use.
|
|
112
115
|
Pipe xcodebuild through `xcbeautify`. Simulator devices share names across iOS
|
|
113
116
|
runtimes: pick one by ID (`xcrun simctl list devices available`) or with
|
|
114
|
-
`OS=27.0` in `-destination
|
|
117
|
+
`OS=27.0` in `-destination`; an older iOS downloads in about 6 minutes
|
|
118
|
+
(`xcodebuild -downloadPlatform iOS -buildVersion 26.5`). Apple Intelligence cannot generate on a virtual
|
|
115
119
|
Mac, in the Simulator either: test it on a device.
|
|
116
120
|
Report failures using `report_issue` with `session_id`, optional `job_id` and
|
|
117
121
|
a description without secrets. Read https://nomac.app/llms.txt for full limits.
|
package/src/hosted-sessions.mjs
CHANGED
|
@@ -60,7 +60,8 @@ const HELP = `Nomac cloud Mac sessions
|
|
|
60
60
|
grant permissions on this Mac at start
|
|
61
61
|
nomac exec [--wait 30] -- command args
|
|
62
62
|
runs it, prints its output as it arrives,
|
|
63
|
-
exits with its code.
|
|
63
|
+
exits with its code. What is piped in is its
|
|
64
|
+
stdin (cat build.sh | nomac exec -- bash -s).
|
|
64
65
|
Waits up to 30 s, or with --timeout N up to N s
|
|
65
66
|
(at most 600); for builds and tests use --wait 600.
|
|
66
67
|
Exit code 75 means still running: see nomac job.
|
|
@@ -189,6 +190,40 @@ export async function sessionAccess(id, request = api) {
|
|
|
189
190
|
transportOptions({ gateway: access.gateway, token: access.token });
|
|
190
191
|
return access;
|
|
191
192
|
}
|
|
193
|
+
/** A command's whole request, what it reads on stdin included: the gateway takes 64 KiB. */
|
|
194
|
+
const JOB_BYTES = 63 * 1024;
|
|
195
|
+
/**
|
|
196
|
+
* What is piped into nomac exec (cat build.sh | nomac exec -- bash -s, or < build.sh), for the command on the Mac.
|
|
197
|
+
* A terminal, /dev/null, and a pipe that sends nothing in its first second (an agent's shell that keeps stdin open
|
|
198
|
+
* and never writes) give nothing, so a command never waits for input nobody sends. More than fits in a command is
|
|
199
|
+
* refused, never cut.
|
|
200
|
+
*/
|
|
201
|
+
export function pipedInput(input = process.stdin, { firstByteMs = 1000, limit = JOB_BYTES } = {}) {
|
|
202
|
+
if (!input || input.isTTY) return Promise.resolve(null);
|
|
203
|
+
return new Promise((resolve, reject) => {
|
|
204
|
+
const chunks = []; let size = 0, done = false;
|
|
205
|
+
const finish = (error, value) => {
|
|
206
|
+
if (done) return; done = true; clearTimeout(silent);
|
|
207
|
+
input.off("data", onData); input.off("end", onEnd); input.off("error", onEnd);
|
|
208
|
+
// Nothing else reads stdin: let go of it, so a pipe that never ends cannot keep this process alive.
|
|
209
|
+
if (error || value === null) input.destroy?.(); else input.pause?.();
|
|
210
|
+
if (error) reject(error); else resolve(value);
|
|
211
|
+
};
|
|
212
|
+
const onData = chunk => {
|
|
213
|
+
size += chunk.length;
|
|
214
|
+
if (size > limit) finish(new CliError(`What is piped into nomac exec goes with the command, which can be ${limit / 1024} KiB in all; this is more. Copy a larger file to the Mac (nomac sync, then run it there).`));
|
|
215
|
+
else chunks.push(chunk);
|
|
216
|
+
};
|
|
217
|
+
const onEnd = () => finish(null, size ? Buffer.concat(chunks) : null);
|
|
218
|
+
const silent = setTimeout(() => { if (!size) finish(null, null); }, firstByteMs);
|
|
219
|
+
silent.unref?.();
|
|
220
|
+
input.on("data", onData); input.on("end", onEnd); input.on("error", onEnd);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/** The command on the Mac reading input on its stdin: carried in the request as base64, decoded into a pipe. */
|
|
224
|
+
export function withInput(command, input) {
|
|
225
|
+
return ["/bin/bash", "-c", 'data=$1; shift; printf %s "$data" | /usr/bin/base64 -D | "$@"', "nomac-stdin", input.toString("base64"), ...command];
|
|
226
|
+
}
|
|
192
227
|
/** nomac exec's exit code for a command still running when the wait ends (EX_TEMPFAIL). */
|
|
193
228
|
export const STILL_RUNNING = 75;
|
|
194
229
|
/** Quick commands are checked early; after that, once a second. */
|
|
@@ -365,7 +400,7 @@ export async function hostedRequest(id, method, path, params = {}, { request = a
|
|
|
365
400
|
return transport(method, path, { ...params, gateway: access.gateway, token: access.token });
|
|
366
401
|
}
|
|
367
402
|
export async function hostedSessionCommand(command, argv, { store = sessionStore(), request = api, transport = macRequest, run = runProcess, print = console.log, sleep = ms => new Promise(r => setTimeout(r, ms)), now = Date.now,
|
|
368
|
-
stdout = data => process.stdout.write(data), stderr = data => process.stderr.write(data), exitWith = code => { process.exitCode = code; } , watch = watchFolder, stopWatching = undefined, debounceMs = 600} = {}) {
|
|
403
|
+
stdout = data => process.stdout.write(data), stderr = data => process.stderr.write(data), exitWith = code => { process.exitCode = code; } , watch = watchFolder, stopWatching = undefined, debounceMs = 600, readInput = pipedInput} = {}) {
|
|
369
404
|
let parsed;
|
|
370
405
|
try { parsed = parseArgs({ args: argv, options, allowPositionals: true }); }
|
|
371
406
|
catch (error) { throw new CliError(error.message); }
|
|
@@ -568,9 +603,13 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
|
|
|
568
603
|
const waitFor = waitSeconds = integer(values.wait, given === null ? 30 : Math.min(given, 600), 0, 3600);
|
|
569
604
|
const timeout = given ?? (values["request-key"] === undefined ? Math.max(300, waitFor) : 600);
|
|
570
605
|
const line = isShellLine(positionals), dir = local.workspaceOnDrive ? local.workspace : null;
|
|
571
|
-
const
|
|
606
|
+
const onMac = dir ? (line ? ["/bin/bash", "-lc", `cd ${shellQuote(dir)} && ${positionals[0]}`] : ["/bin/bash", "-lc", `cd ${shellQuote(dir)} && exec "$@"`, "nomac", ...positionals])
|
|
572
607
|
: line ? ["/bin/bash", "-lc", positionals[0]] : positionals;
|
|
608
|
+
const input = await readInput();
|
|
609
|
+
const remote = input?.length ? withInput(onMac, input) : onMac;
|
|
573
610
|
method = "POST"; path = `${base}/jobs`; params = { requestKey: values["request-key"] ?? `cli-${randomUUID()}`, body: { argv: remote, timeout_seconds: timeout } };
|
|
611
|
+
const size = Buffer.byteLength(JSON.stringify(params.body));
|
|
612
|
+
if (input?.length && size > JOB_BYTES) throw new CliError(`What is piped into nomac exec goes with the command, which can be ${JOB_BYTES / 1024} KiB in all; this is ${Math.ceil(size / 1024)} KiB. Copy a larger file to the Mac (nomac sync, then run it there).`);
|
|
574
613
|
} else {
|
|
575
614
|
if (positionals.length !== 1 || !/^job_[a-f0-9]{40}$/.test(positionals[0])) throw new CliError("Supply the existing job ID.");
|
|
576
615
|
path = `${base}/jobs/${positionals[0]}`;
|
package/src/mcp.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const INSTRUCTIONS = [
|
|
|
22
22
|
"Use it when work needs macOS this machine lacks (Windows, Linux, a cloud sandbox): an iOS, iPadOS, watchOS, visionOS or macOS app (Swift, SwiftUI, React Native, Expo, Flutter, Capacitor), Xcode, signing, TestFlight or the App Store.",
|
|
23
23
|
"Typical flow: get_mac_credits, start_mac, poll get_mac_session until ready, put code there (exec_mac with git clone into ~/drive/src, write_mac_file, fetch_to_mac, create_mac_upload_link), run exec_mac, get results with read_mac_file or create_mac_download_link, then stop_mac.",
|
|
24
24
|
"The account's drive at ~/drive (20 GB) is on every Mac and kept between sessions; everything outside it is deleted at stop. Clone and build in ~/drive/src/<repo> so the next session rebuilds only what changed; keep it under 10 GB (nomac-drive shows what takes the space, nomac-drive clean deletes stale build products).",
|
|
25
|
-
"The Mac's own Simulator: simulator-use is on it (run it with exec_mac): simulator-use look reads the screen as text, simulator-use act 'tap \"Sign In\"' taps by label, simulator-use run builds and launches
|
|
25
|
+
"The Mac's own Simulator: simulator-use is on it (run it with exec_mac): simulator-use look reads the screen as text, simulator-use act 'tap \"Sign In\"' taps by label, simulator-use run builds and launches it, app storekit tests purchases; ~/NOMAC.md has the rest.",
|
|
26
26
|
"When an answer says low_credit (under an hour left), tell the human before a long build and offer its buy_url: a Mac stops when the credit runs out. For a refill, suggest 3 packs ($30, +5%).",
|
|
27
27
|
"One Mac per account at a time: start_mac while one runs answers session_limit_reached with its id, to use; parallel: true starts a second (accounts that bought credit, while NoMac has one to spare), without the drive.",
|
|
28
28
|
"exec_mac returns a quick command's output in the same call; pass wait_seconds: 40 for builds and tests (a call answers within 45 s). A command still running comes back as a job: poll get_mac_job with its job_id, then read_mac_output.",
|
package/src/phone-tools.json
CHANGED
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
"name": "phone_app_control",
|
|
225
|
-
"description": "Cloud iPhone: Launch, install, stop or remove an app
|
|
225
|
+
"description": "Cloud iPhone: Launch, install, stop or remove an app; open a URL or deep link; grant, revoke or reset a permission; set the location; send a push; test purchases (.storekit); set the phone's appearance, locale, time zone, text size or a clean status bar. launch answers with its first screen; app defaults to the last launched.",
|
|
226
226
|
"inputSchema": {
|
|
227
227
|
"type": "object",
|
|
228
228
|
"properties": {
|
|
@@ -239,6 +239,7 @@
|
|
|
239
239
|
"reset_permissions",
|
|
240
240
|
"location",
|
|
241
241
|
"push",
|
|
242
|
+
"storekit",
|
|
242
243
|
"appearance",
|
|
243
244
|
"locale",
|
|
244
245
|
"timezone",
|