worktrust 0.10.37 → 0.11.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.
Files changed (43) hide show
  1. package/LICENSE +43 -18
  2. package/README.md +59 -2
  3. package/SECURITY.md +25 -0
  4. package/chat-exports.mjs +20 -20
  5. package/engine-release.json +1 -1
  6. package/export-facts.mjs +71 -0
  7. package/log-session.mjs +15 -15
  8. package/package-release.json +1 -1
  9. package/package.json +36 -2
  10. package/remote-adapter-claude-code.mjs +111 -0
  11. package/remote-adapter-codex.mjs +119 -0
  12. package/remote-approval-bridge.mjs +122 -0
  13. package/remote-approvals.mjs +124 -0
  14. package/remote-attachments.mjs +129 -0
  15. package/remote-changes.mjs +94 -0
  16. package/remote-claude-events.mjs +212 -0
  17. package/remote-claude-progress.mjs +328 -0
  18. package/remote-cli.mjs +325 -0
  19. package/remote-coalesce.mjs +40 -0
  20. package/remote-codex-events.mjs +153 -0
  21. package/remote-daemon.mjs +205 -0
  22. package/remote-inventory.mjs +132 -0
  23. package/remote-journal.mjs +155 -0
  24. package/remote-pairing.mjs +104 -0
  25. package/remote-pipeline-config.mjs +177 -0
  26. package/remote-pipeline-parsers.mjs +121 -0
  27. package/remote-pipeline.mjs +234 -0
  28. package/remote-policy.mjs +199 -0
  29. package/remote-preview.mjs +146 -0
  30. package/remote-projects.mjs +87 -0
  31. package/remote-protocol.mjs +3881 -0
  32. package/remote-qr.mjs +175 -0
  33. package/remote-release-plans.mjs +88 -0
  34. package/remote-releases.mjs +297 -0
  35. package/remote-run.mjs +174 -0
  36. package/remote-service.mjs +101 -0
  37. package/remote-session-list.mjs +25 -0
  38. package/remote-sessions.mjs +348 -0
  39. package/remote-steered.mjs +114 -0
  40. package/remote-steering.mjs +97 -0
  41. package/remote-store.mjs +123 -0
  42. package/remote-transport.mjs +88 -0
  43. package/worktrust.mjs +13 -6
