worktrust 0.11.12 → 0.11.14

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.
@@ -1717,6 +1717,110 @@ export function agentsActiveRule(a ) {
1717
1717
  return null;
1718
1718
  }
1719
1719
 
1720
+ // ---- packages/remote-protocol/src/health.ts
1721
+ /**
1722
+ * THE COMPUTER'S HEALTH (owner, 2026-11-15: "the computer sometimes crashes from RAM/GPU load"). The Remote daemon reads
1723
+ * a few numbers of its own machine every 15 seconds, without a model and without sudo, and seals one `device.health`
1724
+ * body for each paired phone and browser. It travels on the TRANSIENT LANE (envelopes.ts), device-wide: the relay passes
1725
+ * it on to a phone that is there and keeps, buffers and records none of it, so the server never sees or stores a sample.
1726
+ *
1727
+ * Every field is a number, an enum or a flag, except a process's NAME: the program's basename (`ps -o comm=`), never its
1728
+ * arguments, its path or a window title. healthRule refuses a name that looks like a path or an argument, and refuses a
1729
+ * level that is not what healthLevel says of the numbers, so no sender can call a critical computer green.
1730
+ *
1731
+ * A reading that failed is null, never 0. `gpu_busy` is the GPU's own "Device Utilization %" reading (IOAccelerator),
1732
+ * 0 to 100, passed through as the device states it: no figure computed by the sender. Memory and load travel as counts
1733
+ * (MB, the load average times 100, the cores); a surface derives a share from them (healthView in the client).
1734
+ */
1735
+
1736
+ /** How often the daemon samples, and how far back "swap growing" looks. */
1737
+ export const HEALTH_SAMPLE_MS = 15_000;
1738
+ export const SWAP_GROWTH_WINDOW_MS = 120_000;
1739
+ /** Swap that grew by at least this much over the window is "growing" (a few MB of churn is not). */
1740
+ export const SWAP_GROWTH_MIN_MB = 64;
1741
+ /** Below this share of the memory free (with swap growing) the computer is red. */
1742
+ export const LOW_MEMORY_SHARE = 0.05;
1743
+ /** An hour of samples, in memory only (the client's history; never stored). */
1744
+ export const HEALTH_HISTORY_MS = 3_600_000;
1745
+ export const MAX_PROCESS_NAME = 64;
1746
+
1747
+ export const HEALTH_LEVELS = ["green", "yellow", "red", "unknown"] ;
1748
+
1749
+ /** macOS kern.memorystatus_vm_pressure_level 1, 2, 4; Linux PSI memory (`some`/`full` avg10). */
1750
+ export const MEMORY_PRESSURES = ["normal", "warn", "critical"] ;
1751
+
1752
+ export const HEALTH_REASONS = ["pressure_critical", "low_memory_swap_growing", "pressure_warn", "swap_growing"] ;
1753
+
1754
+ const MB = int(0, 16_777_216);
1755
+ export const HEALTH_PROCESS_SPEC = object({ name: text(MAX_PROCESS_NAME, 1), memory_mb: MB });
1756
+
1757
+ export const HEALTH_BODY_SPEC = object({
1758
+ sampled_at: int(0),
1759
+ level: oneOf(HEALTH_LEVELS),
1760
+ reasons: list(oneOf(HEALTH_REASONS), HEALTH_REASONS.length),
1761
+ pressure: nullable(oneOf(MEMORY_PRESSURES)),
1762
+ memory_total_mb: nullable(MB),
1763
+ memory_free_mb: nullable(MB),
1764
+ swap_used_mb: nullable(MB),
1765
+ /** Swap used now minus SWAP_GROWTH_WINDOW_MS ago; null until the daemon has a reading that old. */
1766
+ swap_growth_mb: nullable(int(-16_777_216, 16_777_216)),
1767
+ /** The one-minute load average times 100, and the logical cores it is shared by. */
1768
+ load_centi: nullable(int(0, 100_000_000)),
1769
+ cores: nullable(int(1, 4096)),
1770
+ gpu_busy: nullable(int(0, 100)),
1771
+ /** The three programs holding the most memory, by basename, summed over their processes. */
1772
+ top: list(HEALTH_PROCESS_SPEC, 3),
1773
+ /** True while the daemon starts no new session (level red); running sessions continue. */
1774
+ refusing: bool(),
1775
+ });
1776
+
1777
+ /**
1778
+ * THE THRESHOLDS, ONE PURE FUNCTION (the daemon, the CLI line and every surface read this). Red: pressure critical, or
1779
+ * under 5 % of the memory free while swap grew for two minutes. Yellow: pressure warn, or swap growing. Unknown: no
1780
+ * reading to judge by at all. Green otherwise.
1781
+ */
1782
+ export function healthLevel(input ) {
1783
+ const swapGrowing = input.swap_growth_mb !== null && input.swap_growth_mb >= SWAP_GROWTH_MIN_MB;
1784
+ const share = input.memory_total_mb && input.memory_free_mb !== null ? input.memory_free_mb / input.memory_total_mb : null;
1785
+ const reasons = [];
1786
+ if (input.pressure === "critical") reasons.push("pressure_critical");
1787
+ if (share !== null && share < LOW_MEMORY_SHARE && swapGrowing) reasons.push("low_memory_swap_growing");
1788
+ if (input.pressure === "warn") reasons.push("pressure_warn");
1789
+ if (swapGrowing) reasons.push("swap_growing");
1790
+ if (reasons.includes("pressure_critical") || reasons.includes("low_memory_swap_growing")) return { level: "red", reasons };
1791
+ if (reasons.length > 0) return { level: "yellow", reasons };
1792
+ if (input.pressure === null && share === null && input.swap_growth_mb === null) return { level: "unknown", reasons };
1793
+ return { level: "green", reasons };
1794
+ }
1795
+
1796
+ /**
1797
+ * A NAME THAT IS A PROGRAM'S BASENAME AND NOTHING ELSE. Refused: a path separator, a control character, a leading dash,
1798
+ * an argument after a space (` -x`, ` --flag`), an `=` (a setting), a URL scheme. Spaces and brackets stay: "Google
1799
+ * Chrome Helper (Renderer)" is one program's name.
1800
+ */
1801
+ export function processNameRefusal(name ) {
1802
+ if (name.length === 0 || name.length > MAX_PROCESS_NAME) return "length";
1803
+ if (/[/\\]/.test(name)) return "a path";
1804
+ if (/[\u0000-\u001f\u007f]/.test(name)) return "a control character";
1805
+ if (/^-|\s-{1,2}\S|=|:\/\//.test(name)) return "an argument";
1806
+ return null;
1807
+ }
1808
+
1809
+ /** The rules between fields, after the schema (events.ts validateEventBody). */
1810
+ export function healthRule(body ) {
1811
+ for (const p of body.top) {
1812
+ const bad = processNameRefusal(p.name);
1813
+ if (bad) return `top: a process name with ${bad}`;
1814
+ }
1815
+ if (new Set(body.top.map((p) => p.name)).size !== body.top.length) return "top: a name twice";
1816
+ if (body.top.some((p, n) => n > 0 && p.memory_mb > body.top[n - 1] .memory_mb)) return "top: largest first";
1817
+ if (body.memory_total_mb !== null && body.memory_free_mb !== null && body.memory_free_mb > body.memory_total_mb) return "memory_free_mb: above the total";
1818
+ const judged = healthLevel(body);
1819
+ if (judged.level !== body.level || judged.reasons.join() !== body.reasons.join()) return "level: not what the numbers say";
1820
+ if (body.refusing && body.level !== "red") return "refusing: only while red";
1821
+ return null;
1822
+ }
1823
+
1720
1824
  // ---- packages/remote-protocol/src/latency.ts
1721
1825
  /**
1722
1826
  * HOW LONG EACH HOP TOOK (owner, 2026-11-07: a prompt sent while the agent is busy waits, and the app must show it).
@@ -1734,6 +1838,41 @@ export function deliveryHops(r )
1734
1838
  return { to_relay_ms: span(r.sent_at, r.relay_ack_seen_at), on_computer_ms: span(r.received_at, r.accepted_at) };
1735
1839
  }
1736
1840
 
1841
+ // ---- packages/remote-protocol/src/desk.ts
1842
+ /**
1843
+ * CONTINUE A SESSION ON THIS COMPUTER (release 36, owner 2026-11-15; docs/remote-agents/DESK-SESSIONS.md). The computer's
1844
+ * newest Claude Code sessions in GRANTED projects, sealed in device.inventory `desk_sessions`, only for a phone that asked
1845
+ * `inventory.get` `desk_sessions` (an older phone refuses unknown keys and never receives it). Per session ONLY: Claude
1846
+ * Code's own session id, the project's id, the last activity, a title of at most 80 characters (Claude Code's own summary,
1847
+ * else the first line typed) and the model when recorded. Never more of the transcript. A phone continues one with
1848
+ * `agent.start` `resume` = `session_ref` under that project; the computer checks it is in its own list, that the project is
1849
+ * granted, and that nothing on the computer holds it (`in_use`).
1850
+ */
1851
+
1852
+ export const MAX_DESK_SESSIONS = 20;
1853
+ export const MAX_DESK_TITLE = 80;
1854
+ const CLAUDE_SESSION_REF = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
1855
+
1856
+ export const DESK_SESSION_SPEC = object({
1857
+ session_ref: text(36, 36),
1858
+ project_id: id("prj"),
1859
+ last_activity_at: int(0),
1860
+ title: nullable(text(MAX_DESK_TITLE, 1)),
1861
+ model: nullable(text(128, 1)),
1862
+ });
1863
+
1864
+ /** device.inventory's field (events.ts spreads it): sealed only for a phone that asked `inventory.get` `desk_sessions`. */
1865
+ export const DESK_INVENTORY_FIELDS = { desk_sessions: optional(list(DESK_SESSION_SPEC, MAX_DESK_SESSIONS)) } ;
1866
+
1867
+ /** The rules between fields: a uuid each, each once, each under a project the same inventory lists. → null, or what is wrong. */
1868
+ export function deskRule(desk , projects ) {
1869
+ const rows = desk ?? [];
1870
+ if (rows.some((d) => !CLAUDE_SESSION_REF.test(d.session_ref))) return "a session_ref is Claude Code's own uuid";
1871
+ if (new Set(rows.map((d) => d.session_ref)).size !== rows.length) return "a session twice";
1872
+ if (rows.some((d) => !projects.some((p) => p.project_id === d.project_id))) return "under a project the inventory lists";
1873
+ return null;
1874
+ }
1875
+
1737
1876
  // ---- packages/remote-protocol/src/state-machine.ts
1738
1877
  /**
1739
1878
  * DELIVERY AND EXECUTION, AS A PURE FUNCTION. One command's state, from the phone's draft to its end:
@@ -2369,6 +2508,9 @@ export const projectNameOk = (name ) => typeof name === "string
2369
2508
  export const MAX_SESSION_NAME = 100;
2370
2509
  /** A phone's or a browser's own name, as it tells a computer (inventory.get `device_name`). */
2371
2510
  export const MAX_DEVICE_NAME = 64;
2511
+ /** One catch-up page (session.attach `after`, release 37): at most this many events, and this many characters of them. */
2512
+ export const CATCH_UP_MAX_EVENTS = 200;
2513
+ export const CATCH_UP_MAX_BYTES = 1_048_576;
2372
2514
 
2373
2515
  export const COMMAND_PAYLOAD_SPECS = {
2374
2516
  /**
@@ -2442,8 +2584,15 @@ export const COMMAND_PAYLOAD_SPECS = {
2442
2584
  }),
2443
2585
  /** Ask for a status.report: of one session, or of the whole computer (then a device.inventory too). */
2444
2586
  "status.get": object({ scope: oneOf(["session", "device"]) }),
2445
- /** Join a session started at the desk, which the computer listed in its inventory. */
2446
- "session.attach": object({}),
2587
+ /**
2588
+ * Join a session started at the desk, which the computer listed in its inventory. Empty: the computer replays the
2589
+ * session's journal whole. THE CATCH-UP (release 37, CLI 0.11.14): `after`, `max_events` and `max_bytes` together ask
2590
+ * only the journaled events after `after`, in order, at most `max_events` of them and at most `max_bytes` (the journal
2591
+ * record's canonical characters; one event always, so a page always moves), sealed for the asking phone alone; the phone
2592
+ * asks the next page once this one's `command.agent_accepted` arrived. Sent only to a computer whose inventory probe
2593
+ * showed it reads `catch_up` (inventory.get below): an older one drops the fields, so it is never asked.
2594
+ */
2595
+ "session.attach": object({ after: optional(int(0)), max_events: optional(int(1, CATCH_UP_MAX_EVENTS)), max_bytes: optional(int(1024, CATCH_UP_MAX_BYTES)) }),
2447
2596
  /** Bring the session to the front on the computer's own screen ("show it on my desk"). Moves the view only. */
2448
2597
  "session.focus": object({}),
2449
2598
  /** End the session and its agent. */
@@ -2477,6 +2626,16 @@ export const COMMAND_PAYLOAD_SPECS = {
2477
2626
  * An older computer refuses the unknown field; the phone then asks again with `extended` alone (client-core.ts).
2478
2627
  */
2479
2628
  model_switch: optional(bool()),
2629
+ /**
2630
+ * Release 36: this phone reads `desk_sessions` (events.ts) and may continue one. Only with `extended`; an older computer
2631
+ * drops the unknown field, so the phone asks it by a probe of its own (client-core.ts, inventory-asks.ts).
2632
+ */
2633
+ desk_sessions: optional(bool()),
2634
+ /**
2635
+ * Release 37: this phone asks a session's events after a sequence (session.attach `after`, the catch-up). Only with
2636
+ * `extended`; an older computer drops the unknown field, so the phone asks it by a probe of its own.
2637
+ */
2638
+ catch_up: optional(bool()),
2480
2639
  }),
2481
2640
  /** This computer's remote settings, each optional. Pausing from the phone is soft; `worktrust remote disable` at the
2482
2641
  * desk is the hard off, which no message can undo. */
@@ -2636,6 +2795,13 @@ export function validateCommandPayload (type , value
2636
2795
  const i = payload ;
2637
2796
  if (i.device_name !== undefined && (i.extended !== true || !deviceNameOk(i.device_name))) return refuse("payload", "$payload.device_name: printable words, with extended");
2638
2797
  if (i.model_switch !== undefined && i.extended !== true) return refuse("payload", "$payload.model_switch: with extended");
2798
+ if (i.desk_sessions !== undefined && i.extended !== true) return refuse("payload", "$payload.desk_sessions: with extended");
2799
+ if (i.catch_up !== undefined && i.extended !== true) return refuse("payload", "$payload.catch_up: with extended");
2800
+ }
2801
+ if (type === "session.attach") {
2802
+ const a = payload ;
2803
+ const given = [a.after, a.max_events, a.max_bytes].filter((v) => v !== undefined).length;
2804
+ if (given !== 0 && given !== 3) return refuse("payload", "$payload: after, max_events and max_bytes together, or none");
2639
2805
  }
2640
2806
  if (type === "attachment.put") { const bad = attachmentRule(payload ); if (bad) return refuse("payload", `$payload: ${bad}`); }
2641
2807
  if (type === "preview.render") { const bad = previewRule(payload ); if (bad) return refuse("payload", `$payload: ${bad}`); }
@@ -2753,6 +2919,7 @@ export const REJECT_REASONS = [
2753
2919
  "busy", // the agent is mid-turn and the command needs it idle (a release: its tasks still run, or no slot for a pipeline)
2754
2920
  "unreviewed", // the project's pipeline file was not reviewed at the keyboard, or changed since (2026-11-07)
2755
2921
  "not_allowed", // the computer did not allow it at its keyboard (a browser endorsement without allow-endorse), or the sender may not (2026-11-09)
2922
+ "in_use", // release 36: the desk session to continue is open on the computer; sent only to a phone that asked `desk_sessions` (others hear `busy`)
2756
2923
  ] ;
2757
2924
 
2758
2925
  export const FAIL_REASONS = ["agent_exited", "adapter_error", "not_ready", "timeout", "internal"] ;
@@ -2902,7 +3069,7 @@ export const EVENT_BODY_SPECS = {
2902
3069
  agent_options: optional(list(AGENT_OPTIONS_SPEC, 16)),
2903
3070
  modes_allowed: optional(list(oneOf(AGENT_MODES), AGENT_MODES.length)),
2904
3071
  /** Part B (owner, 2026-11-12), only for an `extended` phone: the settings page's admin switch, folders, connections (crypto/admin.ts). */
2905
- ...ADMIN_INVENTORY_FIELDS,
3072
+ ...ADMIN_INVENTORY_FIELDS, ...DESK_INVENTORY_FIELDS, // release 36: `desk_sessions`, only for a phone that asked (desk.ts)
2906
3073
  sessions: list(
2907
3074
  object({
2908
3075
  session_id: id("ses"),
@@ -2940,19 +3107,16 @@ export const EVENT_BODY_SPECS = {
2940
3107
  ...TRANSFER_EVENT_SPECS,
2941
3108
  /** The live preview (release 19, live-preview.ts): its state, and its frames on the transient lane only. */
2942
3109
  ...LIVE_EVENT_SPECS,
3110
+ /** The computer's health (health.ts), every 15 s on the transient lane, device-wide: passed on, kept by nobody. */
3111
+ "device.health": HEALTH_BODY_SPEC,
2943
3112
  } ;
2944
3113
 
2945
3114
  export const DEVICE_EVENT_TYPES = Object.keys(EVENT_BODY_SPECS) ;
2946
3115
 
2947
3116
  /** The one device event about the computer as a whole; every other names a session. */
2948
- export const DEVICE_SCOPED_EVENTS = new Set (["device.inventory", "project.created", "preview.targets", "preview.image", "preview.rendered", "release.updated", "release.page", "pipeline.updated", "agents.active"]);
3117
+ export const DEVICE_SCOPED_EVENTS = new Set (["device.inventory", "project.created", "preview.targets", "preview.image", "preview.rendered", "release.updated", "release.page", "pipeline.updated", "agents.active", "device.health"]);
2949
3118
  /** Events that answer one command, so their envelope names it (command_id is required). */
2950
- export const COMMAND_RECEIPT_EVENTS = new Set ([
2951
- "command.device_received",
2952
- "command.agent_accepted",
2953
- "command.rejected",
2954
- "command.queued",
2955
- ]);
3119
+ export const COMMAND_RECEIPT_EVENTS = new Set (["command.device_received", "command.agent_accepted", "command.rejected", "command.queued"]);
2956
3120
 
2957
3121
  export const isDeviceEventType = (value ) =>
2958
3122
  typeof value === "string" && Object.hasOwn(EVENT_BODY_SPECS, value);
@@ -3004,6 +3168,10 @@ export function validateEventBody (type , value
3004
3168
  const bad = agentsActiveRule(checked.value );
3005
3169
  if (bad) return refuse("payload", `$body: ${bad}`);
3006
3170
  }
3171
+ if (type === "device.health") {
3172
+ const bad = healthRule(checked.value );
3173
+ if (bad) return refuse("payload", `$body: ${bad}`);
3174
+ }
3007
3175
  if (type === "agent.attention") {
3008
3176
  const a = validateAttention(value, "$body");
3009
3177
  if (!a.ok) return refuse("payload", a.detail);
@@ -3016,6 +3184,7 @@ export function validateEventBody (type , value
3016
3184
  }
3017
3185
  // One report per (adapter, mode) since release 19: Claude Code structured and in a terminal are two reports.
3018
3186
  if (new Set(inv.adapters.map((a) => `${a.adapter}/${a.mode}`)).size !== inv.adapters.length) return refuse("payload", "$body.adapters: an adapter twice");
3187
+ { const desk = deskRule(inv.desk_sessions, inv.projects); if (desk) return refuse("payload", `$body.desk_sessions: ${desk}`); }
3019
3188
  }
3020
3189
  return checked;
3021
3190
  }
@@ -3100,9 +3269,12 @@ export const COMMAND_ENVELOPE_SPEC = object({
3100
3269
  * So the stream stays gap-free for every phone, whoever followed. Only the types below may take the lane.
3101
3270
  */
3102
3271
  export const EVENT_LANES = ["transient"] ;
3103
- export const TRANSIENT_EVENT_TYPES = new Set (["agent.screen", "preview.frame"]);
3104
- /** Types that may ONLY travel on the transient lane (a live preview's frames: never journaled, never replayed). */
3105
- export const TRANSIENT_ONLY_TYPES = new Set (["preview.frame"]);
3272
+ export const TRANSIENT_EVENT_TYPES = new Set (["agent.screen", "preview.frame", "device.health"]);
3273
+ /**
3274
+ * Types that may ONLY travel on the transient lane (a live preview's frames: never journaled, never replayed), and the
3275
+ * computer's health (health.ts, 2026-11-15): device-wide, so its lane is the device stream's, with its own rising number.
3276
+ */
3277
+ export const TRANSIENT_ONLY_TYPES = new Set (["preview.frame", "device.health"]);
3106
3278
  export const isTransientEvent = (e ) => e.lane === "transient";
3107
3279
 
3108
3280
  export const EVENT_ENVELOPE_SPEC = object({
@@ -3243,9 +3415,10 @@ export function validateEventEnvelope(value ) {
3243
3415
  if (!COMMAND_RECEIPT_EVENTS.has(type) && DEVICE_SCOPED_EVENTS.has(type) !== (e.session_id === null))
3244
3416
  return refuse("shape", "$event.session_id: a session event names a session, a device event none");
3245
3417
  if (COMMAND_RECEIPT_EVENTS.has(type) && e.command_id === null) return refuse("shape", "$event.command_id: a receipt names its command");
3246
- if (isTransientEvent(e) && (!TRANSIENT_EVENT_TYPES.has(type) || e.command_id !== null || e.session_id === null || e.notify !== "none"))
3247
- return refuse("shape", "$event.lane: only a pushed screen or frame, of a session, without a command or a push hint, is transient");
3248
- if (TRANSIENT_ONLY_TYPES.has(type) && !isTransientEvent(e)) return refuse("shape", "$event.lane: a live preview's frame travels on the transient lane only");
3418
+ // A session's screen or frame names its session; the computer's health names none (DEVICE_SCOPED_EVENTS, checked above).
3419
+ if (isTransientEvent(e) && (!TRANSIENT_EVENT_TYPES.has(type) || e.command_id !== null || (e.session_id === null) !== DEVICE_SCOPED_EVENTS.has(type) || e.notify !== "none"))
3420
+ return refuse("shape", "$event.lane: only a pushed screen or frame of a session, or the computer's health, without a command or a push hint, is transient");
3421
+ if (TRANSIENT_ONLY_TYPES.has(type) && !isTransientEvent(e)) return refuse("shape", "$event.lane: a live preview's frame and the computer's health travel on the transient lane only");
3249
3422
  return checked;
3250
3423
  }
3251
3424
 
package/remote-run.mjs CHANGED
@@ -15,7 +15,7 @@ import { fileURLToPath } from "node:url";
15
15
  import * as P from "./remote-protocol.mjs";
16
16
  import { loadPreviewGrants, loadRoots } from "./remote-store.mjs";
17
17
  import { sessionProjects } from "./remote-projects.mjs";
18
- import { ensureRemoteDir, gatewayOf, issuerKeys, loadDeskMarks, loadIdentity, loadKeys, loadPipelineReviews, loadProjects, loadSettings, readJson, remotePath, random, saveIdentity } from "./remote-store.mjs";
18
+ import { ensureRemoteDir, gatewayOf, isLoopbackGateway, issuerKeys, loadDeskMarks, loadIdentity, loadKeys, loadPipelineReviews, loadProjects, loadSettings, readJson, remotePath, random, saveIdentity } from "./remote-store.mjs";
19
19
  import { openJournal } from "./remote-journal.mjs";
20
20
  import { inventory as listAgents, offered } from "./remote-inventory.mjs";
21
21
 
@@ -34,7 +34,9 @@ import { createLivePreview } from "./remote-live-preview.mjs";
34
34
  import { SETTING_WORDS } from "./remote-admin.mjs";
35
35
  import { appendPipelineMark } from "./remote-steered.mjs";
36
36
  import { createDaemonCore } from "./remote-daemon.mjs";
37
+ import { createDesk } from "./remote-desk-sessions.mjs";
37
38
  import { connectGateway, webSocketAvailable } from "./remote-transport.mjs";
39
+ import { createHealthMonitor, fixtureReaders, HEALTH_REFUSAL, healthLine, keepHealth } from "./remote-health.mjs";
38
40
 
39
41
  const HERE = dirname(fileURLToPath(import.meta.url));
40
42
  const log = (kind, fields = {}) => process.stderr.write(`${JSON.stringify({ at: new Date().toISOString(), kind, ...fields })}\n`);
@@ -42,6 +44,7 @@ const log = (kind, fields = {}) => process.stderr.write(`${JSON.stringify({ at:
42
44
  const notice = (kind, fields) => {
43
45
  if (kind === "browser_endorsed") process.stderr.write(` ! A browser was added by your phone ${fields.by}: ${fields.fingerprint}. See or remove it: npx worktrust remote phones\n`);
44
46
  // Part B: a change approved in the app or on the web with the authenticator, signed by WorkTrust and verified here.
47
+ if (kind === "session_refused") process.stderr.write(` ! A new session from a phone or browser was refused: ${HEALTH_REFUSAL}. Running sessions continue.\n`);
45
48
  if (kind === "settings_changed") process.stderr.write(` ! ${SETTING_WORDS[fields.setting] ?? "a remote setting"} changed from ${fields.by}, approved there with your authenticator. To keep every change at this keyboard: npx worktrust remote admin off\n`);
46
49
  };
47
50
  const logged = (kind, fields = {}) => { log(kind, fields); notice(kind, fields); };
@@ -135,7 +138,10 @@ export async function runDaemon({ say = (l) => process.stdout.write(`${l}\n`) }
135
138
  // The live preview (release 19): the session's granted page, live, over the browser's pipe; one per computer.
136
139
  const live = createLivePreview({ emit: (...a) => core.emit(...a), grants: loadPreviewGrants, env: () => agentEnv(loadSettings()), log, now: Date.now,
137
140
  sessionProject: (id) => { const s = journal.session(id); return s ? loadProjects().find((p) => p.project_id === s.project_id) ?? null : null; } });
138
- const core = createDaemonCore({ local, issuerKeys: keysOf, journal, projectSecret: keys.projectSecret, attachments, preview, live, now: Date.now, random, log: logged, send: (f) => transport?.send(f) ?? false, inventory: (refresh) => inventory({ env: agentEnv(loadSettings()), refresh }), online: () => transport?.ready() ?? false, approvals: null });
141
+ // Continue a session on this computer (release 36): its own Claude Code sessions in the projects a phone may reach.
142
+ const desk = createDesk({ projects: () => sessionProjects({ projects: loadProjects, roots: loadRoots, projectSecret: keys.projectSecret }), journal });
143
+ let health = null; // the sampler below (remote-health.mjs): every 15 s, local numbers, no model
144
+ const core = createDaemonCore({ local, issuerKeys: keysOf, journal, projectSecret: keys.projectSecret, attachments, preview, live, desk, now: Date.now, random, log: logged, health: () => health?.latest() ?? null, send: (f) => transport?.send(f) ?? false, inventory: (refresh) => inventory({ env: agentEnv(loadSettings()), refresh }), online: () => transport?.ready() ?? false, approvals: null });
139
145
  const ctx = { journal, now: Date.now, random, deviceId: identity.device_id, emit: core.emit, paused: () => loadSettings().paused !== null || !loadSettings().enabled, phoneOnline: core.phoneOnline, controllers: core.controllers };
140
146
  const approvals = createApprovals(ctx);
141
147
  const socket = await approvals.listen(runDir);
@@ -144,13 +150,13 @@ export async function runDaemon({ say = (l) => process.stdout.write(`${l}\n`) }
144
150
  // A session runs in a granted project or in an existing project inside a root (0.11.7), each by the inventory's id.
145
151
  settings: loadSettings, projects: () => sessionProjects({ projects: loadProjects, roots: loadRoots, projectSecret: keys.projectSecret }), inventory: () => inventory({ env: agentEnv(loadSettings()) }), agentEnv: () => agentEnv(loadSettings()), replay: core.replay,
146
152
  onTaskEnded: (id, outcome) => releases.taskEnded(id, outcome), onActivity: () => releases?.activity(),
147
- onSessionsChanged: () => core.emit(null, "device.inventory", core.inventoryBody(false)), attachments });
153
+ onSessionsChanged: () => core.emit(null, "device.inventory", core.inventoryBody(false)), attachments, desk });
148
154
  ctx.onApprovalOpened = sessions.onApprovalOpened; ctx.onApprovalSettled = sessions.onApprovalSettled;
149
155
  // Terminal sessions (release 19, off until `worktrust remote terminal on`): Claude Code in tmux on WorkTrust's own socket.
150
156
  const tmuxFile = listAgents({ env: agentEnv(loadSettings()) }).files.tmux;
151
157
  const tmux = tmuxFile ? createTmux({ file: tmuxFile, config: writeTmuxConfig(runDir), env: agentEnv(loadSettings()) }) : NO_TMUX;
152
158
  const terminal = createTerminalSessions({ journal, now: Date.now, emit: core.emit, settings: loadSettings, projects: loadProjects, inventory: () => inventory({ env: agentEnv(loadSettings()) }),
153
- tmux, claudeFile: () => listAgents({ env: agentEnv(loadSettings()) }).files["claude-code"], replay: core.replay, running: () => sessions.runningCount(), detect: (lines) => detectScreen("claude-code", lines), approvals,
159
+ tmux, claudeFile: () => listAgents({ env: agentEnv(loadSettings()) }).files["claude-code"], replay: core.replay, running: () => sessions.runningCount(), detect: (lines) => detectScreen("claude-code", lines), approvals, desk,
154
160
  onSessionsChanged: () => core.emit(null, "device.inventory", core.inventoryBody(false)) });
155
161
  const registry = withTerminal(sessions, terminal);
156
162
  // Releases and pipelines (2026-11-07): one queue for every release's tasks, the reviewed pipeline of each project.
@@ -168,8 +174,22 @@ export async function runDaemon({ say = (l) => process.stdout.write(`${l}\n`) }
168
174
  if (frame.frame === "hello") core.receiveHello(frame.hello);
169
175
  else if (frame.frame === "command") await core.receiveCommand(frame.envelope);
170
176
  else if (frame.frame === "relay") { log("relay", { type: frame.event?.type ?? null }); if (frame.event?.type === "device.revoked") core.peerRevoked(frame.event); }
171
- else if (frame.frame === "error") log("gateway_error", { reason: typeof frame.reason === "string" ? frame.reason.slice(0, 40) : null });
177
+ else if (frame.frame === "error") {
178
+ log("gateway_error", { reason: typeof frame.reason === "string" ? frame.reason.slice(0, 40) : null });
179
+ // A gateway older than device.health answers it `error: shape` (and closes nothing): rest the samples half an hour.
180
+ if (frame.reason === "shape" && Date.now() - healthSentAt < 5000) { healthRestUntil = Date.now() + 30 * 60_000; log("health_rested", { minutes: 30 }); }
181
+ }
172
182
  };
183
+ // THE COMPUTER'S HEALTH (2026-11-15): kept here for `remote status` and the menu, said in the run terminal when it turns
184
+ // red or back, and sealed for the paired phones and browsers on the transient lane (the gateway keeps none of it).
185
+ let healthSentAt = 0, healthRestUntil = 0, healthSaid = null;
186
+ const healthFixture = isLoopbackGateway(gateway) ? process.env.WORKTRUST_REMOTE_HEALTH_FIXTURE ?? null : null; // tests on the dev relay only
187
+ health = createHealthMonitor({ log, ...(healthFixture ? fixtureReaders(healthFixture) : {}), onSample: (body) => {
188
+ keepHealth(body);
189
+ if (body.level !== healthSaid && (body.level === "red" || healthSaid === "red")) process.stderr.write(`${healthLine(body)}\n`);
190
+ healthSaid = body.level;
191
+ if (Date.now() >= healthRestUntil && transport?.ready()) { healthSentAt = Date.now(); core.emitHealth(body); }
192
+ } });
173
193
  let sentCode = null;
174
194
  const registerCode = (again = false) => {
175
195
  const invite = readJson("invite.json");
@@ -186,6 +206,7 @@ export async function runDaemon({ say = (l) => process.stdout.write(`${l}\n`) }
186
206
  if (stopping) return;
187
207
  stopping = true;
188
208
  approvals.close();
209
+ health.stop();
189
210
  await pipelines.stopAll();
190
211
  await live.stopAll(); // the browser ended, its profile removed
191
212
  await registry.stopAll(); // the structured agents; a terminal session lives on in tmux
@@ -202,5 +223,6 @@ export async function runDaemon({ say = (l) => process.stdout.write(`${l}\n`) }
202
223
  const grantsChanged = () => { const now = [...loadRoots().map((r) => r.root_id), "|", ...loadProjects().map((p) => p.project_id)].join(","); const changed = grants !== null && now !== grants; grants = now; return changed; };
203
224
  setInterval(() => { const s = loadSettings(); if (!s.enabled) stop(0); registerCode(); releases.poll(); try { if (grantsChanged()) core.emit(null, "device.inventory", core.inventoryBody(false)); } catch { /* an unreadable list: told at the next ask */ } }, 3000).unref();
204
225
  releases.schedule(); // queued tasks a restart kept
226
+ health.start();
205
227
  return new Promise(() => {});
206
228
  }
@@ -32,7 +32,6 @@ const LEDGER_EVERY_MS = 10 * 60_000;
32
32
  /** Per agent: the shape of its own session id (a resume names one), and a fresh stream state. */
33
33
  const AGENT_ID = { "claude-code": isClaudeSessionId, codex: isCodexThreadId, opencode: isOpenCodeSessionId };
34
34
  const FRESH_STATE = { "claude-code": emptyClaudeState, codex: emptyCodexState, opencode: emptyOpenCodeState };
35
-
36
35
  export { createCoalescer } from "./remote-coalesce.mjs"; // kept here for the modules that import it from sessions
37
36
 
38
37
  export function createSessions(ctx) {
@@ -216,9 +215,10 @@ export function createSessions(ctx) {
216
215
  const refused = P.checkStart(payload, adapterOf(ctx.inventory(), payload.adapter)); if (refused) return refused;
217
216
  const choice = startChoice(payload, project.project_id, ctx.inventory(), ctx.settings(), known); if (typeof choice === "string") return choice;
218
217
  if (!AGENT_ID[payload.adapter] || (payload.resume !== null && !AGENT_ID[payload.adapter](payload.resume))) return "unsupported";
218
+ const desk = payload.resume !== null && env.task !== true ? (ctx.desk ? ctx.desk.resumable(payload.resume, project.project_id) : "not_found") : null; if (desk) return desk; // release 36: only a session of the computer's own list, free
219
219
  if (deskGranted(payload.adapter, project.path)) return "not_allowed"; // S0: Codex's own allow rules cannot be denied per session
220
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,
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](),
221
+ agent_ref: payload.resume ?? (payload.adapter === "codex" ? null : payload.adapter === "opencode" ? mintOpenCodeSessionId(ctx.now(), ctx.random) : randomUUID()), how: payload.resume !== null && env.task !== true ? "attached" : "started", first: ctx.now(), queue: [], state: FRESH_STATE[payload.adapter](),
222
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
223
  agentMode: payload.agent_mode ?? null, effort: choice.effort, extraIds: choice.extraProjectIds, extraPaths: choice.extras.map((p) => p.path) };
224
224
  live.set(s.session_id, s);
@@ -58,7 +58,8 @@ export function startChoice(payload, projectId, inventory, settings, known) {
58
58
  /**
59
59
  * The one door for a settings change. `change`: { what: "modes", allow|deny: "edit"|"auto" } | { what: "roots", add: dir,
60
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).
61
+ * { what: "admin", on: boolean } | { what: "endorse", on: boolean } (both this keyboard only) | { what: "connections", remove:
62
+ * fingerprint } (resolved from the app's change only).
62
63
  * `source`: { kind: "keyboard" }, or { kind: "admin", proof, issuerKeys, claims, now, via } (part B; its change is
63
64
  * crypto/admin.ts's ADMIN_CHANGE_SPEC, resolved by id before it reaches the rules below).
64
65
  * → { ok: true, message, paths?, setting? } or { ok: false, reason, code? } (code: the protocol's reject reason).
@@ -94,6 +95,13 @@ function applyRules(change, fromApp) {
94
95
  const n = removePhones([String(change.remove ?? "")]);
95
96
  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
  }
98
+ if (change?.what === "endorse") {
99
+ // May a phone confirmed here add a browser it scanned (remote-endorse.mjs)? This keyboard only, like the admin switch.
100
+ if (fromApp) return refused("whether phones may add a browser changes at this keyboard only");
101
+ if (typeof change.on !== "boolean") return refused("on or off");
102
+ saveSettings({ ...settings, allow_endorse: change.on });
103
+ return { ok: true, message: change.on ? "Your confirmed phones may add a browser. Each one is listed here with the phone that added it." : "No phone may add a browser. Browsers already added stay until you remove them." };
104
+ }
97
105
  if (change?.what === "admin") {
98
106
  if (fromApp) return refused("the admin switch changes at this keyboard only");
99
107
  if (typeof change.on !== "boolean") return refused("on or off");
@@ -189,3 +197,43 @@ export async function askMacFolderAccess(io, paths) {
189
197
  io.say(` then turn on ${guarded.join(" and ")} for "node" (or "python"); or add that program under Full Disk Access.`);
190
198
  return false;
191
199
  }
200
+
201
+ /**
202
+ * TWO MORE QUESTIONS WHEN A PHONE HAS LINKED (CLI 0.11.14, owner 2026-11-16), after its reach (remote-connections.mjs
203
+ * reachStep): may the confirmed phones add a browser, and which agent modes may a phone start here. Both are the settings
204
+ * that exist, changed through `apply` (the keyboard's one door, applySettingsChange): `endorse` is what `remote phones
205
+ * allow-endorse on|off` writes, the ceiling what `remote modes allow|deny` writes. Both answers are taken first and only
206
+ * then applied, so Ctrl+C or Esc at either question changes nothing. Without a terminal the commands are named.
207
+ */
208
+ export const CEILINGS = Object.freeze([
209
+ { value: "plan", label: "Manual and Plan", info: "The agent asks before every change, or only reads and plans." },
210
+ { value: "edit", label: "+ Edit automatically", info: "Also sessions that edit in their projects without asking." },
211
+ { value: "auto", label: "+ Auto", info: "Also the agent's own automatic mode (it allows edit too)." },
212
+ ]);
213
+ /** The ceiling a list of allowed modes is: plan, edit or auto. */
214
+ export const ceilingOf = (allowed) => (allowed.includes("auto") ? "auto" : allowed.includes("edit") ? "edit" : "plan");
215
+ /** The `modes` changes that move the ceiling from one step to another (none when it stays). */
216
+ export function ceilingChanges(from, to) {
217
+ if (from === to) return [];
218
+ if (to === "plan") return [{ what: "modes", deny: "edit" }];
219
+ if (to === "auto") return [{ what: "modes", allow: "auto" }];
220
+ return from === "auto" ? [{ what: "modes", deny: "auto" }] : [{ what: "modes", allow: "edit" }];
221
+ }
222
+ const nowMark = (on) => (on ? { note: { text: "now", tone: "dim" } } : {});
223
+ export async function trustStep(io, { apply, interactive, term = null, choose = null, settings = loadSettings() }) {
224
+ const endorse = settings.allow_endorse === true, ceiling = ceilingOf(allowedModes(settings));
225
+ if (!interactive || !term || !choose) { io.say(" Later: npx worktrust remote phones allow-endorse on|off and npx worktrust remote modes allow|deny edit|auto"); return "later"; }
226
+ term.enter();
227
+ try {
228
+ const asked = await choose(term, { title: "May your confirmed phones add a browser?", items: [
229
+ { label: "Yes, they may add a browser", info: "A phone confirmed here may add a browser it scanned.", value: true, ...nowMark(endorse) },
230
+ { label: "No", info: "Only this keyboard adds a browser.", value: false, ...nowMark(!endorse) }] });
231
+ const modes = asked === "quit" || asked === "back" ? asked : await choose(term, { title: "Which agent modes may a phone start here?", items: CEILINGS.map((c) => ({ ...c, ...nowMark(c.value === ceiling) })) });
232
+ term.erase(); term.restore();
233
+ if (modes === "quit" || modes === "back") { io.say(" Unchanged. Later: npx worktrust remote phones allow-endorse on|off · npx worktrust remote modes"); return "unchanged"; }
234
+ const changes = [...(asked.item.value === endorse ? [] : [{ what: "endorse", on: asked.item.value }]), ...ceilingChanges(ceiling, modes.item.value)];
235
+ for (const change of changes) await apply(change);
236
+ if (changes.length === 0) io.say(" ✓ Unchanged: these were already your settings.");
237
+ return "set";
238
+ } finally { term.restore(); }
239
+ }
@@ -85,6 +85,7 @@ export function createTerminalSessions(ctx) {
85
85
  const project = ctx.projects().find((p) => p.project_id === env.project_id);
86
86
  if (!project) return "not_found";
87
87
  if (payload.resume !== null && !UUID.test(payload.resume)) return "unsupported";
88
+ const held = payload.resume !== null ? (ctx.desk ? ctx.desk.resumable(payload.resume, project.project_id) : "not_found") : null; if (held) return held; // release 36: the computer's own list, free
88
89
  const s = sessionOf({ session_id: env.session_id, project_id: project.project_id, projectPath: project.path, name: payload.name ?? null, model: payload.model, origin: "phone", how: "started",
89
90
  tmux: tmuxNameOf(env.session_id), agent_ref: payload.resume ?? randomUUID(), command_id: env.command_id });
90
91
  let argv;
package/worktrust.mjs CHANGED
@@ -83,7 +83,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
83
83
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
84
84
  const has = (name) => args.includes(`--${name}`);
85
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). */
86
- const CLI_VERSION = "0.11.12";
86
+ const CLI_VERSION = "0.11.14";
87
87
  /**
88
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
89
89
  * to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
@@ -119,7 +119,7 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
119
119
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
120
120
  const HOME_DIR = join(homedir(), ".worktrust");
121
121
  const HERE = dirname(fileURLToPath(import.meta.url));
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-stop.mjs", "cli-look.mjs", "node-guide.mjs", "remote-countdown.mjs", "remote-connections.mjs", "remote-admin.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "credential-decoy.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"];
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-desk-sessions.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-stop.mjs", "cli-look.mjs", "node-guide.mjs", "remote-countdown.mjs", "remote-connections.mjs", "remote-admin.mjs", "remote-health.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "credential-decoy.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"];
123
123
  /** The modules the scripts import by name from beside them; a download keeps that name. */
124
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"]);
125
125
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);