@nomac/cli 0.26.0 → 0.26.2

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.26.0",
3
+ "version": "0.26.2",
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
@@ -18,7 +18,7 @@ shell), a NoMac cloud iPhone is the lighter choice, from the same credit: the
18
18
  phone tools (`phone`, `phone_app_run`, `phone_ui_look`, `phone_ui_act` and the
19
19
  other `phone_*`), which NoMac's MCP lists beside the Mac (`nomac mcp` and
20
20
  https://mcp.nomac.app/mcp); https://mcp.nomac.app/simulator for the phone
21
- alone; or `npx simulator-use@0.15.1 cloud start` from a terminal
21
+ alone; or `npx simulator-use@0.15.3 cloud start` from a terminal
22
22
  (https://nomac.app/simulator). `phone_app_run` builds from a git link, or from
23
23
  the project here: in `nomac mcp`, `local_path` sends the folder (only what
24
24
  changed); on the hosted server, `phone_upload_link` answers one command that
@@ -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 (bigger refills earn bonus credit; the answer suggests how many packs).
41
- 2. Install `npm install -g @nomac/cli@0.26.0` (it updates itself after), run `nomac login`, and give the human
41
+ 2. Install `npm install -g @nomac/cli@0.26.2` (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.26.0 mcp`.
44
+ `NOMAC_API_KEY`. MCP: `claude mcp add nomac -- npx -y @nomac/cli@0.26.2 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
@@ -175,11 +175,16 @@ secrets as variables and files, masked in command output, and a change
175
175
  reaches running Macs within a minute; `nomac secrets install NAME` adds one
176
176
  set to on request.
177
177
 
178
- The human connects Apple once at https://nomac.app/apple; the App Store
179
- Connect key stays on NoMac's server. Check `nomac apple` (MCP
178
+ The human connects Apple once at https://nomac.app/apple: they sign in with
179
+ their Apple Developer account (NoMac makes the App Store Connect key and
180
+ keeps only the key) or upload a key they made. Never ask them for an Apple
181
+ password. The key stays on NoMac's server. Check `nomac apple` (MCP
180
182
  `connect_status`) before asking them: it shows the key, certificates and
181
- profiles already there. Then, from your project folder (the CLI acts on the
182
- Mac):
183
+ profiles already there. Not in the Apple Developer Program yet: the human
184
+ enrolls at https://developer.apple.com/programs/enroll in any browser, Safari
185
+ on the NoMac Mac included (the Apple Developer app does not install on a
186
+ virtual Mac; in India Apple enrolls only in that app, on their own device).
187
+ Then, from your project folder (the CLI acts on the Mac):
183
188
 
184
189
  1. `nomac sign [path]` (MCP `set_up_signing`) makes and installs the App Store
185
190
  profiles the project needs and prints the files, the reserved build number
package/src/cli.mjs CHANGED
@@ -65,7 +65,16 @@ export async function main(argv) {
65
65
  const { tunnel } = await import("./mac-transport.mjs");
66
66
  if (process.env.NOMAC_SESSION_TOKEN) return tunnel(rest[0]);
67
67
  const { sessionAccess } = await import("./hosted-sessions.mjs");
68
- const access = await sessionAccess(rest[0].replace(/^nomac-/, ""));
68
+ // An editor runs this again on every reconnect: a Mac it was told has ended fails at once, without asking NoMac (LIM-386).
69
+ const { endedMac, endedTunnelLine, hasEnded, rememberEnded } = await import("./ended-macs.mjs");
70
+ const id = rest[0].replace(/^nomac-/, ""), known = endedMac(id);
71
+ if (known) throw new CliError("Mac has ended", `${known.message}\n${endedTunnelLine(id)}`, 410, "session_ended");
72
+ const access = await sessionAccess(id).catch(error => {
73
+ if (!hasEnded(error)) throw error;
74
+ // One still stopping is asked about again, so what is remembered says it stopped, and why.
75
+ if (error.details?.state !== "stopping") rememberEnded(id, error.friendly ?? error.message);
76
+ throw new CliError(error.message, `${error.friendly ?? error.message}\n${endedTunnelLine(id)}`, 410, "session_ended", error.details);
77
+ });
69
78
  return tunnel(rest[0], { gateway: access.gateway, token: access.token });
70
79
  }
71
80
  case "transport": {
@@ -237,7 +246,7 @@ async function readStdin() {
237
246
  export function describeApple(view) {
238
247
  const accounts = view.apple_accounts ?? [], identities = (view.identities ?? []).filter(id => id.state === "active"), profiles = view.profiles ?? [];
239
248
  if (!accounts.length && !identities.length) {
240
- return "Apple: not connected. The account owner connects an App Store Connect team key once at https://nomac.app/apple (only a person can); until then nomac sign and nomac testflight cannot reach Apple.";
249
+ return "Apple: not connected. The account owner connects Apple once at https://nomac.app/apple (only a person can): they sign in with their Apple Developer account there, or upload an App Store Connect team key; until then nomac sign and nomac testflight cannot reach Apple.";
241
250
  }
242
251
  const lines = accounts.map(a => `Apple: connected (App Store Connect key ${a.key_id}, issuer ${a.issuer_id}), ${a.status}, since ${String(a.connected_at).slice(0, 10)}.`);
243
252
  if (!accounts.length) lines.push("Apple: no App Store Connect key connected; the certificates below still reach every Mac. Connect one at https://nomac.app/apple to make profiles and send to TestFlight.");
@@ -0,0 +1,50 @@
1
+ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+
5
+ /**
6
+ * Macs this computer was told have ended (LIM-386). nomac ssh-config's ProxyCommand (nomac tunnel ID) knows only the id,
7
+ * and an editor (VS Code, Cursor Remote SSH) runs it again on every reconnect, forever: 46,262 access calls in 4 days
8
+ * from one account in November 2026, all for a Mac that had stopped. A Mac that has ended never runs again, so the
9
+ * tunnel remembers it here and fails at once; each id is asked about once a day at most, and the file keeps the last
10
+ * MAX. Nothing here ever fails the command: at worst NoMac is asked again.
11
+ */
12
+ const KEEP_MS = 24 * 3_600_000, MAX = 100;
13
+ const ENDED_STATES = new Set(["stopping", "stopped", "failed"]);
14
+ const fileIn = home => join(home, ".nomac", "ended-macs.json");
15
+
16
+ /** session_ended, or an older site's session_not_ready for a Mac that is stopping, stopped or failed (one starting can still become ready). */
17
+ export const hasEnded = error => error?.code === "session_ended"
18
+ || (error?.code === "session_not_ready" && ENDED_STATES.has(error?.details?.state) && error?.details?.starting !== true);
19
+
20
+ const fresh = (entry, now) => {
21
+ const at = Date.parse(entry?.at);
22
+ return now - at < KEEP_MS && at <= now + 60_000;
23
+ };
24
+ function read(home) {
25
+ try {
26
+ const list = JSON.parse(readFileSync(fileIn(home), "utf8"));
27
+ return Array.isArray(list) ? list.filter(entry => typeof entry?.id === "string" && typeof entry.message === "string") : [];
28
+ } catch { return []; }
29
+ }
30
+
31
+ /** What NoMac said when it was told this Mac had ended, if that was within the last day. */
32
+ export function endedMac(id, { home = homedir(), now = Date.now() } = {}) {
33
+ return read(home).find(entry => entry.id === id && fresh(entry, now));
34
+ }
35
+
36
+ export function rememberEnded(id, message, { home = homedir(), now = Date.now() } = {}) {
37
+ try {
38
+ const kept = read(home).filter(entry => entry.id !== id && fresh(entry, now)).slice(-(MAX - 1));
39
+ mkdirSync(join(home, ".nomac"), { recursive: true, mode: 0o700 });
40
+ // Several tunnels may write at once: each writes a whole file and renames it into place, and the last one wins.
41
+ const file = fileIn(home), temporary = `${file}.${process.pid}.tmp`;
42
+ try {
43
+ writeFileSync(temporary, `${JSON.stringify([...kept, { id, at: new Date(now).toISOString(), message: String(message).slice(0, 2000) }])}\n`, { mode: 0o600 });
44
+ renameSync(temporary, file);
45
+ } finally { rmSync(temporary, { force: true }); }
46
+ } catch { /* NoMac is asked again next time */ }
47
+ }
48
+
49
+ /** The line an editor's SSH log shows under NoMac's answer. */
50
+ export const endedTunnelLine = id => `NoMac: ${id}, the Mac this SSH entry reaches, has ended. Run nomac start in the project's folder for a new one: once it is ready, this entry (nomac ssh-config) points at it.`;
@@ -900,8 +900,9 @@ export async function hostedSessionCommand(command, argv, { store = sessionStore
900
900
  if (first) print(`${describeSync(result)}\nWatching ${store.project} for changes; Ctrl-C stops.`);
901
901
  else if (result.changed.length || result.deleted?.length || result.kept_on_mac?.length) print(`${clock()} ${describeSync({ ...result, skipped: [] })}`);
902
902
  } catch (error) {
903
- // A stopped Mac ends the watch; a conflict, a busy folder or a lost connection is said, and it goes on.
904
- if (error?.code === "session_not_ready") throw error;
903
+ // A stopped Mac ends the watch (session_ended if it stopped as this sync began, LIM-386); a conflict, a busy
904
+ // folder or a lost connection is said, and it goes on.
905
+ if (error?.code === "session_not_ready" || error?.code === "session_ended") throw error;
905
906
  print(`${clock()} ${error.friendly || error.message}`);
906
907
  }
907
908
  first = false;
package/src/mcp.mjs CHANGED
@@ -87,7 +87,7 @@ export const TOOLS = [
87
87
  org: me.org,
88
88
  connections: [],
89
89
  next_step:
90
- "No Apple connection. The human connects once at https://nomac.app/dash/apple with an App Store Connect API key (about a minute).",
90
+ "No Apple connection. The human connects once at https://nomac.app/dash/apple, in about a minute: they sign in as the team's Account Holder or an Admin and NoMac makes the App Store Connect key, or they upload a key they made. Never ask them for an Apple password.",
91
91
  });
92
92
  }
93
93
  const detail = await api("GET", `/api/v1/connections/${conns.connections[0].id}`);