@@ -0,0 +1,123 @@
1
+ /**
2
+ * WHERE REMOTE AGENTS KEEP THEIR STATE ON THIS COMPUTER (2026-11-07, docs/remote-agents/PROTOCOL.md).
3
+ *
4
+ * Everything lives in ~/.worktrust/remote/ (a directory of mode 0700, never a symlink), each file 0600, written by
5
+ * temporary file, fsync and rename. Nothing here is the measurement key: the remote device keys are their own pair
6
+ * (Ed25519 to sign, X25519 to agree keys), in their own file, for their own audience. scripts/check-remote-cli.mjs refuses
7
+ * a remote module that names the measurement credentials.
8
+ *
9
+ * remote-keys.json the remote device keys and the secret that derives project ids (never leaves the computer)
10
+ * identity.json this computer's device id and the issuer's binding of its keys
11
+ * settings.json on or off, paused (and by whom), the gateway address, default agent and model, PATH for agents
12
+ * phones.json phones pending a keyboard confirmation, and the confirmed ones with their fingerprints
13
+ * projects.json the folders a phone may steer an agent in, canonical paths
14
+ * channels.json the open end-to-end channels (their keys are secrets)
15
+ * journal.jsonl the command journal (remote-journal.mjs); steered.jsonl the steered ledger (remote-steered.mjs)
16
+ */
17
+ import { createHmac, randomBytes } from "node:crypto";
18
+ import { existsSync, lstatSync, mkdirSync, chmodSync, rmSync } from "node:fs";
19
+ import { homedir } from "node:os";
20
+ import { join } from "node:path";
21
+ import { readPrivateFile, writePrivateFile } from "./package-integrity.mjs";
22
+ import * as P from "./remote-protocol.mjs";
23
+
24
+ export const remoteDir = () => join(homedir(), ".worktrust", "remote");
25
+ export const remotePath = (name) => join(remoteDir(), name);
26
+
27
+ export function ensureRemoteDir() {
28
+ const base = join(homedir(), ".worktrust"), dir = remoteDir();
29
+ for (const path of [base, dir]) {
30
+ if (existsSync(path)) {
31
+ const stat = lstatSync(path);
32
+ if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(`${path} must be a directory, not a link`);
33
+ } else mkdirSync(path, { mode: 0o700 });
34
+ try { chmodSync(path, 0o700); } catch { /* Windows */ }
35
+ }
36
+ return dir;
37
+ }
38
+
39
+ export function readJson(name, fallback = null) {
40
+ const file = remotePath(name);
41
+ if (!existsSync(file)) return fallback;
42
+ try { return JSON.parse(readPrivateFile(file)); } catch { throw new Error(`${file} is unreadable or not private (mode 0600)`); }
43
+ }
44
+
45
+ export function writeJson(name, value) {
46
+ ensureRemoteDir();
47
+ writePrivateFile(remotePath(name), `${JSON.stringify(value, null, 2)}\n`);
48
+ }
49
+
50
+ export const removeFile = (name) => rmSync(remotePath(name), { force: true });
51
+
52
+ /** The remote device keys: a fresh pair, kept in memory until a pairing succeeded (then saveKeys). */
53
+ export function newKeys(random = P.systemRandom) {
54
+ return { ...P.exportSecretKeys(P.generateDeviceKeys(random)), project_secret: P.toBase64Url(random(32)) };
55
+ }
56
+ export const saveKeys = (keys) => writeJson("remote-keys.json", { v: 1, ...keys });
57
+ export function loadKeys() {
58
+ const stored = readJson("remote-keys.json");
59
+ if (!stored) return null;
60
+ const secret = P.importSecretKeys(stored);
61
+ if (!secret || typeof stored.project_secret !== "string") throw new Error("remote-keys.json is malformed");
62
+ return { secret, public: P.publicKeysOf(secret), projectSecret: P.fromBase64Url(stored.project_secret) };
63
+ }
64
+
65
+ export const loadIdentity = () => readJson("identity.json");
66
+ export const saveIdentity = (identity) => writeJson("identity.json", identity);
67
+
68
+ 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 });
69
+ export const loadSettings = () => ({ ...DEFAULT_SETTINGS, ...(readJson("settings.json") ?? {}) });
70
+ export const saveSettings = (settings) => writeJson("settings.json", { ...DEFAULT_SETTINGS, ...settings });
71
+
72
+ export const loadPhones = () => ({ pending: [], confirmed: [], removed: [], ...(readJson("phones.json") ?? {}) });
73
+ export const savePhones = (phones) => writeJson("phones.json", phones);
74
+ export const confirmedFingerprints = (phones = loadPhones()) => new Set(phones.confirmed.map((p) => p.fingerprint));
75
+ /** The signing keys of the confirmed phones, by device id: the only keys whose approval decisions count. */
76
+ export const controllerKeys = (phones = loadPhones()) => Object.fromEntries(phones.confirmed.map((p) => [p.device_id, P.fromBase64Url(p.ed25519_pub)]));
77
+
78
+ export const loadProjects = () => readJson("projects.json", []);
79
+ /** Parent folders where a phone may create a new project (remote-projects.mjs): [{ root_id, path, git_init, added_at }]. */
80
+ export const loadRoots = () => readJson("roots.json", []) ?? [];
81
+ /** What a phone may preview per project, granted at the keyboard (remote-preview.mjs): { [project_id]: { ports, files } }. */
82
+ export const loadPreviewGrants = () => readJson("previews.json", {}) ?? {};
83
+ export const savePreviewGrants = (grants) => writeJson("previews.json", grants);
84
+ export const saveRoots = (roots) => writeJson("roots.json", roots);
85
+ /** The pipeline reviews made at the keyboard: { [project_id]: { sha256, reviewed_at, stages } } (remote-pipeline-config.mjs). */
86
+ export const loadPipelineReviews = () => readJson("pipelines.json", {}) ?? {};
87
+ export const savePipelineReviews = (reviews) => writeJson("pipelines.json", reviews);
88
+ /** Release numbers the person marked released at the desk (`worktrust remote releases released <n>`); the phone cannot. */
89
+ export const loadDeskMarks = () => (readJson("released.json", []) ?? []).filter((n) => Number.isSafeInteger(n) && n > 0);
90
+ export const saveDeskMarks = (numbers) => writeJson("released.json", [...new Set(numbers)].sort((a, b) => a - b));
91
+ export const saveProjects = (projects) => writeJson("projects.json", projects);
92
+ /** A stable opaque id for a folder: an HMAC of its canonical path under a key that never leaves this computer. */
93
+ export const projectIdOf = (projectSecret, canonicalPath) =>
94
+ `prj_${P.toBase64Url(createHmac("sha256", Buffer.from(projectSecret)).update(`worktrust-remote/v1/project\n${canonicalPath}`).digest().subarray(0, 16))}`;
95
+
96
+ export function loadChannels() {
97
+ const stored = readJson("channels.json", []);
98
+ return stored.map((c) => P.importChannel(c)).filter(Boolean);
99
+ }
100
+ export const saveChannels = (channels) => writeJson("channels.json", channels.map((c) => P.exportChannel(c)));
101
+
102
+ /**
103
+ * THE ISSUER KEYS THIS RELEASE TRUSTS. Bindings are verified against keys pinned in the build, never against a key a
104
+ * server hands over. The Passport app's issuer is not live yet, so no key is pinned and `remote enable` refuses plainly.
105
+ * For a gateway on this computer only (scripts/dev-remote-relay.mjs, the tests): WORKTRUST_REMOTE_DEV_ISSUER="<kid>:<base64url key>" is read when
106
+ * the gateway is this computer's own loopback address, and never otherwise (devIssuerAllowed).
107
+ */
108
+ export const PINNED_ISSUER_KEYS = Object.freeze({});
109
+ export const isLoopbackGateway = (url) => {
110
+ try {
111
+ const u = new URL(url);
112
+ return (u.protocol === "ws:" || u.protocol === "wss:") && ["127.0.0.1", "[::1]", "localhost"].includes(u.hostname);
113
+ } catch { return false; }
114
+ };
115
+ export function issuerKeys(gateway) {
116
+ const keys = Object.fromEntries(Object.entries(PINNED_ISSUER_KEYS).map(([kid, key]) => [kid, P.fromBase64Url(key)]));
117
+ const dev = /^([A-Za-z0-9._-]{1,64}):([A-Za-z0-9_-]{43})$/.exec(process.env.WORKTRUST_REMOTE_DEV_ISSUER ?? "");
118
+ if (dev && gateway && isLoopbackGateway(gateway)) keys[dev[1]] = P.fromBase64Url(dev[2]);
119
+ return keys;
120
+ }
121
+
122
+ /** The fresh random bytes the daemon needs (ids, nonces, ephemeral keys). */
123
+ export const random = (length) => new Uint8Array(randomBytes(length));
@@ -0,0 +1,88 @@
1
+ /**
2
+ * THE ONE OUTBOUND CONNECTION (2026-11-07). The daemon holds a single WebSocket to the gateway (wss://, or ws:// on this
3
+ * computer's loopback for the dev relay): no inbound port, nothing listening beyond this user's approval socket. It works
4
+ * from anywhere the computer has a network. A same-Wi-Fi direct path is a later optimisation behind this same interface
5
+ * (connect, send, close, onFrame); it is not built.
6
+ *
7
+ * Frames are JSON text, at most 2 MiB. The gateway opens with { frame: "challenge", nonce }; the daemon answers with its
8
+ * binding and an Ed25519 signature by its REMOTE key over the nonce, its device id and the gateway's origin, under the
9
+ * domain "worktrust-remote/v1/relay-auth" (so a signature made for one gateway opens no other). Heartbeat: a ping every
10
+ * 20 seconds; nothing heard for 45 seconds closes and reconnects. Reconnects back off from 1 to 30 seconds with full
11
+ * jitter, or the gateway's own hint when it said `closing` (a restart, a drain). Close codes 4001 (revoked) and 4003
12
+ * (protocol) stop the reconnects: the person acts at the keyboard. The production gateway also wants a five-minute
13
+ * assertion from the issuer with every answer to a challenge, and challenges again before it ends (`authorize`).
14
+ * Node 22.4 or later has the WebSocket this uses; older Node refuses plainly (`webSocketAvailable`).
15
+ */
16
+ import * as P from "./remote-protocol.mjs";
17
+
18
+ export const MAX_FRAME = 2 * 1024 * 1024;
19
+ const PING_MS = 20_000, SILENCE_MS = 45_000, BASE_MS = 1000, CAP_MS = 30_000;
20
+ export const STOP_CODES = P.GATEWAY_STOP_CODES;
21
+ export const webSocketAvailable = () => typeof globalThis.WebSocket === "function";
22
+ export const backoffMs = (attempt, random = Math.random) => Math.floor(random() * Math.min(CAP_MS, BASE_MS * 2 ** Math.min(attempt, 10)));
23
+
24
+ export const relayAuthBytes = (deviceId, nonce, origin) => P.relayAuthBytes({ device_id: deviceId, nonce, origin });
25
+ export function authFrame({ deviceId, binding, signingSecret, nonce, origin, assertion = null }) {
26
+ return { frame: "auth", device_id: deviceId, binding, nonce, signature: P.toBase64Url(P.ed25519Sign(relayAuthBytes(deviceId, nonce, origin), signingSecret)), ...(assertion ? { assertion } : {}) };
27
+ }
28
+
29
+ export function connectGateway({ url, identity, signingSecret, onFrame, onState = () => {}, log = () => {}, authorize = async () => null, WebSocketImpl = globalThis.WebSocket }) {
30
+ const origin = new URL(url).origin.replace(/^http/, "ws");
31
+ let socket = null, attempt = 0, stopped = false, ready = false, lastHeard = 0, ping = null, retry = null, hint = null;
32
+ const send = (frame) => {
33
+ if (!ready || socket?.readyState !== 1) return false;
34
+ const text = JSON.stringify(frame);
35
+ if (text.length > MAX_FRAME) { log("frame_too_large", { frame: frame.frame }); return false; }
36
+ socket.send(text);
37
+ return true;
38
+ };
39
+ const schedule = () => {
40
+ if (stopped) return;
41
+ const wait = hint !== null ? hint + backoffMs(0) : backoffMs(attempt++);
42
+ hint = null;
43
+ onState("waiting", { wait });
44
+ retry = setTimeout(open, wait);
45
+ };
46
+ function open() {
47
+ if (stopped) return;
48
+ ready = false;
49
+ try { socket = new WebSocketImpl(url); } catch { schedule(); return; }
50
+ socket.onopen = () => { lastHeard = Date.now(); onState("open"); };
51
+ socket.onmessage = (event) => {
52
+ lastHeard = Date.now();
53
+ const text = typeof event.data === "string" ? event.data : "";
54
+ if (text.length > MAX_FRAME) { socket.close(4003, "too large"); return; }
55
+ let frame = null;
56
+ try { frame = JSON.parse(text); } catch { frame = null; }
57
+ if (!frame || typeof frame.frame !== "string") return;
58
+ if (frame.frame === "challenge" && typeof frame.nonce === "string") {
59
+ const asked = socket;
60
+ authorize().catch(() => null).then((assertion) => {
61
+ if (asked !== socket || asked.readyState !== 1) return;
62
+ asked.send(JSON.stringify(authFrame({ deviceId: identity.device_id, binding: identity.binding, signingSecret, nonce: frame.nonce, origin, assertion })));
63
+ });
64
+ return;
65
+ }
66
+ if (frame.frame === "closing" && Number.isSafeInteger(frame.retry_after_ms)) { hint = Math.min(frame.retry_after_ms, 3_600_000); return; }
67
+ if (frame.frame === "ready") { ready = true; attempt = 0; onState("ready"); }
68
+ if (frame.frame === "pong") return;
69
+ onFrame(frame);
70
+ };
71
+ socket.onclose = (event) => {
72
+ ready = false;
73
+ clearInterval(ping);
74
+ onState("closed", { code: event?.code ?? null });
75
+ if (STOP_CODES.has(event?.code)) { stopped = true; onState("stopped", { code: event.code }); return; }
76
+ schedule();
77
+ };
78
+ socket.onerror = () => {};
79
+ clearInterval(ping);
80
+ ping = setInterval(() => {
81
+ if (Date.now() - lastHeard > SILENCE_MS) { try { socket.close(); } catch { /* closed */ } return; }
82
+ if (socket.readyState === 1) socket.send(JSON.stringify({ frame: "ping" }));
83
+ }, PING_MS);
84
+ ping.unref?.();
85
+ }
86
+ open();
87
+ return { send, ready: () => ready, close() { stopped = true; clearTimeout(retry); clearInterval(ping); try { socket?.close(1000, "bye"); } catch { /* closed */ } } };
88
+ }
package/worktrust.mjs CHANGED
@@ -26,6 +26,8 @@
26
26
  * command on a coupled computer offers an export lying in ~/Downloads once.
