@nomac/cli 0.23.1 → 0.24.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomac/cli",
3
- "version": "0.23.1",
3
+ "version": "0.24.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
@@ -38,10 +38,10 @@ Store screenshots start the phone with `device: "iphone-pro-max"` (6.9-inch,
38
38
  not a payment. No Apple Developer account is needed for an unsigned build.
39
39
  Under an hour left, answers say `low_credit` with a `buy_url`: tell the
40
40
  human before a long build (a refill of 3 packs, $30, earns bonus credit).
41
- 2. Install `npm install -g @nomac/cli@0.23.1` (it updates itself after), run `nomac login`, and give the human
41
+ 2. Install `npm install -g @nomac/cli@0.24.0` (it updates itself after), run `nomac login`, and give the human
42
42
  the printed device URL and code. With a key the human made at
43
43
  https://nomac.app/keys: `nomac login --with-token < key.txt`, or set
44
- `NOMAC_API_KEY`. MCP: `claude mcp add nomac -- npx -y @nomac/cli@0.23.1 mcp`.
44
+ `NOMAC_API_KEY`. MCP: `claude mcp add nomac -- npx -y @nomac/cli@0.24.0 mcp`.
45
45
  Hosted MCP: https://mcp.nomac.app/mcp with `Authorization: Bearer <nmk_key>`.
46
46
  3. `nomac start --json`, wait until ready, `nomac sync .`, then `nomac ssh`.
47
47
  Run commands with `nomac exec -- COMMAND`: it prints the output as it
@@ -81,7 +81,10 @@ background (`NOMAC_NO_AUTO_UPDATE=1` turns it off; `nomac update` now).
81
81
  One-minute minimum, then by the minute. One session at a time; no overage.
82
82
  For work that needs two Macs at once, `nomac start --parallel` from another
83
83
  folder (MCP `start_mac` with `parallel: true`) starts a second, for accounts
84
- that bought credit while NoMac has a Mac to spare; it runs without `~/drive`.
84
+ that bought credit while NoMac has a Mac to spare. `~/drive` is on one Mac at
85
+ a time: while another Mac has it, the second runs without it, and
86
+ `nomac status` and `~/NOMAC.md` say which Mac has it. A Mac running a
87
+ `nomac run` command is never offered to attach: it stops when its command ends.
85
88
  If start returns `insufficient_credit`, buy credit as in step 1, then retry
86
89
  with the same request key.
87
90
  Keep the same request key and arguments after uncertain responses; inspect
@@ -52,8 +52,10 @@ const HELP = `Nomac cloud Mac sessions
52
52
  nomac start --drive none this Mac without the drive
53
53
  nomac start --parallel a second Mac beside the account's running one, from another
54
54
  folder (accounts that bought credit, while a Mac is spare);
55
- it runs without ~/drive. Without it, a start while the account's Mac
55
+ ~/drive is on one Mac at a time, so while another has it, this one
56
+ runs without it. Without it, a start while the account's Mac
56
57
  runs elsewhere is refused and names it: nomac attach ID uses it.
58
+ A Mac running a nomac run command is never named or attached.
57
59
  nomac ssh-config [--alias nomac] [--print]
58
60
  name this folder's Mac in your SSH config (Host nomac), for
59
61
  VS Code or Cursor Remote-SSH, Claude Code SSH sessions, ssh nomac,
@@ -374,6 +376,8 @@ export function macLine(image) {
374
376
  const xcode = others.length ? `Xcode ${image.xcode} (default) and ${others.map(x => `Xcode ${x.version} (${x.path})`).join(" and ")}` : `Xcode ${image.xcode}`;
375
377
  return `Mac: macOS ${image.macos.split(" ")[0]}, ${xcode}${(image.simulator_runtimes ?? []).map(r => `, ${r} Simulator`).join("")}`;
376
378
  }
379
+ /** A Mac started while another of the account's had the drive runs without it (LIM-383: one Mac at a time). */
380
+ const driveElsewhereLine = holder => `Drive: not on this Mac. The account's drive is on its Mac ${holder} (one Mac at a time), so nothing here is kept after it stops: push or pull what you need first. A Mac started after ${holder} stops gets the drive.`;
377
381
  export function statusSummary(session, image) {
378
382
  const lines = [`${session.id}: ${session.state}`];
379
383
  if (macLine(image)) lines.push(macLine(image));
@@ -389,6 +393,7 @@ export function statusSummary(session, image) {
389
393
  : d.state === "saving" ? "Drive: saving this session's changes." : d.state === "saved" ? `Drive: saved (version ${d.saved_version}).`
390
394
  : d.state === "not_saved" ? `Drive: this session's changes were not saved. ${d.message ?? ""}`.trim() : `Drive: not attached. ${d.message ?? ""}`.trim());
391
395
  }
396
+ if (!d && session.drive_held_by && ["queued", "provisioning", "ready"].includes(session.state)) lines.push(driveElsewhereLine(session.drive_held_by));
392
397
  if (session.state === "ready" && session.access) {
393
398
  lines.push(`Open to your agent: ${session.access.prompts === "auto" ? "no administrator password prompts" : "macOS's usual prompts"}. Login password: nomac password ($NOMAC_MAC_PASSWORD on the Mac).`);
394
399
  }
@@ -415,7 +420,9 @@ export async function hostedRequest(id, method, path, params = {}, { request = a
415
420
  return transport(method, path, { ...params, gateway: access.gateway, token: access.token });
416
421
  }
417
422
  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,
418
- 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} = {}) {
423
+ 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,
424
+ /** nomac run's start: "run" marks its Mac, which agents' refusals, attach and the drive then leave out (LIM-383). */
425
+ purpose = undefined} = {}) {
419
426
  let parsed;
420
427
  if (["exec", "ssh"].includes(command)) argv = withCommandSeparator(argv);
421
428
  try { parsed = parseArgs({ args: argv, options, allowPositionals: true }); }
@@ -444,7 +451,8 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
444
451
  : "Check: nomac status";
445
452
  // A ready Mac says what is on it, as nomac status does.
446
453
  const mac = result.session.state === "ready" && macLine(lastImage) ? `${macLine(lastImage)}\n` : "";
447
- print(`${result.attached ? `${result.attached}\n` : ""}${result.session.id}: ${result.session.state}\n${mac}${next}\n${usage}${result.warning ? `\n${result.warning}` : ""}${result.feedback_request ? `\n\n${result.feedback_request}` : ""}`);
454
+ const elsewhere = !result.session.drive && result.session.drive_held_by && ["queued", "provisioning", "ready"].includes(result.session.state) ? `${driveElsewhereLine(result.session.drive_held_by)}\n` : "";
455
+ print(`${result.attached ? `${result.attached}\n` : ""}${result.session.id}: ${result.session.state}\n${mac}${elsewhere}${next}\n${usage}${result.warning ? `\n${result.warning}` : ""}${result.feedback_request ? `\n\n${result.feedback_request}` : ""}`);
448
456
  return result;
449
457
  };
