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.
package/worktrust.mjs CHANGED
@@ -1,7 +1,8 @@
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 in a person's own terminal (0.11.7; 0.11.8: Update first): the menu (cli-menu.mjs), one item of which is
4
+ * npx worktrust in a person's own terminal (0.11.7; 0.11.8: Update first; 0.11.9: not connected yet, a short
5
+ * menu: Connect, Preserve, Help): the menu (cli-menu.mjs), one item of which is
5
6
  * what the bare command did until then; without a terminal, exactly that:
6
7
  * show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
7
8
  * command always runs the newest version, whatever npx had cached);
@@ -11,7 +12,9 @@
11
12
  * npx worktrust --device a computer without a browser (SSH): type a code on another device
12
13
  * npx worktrust connect couple again, also on a computer already coupled
13
14
  * npx worktrust update this computer onto the newest CLI, same key, no new pairing (0.10.30: what
14
- * was agreed before is refreshed unasked; --rebuild agrees to the re-measure)
15
+ * was agreed before is refreshed unasked; --rebuild agrees to the re-measure;
16
+ * 0.11.9: already on this version with nothing waiting, it says so and
17
+ * changes nothing; --force sets everything up again all the same)
15
18
  * npx worktrust history send this computer's earlier sessions as history (asks first)
16
19
  * npx worktrust history --rebuild the same as history (0.10.5: history always re-measures); WorkTrust replaces this computer's
17
20
  * earlier lines day by day, never counting a day twice (shows the plan, asks first)
@@ -80,7 +83,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
80
83
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
81
84
  const has = (name) => args.includes(`--${name}`);
82
85
  /** 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). */
83
- const CLI_VERSION = "0.11.8";
86
+ const CLI_VERSION = "0.11.10";
84
87
  /**
85
88
  * 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
86
89
  * to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
@@ -116,9 +119,9 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
116
119
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
117
120
  const HOME_DIR = join(homedir(), ".worktrust");
118
121
  const HERE = dirname(fileURLToPath(import.meta.url));
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"];
122
+ 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", "cli-look.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-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"];
120
123
  /** The modules the scripts import by name from beside them; a download keeps that name. */
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"]);
124
+ const IMPORTED = new Set(["project-modes.mjs", "transcript-readers.mjs", "session-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"]);
122
125
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
123
126
  const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
124
127
  const PLACEHOLDER = `wt_${"0".repeat(43)}`;
