worktrust 0.11.6 → 0.11.8

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * THE DAEMON AS A SERVICE OF THIS USER (2026-11-07). Off until `worktrust remote enable`; removed by `disable`.
2
+ * THE DAEMON AS A SERVICE OF THIS USER (2026-11-07). Off until `worktrust remote app` (or `remote web`); removed by `disable`.
3
3
  *
4
4
  * macOS a launchd agent, ~/Library/LaunchAgents/io.worktrust.remote.plist: RunAtLoad, restarted after a crash
5
5
  * (KeepAlive SuccessfulExit false), so `disable` (exit 0) stays off; logs in ~/.worktrust/remote/daemon.log
@@ -12,7 +12,7 @@
12
12
  * (so the agents are found) and nothing else from their environment. Every command is execFile with fixed arguments.
13
13
  */
14
14
  import { execFileSync } from "node:child_process";
15
- import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
15
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
16
16
  import { homedir, userInfo } from "node:os";
17
17
  import { join } from "node:path";
18
18
 
@@ -99,3 +99,37 @@ export function serviceState({ platform = process.platform, home = homedir() } =
99
99
  if (kind === "systemd") return { kind, installed: existsSync(unitPath(home)), running: run("systemctl", ["--user", "is-active", "--quiet", UNIT]) };
100
100
  return { kind, installed: false, running: false };
101
101
  }
102
+
103
+ /**
104
+ * MACOS ASKS ONCE, NOW, NOT MID-SESSION (CLI 0.11.7, owner 2026-11-12). macOS guards Desktop, Documents, Downloads and
105
+ * iCloud Drive per program: a program launchd starts is asked on its first read there, so an agent the service starts in
106
+ * such a folder would stop mid-session at a prompt nobody sees, or fail with "Operation not permitted". When the person
107
+ * adds such a folder at the keyboard, the CLI runs the SAME program the service runs (its node or Python launcher, the
108
+ * release entry, `remote folder-check`) once, as a one-shot launchd job with the service's PATH and HOME, so the prompt
109
+ * comes up at once for the program that later starts the agents. `remote folder-check` only reads whether each guarded
110
+ * root or project can be listed and writes yes or no per folder to ~/.worktrust/remote/folder-check.json; nothing leaves
111
+ * the computer. → that file's contents, or null (not macOS, or no answer in time).
112
+ */
113
+ export const CHECK_LABEL = "io.worktrust.remote.folder-check";
114
+ export const folderCheckPlist = ({ program, path, home = homedir() }) => launchdPlist({ program, path, home })
115
+ .replace(`<string>${LABEL}</string>`, `<string>${CHECK_LABEL}</string>`)
116
+ .replace(" <key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>\n <key>ThrottleInterval</key><integer>10</integer>\n", " <key>LaunchOnlyOnce</key><true/>\n");
117
+ export async function probeFolders({ program, path, home = homedir(), platform = process.platform, waitMs = 120_000 }) {
118
+ if (servicePlatform(platform) !== "launchd") return null;
119
+ const out = join(home, ".worktrust", "remote", "folder-check.json"), file = join(home, "Library", "LaunchAgents", `${CHECK_LABEL}.plist`);
120
+ const domain = `gui/${userInfo().uid}`;
121
+ rmSync(out, { force: true });
122
+ mkdirSync(join(home, "Library", "LaunchAgents"), { recursive: true });
123
+ writeFileSync(file, folderCheckPlist({ program, path, home }), { mode: 0o644 });
124
+ run("launchctl", ["bootout", `${domain}/${CHECK_LABEL}`]);
125
+ let result = null;
126
+ if (run("launchctl", ["bootstrap", domain, file])) {
127
+ for (const end = Date.now() + waitMs; Date.now() < end && result === null;) {
128
+ await new Promise((resolve) => setTimeout(resolve, 500));
129
+ try { result = JSON.parse(readFileSync(out, "utf8")); } catch { result = null; }
130
+ }
131
+ }
132
+ run("launchctl", ["bootout", `${domain}/${CHECK_LABEL}`]);
133
+ rmSync(file, { force: true });
134
+ return result;
135
+ }
@@ -13,6 +13,7 @@ import { basename, join } from "node:path";
13
13
  import * as P from "./remote-protocol.mjs";
14
14
  import { appendSteered } from "./remote-steered.mjs";
15
15
  import { adapterOf } from "./remote-inventory.mjs";
16
+ import { allowedModes, startChoice } from "./remote-settings.mjs";
16
17
  import { claudeArgs, isClaudeSessionId, removeQuietly, startClaude, writeMcpConfig } from "./remote-adapter-claude-code.mjs";
17
18
  import { backgroundJobs, emptyClaudeState, endClaudeRun, mapClaudeLine } from "./remote-claude-events.mjs";
18
19
  import { collectChanges, snapshotChanges } from "./remote-changes.mjs";