450
458
  const saveView = (local, view) => {
@@ -540,10 +548,13 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
540
548
  const project = local => local.state === "ready" && local.workspaceDecided ? { project: { path: local.workspace, on_drive: Boolean(local.workspaceOnDrive) } } : {};
541
549
  /** The last session's folder on the drive and what was synced to it, for the next session to pick up. */
542
550
  const previousDrive = old => old?.workspaceOnDrive ? { previousDriveWorkspace: { path: old.workspace, baseline: store.baseline() } } : {};
543
- /** The account's running Macs, newest first: queued, starting or ready. */
544
- async function liveSessions() {
551
+ /**
552
+ * The account's running Macs, newest first: queued, starting or ready. A Mac nomac run started for one command
553
+ * (purpose run) is left out, or only those with runs: its run stops it when the command ends (LIM-383).
554
+ */
555
+ async function liveSessions({ runs = false } = {}) {
545
556
  const answer = await request("GET", "/api/v1/mac/sessions");
546
- return (Array.isArray(answer?.sessions) ? answer.sessions : []).filter(s => ["queued", "provisioning", "ready"].includes(s.state));
557
+ return (Array.isArray(answer?.sessions) ? answer.sessions : []).filter(s => ["queued", "provisioning", "ready"].includes(s.state) && (s.purpose === "run") === runs);
547
558
  }
548
559
  /** This folder now uses that Mac: a fresh key of its own, then ready() adds it once the Mac is ready. */
549
560
  async function attachTo(view) {
@@ -829,6 +840,7 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
829
840
  return output({ session: current.snapshot, attached: `This folder already uses ${current.id}.`, ...project(current) });
830
841
  }
831
842
  const target = wanted ? live.find(s => s.id === wanted) : live.length === 1 ? live[0] : undefined;
843
+ if (!target && wanted && (await liveSessions({ runs: true }).catch(() => [])).some(s => s.id === wanted)) throw new CliError(`${wanted} runs a nomac run command (a CI job or a script), and that run stops it when the command ends, so it cannot be attached. Start a Mac of your own: nomac start`);
832
844
  if (!target) throw new CliError(wanted ? `No running Mac ${wanted} in this account.` : live.length ? `This account has ${live.length} running Macs: name one, nomac attach ${live.map(s => s.id).join(" | ")}` : "This account has no running Mac. Start one: nomac start");
833
845
  const local = await attachTo(target);
834
846
  return output({ session: local.snapshot, attached: `Attached to ${local.id}, started elsewhere: ssh, sync, pull and exec work from this folder. If another agent or folder is using it, leave it running when you are done here (nomac stop stops it for everyone).`, ...project(local) });
@@ -865,7 +877,7 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
865
877
  const identity = join(store.directory, `id_ed25519_${randomUUID()}`);
866
878
  await run("ssh-keygen", ["-q", "-t", "ed25519", "-N", "", "-C", "nomac-session", "-f", identity]);
867
879
  local = { mode: "hosted", state: "requesting", outcomeUnknown: false, identity, requestKey: values["request-key"] ?? `cli-${randomUUID()}`,
868
- request: { profile: "standard", public_key: readFileSync(`${identity}.pub`, "utf8").trim(), limits, ...(access ? { access } : {}), ...(values.parallel ? { parallel: true } : {}) },
880
+ request: { profile: "standard", public_key: readFileSync(`${identity}.pub`, "utf8").trim(), limits, ...(access ? { access } : {}), ...(values.parallel ? { parallel: true } : {}), ...(purpose ? { purpose } : {}) },
869
881
  ...previousDrive(store.load()) };
870
882
  store.save(local); store.saveBaseline({});
871
883
  }
package/src/mac-tools.mjs CHANGED
@@ -20,7 +20,7 @@ export const MAC_TOOLS = [
20
20
  return text({ ...result, opened_in_browser: opened });
21
21
  } },