@@ -701,9 +704,18 @@ async function sessionEnd() {
701
704
  async function update() {
702
705
  const key = await freshKey();
703
706
  if (!key) fail("this computer has no WorkTrust key file yet. Run npx worktrust connect.");
704
- say();
705
- say(` WorkTrust · update ${hostname().replace(/\.local$/i, "")} to ${CLI_VERSION}`);
706
- say();
707
+ const title = () => { say(); say(` WorkTrust · update ${hostname().replace(/\.local$/i, "")} to ${CLI_VERSION}`); say(); };
708
+ // ALREADY ON THIS VERSION (0.11.9, owner 2026-11-14: "when the latest version is already there it is useless to run the
709
+ // update again"): the second run took every door out and put it back, and said "7 added". Now it says so and changes
710
+ // nothing, but only when NOTHING waits: this version's stable copy, the door chosen, every AI app's door standing by the
711
+ // writer's own reading, nothing new to agree to, no Codex or Antigravity question open. `--force` is the repair road.
712
+ const same = !has("force") && !has("codex") && !has("antigravity") && stableVersion() === CLI_VERSION && existsSync(STABLE) && Boolean(doorState());
713
+ if (!same) title();
714
+ // The plan below asks the writer whether each door names THIS release's bridge, so the bridge's place must be the installed
715
+ // one first; the same release already in ~/.worktrust is only verified here, never written again.
716
+ // The old install is read BEFORE anything is prepared (check-core-logic history-rebuild: the rebuild offer compares it).
717
+ const previous = stableInstall();
718
+ if (same) await prepareBundledRuntime();
707
719
  const paths = await scripts();
708
720
  if (!doorState() && !has("dry-run")) saveDoorState({ mode: await chooseDoor(), asked: new Date().toISOString() }); // once, for a computer coupled before 0.10.37
709
721
  const doorIsOff = doorOff();
@@ -711,10 +723,22 @@ async function update() {
711
723
  // AGREED BEFORE, REFRESHED WITHOUT A QUESTION (0.10.30): an app or hook the person said yes to is brought onto this
712
724
  // version's launcher; only what is NEW here is shown in full and asked about, and --yes leaves the new ones as they are.
713
725
  const agreed = await consent();
714
- say(" Every AI app found here gets the WorkTrust door, the local command that reads the key:");
715
726
  const found = doorIsOff ? [] : planLines(plan.out, true).filter((line) => !line.includes("not on this machine"));
716
- if (doorIsOff) say(` the door stays off here (hours only, ${DOOR_SWITCH})`);
717
727
  const apps = [...new Set(found.map(labelOf).filter(Boolean))], fresh = apps.filter((app) => !agreed.has(`door:${app}`));
728
+ if (same) {
729
+ const standing = doorIsOff || planLines(plan.out).filter((line) => !line.includes("not on this machine")).every((line) => /^\s+✓ /.test(line));
730
+ const asked = (existsSync(join(homedir(), ".codex")) && !codexNotify().text) || (antigravityHere() && agyHooks() !== null && !agyHooks()?.worktrust);
731
+ if (plan.code === 0 && standing && fresh.length === 0 && agreed.has("session-hook") && !asked) {
732
+ say();
733
+ say(` Already up to date (${CLI_VERSION}). Nothing changed.`);
734
+ if (doorIsOff) say(` the door stays off here (hours only, ${DOOR_SWITCH})`); // a choice the update keeps is still said
735
+ say(" To set this computer up again all the same: npx worktrust update --force");
736
+ return;
737
+ }
738
+ title();
739
+ }
740
+ say(" Every AI app found here gets the WorkTrust door, the local command that reads the key:");
741
+ if (doorIsOff) say(` the door stays off here (hours only, ${DOOR_SWITCH})`);
718
742
  for (const app of apps) if (!fresh.includes(app)) say(` ✓ ${app}: refreshed (${agreed.said(`door:${app}`)})`);
719
743
  for (const line of found) if (fresh.includes(labelOf(line))) say(`${line} · new`);
720
744
  if (found.length === 0 && !doorIsOff) say(" (no AI app found here)");
@@ -730,7 +754,6 @@ async function update() {
730
754
  else if (newOnes.length > 0) takeNew = await ask(`Couple the new ${newOnes.length === 1 ? "one" : "ones"} marked "new" (${newOnes.join(", ")})?`, false);
731
755
  if (newOnes.length > 0 && !takeNew && !has("yes")) say(" The new ones stay as they are. npx worktrust update asks again.");
732
756
  const skip = takeNew ? [] : fresh, hookOn = !hookFresh || takeNew;
733
- const previous = stableInstall();
734
757
  await prepareBundledRuntime();
735
758
  ensureHome();
736
759
  saveStableEntry();
@@ -1384,7 +1407,7 @@ async function status() {
1384
1407
  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`);
1385
1408
  // THE LAST UPDATE ON TURN-ON (0.10.37): what happened, in words; the details are in ~/.worktrust/update.log, on this computer only.
1386
1409
  { const state = updateState(); if (state) { const code = (await selfUpdateModule()).updateResult(state);
1387
- const words = { installed: `updated itself to ${state.version}`, current: `already on ${state.version} or newer`, python: "installed with Python: update it with the package manager you installed WorkTrust with", unsupported: "this installation cannot update itself: run npx worktrust@latest update", unverified: `${state.version} could not be verified, so nothing was installed`, failed: `the update to ${state.version} did not finish; the CLI stays as it was` };
1410
+ const words = { installed: `updated itself to ${state.version}`, current: `already on ${state.version} or newer`, python: "installed with Python: update it with the package manager you installed WorkTrust with", unsupported: "this installation cannot update itself: run npx -y worktrust@latest update", unverified: `${state.version} could not be verified, so nothing was installed`, failed: `the update to ${state.version} did not finish; the CLI stays as it was` };
1388
1411
  say(` Update when turned on: ${words[code] ?? `to ${state.version}, under way`}${["unverified", "failed"].includes(code) ? " (~/.worktrust/update.log)" : ""}`); } }
1389
1412
  // A TRANSCRIPT THE HOOK COULD NOT READ (0.10.32): the count of its last run that had any, never which file; WorkTrust has the count too.
1390
1413
  { let unread = null; try { unread = JSON.parse(readFileSync(join(HOME_DIR, "sessions.json"), "utf8")).__unreadable ?? null; } catch { /* no state yet */ }
@@ -1407,19 +1430,34 @@ async function measuredHere() {
1407
1430
  const read = await busyWith("Counting what this computer measured", () => run(hook, ["--evidence-summary"], "", true, { WORKTRUST_MCP_URL: "", WORKTRUST_HOOK_INPUT: "" }));
1408
1431
  let m = null;
1409
1432
  try { m = JSON.parse(read.out.trim().split("\n").filter((text) => text.startsWith("{")).pop()); } catch { return; }
1410
- if (!m || !m.stretches) { say(" Measured here, last 30 days: no finished work stretch yet."); return; }
1411
- const of = (part, whole, one, many) => `${part} of ${whole} ${whole === 1 ? one : many}`;
1412
- say();
1413
- say(` Measured here, last 30 days: ${m.stretches} work stretch${m.stretches === 1 ? "" : "es"} (the hours are WorkTrust's: see the app)`);
1414
- if (m.delivered) say(` verified before delivery ${of(m.verified_first, m.delivered, "stretch that delivered", "stretches that delivered")}`);
1415
- if (m.failures) say(` recovered failures ${of(m.recovered, m.failures, "failed tool call", "failed tool calls")} (${m.blind_retries} retried unchanged)`);
1416
- if (m.steers) say(` steering that worked ${of(m.effective_steers, m.steers, "time you stepped in", "times you stepped in")}`);
1417
- if (m.refused || m.guard_denied) say(` refused ${m.refused} by you · ${m.guard_denied} by a guard`);
1418
- if (m.planned) say(` planned ${m.planned} stretch${m.planned === 1 ? "" : "es"} with a to-do list`);
1419
- if (m.files) say(` tests among changed files ${of(m.test_files, m.files, "file", "files")}`);
1420
- const tiers = Object.entries(m.complexity ?? {}).sort();
1421
- if (tiers.length) say(` task complexity ${tiers.map(([tier, n]) => `${tier} ${n}`).join(" · ")}`);
1422
- say(" Sent with each stretch as kinds and counts, never text. Keep your own copy: npx worktrust@latest preserve");
1433
+ // 0.11.10: the lines are cli-look.mjs's measuredLines (pure; the changed files and the classes now say what they count).
1434
+ const { measuredLines } = await import("./cli-look.mjs");
1435
+ for (const line of measuredLines(m)) say(line);
1436
+ if (m?.stretches) say(" Each AI app's sessions on this computer, counted: npx worktrust look");
1437
+ }
1438
+
1439
+ /**
1440
+ * LOOK AT THIS COMPUTER (`npx worktrust look`, 0.11.10; owner, 2026-11-14): per AI app the sessions its own files hold and
1441
+ * their first and last day (cli-look.mjs). It reads no key, writes nothing and calls no network: not the registry either
1442
+ * (look is not a RELAY_COMMAND). In a person's own terminal (menuWanted) a short list follows, each row a command as a child.
1443
+ */
1444
+ async function look(agentShell) {
1445
+ if (!existsSync(join(HERE, "cli-look.mjs"))) fail("worktrust look needs the complete WorkTrust package. Nothing was read.");
1446
+ const { lookAt, lookLines, lookNext } = await import("./cli-look.mjs");
1447
+ const live = Boolean(process.stderr.isTTY), tell = (words) => process.stderr.write(live ? `\r\x1b[K ${words}` : ` ${words}\n`);
1448
+ tell("Looking for AI apps…");
1449
+ const found = lookAt({ progress: (name) => tell(`Reading ${name}…`) });
1450
+ if (live) process.stderr.write("\r\x1b[K");
1451
+ for (const line of lookLines(found, { columns: process.stdout.columns || 80 })) say(line);
1452
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return;
1453
+ const menu = await import("./cli-menu.mjs");
1454
+ if (!menu.menuWanted({ args: [], env: process.env, stdinTTY: true, stdoutTTY: true, agentShell })) return;
1455
+ const runCli = (cliArgs) => new Promise((resolve) => {
1456
+ const child = spawn(moduleExecutable(HERE), [...moduleArgs(HERE, "worktrust.mjs", cliArgs)], { stdio: "inherit", env: { ...process.env, WORKTRUST_MENU: "off", WORKTRUST_RELAYED: "1" } });
1457
+ child.on("error", () => resolve(1));
1458
+ child.on("exit", (code, signal) => resolve(code ?? (signal ? 130 : 1)));
1459
+ });
1460
+ process.exitCode = await lookNext({ runCli }, { connected: existsSync(KEY_FILE) });
1423
1461
  }
1424
1462
 
1425
1463
  /** Claude Code's `cleanupPeriodDays` (its default 30), or null without Claude Code here. Read only: preserve.mjs changes it, on a yes. */
@@ -1554,6 +1592,23 @@ async function followDoorWish(key) {
1554
1592
  saveDoorState({ mode: wish.mode, asked: state?.asked ?? new Date().toISOString() });
1555
1593
  await accepted(key.url, key.token, key.device, doorModeAgent());
1556
1594
  }
1595
+ /**
1596
+ * THE ACCOUNT'S TYPE, FOR THE MENU (owner, 2026-11-14; 0.11.10): the same signed ask as followDoorWish, read-only here (no
1597
+ * wish is acted on), three seconds at most. `account` is WorkTrust's own answer for this key's owner: `plan` (free | premium,
1598
+ * else not known), `remote` (open | premium_required, else not known: only premium_required locks Remote Agent in the menu)
1599
+ * and `upgrade`, kept only when it is an address on this key's own WorkTrust. Offline or refused: null, which claims nothing.
1600
+ */
1601
+ async function askAccount(key) {
1602
+ if (!key?.device) return null;
1603
+ try {
1604
+ const url = new URL("/api/cli/door", key.url).href, body = "{}";
1605
+ const response = await fetch(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key.token}`, "user-agent": `worktrust-cli/${CLI_VERSION}`, ...proof(key.device, url, body) }, body, redirect: "error", signal: AbortSignal.timeout(3000) });
1606
+ const account = response.ok ? (await response.json())?.account : null;
1607
+ if (!account || typeof account !== "object") return null;
1608
+ let upgrade = null; try { const at = new URL(account.upgrade); upgrade = at.origin === new URL(key.url).origin && /^https?:$/.test(at.protocol) ? at.href : null; } catch { upgrade = null; }
1609
+ return { plan: ["free", "premium"].includes(account.plan) ? account.plan : null, remoteAccess: ["open", "premium_required"].includes(account.remote) ? account.remote : null, upgrade };
1610
+ } catch { return null; }
1611
+ }
1557
1612
  /**
1558
1613
  * CLI ACTIVE, PER COMPUTER (owner, 2026-11-05; 0.10.37). The owner may pause this computer's CLI from Sources: the same answer
1559
1614
  * from api/cli/door carries `measure` (active | paused) and its moment. A wish newer than the last change here is kept in
@@ -1660,6 +1715,8 @@ function help() {
1660
1715
  say(" --replace yes in advance to coupling a computer that is already coupled");
1661
1716
  say(" worktrust update this computer onto the newest CLI: same key, no new pairing; what you agreed to before is");
1662
1717
  say(" refreshed without a question, a new AI app or hook is asked about (--yes: skipped)");
1718
+ say(" already on this version with nothing waiting: says so and changes nothing");
1719
+ say(" --force set everything up again all the same (the repair road)");
1663
1720
  say(" --rebuild yes in advance to the re-measure update offers after a new version (the plan is still shown)");
1664
1721
  say(" --codex yes in advance to letting Codex wake the session hook (also for connect)");
1665
1722
  say(" --antigravity yes in advance to letting Antigravity wake the session hook (also for connect)");
@@ -1681,6 +1738,7 @@ function help() {
1681
1738
  say(" days this computer's own sessions lack, reconstructed, never verified hours (asks first)");
1682
1739
  say(" worktrust disconnect take WorkTrust out of every AI app here (asks first)");
1683
1740
  say(" worktrust status what is coupled here");
1741
+ say(" worktrust look what your AI apps recorded here: sessions per app and their first and last day; reads only, sends nothing");
1684
1742
  say(" worktrust project a folder's mode: exclude (nothing read), confidential (hours and tokens count, no name,");
1685
1743
  say(" branch, path or commit sent) or normal; `project list` shows them (default folder: here)");
1686
1744
  say(" worktrust remote steer this computer's agents from your phone (opt-in, its own key, never your AI Hours):");
@@ -1761,23 +1819,31 @@ async function relayToNewest() {
1761
1819
  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
1820
  try { keyStore.load(); }
1763
1821
  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;
1822
+ let latest, latestKnown = false; // 0.11.9: whether the registry answered at all (no answer is not "up to date")
1823
+ let account = null, accountAt = 0; // 0.11.10: the account's type and Remote Agent's access, asked again after a minute or an upgrade
1765
1824
  const runCli = (cliArgs) => new Promise((resolve) => {
1766
1825
  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
1826
  child.on("error", () => resolve(1));
1768
- child.on("exit", (code) => resolve(code ?? 1));
1827
+ child.on("exit", (code, signal) => resolve(code ?? (signal ? 130 : 1))); // stopped by Ctrl+C: 130, which the first menu reads as cancelled
1769
1828
  });
1770
1829
  const state = async () => {
1771
- if (latest === undefined) { const v = await newestVersion(); latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
1830
+ if (latest === undefined) { const v = await newestVersion(); latestKnown = v !== null; latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
1772
1831
  let key = null; try { key = keyStore.load(); } catch { key = null; }
1832
+ if (key && Date.now() - accountAt > 60_000) { account = await askAccount(key); accountAt = Date.now(); }
1773
1833
  // `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" };
1834
+ // THE SUMMARY'S FACTS (0.11.9): what this computer's own files say, never the key: its name, the day it was coupled, whether
1835
+ // the session hook stands in Claude Code's settings, and how many AI apps' doors the person agreed to (the consent record).
1836
+ let apps = null; try { apps = Object.keys(JSON.parse(readPrivateFile(CONSENT_FILE) ?? "null")?.entries ?? {}).filter((name) => name.startsWith("door:")).length; } catch { apps = null; }
1837
+ return { version: CLI_VERSION, installed: stableVersion(), latest, latestKnown, connected: Boolean(key), account: key?.account ?? null, door: doorOff() ? "off" : "on",
1838
+ host: hostname().replace(/\.local$/i, ""), since: key?.coupledAt ?? null, hook: sessionHookHere(), apps,
1839
+ plan: key ? account?.plan ?? null : null, remoteAccess: key ? account?.remoteAccess ?? null : null, upgrade: key ? account?.upgrade ?? null : null };
1775
1840
  };
1776
- return (await import("./cli-menu.mjs")).runMenu({ runCli, state });
1841
+ const openUrl = (url) => { openBrowser(url); accountAt = 0; }; // after an upgrade, the next read asks the account again
1842
+ return (await import("./cli-menu.mjs")).runMenu({ runCli, state, openUrl });
1777
1843
  }
1778
1844
  if (await relayToNewest()) return;
1779
1845
 
1780
- if (!["version", "help", "preserve", "project"].includes(command)) {
1846
+ if (!["version", "help", "preserve", "project", "look"].includes(command)) { // 0.11.10: look reads no key (it reads, prints and writes nothing)
1781
1847
  try { keyStore.load(); }
1782
1848
  catch { fail("The local WorkTrust key file is unsafe or damaged, or the OS vault is locked or unavailable. Upload stopped. Unlock your OS vault and retry. Do not delete the key file or reset the keychain."); }
1783
1849
  }
@@ -1802,6 +1868,7 @@ else if (command === "codex") await offerCodex();
1802
1868
  else if (command === "antigravity") await offerAntigravity();
1803
1869
  else if (command === "disconnect") await disconnect();
1804
1870
  else if (command === "status") await status();
1871
+ else if (command === "look") await look(agentShell);
1805
1872
  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 }); }
1806
1873
  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 }; } });
1807
1874
  else if (command === "preserve") await preserve();