worktrust 0.11.8 → 0.11.10

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.
@@ -3,25 +3,31 @@
3
3
  * preservation choices. Each item still runs one direct command (runShown), named in its muted line; this file only reads
4
4
  * the remote settings to label the items and never writes one itself: a change goes through the command, so it goes
5
5
  * through applySettingsChange (remote-settings.mjs) like a typed one. Folders are chosen without typing (folder-picker.mjs).
6
+ *
7
+ * 0.11.9 (owner, 2026-11-14): every sentence fits the one-row form (60 characters at most), and Remote Agent asks for the
8
+ * approval FIRST: what cannot work before it cannot be chosen (remoteItems).
6
9
  */
7
10
  import { homedir } from "node:os";
8
11
  import { join } from "node:path";
9
- import { choose, runShown, typed } from "./cli-menu.mjs";
12
+ import { choose, muted, remoteState, runShown, typed } from "./cli-menu.mjs";
10
13
  import { makeProjectsFolder, pickFolder, pickerCommand, suggestedFolders } from "./folder-picker.mjs";
11
14
  import { connections } from "./remote-connections.mjs";
12
15
  import { loadIdentity, loadProjects, loadRoots, loadSettings } from "./remote-store.mjs";
13
16
  import { allowedModes } from "./remote-settings.mjs";
14
17
 
15
- const BACK = { label: "← Back", hint: "Esc", info: "Returns to the list before this one.", back: true };
18
+ const BACK = { label: "← Back", hint: "Esc", back: true }; // its name and its key say it: no sentence of its own (owner, 2026-11-14)
16
19
  const tilde = (path) => (path.startsWith(homedir()) ? `~${path.slice(homedir().length)}` : path);
17
20
 
18
21
  /** Loop one level: each pick runs, Back or Esc returns; a pick that returns false ends the menu (Ctrl+C after a command). */
