@nomac/cli 0.26.0 → 0.26.1
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 +3 -3
- package/src/cli.mjs +10 -1
- package/src/ended-macs.mjs +50 -0
- package/src/hosted-sessions.mjs +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomac/cli",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.1",
|
|
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.
|
|
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.
|
|
41
|
+
2. Install `npm install -g @nomac/cli@0.26.1` (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.
|
|
44
|
+
`NOMAC_API_KEY`. MCP: `claude mcp add nomac -- npx -y @nomac/cli@0.26.1 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
|
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
|
-
|
|
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": {
|
|
@@ -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.`;
|
package/src/hosted-sessions.mjs
CHANGED
|
@@ -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
|
|
904
|
-
|
|
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;
|