clearotron 0.5.0 → 0.5.1-beta.1
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/CONTRIBUTING.md +2 -2
- package/INSTALL.md +351 -308
- package/QUICKSTART.md +12 -4
- package/README.md +12 -7
- package/THIRD-PARTY-NOTICES.md +4 -4
- package/bin/README.md +14 -11
- package/bin/clearotron.mjs +1 -1
- package/bin/connect.mjs +73 -25
- package/bin/example.mjs +4 -2
- package/bin/onboard.mjs +647 -352
- package/bin/start.mjs +213 -66
- package/bin/update.mjs +26 -13
- package/build-info.json +2 -2
- package/docs/CLIENT-MCP.md +1 -1
- package/docs/PORTAL.md +2 -2
- package/docs/architecture/02-architecture.md +3 -3
- package/docs/architecture/04-configuration-reference.md +2 -3
- package/docs/architecture/05-config-governance.md +1 -1
- package/docs/architecture/06-operations-runbook.md +1 -1
- package/driver/CHANGELOG.md +91 -0
- package/driver/README.md +2 -2
- package/driver/config-inventory.mjs +20 -11
- package/driver/contract-e3-backlog.mjs +27 -27
- package/driver/contract-e3-baseline.json +2 -2
- package/driver/contract-vocabulary.mjs +1 -1
- package/driver/degraded-parts.mjs +67 -3
- package/driver/dev-portal.mjs +1 -1
- package/driver/digest-queue.mjs +5 -5
- package/driver/driver.config.mjs +9 -9
- package/driver/engine/CONTRACT.md +1 -1
- package/driver/engine/anthropic-agent.mjs +4 -2
- package/driver/engine/jx-turn.mjs +10 -2
- package/driver/engine/mcp/band-server.mjs +1 -21
- package/driver/engine/mcp/clarivate-propose-tool.mjs +26 -0
- package/driver/engine/mcp/clarivate-server.mjs +2 -18
- package/driver/engine/mcp/fixture-register-server.mjs +33 -0
- package/driver/engine/mcp/gather-config.mjs +48 -7
- package/driver/engine/mcp/recording-server.mjs +206 -14
- package/driver/engine/mcp/supplemental.mjs +4 -2
- package/driver/engine/openai-agent.mjs +3 -1
- package/driver/engine/probe.mjs +10 -0
- package/driver/filing-goods.mjs +95 -0
- package/driver/findings-model.mjs +3 -0
- package/driver/gateway.mjs +42 -40
- package/driver/how-it-runs.mjs +103 -0
- package/driver/knockout-assess-record.mjs +54 -4
- package/driver/knockout-correction-record.mjs +342 -0
- package/driver/knockout-frame-record.mjs +4 -2
- package/driver/knockout-register-read.mjs +705 -0
- package/driver/knockout-register-record.mjs +222 -0
- package/driver/knockout-review-record.mjs +96 -25
- package/driver/narrative-refutation-record.mjs +87 -1
- package/driver/order-tables.mjs +23 -0
- package/driver/owner-use-check.mjs +5 -2
- package/driver/package.json +1 -1
- package/driver/partial-payload-baseline.json +8 -0
- package/driver/pipeline-knockout.mjs +506 -313
- package/driver/pipeline.mjs +179 -86
- package/driver/portal-local-auth.mjs +7 -1
- package/driver/portal-service.mjs +99 -9
- package/driver/progress.mjs +2 -2
- package/driver/publish/index.mjs +18 -21
- package/driver/publish/knockout.mjs +40 -18
- package/driver/publish/render-knockout.mjs +40 -27
- package/driver/publish/report-dates.mjs +43 -0
- package/driver/recall-reconciliation.mjs +2 -2
- package/driver/record-goods.mjs +50 -9
- package/driver/register-count.mjs +12 -59
- package/driver/register-fixture-marker.mjs +22 -0
- package/driver/register-plan.mjs +48 -0
- package/driver/register-records.mjs +84 -266
- package/driver/register-taint.mjs +2 -2
- package/driver/repair-composers.mjs +15 -8
- package/driver/result-noun-fields.mjs +6 -2
- package/driver/run-requirements.mjs +111 -37
- package/driver/runner.mjs +9 -16
- package/driver/skills/clearance-register/providers/clarivate.md +2 -2
- package/driver/skills/knockout-assess/SKILL.md +101 -100
- package/driver/skills/knockout-frame/SKILL.md +3 -1
- package/driver/skills/knockout-register-read/SKILL.md +77 -0
- package/driver/stages-knockout.mjs +159 -98
- package/driver/stages.mjs +4 -2
- package/driver/suite-census.json +435 -81
- package/driver/systemd/README.md +2 -2
- package/driver/unit-environment.mjs +19 -0
- package/driver/verify-knockout.mjs +175 -39
- package/driver/verify.mjs +10 -9
- package/mcp-server/CHANGELOG.md +8 -0
- package/mcp-server/CONNECT.md +4 -0
- package/mcp-server/demo-mode.mjs +6 -0
- package/mcp-server/lib/demo-texts.mjs +38 -0
- package/mcp-server/lib/http-handler.mjs +7 -1
- package/mcp-server/lib/knockout.mjs +3 -2
- package/mcp-server/lib/options.mjs +3 -1
- package/mcp-server/lib/plan.mjs +6 -1
- package/mcp-server/lib/runs.mjs +7 -2
- package/mcp-server/mint-token.mjs +1 -1
- package/mcp-server/package.json +1 -1
- package/mcp-server/serve.mjs +11 -0
- package/mcp-server/server.mjs +13 -5
- package/package.json +1 -1
- package/portal-ui/dist/assets/{index-D2wrw9cH.css → index-AtB9ZpDH.css} +29 -0
- package/portal-ui/dist/assets/{index-DcLbvFmQ.js → index-fPqAU0sx.js} +237 -231
- package/portal-ui/dist/index.html +2 -2
- package/portal-ui/package.json +4 -4
- package/providers/README.md +4 -4
- package/providers/_shared/execute-plan.mjs +45 -1
- package/providers/_shared/term-shape.mjs +1 -1
- package/providers/clarivate/src/capabilities.js +7 -6
- package/providers/clarivate/src/core.js +11 -7
- package/providers/clarivate/src/wider-list.js +104 -0
- package/providers/oauth-mcp-bridge/CHANGELOG.md +8 -0
- package/providers/oauth-mcp-bridge/package.json +1 -1
- package/providers/signa/src/capabilities.js +0 -9
- package/scripts/e2e-first-time.mjs +8 -7
- package/scripts/freeze-example-run.mjs +2 -2
- package/scripts/settings-render-check.mjs +5 -3
- package/scripts/test-run.mjs +8 -2
- package/shared/client-door.mjs +11 -8
- package/shared/connect-clients.mjs +10 -4
- package/shared/demo-connection.mjs +43 -0
- package/shared/demo-start-args.mjs +7 -2
- package/shared/invocation.mjs +18 -3
- package/shared/permanent-install.mjs +24 -0
- package/shared/scope.mjs +8 -1
- package/shared/server-units.mjs +37 -1
- package/shared/stdio-connect.mjs +43 -21
- package/shared/trigger-lane.mjs +7 -0
- package/shared/tty-style.mjs +21 -5
package/bin/onboard.mjs
CHANGED
|
@@ -74,7 +74,7 @@ import { invocationForm } from "../shared/invocation.mjs"; // — and WHY that
|
|
|
74
74
|
import { foreignPageHint } from "../shared/invocation.mjs";
|
|
75
75
|
import { standFrom } from "../shared/invocation.mjs"; // is this tree one npm replaces?
|
|
76
76
|
import { installShim } from "../shared/verb-shim.mjs"; // — the verb goes on PATH
|
|
77
|
-
import { relocationPlan } from "../shared/permanent-install.mjs"; // — and the program out of npx's cache
|
|
77
|
+
import { relocationPlan, channelPackage, ownVersion, permanentPrefix } from "../shared/permanent-install.mjs"; // — and the program out of npx's cache
|
|
78
78
|
import { isWsl } from "../shared/wsl.mjs"; // — one answer to "is this WSL", shared with the connect lines
|
|
79
79
|
import { styleFor, banner } from "../shared/tty-style.mjs"; // — weight where the meaning is
|
|
80
80
|
import { bracketAsciiCells, BRAND } from "../shared/brand.mjs"; // F18 — the mark, from the geometry the SVG already uses
|
|
@@ -118,8 +118,22 @@ import { probeCliVersion } from "../driver/engine/cli-version.mjs"; // the eng
|
|
|
118
118
|
// use. "Its cheapest model" is true of either engine and brands neither.
|
|
119
119
|
export const probingLine = (engineId) =>
|
|
120
120
|
`Probing ${engineId} with one turn on its cheapest model (this SPENDS; ${PROBE_TIMEOUT_SEC}s ceiling)…`;
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
/** How each answer to the pay question is said afterwards, keyed by the billing word that answer's id is. */
|
|
122
|
+
export const PAYS_WITH = Object.freeze({ subscription: "your subscription", "api-key": "your API key", cloud: "your cloud account" });
|
|
123
|
+
export const proveQuestion = ({ product, billing }) =>
|
|
124
|
+
`Prove ${product} on ${PAYS_WITH[billing]} now with one turn on its cheapest model (a few tokens, ${PROBE_TIMEOUT_SEC}s ceiling)?`;
|
|
125
|
+
/**
|
|
126
|
+
* What setup says just before it asks to prove the engine. Answering no saves nothing and asks whether to go
|
|
127
|
+
* on without an AI, so the reader is told before answering that the AI is saved only once the turn works. On a
|
|
128
|
+
* subscription it also says what a turn costs when the program is not signed in yet, nothing, and that the
|
|
129
|
+
* sign-in follows (signInHandOff); under a key or a cloud account there is no sign-in to follow.
|
|
130
|
+
*/
|
|
131
|
+
export const proofPreamble = ({ product, billing }) => [
|
|
132
|
+
"A file that exists is not an engine that works — so setup tries one before writing anything.",
|
|
133
|
+
`It takes a few seconds, and setup saves ${product} as your AI only once this turn works.`,
|
|
134
|
+
...(billing === "subscription"
|
|
135
|
+
? [`If ${product} is not signed in yet, the turn costs nothing, and setup then shows how to sign in.`] : []),
|
|
136
|
+
];
|
|
123
137
|
|
|
124
138
|
// HOW CLAUDE IS PAID FOR, IN THE OWNER'S WORDS (2026-09-14): one question, three answers, the third a cloud
|
|
125
139
|
// account. Codex keeps the question it had: a cloud account bills Claude only, and the resolver refuses
|
|
@@ -229,7 +243,7 @@ export const cloudAccount = (cloud) =>
|
|
|
229
243
|
export const servedLine = (v) => (v?.served || v?.provider)
|
|
230
244
|
? `served by ${v.served ?? "a model the program did not name"}${v.provider ? `; the program names its provider "${v.provider}"` : ""}.`
|
|
231
245
|
: null;
|
|
232
|
-
import { runRequiredNames, missingRequirements, billingRefusalWords, REGISTER_ENV, ENGINE_ENV } from "../driver/run-requirements.mjs"; // the order-time gate's own question, asked here rather than restated
|
|
246
|
+
import { runRequiredNames, missingRequirements, billingRefusalWords, whatIsMissing, cannotSearchYet, REGISTER_ENV, ENGINE_ENV } from "../driver/run-requirements.mjs"; // the order-time gate's own question, asked here rather than restated
|
|
233
247
|
import { pinEnv, envFrom } from "../shared/env-aliases.mjs";
|
|
234
248
|
import { isEntrypoint } from "../shared/is-entrypoint.mjs"; // — one entry-point test, all spellings
|
|
235
249
|
// one synopsis reader for every verb that prints one.
|
|
@@ -393,6 +407,7 @@ const prose = (...parts) => { for (const l of wrapProse(parts.join(" "), proseWi
|
|
|
393
407
|
*
|
|
394
408
|
* @param {Record<string,string>} candidate what setup collected — always wins
|
|
395
409
|
* @param {Record<string,string>} existing the file as it stands
|
|
410
|
+
* @param {{ packaged?: boolean }} [how] whether this is a package install, for the header's command
|
|
396
411
|
*/
|
|
397
412
|
/**
|
|
398
413
|
* ── IS THE PORTAL BUNDLE THE ONE ITS SOURCES WOULD BUILD? — ─────────────────
|
|
@@ -511,12 +526,53 @@ export function configurationLostToUpgrade({
|
|
|
511
526
|
return dirs.every((d) => exists(d)) ? { base, dirs, installDir } : null;
|
|
512
527
|
}
|
|
513
528
|
|
|
514
|
-
|
|
529
|
+
/**
|
|
530
|
+
* Why setup keeps a reader's configuration outside the program's own files, said for how the program was
|
|
531
|
+
* installed. A checkout takes updates with `git pull`; a package has no git, and an update replaces it whole.
|
|
532
|
+
*/
|
|
533
|
+
export const configOutsideWhy = (packaged) => (packaged
|
|
534
|
+
? "Your customers and any instructions you override live here, outside the installed package, so an "
|
|
535
|
+
+ "update can replace the package without touching them."
|
|
536
|
+
: "Your customers and any instructions you override live here, outside the checkout — which is what "
|
|
537
|
+
+ "lets you take updates with `git pull` instead of merging into files you never meant to own.");
|
|
538
|
+
/** What setup says when the folder a reader named sits inside the program's own files, said the same way. */
|
|
539
|
+
export const configInsideRefusal = (packaged, path, repo) => (packaged
|
|
540
|
+
? [`${path} is INSIDE the installed package (${repo}).`,
|
|
541
|
+
"An update replaces the package and everything in it. Choose a path outside the installed package."]
|
|
542
|
+
: [`${path} is INSIDE the checkout (${repo}).`,
|
|
543
|
+
"Everything you write there becomes a local modification to our files: `git pull` conflicts,",
|
|
544
|
+
"and `git status` that is never clean. Choose a path outside the checkout."]);
|
|
545
|
+
/**
|
|
546
|
+
* What setup says about custom instructions in the configuration step, for the configuration folder `cfg`:
|
|
547
|
+
* none are set, and how to add one later. Setup writes no CLEAROTRON_INSTRUCTIONS_DIR; the reason is beside
|
|
548
|
+
* the line that prints this.
|
|
549
|
+
*/
|
|
550
|
+
export const customInstructionsNone = (cfg) => "Custom instructions: none, so CLEAROTRON_INSTRUCTIONS_DIR stays unset "
|
|
551
|
+
+ "and the product's own instruction files are used. To override one later, put your copy in "
|
|
552
|
+
+ `${join(cfg, "skills")}, commit it in ${cfg}, and set CLEAROTRON_INSTRUCTIONS_DIR to that folder. `
|
|
553
|
+
+ "A run cannot identify an uncommitted folder, and says so rather than guessing.";
|
|
554
|
+
/** What setup says about the configuration folder it leaves empty: an empty one is a working install. */
|
|
555
|
+
export const EMPTY_CONFIG_FOLDER = "Left empty, and an empty folder is a working install: searches use the "
|
|
556
|
+
+ "product's own instruction files and its Generic defaults, each until you add your own. Your own customers "
|
|
557
|
+
+ "are added here; the demo's sample customers never appear among them.";
|
|
558
|
+
/** The line setup prints once it has created the configuration folder `cfg` and the folder beneath it. */
|
|
559
|
+
export const configFoldersMade = (cfg) => `configuration directories created under ${cfg} (empty: the product's `
|
|
560
|
+
+ "own instruction files and its Generic defaults apply, each until you add your own)";
|
|
561
|
+
/** What setup says at its last check when no register is chosen: what it skips, what follows, and what to do. */
|
|
562
|
+
export const REGISTER_CHECK_SKIPPED =
|
|
563
|
+
"Skipping the register credential check: no register is chosen. Every search refuses until one is set. Re-run setup when you have a credential.";
|
|
564
|
+
/** What setup says when the register's credentials pass that check: the register, and the settings it checked. */
|
|
565
|
+
export const registerCheckPassed = (register, settings) =>
|
|
566
|
+
`the register credential check passed for "${register}" — checked ${settings}`;
|
|
567
|
+
|
|
568
|
+
export function composeEnvBody(candidate, existing = {}, { packaged = PACKAGED } = {}) {
|
|
515
569
|
// Setup's own answers win: the reader just typed them, and this run is the newer statement.
|
|
516
570
|
const carried = Object.entries(existing).filter(([k]) => !(k in candidate));
|
|
517
571
|
return [
|
|
518
|
-
|
|
519
|
-
|
|
572
|
+
// NAMED FOR HOW THE PROGRAM WAS INSTALLED: a package has no npm scripts. And no .gitignore is claimed,
|
|
573
|
+
// because the file is written to the reader's own settings folder (envLocalPath), outside the program.
|
|
574
|
+
`# Written by \`${packaged ? "clearotron install" : "npm run setup"}\`. Environment variables always win over this file.`,
|
|
575
|
+
"# It holds credentials: keep it at mode 600, and out of git.",
|
|
520
576
|
"",
|
|
521
577
|
// — VALIDATE under the names the engine reads, WRITE the names an installer should now see.
|
|
522
578
|
// Without this a fresh `npm run setup` emits a .env full of deprecated spellings and the very next
|
|
@@ -826,6 +882,34 @@ export { ON_A_WINDOWS_DRIVE };
|
|
|
826
882
|
*/
|
|
827
883
|
export { namingProgram };
|
|
828
884
|
|
|
885
|
+
/**
|
|
886
|
+
* What setup shows under a failed proof turn as its evidence: the engine's own last words, or that it said
|
|
887
|
+
* none, and how the verdict was read. A turn refused before the program started (basis "config": a billing
|
|
888
|
+
* setting, a missing sign-in file, an engine this driver does not ship) has no output to show and nothing
|
|
889
|
+
* read from it, so it shows neither; the verdict above it names what is missing.
|
|
890
|
+
*/
|
|
891
|
+
export function proofEvidence(v) {
|
|
892
|
+
if (v.basis === "config") return [];
|
|
893
|
+
return [
|
|
894
|
+
v.detail ? `engine said: ${v.detail}` : "engine said: nothing — it produced no output on either stream before it stopped.",
|
|
895
|
+
...(v.basis ? [v.basis === "text-match"
|
|
896
|
+
? "(setup's reading of the words above, not a status the program reported)"
|
|
897
|
+
: `(that reading is ${v.basis})`] : []),
|
|
898
|
+
];
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* A failed proof turn's first line, as setup prints it: the probe's verdict with the AI named the way setup's
|
|
903
|
+
* own questions name it (`product`: "Claude" or "Codex"), not by its setting's value, `anthropic-agent` or
|
|
904
|
+
* `openai-agent`. Only that word changes, whichever way the turn failed. The probe keeps its own words for
|
|
905
|
+
* `doctor --probe-engine` and for a run's check before it starts, which both report the setting. PURE.
|
|
906
|
+
*/
|
|
907
|
+
export function proofFailureLine(v, product) {
|
|
908
|
+
const id = String(v?.engine ?? "");
|
|
909
|
+
const headline = String(v?.headline ?? "");
|
|
910
|
+
return probeFailureText({ ...v, headline: id && product ? headline.replace(id, () => product) : headline });
|
|
911
|
+
}
|
|
912
|
+
|
|
829
913
|
/**
|
|
830
914
|
* What setup says after a failed proof turn about the step it cannot take for the reader, by how the turn
|
|
831
915
|
* is paid for (`billing`, the billing word). On a subscription that is the sign-in, naming the copy that runs,
|
|
@@ -838,7 +922,12 @@ export function signInHandOff(eng, bin, billing) {
|
|
|
838
922
|
if (billing === "cloud") return { lines: ["if you fixed the cloud's sign-in on this machine, answer yes below; to change the answers "
|
|
839
923
|
+ "above, answer no and pick the engine again."], captureToken: false };
|
|
840
924
|
if (billing === "api-key") return { lines: ["to give a different key, answer no below and pick the engine again."], captureToken: false };
|
|
841
|
-
|
|
925
|
+
// SETUP IS STILL WAITING IN THIS TERMINAL, so the commands are run in a second one. Said of the commands,
|
|
926
|
+
// not as "sign in": these lines follow every failed turn, a spent quota as much as a sign-out. And the yes
|
|
927
|
+
// it asks for is the retry's, named. On Claude a token question follows the retry, and it wants a no after a
|
|
928
|
+
// browser sign-in.
|
|
929
|
+
const lines = ["setup waits in this terminal, so run the commands below in a second one:",
|
|
930
|
+
`if it is signed out: ${namingProgram(eng.signIn, eng, bin)}, then answer yes to "Run the turn again".`];
|
|
842
931
|
// Codex's headless sign-in runs HERE, so it names the copy that runs here. Claude's token can be made on
|
|
843
932
|
// any machine, so its command keeps the bare word, and this machine's copy is named beside it.
|
|
844
933
|
if (eng.headless) {
|
|
@@ -942,11 +1031,18 @@ const isExec = (p) => { try { accessSync(p, constants.X_OK); return statSync(p).
|
|
|
942
1031
|
* and the portal reports what the engine saw then. No sign-in command is named here: no copy can run in
|
|
943
1032
|
* demo mode, so none can be named, and setup names the one that signs in the copy it proves. `command` is
|
|
944
1033
|
* the setup command as the reader can type it from here.
|
|
1034
|
+
*
|
|
1035
|
+
* WITH NO AI CHOSEN, `engSpec` is null and the first line names no one AI's program: setup asks which AI
|
|
1036
|
+
* to use before it offers to install anything, so naming the code's default AI's vendor described a
|
|
1037
|
+
* program the reader may never pick.
|
|
945
1038
|
*/
|
|
946
1039
|
export function leaveDemoAdvice(engSpec, { platform = process.platform, command = reachableCommand("install"),
|
|
947
1040
|
startCommand = reachableCommand("start") } = {}) {
|
|
948
|
-
const first =
|
|
949
|
-
|
|
1041
|
+
const first = engSpec
|
|
1042
|
+
? `To leave demo: run \`${command}\`. It offers to install ${engSpec.vendor}'s CLI if this machine has none, `
|
|
1043
|
+
+ "asks how it is paid for, and proves it with one turn; if the CLI is not signed in, it names the command that signs it in."
|
|
1044
|
+
: `To leave demo: run \`${command}\`. It asks which AI to use, offers to install that AI's program if this machine has none, `
|
|
1045
|
+
+ "asks how it is paid for, and proves it with one turn; if the program is not signed in, it names the command that signs it in.";
|
|
950
1046
|
// WINDOWS HAS NO BACKGROUND FORM, so the second line there names the one restart it has: the window.
|
|
951
1047
|
if (platform === "win32") {
|
|
952
1048
|
return [first, "If Clearotron is already running, close its window and start it again: it reads the settings setup writes when it starts."];
|
|
@@ -1064,6 +1160,16 @@ export function engineOptions(found = {}) {
|
|
|
1064
1160
|
];
|
|
1065
1161
|
}
|
|
1066
1162
|
|
|
1163
|
+
/**
|
|
1164
|
+
* The engine menu's default row: the AI the reader picked on an earlier pass, or row 0 on the first. A reader
|
|
1165
|
+
* whose turn failed on one AI and who went back to the menu met row 0 under Enter, which is a change of AI they
|
|
1166
|
+
* had not chosen. Remembering the pick saves nothing: the proof turn still decides what is written.
|
|
1167
|
+
*/
|
|
1168
|
+
export function engineMenuDefault(options, lastPick = null) {
|
|
1169
|
+
const at = lastPick ? options.findIndex((o) => o.id === lastPick) : -1;
|
|
1170
|
+
return at < 0 ? 0 : at;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1067
1173
|
// A COPY REFUSED AS THE VENDOR'S PLACEHOLDER, told apart by the resolver's own reason for refusing it
|
|
1068
1174
|
// (driver.config.mjs engineCandidate). setup-asks-which-ai-runs-your-searches.test.mjs creates a real
|
|
1069
1175
|
// placeholder and reads the row, so a reworded reason turns that test red instead of this row wrong.
|
|
@@ -1459,9 +1565,28 @@ export function readOwnProcesses(repo, { table = processTable() } = {}) {
|
|
|
1459
1565
|
.map((p) => ({ pid: p.pid, startedAt: p.startedAt, cmd: p.cmd.slice(0, 120) }));
|
|
1460
1566
|
}
|
|
1461
1567
|
|
|
1568
|
+
// The closing line of a check whose engine probe ran a test turn: the turn's AI program writes its own files
|
|
1569
|
+
// under ~/.claude and ~/.cache, so "Nothing was written" was true of this command and not of the turn.
|
|
1570
|
+
const TURN_KEPT_ITS_FILES = "Clearotron wrote nothing; the AI program's test turn keeps its own files.";
|
|
1571
|
+
/**
|
|
1572
|
+
* What setup says when it is cancelled, after "setup: ". It said "Nothing was written." every time, and by
|
|
1573
|
+
* then it may have installed its own copy under the reader's home (`copy`, from npx), the AI's program into
|
|
1574
|
+
* the engines folder (`engine`), or both, and a test turn may have left the AI program's own files
|
|
1575
|
+
* (`turnRan`). The settings file is only ever written at the end, so that part stays true, and the line
|
|
1576
|
+
* says what does stay. "Nothing was written." is kept for the cancel where it is still true.
|
|
1577
|
+
*/
|
|
1578
|
+
export function cancelledLine({ copy = null, engine = null, turnRan = false } = {}) {
|
|
1579
|
+
if (!copy && !engine) return `cancelled. ${turnRan ? TURN_KEPT_ITS_FILES : "Nothing was written."}`;
|
|
1580
|
+
const stays = copy && engine
|
|
1581
|
+
? `clearotron ${copy.version} stays installed in ${copy.prefix}, and ${engine.vendor}'s CLI in ${engine.dir}.`
|
|
1582
|
+
: copy ? `clearotron ${copy.version} stays installed in ${copy.prefix}.`
|
|
1583
|
+
: `${engine.vendor}'s CLI stays installed in ${engine.dir}.`;
|
|
1584
|
+
return `cancelled. No settings were written. ${stays}${turnRan ? " The AI program's test turn keeps its own files." : ""}`;
|
|
1585
|
+
}
|
|
1462
1586
|
export async function runCheck() {
|
|
1463
1587
|
say("\n Trademark clearance engine — configuration check\n");
|
|
1464
|
-
|
|
1588
|
+
// Whether the engine probe's turn started the AI program (TURN_KEPT_ITS_FILES); one refused first did not.
|
|
1589
|
+
let probeTurnRan = false;
|
|
1465
1590
|
|
|
1466
1591
|
// ── ONE READING OF THE UNITS' ENVIRONMENT, FOR EVERY SECTION THAT CLAIMS ANYTHING ABOUT THEM ─────
|
|
1467
1592
|
//
|
|
@@ -1486,8 +1611,313 @@ export async function runCheck() {
|
|
|
1486
1611
|
home: homedir() })
|
|
1487
1612
|
: null;
|
|
1488
1613
|
|
|
1489
|
-
//
|
|
1490
|
-
//
|
|
1614
|
+
// Read the file up here rather than at the `.env` heading below: the opening is the first that needs
|
|
1615
|
+
// `effective()`, and which ENGINE is configured decides which binary variable to check. Reading
|
|
1616
|
+
// is not applying — see readEnvFile's header.
|
|
1617
|
+
// `fileEnv` is read at the top of runCheck now — the Deployment section needs it to name the box on a
|
|
1618
|
+
// box that runs no units, and a `const` used above its declaration is a dead-zone crash, not a
|
|
1619
|
+
// fallback. It reached here as one on the first draft of that section: harmless on a hosted box,
|
|
1620
|
+
// where the ternary never evaluates this branch, and fatal on every install without units.
|
|
1621
|
+
// Environment wins over the file (the loader contract), so report the effective value and say which
|
|
1622
|
+
// source it came from — a value read from the wrong place is the whole class of bug here.
|
|
1623
|
+
// ── CHECK 1 — THE CHECKER READS EVERY SPELLING THE ENGINE ACCEPTS ─────────────────────────
|
|
1624
|
+
//
|
|
1625
|
+
// This read `process.env[k]` and `fileEnv[k]` for the LITERAL key, while the writer below maps every
|
|
1626
|
+
// key and writes the CLEAROTRON_* name. So on an install THIS WIZARD had
|
|
1627
|
+
// just configured correctly, `--check` reported every renamed variable as NOT SET, and told the
|
|
1628
|
+
// operator to go and set the old name — the one the engine is moving away from.
|
|
1629
|
+
//
|
|
1630
|
+
// Batch 1 recorded this trap in the opposite direction ("validating under names the engine reads while
|
|
1631
|
+
// writing names that would warn"). It survived its own fix in mirror image, which is why carries
|
|
1632
|
+
// the write-point check forward as a standing requirement rather than a one-off.
|
|
1633
|
+
//
|
|
1634
|
+
// CURRENT SPELLING FIRST, then the retired ones — the same order `applyEnvAliases` resolves in, so the
|
|
1635
|
+
// checker cannot disagree with the engine about which value wins when an operator has both set during
|
|
1636
|
+
// the migration. `from` names the spelling that answered, so an operator running on an old name can
|
|
1637
|
+
// see that they are, instead of being told everything is fine.
|
|
1638
|
+
//
|
|
1639
|
+
// `from` NAMES THE SOURCE, NOT THE SPELLING, and the first cut of this got that wrong. It appended
|
|
1640
|
+
// the answering spelling so "an operator on an old name can see that they are" — but `applyEnvAliases`
|
|
1641
|
+
// runs ungated at load and populates the CURRENT name from the old one, so the current spelling always
|
|
1642
|
+
// answers first and the label always named it. On a box configured entirely under retired names it
|
|
1643
|
+
// therefore reported the new spelling as the one that had answered: not merely uninformative, but the
|
|
1644
|
+
// opposite of what happened. The evidence it wanted is destroyed before this function can see it.
|
|
1645
|
+
//
|
|
1646
|
+
// THAT OPERATOR IS NO LONGER TOLD ANYTHING, and this note used to claim otherwise. It described a
|
|
1647
|
+
// deprecation notice `applyEnvAliases` printed at load, from the translation itself. There is no
|
|
1648
|
+
// translation and no notice: the owner ruled both out on 2026-08-26 (no migration, no legacy support,
|
|
1649
|
+
// and — asked directly — no check for the old names either), because a box reaches this code through
|
|
1650
|
+
// the install and the boxes that predated the rename are rebuilt rather than upgraded. The 2026-09-04
|
|
1651
|
+
// global rename extended that to the whole namespace. An old name is a line in a file nothing reads,
|
|
1652
|
+
// and the paragraph above describes a configuration that no longer occurs.
|
|
1653
|
+
const effective = (k, names = [k]) => {
|
|
1654
|
+
for (const name of names) {
|
|
1655
|
+
if (present(process.env[name])) return { v: process.env[name], from: "environment", name };
|
|
1656
|
+
if (present(fileEnv[name])) return { v: fileEnv[name], from: ".env", name };
|
|
1657
|
+
}
|
|
1658
|
+
return null;
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// ── ONE READING OF THE UNITS' ENVIRONMENT, FOR EVERY SECTION THAT CLAIMS ANYTHING ABOUT THEM ─────
|
|
1662
|
+
//
|
|
1663
|
+
// F34: two sections asserted facts about the units while reading the operator's shell, and both of
|
|
1664
|
+
// their reported problems were false on a correctly-running install. Resolving this once, here, is
|
|
1665
|
+
// deliberate — a second reader would drift from this one exactly as the composer and the checker did
|
|
1666
|
+
// in F41, and the drift is invisible because both sides keep passing their own arms.
|
|
1667
|
+
// The reading itself was hoisted AGAIN, to the top of runCheck, so the Deployment section can name
|
|
1668
|
+
// the box from the file the units load. `unitDir`, `hosted`, `unitEnv` and `startPaths` are all in
|
|
1669
|
+
// scope from there; nothing between here and there consumed them, which is why the move is safe.
|
|
1670
|
+
|
|
1671
|
+
// ── AND THE DOOR SECTION IS THE THIRD SUCH SECTION ──────────────────────────────────────────────
|
|
1672
|
+
//
|
|
1673
|
+
// The reading above was hoisted here from further down for this. It used to be resolved BELOW the
|
|
1674
|
+
// door check, so the one section making the loudest claim about the running service — "NOBODY can
|
|
1675
|
+
// use this portal" — was the one section that could not consult it.
|
|
1676
|
+
//
|
|
1677
|
+
// MEASURED 2026-09-06 on a healthy packaged install: `doctor` printed that ✗ and exited 1 on a box
|
|
1678
|
+
// where the local user signs in and `GET /portal/api/me` returned `{"role":"staff"}`. The units' file
|
|
1679
|
+
// carried `PORTAL_STAFF_DOMAINS=localhost` (a staff-domain rule, since deleted), the identity was
|
|
1680
|
+
// `<user>@localhost`, and the running service admitted it as staff. This command read the CLI's own
|
|
1681
|
+
// `.env`, where neither that name nor `PORTAL_AUTH_MODE` appeared — so the check was not ignoring the
|
|
1682
|
+
// auth mode, it never saw it. What admits a person now is their entry in the grants file, and the
|
|
1683
|
+
// units' file is still the only place that names which grants file.
|
|
1684
|
+
//
|
|
1685
|
+
// The disclosure was already here and one severity too quiet: a `·` saying "what THIS environment
|
|
1686
|
+
// implies, not what the running service serves", directly above a `✗` phrased in the present
|
|
1687
|
+
// indicative about the live box. A caveat does not repair a false claim standing beside it.
|
|
1688
|
+
//
|
|
1689
|
+
// SO THE VALUES COME FROM THE FILE THE SERVICE READS when this box is hosted, and the source is named
|
|
1690
|
+
// beside the verdict rather than left to a caveat. Not an exemption for `PORTAL_AUTH_MODE=local`,
|
|
1691
|
+
// which was the fix originally filed: that variable is absent from the file this command was reading,
|
|
1692
|
+
// so exempting on it would have changed nothing at all.
|
|
1693
|
+
const serviceEnvLabel = hosted ? "the units' environment" : "your environment file";
|
|
1694
|
+
const serviceEnvFile = hosted ? join(homedir(), ".env") : READ_ENV_PATH();
|
|
1695
|
+
// A HOSTED BOX WHOSE UNIT ENVIRONMENT COULD NOT BE READ ANSWERS `null`, NEVER `fileEnv`. Falling back
|
|
1696
|
+
// to the CLI's file there would reproduce this defect exactly, and silently — `unitEnvironment`
|
|
1697
|
+
// already distinguishes a failure to look, and the door check below refuses to claim a lockout on one.
|
|
1698
|
+
const serviceKnown = !hosted || unitEnv?.known === true;
|
|
1699
|
+
const serviceFileEnv = hosted ? (unitEnv?.known === true ? unitEnv.env : null) : fileEnv;
|
|
1700
|
+
const effectiveForService = (k, names = [k]) => {
|
|
1701
|
+
for (const name of names) {
|
|
1702
|
+
if (present(process.env[name])) return { v: process.env[name], from: "environment", name };
|
|
1703
|
+
if (serviceFileEnv && present(serviceFileEnv[name])) return { v: serviceFileEnv[name], from: serviceEnvLabel, name };
|
|
1704
|
+
}
|
|
1705
|
+
return null;
|
|
1706
|
+
};
|
|
1707
|
+
// WHAT THE SERVICES THEMSELVES READ, for the two judgements that decide whether a search runs: how they
|
|
1708
|
+
// pay, and "Will a search run?". On a machine with units, that is their file and nothing else: they run
|
|
1709
|
+
// with CLEAROTRON_NO_ENV_FILE=1, so doctor's shell never reaches them. Layered as effectiveForService
|
|
1710
|
+
// layers it, a cloud switch this shell exported for its own use was judged the services' own, and doctor
|
|
1711
|
+
// reported "a search is refused" on services that ran; a billing word here asked them for a key they did
|
|
1712
|
+
// not need. With no units, the services are the children of `clearotron start` and inherit its shell, so
|
|
1713
|
+
// effectiveForService is the true answer there.
|
|
1714
|
+
const servicesRead = (k) => (!hosted ? effectiveForService(k)
|
|
1715
|
+
: serviceFileEnv && present(serviceFileEnv[k]) ? { v: serviceFileEnv[k], from: serviceEnvLabel, name: k } : null);
|
|
1716
|
+
|
|
1717
|
+
// ON A MACHINE WITH UNITS THIS SECTION DESCRIBES THE SERVICES: which AI, which program, how they pay. They read their
|
|
1718
|
+
// own file and search their own PATH (servicesRead, above), so a shell that chose another AI says nothing about them,
|
|
1719
|
+
// and a file that cannot be read is a failure to look, never a reason to answer from this shell. With no units, the
|
|
1720
|
+
// services are the children of `clearotron start`, and this command's configuration is theirs.
|
|
1721
|
+
const engineRead = (k, names = [k]) => (hosted ? servicesRead(k) : effective(k, names));
|
|
1722
|
+
/** The environment a stage's program would see: `keys` as engineRead reads them, and on a machine with units, the units' PATH and none of this shell's values for those keys. */
|
|
1723
|
+
const engineEnvOf = (keys = []) => {
|
|
1724
|
+
const env = { ...process.env };
|
|
1725
|
+
const unitsPath = hosted ? unitValue(unitEnv, "PATH").value : null;
|
|
1726
|
+
if (unitsPath) env.PATH = unitsPath;
|
|
1727
|
+
for (const k of keys) {
|
|
1728
|
+
if (hosted) delete env[k];
|
|
1729
|
+
const e = engineRead(k);
|
|
1730
|
+
if (e) env[k] = e.v;
|
|
1731
|
+
}
|
|
1732
|
+
return env;
|
|
1733
|
+
};
|
|
1734
|
+
const engSel = engineRead("CLEAROTRON_AI");
|
|
1735
|
+
const engineId = String(engSel?.v ?? DEFAULT_ENGINE_ID).trim().toLowerCase();
|
|
1736
|
+
const engSpec = ENGINE_BINARIES[engineId];
|
|
1737
|
+
|
|
1738
|
+
// ONE READER FOR THE REGISTER AND THE RESEARCH KEY, the services' own. Only a machine with units has a
|
|
1739
|
+
// second environment to read; with no units, the services are started from this command's own file, and
|
|
1740
|
+
// `effective` has always read and labelled exactly that.
|
|
1741
|
+
const serviceValue = hosted ? effectiveForService : effective;
|
|
1742
|
+
|
|
1743
|
+
// ── WHAT THE OPENING NEEDS FROM THE ENGINE SECTION, READ BEFORE IT ─────────────────────────────────
|
|
1744
|
+
//
|
|
1745
|
+
// The opening says whether the engine program resolves (the sign-in line) and, under --probe-engine,
|
|
1746
|
+
// runs the turn on the copy that resolves. Both are read here, once, and the Engine section still
|
|
1747
|
+
// prints every line about them. `engineJudged` is that section's own condition: it judges nothing when
|
|
1748
|
+
// the units' environment cannot be read, or when CLEAROTRON_AI names no engine this driver ships.
|
|
1749
|
+
const engineJudged = serviceKnown && !(engSel && !engSpec);
|
|
1750
|
+
// WITH NO AI CHOSEN THERE IS NO ENGINE TO JUDGE. `engineId` falls back to the code's default, and the
|
|
1751
|
+
// default is not a choice: every search is refused until one is made (run-requirements.mjs, the engine row
|
|
1752
|
+
// of `runRequirements`). Everything this section read off that default described an AI nobody chose: a
|
|
1753
|
+
// machine with only Codex was told no `claude` was on its PATH, a ticked billing line named the default's
|
|
1754
|
+
// subscription, and --probe-engine spent a turn proving the default and called the install ready. Measured
|
|
1755
|
+
// on a fresh install of 0.5.1-beta.0, 2026-11-07. So the program, the probe and the billing are read
|
|
1756
|
+
// only for an AI that is chosen, and a machine with none is in demo mode: nothing it has chosen can run.
|
|
1757
|
+
const engineChosen = engineJudged && !!engSel;
|
|
1758
|
+
// — through `effective`, so the engine binary is found under whichever spelling is set. Read
|
|
1759
|
+
// literally, this reported a configured binary as missing on any install the wizard had written.
|
|
1760
|
+
const binEff = engineChosen ? engineRead(engSpec.env, [engSpec.env]) : null;
|
|
1761
|
+
// The engine's own fallback word is the default spelled out (resolveEngineProgram), so a setting of
|
|
1762
|
+
// `claude` is not a configuration that can be wrong: it asks PATH, then the copy Clearotron installed.
|
|
1763
|
+
const binSet = engineChosen && !!binEff && String(binEff.v).trim() !== engSpec.fallback;
|
|
1764
|
+
const binSetting = engineChosen ? (binEff?.v || engSpec.fallback) : null;
|
|
1765
|
+
const bin = engineChosen ? resolveEngineBin(binSetting, { engine: engineId, env: engineEnvOf() }) : null;
|
|
1766
|
+
// How the mode is read, and why its environment is normalised first, is the Engine section's note
|
|
1767
|
+
// WHICH MODE THIS INSTALL IS IN.
|
|
1768
|
+
const invEnv = engineChosen
|
|
1769
|
+
? engineEnvOf(["CLEAROTRON_AI", ...Object.values(ENGINE_BINARIES).flatMap((x) => [x.env, x.authEnv, x.apiKeyEnv])].filter(Boolean))
|
|
1770
|
+
: null;
|
|
1771
|
+
const installMode = !engineJudged ? null : engineChosen ? engineMode(engineInventory(invEnv)) : ENGINE_MODES.DEMO;
|
|
1772
|
+
// THE COMMAND THE READER CAN TYPE FROM HERE, as the demo line names its own. A bare `clearotron` is not
|
|
1773
|
+
// on PATH for an install run from npx, and now that the engine program comes with the install this is
|
|
1774
|
+
// the line most installs see first. The opening prints it when it leads and the Engine section prints
|
|
1775
|
+
// it otherwise; null where that section would print the demo lines instead.
|
|
1776
|
+
const signInLine = engineJudged && installMode !== ENGINE_MODES.DEMO
|
|
1777
|
+
? "The engine program is installed. Whether it is signed in cannot be read from disk: run "
|
|
1778
|
+
+ `\`${reachableCommand("doctor --probe-engine")}\` to find out.`
|
|
1779
|
+
: null;
|
|
1780
|
+
|
|
1781
|
+
// ONE TURN, WHEREVER IT RUNS. The engine as a RUN would see it (engineEnvOf). Only the engine-selection
|
|
1782
|
+
// keys — the probe must bill exactly the way this machine bills and moves no other variable. The auth
|
|
1783
|
+
// variables ride this list for the same reason CLEAROTRON_AI does: without them the probe bills the way
|
|
1784
|
+
// the AMBIENT environment says rather than the way this .env says, and "proven" would name a way of
|
|
1785
|
+
// paying that no run takes.
|
|
1786
|
+
//
|
|
1787
|
+
// THE CREDENTIALS RIDE IT TOO, and did not. This was a second copy of the list `applyEngineEnv`
|
|
1788
|
+
// applies, and it had dropped the API key and the headless token — so a token kept only in this
|
|
1789
|
+
// install's .env never reached the probe, which then reported the engine signed out while the same
|
|
1790
|
+
// token exported into the shell proved it. `engineEnvKeys` is the probe's own list: the copy that is
|
|
1791
|
+
// filled is now the copy that is applied.
|
|
1792
|
+
const runTurn = async () => {
|
|
1793
|
+
const v = await probeEngineTurn({ env: engineEnvOf(engineEnvKeys()) });
|
|
1794
|
+
probeTurnRan = v.ok || v.basis !== "config";
|
|
1795
|
+
return v;
|
|
1796
|
+
};
|
|
1797
|
+
/** What a turn's verdict prints, wherever the turn ran. */
|
|
1798
|
+
const sayTurn = (v) => {
|
|
1799
|
+
if (v.ok) {
|
|
1800
|
+
ok(`${engineId} completed a turn — binary, credential and model access all work`);
|
|
1801
|
+
const served = servedLine(v);
|
|
1802
|
+
if (served) info(served);
|
|
1803
|
+
// The ONLY route to READY. Everything else in this block reads the filesystem, and a signed-out
|
|
1804
|
+
// CLI passes every filesystem test there is — which is why this line is here and not above.
|
|
1805
|
+
ok("MODE: engine ready — proven by the turn just spent, not inferred from a file being executable.");
|
|
1806
|
+
}
|
|
1807
|
+
else {
|
|
1808
|
+
problem(probeFailureText(v));
|
|
1809
|
+
if (v.detail) info(`engine said: ${v.detail}`);
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1813
|
+
// ── WILL A SEARCH RUN? — THE ORDER-TIME GATE'S OWN QUESTION, OF THE ENVIRONMENT A RUN WILL HAVE ──
|
|
1814
|
+
//
|
|
1815
|
+
// Every section reads one requirement from YOUR shell and this command's .env. A search is refused by
|
|
1816
|
+
// a different reader: `orderTimeRefusal`, at order time, against the runner's environment — a
|
|
1817
|
+
// background unit's, on a machine that has them. So this command could pass an install the run then
|
|
1818
|
+
// refused: it found `claude` on this shell's PATH while the unit, which has no such PATH, was refused
|
|
1819
|
+
// for an engine path it had never been given. Asking the gate's own authority of the units' environment
|
|
1820
|
+
// is what makes an install this command passes one that can run. `blocking`, not `problem`: an install
|
|
1821
|
+
// that is not configured yet is unfinished rather than broken, and the exit status keeps that contract.
|
|
1822
|
+
//
|
|
1823
|
+
// ASKED ONCE, BEFORE ANYTHING ELSE IS PRINTED, because the opening is its answer. `atOrder` is null
|
|
1824
|
+
// when the units' environment could not be read; sayWillASearchRun prints the section wherever it goes.
|
|
1825
|
+
const tables = { registers: PROVIDERS, engines: ENGINE_BINARIES, defaultEngine: DEFAULT_ENGINE_ID, resolveEngine: resolveEngineProgram };
|
|
1826
|
+
const atOrder = (() => {
|
|
1827
|
+
if (!serviceKnown) return null;
|
|
1828
|
+
// UNTIL NOTHING NEW IS NAMED: which names a run needs depends on values read in the pass before. The
|
|
1829
|
+
// register and the engine name their credentials, their program and the billing word; a billing word of
|
|
1830
|
+
// `cloud` names the cloud switches and the gateway address; a switch found becomes the blocking row, and
|
|
1831
|
+
// the cloud's other settings are named only where the view already holds them. Two passes stopped before
|
|
1832
|
+
// the billing word was read, so a machine that pays through a cloud account was checked as a subscription
|
|
1833
|
+
// one and its missing switch went unreported. It stops at the first pass that finds no new value: the names
|
|
1834
|
+
// asked for depend only on the values found, so the next pass would ask for the names this one just read.
|
|
1835
|
+
const view = {};
|
|
1836
|
+
// Read as the services read it (servicesRead): a value in this shell never reaches a unit.
|
|
1837
|
+
const fill = (names) => { for (const n of names) { const e = servicesRead(n); if (e) view[n] = e.v; } };
|
|
1838
|
+
fill([REGISTER_ENV, ENGINE_ENV]);
|
|
1839
|
+
let before;
|
|
1840
|
+
do { before = Object.keys(view).length; fill(runRequiredNames(view, tables)); } while (Object.keys(view).length > before);
|
|
1841
|
+
// AND THE PATH THE SERVICES SEARCH, so the engine's program is looked for where a run looks for it.
|
|
1842
|
+
// The view held the settings and no PATH, so a `claude` on the services' PATH, with no path setting and
|
|
1843
|
+
// no copy installed by setup, was reported as a search refused while the run found it and ran. On a
|
|
1844
|
+
// machine with units that PATH is the units' own (every unit sets it, with `%h` for the home, which the
|
|
1845
|
+
// unit reader expands); never this shell's, which the units do not inherit. With no units, the
|
|
1846
|
+
// services are the children of `clearotron start`, which inherit the PATH of the shell it runs in.
|
|
1847
|
+
const servicesPath = hosted ? unitValue(unitEnv, "PATH").value : process.env.PATH;
|
|
1848
|
+
if (servicesPath) view.PATH = servicesPath;
|
|
1849
|
+
return missingRequirements(view, tables).atOrder;
|
|
1850
|
+
})();
|
|
1851
|
+
const sayWillASearchRun = () => {
|
|
1852
|
+
say("\n Will a search run?");
|
|
1853
|
+
if (!serviceKnown) {
|
|
1854
|
+
info("the units' environment could not be read, so what a search would be refused for is NOT checked here — a failure to look is not a clean result");
|
|
1855
|
+
} else if (atOrder.length) {
|
|
1856
|
+
blocking(`a search is refused until ${atOrder.length === 1 ? "this is" : "these are"} set in ${serviceEnvLabel}: ${atOrder.map((r) => r.name).join(", ")}`);
|
|
1857
|
+
for (const r of atOrder) info(` ${r.name} — ${r.why}`);
|
|
1858
|
+
} else ok(`nothing a search is refused for at order time is missing from ${serviceEnvLabel}`);
|
|
1859
|
+
};
|
|
1860
|
+
const sayResearch = () => {
|
|
1861
|
+
say("\n Research provider");
|
|
1862
|
+
// The same reader as the register, for the same reason: this is a key the services use.
|
|
1863
|
+
const px = serviceKnown ? serviceValue("PERPLEXITY_API_KEY") : null;
|
|
1864
|
+
if (!serviceKnown) info("the units' environment could not be read, so whether the services hold PERPLEXITY_API_KEY is not judged here — a failure to look, not a finding");
|
|
1865
|
+
else if (px) ok(`PERPLEXITY_API_KEY present (${px.from}) — presence only; add --probe-providers to prove it answers`);
|
|
1866
|
+
else info("PERPLEXITY_API_KEY is not set — the three clearance searches carry the common-law grid and cannot switch it off, so a clearance stops before it starts, and names the missing key; a Knockout search still runs and discloses the half it skipped");
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
// ── THE OPENING: WHETHER A SEARCH CAN RUN, WHAT STOPS IT, AND THE NEXT ACTION ─────────────────────
|
|
1870
|
+
//
|
|
1871
|
+
// A newcomer reads this command from the top, and the top was its path and its build: the answer to
|
|
1872
|
+
// "can this install search" sat halfway down, a screen away from the command that changes it (measured
|
|
1873
|
+
// on a packaged install, 2026-11-06: line 52 of 100). So the answer comes first, and every section
|
|
1874
|
+
// below keeps every line it had.
|
|
1875
|
+
//
|
|
1876
|
+
// ON A MACHINE WITH NO UNITS WHOSE SEARCH IS REFUSED, the opening is the refusal the portal gives the
|
|
1877
|
+
// person who runs the install, from the same composer (cannotSearchYet), with the command as it is
|
|
1878
|
+
// typed from here. A machine with units is not told that: its services read `~/.env`, which setup does
|
|
1879
|
+
// not write, so running setup alone would not reach them. A refusal with no words for what is missing
|
|
1880
|
+
// has no such sentence, and opens as every other state does.
|
|
1881
|
+
//
|
|
1882
|
+
// EVERY OTHER STATE OPENS WITH "Will a search run?" ITSELF, then the sign-in line when the program
|
|
1883
|
+
// resolves, or, under --probe-engine on an install that can search, the turn that answers it. The turn
|
|
1884
|
+
// is announced before it spends anything, and above the heading: a line that starts a section would end
|
|
1885
|
+
// "Will a search run?" for any reader that splits this output at its headings.
|
|
1886
|
+
//
|
|
1887
|
+
// "Research provider" comes second in every state: it is the one setting that stops three of the four
|
|
1888
|
+
// searches and that the order-time answer does not cover.
|
|
1889
|
+
const missingWords = serviceKnown && atOrder.length ? whatIsMissing(atOrder) : "";
|
|
1890
|
+
const leadIsTheRefusal = !hosted && missingWords !== "";
|
|
1891
|
+
const turnLeads = PROBE_ENGINE && serviceKnown && atOrder.length === 0 && engineChosen && bin.executable && !bin.relative;
|
|
1892
|
+
const signInLineLeads = !leadIsTheRefusal && !PROBE_ENGINE && signInLine !== null;
|
|
1893
|
+
// ONE LINE, AS EVERY LINE BELOW IS, and the terminal wraps it. Wrapped here at spaces, it broke the command
|
|
1894
|
+
// apart wherever the install's path made a long word: `cd <path> && npx clearotron install` on three lines.
|
|
1895
|
+
//
|
|
1896
|
+
// AND IT SAYS TO RUN `start` AGAIN ONLY WHILE ONE RUNS THAT SETUP REACHES. A foreground `clearotron start` reads
|
|
1897
|
+
// its settings file when it starts, so after setup it must be run again; with none running, setup is the whole
|
|
1898
|
+
// remedy. A demo's start reads no install's settings, and a start whose record names no settings file read
|
|
1899
|
+
// none, so setup does not reach either. The record is the one `clearotron status` reads; `start` writes `envFile`.
|
|
1900
|
+
const { readRunning } = await import(pathToFileURL(join(REPO, "shared", "running-start.mjs")).href);
|
|
1901
|
+
const startRunning = leadIsTheRefusal && readRunning().some((r) => !r.demo && typeof r.envFile === "string" && r.envFile !== "");
|
|
1902
|
+
if (leadIsTheRefusal) say(` ${cannotSearchYet(missingWords, invoke("install"), startRunning ? { kind: "start" } : null)}`);
|
|
1903
|
+
else {
|
|
1904
|
+
let turn = null;
|
|
1905
|
+
if (turnLeads) {
|
|
1906
|
+
say(` ${probingLine(engineId)}`);
|
|
1907
|
+
turn = await runTurn();
|
|
1908
|
+
}
|
|
1909
|
+
sayWillASearchRun();
|
|
1910
|
+
if (signInLineLeads) info(signInLine);
|
|
1911
|
+
if (turn) sayTurn(turn);
|
|
1912
|
+
}
|
|
1913
|
+
sayResearch();
|
|
1914
|
+
|
|
1915
|
+
// The path this command runs from, with the build it names below it.
|
|
1916
|
+
say(`\n repo: ${REPO}`);
|
|
1917
|
+
|
|
1918
|
+
// — CURRENT, not just configured. Printed first among the sections about this install's build,
|
|
1919
|
+
// because a stale deployment makes every line below it a report about the wrong build. The opening
|
|
1920
|
+
// and the research key come before it, because a newcomer's first question is whether a search runs.
|
|
1491
1921
|
say("\n Deployment");
|
|
1492
1922
|
const cur = deploymentCurrency();
|
|
1493
1923
|
if (cur.state === "current") ok(`up to date with ${cur.upstream} as of the last fetch`);
|
|
@@ -1545,16 +1975,18 @@ export async function runCheck() {
|
|
|
1545
1975
|
// THE ACCEPTED NAMES ARE NEVER PRINTED. They are the names of the deployments this build was made for,
|
|
1546
1976
|
// and the line offered them to a newcomer to name their own machine after (measured on a fresh install
|
|
1547
1977
|
// of a beta, 2026-11-03). An install without units says nothing of an unset name: nothing there reads
|
|
1548
|
-
// it. Installed units are
|
|
1978
|
+
// it. Installed units are told, because the services read it, and `start --background` installs the
|
|
1549
1979
|
// same units a hosted deployment runs, from the same renderer, so nothing here can tell the two apart.
|
|
1550
1980
|
if (!raw) {
|
|
1551
1981
|
// AN ABSENCE IS NOT A MISCONFIGURATION, and this command already separates the two — a machine
|
|
1552
|
-
// nobody has configured yet has no
|
|
1553
|
-
// Reported
|
|
1554
|
-
//
|
|
1555
|
-
//
|
|
1556
|
-
|
|
1557
|
-
|
|
1982
|
+
// nobody has configured yet has no name, legitimately, and `--check` on one exits 0 by contract.
|
|
1983
|
+
// Reported so it is visible rather than silent, which is the whole requirement. At `·`, in plain
|
|
1984
|
+
// words, because the reader most likely to see it is a newcomer after `start --background`, who
|
|
1985
|
+
// has nothing to set: a `!` there said the rest of the report could not be trusted and gave them
|
|
1986
|
+
// nothing to do (measured on a fresh install of a beta, 2026-11-04). Raising it to `✗` made every
|
|
1987
|
+
// unconfigured machine fail its own acceptance arm.
|
|
1988
|
+
if (hosted) info(`no CLEAROTRON_BOX in ${boxSource}. Only Clearotron's own servers set it, to name `
|
|
1989
|
+
+ "themselves; an install of your own leaves it unset");
|
|
1558
1990
|
} else if (!DEPLOYMENT_BOXES.includes(raw)) {
|
|
1559
1991
|
problem(`CLEAROTRON_BOX is "${raw}" in ${boxSource}, which is not a box this build knows. `
|
|
1560
1992
|
+ `An unrecognised name reads as NO box everywhere it is `
|
|
@@ -1650,136 +2082,46 @@ export async function runCheck() {
|
|
|
1650
2082
|
if (nodeV.ok) ok(`node ${nodeV.current}`);
|
|
1651
2083
|
else problem(`node ${nodeV.current} — this engine needs ${nodeV.required} or newer; node:sqlite is not a built-in module before then`);
|
|
1652
2084
|
|
|
1653
|
-
// Read the file up here rather than at the `.env` heading below: the engine section is the first that
|
|
1654
|
-
// needs `effective()`, and which ENGINE is configured decides which binary variable to check. Reading
|
|
1655
|
-
// is not applying — see readEnvFile's header.
|
|
1656
|
-
// `fileEnv` is read at the top of runCheck now — the Deployment section needs it to name the box on a
|
|
1657
|
-
// box that runs no units, and a `const` used above its declaration is a dead-zone crash, not a
|
|
1658
|
-
// fallback. It reached here as one on the first draft of that section: harmless on a hosted box,
|
|
1659
|
-
// where the ternary never evaluates this branch, and fatal on every install without units.
|
|
1660
|
-
// Environment wins over the file (the loader contract), so report the effective value and say which
|
|
1661
|
-
// source it came from — a value read from the wrong place is the whole class of bug here.
|
|
1662
|
-
// ── CHECK 1 — THE CHECKER READS EVERY SPELLING THE ENGINE ACCEPTS ─────────────────────────
|
|
1663
|
-
//
|
|
1664
|
-
// This read `process.env[k]` and `fileEnv[k]` for the LITERAL key, while the writer below maps every
|
|
1665
|
-
// key and writes the CLEAROTRON_* name. So on an install THIS WIZARD had
|
|
1666
|
-
// just configured correctly, `--check` reported every renamed variable as NOT SET, and told the
|
|
1667
|
-
// operator to go and set the old name — the one the engine is moving away from.
|
|
1668
|
-
//
|
|
1669
|
-
// Batch 1 recorded this trap in the opposite direction ("validating under names the engine reads while
|
|
1670
|
-
// writing names that would warn"). It survived its own fix in mirror image, which is why carries
|
|
1671
|
-
// the write-point check forward as a standing requirement rather than a one-off.
|
|
1672
|
-
//
|
|
1673
|
-
// CURRENT SPELLING FIRST, then the retired ones — the same order `applyEnvAliases` resolves in, so the
|
|
1674
|
-
// checker cannot disagree with the engine about which value wins when an operator has both set during
|
|
1675
|
-
// the migration. `from` names the spelling that answered, so an operator running on an old name can
|
|
1676
|
-
// see that they are, instead of being told everything is fine.
|
|
1677
|
-
//
|
|
1678
|
-
// `from` NAMES THE SOURCE, NOT THE SPELLING, and the first cut of this got that wrong. It appended
|
|
1679
|
-
// the answering spelling so "an operator on an old name can see that they are" — but `applyEnvAliases`
|
|
1680
|
-
// runs ungated at load and populates the CURRENT name from the old one, so the current spelling always
|
|
1681
|
-
// answers first and the label always named it. On a box configured entirely under retired names it
|
|
1682
|
-
// therefore reported the new spelling as the one that had answered: not merely uninformative, but the
|
|
1683
|
-
// opposite of what happened. The evidence it wanted is destroyed before this function can see it.
|
|
1684
|
-
//
|
|
1685
|
-
// THAT OPERATOR IS NO LONGER TOLD ANYTHING, and this note used to claim otherwise. It described a
|
|
1686
|
-
// deprecation notice `applyEnvAliases` printed at load, from the translation itself. There is no
|
|
1687
|
-
// translation and no notice: the owner ruled both out on 2026-08-26 (no migration, no legacy support,
|
|
1688
|
-
// and — asked directly — no check for the old names either), because a box reaches this code through
|
|
1689
|
-
// the install and the boxes that predated the rename are rebuilt rather than upgraded. The 2026-09-04
|
|
1690
|
-
// global rename extended that to the whole namespace. An old name is a line in a file nothing reads,
|
|
1691
|
-
// and the paragraph above describes a configuration that no longer occurs.
|
|
1692
|
-
const effective = (k, names = [k]) => {
|
|
1693
|
-
for (const name of names) {
|
|
1694
|
-
if (present(process.env[name])) return { v: process.env[name], from: "environment", name };
|
|
1695
|
-
if (present(fileEnv[name])) return { v: fileEnv[name], from: ".env", name };
|
|
1696
|
-
}
|
|
1697
|
-
return null;
|
|
1698
|
-
};
|
|
1699
|
-
|
|
1700
|
-
// ── ONE READING OF THE UNITS' ENVIRONMENT, FOR EVERY SECTION THAT CLAIMS ANYTHING ABOUT THEM ─────
|
|
1701
|
-
//
|
|
1702
|
-
// F34: two sections asserted facts about the units while reading the operator's shell, and both of
|
|
1703
|
-
// their reported problems were false on a correctly-running install. Resolving this once, here, is
|
|
1704
|
-
// deliberate — a second reader would drift from this one exactly as the composer and the checker did
|
|
1705
|
-
// in F41, and the drift is invisible because both sides keep passing their own arms.
|
|
1706
|
-
// The reading itself was hoisted AGAIN, to the top of runCheck, so the Deployment section can name
|
|
1707
|
-
// the box from the file the units load. `unitDir`, `hosted`, `unitEnv` and `startPaths` are all in
|
|
1708
|
-
// scope from there; nothing between here and there consumed them, which is why the move is safe.
|
|
1709
|
-
|
|
1710
|
-
// ── AND THE DOOR SECTION IS THE THIRD SUCH SECTION ──────────────────────────────────────────────
|
|
1711
|
-
//
|
|
1712
|
-
// The reading above was hoisted here from further down for this. It used to be resolved BELOW the
|
|
1713
|
-
// door check, so the one section making the loudest claim about the running service — "NOBODY can
|
|
1714
|
-
// use this portal" — was the one section that could not consult it.
|
|
1715
|
-
//
|
|
1716
|
-
// MEASURED 2026-09-06 on a healthy packaged install: `doctor` printed that ✗ and exited 1 on a box
|
|
1717
|
-
// where the local user signs in and `GET /portal/api/me` returned `{"role":"staff"}`. The units' file
|
|
1718
|
-
// carried `PORTAL_STAFF_DOMAINS=localhost` (a staff-domain rule, since deleted), the identity was
|
|
1719
|
-
// `<user>@localhost`, and the running service admitted it as staff. This command read the CLI's own
|
|
1720
|
-
// `.env`, where neither that name nor `PORTAL_AUTH_MODE` appeared — so the check was not ignoring the
|
|
1721
|
-
// auth mode, it never saw it. What admits a person now is their entry in the grants file, and the
|
|
1722
|
-
// units' file is still the only place that names which grants file.
|
|
1723
|
-
//
|
|
1724
|
-
// The disclosure was already here and one severity too quiet: a `·` saying "what THIS environment
|
|
1725
|
-
// implies, not what the running service serves", directly above a `✗` phrased in the present
|
|
1726
|
-
// indicative about the live box. A caveat does not repair a false claim standing beside it.
|
|
1727
|
-
//
|
|
1728
|
-
// SO THE VALUES COME FROM THE FILE THE SERVICE READS when this box is hosted, and the source is named
|
|
1729
|
-
// beside the verdict rather than left to a caveat. Not an exemption for `PORTAL_AUTH_MODE=local`,
|
|
1730
|
-
// which was the fix originally filed: that variable is absent from the file this command was reading,
|
|
1731
|
-
// so exempting on it would have changed nothing at all.
|
|
1732
|
-
const serviceEnvLabel = hosted ? "the units' environment" : "your environment file";
|
|
1733
|
-
const serviceEnvFile = hosted ? join(homedir(), ".env") : READ_ENV_PATH();
|
|
1734
|
-
// A HOSTED BOX WHOSE UNIT ENVIRONMENT COULD NOT BE READ ANSWERS `null`, NEVER `fileEnv`. Falling back
|
|
1735
|
-
// to the CLI's file there would reproduce this defect exactly, and silently — `unitEnvironment`
|
|
1736
|
-
// already distinguishes a failure to look, and the door check below refuses to claim a lockout on one.
|
|
1737
|
-
const serviceKnown = !hosted || unitEnv?.known === true;
|
|
1738
|
-
const serviceFileEnv = hosted ? (unitEnv?.known === true ? unitEnv.env : null) : fileEnv;
|
|
1739
|
-
const effectiveForService = (k, names = [k]) => {
|
|
1740
|
-
for (const name of names) {
|
|
1741
|
-
if (present(process.env[name])) return { v: process.env[name], from: "environment", name };
|
|
1742
|
-
if (serviceFileEnv && present(serviceFileEnv[name])) return { v: serviceFileEnv[name], from: serviceEnvLabel, name };
|
|
1743
|
-
}
|
|
1744
|
-
return null;
|
|
1745
|
-
};
|
|
1746
|
-
// WHAT THE SERVICES THEMSELVES READ, for the two judgements that decide whether a search runs: how they
|
|
1747
|
-
// pay, and "Will a search run?". On a machine with units, that is their file and nothing else: they run
|
|
1748
|
-
// with CLEAROTRON_NO_ENV_FILE=1, so doctor's shell never reaches them. Layered as effectiveForService
|
|
1749
|
-
// layers it, a cloud switch this shell exported for its own use was judged the services' own, and doctor
|
|
1750
|
-
// reported "a search is refused" on services that ran; a billing word here asked them for a key they did
|
|
1751
|
-
// not need. With no units, the services are the children of `clearotron start` and inherit its shell, so
|
|
1752
|
-
// effectiveForService is the true answer there.
|
|
1753
|
-
const servicesRead = (k) => (!hosted ? effectiveForService(k)
|
|
1754
|
-
: serviceFileEnv && present(serviceFileEnv[k]) ? { v: serviceFileEnv[k], from: serviceEnvLabel, name: k } : null);
|
|
1755
|
-
|
|
1756
2085
|
say("\n Engine");
|
|
1757
2086
|
// This block used to read CLEAROTRON_CLAUDE_PATH unconditionally, under the heading "Engine binary", on a
|
|
1758
2087
|
// box that may be running codex — so it reported the wrong variable and could pass for the wrong
|
|
1759
2088
|
// reason. Which engine is configured comes first now, and the binary is checked through THAT engine's
|
|
1760
2089
|
// variable.
|
|
1761
|
-
|
|
1762
|
-
const
|
|
1763
|
-
|
|
1764
|
-
if (
|
|
2090
|
+
// The mode of a machine that cannot start a search, said by both branches below that reach it.
|
|
2091
|
+
const demoModeLine = () => "MODE: demo — everything works except starting a NEW search. The example report, its audit trail "
|
|
2092
|
+
+ `and the MCP connection are live right now; \`${reachableCommand("demo")}\` needs no engine.`;
|
|
2093
|
+
if (!serviceKnown) {
|
|
2094
|
+
info("the units' environment could not be read, so which AI the services run is not judged here — a failure to look, not a finding");
|
|
2095
|
+
} else if (engSel && !engSpec) {
|
|
1765
2096
|
problem(`CLEAROTRON_AI="${engSel.v}" (${engSel.from}) is not an engine this driver ships — one of: `
|
|
1766
2097
|
+ `${Object.keys(ENGINE_BINARIES).join(", ")}. The run refuses on this by itself (gateway.selectEngine); `
|
|
1767
2098
|
+ "nothing can be checked here until it names an adapter.");
|
|
2099
|
+
} else if (!engSel) {
|
|
2100
|
+
// WHAT THE ORDER-TIME CHECK SAYS, NOT WHAT THE CODE FALLS BACK TO. Every search is refused while the
|
|
2101
|
+
// services lack this (run-requirements.mjs, `runRequirements`, the engine row), whatever the default
|
|
2102
|
+
// below checks. Naming that default here read as "nothing to do", a few lines above "Will a search
|
|
2103
|
+
// run?" listing this very setting (measured on a fresh install of a beta, 2026-11-04). Asked of the
|
|
2104
|
+
// services' own reading (servicesRead), as that section asks it: on a machine with units, their file
|
|
2105
|
+
// may hold the value this command's file does not, and then no search is refused over it.
|
|
2106
|
+
const noAiChosen = !servicesRead("CLEAROTRON_AI");
|
|
2107
|
+
if (noAiChosen) info(`CLEAROTRON_AI is not set, so no AI is chosen, `
|
|
2108
|
+
+ `and a search is refused until one is. \`${invoke("install")}\` asks which AI to use.`);
|
|
2109
|
+
else info(`CLEAROTRON_AI is not set — the code default is ${DEFAULT_ENGINE_ID}, and one engine serves every stage of every run on this machine`);
|
|
2110
|
+
// AND NOTHING BELOW IT IS READ OFF THE DEFAULT (engineChosen, above the opening): no program, no payment
|
|
2111
|
+
// and no turn, which would all describe an AI nobody chose. The machine is in demo mode, and the way out
|
|
2112
|
+
// is the demo's own advice. With no AI chosen it names no one AI's program; where the services hold an
|
|
2113
|
+
// AI this command's file does not, it keeps the words it had.
|
|
2114
|
+
info(demoModeLine());
|
|
2115
|
+
for (const line of leaveDemoAdvice(noAiChosen ? null : engSpec)) info(line);
|
|
2116
|
+
// ASKED TO PROBE with no AI chosen, it says why it did not, where it used to print nothing at all.
|
|
2117
|
+
if (PROBE_ENGINE && noAiChosen) info(`not probed — no AI is chosen. \`${invoke("install")}\` asks which AI to use.`);
|
|
1768
2118
|
} else {
|
|
1769
|
-
|
|
1770
|
-
else info(`CLEAROTRON_AI is not set — the code default is ${DEFAULT_ENGINE_ID}, and one engine serves every stage of every run on this box`);
|
|
2119
|
+
ok(`${engineId} (${engSel.from}) — ${engSpec.label}`);
|
|
1771
2120
|
|
|
1772
2121
|
// The line between an ABSENCE and a MISCONFIGURATION. Nothing set and no binary on PATH is a fresh
|
|
1773
2122
|
// machine — reported, not failed. A variable that names something wrong is a configuration that
|
|
1774
|
-
// will fail at run time, and this is the cheap place to learn it.
|
|
1775
|
-
//
|
|
1776
|
-
// literally, this reported a configured binary as missing on any install the wizard had written.
|
|
1777
|
-
const binEff = effective(engSpec.env, [engSpec.env]);
|
|
1778
|
-
// The engine's own fallback word is the default spelled out (resolveEngineProgram), so a setting of
|
|
1779
|
-
// `claude` is not a configuration that can be wrong: it asks PATH, then the copy Clearotron installed.
|
|
1780
|
-
const binSet = !!binEff && String(binEff.v).trim() !== engSpec.fallback;
|
|
1781
|
-
const binSetting = binEff?.v || engSpec.fallback;
|
|
1782
|
-
const bin = resolveEngineBin(binSetting, { engine: engineId });
|
|
2123
|
+
// will fail at run time, and this is the cheap place to learn it. The program (`bin`) is resolved above
|
|
2124
|
+
// the opening, which needs it; this section still says everything about it.
|
|
1783
2125
|
// WHICH COPY, AND ITS VERSION, because the machine's own install and the one Clearotron installed
|
|
1784
2126
|
// are both legitimate and behave differently: the first updates itself, the second moves with
|
|
1785
2127
|
// `clearotron update`. The version comes from the copy's own package.json when npm installed it.
|
|
@@ -1864,16 +2206,10 @@ export async function runCheck() {
|
|
|
1864
2206
|
// `env[spec.env]` — the CURRENT spelling only — and this file is deliberately not a CLI entry, so
|
|
1865
2207
|
// the alias layer has not run here. Handed raw process.env it would miss a binary configured
|
|
1866
2208
|
// under the legacy name and report DEMO on a box that has an engine.
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
if (!k) continue;
|
|
1870
|
-
const e = effective(k, [k]);
|
|
1871
|
-
if (e) invEnv[k] = e.v;
|
|
1872
|
-
}
|
|
1873
|
-
const installMode = engineMode(engineInventory(invEnv));
|
|
2209
|
+
//
|
|
2210
|
+
// `invEnv` and `installMode` are read that way above the opening, which needs the mode for its sign-in line.
|
|
1874
2211
|
if (installMode === ENGINE_MODES.DEMO) {
|
|
1875
|
-
info(
|
|
1876
|
-
+ `and the MCP connection are live right now; \`${reachableCommand("demo")}\` needs no engine.`);
|
|
2212
|
+
info(demoModeLine());
|
|
1877
2213
|
// NAMES THE COMMAND, AND THE RESTART. The settings page says both now, and a doctor that named
|
|
1878
2214
|
// the program but not how to install it — or that left out the restart, which is what actually
|
|
1879
2215
|
// unsticks a reader who has just installed it — would be the third opinion this issue exists to
|
|
@@ -1883,13 +2219,7 @@ export async function runCheck() {
|
|
|
1883
2219
|
// restart a service — neither of which can change the answer, because the refusal is about the
|
|
1884
2220
|
// platform rather than the binary. Naming WSL2 is the only instruction that ends this state.
|
|
1885
2221
|
for (const line of leaveDemoAdvice(engSpec)) info(line);
|
|
1886
|
-
} else
|
|
1887
|
-
// THE COMMAND THE READER CAN TYPE FROM HERE, as the demo line above names its own. A bare
|
|
1888
|
-
// `clearotron` is not on PATH for an install run from npx, and now that the engine program comes
|
|
1889
|
-
// with the install this is the line most installs see first.
|
|
1890
|
-
info("The engine program is installed. Whether it is signed in cannot be read from disk: run "
|
|
1891
|
-
+ `\`${reachableCommand("doctor --probe-engine")}\` to find out.`);
|
|
1892
|
-
}
|
|
2222
|
+
} else if (!signInLineLeads) info(signInLine); // printed here unless the opening carries it
|
|
1893
2223
|
|
|
1894
2224
|
// AND WHETHER THE ENGINE AGREES, which is a different question from the one above and the reason an
|
|
1895
2225
|
// outside user gave up on this product. This command reads its OWN environment; the portal's New
|
|
@@ -1940,11 +2270,7 @@ export async function runCheck() {
|
|
|
1940
2270
|
// see it, with the .env's values overlaid for the keys an engine spawn is made of. The cloud's names
|
|
1941
2271
|
// are on it, because with the billing word read from the file and a cloud's switch left to the shell,
|
|
1942
2272
|
// a cloud file that runs would read as refused.
|
|
1943
|
-
const envForResolve =
|
|
1944
|
-
for (const k of engineEnvKeys()) {
|
|
1945
|
-
const e = effective(k);
|
|
1946
|
-
if (e) envForResolve[k] = e.v;
|
|
1947
|
-
}
|
|
2273
|
+
const envForResolve = engineEnvOf(engineEnvKeys());
|
|
1948
2274
|
const billingOf = (eng, env) => {
|
|
1949
2275
|
try {
|
|
1950
2276
|
const auth = resolveAuthMode({ engineName: eng, env });
|
|
@@ -1966,28 +2292,6 @@ export async function runCheck() {
|
|
|
1966
2292
|
// was the only line claiming a verdict it had not reached.
|
|
1967
2293
|
const engineResolved = !!(bin?.path && bin.executable && !bin.relative);
|
|
1968
2294
|
(engineResolved || here.say === problem ? here.say : info)(here.text);
|
|
1969
|
-
// AND AS THE SERVICES READ IT, when this machine runs them and that reading differs. The line above is
|
|
1970
|
-
// this command's configuration; the services read their own file, and a start never replaces a line
|
|
1971
|
-
// in it. So a machine whose services pay through a cloud account printed "billing: subscription" here,
|
|
1972
|
-
// two sections above "Will a search run?" reading the services' file. Both are said when they differ.
|
|
1973
|
-
// Read as the services read it (servicesRead), never through this shell.
|
|
1974
|
-
//
|
|
1975
|
-
// A CAUTION ONLY WHEN THIS COMMAND SAYS OTHERWISE. With no billing word in this command's configuration,
|
|
1976
|
-
// the line above is the default and contradicts nothing, and a working api-key or cloud install whose
|
|
1977
|
-
// billing lives in the services' file alone was cautioned on every run from a bare shell. Then it is
|
|
1978
|
-
// information. Never a problem: the services' refusal, if there is one, is reported under that section.
|
|
1979
|
-
if (hosted && serviceKnown) {
|
|
1980
|
-
const envForService = {};
|
|
1981
|
-
for (const k of engineEnvKeys()) {
|
|
1982
|
-
const e = servicesRead(k);
|
|
1983
|
-
if (e) envForService[k] = e.v;
|
|
1984
|
-
}
|
|
1985
|
-
const svc = billingOf(String(envForService.CLEAROTRON_AI ?? DEFAULT_ENGINE_ID).trim().toLowerCase(), envForService);
|
|
1986
|
-
if (svc.text !== here.text) {
|
|
1987
|
-
if (effective(engSpec?.authEnv ?? "CLEAROTRON_AI_BILLING")) warn(`the services read how they pay from ${serviceEnvLabel}, and it says otherwise — ${svc.text}`);
|
|
1988
|
-
else info(`the services pay as ${serviceEnvLabel} says — ${svc.text}`);
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
2295
|
} catch (e) {
|
|
1992
2296
|
problem(String(e?.message ?? e));
|
|
1993
2297
|
}
|
|
@@ -2004,37 +2308,10 @@ export async function runCheck() {
|
|
|
2004
2308
|
info("whether it is SIGNED IN is not checked here — add --probe-engine to spend one cheap turn proving it");
|
|
2005
2309
|
} else if (!bin.executable || bin.relative) {
|
|
2006
2310
|
info("not probed — there is no usable binary to probe. Fix the line above first.");
|
|
2007
|
-
} else {
|
|
2311
|
+
} else if (!turnLeads) {
|
|
2312
|
+
// The turn runs here unless it ran for the opening; runTurn and sayTurn are the same either way.
|
|
2008
2313
|
say(`\n ${probingLine(engineId)}`);
|
|
2009
|
-
|
|
2010
|
-
// keys — the probe must bill exactly the way this box bills and moves no other variable.
|
|
2011
|
-
const probeEnv = { ...process.env };
|
|
2012
|
-
// The auth variables ride this list for the same reason CLEAROTRON_AI does: without them the
|
|
2013
|
-
// probe bills the way the AMBIENT environment says rather than the way this .env says, and
|
|
2014
|
-
// "proven" would name a lane no run takes.
|
|
2015
|
-
//
|
|
2016
|
-
// THE CREDENTIALS RIDE IT TOO, and did not. This was a second copy of the list `applyEngineEnv`
|
|
2017
|
-
// applies, and it had dropped the API key and the headless token — so a token kept only in this
|
|
2018
|
-
// install's .env never reached the probe, which then reported the engine signed out while the same
|
|
2019
|
-
// token exported into the shell proved it. `engineEnvKeys` is the probe's own list: the copy that is
|
|
2020
|
-
// filled is now the copy that is applied.
|
|
2021
|
-
for (const k of engineEnvKeys()) {
|
|
2022
|
-
const e = effective(k);
|
|
2023
|
-
if (e) probeEnv[k] = e.v;
|
|
2024
|
-
}
|
|
2025
|
-
const v = await probeEngineTurn({ env: probeEnv });
|
|
2026
|
-
if (v.ok) {
|
|
2027
|
-
ok(`${engineId} completed a turn — binary, credential and model access all work`);
|
|
2028
|
-
const served = servedLine(v);
|
|
2029
|
-
if (served) info(served);
|
|
2030
|
-
// The ONLY route to READY. Everything else in this block reads the filesystem, and a signed-out
|
|
2031
|
-
// CLI passes every filesystem test there is — which is why this line is here and not above.
|
|
2032
|
-
ok("MODE: engine ready — proven by the turn just spent, not inferred from a file being executable.");
|
|
2033
|
-
}
|
|
2034
|
-
else {
|
|
2035
|
-
problem(probeFailureText(v));
|
|
2036
|
-
if (v.detail) info(`engine said: ${v.detail}`);
|
|
2037
|
-
}
|
|
2314
|
+
sayTurn(await runTurn());
|
|
2038
2315
|
}
|
|
2039
2316
|
}
|
|
2040
2317
|
|
|
@@ -2368,8 +2645,20 @@ export async function runCheck() {
|
|
|
2368
2645
|
+ (w.branch ? `whose branch ${w.branch} tracks no remote branch` : "which is not on a branch")
|
|
2369
2646
|
+ " — nothing carries them off this machine unless someone pushes them by name");
|
|
2370
2647
|
} else if (w.state === "not-a-repository") {
|
|
2371
|
-
|
|
2372
|
-
|
|
2648
|
+
// NOT MADE YET IS NOT A REFUSAL. With no units, `start` makes its configuration directory a git
|
|
2649
|
+
// repository the first time it runs (bin/start.mjs, the `git init` of `paths.configStore`), and
|
|
2650
|
+
// setup's default puts the store inside it. Before then this warned a newcomer that saves were
|
|
2651
|
+
// refused (measured on a fresh install of a beta, 2026-11-04). "The first time" is start's own
|
|
2652
|
+
// test, no grants file and no repository yet; a store anywhere else is never made one by start.
|
|
2653
|
+
const handed = hosted ? null : startPaths({ env: { ...(serviceFileEnv ?? {}), ...process.env } });
|
|
2654
|
+
if (handed && isInsideCheckout(storeDir, handed.configStore)
|
|
2655
|
+
&& !existsSync(handed.grants) && !existsSync(join(handed.configStore, ".git"))) {
|
|
2656
|
+
info(`saves to ${storeDir} are recorded from the first \`${invoke("start")}\`, which makes `
|
|
2657
|
+
+ `${handed.configStore} a git repository`);
|
|
2658
|
+
} else {
|
|
2659
|
+
warn(`${storeDir} is not inside a git repository, so a save through the portal is refused rather than `
|
|
2660
|
+
+ "recorded until it is");
|
|
2661
|
+
}
|
|
2373
2662
|
} else {
|
|
2374
2663
|
info(`could not ask git where saves to ${storeDir} go (${w.why}) — a failure to look, not a finding`);
|
|
2375
2664
|
}
|
|
@@ -2481,10 +2770,8 @@ export async function runCheck() {
|
|
|
2481
2770
|
// no register was selected, one screen above "nothing a search is refused for is missing from the units'
|
|
2482
2771
|
// environment": one install, two answers, and the fix it named was already set. effectiveForService is
|
|
2483
2772
|
// the reader that check asks, so the two lines cannot disagree; where it cannot read the units, this
|
|
2484
|
-
// says it could not look rather than reporting the register absent.
|
|
2485
|
-
//
|
|
2486
|
-
// this command's own file, and `effective` has always read and labelled exactly that.
|
|
2487
|
-
const serviceValue = hosted ? effectiveForService : effective;
|
|
2773
|
+
// says it could not look rather than reporting the register absent. That reader is `serviceValue`, above
|
|
2774
|
+
// the opening, which shares it with the research section.
|
|
2488
2775
|
const prov = serviceKnown ? serviceValue("CLEAROTRON_DATABASE") : null;
|
|
2489
2776
|
if (!serviceKnown) {
|
|
2490
2777
|
info(`the units are installed but their environment could not be read (${unitEnv?.why ?? "no reason given"}) — `
|
|
@@ -2501,7 +2788,7 @@ export async function runCheck() {
|
|
|
2501
2788
|
if (!prov) {
|
|
2502
2789
|
blocking(`no register is selected — CLEAROTRON_DATABASE is not set and there is NO default, so every search refuses until one is`);
|
|
2503
2790
|
info(` set it to one of: ${PROVIDERS.map((p) => p.id).join(", ")} — any one of them is enough, and none needs another`);
|
|
2504
|
-
info(` re-run \`${invoke("install")}
|
|
2791
|
+
info(` re-run \`${invoke("install")}\` to set it`);
|
|
2505
2792
|
}
|
|
2506
2793
|
else {
|
|
2507
2794
|
const spec = PROVIDERS.find((p) => p.id === prov.v);
|
|
@@ -2527,12 +2814,7 @@ export async function runCheck() {
|
|
|
2527
2814
|
}
|
|
2528
2815
|
}
|
|
2529
2816
|
|
|
2530
|
-
|
|
2531
|
-
// The same reader as the register, for the same reason: this is a key the services use.
|
|
2532
|
-
const px = serviceKnown ? serviceValue("PERPLEXITY_API_KEY") : null;
|
|
2533
|
-
if (!serviceKnown) info("the units' environment could not be read, so whether the services hold PERPLEXITY_API_KEY is not judged here — a failure to look, not a finding");
|
|
2534
|
-
else if (px) ok(`PERPLEXITY_API_KEY present (${px.from}) — presence only; add --probe-providers to prove it answers`);
|
|
2535
|
-
else info("PERPLEXITY_API_KEY is not set — the three clearance searches carry the common-law grid and cannot switch it off, so a clearance stops before it starts, and names the missing key; a Knockout search still runs and discloses the half it skipped");
|
|
2817
|
+
// "Research provider" is printed second, right after the opening (sayResearch).
|
|
2536
2818
|
|
|
2537
2819
|
// ── — THE LANES A PRODUCT DECLARES IT NEEDS, BEFORE A REPORT NAMES THEM ──
|
|
2538
2820
|
//
|
|
@@ -2549,47 +2831,10 @@ export async function runCheck() {
|
|
|
2549
2831
|
// doctor that hangs on a box with no route — so this reports ENROLMENT, and says plainly that a
|
|
2550
2832
|
// source which is enrolled can still fail at run time. The owner's own report says `CONNECTION_CLOSED`
|
|
2551
2833
|
// on exactly that case.
|
|
2552
|
-
// ── WILL A SEARCH RUN? — THE ORDER-TIME GATE'S OWN QUESTION, OF THE ENVIRONMENT A RUN WILL HAVE ──
|
|
2553
2834
|
//
|
|
2554
|
-
//
|
|
2555
|
-
//
|
|
2556
|
-
|
|
2557
|
-
// refused: it found `claude` on this shell's PATH while the unit, which has no such PATH, was refused
|
|
2558
|
-
// for an engine path it had never been given. Asking the gate's own authority of the units' environment
|
|
2559
|
-
// is what makes an install this command passes one that can run. `blocking`, not `problem`: an install
|
|
2560
|
-
// that is not configured yet is unfinished rather than broken, and the exit status keeps that contract.
|
|
2561
|
-
say("\n Will a search run?");
|
|
2562
|
-
if (!serviceKnown) {
|
|
2563
|
-
info("the units' environment could not be read, so what a search would be refused for is NOT checked here — a failure to look is not a clean result");
|
|
2564
|
-
} else {
|
|
2565
|
-
const tables = { registers: PROVIDERS, engines: ENGINE_BINARIES, defaultEngine: DEFAULT_ENGINE_ID, resolveEngine: resolveEngineProgram };
|
|
2566
|
-
// UNTIL NOTHING NEW IS NAMED: which names a run needs depends on values read in the pass before. The
|
|
2567
|
-
// register and the engine name their credentials, their program and the billing word; a billing word of
|
|
2568
|
-
// `cloud` names the cloud switches and the gateway address; a switch found becomes the blocking row, and
|
|
2569
|
-
// the cloud's other settings are named only where the view already holds them. Two passes stopped before
|
|
2570
|
-
// the billing word was read, so a machine that pays through a cloud account was checked as a subscription
|
|
2571
|
-
// one and its missing switch went unreported. It stops at the first pass that finds no new value: the names
|
|
2572
|
-
// asked for depend only on the values found, so the next pass would ask for the names this one just read.
|
|
2573
|
-
const view = {};
|
|
2574
|
-
// Read as the services read it (servicesRead): a value in this shell never reaches a unit.
|
|
2575
|
-
const fill = (names) => { for (const n of names) { const e = servicesRead(n); if (e) view[n] = e.v; } };
|
|
2576
|
-
fill([REGISTER_ENV, ENGINE_ENV]);
|
|
2577
|
-
let before;
|
|
2578
|
-
do { before = Object.keys(view).length; fill(runRequiredNames(view, tables)); } while (Object.keys(view).length > before);
|
|
2579
|
-
// AND THE PATH THE SERVICES SEARCH, so the engine's program is looked for where a run looks for it.
|
|
2580
|
-
// The view held the settings and no PATH, so a `claude` on the services' PATH, with no path setting and
|
|
2581
|
-
// no copy installed by setup, was reported as a search refused while the run found it and ran. On a
|
|
2582
|
-
// machine with units that PATH is the units' own (every unit sets it, with `%h` for the home, which the
|
|
2583
|
-
// unit reader expands); never this shell's, which the units do not inherit. With no units, the
|
|
2584
|
-
// services are the children of `clearotron start`, which inherit the PATH of the shell it runs in.
|
|
2585
|
-
const servicesPath = hosted ? unitValue(unitEnv, "PATH").value : process.env.PATH;
|
|
2586
|
-
if (servicesPath) view.PATH = servicesPath;
|
|
2587
|
-
const { atOrder } = missingRequirements(view, tables);
|
|
2588
|
-
if (atOrder.length) {
|
|
2589
|
-
blocking(`a search is refused until ${atOrder.length === 1 ? "this is" : "these are"} set in ${serviceEnvLabel}: ${atOrder.map((r) => r.name).join(", ")}`);
|
|
2590
|
-
for (const r of atOrder) info(` ${r.name} — ${r.why}`);
|
|
2591
|
-
} else ok(`nothing a search is refused for at order time is missing from ${serviceEnvLabel}`);
|
|
2592
|
-
}
|
|
2835
|
+
// "Will a search run?" keeps this place when the opening was the refusal's own sentence, which says the
|
|
2836
|
+
// same thing without the names; in every other state it is the opening (sayWillASearchRun).
|
|
2837
|
+
if (leadIsTheRefusal) sayWillASearchRun();
|
|
2593
2838
|
|
|
2594
2839
|
say("\n Case law and other capabilities");
|
|
2595
2840
|
{
|
|
@@ -3189,22 +3434,37 @@ export async function runCheck() {
|
|
|
3189
3434
|
} catch (e) { warn(`the submit lane could not be read: ${e.message}`); }
|
|
3190
3435
|
|
|
3191
3436
|
say("\n Client connector");
|
|
3192
|
-
// THE REVOCATION LIST, REPORTED (found in review). `isRevoked`
|
|
3193
|
-
//
|
|
3194
|
-
//
|
|
3195
|
-
//
|
|
3437
|
+
// THE REVOCATION LIST, REPORTED (found in review). `isRevoked` used to read an unreadable denylist as
|
|
3438
|
+
// "not revoked", so a named-but-absent file made every revocation silently ineffective: measured on a
|
|
3439
|
+
// default install, a revoked key completed a full handshake with nothing logged. It now refuses every
|
|
3440
|
+
// key (shared/scope.mjs), and this is where the reader learns why.
|
|
3196
3441
|
{
|
|
3197
3442
|
const { defaultDenylistPath } = await import(pathToFileURL(join(REPO, "shared", "client-door.mjs")).href);
|
|
3198
|
-
const
|
|
3443
|
+
const named = effective("TRADEMARK_MCP_TOKEN_DENYLIST")?.v;
|
|
3444
|
+
const dl = named || defaultDenylistPath(homedir());
|
|
3199
3445
|
try {
|
|
3200
3446
|
const n = readFileSync(dl, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#")).length;
|
|
3201
3447
|
ok(`revocation list readable at ${dl} — ${n} revoked key id(s)`);
|
|
3202
3448
|
} catch (e) {
|
|
3203
|
-
//
|
|
3204
|
-
//
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3449
|
+
// THE DEFAULT LIST, NOT WRITTEN YET, IS NOTHING REVOKED. That is the key check's own rule
|
|
3450
|
+
// (shared/scope.mjs, `isRevoked`): every revocation creates the file it writes to, so its absence is
|
|
3451
|
+
// the proof. With no units the first `start` creates it, and before then this warned a newcomer that
|
|
3452
|
+
// revoking would silently do nothing (measured on a fresh install of a beta, 2026-11-04). "Before
|
|
3453
|
+
// then" is start's own first-run test, as for the store above: no grants file and no repository yet.
|
|
3454
|
+
// Once start has run it hands its door this path BY NAME, and a named list the key check cannot read
|
|
3455
|
+
// refuses every key; so does a list the settings name, or one on a machine with units. Those are
|
|
3456
|
+
// still the fault below.
|
|
3457
|
+
const handed = hosted ? null : startPaths({ env: { ...(serviceFileEnv ?? {}), ...process.env } });
|
|
3458
|
+
if (!named && handed && e?.code === "ENOENT"
|
|
3459
|
+
&& !existsSync(handed.grants) && !existsSync(join(handed.configStore, ".git"))) {
|
|
3460
|
+
info(`no revocation list yet at ${dl}: no key has been revoked. The first \`${invoke("start")}\` creates it.`);
|
|
3461
|
+
} else {
|
|
3462
|
+
// NOT `warn`. The door refuses every key while its list cannot be read, so every assistant connected
|
|
3463
|
+
// to it stops, and this sentence is the door's own (mcp-server/lib/http-handler.mjs).
|
|
3464
|
+
blocking(`the revocation list at ${dl} cannot be read (${e.code ?? e.message}) — this install cannot `
|
|
3465
|
+
+ "check whether keys have been revoked, so it is refusing all of them. "
|
|
3466
|
+
+ `Run \`${invoke("start")}\` — it creates the list.`);
|
|
3467
|
+
}
|
|
3208
3468
|
}
|
|
3209
3469
|
}
|
|
3210
3470
|
// ── IS THIS DOOR'S ACCESS LOG BEING WRITTEN, AND WHERE? ───────────────────────────────────────────
|
|
@@ -3573,17 +3833,17 @@ export async function runCheck() {
|
|
|
3573
3833
|
// different actions from the reader — edit a file versus fix a credential — and a single number
|
|
3574
3834
|
// covering both sends them to the wrong one.
|
|
3575
3835
|
if (inert.length) parts.push(`${inert.length} setting(s) being ignored`);
|
|
3576
|
-
say(` ${parts.join(" and ")}. Nothing was written — this command only reads
|
|
3836
|
+
say(` ${parts.join(" and ")}. ${probeTurnRan ? TURN_KEPT_ITS_FILES : "Nothing was written — this command only reads."}\n`);
|
|
3577
3837
|
return 1;
|
|
3578
3838
|
}
|
|
3579
3839
|
// The exit status stays 0: an unfinished install is not a broken one, and `--check` separates an
|
|
3580
3840
|
// absence from a misconfiguration. What changed is that the closing line no longer says nothing is
|
|
3581
3841
|
// wrong while something that stops the product stands above it.
|
|
3582
3842
|
if (blockers.length) {
|
|
3583
|
-
say(
|
|
3843
|
+
say(` Nothing is MISconfigured — fix those and nothing else here needs changing. ${probeTurnRan ? TURN_KEPT_ITS_FILES : "Nothing was written."}\n`);
|
|
3584
3844
|
return 0;
|
|
3585
3845
|
}
|
|
3586
|
-
say(
|
|
3846
|
+
say(` Nothing wrong with what is configured. ${probeTurnRan ? TURN_KEPT_ITS_FILES : "Nothing was written."}\n`);
|
|
3587
3847
|
return 0;
|
|
3588
3848
|
}
|
|
3589
3849
|
|
|
@@ -3596,6 +3856,17 @@ export async function runCheck() {
|
|
|
3596
3856
|
// back. Exported so the test drives the options this file uses; above the call below, which reads it.
|
|
3597
3857
|
export const SETUP_READLINE = Object.freeze({ terminal: true, historySize: 0 });
|
|
3598
3858
|
|
|
3859
|
+
/**
|
|
3860
|
+
* What setup says when it cannot move out of npx's cache, and the install that lasts, ON THIS CHANNEL.
|
|
3861
|
+
* `npm install -g clearotron` installs the stable, so on a beta it named the other channel.
|
|
3862
|
+
*/
|
|
3863
|
+
export function stuckInNpxCacheNote(skip, pkg = channelPackage()) {
|
|
3864
|
+
return [
|
|
3865
|
+
`\n Note: this is running from npm's temporary npx cache and cannot be moved out of it here (${skip}).`,
|
|
3866
|
+
` It will stop working when npm cleans that cache. \`npm install -g ${pkg}\` installs it permanently.\n`,
|
|
3867
|
+
];
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3599
3870
|
if (!isEntrypoint(import.meta.url)) {
|
|
3600
3871
|
// imported, not run — do nothing else
|
|
3601
3872
|
} else {
|
|
@@ -3649,10 +3920,7 @@ if (move && !move.skip && process.env.CLEAROTRON_RELOCATED !== "1") {
|
|
|
3649
3920
|
const moved = spawnSync(process.execPath, [move.entry, "install", ...process.argv.slice(2)], { stdio: "inherit", env });
|
|
3650
3921
|
process.exit(moved.status ?? 1);
|
|
3651
3922
|
}
|
|
3652
|
-
if (move?.skip)
|
|
3653
|
-
console.error(`\n Note: this is running from npm's temporary npx cache and cannot be moved out of it here (${move.skip}).`);
|
|
3654
|
-
console.error(" It will stop working when npm cleans that cache. `npm install -g clearotron` installs it permanently.\n");
|
|
3655
|
-
}
|
|
3923
|
+
if (move?.skip) for (const line of stuckInNpxCacheNote(move.skip)) console.error(line);
|
|
3656
3924
|
|
|
3657
3925
|
// A credential typed at a prompt is echoed by the terminal and then sits in scrollback, in tmux history,
|
|
3658
3926
|
// in whatever the reader pastes into a bug report. So the echo is muted while a secret is being typed:
|
|
@@ -3770,10 +4038,17 @@ const choose = async (q, options, def = 0, after = []) => {
|
|
|
3770
4038
|
|
|
3771
4039
|
const candidate = {};
|
|
3772
4040
|
let aborted = null;
|
|
4041
|
+
// WHAT SETUP HAS ALREADY PUT ON THE MACHINE, for the line a cancel prints (cancelledLine). Run from npx, the
|
|
4042
|
+
// copy this process runs from was installed by the process that started it, under the same prefix.
|
|
4043
|
+
const installedCopy = process.env.CLEAROTRON_RELOCATED === "1" ? { version: ownVersion(), prefix: permanentPrefix() } : null;
|
|
4044
|
+
let installedEngine = null;
|
|
4045
|
+
let setupTurnRan = false;
|
|
3773
4046
|
try {
|
|
3774
4047
|
say("\n Trademark clearance engine — setup\n");
|
|
3775
4048
|
say(" One question at a time. Enter takes the default in brackets.");
|
|
3776
|
-
|
|
4049
|
+
// "No setting", not "Nothing": by the end of a cancelled setup its own copy, the AI's program and a test
|
|
4050
|
+
// turn's files may be on the machine (cancelledLine), and only the settings wait for the checks.
|
|
4051
|
+
say(" No setting is written until each credential you give has been checked, except a paid register key: checking it would cost you, so it is written on your word.\n");
|
|
3777
4052
|
|
|
3778
4053
|
// ── BEFORE YOU START, derived from what the product declares it needs ──────
|
|
3779
4054
|
//
|
|
@@ -3781,13 +4056,13 @@ try {
|
|
|
3781
4056
|
// what to prepare by failing the question — the owner's own first run, in his words. The list below
|
|
3782
4057
|
// is DERIVED: the engines from ENGINE_BINARIES, the search vendors from the same adapter tables the
|
|
3783
4058
|
// prompts loop over, each wearing its own table row's where-to-get line. A hand-kept copy here would
|
|
3784
|
-
// be the SERPAPI defect again, one screen earlier. Everything
|
|
4059
|
+
// be the SERPAPI defect again, one screen earlier. Everything but the organisation's name is skippable.
|
|
3785
4060
|
// THE BANNER — once, on entry, named (ruling 2026-08-31). Not on every
|
|
3786
4061
|
// command: a banner every verb prints is how a product becomes tiresome to use twice. It sits here
|
|
3787
4062
|
// rather than at the top of main() so that `--check`, which writes nothing and is run repeatedly,
|
|
3788
4063
|
// does not wear it either.
|
|
3789
4064
|
say("");
|
|
3790
|
-
say(banner({ title: "Clearotron setup", subtitle: "one pass, and everything here is skippable", style,
|
|
4065
|
+
say(banner({ title: "Clearotron setup", subtitle: "one pass, and everything here but your organisation's name is skippable", style,
|
|
3791
4066
|
mark: bracketAsciiCells(), columns: process.stdout.columns }));
|
|
3792
4067
|
say("");
|
|
3793
4068
|
say(` ${style.bold("Before you start")} — what this setup can take, so nothing here surprises you:`);
|
|
@@ -3821,6 +4096,7 @@ try {
|
|
|
3821
4096
|
say("\n Engine");
|
|
3822
4097
|
say(" Clearotron runs each step of a search as a short, unattended session of an AI. One AI serves");
|
|
3823
4098
|
say(" every search on this computer, so it is not chosen per search.");
|
|
4099
|
+
let lastPick = null; // the AI picked on the pass before this one (engineMenuDefault)
|
|
3824
4100
|
engine: for (;;) {
|
|
3825
4101
|
// ── THE STATE FIRST, THE QUESTIONS OFF IT ──────────────────────────────
|
|
3826
4102
|
//
|
|
@@ -3836,8 +4112,10 @@ try {
|
|
|
3836
4112
|
// only honest answer to it, and a guessed "signed in" that the turn then contradicts costs more than
|
|
3837
4113
|
// no claim. Resolved once per pass, so a reader who mends something and comes back sees it mended.
|
|
3838
4114
|
const found = engineMenuState();
|
|
3839
|
-
const
|
|
4115
|
+
const options = engineOptions(found);
|
|
4116
|
+
const pick = await choose(ENGINE_QUESTION, options, engineMenuDefault(options, lastPick), PAY_PREAMBLE);
|
|
3840
4117
|
if (!pick.id) { sayNoEngine(); break; }
|
|
4118
|
+
lastPick = pick.id;
|
|
3841
4119
|
const eng = ENGINE_BINARIES[pick.id];
|
|
3842
4120
|
|
|
3843
4121
|
let bin = resolveEngineBin(process.env[eng.env] || eng.fallback, { engine: pick.id });
|
|
@@ -3886,6 +4164,7 @@ try {
|
|
|
3886
4164
|
if (r.error) problem(`could not run it: ${r.error.message}`);
|
|
3887
4165
|
else if (r.status !== 0) warn(`that command exited ${r.status ?? "on a signal"} — checking anyway, since its exit code is not what settles this.`);
|
|
3888
4166
|
bin = resolveEngineBin(eng.fallback, { engine: pick.id });
|
|
4167
|
+
if (bin.source === "installed") installedEngine = { vendor: eng.vendor, dir };
|
|
3889
4168
|
if (bin.executable && !bin.relative) { if (bin.source === "installed") ok(`installed: ${bin.path}`); }
|
|
3890
4169
|
else warn(cannotRunLine(eng, bin, ""));
|
|
3891
4170
|
// RESOLVED WITH THE ENGINE'S DEFAULT WORD, NOT THE SETTING IN FORCE. The line above the offer promised
|
|
@@ -3974,7 +4253,7 @@ try {
|
|
|
3974
4253
|
if (authPick.id === "api-key") {
|
|
3975
4254
|
if (ambientKeyPresent) {
|
|
3976
4255
|
apiKey = process.env[eng.apiKeyEnv];
|
|
3977
|
-
info(`${eng.apiKeyEnv} is already in your environment — adopting it, so the .env this writes
|
|
4256
|
+
info(`${eng.apiKeyEnv} is already in your environment — adopting it, so the .env this writes carries the key the test turn uses.`);
|
|
3978
4257
|
} else {
|
|
3979
4258
|
apiKey = await askValue(`${eng.apiKeyEnv}:`, { secret: true });
|
|
3980
4259
|
}
|
|
@@ -4010,23 +4289,32 @@ try {
|
|
|
4010
4289
|
//
|
|
4011
4290
|
// THE CHECK IS UNCHANGED AND THE REFUSAL IS UNCHANGED. He valued both, and the issue puts them out
|
|
4012
4291
|
// of scope explicitly — what was wrong was the sentence around them, so only the sentence moved.
|
|
4013
|
-
//
|
|
4014
|
-
//
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4292
|
+
// proofPreamble says what a reader needs to decide with: what the turn costs, and that answering no
|
|
4293
|
+
// saves nothing.
|
|
4294
|
+
for (const line of proofPreamble({ product: eng.product, billing: authPick.id })) info(line);
|
|
4295
|
+
if (!await confirm(proveQuestion({ product: eng.product, billing: authPick.id }), true)) {
|
|
4296
|
+
// A WAY ON WITHOUT AN AI, BEFORE THE MENU. A declined proof went straight back to the menu, so a reader
|
|
4297
|
+
// taking every default went round the same setup again. The question the no-program path already asks
|
|
4298
|
+
// offers the way on; no returns to the menu, with this pick its default, and only that answer says so.
|
|
4299
|
+
if (await confirm("Continue with no engine configured?", true)) { sayNoEngine(); break engine; }
|
|
4018
4300
|
info("Not proven, so not written. Pick again — the last row configures no engine at all.");
|
|
4019
4301
|
continue;
|
|
4020
4302
|
}
|
|
4303
|
+
// A TOKEN PASTED BELOW IS SAVED ONLY WITH THE TURN IT PROVED. It was written into the settings as it was
|
|
4304
|
+
// pasted, so a reader whose turn still failed, and who then went on without an AI, had it saved unproved.
|
|
4305
|
+
let pastedToken = null;
|
|
4021
4306
|
for (;;) {
|
|
4022
4307
|
say(" Running one turn…");
|
|
4023
4308
|
// Read on every try, so a setting the reader fixes in the file between tries is the one the next turn uses.
|
|
4024
4309
|
const v = await probeEngineTurn(proofTurn({ engineId: pick.id, eng, bin, authEnv, settings: settingsInForce() }));
|
|
4310
|
+
// A turn refused before it started the program left no files of the program's own (runCheck's runTurn).
|
|
4311
|
+
if (v.ok || v.basis !== "config") setupTurnRan = true;
|
|
4025
4312
|
if (v.ok) {
|
|
4026
|
-
ok(`${
|
|
4313
|
+
ok(`${eng.product} completed a turn on ${PAYS_WITH[authPick.id]} — binary, credential, billing mode and model access all work.`);
|
|
4027
4314
|
const served = servedLine(v);
|
|
4028
4315
|
if (served) info(served);
|
|
4029
4316
|
candidate.CLEAROTRON_AI = pick.id;
|
|
4317
|
+
if (pastedToken !== null) candidate[eng.headless.tokenEnv] = pastedToken;
|
|
4030
4318
|
// ALWAYS WRITTEN, and for the copy Clearotron installed it is the engine's default word: see
|
|
4031
4319
|
// engineProgramSetting for why leaving it out was not enough.
|
|
4032
4320
|
candidate[eng.env] = engineProgramSetting(eng, bin);
|
|
@@ -4036,14 +4324,14 @@ try {
|
|
|
4036
4324
|
const cloudLines = Object.entries(cloudEnv ?? {}).filter(([k]) => k !== eng.authEnv);
|
|
4037
4325
|
for (const [k, val] of cloudLines) candidate[k] = val;
|
|
4038
4326
|
info(`CLEAROTRON_AI=${pick.id}`);
|
|
4039
|
-
info(`${eng.authEnv}=${authPick.id} —
|
|
4327
|
+
info(`${eng.authEnv}=${authPick.id} — how the turn above was paid for.`);
|
|
4040
4328
|
if (apiKey) info(`${eng.apiKeyEnv}=… — adopted, so a run bills the way you just proved.`);
|
|
4041
4329
|
for (const [k, val] of cloudLines) info(shownSetting(k, val));
|
|
4042
4330
|
if (bin.source === "installed") info(`${eng.env}=${eng.fallback} — the engine's default: this machine's own \`${eng.fallback}\` once it has one, and the copy Clearotron installed until then.`);
|
|
4043
4331
|
else info(`${eng.env}=${bin.path} — the absolute form, because a service's PATH is not your shell's.`);
|
|
4044
4332
|
break engine;
|
|
4045
4333
|
}
|
|
4046
|
-
problem(
|
|
4334
|
+
problem(proofFailureLine(v, eng.product));
|
|
4047
4335
|
// ── THE ENGINE'S OWN LAST LINES, UNDER EVERY VERDICT, ON BOTH LANES ──────────────────────────
|
|
4048
4336
|
//
|
|
4049
4337
|
// This used to be `if (v.detail)`, so a verdict carrying no detail printed a headline and nothing
|
|
@@ -4054,10 +4342,9 @@ try {
|
|
|
4054
4342
|
//
|
|
4055
4343
|
// SAY WHICH IT IS, INCLUDING WHEN THERE IS NOTHING. "The engine printed nothing" is itself the
|
|
4056
4344
|
// diagnosis on a binary that died before it opened its mouth, and printing no line at all leaves
|
|
4057
|
-
// a reader unable to tell that from a wizard that decided not to show them.
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
if (v.basis) info(`(that reading is ${v.basis === "text-match" ? "matched out of the text above, not a signal from the provider" : v.basis})`);
|
|
4345
|
+
// a reader unable to tell that from a wizard that decided not to show them. A program refused before it
|
|
4346
|
+
// started said nothing because it never ran, so proofEvidence shows no line for it.
|
|
4347
|
+
for (const line of proofEvidence(v)) info(line);
|
|
4061
4348
|
// — THE HAND-OFF. Signing in is the one step of this sequence nobody here can perform for
|
|
4062
4349
|
// someone, so the wizard names the command, waits, and re-probes rather than ending at a
|
|
4063
4350
|
// description of what is wrong. The text comes from ENGINE_BINARIES so the two adapters cannot
|
|
@@ -4065,6 +4352,20 @@ try {
|
|
|
4065
4352
|
// subscription's step, and on a cloud or under a key the verdict above has named what to check.
|
|
4066
4353
|
const handOff = signInHandOff(eng, bin, authPick.id);
|
|
4067
4354
|
for (const line of handOff.lines) info(line);
|
|
4355
|
+
// — found in review, and the same trap closed one prompt over. The default
|
|
4356
|
+
// was YES, so Enter re-ran a probe that CANNOT succeed until the reader has signed in somewhere
|
|
4357
|
+
// else — and the wizard's own header tells them Enter is the safe key. Driven with Enter it went
|
|
4358
|
+
// 19 attempts, no cap and no escape, in a wizard whose header says everything here is skippable.
|
|
4359
|
+
//
|
|
4360
|
+
// Enter now declines, and the question after it is the one the no-program path asks, whose Enter
|
|
4361
|
+
// goes on with no AI: a reader taking every default no longer goes round the menu again. No returns
|
|
4362
|
+
// to the engine menu with this AI its default, and that line says what going on without one costs.
|
|
4363
|
+
if (!await confirm("Fixed it? Run the turn again", false)) {
|
|
4364
|
+
if (await confirm("Continue with no engine configured?", true)) { sayNoEngine(); break engine; }
|
|
4365
|
+
info("Not proven, so not written. Back to the engine menu — its last row configures no engine: "
|
|
4366
|
+
+ "the demo and a replayed report still work, and a real clearance refuses by name until one is set.");
|
|
4367
|
+
continue engine;
|
|
4368
|
+
}
|
|
4068
4369
|
// ── THE HEADLESS ENDING ────────────────────────────────────────────────
|
|
4069
4370
|
//
|
|
4070
4371
|
// On a box with no browser the interactive sign-in cannot complete, and the documented route had
|
|
@@ -4074,30 +4375,21 @@ try {
|
|
|
4074
4375
|
// stream layout is not ours to guess at, and a paste works whatever it prints where. Codex's
|
|
4075
4376
|
// headless ending writes its own auth file and there is nothing to capture — the command is
|
|
4076
4377
|
// named, and the re-probe is the proof either way.
|
|
4378
|
+
//
|
|
4379
|
+
// ASKED AFTER THE RETRY'S YES, NOT BEFORE IT. The hand-off above asks for that yes by name, and a reader
|
|
4380
|
+
// who had signed in in the browser met this question first, which wants a no from them. The turn has not
|
|
4381
|
+
// run again yet, so a token pasted here is still the one it proves.
|
|
4077
4382
|
if (handOff.captureToken) {
|
|
4078
4383
|
// A TOKEN PASTED AT THE YES/NO IS THE ANSWER (confirmOrKey): taken, never shown, not asked for twice.
|
|
4079
4384
|
const answer = await confirmOrKey(`Did that give you a token to paste? Capture it into ${eng.headless.tokenEnv} now`, false, { what: "token" });
|
|
4080
4385
|
const tok = answer.value ?? (answer.yes
|
|
4081
4386
|
? await askValue(`${eng.headless.tokenEnv}:`, { secret: true, skippable: true, skipped: "Nothing captured." }) : null);
|
|
4082
4387
|
if (tok !== null) {
|
|
4083
|
-
|
|
4388
|
+
pastedToken = tok;
|
|
4084
4389
|
authEnv[eng.headless.tokenEnv] = tok; // the re-probe below must prove the sign-in WITH it
|
|
4085
4390
|
info(`${eng.headless.tokenEnv} captured — the turn below proves it before anything is written.`);
|
|
4086
4391
|
}
|
|
4087
4392
|
}
|
|
4088
|
-
// — found in review, and the same trap closed one prompt over. The default
|
|
4089
|
-
// was YES, so Enter re-ran a probe that CANNOT succeed until the reader has signed in somewhere
|
|
4090
|
-
// else — and the wizard's own header tells them Enter is the safe key. Driven with Enter it went
|
|
4091
|
-
// 19 attempts, no cap and no escape, in a wizard whose header says everything here is skippable.
|
|
4092
|
-
//
|
|
4093
|
-
// Enter now declines. The reader lands back on the engine menu, whose last row configures no
|
|
4094
|
-
// engine at all, so the way out is the one that already exists rather than a second one invented
|
|
4095
|
-
// here — and the line says what that costs before they take it.
|
|
4096
|
-
if (!await confirm("Fixed it? Run the turn again", false)) {
|
|
4097
|
-
info("Not proven, so not written. Back to the engine menu — its last row configures no engine: "
|
|
4098
|
-
+ "the demo and a replayed report still work, and a real clearance refuses by name until one is set.");
|
|
4099
|
-
continue engine;
|
|
4100
|
-
}
|
|
4101
4393
|
}
|
|
4102
4394
|
}
|
|
4103
4395
|
|
|
@@ -4115,8 +4407,9 @@ try {
|
|
|
4115
4407
|
|
|
4116
4408
|
// 4 ── register provider
|
|
4117
4409
|
say("\n Register provider");
|
|
4118
|
-
|
|
4119
|
-
say("
|
|
4410
|
+
// "(default)" below is the answer Enter picks, so the line says what the engine does with none: it refuses.
|
|
4411
|
+
say(" This decides which register gets searched, and which vendor gets billed. Every search refuses");
|
|
4412
|
+
say(" until one is set.");
|
|
4120
4413
|
// THE LAST ROW IS NOT A REGISTER, as on the AI question, and with the same words. Leaving the register
|
|
4121
4414
|
// unset was reachable only by picking a vendor and skipping its credential, so a reader who meant "none
|
|
4122
4415
|
// yet" had to pretend to choose one. Choosing it takes the branch a skipped credential reaches below.
|
|
@@ -4170,7 +4463,7 @@ try {
|
|
|
4170
4463
|
say("");
|
|
4171
4464
|
info("No register is selected, and nothing register-related will be written.");
|
|
4172
4465
|
info(`Every search refuses until one is set — \`${invoke("doctor")}\` says so on every run, and the`);
|
|
4173
|
-
info(" Installation settings page says it too. Re-run setup
|
|
4466
|
+
info(" Installation settings page says it too. Re-run setup when you have a credential.");
|
|
4174
4467
|
}
|
|
4175
4468
|
for (const k of registerSelected ? (spec.optionalCredentials ?? []) : []) {
|
|
4176
4469
|
if (present(candidate[k])) { ok(`${k} already adopted from your environment`); continue; }
|
|
@@ -4241,7 +4534,7 @@ try {
|
|
|
4241
4534
|
// table row carries. A live check runs where one exists, keyed on the credential's name.
|
|
4242
4535
|
say("\n Search credentials");
|
|
4243
4536
|
const liveChecks = { PERPLEXITY_API_KEY: validatePerplexity };
|
|
4244
|
-
for (const [tableLabel, table] of [["research", RESEARCH_PROVIDERS], ["the
|
|
4537
|
+
for (const [tableLabel, table] of [["research", RESEARCH_PROVIDERS], ["the Chinese marketplace search", SERP_PROVIDERS]]) {
|
|
4245
4538
|
for (const adapter of Object.values(table)) {
|
|
4246
4539
|
const name = adapter.credEnv;
|
|
4247
4540
|
say("");
|
|
@@ -4369,18 +4662,16 @@ try {
|
|
|
4369
4662
|
// consequence at the end. Its explanation of WHY an assistant reaches the box from a vendor's cloud is
|
|
4370
4663
|
// genuinely useful and is a document, not a prompt — it lives in mcp-server/CONNECT.md, and the prompt
|
|
4371
4664
|
// carries one line and a pointer.
|
|
4372
|
-
say("\n
|
|
4665
|
+
say("\n Optional: the public connector address");
|
|
4373
4666
|
prose("An assistant connects from its maker's servers, not from your machine, so this has to be an",
|
|
4374
4667
|
"address on the public internet, over https.");
|
|
4375
|
-
prose("No default — it is your hostname. Skip it and this stays a local install: everything works"
|
|
4376
|
-
"here, and the Use-your-AI page says so rather than handing out an address that fails.");
|
|
4668
|
+
prose("No default — it is your hostname. Skip it and this stays a local install: everything works here, and the Connect your AI page says so rather than handing out an address that fails.");
|
|
4377
4669
|
prose("The usual shape, and why: mcp-server/CONNECT.md.");
|
|
4378
4670
|
const { clientDoorReachability } = await import(pathToFileURL(join(REPO, "shared", "client-door.mjs")).href);
|
|
4379
4671
|
for (;;) {
|
|
4380
4672
|
const clientUrl = await askValue("Public connector address:", {
|
|
4381
4673
|
skippable: true,
|
|
4382
|
-
skipped: "CLEAROTRON_CLIENT_MCP_URL left unset — the
|
|
4383
|
-
+ "show their empty state, which is correct for a local install",
|
|
4674
|
+
skipped: "CLEAROTRON_CLIENT_MCP_URL left unset — the Connect your AI page and a report's Ask AI control will show their empty state, which is correct for a local install",
|
|
4384
4675
|
});
|
|
4385
4676
|
if (clientUrl === null) break;
|
|
4386
4677
|
const trimmed = clientUrl.trim();
|
|
@@ -4418,8 +4709,7 @@ try {
|
|
|
4418
4709
|
// making a decision about where their customer data lives without being told they had made it.
|
|
4419
4710
|
const cfgDefault = join(base, "config");
|
|
4420
4711
|
say("\n Where this install keeps its own configuration");
|
|
4421
|
-
prose(
|
|
4422
|
-
"lets you take updates with `git pull` instead of merging into files you never meant to own.");
|
|
4712
|
+
prose(configOutsideWhy(PACKAGED));
|
|
4423
4713
|
prose(`Enter accepts ${cfgDefault}, and your customers are written there.`);
|
|
4424
4714
|
const cfg = await askValue("Configuration directory:", { def: cfgDefault });
|
|
4425
4715
|
|
|
@@ -4428,9 +4718,9 @@ try {
|
|
|
4428
4718
|
// `<repo>-notes` is not mistaken for a path inside `<repo>`.
|
|
4429
4719
|
const cfgAbs = resolve(cfg);
|
|
4430
4720
|
if (isInsideCheckout(cfg, REPO)) {
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4721
|
+
const [inside, ...why] = configInsideRefusal(PACKAGED, cfgAbs, resolve(REPO));
|
|
4722
|
+
problem(inside);
|
|
4723
|
+
for (const line of why) say(` ${line}`);
|
|
4434
4724
|
aborted = "config-inside-checkout";
|
|
4435
4725
|
throw new Error("config-inside-checkout");
|
|
4436
4726
|
}
|
|
@@ -4466,10 +4756,7 @@ try {
|
|
|
4466
4756
|
//
|
|
4467
4757
|
// Note for whoever adds an overlay later: it needs this name set, which is why the line below says so
|
|
4468
4758
|
// rather than leaving a reader to discover that files they dropped in are being ignored.
|
|
4469
|
-
info(
|
|
4470
|
-
+ `product's own files are used. To override an instruction file later, put it in ${join(cfg, "skills")}, `
|
|
4471
|
-
+ `COMMIT it in ${cfg}, and set CLEAROTRON_INSTRUCTIONS_DIR to that directory — an uncommitted store `
|
|
4472
|
-
+ "cannot be identified, and a run says so rather than guessing.");
|
|
4759
|
+
info(customInstructionsNone(cfg));
|
|
4473
4760
|
|
|
4474
4761
|
// DELIBERATELY NOT SEEDED, and this reverses what the issue asked for. Copying the house `generic.json`
|
|
4475
4762
|
// in would make the store a working install — but since an EMPTY store already is one: profiles
|
|
@@ -4480,9 +4767,7 @@ try {
|
|
|
4480
4767
|
// PRECISELY what shows through, because the last wording said "bundled customers" and the loader
|
|
4481
4768
|
// says otherwise: the demo roster never layers into a deployment (a typo'd key must not resolve to
|
|
4482
4769
|
// our fixtures), generic.json falls through BY NAME, and doctrine resolves file-by-file.
|
|
4483
|
-
|
|
4484
|
-
say(" fallback — falls through by name, so an empty store is a working install. Your own customers");
|
|
4485
|
-
say(" are added here by name; the bundled demo customers never show through into your roster.");
|
|
4770
|
+
prose(EMPTY_CONFIG_FOLDER);
|
|
4486
4771
|
|
|
4487
4772
|
// 7c ── YOUR ORGANISATION, AND WHO SIGNS IN
|
|
4488
4773
|
//
|
|
@@ -4512,9 +4797,9 @@ try {
|
|
|
4512
4797
|
// silently passed over. A reader who is told a preflight ran and passed, when it never ran, learns
|
|
4513
4798
|
// to trust a line that means nothing.
|
|
4514
4799
|
if (registerSelected) {
|
|
4515
|
-
say("\n Running the
|
|
4800
|
+
say("\n Running the register credential check over these values…");
|
|
4516
4801
|
const pf = await preflightCandidate(candidate);
|
|
4517
|
-
if (pf.ok) ok(
|
|
4802
|
+
if (pf.ok) ok(registerCheckPassed(pf.result.provider, pf.result.checked.join(" + ")));
|
|
4518
4803
|
else {
|
|
4519
4804
|
problem(pf.error);
|
|
4520
4805
|
say("\n Nothing has been written.");
|
|
@@ -4522,9 +4807,8 @@ try {
|
|
|
4522
4807
|
throw new Error("preflight");
|
|
4523
4808
|
}
|
|
4524
4809
|
} else {
|
|
4525
|
-
say("
|
|
4526
|
-
|
|
4527
|
-
say(" untouched, and this is only setup declining to fail an install it was told to allow.");
|
|
4810
|
+
say("");
|
|
4811
|
+
prose(REGISTER_CHECK_SKIPPED);
|
|
4528
4812
|
}
|
|
4529
4813
|
|
|
4530
4814
|
// 9 ── write, atomically
|
|
@@ -4558,7 +4842,7 @@ try {
|
|
|
4558
4842
|
// portal reads an empty folder the same way: it overrides nothing. It is here so that the place an
|
|
4559
4843
|
// override goes exists, and so the line below is true of both folders it describes.
|
|
4560
4844
|
mkdirSync(join(cfg, "skills"), { recursive: true });
|
|
4561
|
-
ok(
|
|
4845
|
+
ok(configFoldersMade(cfg));
|
|
4562
4846
|
|
|
4563
4847
|
// 9a ── PUT THE VERB ON THIS OPERATOR'S PATH
|
|
4564
4848
|
//
|
|
@@ -4625,23 +4909,29 @@ try {
|
|
|
4625
4909
|
// and asserts which command LEADS; a command named here would lead instead, and the guard that has
|
|
4626
4910
|
// twice caught this screen regressing would start reporting the wrong thing.
|
|
4627
4911
|
const stateLine = (label, value, absent) => `${value ? "set" : "not set"} — ${label}: ${value || absent}`;
|
|
4628
|
-
|
|
4629
|
-
|
|
4912
|
+
// The AI by the name the engine question gives it; none unless one passed its proof turn.
|
|
4913
|
+
const aiChosen = ENGINE_BINARIES[candidate.CLEAROTRON_AI]?.product ?? "";
|
|
4914
|
+
// "NOTHING HERE NEEDS RUNNING AGAIN" ONLY WITH AN AI AND A REGISTER CHOSEN. Without either, setup
|
|
4915
|
+
// has already told the reader to run it again (NO_AI_CHOSEN, and the warning under a missing register).
|
|
4916
|
+
say(`\n ${style.bold("Setup finished.")}${aiChosen && registerSelected ? " Nothing here needs running again." : ""}\n`);
|
|
4917
|
+
say(" What this install has now:");
|
|
4630
4918
|
for (const line of [
|
|
4631
4919
|
// THE ONE PLACE THE ADDRESS IS SHOWN (ruling, 2026-09-10): setup no longer asks for it.
|
|
4632
4920
|
stateLine("signs in as", candidate.PORTAL_LOCAL_USER, "the local account"),
|
|
4921
|
+
stateLine("AI", aiChosen, "none chosen; the demo works without one, and a real search needs one"),
|
|
4633
4922
|
stateLine("register", candidate.CLEAROTRON_DATABASE, "no register, so every search refuses until one is chosen"),
|
|
4634
4923
|
stateLine("web research", present(candidate.PERPLEXITY_API_KEY) ? "a key" : "", "a clearance stops before it starts, and names the missing key; a knockout search runs and discloses the half it skipped"),
|
|
4635
4924
|
stateLine("data directory", candidate.CLEAROTRON_REPORTS_DIR, "unset"),
|
|
4636
4925
|
stateLine("configuration store", candidate.CLEAROTRON_CUSTOMERS_DIR, "the bundled demo roster"),
|
|
4637
4926
|
stateLine("notification links", candidate.CLEAROTRON_REPORTS_URL, "notifications carry no link into the report"),
|
|
4638
|
-
stateLine("client connector", candidate.CLEAROTRON_CLIENT_MCP_URL, "local install; the
|
|
4927
|
+
stateLine("client connector", candidate.CLEAROTRON_CLIENT_MCP_URL, "local install; the Connect your AI page shows its empty state"),
|
|
4639
4928
|
]) say(` ${line}`);
|
|
4640
4929
|
|
|
4641
4930
|
say(`\n ${style.bold("Start here:")}\n`);
|
|
4642
4931
|
say(` ${invocationPrefix()}clearotron start\n`);
|
|
4643
|
-
say(" Starts the portal
|
|
4644
|
-
say(" address is the product: you order a clearance from it and read the
|
|
4932
|
+
say(" Starts the portal, the engine door, the client door and the worker, and prints one address to");
|
|
4933
|
+
say(" open in your browser. That address is the product: you order a clearance from it and read the");
|
|
4934
|
+
say(" report there.\n");
|
|
4645
4935
|
// THE ONE SENTENCE A READER NEEDS BEFORE THEY OPEN THAT ADDRESS, and setup was the only one of the
|
|
4646
4936
|
// three commands that never said it. A port can be free where the product runs and taken where the
|
|
4647
4937
|
// BROWSER runs — a forwarding listener outside this environment answers 127.0.0.1 first — and the
|
|
@@ -4651,8 +4941,12 @@ try {
|
|
|
4651
4941
|
// use, with no number, so the three commands cannot drift into three answers.
|
|
4652
4942
|
for (const line of foreignPageHint("start")) say(` ${line}`);
|
|
4653
4943
|
say("");
|
|
4654
|
-
|
|
4655
|
-
|
|
4944
|
+
// A FIRST REAL CLEARANCE IS SUGGESTED ONLY WHERE ONE CAN RUN. With no register chosen, the line suggesting
|
|
4945
|
+
// `run` sat a few lines above the warning that `run` will refuse at its door.
|
|
4946
|
+
if (registerSelected) {
|
|
4947
|
+
say(` ${style.dim(`Also: \`${invocationPrefix()}clearotron demo\` replays a finished report with no keys and no model calls;`)}`);
|
|
4948
|
+
say(` ${style.dim(`\`${invocationPrefix()}clearotron run --job ${/\s/.test(EXAMPLE_JOB) ? `"${EXAMPLE_JOB}"` : EXAMPLE_JOB}\` runs a first real clearance on the EU register.`)}`);
|
|
4949
|
+
} else say(` ${style.dim(`Also: \`${invocationPrefix()}clearotron demo\` replays a finished report with no keys and no model calls.`)}`);
|
|
4656
4950
|
// THE OLD WAY IS A CHECKOUT'S. A package has no npm scripts where its reader stands.
|
|
4657
4951
|
if (!PACKAGED) say(` ${style.dim("Each still works the old way too — `npm start`, `node driver/pipeline.mjs`.")}`);
|
|
4658
4952
|
say("");
|
|
@@ -4710,7 +5004,7 @@ try {
|
|
|
4710
5004
|
if (needs.length && !enrollable.some((r) => r.configured)) {
|
|
4711
5005
|
say("\n Case law");
|
|
4712
5006
|
say(` ${needs.join(" and ")} reasons against case law and oppositions. No case-law source is`);
|
|
4713
|
-
say(" enrolled on this
|
|
5007
|
+
say(" enrolled on this install, so that search will run and its report will state the gap rather than");
|
|
4714
5008
|
say(" telling you what the courts have decided. Nothing here can set it up: it is a one-time OAuth");
|
|
4715
5009
|
say(" sign-in, described in providers/oauth-mcp-bridge/README.md, and every other search is");
|
|
4716
5010
|
say(` unaffected. \`${invocationPrefix()}clearotron doctor\` reports it at any time.\n`);
|
|
@@ -4722,16 +5016,17 @@ try {
|
|
|
4722
5016
|
say(` \`${invocationPrefix()}clearotron demo\` and \`${invocationPrefix()}clearotron start\` work now. A real`);
|
|
4723
5017
|
say(" clearance needs one register — any one is enough, and none requires another:");
|
|
4724
5018
|
say(` ${PROVIDERS.map((p) => p.id).join(", ")}`);
|
|
4725
|
-
say(` Set it by re-running \`${invocationPrefix()}clearotron install
|
|
5019
|
+
say(` Set it by re-running \`${invocationPrefix()}clearotron install\`.`);
|
|
4726
5020
|
say(` \`${invocationPrefix()}clearotron doctor\` says which state this install is in, at any time.\n`);
|
|
4727
5021
|
}
|
|
4728
5022
|
} catch (e) {
|
|
4729
5023
|
if (!aborted) {
|
|
4730
5024
|
muted = false;
|
|
4731
|
-
// Ctrl-D
|
|
4732
|
-
// been written
|
|
4733
|
-
|
|
4734
|
-
|
|
5025
|
+
// Ctrl-C, Ctrl-D or a closed stdin lands here. It is not a crash and must not read like one. No setting
|
|
5026
|
+
// has been written before the single atomic rename at the end, but setup's own copy, the AI's program
|
|
5027
|
+
// and a test turn's files may already be on the machine, and the line names each one that is.
|
|
5028
|
+
const msg = /Ctrl\+[CD]|closed|aborted/i.test(String(e?.message ?? e))
|
|
5029
|
+
? cancelledLine({ copy: installedCopy, engine: installedEngine, turnRan: setupTurnRan })
|
|
4735
5030
|
: String(e?.message ?? e);
|
|
4736
5031
|
console.error(`\nsetup: ${msg}\n`);
|
|
4737
5032
|
rl.close();
|