19
- async function level(term, header, title, build) {
22
+ async function level(term, header, title, build, io = null) {
20
23
  for (;;) {
21
- const picked = await choose(term, { header, title, items: build() });
24
+ const picked = await choose(term, { header, title: typeof title === "function" ? title() : title, items: build() });
22
25
  if (picked === "quit") return false;
23
26
  if (picked === "back" || picked.item.back) return true;
24
- if (picked.item.run && (await picked.item.run()) === false) return false;
27
+ const result = picked.item.run ? await picked.item.run() : true;
28
+ await io?.state?.(); // the head above reads this computer again: what the command changed shows at once
29
+ if (result === false) return false;
30
+ if (result === "back") return true; // the step this level was for is done (0.11.9: approved): the level above draws again
25
31
  }
26
32
  }
27
33
 
@@ -38,8 +44,8 @@ async function addRoots(term, io, header) {
38
44
  const offered = suggestedFolders().filter((f) => !have.has(f.path));
39
45
  const items = [
40
46
  ...offered.map((f) => ({ label: tilde(f.path), note: { text: `${f.projects} project${f.projects === 1 ? "" : "s"} found`, tone: "dim" }, info: "Space ticks it; Enter adds the ticked folders as roots.", tick: true, path: f.path })),
41
- { label: "+ Make a new folder for my projects", make: true, hint: "npx worktrust remote roots add <folder> --git-init", info: "Asks for a name (Projects by default), makes the folder in your home folder and adds it; new projects in it get git init." },
42
- { label: "Choose another folder…", pick: true, hint: "npx worktrust remote roots add <folder>", info: "Opens the system's folder picker and adds the folder you choose." },
47
+ { label: "+ Make a new folder for my projects", make: true, hint: "npx worktrust remote roots add <folder> --git-init", info: "Makes a folder in your home folder and adds it as a root." },
48
+ { label: "Choose another folder…", pick: true, hint: "npx worktrust remote roots add <folder>", info: "Opens the folder picker and adds the folder you choose." },
43
49
  BACK,
44
50
  ];
45
51
  const picked = await choose(term, { header, title: "Add folders where your projects live", items, multi: true });
@@ -58,16 +64,16 @@ async function addRoots(term, io, header) {
58
64
 
59
65
  function rootsMenu(term, io, header) {
60
66
  return level(term, header, "Roots for new projects", () => [
61
- { label: "+ Add folders", hint: "npx worktrust remote roots add <folder>", info: "Opens a list of folders to tick. A phone may open the projects in a root and create new ones there.", run: () => addRoots(term, io, header) },
62
- ...loadRoots().map((r) => ({ label: `Remove ${tilde(r.path)}`, hint: `npx worktrust remote roots remove ${tilde(r.path)}`, info: "Takes this folder off the list; a phone can no longer open or create projects in it. No file is touched.", run: () => runShown(term, io, ["remote", "roots", "remove", r.path]) })),
67
+ { label: "+ Add folders", hint: "npx worktrust remote roots add <folder>", info: "Choose folders whose projects a phone may open or add to.", run: () => addRoots(term, io, header) },
68
+ ...loadRoots().map((r) => ({ label: `Remove ${tilde(r.path)}`, hint: `npx worktrust remote roots remove ${tilde(r.path)}`, info: "A phone can no longer use this folder. No file is touched.", run: () => runShown(term, io, ["remote", "roots", "remove", r.path]) })),
63
69
  BACK,
64
70
  ]);
65
71
  }
66
72
 
67
73
  function projectsMenu(term, io, header) {
68
74
  return level(term, header, "Projects a phone may steer an agent in", () => [
69
- { label: "+ Add a project folder…", hint: "npx worktrust remote projects add <folder>", info: "Opens the system's folder picker; a phone may then steer an agent in the folder you choose.", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["remote", "projects", "add", path]) : true; } },
70
- ...loadProjects().map((p) => ({ label: `Remove ${tilde(p.path)}`, hint: `npx worktrust remote projects remove ${tilde(p.path)}`, info: "Takes this folder off the list; a phone can no longer start an agent in it. No file is touched.", run: () => runShown(term, io, ["remote", "projects", "remove", p.path]) })),
75
+ { label: "+ Add a project folder…", hint: "npx worktrust remote projects add <folder>", info: "Pick a folder a phone may steer an agent in.", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["remote", "projects", "add", path]) : true; } },
76
+ ...loadProjects().map((p) => ({ label: `Remove ${tilde(p.path)}`, hint: `npx worktrust remote projects remove ${tilde(p.path)}`, info: "A phone can no longer start an agent here. No file changes.", run: () => runShown(term, io, ["remote", "projects", "remove", p.path]) })),
71
77
  BACK,
72
78
  ]);
73
79
  }
