clearotron 0.5.0 → 0.5.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/INSTALL.md +334 -302
  3. package/QUICKSTART.md +12 -4
  4. package/README.md +12 -7
  5. package/THIRD-PARTY-NOTICES.md +4 -4
  6. package/bin/README.md +14 -11
  7. package/bin/clearotron.mjs +1 -1
  8. package/bin/connect.mjs +73 -25
  9. package/bin/example.mjs +4 -2
  10. package/bin/onboard.mjs +562 -336
  11. package/bin/start.mjs +184 -36
  12. package/bin/update.mjs +26 -13
  13. package/build-info.json +2 -2
  14. package/docs/PORTAL.md +2 -2
  15. package/docs/architecture/02-architecture.md +3 -3
  16. package/docs/architecture/04-configuration-reference.md +1 -2
  17. package/docs/architecture/05-config-governance.md +1 -1
  18. package/docs/architecture/06-operations-runbook.md +1 -1
  19. package/driver/CHANGELOG.md +77 -0
  20. package/driver/README.md +2 -2
  21. package/driver/config-inventory.mjs +20 -11
  22. package/driver/contract-e3-backlog.mjs +27 -27
  23. package/driver/contract-e3-baseline.json +2 -2
  24. package/driver/contract-vocabulary.mjs +1 -1
  25. package/driver/degraded-parts.mjs +67 -3
  26. package/driver/dev-portal.mjs +1 -1
  27. package/driver/digest-queue.mjs +5 -5
  28. package/driver/driver.config.mjs +9 -9
  29. package/driver/engine/CONTRACT.md +1 -1
  30. package/driver/engine/anthropic-agent.mjs +4 -2
  31. package/driver/engine/mcp/band-server.mjs +1 -21
  32. package/driver/engine/mcp/clarivate-propose-tool.mjs +26 -0
  33. package/driver/engine/mcp/clarivate-server.mjs +2 -18
  34. package/driver/engine/mcp/fixture-register-server.mjs +33 -0
  35. package/driver/engine/mcp/gather-config.mjs +48 -7
  36. package/driver/engine/mcp/recording-server.mjs +206 -14
  37. package/driver/engine/mcp/supplemental.mjs +4 -2
  38. package/driver/engine/openai-agent.mjs +3 -1
  39. package/driver/engine/probe.mjs +10 -0
  40. package/driver/filing-goods.mjs +95 -0
  41. package/driver/findings-model.mjs +3 -0
  42. package/driver/gateway.mjs +42 -40
  43. package/driver/knockout-assess-record.mjs +54 -4
  44. package/driver/knockout-correction-record.mjs +342 -0
  45. package/driver/knockout-frame-record.mjs +4 -2
  46. package/driver/knockout-register-read.mjs +705 -0
  47. package/driver/knockout-register-record.mjs +222 -0
  48. package/driver/knockout-review-record.mjs +96 -25
  49. package/driver/narrative-refutation-record.mjs +87 -1
  50. package/driver/order-tables.mjs +23 -0
  51. package/driver/owner-use-check.mjs +5 -2
  52. package/driver/package.json +1 -1
  53. package/driver/partial-payload-baseline.json +8 -0
  54. package/driver/pipeline-knockout.mjs +506 -313
  55. package/driver/pipeline.mjs +179 -86
  56. package/driver/portal-local-auth.mjs +7 -1
  57. package/driver/portal-service.mjs +62 -6
  58. package/driver/progress.mjs +2 -2
  59. package/driver/publish/index.mjs +18 -21
  60. package/driver/publish/knockout.mjs +40 -18
  61. package/driver/publish/render-knockout.mjs +40 -27
  62. package/driver/publish/report-dates.mjs +43 -0
  63. package/driver/recall-reconciliation.mjs +2 -2
  64. package/driver/record-goods.mjs +50 -9
  65. package/driver/register-count.mjs +12 -59
  66. package/driver/register-fixture-marker.mjs +22 -0
  67. package/driver/register-plan.mjs +48 -0
  68. package/driver/register-records.mjs +84 -266
  69. package/driver/register-taint.mjs +2 -2
  70. package/driver/repair-composers.mjs +15 -8
  71. package/driver/result-noun-fields.mjs +6 -2
  72. package/driver/run-requirements.mjs +54 -4
  73. package/driver/runner.mjs +4 -13
  74. package/driver/skills/clearance-register/providers/clarivate.md +2 -2
  75. package/driver/skills/knockout-assess/SKILL.md +101 -100
  76. package/driver/skills/knockout-frame/SKILL.md +3 -1
  77. package/driver/skills/knockout-register-read/SKILL.md +77 -0
  78. package/driver/stages-knockout.mjs +159 -98
  79. package/driver/stages.mjs +4 -2
  80. package/driver/suite-census.json +389 -71
  81. package/driver/systemd/README.md +2 -2
  82. package/driver/verify-knockout.mjs +175 -39
  83. package/driver/verify.mjs +10 -9
  84. package/mcp-server/CHANGELOG.md +4 -0
  85. package/mcp-server/CONNECT.md +4 -0
  86. package/mcp-server/demo-mode.mjs +6 -0
  87. package/mcp-server/lib/demo-texts.mjs +38 -0
  88. package/mcp-server/lib/http-handler.mjs +7 -1
  89. package/mcp-server/lib/knockout.mjs +3 -2
  90. package/mcp-server/lib/options.mjs +3 -1
  91. package/mcp-server/lib/plan.mjs +6 -1
  92. package/mcp-server/mint-token.mjs +1 -1
  93. package/mcp-server/package.json +1 -1
  94. package/mcp-server/serve.mjs +11 -0
  95. package/mcp-server/server.mjs +13 -5
  96. package/package.json +1 -1
  97. package/portal-ui/dist/assets/{index-D2wrw9cH.css → index-AtB9ZpDH.css} +29 -0
  98. package/portal-ui/dist/assets/{index-DcLbvFmQ.js → index-C1oE78Wk.js} +161 -195
  99. package/portal-ui/dist/index.html +2 -2
  100. package/portal-ui/package.json +4 -4
  101. package/providers/README.md +4 -4
  102. package/providers/_shared/execute-plan.mjs +45 -1
  103. package/providers/_shared/term-shape.mjs +1 -1
  104. package/providers/clarivate/src/capabilities.js +7 -6
  105. package/providers/clarivate/src/core.js +11 -7
  106. package/providers/clarivate/src/wider-list.js +104 -0
  107. package/providers/oauth-mcp-bridge/CHANGELOG.md +4 -0
  108. package/providers/oauth-mcp-bridge/package.json +1 -1
  109. package/providers/signa/src/capabilities.js +0 -9
  110. package/scripts/e2e-first-time.mjs +8 -7
  111. package/scripts/freeze-example-run.mjs +2 -2
  112. package/scripts/settings-render-check.mjs +5 -3
  113. package/scripts/test-run.mjs +8 -2
  114. package/shared/client-door.mjs +11 -8
  115. package/shared/connect-clients.mjs +10 -4
  116. package/shared/demo-connection.mjs +43 -0
  117. package/shared/demo-start-args.mjs +7 -2
  118. package/shared/invocation.mjs +18 -3
  119. package/shared/permanent-install.mjs +14 -0
  120. package/shared/scope.mjs +8 -1
  121. package/shared/stdio-connect.mjs +43 -21
  122. package/shared/trigger-lane.mjs +7 -0
  123. package/shared/tty-style.mjs +21 -5
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Copyright 2026 Cordillera Sàrl. Additional terms under section 7 of the AGPL-3.0 apply — see ADDITIONAL-TERMS.md
3
+ //
4
+ // demo-connection.mjs — a connection a demo printed stays with that demo.
5
+ //
6
+ // The connect line names the demo's workspace and CLEAROTRON_DEMO=1, and nothing else. The assistant starts the
7
+ // server with that line, long after the demo's supervisor, so this server is nobody's child: left alone it would read
8
+ // the machine's settings file and fall back to the real install's queue, stores and access log. So the rest of the
9
+ // layout is pinned here to the demo's own folder, exactly as `clearotron start --demo` pins it for the doors (childEnv
10
+ // in bin/start.mjs), and the settings file is not read. A demo that has been removed has nothing to serve, so the
11
+ // server refuses, and the real install on this machine is never offered in its place.
12
+ import { existsSync } from "node:fs";
13
+ import { dirname, join } from "node:path";
14
+
15
+ /**
16
+ * Applies the pins to `env`, or returns the sentence to refuse with when the demo is gone. `null` once bound.
17
+ * Run before the server loads: its modules read these settings as they load.
18
+ */
19
+ export function bindDemoConnection(env = process.env, exists = existsSync) {
20
+ const work = String(env.CLEAROTRON_WORK_DIR ?? "").trim();
21
+ if (!work || !exists(work)) {
22
+ return `the demo this connection belongs to is gone${work ? ` (${work})` : ""}. Remove this connection, or start a new demo and use the line it prints.`;
23
+ }
24
+ const base = dirname(work);
25
+ Object.assign(env, {
26
+ CLEAROTRON_NO_ENV_FILE: "1",
27
+ CLEAROTRON_REPORTS_DIR: String(env.CLEAROTRON_REPORTS_DIR ?? "").trim() || join(base, "pool"),
28
+ CLEAROTRON_QUEUE_DIR: join(base, "queue"),
29
+ CLEAROTRON_OUTBOX_DIR: join(base, "outbox"),
30
+ CLEAROTRON_RUN_LOCK_DIR: join(base, "locks"),
31
+ CLEAROTRON_ACCESS_FILE: join(base, "grants.json"),
32
+ CLEAROTRON_RECIPES_DIR: join(base, "config", "recipes"),
33
+ RECIPE_REPO_ROOT: join(base, "config"),
34
+ CLEAROTRON_CUSTOMERS_DIR: join(base, "config", "profiles"),
35
+ CLEAROTRON_INSTRUCTIONS_DIR: "",
36
+ PROFILE_REPO_ROOT: join(base, "config"),
37
+ PROFILE_AUDIT: "",
38
+ RECIPE_AUDIT: "",
39
+ CLEAROTRON_FEEDBACK_DIR: "",
40
+ TRADEMARK_MCP_AUDIT_LOG: join(base, "telemetry", "trademark-mcp-access.jsonl"),
41
+ });
42
+ return null;
43
+ }
@@ -11,6 +11,11 @@
11
11
  * before the supervisor starts. So whether the READER chose it has to travel separately:
12
12
  * `--demo-own-base` says it is the demo's default, which is what lets the supervisor remove the folder
13
13
  * when the window closes. `--keep` is the reader's, and it travels as given.
14
+ *
15
+ * A FOLDER THAT WAS THERE BEFORE THIS DEMO IS NOT ITS TO REMOVE. `demo --once` and `demo --keep` both
16
+ * leave the default folder behind and say so, and a later plain `demo` published into it and then
17
+ * removed it on exit, reports and all. `baseExisted` is read before the launcher makes anything, and
18
+ * such a folder is handed over as the reader's: kept, with the line that says how to remove it.
14
19
  */
15
20
  /**
16
21
  * The Node flag the demo runs under, so Node's one-time warning that its built-in SQLite is experimental
@@ -22,9 +27,9 @@ export const EXPERIMENTAL_WARNING_OFF = "--disable-warning=ExperimentalWarning";
22
27
  /** The same flag added to whatever NODE_OPTIONS the reader already has, which is kept. PURE. */
23
28
  export const withWarningOff = (nodeOptions) => [nodeOptions, EXPERIMENTAL_WARNING_OFF].filter(Boolean).join(" ");
24
29
 
25
- export function demoStartArgs({ demoBase, readerBase = false, keep = false, port = null, noOpen = false } = {}) {
30
+ export function demoStartArgs({ demoBase, readerBase = false, baseExisted = false, keep = false, port = null, noOpen = false } = {}) {
26
31
  const args = ["--demo", "--base", demoBase];
27
- if (!readerBase) args.push("--demo-own-base");
32
+ if (!readerBase && !baseExisted) args.push("--demo-own-base");
28
33
  if (keep) args.push("--keep");
29
34
  if (port) args.push("--port", String(port));
30
35
  if (noOpen) args.push("--no-open");
@@ -37,7 +37,7 @@
37
37
  // earlier on PATH demotes the bare form rather than confirming it. Identity, not availability. A later
38
38
  // sweep tempted to simplify this into `command -v` would be reintroducing the defect, not tidying it.
39
39
  import { existsSync, readFileSync } from "node:fs";
40
- import { basename, join, sep } from "node:path";
40
+ import { basename, delimiter, join, sep } from "node:path";
41
41
  import { INSTALL_DIR, inspectShim, pathPosition, shimDir, shimPath } from "./verb-shim.mjs";
42
42
  import { chdirPrefix } from "./os-advice.mjs";
43
43
 
@@ -165,6 +165,21 @@ export function globalBinDirFrom(dir, platform = process.platform) {
165
165
  return `${s.slice(0, -tail.length)}${sep}bin`;
166
166
  }
167
167
 
168
+ /**
169
+ * The environment with npx's own folders taken off its PATH, for asking what the reader's shell finds.
170
+ *
171
+ * npx puts the bin folder of the copy it fetched, `<npm's cache>/_npx/<id>/node_modules/.bin`, first on the
172
+ * PATH of the process it starts, and that folder holds a `clearotron`. The install moved out of the cache
173
+ * runs as that process's child and inherits the same PATH, so the copy npx fetched read as "a different
174
+ * `clearotron` earlier on your PATH" on every install run through npx. No shell the reader types in has
175
+ * that folder on its PATH, so it shadows nothing they will type. Every other folder is kept: a
176
+ * `clearotron` the reader's own PATH finds first is still reported.
177
+ */
178
+ function readerEnv(env) {
179
+ const path = String(env?.PATH ?? "");
180
+ return { ...env, PATH: path.split(delimiter).filter((d) => !/[\\/]_npx[\\/]/.test(d)).join(delimiter) };
181
+ }
182
+
168
183
  export function invocationForm(env = process.env, io = FS, installDir = INSTALL_DIR) {
169
184
  const dir = shimDir(env);
170
185
  const path = shimPath(env);
@@ -176,7 +191,7 @@ export function invocationForm(env = process.env, io = FS, installDir = INSTALL_
176
191
  ? inspectShim(path, io.read ? { installDir, read: io.read } : { installDir })
177
192
  : { kind: "absent-or-unreadable", installDir: null };
178
193
  if (shim.kind === "ours" && shim.interpreterMissing !== true) {
179
- const { onPath, shadowedBy } = pathPosition(dir, env, { exists: io.exists });
194
+ const { onPath, shadowedBy } = pathPosition(dir, readerEnv(env), { exists: io.exists });
180
195
  if (onPath && !shadowedBy) {
181
196
  return { form: "bare", prefix: "", shim: path, dir, onPath: true, shadowedBy: null, staleInterpreter: null };
182
197
  }
@@ -193,7 +208,7 @@ export function invocationForm(env = process.env, io = FS, installDir = INSTALL_
193
208
  // disk would answer differently on a box that really has a global install — the reason the FS note at
194
209
  // the top of this file gives for injecting both halves.
195
210
  if (globalExe && shim.kind !== "ours" && io.exists(globalExe)) {
196
- const { onPath, shadowedBy } = pathPosition(globalDir, env, { exists: io.exists });
211
+ const { onPath, shadowedBy } = pathPosition(globalDir, readerEnv(env), { exists: io.exists });
197
212
  if (onPath && !shadowedBy) {
198
213
  return { form: "bare", prefix: "", shim: globalExe, dir: globalDir, onPath: true, shadowedBy: null, staleInterpreter: null, via: "global" };
199
214
  }
@@ -19,6 +19,7 @@ import { existsSync, readFileSync } from "node:fs";
19
19
  import { join, dirname } from "node:path";
20
20
  import { fileURLToPath } from "node:url";
21
21
  import { globalBinDirFrom } from "./invocation.mjs";
22
+ import { chdirPrefix } from "./os-advice.mjs";
22
23
 
23
24
  /** The root of THIS install — `<root>/shared/permanent-install.mjs` is this file. */
24
25
  export const INSTALL_DIR = dirname(dirname(fileURLToPath(import.meta.url)));
@@ -154,6 +155,19 @@ export function packagedUpdate({ installDir = INSTALL_DIR, version = ownVersion(
154
155
  };
155
156
  }
156
157
 
158
+ /**
159
+ * The npm command a reader runs to update a package install `packagedUpdate` cannot name: Windows, npx's
160
+ * cache or a project's own `node_modules`. On the channel the install came from, so a beta stays a beta,
161
+ * and in the project's folder for a project install, because a global install would leave that copy behind.
162
+ */
163
+ export function packagedUpdateCommand({ installDir = INSTALL_DIR, version = ownVersion(installDir), exists = existsSync, platform = process.platform } = {}) {
164
+ const spec = `clearotron@${channelOf(version)}`;
165
+ const owner = dirname(dirname(installDir));
166
+ return !inNpxCache(installDir) && exists(join(owner, "package.json"))
167
+ ? `${chdirPrefix(owner, { platform })}npm install ${spec}`
168
+ : `npm install -g ${spec}`;
169
+ }
170
+
157
171
  /**
158
172
  * The install root a connect line should name. The running root, unless that is npx's cache and the
159
173
  * permanent install exists, in which case the permanent one: an assistant registered against the cache
package/shared/scope.mjs CHANGED
@@ -1149,8 +1149,15 @@ export function authorize(scope, toolName, args = {}) {
1149
1149
  // account session returns above it, so what-if is visible to a client — and what stops the client face
1150
1150
  // shelling is not this listing but what_if_run's own shape: for an account it ENQUEUES (server.mjs) and
1151
1151
  // the engine is spawned by driver/whatif-worker.mjs, in a service process, exactly as a clearance is.
1152
- export function visibleTools({ kind = "internal", local = false } = {}) {
1152
+ //
1153
+ // A DEMO OFFERS NONE OF THE TOOLS THAT START WORK, to anybody. It answers from the reports it holds, and a tool
1154
+ // request must reach no model, register or paid search: `what_if_run` shells the engine, and `start_run` would
1155
+ // queue a search nothing is there to run. The listing is the wall (server.mjs), so no sentence is needed for it.
1156
+ // `what_if_result` goes with them: it collects what `what_if_run` made, and a demo holds no experiment to collect.
1157
+ export const DEMO_WITHHELD_TOOLS = Object.freeze(["start_run", "what_if_plan", "what_if_run", "what_if_result"]);
1158
+ export function visibleTools({ kind = "internal", local = false, demo = false } = {}) {
1153
1159
  return (name) => {
1160
+ if (demo && DEMO_WITHHELD_TOOLS.includes(name)) return false;
1154
1161
  const rule = TOOL_SCOPES[name] ?? {};
1155
1162
  const isWhatIf = name === "what_if_plan" || name === "what_if_run";
1156
1163
  if (kind === "user") return !!rule.clientSafe; // report-link token: plain client layer only
@@ -40,6 +40,13 @@ export const INSTALL_ROOT = join(fileURLToPath(new URL(".", import.meta.url)), "
40
40
  /** The name the server registers under. One spelling, because `claude mcp remove` needs the same one. */
41
41
  export const STDIO_SERVER_NAME = "trademark-artifacts";
42
42
 
43
+ /**
44
+ * The name a demo's connection registers under. Its own, so registering it can neither replace a real
45
+ * install's connection on this machine nor be replaced by one, and removing it touches nothing else.
46
+ */
47
+ export const DEMO_SERVER_NAME = "trademark-artifacts-demo";
48
+ const serverName = (demo) => (demo ? DEMO_SERVER_NAME : STDIO_SERVER_NAME);
49
+
43
50
  /**
44
51
  * The one-line registration for an assistant that spawns the server locally. PURE.
45
52
  *
@@ -71,12 +78,12 @@ export function stdioConnectOffer(opts = {}) {
71
78
  return {
72
79
  command: both.text,
73
80
  variants: both.variants,
74
- name: STDIO_SERVER_NAME,
81
+ name: serverName(opts.demo),
75
82
  // Deliberately states the two facts a reader needs to judge it: no network, and it only works from a
76
83
  // machine with this install on its disk. Both are why it is offered to staff and not to a client.
77
84
  note: "Runs the connector from this install's own disk — no address, no sign-in, no network. "
78
85
  + "Only works on a machine that has this install: run it where you installed Clearotron.",
79
- verify: `claude mcp list → ${STDIO_SERVER_NAME}: … ✓ Connected`,
86
+ verify: `claude mcp list → ${serverName(opts.demo)}: … ✓ Connected`,
80
87
  };
81
88
  }
82
89
 
@@ -101,8 +108,10 @@ export function stdioConnectOffer(opts = {}) {
101
108
  * published to. Handed over rather than left to the server's own defaults, so it reads what the services
102
109
  * read: a demo's own base, not the real install's workspace. Only what is set is written.
103
110
  */
104
- function envOf({ workDir = null, reportsDir = null } = {}) {
105
- return { ...(workDir ? { CLEAROTRON_WORK_DIR: workDir } : {}), ...(reportsDir ? { CLEAROTRON_REPORTS_DIR: reportsDir } : {}) };
111
+ function envOf({ workDir = null, reportsDir = null, demo = false } = {}) {
112
+ return { ...(workDir ? { CLEAROTRON_WORK_DIR: workDir } : {}), ...(reportsDir ? { CLEAROTRON_REPORTS_DIR: reportsDir } : {}),
113
+ // A DEMO'S CONNECTION SAYS WHOSE IT IS, and the server holds it to that (shared/demo-connection.mjs).
114
+ ...(demo ? { CLEAROTRON_DEMO: "1" } : {}) };
106
115
  }
107
116
  const envBlock = (o) => (Object.keys(envOf(o)).length ? { env: envOf(o) } : {});
108
117
 
@@ -179,8 +188,8 @@ export const STDIO_ENTRY = "serve.mjs";
179
188
  export const WSL_DISTRO_PLACEHOLDER = "YOUR-WSL-DISTRIBUTION";
180
189
  export const WSL_DISTRO_FILL_IN = `Replace ${WSL_DISTRO_PLACEHOLDER} with this Linux's name before you paste it: \`wsl -l\` in Windows lists the names.`;
181
190
 
182
- export function stdioLauncher({ server, workDir = null, reportsDir = null, wsl = null, node = process.execPath } = {}) {
183
- const vars = envOf({ workDir, reportsDir });
191
+ export function stdioLauncher({ server, workDir = null, reportsDir = null, wsl = null, node = process.execPath, demo = false } = {}) {
192
+ const vars = envOf({ workDir, reportsDir, demo });
184
193
  if (!wsl) return { command: node, args: [server], env: vars, crossesIntoWsl: false };
185
194
  const distro = String(wsl.distro ?? "").trim();
186
195
  return {
@@ -202,8 +211,8 @@ export const STDIO_SHAPES = Object.freeze({
202
211
  "claude-cli": {
203
212
  kind: "command",
204
213
  where: null,
205
- render: ({ server, workDir, reportsDir, platform, wsl, node }) => {
206
- const l = stdioLauncher({ server, workDir, reportsDir, wsl, node });
214
+ render: ({ server, workDir, reportsDir, platform, wsl, node, demo }) => {
215
+ const l = stdioLauncher({ server, workDir, reportsDir, wsl, node, demo });
207
216
  // WHICH SHELL READS IT. A native Windows install's line is pasted on Windows, and so is the row
208
217
  // that crosses into WSL: it exists for an assistant on the Windows side. Everything else is pasted
209
218
  // into a POSIX shell.
@@ -213,19 +222,19 @@ export const STDIO_SHAPES = Object.freeze({
213
222
  // through the wrapper it is `wsl.exe`, and they stop at the boundary — so on WSL they ride inside
214
223
  // the command instead and this line carries none.
215
224
  const flags = l.crossesIntoWsl ? ""
216
- : Object.entries(envOf({ workDir, reportsDir })).map(([k, v]) => ` -e ${windowsShell ? word(`${k}=${v}`) : `${k}=${word(v)}`}`).join("");
217
- return `claude mcp add ${STDIO_SERVER_NAME} --scope user${flags} ${separator(windowsShell)} ${[l.command, ...l.args].map(word).join(" ")}`;
225
+ : Object.entries(envOf({ workDir, reportsDir, demo })).map(([k, v]) => ` -e ${windowsShell ? word(`${k}=${v}`) : `${k}=${word(v)}`}`).join("");
226
+ return `claude mcp add ${serverName(demo)} --scope user${flags} ${separator(windowsShell)} ${[l.command, ...l.args].map(word).join(" ")}`;
218
227
  },
219
228
  after: null,
220
229
  },
221
230
  "desktop-json": {
222
231
  kind: "config",
223
232
  where: "Settings → Developer → Edit Config",
224
- render: ({ server, workDir, reportsDir, wsl, node }) => {
225
- const l = stdioLauncher({ server, workDir, reportsDir, wsl, node });
233
+ render: ({ server, workDir, reportsDir, wsl, node, demo }) => {
234
+ const l = stdioLauncher({ server, workDir, reportsDir, wsl, node, demo });
226
235
  return JSON.stringify({
227
236
  mcpServers: {
228
- [STDIO_SERVER_NAME]: {
237
+ [serverName(demo)]: {
229
238
  command: l.command,
230
239
  args: l.args,
231
240
  ...(Object.keys(l.env).length ? { env: l.env } : {}),
@@ -240,8 +249,8 @@ export const STDIO_SHAPES = Object.freeze({
240
249
  "generic-json": {
241
250
  kind: "config",
242
251
  where: "your agent's MCP server configuration",
243
- render: ({ server, workDir, reportsDir, wsl, node }) => {
244
- const l = stdioLauncher({ server, workDir, reportsDir, wsl, node });
252
+ render: ({ server, workDir, reportsDir, wsl, node, demo }) => {
253
+ const l = stdioLauncher({ server, workDir, reportsDir, wsl, node, demo });
245
254
  return JSON.stringify({
246
255
  command: l.command,
247
256
  args: l.args,
@@ -261,10 +270,10 @@ export const STDIO_SHAPES = Object.freeze({
261
270
  // Codex does not forward the shell environment, and a credential would have to be forwarded BY NAME
262
271
  // rather than written into a file. This server takes no credential — the work directory is a path,
263
272
  // not a secret — so `env` is correct here and would not be for a server that wanted a key.
264
- render: ({ server, workDir, reportsDir, wsl, node }) => {
265
- const l = stdioLauncher({ server, workDir, reportsDir, wsl, node });
273
+ render: ({ server, workDir, reportsDir, wsl, node, demo }) => {
274
+ const l = stdioLauncher({ server, workDir, reportsDir, wsl, node, demo });
266
275
  return [
267
- `[mcp_servers.${STDIO_SERVER_NAME}]`,
276
+ `[mcp_servers.${serverName(demo)}]`,
268
277
  `command = ${tomlString(l.command)}`,
269
278
  `args = [${l.args.map(tomlString).join(", ")}]`,
270
279
  ...(Object.keys(l.env).length
@@ -387,12 +396,25 @@ export function remoteConnectFor(shape, { address = null } = {}) {
387
396
  */
388
397
  export const WSL_ROW_HEADINGS = Object.freeze({ fromWindows: "From Windows", insideWsl: "Inside WSL" });
389
398
 
390
- export function stdioConnectFor(shape, { installRoot = stableInstallRoot({ installRoot: INSTALL_ROOT }), workDir = null, reportsDir = null, platform = process.platform, wsl = null, node = process.execPath } = {}) {
399
+ /**
400
+ * A route with its program word rewritten by `name`, for a surface that knows which copy this machine runs.
401
+ *
402
+ * ONLY THE `claude-cli` SHAPE NAMES A PROGRAM. Under WSL only the row run inside Linux is rewritten: the Windows
403
+ * row runs Windows' own `claude`, and `text` stays that row's. PURE.
404
+ */
405
+ export function routeNaming(route, name) {
406
+ if (route?.shape !== "claude-cli") return route;
407
+ return route.variants
408
+ ? { ...route, variants: route.variants.map((v) => (v.heading === WSL_ROW_HEADINGS.insideWsl ? { ...v, text: name(v.text) } : v)) }
409
+ : { ...route, text: name(route.text) };
410
+ }
411
+
412
+ export function stdioConnectFor(shape, { installRoot = stableInstallRoot({ installRoot: INSTALL_ROOT }), workDir = null, reportsDir = null, platform = process.platform, wsl = null, node = process.execPath, demo = false } = {}) {
391
413
  const spec = Object.hasOwn(STDIO_SHAPES, String(shape ?? "")) ? STDIO_SHAPES[shape] : null;
392
414
  if (!spec) return null;
393
415
  const server = join(installRoot, "mcp-server", STDIO_ENTRY);
394
- const render = (target) => spec.render({ server, workDir, reportsDir, platform, wsl: target, node });
395
- const base = { shape, kind: spec.kind, where: spec.where, after: spec.after, name: STDIO_SERVER_NAME };
416
+ const render = (target) => spec.render({ server, workDir, reportsDir, platform, wsl: target, node, demo });
417
+ const base = { shape, kind: spec.kind, where: spec.where, after: spec.after, name: serverName(demo) };
396
418
  // OFF WSL NOTHING CHANGES: one launcher, no variants, and `variants: null` rather than an empty array
397
419
  // so a consumer cannot read "this install has no sides" as "this install has two sides, both missing".
398
420
  if (!wsl) return { ...base, text: render(null), variants: null };
@@ -48,6 +48,13 @@ import { challengeVerdict, blockedByAccessChallenge, challengeNote } from "./mcp
48
48
  export const HOSTED = "hosted";
49
49
  export const SUPERVISED = "supervised";
50
50
 
51
+ /**
52
+ * The header the portal's boot probe carries, so the engine door can tell its expected 401 from a caller
53
+ * that came without a key. It changes nothing the door answers: the probe reads the refusal's body to
54
+ * classify the door, so that body is the same either way. Only the door's log line differs.
55
+ */
56
+ export const BOOT_PROBE_HEADER = "x-trademark-boot-probe";
57
+
51
58
  /**
52
59
  * @param {object} a
53
60
  * @param {string|null} a.url PORTAL_MCP_URL as the portal will read it — an ORIGIN, never .../mcp
@@ -110,6 +110,17 @@ function paintRow(cells, style) {
110
110
  return out;
111
111
  }
112
112
 
113
+ // Greedy wrap at spaces into lines no wider than `width`; a word wider than that keeps a line of its own.
114
+ function wrapWords(text, width) {
115
+ const out = [];
116
+ for (const word of text.split(" ")) {
117
+ const last = out.length ? out[out.length - 1] : null;
118
+ if (last !== null && last.length + 1 + word.length <= width) out[out.length - 1] = `${last} ${word}`;
119
+ else out.push(word);
120
+ }
121
+ return out;
122
+ }
123
+
113
124
  /**
114
125
  * The entry banner. ONCE, on entry, named — not on every command (the ruling says so, and a banner on
115
126
  * every verb is how a product becomes tiresome to use twice).
@@ -124,11 +135,7 @@ function paintRow(cells, style) {
124
135
  * Sizing it from the title alone is how a mark wider than the title overflows the frame it is in.
125
136
  */
126
137
  export function banner({ title, subtitle = "", style = styleFor(), mark = null, gutter = 3, columns = Infinity } = {}) {
127
- const text = [
128
- { text: style.bold(title), width: title.length },
129
- ...(subtitle ? [{ text: style.dim(subtitle), width: subtitle.length }] : []),
130
- ];
131
- const words = Math.max(...text.map((t) => t.width));
138
+ let words = Math.max(title.length, subtitle.length);
132
139
  // The mark is the first thing to go when it does not fit. A box that wraps is worse than a box with
133
140
  // no logo in it — the owner asked to SEE the mark, and a 65-column frame folded into a 60-column pane
134
141
  // shows him neither the mark nor the sentence. `columns` defaults to Infinity so a caller that has no
@@ -137,6 +144,15 @@ export function banner({ title, subtitle = "", style = styleFor(), mark = null,
137
144
  let cells = mark ?? [];
138
145
  let markWidth = cells.length ? Math.max(...cells.map((r) => r.length)) : 0;
139
146
  if (markWidth && markWidth + gutter + words + 4 > columns) { cells = []; markWidth = 0; }
147
+ // THEN THE SUBTITLE WRAPS, at a space, when the box is still wider than the pane without the mark. The setup
148
+ // banner's subtitle names the one answer that cannot be skipped, which made its plain box 75 columns, and a
149
+ // 60-column pane would fold that box as it once folded the mark.
150
+ const subtitleLines = !subtitle ? [] : words + 4 > columns ? wrapWords(subtitle, Math.max(title.length, columns - 4)) : [subtitle];
151
+ const text = [
152
+ { text: style.bold(title), width: title.length },
153
+ ...subtitleLines.map((l) => ({ text: style.dim(l), width: l.length })),
154
+ ];
155
+ words = Math.max(...text.map((t) => t.width));
140
156
  const pad = markWidth ? markWidth + gutter : 0;
141
157
  const inner = pad + words;
142
158
  const line = "─".repeat(inner + 2);