22
22
  { name: "get_mac_credits", description: "Read the prepaid Mac credit balance: spendable dollars, spendable_seconds (how long a Mac can run on it), amounts held by a running session, pricing (including bonus_tiers for bigger purchases), recent purchases and first_purchase (true until the first paid top-up). Credit never expires. If spendable_seconds is below what the task needs, call get_mac_checkout.", inputSchema: schema({}), handler: async () => text(await api("GET", "/api/v1/mac/credits")) },
23
- { name: "start_mac", description: "Allocate a full cloud Mac VM, billed per minute from prepaid credit; its answer states its price. If it returns insufficient_credit, call get_mac_checkout, have the human pay, then retry with the same request_key. Supply a stable request_key; SSH public_key is optional for HTTPS-only agents; reuse both after a lost response. Inspect the returned offer and limits. Poll get_mac_session until ready. No project pipeline is imposed; stop_mac deletes the VM and files. The Mac is fully enabled for you: macOS asks for no administrator password, and the Mac's login password is in $NOMAC_MAC_PASSWORD on it; the answer's warning says so. Every Mac has the account's persistent drive at ~/drive, kept between sessions (get_mac_drive). access opts out: prompts ask keeps macOS's usual prompts; drive none starts without the drive.", inputSchema: schema({ public_key: { type: "string" }, request_key: key, limits: { type: "object", properties: { max_duration_seconds: { type: "integer", minimum: 60, maximum: 28800 }, idle_timeout_seconds: { type: "integer", minimum: 60, maximum: 3600 }, spend_cap_microunits: { type: "string", pattern: "^[1-9][0-9]{0,17}$" } }, additionalProperties: false }, parallel: { type: "boolean", description: "true starts a second Mac beside the account's running one (accounts that bought credit, while NoMac has a Mac to spare); it runs without the account's drive. Without it, a start while a Mac runs answers session_limit_reached with that Mac's id, to use." },
23
+ { name: "start_mac", description: "Allocate a full cloud Mac VM, billed per minute from prepaid credit; its answer states its price. If it returns insufficient_credit, call get_mac_checkout, have the human pay, then retry with the same request_key. Supply a stable request_key; SSH public_key is optional for HTTPS-only agents; reuse both after a lost response. Inspect the returned offer and limits. Poll get_mac_session until ready. No project pipeline is imposed; stop_mac deletes the VM and files. The Mac is fully enabled for you: macOS asks for no administrator password, and the Mac's login password is in $NOMAC_MAC_PASSWORD on it; the answer's warning says so. The account's persistent drive at ~/drive is kept between sessions, on one Mac at a time: a Mac started while another has it runs without it (get_mac_drive). access opts out: prompts ask keeps macOS's usual prompts; drive none starts without the drive.", inputSchema: schema({ public_key: { type: "string" }, request_key: key, limits: { type: "object", properties: { max_duration_seconds: { type: "integer", minimum: 60, maximum: 28800 }, idle_timeout_seconds: { type: "integer", minimum: 60, maximum: 3600 }, spend_cap_microunits: { type: "string", pattern: "^[1-9][0-9]{0,17}$" } }, additionalProperties: false }, parallel: { type: "boolean", description: "true starts a second Mac beside the account's running one (accounts that bought credit, while NoMac has a Mac to spare); it runs without the account's drive. Without it, a start while a Mac runs answers session_limit_reached with that Mac's id, to use." },
24
24
  access: { type: "object", properties: { prompts: { type: "string", enum: ["auto", "ask"] }, gatekeeper: { type: "string", enum: ["off", "on"] }, drive: { type: "string", enum: ["account", "none"] },
25
25
  permissions: { type: "object", description: "By bundle ID: a list of permissions (camera, microphone, contacts, calendars, reminders, photos, desktop, documents, downloads and more) or \"all\"", additionalProperties: { anyOf: [{ type: "string", enum: ["all"] }, { type: "array", items: { type: "string" }, minItems: 1 }] } } }, additionalProperties: false } }, ["request_key"]), handler: async ({ request_key, ...body }) => text(await api("POST", "/api/v1/mac/sessions", { body, idempotencyKey: request_key })) },
26
26
  { name: "list_mac_sessions", description: "Find existing Mac sessions, including after losing a response. Shows state, cost, limits and cleanup.", inputSchema: schema({}), handler: async () => text(await api("GET", "/api/v1/mac/sessions")) },
package/src/mcp.mjs CHANGED
@@ -21,7 +21,7 @@ const INSTRUCTIONS = [
21
21
  "The cloud iPhone (the phone tools: phone and phone_*) builds, runs and tests an iOS app, ready in seconds, no shell: phone with action start (its answer has links.view for the person); phone_app_run with local_path (a folder here, only changes sent) or git (an https repository link) builds and runs the app, incrementally; phone_ui_look reads the screen as text, phone_ui_act taps and types by label; phone_app_logs, phone_tests_run; a long build answers with a job for phone_job_status; phone with action stop when done. The Mac (start_mac and the Mac tools) does the rest.",
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
- "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).",
24
+ "The account's drive at ~/drive (20 GB) is kept between sessions, on one Mac at a time; the rest 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
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.",
package/src/run.mjs CHANGED
@@ -15,7 +15,7 @@ export const RUN_HELP = `nomac run [options] -- command args
15
15
  Mac. stdout is the command's output; nomac run's own lines go to stderr. Its exit code is
16
16
  the command's. It never uses or stops a Mac you or your agents run, and runs without the
17
17
  drive: nothing carries over from one run to the next. While it runs it counts as one of
18
- the account's Macs.
18
+ the account's Macs, and your agents are never offered it (to use, attach or stop).
19
19
  --timeout SECONDS the command's limit, 60 to 3540 (the default)
20
20
  --pull PATH after the command, copy PATH (relative to the project folder) here;
21
21
  repeat it for more
@@ -54,7 +54,8 @@ function whole(value, fallback, min, max, what) {
54
54
  /**
55
55
  * nomac run: start, sync, exec and pull as those commands do them, under a session state of the run's own (a fresh
56
56
  * directory, removed after, marked ephemeral so the folder's SSH config entry is left alone), always with --parallel and
57
- * without the drive, so it never takes or touches a Mac or drive someone uses. The Mac is stopped with one API call (no
57
+ * without the drive, so it never takes or touches a Mac or drive someone uses. Its Mac is marked purpose run, so agents
58
+ * are never offered it (refusals, attach, calls without a session id). The Mac is stopped with one API call (no
58
59
  * folder lock to wait for) at the end, after any failure, and on the first SIGTERM or SIGINT (later ones, such as npm
59
60
  * forwarding the same signal, are ignored), which then exits 143 or 130. Returns the command's exit code.
60
61
  */
@@ -126,7 +127,8 @@ export async function runCommand(argv, {
126
127
  for (let waited = false; ; waited = true) {
127
128
  if (signalled) return code;
128
129
  say(waited ? "starting a Mac (another try)" : "starting a Mac");
129
- try { started = await step("start", start); break; }
130
+ // Marked as a run's Mac: an agent's refused start never names it, nomac attach never picks it, and it never takes the drive.
131
+ try { started = await step("start", start, { purpose: "run" }); break; }
130
132
  catch (error) {
131
133
  // The account already runs as many Macs as it may: a pipeline waits its turn, a bounded time.
132
134
  if (error?.code !== "session_limit_reached" || now() >= until) throw error;