@@ -75,74 +81,168 @@ function projectsMenu(term, io, header) {
75
81
  function modesMenu(term, io, header) {
76
82
  return level(term, header, "Agent modes a phone may start here", () => {
77
83
  const allowed = allowedModes(loadSettings());
78
- const toggle = (mode, words) => ({ label: `${words}: ${allowed.includes(mode) ? "allowed" : "not allowed"}`, hint: `npx worktrust remote modes ${allowed.includes(mode) ? "deny" : "allow"} ${mode}`, info: allowed.includes(mode) ? `Stops a phone from starting an agent in this mode${mode === "edit" ? "; auto goes with it" : ""}.` : `Lets a phone start an agent in this mode${mode === "auto" ? "; allowing auto allows edit too" : ""}.`,
84
+ const toggle = (mode, words) => ({ label: `${words}: ${allowed.includes(mode) ? "allowed" : "not allowed"}`, hint: `npx worktrust remote modes ${allowed.includes(mode) ? "deny" : "allow"} ${mode}`, info: allowed.includes(mode) ? `Stops a phone from starting this mode${mode === "edit" ? "; auto goes too" : ""}.` : `Lets a phone start this mode${mode === "auto" ? "; that allows edit too" : ""}.`,
79
85
  run: () => runShown(term, io, ["remote", "modes", allowed.includes(mode) ? "deny" : "allow", mode]) });
80
86
  return [
81
- { label: "Manual (asks for every change): always allowed", info: "Always there: the agent asks you before every change.", disabled: true },
82
- { label: "Plan (read-only): always allowed", info: "Always there: the agent reads and plans, and changes nothing.", disabled: true },
87
+ { label: "Manual: always allowed", info: "Always there: the agent asks before every change.", disabled: true },
88
+ { label: "Plan: always allowed", info: "Always there: the agent reads and plans, changes nothing.", disabled: true },
83
89
  toggle("edit", "Edit automatically"),
84
- toggle("auto", "Auto (the agent's own automatic mode)"),
85
- { label: "Status", hint: "npx worktrust remote modes status", info: "Shows which modes a phone may start here. It only reads.", run: () => runShown(term, io, ["remote", "modes", "status"]) },
90
+ toggle("auto", "Auto mode"),
91
+ { label: "Status", hint: "npx worktrust remote modes status", info: "Shows which modes a phone may start. It only reads.", run: () => runShown(term, io, ["remote", "modes", "status"]) },
86
92
  BACK,
87
93
  ];
88
94
  });
89
95
  }
90
96
 
97
+ /**
98
+ * THE LINKED DEVICES, AS A TABLE (0.11.9, owner 2026-11-14): one row per connection: name, kind, since, last activity. Enter
99
+ * opens that connection's acts. Disconnect runs the same `remote disconnect <fingerprint>` a person types, with its typed
100
+ * confirmation (remote-connections.mjs, a security decision of 2026-11-12): the menu confirms nothing itself and fills nothing in.
101
+ */
102
+ const day = (ms) => (Number.isFinite(ms) ? new Date(ms).toISOString().slice(0, 10) : "not known");
91
103
  function connectionsMenu(term, io, header) {
92
104
  return level(term, header, "Connections to this computer", () => {
93
- const list = connections();
105
+ const list = connections(), wide = Math.min(20, Math.max(4, ...list.map((c) => c.name.length))), last = term.size().columns >= 72; // a narrow terminal keeps name, kind and since
106
+ if (list.length === 0) return [
107
+ { label: "No phone or browser is linked yet.", info: "Link one with the row below.", disabled: true, quiet: "Nothing to open here." },
108
+ { label: "Link a phone (QR here)", hint: "npx worktrust remote pair", info: "Shows a QR that links a phone to this computer.", run: () => runShown(term, io, ["remote", "pair"]) },
109
+ BACK,
110
+ ];
111
+ const acts = (c) => () => level(term, header, `${c.name} · ${c.kind} · ${c.fingerprint}`, () => [
112
+ ...(c.state === "pending" ? [{ label: "Confirm it", hint: `npx worktrust remote phones confirm ${c.fingerprint}`, info: "Confirms this link. Check the fingerprint on the device.", run: async () => ((await runShown(term, io, ["remote", "phones", "confirm", c.fingerprint])) === false ? false : "back") }] : []),
113
+ { label: "Disconnect", hint: `npx worktrust remote disconnect ${c.fingerprint}`, info: "Closes it. You type its name or code to confirm.", run: async () => ((await runShown(term, io, ["remote", "disconnect", c.fingerprint])) === false ? false : "back") },
114
+ BACK,
115
+ ], io);
94
116
  return [
95
- { label: "List them", hint: "npx worktrust remote connections", info: "Shows every phone and browser linked to this computer. It only reads.", run: () => runShown(term, io, ["remote", "connections"]) },
96
- ...list.filter((c) => c.state === "pending").map((c) => ({ label: `Confirm ${c.name} (pending)`, hint: `npx worktrust remote phones confirm ${c.fingerprint}`, info: "Confirms this pending link, so it may steer agents here. Check the fingerprint on the device first.", run: () => runShown(term, io, ["remote", "phones", "confirm", c.fingerprint]) })),
97
- ...list.map((c) => ({ label: `${c.name} · ${c.kind} · ${c.fingerprint}`, hint: `npx worktrust remote disconnect ${c.n}`, info: "Closes this connection; that device has to be linked again to come back. It asks twice.", run: () => runShown(term, io, ["remote", "disconnect", c.fingerprint]) })),
98
- ...(list.length > 0 ? [{ label: "Close all connections", hint: "npx worktrust remote disconnect --all", info: "Closes every connection to this computer. You type close all to confirm.", run: () => runShown(term, io, ["remote", "disconnect", "--all"]) }] : []),
117
+ ...list.map((c) => ({ label: `${c.name.length > wide ? `${c.name.slice(0, wide - 1)}…` : c.name.padEnd(wide)} ${c.kind.padEnd(7)} since ${day(c.since)}${last ? ` last ${day(c.last_seen)}` : ""}${c.state === "pending" ? " pending" : ""}`, hint: `npx worktrust remote disconnect ${c.n}`, info: `Enter opens ${c.name} · ${c.fingerprint}.`, run: acts(c) })),
118
+ { label: "Disconnect all…", hint: "npx worktrust remote disconnect --all", info: "Closes every connection. You type close all to confirm.", run: () => runShown(term, io, ["remote", "disconnect", "--all"]) },
99
119
  BACK,
100
120
  ];
101
- });
121
+ }, io);
122
+ }
123
+
124
+ /**
125
+ * SHARING (0.11.9, owner 2026-11-14): what this computer sends, in words, and the switches that exist. Each switch runs the
126
+ * command a person types (`mcp off | on`, `remote pause | resume`); the session hook has no switch in the CLI (measuring is
127
+ * paused in WorkTrust under Sources, and `disconnect` takes it out), so its row says so and cannot be chosen. One app alone
128
+ * cannot be coupled or uncoupled by a command today, so there is no row per app. The state is read again at every draw.
129
+ */
130
+ export function sharingItems(state, remote, act = {}) {
131
+ const doorOn = state.door === "on", live = ["approved", "paused"].includes(remote.word), paused = remote.word === "paused";
132
+ return [
133
+ { label: `Session hook: ${state.hook === true ? "on" : state.hook === false ? "not installed" : "not known"}`, note: { text: "no switch here", tone: "dim" }, info: "Sends times, tokens, models and tools. Never content.", disabled: true, quiet: "Pause it under Sources." },
134
+ state.door === "on" || state.door === "off"
135
+ ? { label: `WorkTrust in your AI apps: ${doorOn ? `on${Number.isInteger(state.apps) ? ` (${state.apps} app${state.apps === 1 ? "" : "s"})` : ""}` : "off"}`, hint: `npx worktrust mcp ${doorOn ? "off" : "on"}`, info: doorOn ? "On: your AI logs finished work. Enter takes the door out." : "Off: hours only. Enter puts the door back in your AI apps.", run: () => act.door?.(doorOn ? "off" : "on") }
136
+ : { label: "WorkTrust in your AI apps: not known", hint: "npx worktrust mcp status", info: "Its state could not be read. Enter shows it.", run: () => act.door?.("status") },
137
+ live
138
+ ? { label: `Remote Agent: ${paused ? "paused" : "on"}`, hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, info: paused ? "Paused: no phone steers agents here. Enter resumes." : "On: linked phones steer agents here. Enter pauses.", run: () => act.remote?.(paused ? "resume" : "pause") }
139
+ : { label: `Remote Agent: ${remote.word}`, hint: "npx worktrust remote …", info: "Lets your phone steer this computer's agents.", disabled: true, quiet: remote.word === "not known" ? "Its state could not be read." : "Set it up under Remote Agent." },
140
+ BACK,
141
+ ];
142
+ }
143
+ export async function sharingMenu(term, io, header) {
144
+ for (;;) {
145
+ const state = await io.state();
146
+ const picked = await choose(term, { header, title: "Sharing", items: sharingItems(state, remoteState(), { door: (to) => runShown(term, io, ["mcp", to]), remote: (to) => runShown(term, io, ["remote", to]) }) });
147
+ if (picked === "quit") return false;
148
+ if (picked === "back" || picked.item.back) return true;
149
+ if ((await picked.item.run()) === false) return false;
150
+ }
151
+ }
152
+
153
+ /**
154
+ * WHETHER THIS COMPUTER IS APPROVED FOR REMOTE AGENT, in three states (0.11.9): true (its identity is here), false (none),
155
+ * null when the file could not be read (remote-store readJson refuses an unreadable or non-private one): not known is
156
+ * never "not approved".
157
+ */
158
+ export function approval() { try { return Boolean(loadIdentity()); } catch { return null; } }
159
+
160
+ /**
161
+ * Remote Agent's rows (owner, 2026-11-14: "first the approve, and once that succeeded you go on to the other steps"). Pure:
162
+ * `approved` is approval()'s answer, `act` what each row does. NOT APPROVED: the approval is first and chosen, and what
163
+ * cannot work before it cannot be chosen. By the code: `remote pair` and adding a project or a root refuse without this
164
+ * computer's remote keys (remote-cli.mjs needPaired, remote-settings.mjs applyRules), and no phone can be linked, so there
165
+ * is no connection to list and nothing to pause. Allowed modes is a local setting and Status only reads: both stay.
166
+ * APPROVED: Link a phone first, and approving again stays (new keys). NOT KNOWN: every row can be chosen and the title says so.
167
+ *
168
+ * PART OF PREMIUM (owner, 2026-11-14; docs/remote-agents/ISSUER.md §12): when WorkTrust itself answered `premium_required`
169
+ * (`access`, from api/cli/door: the switch on and the account Free), the first row is "Upgrade to Premium ›" and every other
170
+ * row stays visible and cannot be chosen (the one disabled-row mechanism). Any other answer, or none, is the list as above.
171
+ */
172
+ export function remoteItems(approved, paused, act = {}, access = null) {
173
+ if (access === "premium_required") return [
174
+ { label: "Upgrade to Premium ›", hint: act.upgradeHint ?? undefined, info: "Remote Agent is part of Premium. Opens the upgrade page.", run: act.upgrade },
175
+ ...remoteItems(approved, paused).filter((item) => !item.back).map((item) => ({ label: item.label, hint: item.hint, info: item.info, disabled: true, quiet: "Part of Premium: upgrade first.", note: { text: "Premium", tone: "dim" } })),
176
+ BACK,
177
+ ];
178
+ const wait = approved === false ? { disabled: true, quiet: "Approve this computer first.", note: { text: "not yet", tone: "dim" } } : {};
179
+ const approve = { label: approved ? "Approved ✓ · approve again ›" : "Approve this computer ›", hint: approved ? "npx worktrust remote app --repair" : "npx worktrust remote app | web", info: approved ? "Approve again: new keys, and linked phones link again." : "Needed once: your account allows steering this computer.", run: act.approve };
180
+ const link = { label: "Link a phone (QR here)", hint: "npx worktrust remote pair", info: "Shows a QR that links a phone to this computer.", run: act.link, ...wait };
181
+ return [
182
+ ...(approved ? [link, approve] : [approve, link]),
183
+ { label: "Projects ›", hint: "npx worktrust remote projects", info: "Folders a phone may steer an agent in.", run: act.projects, ...wait },
184
+ { label: "Roots for new projects ›", hint: "npx worktrust remote roots", info: "Where a phone may open and create projects.", run: act.roots, ...wait },
185
+ { label: "Allowed modes ›", hint: "npx worktrust remote modes", info: "Agent modes a phone may start. This computer is the limit.", run: act.modes },
186
+ { label: "Connections ›", hint: "npx worktrust remote connections", info: "Phones and browsers linked here.", run: act.connections, ...wait },
187
+ { label: paused ? "Resume" : "Pause", hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, info: paused ? "Lets linked phones steer agents here again." : "Stops every phone until you resume. Links stay.", run: act.pause, ...wait },
188
+ { label: "Status", hint: "npx worktrust remote status", info: "Shows if Remote Agent is on and what is linked. Only reads.", run: act.status },
189
+ BACK,
190
+ ];
191
+ }
192
+
193
+ /**
194
+ * "Upgrade to Premium ›" (owner, 2026-11-14): the address WorkTrust answered, opened in the browser AND printed, for a
195
+ * terminal without one (SSH). No address: where to find it in words. The account is asked again at the next read.
196
+ */
197
+ export async function showUpgrade(term, io, url) {
198
+ term.write(url ? `\n Upgrade to Premium: ${url}\n It opens in your browser; on another device, open the address above.\n` : "\n Upgrade to Premium in WorkTrust: Settings › Plan & billing.\n");
199
+ if (url) io.openUrl?.(url);
200
+ term.write(` ${muted("Press any key for the menu.")}\n`);
201
+ const k = await term.anyKey();
202
+ return !(k.ctrl && k.name === "c");
102
203
  }
103
204
 
104
- /** Remote Agent ›. Approved already: "Link a phone" comes first and approving reads "approve again". */
105
- export function remoteMenu(term, io, header) {
106
- return level(term, header, "Remote Agent", () => {
107
- const approved = Boolean(loadIdentity()), settings = loadSettings();
108
- const approveMenu = { label: approved ? "Approved ✓ · approve again ›" : "Approve this computer ›", hint: approved ? "npx worktrust remote app --repair" : "npx worktrust remote app | web", info: approved ? "Opens the two ways to approve this computer again; that gives it new keys, and linked phones link again." : "Opens the two ways to approve this computer for Remote Agent. Nothing changes yet.",
109
- run: () => level(term, header, approved ? "Approve this computer again (new keys)" : "Approve this computer", () => [
110
- { label: "With the WorkTrust app", hint: `npx worktrust remote app${approved ? " --repair" : ""}`, info: "Shows a QR here; you scan it with the WorkTrust app and approve this computer on your phone.", run: () => runShown(term, io, ["remote", "app", ...(approved ? ["--repair"] : [])]) },
111
- { label: "In the browser", hint: `npx worktrust remote web${approved ? " --repair" : ""}`, info: "Opens WorkTrust in your browser, where you approve this computer.", run: () => runShown(term, io, ["remote", "web", ...(approved ? ["--repair"] : [])]) },
205
+ /** Remote Agent ›. The rows are read again after every command, so an approval made here opens the other steps at once. */
206
+ export async function remoteMenu(term, io, header) {
207
+ let state = (await io.state?.()) ?? null; // the account's answer (plan, remoteAccess, upgrade), read again after every command below
208
+ const reading = { ...io, state: async () => (state = (await io.state?.()) ?? null) };
209
+ const title = () => (state?.remoteAccess === "premium_required" ? "Remote Agent · part of Premium" : approval() === null ? "Remote Agent · its state could not be read" : "Remote Agent");
210
+ return level(term, header, title, () => {
211
+ const approved = approval(), paused = (() => { try { return loadSettings().paused !== null; } catch { return false; } })();
212
+ // The two roads; one that leaves this computer approved returns to the list above, which now opens on Link a phone.
213
+ const road = (which) => async () => ((await runShown(term, io, ["remote", which, ...(approved ? ["--repair"] : [])])) === false ? false : approved === false && approval() === true ? "back" : true);
214
+ return remoteItems(approved, paused, {
215
+ approve: () => level(term, header, approved ? "Approve this computer again (new keys)" : "Approve this computer", () => [
216
+ { label: "With the WorkTrust app", hint: `npx worktrust remote app${approved ? " --repair" : ""}`, info: "One QR: the app approves and links this phone.", run: road("app") },
217
+ { label: "In the browser", hint: `npx worktrust remote web${approved ? " --repair" : ""}`, info: "Opens WorkTrust in your browser, where you approve.", run: road("web") },
112
218
  BACK,
113
- ]) };
114
- const link = { label: "Link a phone (QR here)", hint: "npx worktrust remote pair", info: "Shows a QR here; scanning it with the WorkTrust app links that phone to this computer.", run: () => runShown(term, io, ["remote", "pair"]) };
115
- const paused = settings.paused !== null;
116
- return [
117
- ...(approved ? [link, approveMenu] : [approveMenu, link]),
118
- { label: "Projects ›", hint: "npx worktrust remote projects", info: "Opens the folders a phone may steer an agent in, to add or remove one.", run: () => projectsMenu(term, io, header) },
119
- { label: "Roots for new projects ›", hint: "npx worktrust remote roots", info: "Opens the folders whose projects a phone may open, and where it may create new ones.", run: () => rootsMenu(term, io, header) },
120
- { label: "Allowed modes ›", hint: "npx worktrust remote modes", info: "Opens the agent modes a phone may start here: this computer is the ceiling.", run: () => modesMenu(term, io, header) },
121
- { label: "Connections ›", hint: "npx worktrust remote connections", info: "Opens the phones and browsers linked here, to confirm or close one.", run: () => connectionsMenu(term, io, header) },
122
- { label: paused ? "Resume" : "Pause", hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, info: paused ? "Lets linked phones steer agents here again." : "Stops every phone from steering agents here until you resume; links and settings stay.", run: () => runShown(term, io, ["remote", paused ? "resume" : "pause"]) },
123
- { label: "Status", hint: "npx worktrust remote status", info: "Shows whether Remote Agent is on, its service and what is linked. It only reads.", run: () => runShown(term, io, ["remote", "status"]) },
124
- BACK,
125
- ];
126
- });
219
+ ], io),
220
+ link: () => runShown(term, io, ["remote", "pair"]),
221
+ projects: () => projectsMenu(term, io, header), roots: () => rootsMenu(term, io, header), modes: () => modesMenu(term, io, header), connections: () => connectionsMenu(term, io, header),
222
+ pause: () => runShown(term, io, ["remote", paused ? "resume" : "pause"]),
223
+ status: () => runShown(term, io, ["remote", "status"]),
224
+ upgrade: () => showUpgrade(term, io, state?.upgrade ?? null), upgradeHint: state?.upgrade ? String(state.upgrade).replace(/^https?:\/\//, "") : undefined,
225
+ }, state?.remoteAccess ?? null);
226
+ }, reading);
127
227
  }
128
228
 
129
229
  export function historyMenu(term, io, header) {
130
230
  return level(term, header, "Import earlier history", () => [
131
- { label: "This computer's earlier sessions", hint: "npx worktrust history", info: "Sends the sessions your AI apps still hold here as history. It shows the plan and asks first.", run: () => runShown(term, io, ["history"]) },
132
- { label: "From your local archive", hint: "npx worktrust history --from-archive", info: "Sends what your local archive holds of sessions your AI apps already deleted. It shows the plan and asks first.", run: () => runShown(term, io, ["history", "--from-archive"]) },
133
- { label: "From a ChatGPT or Claude export…", hint: "npx worktrust history --export <path>", info: "Asks for the export's path, then shows the plan and asks. These hours are reconstructed, never verified hours.", run: async () => { const path = await typed(term, "The export's path (the zip, its folder or conversations.json):", join(homedir(), "Downloads")); term.enter(); return path ? runShown(term, io, ["history", "--export", path]) : true; } },
134
- { label: "From a copied session folder…", hint: "npx worktrust history --from-folder <dir>", info: "Opens the folder picker for your own copy of a session folder, then shows the plan and asks. Reconstructed hours.", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["history", "--from-folder", path]) : true; } },
231
+ { label: "Sessions on this computer", hint: "npx worktrust history", info: "Sessions your AI apps still hold. Shows a plan, asks first.", run: () => runShown(term, io, ["history"]) },
232
+ { label: "Your local archive", hint: "npx worktrust history --from-archive", info: "Sessions your apps deleted, from your archive. Asks first.", run: () => runShown(term, io, ["history", "--from-archive"]) },
233
+ { label: "A ChatGPT or Claude export…", hint: "npx worktrust history --export <path>", info: "Asks for its path. Reconstructed hours, never verified.", run: async () => { const path = await typed(term, "The export's path (the zip, its folder or conversations.json):", join(homedir(), "Downloads")); term.enter(); return path ? runShown(term, io, ["history", "--export", path]) : true; } },
234
+ { label: "A copied session folder…", hint: "npx worktrust history --from-folder <dir>", info: "Your copy of a session folder. Reconstructed, not verified.", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["history", "--from-folder", path]) : true; } },
135
235
  BACK,
136
236
  ]);