27
27
  * npx worktrust disconnect show what comes out, ask, take it out again
28
28
  * npx worktrust status what is coupled here
29
+ * npx worktrust remote enable|pair|status|pause|resume|disable|phones|projects|run steer this computer's agents
30
+ * from your phone (remote-cli.mjs; opt-in, its own key, never the measurement key)
29
31
  * npx worktrust@latest preserve how long each AI app here keeps its sessions (--apply keeps them,
30
32
  * --archive [dir] a local metadata-only record, --verify [dir] checks it,
31
33
  * --summary [dir] counts hours, tokens and parallel sessions from it);
@@ -71,12 +73,12 @@ import { fileURLToPath, pathToFileURL } from "node:url";
71
73
  const { moduleArgs, moduleExecutable, readPrivateFile, writePrivateFile } = await import("./package-integrity.mjs").catch(() => ({}));
72
74
 
73
75
  const args = process.argv.slice(2);
74
- const VALUED = ["--name", "--origin", "--url", "--export", "--from-folder"];
76
+ const VALUED = ["--name", "--origin", "--url", "--export", "--from-folder", "--gateway"];
75
77
  const command = args.includes("--help") ? "help" : args.includes("--version") ? "version" : args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALUED.includes(args[at - 1]))) ?? "default";
76
78
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
77
79
  const has = (name) => args.includes(`--${name}`);