@@ -198,7 +199,7 @@ export function createSessions(ctx) {
198
199
  const features = ctx.inventory().features["claude-code"];
199
200
  s.token = ctx.approvals.register(s);
200
201
  s.mcpFile = writeMcpConfig(join(ctx.runDir, `${s.session_id}.mcp.json`), { node: ctx.node, bridge: ctx.bridgePath, socket: ctx.socket(), token: s.token });
201
- const args = claudeArgs({ features, mode: s.mode, model: s.model, resume, sessionRef: s.agent_ref, mcpConfig: s.mcpFile });
202
+ const args = claudeArgs({ features, mode: s.agentMode ?? s.mode, model: s.model, resume, sessionRef: s.agent_ref, mcpConfig: s.mcpFile, effort: s.effort ?? null, addDirs: s.extraPaths ?? [] });
202
203
  mark(s); // the ledger names the session before the agent writes a line
203
204
  s.run = startClaude({ file: ctx.inventory().files["claude-code"], cwd: s.projectPath, env: ctx.agentEnv(), args, onLine: (line) => onLine(s, line), onExit: (how) => onExit(s, how) });
204
205
  ctx.journal.recordSession({ session_id: s.session_id, pid: s.run.pid ?? null, agent_session_ref: s.agent_ref }); // a later daemon ends it if this one dies (P2-b)
@@ -209,17 +210,19 @@ export function createSessions(ctx) {
209
210
  function start(env, payload) {
210
211
  if (live.has(env.session_id) || ctx.journal.session(env.session_id)) return "conflict";
211
212
  if ([...live.values()].filter((s) => s.run).length >= (ctx.settings().max_sessions ?? DEFAULT_MAX_SESSIONS)) return "busy";
212
- const project = ctx.projects().find((p) => p.project_id === env.project_id);
213
+ // Project and extras by the ids of the computer's own list, never a path; the 0.11.7 options against its own ceiling.
214
+ const known = ctx.projects(), project = known.find((p) => p.project_id === env.project_id);
213
215
  if (!project) return "not_found";
214
- const refused = P.checkStart(payload, adapterOf(ctx.inventory(), payload.adapter));
215
- if (refused) return refused;
216
+ const refused = P.checkStart(payload, adapterOf(ctx.inventory(), payload.adapter)); if (refused) return refused;
217
+ const choice = startChoice(payload, project.project_id, ctx.inventory(), ctx.settings(), known); if (typeof choice === "string") return choice;
216
218
  if (!AGENT_ID[payload.adapter]) return "unsupported";
217
219
  if (payload.resume !== null && !AGENT_ID[payload.adapter](payload.resume)) return "unsupported";
218
220
  const s = { session_id: env.session_id, project_id: project.project_id, projectPath: project.path, adapter: payload.adapter, model: payload.model, mode: payload.permission_mode,
219
221
  agent_ref: payload.resume ?? (payload.adapter === "codex" ? null : payload.adapter === "opencode" ? mintOpenCodeSessionId(ctx.now(), ctx.random) : randomUUID()), how: "started", first: ctx.now(), queue: [], state: FRESH_STATE[payload.adapter](),
220
- coalesce: createCoalescer({ now: ctx.now }), attention: null, command_id: null, waiting: null, turnOpen: false, run: null, steers: [], interrupting: false, ownTurn: null, task: env.task === true, tokens: P.NO_TOKENS, subagents: new Map(), turnStartedAt: null, name: payload.name ?? null, active: 0, countedTurn: null };
222
+ coalesce: createCoalescer({ now: ctx.now }), attention: null, command_id: null, waiting: null, turnOpen: false, run: null, steers: [], interrupting: false, ownTurn: null, task: env.task === true, tokens: P.NO_TOKENS, subagents: new Map(), turnStartedAt: null, name: payload.name ?? null, active: 0, countedTurn: null,
223
+ agentMode: payload.agent_mode ?? null, effort: choice.effort, extraIds: choice.extraProjectIds, extraPaths: choice.extras.map((p) => p.path) };
221
224
  live.set(s.session_id, s);
222
- ctx.journal.recordSession({ session_id: s.session_id, adapter: s.adapter, project_id: s.project_id, agent_session_ref: s.agent_ref, model: s.model, mode: s.mode, at: ctx.now(), name: s.name, active_ms: 0 });
225
+ ctx.journal.recordSession({ session_id: s.session_id, adapter: s.adapter, project_id: s.project_id, agent_session_ref: s.agent_ref, model: s.model, mode: s.mode, at: ctx.now(), name: s.name, active_ms: 0, ...(s.agentMode ? { agent_mode: s.agentMode } : {}), ...(s.effort ? { effort: s.effort } : {}), ...(s.extraIds.length ? { extra_project_ids: s.extraIds } : {}) });
223
226
  ctx.emit(s.session_id, "session.created", { adapter: s.adapter, model: s.model, origin: "phone", title: null, project_label: basename(project.path).slice(0, 256) || null, name: s.name }, env.command_id);
224
227
  spawnAgent(s, payload.resume);
225
228
  if (payload.prompt) s.queue.push({ text: payload.prompt, command_id: env.command_id, received_at: ctx.now() });
@@ -234,12 +237,15 @@ export function createSessions(ctx) {
234
237
  if (s?.run) return s;
235
238
  const saved = s ?? ctx.journal.session(sessionId);
236
239
  if (!saved || saved.closed) return null;
237
- const project = ctx.projects().find((p) => p.project_id === saved.project_id);
238
- const ref = s?.agent_ref ?? saved.agent_session_ref;
240
+ const known = ctx.projects(), project = known.find((p) => p.project_id === saved.project_id), ref = s?.agent_ref ?? saved.agent_session_ref;
239
241
  if (!project || !AGENT_ID[saved.adapter]?.(ref)) return null;
242
+ const agentMode = s?.agentMode ?? saved.agent_mode ?? null; // within today's ceiling, or it stays down (0.11.7)
243
+ if (agentMode && !allowedModes(ctx.settings()).includes(agentMode)) return null;
244
+ const extras = (s?.extraIds ?? saved.extra_project_ids ?? []).map((id) => known.find((p) => p.project_id === id)).filter(Boolean);
240
245
  if ([...live.values()].filter((x) => x.run).length >= (ctx.settings().max_sessions ?? DEFAULT_MAX_SESSIONS)) return null;
241
246
  s = s ?? { session_id: sessionId, project_id: saved.project_id, projectPath: project.path, adapter: saved.adapter, model: saved.model ?? null, mode: saved.mode ?? "ask", agent_ref: ref, how: "started", first: ctx.now(), queue: [], state: FRESH_STATE[saved.adapter](),
242
- coalesce: createCoalescer({ now: ctx.now }), attention: null, command_id: null, waiting: null, turnOpen: false, run: null, steers: [], interrupting: false, ownTurn: null, task: false, tokens: P.NO_TOKENS, subagents: new Map(), turnStartedAt: null, name: saved.name ?? null, active: saved.active_ms ?? null, countedTurn: null };
247
+ coalesce: createCoalescer({ now: ctx.now }), attention: null, command_id: null, waiting: null, turnOpen: false, run: null, steers: [], interrupting: false, ownTurn: null, task: false, tokens: P.NO_TOKENS, subagents: new Map(), turnStartedAt: null, name: saved.name ?? null, active: saved.active_ms ?? null, countedTurn: null,
248
+ agentMode, effort: saved.effort ?? null, extraIds: extras.map((p) => p.project_id), extraPaths: extras.map((p) => p.path) };
243
249
  live.set(sessionId, s);
244
250
  spawnAgent(s, s.agent_ref);
245
251
  return s;
@@ -0,0 +1,191 @@
1
+ /**
2
+ * WHAT A PHONE MAY DO ON THIS COMPUTER, CHANGED IN ONE PLACE (CLI 0.11.7, owner 2026-11-12). Every change to the remote
3
+ * settings that widens or narrows a phone's reach (the ceiling of agent modes, the roots, the granted projects, the admin
4
+ * switch) goes through applySettingsChange(change, source). Today the only source is THIS KEYBOARD (`{ kind: "keyboard" }`,
5
+ * a `remote …` command or the menu, both refused in an AI agent's shell by worktrust.mjs). Part B adds a second source, a
6
+ * change the person approved in the WorkTrust app or on the web and the server signed (`{ kind: "admin", proof }`); it will
7
+ * be honoured only while `remote admin on` (the default) and only once its proof verifies here. Until part B ships, an
8
+ * admin change is refused: nothing but this keyboard changes these settings (docs/remote-agents/PROTOCOL.md "Agent modes").
9
+ *
10
+ * PART B (owner, 2026-11-12): the second source is here. A change from the app or the web arrives as `{ kind: "admin",
11
+ * proof, issuerKeys, claims, now }` (remote-daemon.mjs, from a sealed device.configure): remote-admin.mjs adminRefusal
12
+ * checks `remote admin on` and the issuer-signed proof (this computer, this account, this change, five minutes, one use),
13
+ * resolveAdminChange names its folder, root or connection from this computer's own lists by id, and the result goes
14
+ * through the same rules below as a typed command. The admin switch itself never changes from the app.
15
+ *
16
+ * THE CEILING OF AGENT MODES (protocol adapters.ts AGENT_MODES). Manual and plan are always allowed (today's behaviour);
17
+ * `allow edit` lets a phone start a session that edits files inside its projects without asking; `allow auto` lets it start
18
+ * the agent's own automatic mode, and, being above edit, allows edit too. `deny edit` takes both away again. The ceiling is
19
+ * read by the daemon on every start (checkAgentOptions), never taken from a phone.
20
+ */
21
+ import { readdirSync } from "node:fs";
22
+ import { adminRefusal, resolveAdminChange } from "./remote-admin.mjs";
23
+ import { removePhones } from "./remote-connections.mjs";
24
+ import { protectedFolder } from "./folder-picker.mjs";
25
+ import { canonicalProject } from "./remote-policy.mjs";
26
+ import { probeFolders } from "./remote-service.mjs";
27
+ import { checkRoot, MAX_ROOTS, rootIdOf } from "./remote-projects.mjs";
28
+ import { agentOptionsOf } from "./remote-inventory.mjs";
29
+ import * as P from "./remote-protocol.mjs";
30
+ import { ensureRemoteDir, loadKeys, loadProjects, loadRoots, loadSettings, projectIdOf, saveProjects, saveRoots, saveSettings, writeJson } from "./remote-store.mjs";
31
+
32
+ export const RAISABLE_MODES = Object.freeze(["edit", "auto"]);
33
+ const ORDER = ["manual", "edit", "plan", "auto"];
34
+
35
+ /** The modes this computer allows: manual and plan always, edit and auto when the person allowed them (auto brings edit). */
36
+ export function allowedModes(settings = loadSettings()) {
37
+ const set = new Set(["manual", "plan"]);
38
+ const asked = Array.isArray(settings.modes_allowed) ? settings.modes_allowed : [];
39
+ if (asked.includes("auto")) { set.add("auto"); set.add("edit"); }
40
+ if (asked.includes("edit")) set.add("edit");
41
+ return ORDER.filter((m) => set.has(m));
42
+ }
43
+
44
+ const refused = (reason) => ({ ok: false, reason });
45
+
46
+ /**
47
+ * A START'S 0.11.7 OPTIONS, decided here (remote-sessions.mjs calls it before anything is set up): the adapter's options as
48
+ * this computer reads them from its own agent, the ceiling from the settings file, and the extra projects from the
49
+ * computer's own list by id. → a reject reason, or { agentMode, effort, extraProjectIds, extras: [{ project_id, path }] }.
50
+ */
51
+ export function startChoice(payload, projectId, inventory, settings, known) {
52
+ const options = agentOptionsOf(inventory).find((o) => o.adapter === payload.adapter && o.mode === (payload.mode ?? "structured")) ?? null;
53
+ const choice = P.checkAgentOptions(payload, projectId, options, allowedModes(settings), new Set(known.map((p) => p.project_id)));
54
+ if (typeof choice === "string") return choice;
55
+ return { ...choice, extras: choice.extraProjectIds.map((id) => known.find((p) => p.project_id === id)) };
56
+ }
57
+
58
+ /**
59
+ * The one door for a settings change. `change`: { what: "modes", allow|deny: "edit"|"auto" } | { what: "roots", add: dir,
60
+ * git_init } | { what: "roots", remove: id|dir } | { what: "projects", add: dir } | { what: "projects", remove: id|dir } |
61
+ * { what: "admin", on: boolean } | { what: "connections", remove: fingerprint } (resolved from the app's change only).
62
+ * `source`: { kind: "keyboard" }, or { kind: "admin", proof, issuerKeys, claims, now, via } (part B; its change is
63
+ * crypto/admin.ts's ADMIN_CHANGE_SPEC, resolved by id before it reaches the rules below).
64
+ * → { ok: true, message, paths?, setting? } or { ok: false, reason, code? } (code: the protocol's reject reason).
65
+ */
66
+ export function applySettingsChange(change, source) {
67
+ if (source?.kind === "admin") {
68
+ // From the app or the web: `remote admin on`, then the issuer-signed proof, then this computer's own lists by id.
69
+ const gate = adminRefusal(change, source, loadSettings());
70
+ if (gate) return { ok: false, reason: gate.reason, code: gate.code };
71
+ const resolved = resolveAdminChange(change);
72
+ if (!resolved.ok) return { ok: false, reason: resolved.reason, code: resolved.code };
73
+ const done = applyRules(resolved.change, true);
74
+ return done.ok ? { ...done, setting: resolved.setting } : { ...done, code: done.code ?? "unsupported" };
75
+ }
76
+ if (source?.kind !== "keyboard") return refused("this computer's remote settings are changed at its keyboard");
77
+ return applyRules(change, false);
78
+ }
79
+
80
+ /** The rules every change meets, typed here or resolved from the app (`fromApp`): the same checks, the same files. */
81
+ function applyRules(change, fromApp) {
82
+ const settings = loadSettings();
83
+ if (change?.what === "modes") {
84
+ const mode = change.allow ?? change.deny;
85
+ if (!RAISABLE_MODES.includes(mode)) return refused("name edit or auto (manual and plan are always allowed)");
86
+ const now = new Set(allowedModes(settings));
87
+ if (change.allow) { now.add(mode); if (mode === "auto") now.add("edit"); }
88
+ else { now.delete(mode); if (mode === "edit") now.delete("auto"); }
89
+ saveSettings({ ...settings, modes_allowed: ORDER.filter((m) => now.has(m)) });
90
+ return { ok: true, message: `Allowed modes: ${allowedModes(loadSettings()).join(", ")}` };
91
+ }
92
+ if (change?.what === "connections" && fromApp) {
93
+ // From the app only (the keyboard's own `remote disconnect` asks twice and calls removePhones itself).
94
+ const n = removePhones([String(change.remove ?? "")]);
95
+ return n > 0 ? { ok: true, message: "Disconnected: it can no longer steer this computer." } : { ...refused("no phone or browser by that fingerprint"), code: "not_found" };
96
+ }
97
+ if (change?.what === "admin") {
98
+ if (fromApp) return refused("the admin switch changes at this keyboard only");
99
+ if (typeof change.on !== "boolean") return refused("on or off");
100
+ saveSettings({ ...settings, admin: change.on });
101
+ return { ok: true, message: change.on ? "Managing this computer from the app or the web: on. Each change there asks your authenticator, and this computer checks WorkTrust's signature on it." : "Managing this computer from the app or the web: off. Only this keyboard changes its remote settings." };
102
+ }
103
+ const keys = loadKeys();
104
+ if (change?.what === "roots") {
105
+ const list = loadRoots();
106
+ if (change.add !== undefined) {
107
+ if (!keys) return refused("this computer is not paired for remote yet: run `npx worktrust remote app`");
108
+ const root = checkRoot(change.add ?? "");
109
+ if (!root.ok) return refused(`not added: ${root.reason}`);
110
+ if (list.length >= MAX_ROOTS && !list.some((r) => r.path === root.path)) return refused(`at most ${MAX_ROOTS} roots`);
111
+ const root_id = rootIdOf(keys.projectSecret, root.path);
112
+ saveRoots([...list.filter((r) => r.root_id !== root_id), { root_id, path: root.path, git_init: change.git_init === true, added_at: Date.now() }]);
113
+ return { ok: true, paths: [root.path], message: `Root: ${root.path}. A phone may open the projects already in it and create one new, empty folder in it per request${change.git_init === true ? ", with git init" : ""}.` };
114
+ }
115
+ const key = String(change.remove ?? "");
116
+ const kept = list.filter((r) => r.root_id !== key && r.path !== key && r.path !== checkRoot(key).path);
117
+ if (kept.length === list.length) return refused("no root by that path or id");
118
+ saveRoots(kept);
119
+ return { ok: true, message: "Removed. Projects made in it stay granted: npx worktrust remote projects remove <folder>." };
120
+ }
121
+ if (change?.what === "projects") {
122
+ const list = loadProjects();
123
+ if (change.add !== undefined) {
124
+ if (!keys) return refused("this computer is not paired for remote yet: run `npx worktrust remote app`");
125
+ const canonical = canonicalProject(change.add ?? "");
126
+ if (!canonical.ok) return refused(`not granted: ${canonical.reason}`);
127
+ const project_id = projectIdOf(keys.projectSecret, canonical.path);
128
+ if (!list.some((p) => p.project_id === project_id)) saveProjects([...list, { project_id, path: canonical.path, added_at: Date.now() }]);
129
+ return { ok: true, paths: [canonical.path], message: `Granted: ${canonical.path}` };
130
+ }
131
+ const key = String(change.remove ?? "");
132
+ const canonical = canonicalProject(key);
133
+ const kept = list.filter((p) => p.project_id !== key && p.path !== key && !(canonical.ok && p.path === canonical.path));
134
+ if (kept.length === list.length) return refused("no granted folder by that path or id");
135
+ saveProjects(kept);
136
+ return { ok: true, message: "Removed." };
137
+ }
138
+ return refused("not a setting this computer knows");
139
+ }
140
+
141
+ /** `remote modes allow|deny edit|auto | status`. */
142
+ export function modesCommand(io, rest) {
143
+ if (rest[0] === "allow" || rest[0] === "deny") {
144
+ const done = applySettingsChange({ what: "modes", [rest[0]]: rest[1] }, { kind: "keyboard" });
145
+ if (!done.ok) io.fail(`npx worktrust remote modes allow|deny edit|auto: ${done.reason}`);
146
+ io.say(` ✓ ${done.message}`);
147
+ if (rest[0] === "allow") io.say(" A phone may now start sessions in it; the deny rules (no push, no install, no deploy, no secret) hold in every mode.");
148
+ return;
149
+ }
150
+ if (rest[0] !== undefined && rest[0] !== "status") io.fail("npx worktrust remote modes allow|deny edit|auto | status");
151
+ const allowed = allowedModes();
152
+ const WORDS = { manual: "Manual (asks for every change)", edit: "Edit automatically (edits inside the project without asking)", plan: "Plan (read-only)", auto: "Auto (the agent's own automatic mode)" };
153
+ io.say(" Agent modes a phone may start on this computer:");
154
+ for (const m of ORDER) io.say(` ${allowed.includes(m) ? "✓" : "·"} ${WORDS[m]}${allowed.includes(m) || m === "manual" || m === "plan" ? "" : ` allow: npx worktrust remote modes allow ${m}`}`);
155
+ }
156
+
157
+ /** `remote admin on|off | status`: whether a change approved in the app or on the web (with the authenticator) is honoured here. */
158
+ export function adminCommand(io, rest) {
159
+ if (rest[0] === "on" || rest[0] === "off") {
160
+ const done = applySettingsChange({ what: "admin", on: rest[0] === "on" }, { kind: "keyboard" });
161
+ io.say(` ✓ ${done.message}`);
162
+ return;
163
+ }
164
+ io.say(` Managing this computer from the app or the web: ${loadSettings().admin === false ? "off" : "on"} (npx worktrust remote admin on|off; each change there asks your authenticator)`);
165
+ }
166
+
167
+ /**
168
+ * `remote folder-check` (internal; run by probeFolders as the service's own program): can each root and project in a folder
169
+ * macOS guards be listed? Writes { at, folders: [{ path, folder, ok }] } to folder-check.json and nothing else.
170
+ */
171
+ export function folderCheck() {
172
+ const folders = [...loadRoots(), ...loadProjects()].map((x) => x.path).filter((path, i, all) => all.indexOf(path) === i && protectedFolder(path))
173
+ .map((path) => { try { readdirSync(path); return { path, folder: protectedFolder(path), ok: true }; } catch { return { path, folder: protectedFolder(path), ok: false }; } });
174
+ ensureRemoteDir();
175
+ writeJson("folder-check.json", { at: Date.now(), folders });
176
+ }
177
+
178
+ /** After a folder was added at the keyboard: when macOS guards it, ask at once, from the program that will run the agents. */
179
+ export async function askMacFolderAccess(io, paths) {
180
+ const guarded = [...new Set((paths ?? []).map((p) => protectedFolder(p)).filter(Boolean))];
181
+ if (guarded.length === 0) return null;
182
+ io.say(` macOS guards your ${guarded.join(" and ")} folder. It now asks once whether the program that runs your agents (shown as "node" or "python") may read it.`);
183
+ io.say(" Click OK (Allow). Without it, a session there stops at a prompt nobody sees, or fails with \"Operation not permitted\".");
184
+ const runtime = await io.prepare();
185
+ const result = await probeFolders({ program: [runtime.node, ...runtime.nodeArgs, runtime.entry, "remote", "folder-check"], path: loadSettings().agent_path ?? process.env.PATH ?? "" });
186
+ const refusedHere = (result?.folders ?? []).filter((f) => !f.ok);
187
+ if (result && refusedHere.length === 0) { io.say(" ✓ macOS lets the Remote Agent service read it."); return true; }
188
+ io.say(` ! ${result ? `macOS refused: ${refusedHere.map((f) => f.path).join(", ")}` : "No answer from macOS in time"}. To allow it later: System Settings › Privacy & Security › Files and Folders,`);
189
+ io.say(` then turn on ${guarded.join(" and ")} for "node" (or "python"); or add that program under Full Disk Access.`);
190
+ return false;
191
+ }
package/remote-store.mjs CHANGED
@@ -69,7 +69,10 @@ export const saveIdentity = (identity) => writeJson("identity.json", identity);
69
69
 
70
70
  // allow_endorse (2026-11-09): may a confirmed phone add a browser it scanned (remote-endorse.mjs)? Off until the person says so
71
71
  // here, at the keyboard (`worktrust remote phones allow-endorse on`).
72
- export const DEFAULT_SETTINGS = Object.freeze({ v: 1, enabled: false, paused: null, gateway: null, default_adapter: "claude-code", default_model: null, agent_path: null, codex: false, opencode: false, terminal: false, allow_endorse: false });
72
+ // modes_allowed (0.11.7, owner 2026-11-12): the CEILING of agent modes a phone may start, set here only (`worktrust remote
73
+ // modes allow|deny edit|auto`); manual and plan always. admin (0.11.7): RESERVED for managing this computer from the app or
74
+ // the web with a server-signed proof (part B); on by default, honoured by nothing yet (remote-settings.mjs).
75
+ export const DEFAULT_SETTINGS = Object.freeze({ v: 1, enabled: false, paused: null, gateway: null, default_adapter: "claude-code", default_model: null, agent_path: null, codex: false, opencode: false, terminal: false, allow_endorse: false, modes_allowed: Object.freeze(["manual", "plan"]), admin: true });
73
76
  export const loadSettings = () => ({ ...DEFAULT_SETTINGS, ...(readJson("settings.json") ?? {}) });
74
77
  export const saveSettings = (settings) => writeJson("settings.json", { ...DEFAULT_SETTINGS, ...settings });
75
78
 
package/worktrust.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * WorkTrust on a computer, in one command — like `gh auth login` (2026-10-03).
4
- * npx worktrust show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
4
+ * npx worktrust in a person's own terminal (0.11.7; 0.11.8: Update first): the menu (cli-menu.mjs), one item of which is
5
+ * what the bare command did until then; without a terminal, exactly that:
6
+ * show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
5
7
  * command always runs the newest version, whatever npx had cached);
6
8
  * on a computer already coupled: what is coupled here
7
9
  * npx worktrust --dry-run show the plan only; nothing is written, nothing is sent
@@ -26,7 +28,7 @@
26
28
  * command on a coupled computer offers an export lying in ~/Downloads once.
27
29
  * npx worktrust disconnect show what comes out, ask, take it out again
28
30
  * npx worktrust status what is coupled here
29
- * npx worktrust remote app|web|enable|pair|status|pause|resume|disable|phones|projects|run steer this computer's agents
31
+ * npx worktrust remote app|web|pair|status|pause|resume|disable|phones|projects|roots|modes|run steer this computer's agents
30
32
  * from your phone (remote-cli.mjs; opt-in, its own key, never the measurement key)
31
33
  * npx worktrust@latest preserve how long each AI app here keeps its sessions (--apply keeps them,
32
34
  * --archive [dir] a local metadata-only record, --verify [dir] checks it,
@@ -78,7 +80,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
78
80
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
79
81
  const has = (name) => args.includes(`--${name}`);
80
82
  /** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
81
- const CLI_VERSION = "0.11.6";
83
+ const CLI_VERSION = "0.11.8";
82
84
  /**
83
85
  * HOW THIS CLI MEASURES, AS A NUMBER OF ITS OWN (0.10.31; owner, 2026-10-28: 0.10.30 offered a re-measure it had no reason
84
86
  * to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
@@ -114,17 +116,23 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
114
116
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
115
117
  const HOME_DIR = join(homedir(), ".worktrust");
116
118
  const HERE = dirname(fileURLToPath(import.meta.url));
117
- const SCRIPTS = ["credential-store.mjs", "remote-protocol.mjs", "remote-store.mjs", "remote-policy.mjs", "remote-journal.mjs", "remote-steered.mjs", "remote-inventory.mjs", "remote-claude-events.mjs", "remote-claude-progress.mjs", "remote-attachments.mjs", "remote-preview.mjs", "remote-coalesce.mjs", "remote-steering.mjs", "remote-codex-events.mjs", "remote-adapter-codex.mjs", "remote-opencode-events.mjs", "remote-adapter-opencode.mjs", "remote-opencode-session.mjs", "remote-adapter-terminal.mjs", "remote-terminal-sessions.mjs", "remote-terminal-cli.mjs", "remote-screen-states.mjs", "remote-screen-approvals.mjs", "remote-screen-push.mjs", "remote-cdp.mjs", "remote-live-preview.mjs", "remote-projects.mjs", "remote-pipeline-config.mjs", "remote-pipeline-parsers.mjs", "remote-pipeline.mjs", "remote-releases.mjs", "remote-release-plans.mjs", "remote-adapter-claude-code.mjs", "remote-approval-bridge.mjs", "remote-approvals.mjs", "remote-sessions.mjs", "remote-session-list.mjs", "remote-changes.mjs", "remote-endorse.mjs", "remote-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.mjs", "remote-agent-switch.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "project-modes.mjs", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
119
+ const SCRIPTS = ["credential-store.mjs", "remote-protocol.mjs", "remote-store.mjs", "remote-policy.mjs", "remote-journal.mjs", "remote-steered.mjs", "remote-inventory.mjs", "remote-claude-events.mjs", "remote-claude-progress.mjs", "remote-attachments.mjs", "remote-preview.mjs", "remote-coalesce.mjs", "remote-steering.mjs", "remote-codex-events.mjs", "remote-adapter-codex.mjs", "remote-opencode-events.mjs", "remote-adapter-opencode.mjs", "remote-opencode-session.mjs", "remote-adapter-terminal.mjs", "remote-terminal-sessions.mjs", "remote-terminal-cli.mjs", "remote-screen-states.mjs", "remote-screen-approvals.mjs", "remote-screen-push.mjs", "remote-cdp.mjs", "remote-live-preview.mjs", "remote-projects.mjs", "remote-pipeline-config.mjs", "remote-pipeline-parsers.mjs", "remote-pipeline.mjs", "remote-releases.mjs", "remote-release-plans.mjs", "remote-adapter-claude-code.mjs", "remote-approval-bridge.mjs", "remote-approvals.mjs", "remote-sessions.mjs", "remote-session-list.mjs", "remote-changes.mjs", "remote-endorse.mjs", "remote-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.mjs", "remote-agent-switch.mjs", "remote-settings.mjs", "folder-picker.mjs", "cli-menu.mjs", "cli-menu-remote.mjs", "cli-colour.mjs", "node-guide.mjs", "remote-countdown.mjs", "remote-connections.mjs", "remote-admin.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "project-modes.mjs", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
118
120
  /** The modules the scripts import by name from beside them; a download keeps that name. */
119
121
  const IMPORTED = new Set(["project-modes.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
120
122
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
121
123
  const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
122
124
  const PLACEHOLDER = `wt_${"0".repeat(43)}`;
123
- const say = (line = "") => process.stdout.write(`${line}\n`);
125
+ // COLOUR WITH MEANING (0.11.8, cli-colour.mjs): a status line is painted by the symbol or word it already carries (✓ green,
126
+ // ! yellow, an error red), on a person's terminal only. A hook, the MCP bridge and self-update are read by programs: never
127
+ // painted, whatever the environment says. Colours off (a pipe, NO_COLOR, --no-color, CI), every byte is as before 0.11.8.
128
+ const MACHINE = command === "hook" || command === "self-update" || (command === "mcp" && !["on", "off", "status"].includes(args[args.indexOf("mcp") + 1]));
129
+ const { coloursFor, busyWith = (words, work) => work() } = await import("./cli-colour.mjs").catch(() => ({}));
130
+ const PAINT = coloursFor?.(process.stdout, { machine: MACHINE }) ?? { status: (line) => line }, PAINT_ERR = coloursFor?.(process.stderr, { machine: MACHINE }) ?? { status: (line) => line };
131
+ const say = (line = "") => process.stdout.write(`${PAINT.status(line)}\n`);
124
132
  // A reader that closed the pipe (`worktrust status | head`) wants no more: stop quietly, never an EPIPE stack (0.6.16, audit L4).
125
133
  process.stdout.on("error", (error) => { if (error?.code === "EPIPE") process.exit(0); throw error; });
126
134
  class CliFailure extends Error {}
127
- const fail = (line) => { process.stderr.write(`worktrust: ${line}\n`); throw new CliFailure(); };
135
+ const fail = (line) => { process.stderr.write(`${PAINT_ERR.status(`worktrust: ${line}`)}\n`); throw new CliFailure(); };
128
136
  const NODE_FLAGS = process.versions.node === "26.5.0" ? ["--no-concurrent-sparkplug"] : [];
129
137
  const OS = { darwin: "macos", win32: "windows", linux: "linux" }[platform()] ?? "other";
130
138
  /** The shells AI agents run commands in (AGENTS.md): a person-only command stops there (main). */
@@ -699,7 +707,7 @@ async function update() {
699
707
  const paths = await scripts();
700
708
  if (!doorState() && !has("dry-run")) saveDoorState({ mode: await chooseDoor(), asked: new Date().toISOString() }); // once, for a computer coupled before 0.10.37
701
709
  const doorIsOff = doorOff();
702
- const plan = await run(paths["setup-mcp.mjs"], ["--bridge", STABLE], PLACEHOLDER, true);
710
+ const plan = await busyWith("Reading the AI apps on this computer", () => run(paths["setup-mcp.mjs"], ["--bridge", STABLE], PLACEHOLDER, true));
703
711
  // AGREED BEFORE, REFRESHED WITHOUT A QUESTION (0.10.30): an app or hook the person said yes to is brought onto this
704
712
  // version's launcher; only what is NEW here is shown in full and asked about, and --yes leaves the new ones as they are.
705
713
  const agreed = await consent();
@@ -740,7 +748,7 @@ async function update() {
740
748
  // Codex installed since, or a No said at connect: the one question, asked again (or "already set").
741
749
  await offerCodex();
742
750
  await offerAntigravity();
743
- const reported = await accepted(key.url, key.token, key.device, doorModeAgent());
751
+ const reported = await busyWith("Telling WorkTrust the version", () => accepted(key.url, key.token, key.device, doorModeAgent()));
744
752
  say(reported === true ? ` ✓ WorkTrust received CLI version ${CLI_VERSION}.` : " ! Installed locally. WorkTrust could not confirm the version yet; it will be reported on the next connection.");
745
753
  await offerRebuild(previous, paths, key);
746
754
  doubleDoorNotice();
@@ -1005,7 +1013,7 @@ async function again() {
1005
1013
  * run was planned. Held-for-review batches stay held. Quiet when nothing was pending.
1006
1014
  */
1007
1015
  async function resendHistory(key) {
1008
- const paths = await scripts(), sent = await run(paths["log-session.mjs"], ["--history", "--resume"], key.token, true, { WORKTRUST_MCP_URL: key.url, ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) });
1016
+ const paths = await scripts(), sent = await busyWith("Checking for earlier history still waiting", () => run(paths["log-session.mjs"], ["--history", "--resume"], key.token, true, { WORKTRUST_MCP_URL: key.url, ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) }));
1009
1017
  let did = null;
1010
1018
  try { did = JSON.parse(sent.out.trim().split("\n").reverse().find((line) => line.startsWith('{"resumed"')) ?? "null"); } catch { /* nothing pending, or an older hook */ }
1011
1019
  if (Number(did?.resumed) > 0) { say(); say(` ✓ ${did.resumed} lines of earlier history that had not reached WorkTrust were sent; WorkTrust keeps them and rebuilds the days itself.`); }
@@ -1371,6 +1379,7 @@ async function status() {
1371
1379
  say(key ? ` Key: in ${KEY_PLACE}, ${key.device ? "bound to this computer, " : ""}last renewed ${String(key.renewedAt ?? "").slice(0, 10) || "never"}` : " Key: not on this computer (or written into the apps' settings with --direct)");
1372
1380
  if (key) say(key.account ? ` Account: ${key.account}${key.coupledAt ? `, coupled ${String(key.coupledAt).slice(0, 10)}` : ""}` : " Account: not recorded (coupled by an older version; `npx worktrust connect` records it)");
1373
1381
  say(sessionHookHere() ? " Session hook: installed" : " Session hook: not installed");
1382
+ if (typeof globalThis.WebSocket !== "function") say(` Remote Agent: needs Node 22.4 or later (this is ${process.versions.node})`);
1374
1383
  say(` AI work lines: ${doorLine()}`);
1375
1384
  if (measurePaused()) say(` Measuring: paused by you in Sources since ${String(measureState()?.since ?? "").slice(0, 10)}; nothing is measured or sent until you turn it on there`);
1376
1385
  // THE LAST UPDATE ON TURN-ON (0.10.37): what happened, in words; the details are in ~/.worktrust/update.log, on this computer only.
@@ -1395,7 +1404,7 @@ async function measuredHere() {
1395
1404
  const hook = join(HERE, "log-session.mjs");
1396
1405
  if (!hook) return;
1397
1406
  // Through the CLI's one way of starting a script (never a synchronous child: check-computer-pairing), with no door to send to.
1398
- const read = await run(hook, ["--evidence-summary"], "", true, { WORKTRUST_MCP_URL: "", WORKTRUST_HOOK_INPUT: "" });
1407
+ const read = await busyWith("Counting what this computer measured", () => run(hook, ["--evidence-summary"], "", true, { WORKTRUST_MCP_URL: "", WORKTRUST_HOOK_INPUT: "" }));
1399
1408
  let m = null;
1400
1409
  try { m = JSON.parse(read.out.trim().split("\n").filter((text) => text.startsWith("{")).pop()); } catch { return; }
1401
1410
  if (!m || !m.stretches) { say(" Measured here, last 30 days: no finished work stretch yet."); return; }
@@ -1638,8 +1647,10 @@ async function doorCommand(sub) {
1638
1647
  function help() {
1639
1648
  say("WorkTrust: couple this computer to your record. Metadata only.");
1640
1649
  say();
1641
- say(" worktrust couple this computer: show the plan, ask, approve in your browser");
1642
- say(" (already coupled: shows what is coupled here)");
1650
+ say(" worktrust in your terminal: the menu (every command below, with the short form it runs)");
1651
+ say(" npx -y worktrust skips npm's own \"Ok to proceed?\" question; --no-color (or NO_COLOR) turns colours off");
1652
+ say(" without a terminal, or with any option: couple this computer: show the plan, ask,");
1653
+ say(" approve in your browser (already coupled: shows what is coupled here)");
1643
1654
  say(" --dry-run the plan only: nothing is written, nothing is sent");
1644
1655
  say(" --yes no question (the computer is still approved in the browser)");
1645
1656
  say(" --device no browser here (SSH): type a code on another device");
@@ -1672,8 +1683,12 @@ function help() {
1672
1683
  say(" worktrust status what is coupled here");
1673
1684
  say(" worktrust project a folder's mode: exclude (nothing read), confidential (hours and tokens count, no name,");
1674
1685
  say(" branch, path or commit sent) or normal; `project list` shows them (default folder: here)");
1675
- say(" worktrust remote steer this computer's agents from your phone: enable, pair (a QR), status, pause, resume,");
1676
- say(" disable, phones, projects, run. Opt-in, its own key, never counted as your AI Hours");
1686
+ say(" worktrust remote steer this computer's agents from your phone (opt-in, its own key, never your AI Hours):");
1687
+ say(" app | web approve this computer: with the WorkTrust app (a QR here) | in the browser");
1688
+ say(" pair link a phone (a QR) status · pause · resume · disable · phones");
1689
+ say(" connections every phone and browser linked here; disconnect <n|name|fingerprint> | --all closes them");
1690
+ say(" projects · roots the folders a phone may steer an agent in; roots open the git projects inside them");
1691
+ say(" modes allow|deny edit|auto the agent modes a phone may start (default: manual and plan)");
1677
1692
  say(" worktrust mcp off hours only: the WorkTrust door out of every AI app here, nothing of it in your sessions;");
1678
1693
  say(" the session hook keeps measuring your hours, and update leaves the door out");
1679
1694
  say(" worktrust mcp on the door back in, so your AI can log finished work (about 40 tokens per session)");
@@ -1740,6 +1755,26 @@ async function relayToNewest() {
1740
1755
  say(` WorkTrust ${latest} is available. Automatic execution is paused until signed release verification is configured.`);
1741
1756
  say(" Update explicitly using the package manager you installed with. This invocation keeps its current version.");
1742
1757
  }
1758
+ // THE MENU (0.11.7, owner 2026-11-12): bare `npx worktrust` in a person's own terminal, nowhere else (cli-menu.mjs menuWanted:
1759
+ // both ends a terminal, no argument, not relayed, not a hook or the MCP door, not an agent's shell, WORKTRUST_MENU not off).
1760
+ // Each item runs one direct command as a child of this CLI, the terminal handed over and the menu kept out of it.
1761
+ if (command === "default" && BUNDLED && (await import("./cli-menu.mjs")).menuWanted({ args, env: process.env, stdinTTY: Boolean(process.stdin.isTTY), stdoutTTY: Boolean(process.stdout.isTTY), agentShell })) {
1762
+ try { keyStore.load(); }
1763
+ catch { fail("The local WorkTrust key file is unsafe or damaged, or the OS vault is locked or unavailable. Unlock your OS vault and retry. Do not delete the key file or reset the keychain."); }
1764
+ let latest;
1765
+ const runCli = (cliArgs) => new Promise((resolve) => {
1766
+ const child = spawn(moduleExecutable(HERE), [...moduleArgs(HERE, "worktrust.mjs", cliArgs)], { stdio: "inherit", env: { ...process.env, WORKTRUST_MENU: "off", WORKTRUST_RELAYED: "1", ...(has("no-color") || has("no-colour") ? { NO_COLOR: "1" } : {}) } });
1767
+ child.on("error", () => resolve(1));
1768
+ child.on("exit", (code) => resolve(code ?? 1));
1769
+ });
1770
+ const state = async () => {
1771
+ if (latest === undefined) { const v = await newestVersion(); latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
1772
+ let key = null; try { key = keyStore.load(); } catch { key = null; }
1773
+ // `installed` is read again at every ask (0.11.8): the menu's Update item says "up to date" the moment an update ends.
1774
+ return { version: CLI_VERSION, installed: stableVersion(), latest, connected: Boolean(key), account: key?.account ?? null, door: doorOff() ? "off" : "on" };
1775
+ };
1776
+ return (await import("./cli-menu.mjs")).runMenu({ runCli, state });
1777
+ }
1743
1778
  if (await relayToNewest()) return;
1744
1779
 
1745
1780
  if (!["version", "help", "preserve", "project"].includes(command)) {
@@ -1768,7 +1803,7 @@ else if (command === "antigravity") await offerAntigravity();
1768
1803
  else if (command === "disconnect") await disconnect();
1769
1804
  else if (command === "status") await status();
1770
1805
  else if (command === "project") { if (!projectCommand) fail("worktrust project needs the complete WorkTrust package. Nothing was changed."); projectCommand(args.slice(args.indexOf("project") + 1).filter((arg) => !arg.startsWith("--")), { say, fail }); }
1771
- else if (command === "remote") await (await import("./remote-cli.mjs")).remoteCommand(args.slice(args.indexOf("remote") + 1).filter((a, i, all) => !a.startsWith("--") && !(i > 0 && ["--gateway", "--origin"].includes(all[i - 1]))), { say, fail, ask, has, flag, origin: ORIGIN, os: OS, openBrowser, prepare: async () => { await prepareBundledRuntime(); return { node: NODE, nodeArgs: [...NODE_FLAGS, ...NODE_ARGS], entry: STABLE }; } });
1806
+ else if (command === "remote") await (await import("./remote-cli.mjs")).remoteCommand(args.slice(args.indexOf("remote") + 1).filter((a, i, all) => !a.startsWith("--") && !(i > 0 && ["--gateway", "--origin"].includes(all[i - 1]))), { say, fail, ask, has, flag, connected: () => { try { return Boolean(keyStore.load()); } catch { return false; } }, origin: ORIGIN, os: OS, openBrowser, prepare: async () => { await prepareBundledRuntime(); return { node: NODE, nodeArgs: [...NODE_FLAGS, ...NODE_ARGS], entry: STABLE }; } });
1772
1807
  else if (command === "preserve") await preserve();
1773
1808
  else if (command === "mod") await mod();
1774
1809
  else if (command === "git") await gitCommits();