137
237
  }
138
238
 
139
239
  export function preserveMenu(term, io, header) {
140
240
  return level(term, header, "Preserve evidence", () => [
141
- { label: "How long each AI app keeps its sessions", hint: "npx worktrust preserve", info: "Shows a report of how long each AI app here keeps its sessions. Nothing is changed or sent.", run: () => runShown(term, io, ["preserve"]) },
142
- { label: "Keep them longer", hint: "npx worktrust preserve --apply", info: "Sets your AI apps to keep their sessions longer. It asks per change and backs each file up first.", run: () => runShown(term, io, ["preserve", "--apply"]) },
143
- { label: "Make a local archive", hint: "npx worktrust preserve --archive", info: "Writes a metadata-only, hash-chained record of the measured days to ~/AI-Evidence. Nothing is sent.", run: () => runShown(term, io, ["preserve", "--archive"]) },
144
- { label: "Check the archive", hint: "npx worktrust preserve --verify", info: "Checks that record: every hash, the chain, each day's root and signature. It only reads.", run: () => runShown(term, io, ["preserve", "--verify"]) },
145
- { label: "Count hours from the archive", hint: "npx worktrust preserve --summary", info: "Counts hours, tokens per model and parallel sessions from that record. It only reads.", run: () => runShown(term, io, ["preserve", "--summary"]) },
241
+ { label: "How long each AI app keeps sessions", hint: "npx worktrust preserve", info: "Shows how long each AI app keeps sessions. Changes nothing.", run: () => runShown(term, io, ["preserve"]) },
242
+ { label: "Keep them longer", hint: "npx worktrust preserve --apply", info: "Keeps sessions longer. Asks per change, backs up first.", run: () => runShown(term, io, ["preserve", "--apply"]) },
243
+ { label: "Make a local archive", hint: "npx worktrust preserve --archive", info: "Writes a metadata-only record to ~/AI-Evidence. Not sent.", run: () => runShown(term, io, ["preserve", "--archive"]) },
244
+ { label: "Check the archive", hint: "npx worktrust preserve --verify", info: "Checks that record's hashes and signatures. It only reads.", run: () => runShown(term, io, ["preserve", "--verify"]) },
245
+ { label: "Count hours from the archive", hint: "npx worktrust preserve --summary", info: "Counts hours and tokens from that record. It only reads.", run: () => runShown(term, io, ["preserve", "--summary"]) },
146
246
  BACK,
147
247
  ]);
148
248
  }