78
80
  /** 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). */
79
- const CLI_VERSION = "0.10.37";
81
+ const CLI_VERSION = "0.11.0";
80
82
  /**
81
83
  * 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
82
84
  * to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
@@ -108,9 +110,9 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
108
110
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
109
111
  const HOME_DIR = join(homedir(), ".worktrust");
110
112
  const HERE = dirname(fileURLToPath(import.meta.url));
111
- const SCRIPTS = ["credential-store.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", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.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", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
113
+ 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-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-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.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", "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", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
112
114
  /** The modules the scripts import by name from beside them; a download keeps that name. */
113
- const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
115
+ const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.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"]);
114
116
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
115
117
  const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
116
118
  const PLACEHOLDER = `wt_${"0".repeat(43)}`;
@@ -183,7 +185,7 @@ function run(path, scriptArgs, token, collect = false, extraEnv = {}, watch = nu
183
185
  });
184
186
  child.stderr?.on("data", (chunk) => { if (watch) said += chunk; else out += chunk; });
185
187
  // Watched, the answer waits for the streams to close, so the last event is heard before the command speaks.
186
- child.on(watch ? "close" : "exit", (code) => { if (watch) { process.off("SIGINT", stop); process.off("SIGTERM", stop); if (pending) heard(pending); pending = ""; } resolve({ code: code ?? 1, out: said + out, stopped: stops > 0 }); });
188
+ child.on(watch ? "close" : "exit", (code) => { if (watch) { process.off("SIGINT", stop); process.off("SIGTERM", stop); if (stops > 0) { const late = () => process.exit(130); /* stopped: a later Ctrl+C exits 130, never by the signal (2026-11-06) */ process.on("SIGINT", late); process.on("SIGTERM", late); } if (pending) heard(pending); pending = ""; } resolve({ code: code ?? 1, out: said + out, stopped: stops > 0 }); });
187
189
  });
188
190
  }
189
191
  /**
@@ -1654,6 +1656,8 @@ function help() {
1654
1656
  say(" days this computer's own sessions lack, reconstructed, never verified hours (asks first)");
1655
1657
  say(" worktrust disconnect take WorkTrust out of every AI app here (asks first)");
1656
1658
  say(" worktrust status what is coupled here");
1659
+ say(" worktrust remote steer this computer's agents from your phone: enable, pair (a QR), status, pause, resume,");
1660
+ say(" disable, phones, projects, run. Opt-in, its own key, never counted as your AI Hours");
1657
1661
  say(" worktrust mcp off hours only: the WorkTrust door out of every AI app here, nothing of it in your sessions;");
1658
1662
  say(" the session hook keeps measuring your hours, and update leaves the door out");
1659
1663
  say(" worktrust mcp on the door back in, so your AI can log finished work (about 40 tokens per session)");
@@ -1688,7 +1692,9 @@ const PERSON_ONLY = new Set(["default", "connect", "update", "history", "disconn
1688
1692
  const agentShell = AGENT_ENV.find((name) => process.env[name] && process.env[name] !== "0");
1689
1693
  // `mcp off` and `mcp on` change what this computer's AI apps load: the person's. Bare `mcp` stays the bridge the apps start.
1690
1694
  const doorSwitch = command === "mcp" && ["off", "on"].includes(args[args.indexOf("mcp") + 1]);
1691
- if (agentShell && (PERSON_ONLY.has(command) || doorSwitch)) {
1695
+ // Remote control (2026-11-07) is the person's act at the keyboard: an agent cannot enable, pair, extend or run its own leash; `remote status` only reads.
1696
+ const remoteAct = command === "remote" && args[args.indexOf("remote") + 1] !== "status";
1697
+ if (agentShell && (PERSON_ONLY.has(command) || doorSwitch || remoteAct)) {
1692
1698
  say();
1693
1699
  say(` worktrust${command === "default" ? "" : ` ${command}`} is run by the person, in their own terminal, never by an AI agent for them (this shell is an agent's: ${agentShell}).`);
1694
1700
  say(" Nothing was read, sent or changed. See AGENTS.md in the package: https://www.npmjs.com/package/worktrust");
@@ -1743,6 +1749,7 @@ else if (command === "codex") await offerCodex();
1743
1749
  else if (command === "antigravity") await offerAntigravity();
1744
1750
  else if (command === "disconnect") await disconnect();
1745
1751
  else if (command === "status") await status();
1752
+ 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 }; } });
1746
1753
  else if (command === "preserve") await preserve();
1747
1754
  else if (command === "mod") await mod();
1748
1755
  else if (command === "git") await gitCommits();