clearotron 0.5.0 → 0.5.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +2 -2
- package/INSTALL.md +334 -302
- 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 +562 -336
- package/bin/start.mjs +184 -36
- package/bin/update.mjs +26 -13
- package/build-info.json +2 -2
- package/docs/PORTAL.md +2 -2
- package/docs/architecture/02-architecture.md +3 -3
- package/docs/architecture/04-configuration-reference.md +1 -2
- package/docs/architecture/05-config-governance.md +1 -1
- package/docs/architecture/06-operations-runbook.md +1 -1
- package/driver/CHANGELOG.md +77 -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/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/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 +62 -6
- 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 +54 -4
- package/driver/runner.mjs +4 -13
- 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 +389 -71
- package/driver/systemd/README.md +2 -2
- package/driver/verify-knockout.mjs +175 -39
- package/driver/verify.mjs +10 -9
- package/mcp-server/CHANGELOG.md +4 -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/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-C1oE78Wk.js} +161 -195
- 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 +4 -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 +14 -0
- package/shared/scope.mjs +8 -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
|
@@ -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) {
|
|
@@ -1064,6 +1153,16 @@ export function engineOptions(found = {}) {
|
|
|
1064
1153
|
];
|
|
1065
1154
|
}
|
|
1066
1155
|
|
|
1156
|
+
/**
|
|
1157
|
+
* The engine menu's default row: the AI the reader picked on an earlier pass, or row 0 on the first. A reader
|
|
1158
|
+
* 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
|
|
1159
|
+
* had not chosen. Remembering the pick saves nothing: the proof turn still decides what is written.
|
|
1160
|
+
*/
|
|
1161
|
+
export function engineMenuDefault(options, lastPick = null) {
|
|
1162
|
+
const at = lastPick ? options.findIndex((o) => o.id === lastPick) : -1;
|
|
1163
|
+
return at < 0 ? 0 : at;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1067
1166
|
// A COPY REFUSED AS THE VENDOR'S PLACEHOLDER, told apart by the resolver's own reason for refusing it
|
|
1068
1167
|
// (driver.config.mjs engineCandidate). setup-asks-which-ai-runs-your-searches.test.mjs creates a real
|
|
1069
1168
|
// placeholder and reads the row, so a reworded reason turns that test red instead of this row wrong.
|
|
@@ -1459,9 +1558,13 @@ export function readOwnProcesses(repo, { table = processTable() } = {}) {
|
|
|
1459
1558
|
.map((p) => ({ pid: p.pid, startedAt: p.startedAt, cmd: p.cmd.slice(0, 120) }));
|
|
1460
1559
|
}
|
|
1461
1560
|
|
|
1561
|
+
// The closing line of a check whose engine probe ran a test turn: the turn's AI program writes its own files
|
|
1562
|
+
// under ~/.claude and ~/.cache, so "Nothing was written" was true of this command and not of the turn.
|
|
1563
|
+
const TURN_KEPT_ITS_FILES = "Clearotron wrote nothing; the AI program's test turn keeps its own files.";
|
|
1462
1564
|
export async function runCheck() {
|
|
1463
1565
|
say("\n Trademark clearance engine — configuration check\n");
|
|
1464
|
-
|
|
1566
|
+
// Whether the engine probe's turn started the AI program (TURN_KEPT_ITS_FILES); one refused first did not.
|
|
1567
|
+
let probeTurnRan = false;
|
|
1465
1568
|
|
|
1466
1569
|
// ── ONE READING OF THE UNITS' ENVIRONMENT, FOR EVERY SECTION THAT CLAIMS ANYTHING ABOUT THEM ─────
|
|
1467
1570
|
//
|
|
@@ -1486,8 +1589,298 @@ export async function runCheck() {
|
|
|
1486
1589
|
home: homedir() })
|
|
1487
1590
|
: null;
|
|
1488
1591
|
|
|
1489
|
-
//
|
|
1490
|
-
//
|
|
1592
|
+
// Read the file up here rather than at the `.env` heading below: the opening is the first that needs
|
|
1593
|
+
// `effective()`, and which ENGINE is configured decides which binary variable to check. Reading
|
|
1594
|
+
// is not applying — see readEnvFile's header.
|
|
1595
|
+
// `fileEnv` is read at the top of runCheck now — the Deployment section needs it to name the box on a
|
|
1596
|
+
// box that runs no units, and a `const` used above its declaration is a dead-zone crash, not a
|
|
1597
|
+
// fallback. It reached here as one on the first draft of that section: harmless on a hosted box,
|
|
1598
|
+
// where the ternary never evaluates this branch, and fatal on every install without units.
|
|
1599
|
+
// Environment wins over the file (the loader contract), so report the effective value and say which
|
|
1600
|
+
// source it came from — a value read from the wrong place is the whole class of bug here.
|
|
1601
|
+
// ── CHECK 1 — THE CHECKER READS EVERY SPELLING THE ENGINE ACCEPTS ─────────────────────────
|
|
1602
|
+
//
|
|
1603
|
+
// This read `process.env[k]` and `fileEnv[k]` for the LITERAL key, while the writer below maps every
|
|
1604
|
+
// key and writes the CLEAROTRON_* name. So on an install THIS WIZARD had
|
|
1605
|
+
// just configured correctly, `--check` reported every renamed variable as NOT SET, and told the
|
|
1606
|
+
// operator to go and set the old name — the one the engine is moving away from.
|
|
1607
|
+
//
|
|
1608
|
+
// Batch 1 recorded this trap in the opposite direction ("validating under names the engine reads while
|
|
1609
|
+
// writing names that would warn"). It survived its own fix in mirror image, which is why carries
|
|
1610
|
+
// the write-point check forward as a standing requirement rather than a one-off.
|
|
1611
|
+
//
|
|
1612
|
+
// CURRENT SPELLING FIRST, then the retired ones — the same order `applyEnvAliases` resolves in, so the
|
|
1613
|
+
// checker cannot disagree with the engine about which value wins when an operator has both set during
|
|
1614
|
+
// the migration. `from` names the spelling that answered, so an operator running on an old name can
|
|
1615
|
+
// see that they are, instead of being told everything is fine.
|
|
1616
|
+
//
|
|
1617
|
+
// `from` NAMES THE SOURCE, NOT THE SPELLING, and the first cut of this got that wrong. It appended
|
|
1618
|
+
// the answering spelling so "an operator on an old name can see that they are" — but `applyEnvAliases`
|
|
1619
|
+
// runs ungated at load and populates the CURRENT name from the old one, so the current spelling always
|
|
1620
|
+
// answers first and the label always named it. On a box configured entirely under retired names it
|
|
1621
|
+
// therefore reported the new spelling as the one that had answered: not merely uninformative, but the
|
|
1622
|
+
// opposite of what happened. The evidence it wanted is destroyed before this function can see it.
|
|
1623
|
+
//
|
|
1624
|
+
// THAT OPERATOR IS NO LONGER TOLD ANYTHING, and this note used to claim otherwise. It described a
|
|
1625
|
+
// deprecation notice `applyEnvAliases` printed at load, from the translation itself. There is no
|
|
1626
|
+
// translation and no notice: the owner ruled both out on 2026-08-26 (no migration, no legacy support,
|
|
1627
|
+
// and — asked directly — no check for the old names either), because a box reaches this code through
|
|
1628
|
+
// the install and the boxes that predated the rename are rebuilt rather than upgraded. The 2026-09-04
|
|
1629
|
+
// global rename extended that to the whole namespace. An old name is a line in a file nothing reads,
|
|
1630
|
+
// and the paragraph above describes a configuration that no longer occurs.
|
|
1631
|
+
const effective = (k, names = [k]) => {
|
|
1632
|
+
for (const name of names) {
|
|
1633
|
+
if (present(process.env[name])) return { v: process.env[name], from: "environment", name };
|
|
1634
|
+
if (present(fileEnv[name])) return { v: fileEnv[name], from: ".env", name };
|
|
1635
|
+
}
|
|
1636
|
+
return null;
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1639
|
+
// ── ONE READING OF THE UNITS' ENVIRONMENT, FOR EVERY SECTION THAT CLAIMS ANYTHING ABOUT THEM ─────
|
|
1640
|
+
//
|
|
1641
|
+
// F34: two sections asserted facts about the units while reading the operator's shell, and both of
|
|
1642
|
+
// their reported problems were false on a correctly-running install. Resolving this once, here, is
|
|
1643
|
+
// deliberate — a second reader would drift from this one exactly as the composer and the checker did
|
|
1644
|
+
// in F41, and the drift is invisible because both sides keep passing their own arms.
|
|
1645
|
+
// The reading itself was hoisted AGAIN, to the top of runCheck, so the Deployment section can name
|
|
1646
|
+
// the box from the file the units load. `unitDir`, `hosted`, `unitEnv` and `startPaths` are all in
|
|
1647
|
+
// scope from there; nothing between here and there consumed them, which is why the move is safe.
|
|
1648
|
+
|
|
1649
|
+
// ── AND THE DOOR SECTION IS THE THIRD SUCH SECTION ──────────────────────────────────────────────
|
|
1650
|
+
//
|
|
1651
|
+
// The reading above was hoisted here from further down for this. It used to be resolved BELOW the
|
|
1652
|
+
// door check, so the one section making the loudest claim about the running service — "NOBODY can
|
|
1653
|
+
// use this portal" — was the one section that could not consult it.
|
|
1654
|
+
//
|
|
1655
|
+
// MEASURED 2026-09-06 on a healthy packaged install: `doctor` printed that ✗ and exited 1 on a box
|
|
1656
|
+
// where the local user signs in and `GET /portal/api/me` returned `{"role":"staff"}`. The units' file
|
|
1657
|
+
// carried `PORTAL_STAFF_DOMAINS=localhost` (a staff-domain rule, since deleted), the identity was
|
|
1658
|
+
// `<user>@localhost`, and the running service admitted it as staff. This command read the CLI's own
|
|
1659
|
+
// `.env`, where neither that name nor `PORTAL_AUTH_MODE` appeared — so the check was not ignoring the
|
|
1660
|
+
// auth mode, it never saw it. What admits a person now is their entry in the grants file, and the
|
|
1661
|
+
// units' file is still the only place that names which grants file.
|
|
1662
|
+
//
|
|
1663
|
+
// The disclosure was already here and one severity too quiet: a `·` saying "what THIS environment
|
|
1664
|
+
// implies, not what the running service serves", directly above a `✗` phrased in the present
|
|
1665
|
+
// indicative about the live box. A caveat does not repair a false claim standing beside it.
|
|
1666
|
+
//
|
|
1667
|
+
// SO THE VALUES COME FROM THE FILE THE SERVICE READS when this box is hosted, and the source is named
|
|
1668
|
+
// beside the verdict rather than left to a caveat. Not an exemption for `PORTAL_AUTH_MODE=local`,
|
|
1669
|
+
// which was the fix originally filed: that variable is absent from the file this command was reading,
|
|
1670
|
+
// so exempting on it would have changed nothing at all.
|
|
1671
|
+
const serviceEnvLabel = hosted ? "the units' environment" : "your environment file";
|
|
1672
|
+
const serviceEnvFile = hosted ? join(homedir(), ".env") : READ_ENV_PATH();
|
|
1673
|
+
// A HOSTED BOX WHOSE UNIT ENVIRONMENT COULD NOT BE READ ANSWERS `null`, NEVER `fileEnv`. Falling back
|
|
1674
|
+
// to the CLI's file there would reproduce this defect exactly, and silently — `unitEnvironment`
|
|
1675
|
+
// already distinguishes a failure to look, and the door check below refuses to claim a lockout on one.
|
|
1676
|
+
const serviceKnown = !hosted || unitEnv?.known === true;
|
|
1677
|
+
const serviceFileEnv = hosted ? (unitEnv?.known === true ? unitEnv.env : null) : fileEnv;
|
|
1678
|
+
const effectiveForService = (k, names = [k]) => {
|
|
1679
|
+
for (const name of names) {
|
|
1680
|
+
if (present(process.env[name])) return { v: process.env[name], from: "environment", name };
|
|
1681
|
+
if (serviceFileEnv && present(serviceFileEnv[name])) return { v: serviceFileEnv[name], from: serviceEnvLabel, name };
|
|
1682
|
+
}
|
|
1683
|
+
return null;
|
|
1684
|
+
};
|
|
1685
|
+
// WHAT THE SERVICES THEMSELVES READ, for the two judgements that decide whether a search runs: how they
|
|
1686
|
+
// pay, and "Will a search run?". On a machine with units, that is their file and nothing else: they run
|
|
1687
|
+
// with CLEAROTRON_NO_ENV_FILE=1, so doctor's shell never reaches them. Layered as effectiveForService
|
|
1688
|
+
// layers it, a cloud switch this shell exported for its own use was judged the services' own, and doctor
|
|
1689
|
+
// reported "a search is refused" on services that ran; a billing word here asked them for a key they did
|
|
1690
|
+
// not need. With no units, the services are the children of `clearotron start` and inherit its shell, so
|
|
1691
|
+
// effectiveForService is the true answer there.
|
|
1692
|
+
const servicesRead = (k) => (!hosted ? effectiveForService(k)
|
|
1693
|
+
: serviceFileEnv && present(serviceFileEnv[k]) ? { v: serviceFileEnv[k], from: serviceEnvLabel, name: k } : null);
|
|
1694
|
+
|
|
1695
|
+
// ON A MACHINE WITH UNITS THIS SECTION DESCRIBES THE SERVICES: which AI, which program, how they pay. They read their
|
|
1696
|
+
// own file and search their own PATH (servicesRead, above), so a shell that chose another AI says nothing about them,
|
|
1697
|
+
// and a file that cannot be read is a failure to look, never a reason to answer from this shell. With no units, the
|
|
1698
|
+
// services are the children of `clearotron start`, and this command's configuration is theirs.
|
|
1699
|
+
const engineRead = (k, names = [k]) => (hosted ? servicesRead(k) : effective(k, names));
|
|
1700
|
+
/** 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. */
|
|
1701
|
+
const engineEnvOf = (keys = []) => {
|
|
1702
|
+
const env = { ...process.env };
|
|
1703
|
+
const unitsPath = hosted ? unitValue(unitEnv, "PATH").value : null;
|
|
1704
|
+
if (unitsPath) env.PATH = unitsPath;
|
|
1705
|
+
for (const k of keys) {
|
|
1706
|
+
if (hosted) delete env[k];
|
|
1707
|
+
const e = engineRead(k);
|
|
1708
|
+
if (e) env[k] = e.v;
|
|
1709
|
+
}
|
|
1710
|
+
return env;
|
|
1711
|
+
};
|
|
1712
|
+
const engSel = engineRead("CLEAROTRON_AI");
|
|
1713
|
+
const engineId = String(engSel?.v ?? DEFAULT_ENGINE_ID).trim().toLowerCase();
|
|
1714
|
+
const engSpec = ENGINE_BINARIES[engineId];
|
|
1715
|
+
|
|
1716
|
+
// ONE READER FOR THE REGISTER AND THE RESEARCH KEY, the services' own. Only a machine with units has a
|
|
1717
|
+
// second environment to read; with no units, the services are started from this command's own file, and
|
|
1718
|
+
// `effective` has always read and labelled exactly that.
|
|
1719
|
+
const serviceValue = hosted ? effectiveForService : effective;
|
|
1720
|
+
|
|
1721
|
+
// ── WHAT THE OPENING NEEDS FROM THE ENGINE SECTION, READ BEFORE IT ─────────────────────────────────
|
|
1722
|
+
//
|
|
1723
|
+
// The opening says whether the engine program resolves (the sign-in line) and, under --probe-engine,
|
|
1724
|
+
// runs the turn on the copy that resolves. Both are read here, once, and the Engine section still
|
|
1725
|
+
// prints every line about them. `engineJudged` is that section's own condition: it judges nothing when
|
|
1726
|
+
// the units' environment cannot be read, or when CLEAROTRON_AI names no engine this driver ships.
|
|
1727
|
+
const engineJudged = serviceKnown && !(engSel && !engSpec);
|
|
1728
|
+
// — through `effective`, so the engine binary is found under whichever spelling is set. Read
|
|
1729
|
+
// literally, this reported a configured binary as missing on any install the wizard had written.
|
|
1730
|
+
const binEff = engineJudged ? engineRead(engSpec.env, [engSpec.env]) : null;
|
|
1731
|
+
// The engine's own fallback word is the default spelled out (resolveEngineProgram), so a setting of
|
|
1732
|
+
// `claude` is not a configuration that can be wrong: it asks PATH, then the copy Clearotron installed.
|
|
1733
|
+
const binSet = engineJudged && !!binEff && String(binEff.v).trim() !== engSpec.fallback;
|
|
1734
|
+
const binSetting = engineJudged ? (binEff?.v || engSpec.fallback) : null;
|
|
1735
|
+
const bin = engineJudged ? resolveEngineBin(binSetting, { engine: engineId, env: engineEnvOf() }) : null;
|
|
1736
|
+
// How the mode is read, and why its environment is normalised first, is the Engine section's note
|
|
1737
|
+
// WHICH MODE THIS INSTALL IS IN.
|
|
1738
|
+
const invEnv = engineJudged
|
|
1739
|
+
? engineEnvOf(["CLEAROTRON_AI", ...Object.values(ENGINE_BINARIES).flatMap((x) => [x.env, x.authEnv, x.apiKeyEnv])].filter(Boolean))
|
|
1740
|
+
: null;
|
|
1741
|
+
const installMode = engineJudged ? engineMode(engineInventory(invEnv)) : null;
|
|
1742
|
+
// THE COMMAND THE READER CAN TYPE FROM HERE, as the demo line names its own. A bare `clearotron` is not
|
|
1743
|
+
// on PATH for an install run from npx, and now that the engine program comes with the install this is
|
|
1744
|
+
// the line most installs see first. The opening prints it when it leads and the Engine section prints
|
|
1745
|
+
// it otherwise; null where that section would print the demo lines instead.
|
|
1746
|
+
const signInLine = engineJudged && installMode !== ENGINE_MODES.DEMO
|
|
1747
|
+
? "The engine program is installed. Whether it is signed in cannot be read from disk: run "
|
|
1748
|
+
+ `\`${reachableCommand("doctor --probe-engine")}\` to find out.`
|
|
1749
|
+
: null;
|
|
1750
|
+
|
|
1751
|
+
// ONE TURN, WHEREVER IT RUNS. The engine as a RUN would see it (engineEnvOf). Only the engine-selection
|
|
1752
|
+
// keys — the probe must bill exactly the way this machine bills and moves no other variable. The auth
|
|
1753
|
+
// variables ride this list for the same reason CLEAROTRON_AI does: without them the probe bills the way
|
|
1754
|
+
// the AMBIENT environment says rather than the way this .env says, and "proven" would name a way of
|
|
1755
|
+
// paying that no run takes.
|
|
1756
|
+
//
|
|
1757
|
+
// THE CREDENTIALS RIDE IT TOO, and did not. This was a second copy of the list `applyEngineEnv`
|
|
1758
|
+
// applies, and it had dropped the API key and the headless token — so a token kept only in this
|
|
1759
|
+
// install's .env never reached the probe, which then reported the engine signed out while the same
|
|
1760
|
+
// token exported into the shell proved it. `engineEnvKeys` is the probe's own list: the copy that is
|
|
1761
|
+
// filled is now the copy that is applied.
|
|
1762
|
+
const runTurn = async () => {
|
|
1763
|
+
const v = await probeEngineTurn({ env: engineEnvOf(engineEnvKeys()) });
|
|
1764
|
+
probeTurnRan = v.ok || v.basis !== "config";
|
|
1765
|
+
return v;
|
|
1766
|
+
};
|
|
1767
|
+
/** What a turn's verdict prints, wherever the turn ran. */
|
|
1768
|
+
const sayTurn = (v) => {
|
|
1769
|
+
if (v.ok) {
|
|
1770
|
+
ok(`${engineId} completed a turn — binary, credential and model access all work`);
|
|
1771
|
+
const served = servedLine(v);
|
|
1772
|
+
if (served) info(served);
|
|
1773
|
+
// The ONLY route to READY. Everything else in this block reads the filesystem, and a signed-out
|
|
1774
|
+
// CLI passes every filesystem test there is — which is why this line is here and not above.
|
|
1775
|
+
ok("MODE: engine ready — proven by the turn just spent, not inferred from a file being executable.");
|
|
1776
|
+
}
|
|
1777
|
+
else {
|
|
1778
|
+
problem(probeFailureText(v));
|
|
1779
|
+
if (v.detail) info(`engine said: ${v.detail}`);
|
|
1780
|
+
}
|
|
1781
|
+
};
|
|
1782
|
+
|
|
1783
|
+
// ── WILL A SEARCH RUN? — THE ORDER-TIME GATE'S OWN QUESTION, OF THE ENVIRONMENT A RUN WILL HAVE ──
|
|
1784
|
+
//
|
|
1785
|
+
// Every section reads one requirement from YOUR shell and this command's .env. A search is refused by
|
|
1786
|
+
// a different reader: `orderTimeRefusal`, at order time, against the runner's environment — a
|
|
1787
|
+
// background unit's, on a machine that has them. So this command could pass an install the run then
|
|
1788
|
+
// refused: it found `claude` on this shell's PATH while the unit, which has no such PATH, was refused
|
|
1789
|
+
// for an engine path it had never been given. Asking the gate's own authority of the units' environment
|
|
1790
|
+
// is what makes an install this command passes one that can run. `blocking`, not `problem`: an install
|
|
1791
|
+
// that is not configured yet is unfinished rather than broken, and the exit status keeps that contract.
|
|
1792
|
+
//
|
|
1793
|
+
// ASKED ONCE, BEFORE ANYTHING ELSE IS PRINTED, because the opening is its answer. `atOrder` is null
|
|
1794
|
+
// when the units' environment could not be read; sayWillASearchRun prints the section wherever it goes.
|
|
1795
|
+
const tables = { registers: PROVIDERS, engines: ENGINE_BINARIES, defaultEngine: DEFAULT_ENGINE_ID, resolveEngine: resolveEngineProgram };
|
|
1796
|
+
const atOrder = (() => {
|
|
1797
|
+
if (!serviceKnown) return null;
|
|
1798
|
+
// UNTIL NOTHING NEW IS NAMED: which names a run needs depends on values read in the pass before. The
|
|
1799
|
+
// register and the engine name their credentials, their program and the billing word; a billing word of
|
|
1800
|
+
// `cloud` names the cloud switches and the gateway address; a switch found becomes the blocking row, and
|
|
1801
|
+
// the cloud's other settings are named only where the view already holds them. Two passes stopped before
|
|
1802
|
+
// the billing word was read, so a machine that pays through a cloud account was checked as a subscription
|
|
1803
|
+
// one and its missing switch went unreported. It stops at the first pass that finds no new value: the names
|
|
1804
|
+
// asked for depend only on the values found, so the next pass would ask for the names this one just read.
|
|
1805
|
+
const view = {};
|
|
1806
|
+
// Read as the services read it (servicesRead): a value in this shell never reaches a unit.
|
|
1807
|
+
const fill = (names) => { for (const n of names) { const e = servicesRead(n); if (e) view[n] = e.v; } };
|
|
1808
|
+
fill([REGISTER_ENV, ENGINE_ENV]);
|
|
1809
|
+
let before;
|
|
1810
|
+
do { before = Object.keys(view).length; fill(runRequiredNames(view, tables)); } while (Object.keys(view).length > before);
|
|
1811
|
+
// AND THE PATH THE SERVICES SEARCH, so the engine's program is looked for where a run looks for it.
|
|
1812
|
+
// The view held the settings and no PATH, so a `claude` on the services' PATH, with no path setting and
|
|
1813
|
+
// no copy installed by setup, was reported as a search refused while the run found it and ran. On a
|
|
1814
|
+
// machine with units that PATH is the units' own (every unit sets it, with `%h` for the home, which the
|
|
1815
|
+
// unit reader expands); never this shell's, which the units do not inherit. With no units, the
|
|
1816
|
+
// services are the children of `clearotron start`, which inherit the PATH of the shell it runs in.
|
|
1817
|
+
const servicesPath = hosted ? unitValue(unitEnv, "PATH").value : process.env.PATH;
|
|
1818
|
+
if (servicesPath) view.PATH = servicesPath;
|
|
1819
|
+
return missingRequirements(view, tables).atOrder;
|
|
1820
|
+
})();
|
|
1821
|
+
const sayWillASearchRun = () => {
|
|
1822
|
+
say("\n Will a search run?");
|
|
1823
|
+
if (!serviceKnown) {
|
|
1824
|
+
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");
|
|
1825
|
+
} else if (atOrder.length) {
|
|
1826
|
+
blocking(`a search is refused until ${atOrder.length === 1 ? "this is" : "these are"} set in ${serviceEnvLabel}: ${atOrder.map((r) => r.name).join(", ")}`);
|
|
1827
|
+
for (const r of atOrder) info(` ${r.name} — ${r.why}`);
|
|
1828
|
+
} else ok(`nothing a search is refused for at order time is missing from ${serviceEnvLabel}`);
|
|
1829
|
+
};
|
|
1830
|
+
const sayResearch = () => {
|
|
1831
|
+
say("\n Research provider");
|
|
1832
|
+
// The same reader as the register, for the same reason: this is a key the services use.
|
|
1833
|
+
const px = serviceKnown ? serviceValue("PERPLEXITY_API_KEY") : null;
|
|
1834
|
+
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");
|
|
1835
|
+
else if (px) ok(`PERPLEXITY_API_KEY present (${px.from}) — presence only; add --probe-providers to prove it answers`);
|
|
1836
|
+
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");
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1839
|
+
// ── THE OPENING: WHETHER A SEARCH CAN RUN, WHAT STOPS IT, AND THE NEXT ACTION ─────────────────────
|
|
1840
|
+
//
|
|
1841
|
+
// A newcomer reads this command from the top, and the top was its path and its build: the answer to
|
|
1842
|
+
// "can this install search" sat halfway down, a screen away from the command that changes it (measured
|
|
1843
|
+
// on a packaged install, 2026-11-06: line 52 of 100). So the answer comes first, and every section
|
|
1844
|
+
// below keeps every line it had.
|
|
1845
|
+
//
|
|
1846
|
+
// ON A MACHINE WITH NO UNITS WHOSE SEARCH IS REFUSED, the opening is the refusal the portal gives the
|
|
1847
|
+
// person who runs the install, from the same composer (cannotSearchYet), with the command as it is
|
|
1848
|
+
// typed from here. A machine with units is not told that: its services read `~/.env`, which setup does
|
|
1849
|
+
// not write, so running setup alone would not reach them. A refusal with no words for what is missing
|
|
1850
|
+
// has no such sentence, and opens as every other state does.
|
|
1851
|
+
//
|
|
1852
|
+
// EVERY OTHER STATE OPENS WITH "Will a search run?" ITSELF, then the sign-in line when the program
|
|
1853
|
+
// resolves, or, under --probe-engine on an install that can search, the turn that answers it. The turn
|
|
1854
|
+
// is announced before it spends anything, and above the heading: a line that starts a section would end
|
|
1855
|
+
// "Will a search run?" for any reader that splits this output at its headings.
|
|
1856
|
+
//
|
|
1857
|
+
// "Research provider" comes second in every state: it is the one setting that stops three of the four
|
|
1858
|
+
// searches and that the order-time answer does not cover.
|
|
1859
|
+
const missingWords = serviceKnown && atOrder.length ? whatIsMissing(atOrder) : "";
|
|
1860
|
+
const leadIsTheRefusal = !hosted && missingWords !== "";
|
|
1861
|
+
const turnLeads = PROBE_ENGINE && serviceKnown && atOrder.length === 0 && engineJudged && bin.executable && !bin.relative;
|
|
1862
|
+
const signInLineLeads = !leadIsTheRefusal && !PROBE_ENGINE && signInLine !== null;
|
|
1863
|
+
// ONE LINE, AS EVERY LINE BELOW IS, and the terminal wraps it. Wrapped here at spaces, it broke the command
|
|
1864
|
+
// apart wherever the install's path made a long word: `cd <path> && npx clearotron install` on three lines.
|
|
1865
|
+
if (leadIsTheRefusal) say(` ${cannotSearchYet(missingWords, invoke("install"))}`);
|
|
1866
|
+
else {
|
|
1867
|
+
let turn = null;
|
|
1868
|
+
if (turnLeads) {
|
|
1869
|
+
say(` ${probingLine(engineId)}`);
|
|
1870
|
+
turn = await runTurn();
|
|
1871
|
+
}
|
|
1872
|
+
sayWillASearchRun();
|
|
1873
|
+
if (signInLineLeads) info(signInLine);
|
|
1874
|
+
if (turn) sayTurn(turn);
|
|
1875
|
+
}
|
|
1876
|
+
sayResearch();
|
|
1877
|
+
|
|
1878
|
+
// The path this command runs from, with the build it names below it.
|
|
1879
|
+
say(`\n repo: ${REPO}`);
|
|
1880
|
+
|
|
1881
|
+
// — CURRENT, not just configured. Printed first among the sections about this install's build,
|
|
1882
|
+
// because a stale deployment makes every line below it a report about the wrong build. The opening
|
|
1883
|
+
// and the research key come before it, because a newcomer's first question is whether a search runs.
|
|
1491
1884
|
say("\n Deployment");
|
|
1492
1885
|
const cur = deploymentCurrency();
|
|
1493
1886
|
if (cur.state === "current") ok(`up to date with ${cur.upstream} as of the last fetch`);
|
|
@@ -1545,16 +1938,18 @@ export async function runCheck() {
|
|
|
1545
1938
|
// THE ACCEPTED NAMES ARE NEVER PRINTED. They are the names of the deployments this build was made for,
|
|
1546
1939
|
// and the line offered them to a newcomer to name their own machine after (measured on a fresh install
|
|
1547
1940
|
// of a beta, 2026-11-03). An install without units says nothing of an unset name: nothing there reads
|
|
1548
|
-
// it. Installed units are
|
|
1941
|
+
// it. Installed units are told, because the services read it, and `start --background` installs the
|
|
1549
1942
|
// same units a hosted deployment runs, from the same renderer, so nothing here can tell the two apart.
|
|
1550
1943
|
if (!raw) {
|
|
1551
1944
|
// 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
|
-
|
|
1945
|
+
// nobody has configured yet has no name, legitimately, and `--check` on one exits 0 by contract.
|
|
1946
|
+
// Reported so it is visible rather than silent, which is the whole requirement. At `·`, in plain
|
|
1947
|
+
// words, because the reader most likely to see it is a newcomer after `start --background`, who
|
|
1948
|
+
// has nothing to set: a `!` there said the rest of the report could not be trusted and gave them
|
|
1949
|
+
// nothing to do (measured on a fresh install of a beta, 2026-11-04). Raising it to `✗` made every
|
|
1950
|
+
// unconfigured machine fail its own acceptance arm.
|
|
1951
|
+
if (hosted) info(`no CLEAROTRON_BOX in ${boxSource}. Only Clearotron's own servers set it, to name `
|
|
1952
|
+
+ "themselves; an install of your own leaves it unset");
|
|
1558
1953
|
} else if (!DEPLOYMENT_BOXES.includes(raw)) {
|
|
1559
1954
|
problem(`CLEAROTRON_BOX is "${raw}" in ${boxSource}, which is not a box this build knows. `
|
|
1560
1955
|
+ `An unrecognised name reads as NO box everywhere it is `
|
|
@@ -1650,136 +2045,33 @@ export async function runCheck() {
|
|
|
1650
2045
|
if (nodeV.ok) ok(`node ${nodeV.current}`);
|
|
1651
2046
|
else problem(`node ${nodeV.current} — this engine needs ${nodeV.required} or newer; node:sqlite is not a built-in module before then`);
|
|
1652
2047
|
|
|
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
2048
|
say("\n Engine");
|
|
1757
2049
|
// This block used to read CLEAROTRON_CLAUDE_PATH unconditionally, under the heading "Engine binary", on a
|
|
1758
2050
|
// box that may be running codex — so it reported the wrong variable and could pass for the wrong
|
|
1759
2051
|
// reason. Which engine is configured comes first now, and the binary is checked through THAT engine's
|
|
1760
2052
|
// variable.
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
if (engSel && !engSpec) {
|
|
2053
|
+
if (!serviceKnown) {
|
|
2054
|
+
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");
|
|
2055
|
+
} else if (engSel && !engSpec) {
|
|
1765
2056
|
problem(`CLEAROTRON_AI="${engSel.v}" (${engSel.from}) is not an engine this driver ships — one of: `
|
|
1766
2057
|
+ `${Object.keys(ENGINE_BINARIES).join(", ")}. The run refuses on this by itself (gateway.selectEngine); `
|
|
1767
2058
|
+ "nothing can be checked here until it names an adapter.");
|
|
1768
2059
|
} else {
|
|
1769
2060
|
if (engSel) ok(`${engineId} (${engSel.from}) — ${engSpec.label}`);
|
|
1770
|
-
|
|
2061
|
+
// WHAT THE ORDER-TIME CHECK SAYS, NOT WHAT THE CODE FALLS BACK TO. Every search is refused while the
|
|
2062
|
+
// services lack this (run-requirements.mjs, `runRequirements`, the engine row), whatever the default
|
|
2063
|
+
// below checks. Naming that default here read as "nothing to do", a few lines above "Will a search
|
|
2064
|
+
// run?" listing this very setting (measured on a fresh install of a beta, 2026-11-04). Asked of the
|
|
2065
|
+
// services' own reading (servicesRead), as that section asks it: on a machine with units, their file
|
|
2066
|
+
// may hold the value this command's file does not, and then no search is refused over it.
|
|
2067
|
+
else if (serviceKnown && !servicesRead("CLEAROTRON_AI")) info(`CLEAROTRON_AI is not set, so no AI is chosen, `
|
|
2068
|
+
+ `and a search is refused until one is. \`${invoke("install")}\` asks which AI to use.`);
|
|
2069
|
+
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`);
|
|
1771
2070
|
|
|
1772
2071
|
// The line between an ABSENCE and a MISCONFIGURATION. Nothing set and no binary on PATH is a fresh
|
|
1773
2072
|
// 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 });
|
|
2073
|
+
// will fail at run time, and this is the cheap place to learn it. The program (`bin`) is resolved above
|
|
2074
|
+
// the opening, which needs it; this section still says everything about it.
|
|
1783
2075
|
// WHICH COPY, AND ITS VERSION, because the machine's own install and the one Clearotron installed
|
|
1784
2076
|
// are both legitimate and behave differently: the first updates itself, the second moves with
|
|
1785
2077
|
// `clearotron update`. The version comes from the copy's own package.json when npm installed it.
|
|
@@ -1864,13 +2156,8 @@ export async function runCheck() {
|
|
|
1864
2156
|
// `env[spec.env]` — the CURRENT spelling only — and this file is deliberately not a CLI entry, so
|
|
1865
2157
|
// the alias layer has not run here. Handed raw process.env it would miss a binary configured
|
|
1866
2158
|
// 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));
|
|
2159
|
+
//
|
|
2160
|
+
// `invEnv` and `installMode` are read that way above the opening, which needs the mode for its sign-in line.
|
|
1874
2161
|
if (installMode === ENGINE_MODES.DEMO) {
|
|
1875
2162
|
info("MODE: demo — everything works except starting a NEW search. The example report, its audit trail "
|
|
1876
2163
|
+ `and the MCP connection are live right now; \`${reachableCommand("demo")}\` needs no engine.`);
|
|
@@ -1883,13 +2170,7 @@ export async function runCheck() {
|
|
|
1883
2170
|
// restart a service — neither of which can change the answer, because the refusal is about the
|
|
1884
2171
|
// platform rather than the binary. Naming WSL2 is the only instruction that ends this state.
|
|
1885
2172
|
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
|
-
}
|
|
2173
|
+
} else if (!signInLineLeads) info(signInLine); // printed here unless the opening carries it
|
|
1893
2174
|
|
|
1894
2175
|
// AND WHETHER THE ENGINE AGREES, which is a different question from the one above and the reason an
|
|
1895
2176
|
// outside user gave up on this product. This command reads its OWN environment; the portal's New
|
|
@@ -1940,11 +2221,7 @@ export async function runCheck() {
|
|
|
1940
2221
|
// see it, with the .env's values overlaid for the keys an engine spawn is made of. The cloud's names
|
|
1941
2222
|
// are on it, because with the billing word read from the file and a cloud's switch left to the shell,
|
|
1942
2223
|
// 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
|
-
}
|
|
2224
|
+
const envForResolve = engineEnvOf(engineEnvKeys());
|
|
1948
2225
|
const billingOf = (eng, env) => {
|
|
1949
2226
|
try {
|
|
1950
2227
|
const auth = resolveAuthMode({ engineName: eng, env });
|
|
@@ -1966,28 +2243,6 @@ export async function runCheck() {
|
|
|
1966
2243
|
// was the only line claiming a verdict it had not reached.
|
|
1967
2244
|
const engineResolved = !!(bin?.path && bin.executable && !bin.relative);
|
|
1968
2245
|
(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
2246
|
} catch (e) {
|
|
1992
2247
|
problem(String(e?.message ?? e));
|
|
1993
2248
|
}
|
|
@@ -2004,37 +2259,10 @@ export async function runCheck() {
|
|
|
2004
2259
|
info("whether it is SIGNED IN is not checked here — add --probe-engine to spend one cheap turn proving it");
|
|
2005
2260
|
} else if (!bin.executable || bin.relative) {
|
|
2006
2261
|
info("not probed — there is no usable binary to probe. Fix the line above first.");
|
|
2007
|
-
} else {
|
|
2262
|
+
} else if (!turnLeads) {
|
|
2263
|
+
// The turn runs here unless it ran for the opening; runTurn and sayTurn are the same either way.
|
|
2008
2264
|
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
|
-
}
|
|
2265
|
+
sayTurn(await runTurn());
|
|
2038
2266
|
}
|
|
2039
2267
|
}
|
|
2040
2268
|
|
|
@@ -2368,8 +2596,20 @@ export async function runCheck() {
|
|
|
2368
2596
|
+ (w.branch ? `whose branch ${w.branch} tracks no remote branch` : "which is not on a branch")
|
|
2369
2597
|
+ " — nothing carries them off this machine unless someone pushes them by name");
|
|
2370
2598
|
} else if (w.state === "not-a-repository") {
|
|
2371
|
-
|
|
2372
|
-
|
|
2599
|
+
// NOT MADE YET IS NOT A REFUSAL. With no units, `start` makes its configuration directory a git
|
|
2600
|
+
// repository the first time it runs (bin/start.mjs, the `git init` of `paths.configStore`), and
|
|
2601
|
+
// setup's default puts the store inside it. Before then this warned a newcomer that saves were
|
|
2602
|
+
// refused (measured on a fresh install of a beta, 2026-11-04). "The first time" is start's own
|
|
2603
|
+
// test, no grants file and no repository yet; a store anywhere else is never made one by start.
|
|
2604
|
+
const handed = hosted ? null : startPaths({ env: { ...(serviceFileEnv ?? {}), ...process.env } });
|
|
2605
|
+
if (handed && isInsideCheckout(storeDir, handed.configStore)
|
|
2606
|
+
&& !existsSync(handed.grants) && !existsSync(join(handed.configStore, ".git"))) {
|
|
2607
|
+
info(`saves to ${storeDir} are recorded from the first \`${invoke("start")}\`, which makes `
|
|
2608
|
+
+ `${handed.configStore} a git repository`);
|
|
2609
|
+
} else {
|
|
2610
|
+
warn(`${storeDir} is not inside a git repository, so a save through the portal is refused rather than `
|
|
2611
|
+
+ "recorded until it is");
|
|
2612
|
+
}
|
|
2373
2613
|
} else {
|
|
2374
2614
|
info(`could not ask git where saves to ${storeDir} go (${w.why}) — a failure to look, not a finding`);
|
|
2375
2615
|
}
|
|
@@ -2481,10 +2721,8 @@ export async function runCheck() {
|
|
|
2481
2721
|
// no register was selected, one screen above "nothing a search is refused for is missing from the units'
|
|
2482
2722
|
// environment": one install, two answers, and the fix it named was already set. effectiveForService is
|
|
2483
2723
|
// 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;
|
|
2724
|
+
// says it could not look rather than reporting the register absent. That reader is `serviceValue`, above
|
|
2725
|
+
// the opening, which shares it with the research section.
|
|
2488
2726
|
const prov = serviceKnown ? serviceValue("CLEAROTRON_DATABASE") : null;
|
|
2489
2727
|
if (!serviceKnown) {
|
|
2490
2728
|
info(`the units are installed but their environment could not be read (${unitEnv?.why ?? "no reason given"}) — `
|
|
@@ -2501,7 +2739,7 @@ export async function runCheck() {
|
|
|
2501
2739
|
if (!prov) {
|
|
2502
2740
|
blocking(`no register is selected — CLEAROTRON_DATABASE is not set and there is NO default, so every search refuses until one is`);
|
|
2503
2741
|
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")}
|
|
2742
|
+
info(` re-run \`${invoke("install")}\` to set it`);
|
|
2505
2743
|
}
|
|
2506
2744
|
else {
|
|
2507
2745
|
const spec = PROVIDERS.find((p) => p.id === prov.v);
|
|
@@ -2527,12 +2765,7 @@ export async function runCheck() {
|
|
|
2527
2765
|
}
|
|
2528
2766
|
}
|
|
2529
2767
|
|
|
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");
|
|
2768
|
+
// "Research provider" is printed second, right after the opening (sayResearch).
|
|
2536
2769
|
|
|
2537
2770
|
// ── — THE LANES A PRODUCT DECLARES IT NEEDS, BEFORE A REPORT NAMES THEM ──
|
|
2538
2771
|
//
|
|
@@ -2549,47 +2782,10 @@ export async function runCheck() {
|
|
|
2549
2782
|
// doctor that hangs on a box with no route — so this reports ENROLMENT, and says plainly that a
|
|
2550
2783
|
// source which is enrolled can still fail at run time. The owner's own report says `CONNECTION_CLOSED`
|
|
2551
2784
|
// on exactly that case.
|
|
2552
|
-
// ── WILL A SEARCH RUN? — THE ORDER-TIME GATE'S OWN QUESTION, OF THE ENVIRONMENT A RUN WILL HAVE ──
|
|
2553
2785
|
//
|
|
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
|
-
}
|
|
2786
|
+
// "Will a search run?" keeps this place when the opening was the refusal's own sentence, which says the
|
|
2787
|
+
// same thing without the names; in every other state it is the opening (sayWillASearchRun).
|
|
2788
|
+
if (leadIsTheRefusal) sayWillASearchRun();
|
|
2593
2789
|
|
|
2594
2790
|
say("\n Case law and other capabilities");
|
|
2595
2791
|
{
|
|
@@ -3189,22 +3385,37 @@ export async function runCheck() {
|
|
|
3189
3385
|
} catch (e) { warn(`the submit lane could not be read: ${e.message}`); }
|
|
3190
3386
|
|
|
3191
3387
|
say("\n Client connector");
|
|
3192
|
-
// THE REVOCATION LIST, REPORTED (found in review). `isRevoked`
|
|
3193
|
-
//
|
|
3194
|
-
//
|
|
3195
|
-
//
|
|
3388
|
+
// THE REVOCATION LIST, REPORTED (found in review). `isRevoked` used to read an unreadable denylist as
|
|
3389
|
+
// "not revoked", so a named-but-absent file made every revocation silently ineffective: measured on a
|
|
3390
|
+
// default install, a revoked key completed a full handshake with nothing logged. It now refuses every
|
|
3391
|
+
// key (shared/scope.mjs), and this is where the reader learns why.
|
|
3196
3392
|
{
|
|
3197
3393
|
const { defaultDenylistPath } = await import(pathToFileURL(join(REPO, "shared", "client-door.mjs")).href);
|
|
3198
|
-
const
|
|
3394
|
+
const named = effective("TRADEMARK_MCP_TOKEN_DENYLIST")?.v;
|
|
3395
|
+
const dl = named || defaultDenylistPath(homedir());
|
|
3199
3396
|
try {
|
|
3200
3397
|
const n = readFileSync(dl, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#")).length;
|
|
3201
3398
|
ok(`revocation list readable at ${dl} — ${n} revoked key id(s)`);
|
|
3202
3399
|
} catch (e) {
|
|
3203
|
-
//
|
|
3204
|
-
//
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3400
|
+
// THE DEFAULT LIST, NOT WRITTEN YET, IS NOTHING REVOKED. That is the key check's own rule
|
|
3401
|
+
// (shared/scope.mjs, `isRevoked`): every revocation creates the file it writes to, so its absence is
|
|
3402
|
+
// the proof. With no units the first `start` creates it, and before then this warned a newcomer that
|
|
3403
|
+
// revoking would silently do nothing (measured on a fresh install of a beta, 2026-11-04). "Before
|
|
3404
|
+
// then" is start's own first-run test, as for the store above: no grants file and no repository yet.
|
|
3405
|
+
// Once start has run it hands its door this path BY NAME, and a named list the key check cannot read
|
|
3406
|
+
// refuses every key; so does a list the settings name, or one on a machine with units. Those are
|
|
3407
|
+
// still the fault below.
|
|
3408
|
+
const handed = hosted ? null : startPaths({ env: { ...(serviceFileEnv ?? {}), ...process.env } });
|
|
3409
|
+
if (!named && handed && e?.code === "ENOENT"
|
|
3410
|
+
&& !existsSync(handed.grants) && !existsSync(join(handed.configStore, ".git"))) {
|
|
3411
|
+
info(`no revocation list yet at ${dl}: no key has been revoked. The first \`${invoke("start")}\` creates it.`);
|
|
3412
|
+
} else {
|
|
3413
|
+
// NOT `warn`. The door refuses every key while its list cannot be read, so every assistant connected
|
|
3414
|
+
// to it stops, and this sentence is the door's own (mcp-server/lib/http-handler.mjs).
|
|
3415
|
+
blocking(`the revocation list at ${dl} cannot be read (${e.code ?? e.message}) — this install cannot `
|
|
3416
|
+
+ "check whether keys have been revoked, so it is refusing all of them. "
|
|
3417
|
+
+ `Run \`${invoke("start")}\` — it creates the list.`);
|
|
3418
|
+
}
|
|
3208
3419
|
}
|
|
3209
3420
|
}
|
|
3210
3421
|
// ── IS THIS DOOR'S ACCESS LOG BEING WRITTEN, AND WHERE? ───────────────────────────────────────────
|
|
@@ -3573,17 +3784,17 @@ export async function runCheck() {
|
|
|
3573
3784
|
// different actions from the reader — edit a file versus fix a credential — and a single number
|
|
3574
3785
|
// covering both sends them to the wrong one.
|
|
3575
3786
|
if (inert.length) parts.push(`${inert.length} setting(s) being ignored`);
|
|
3576
|
-
say(` ${parts.join(" and ")}. Nothing was written — this command only reads
|
|
3787
|
+
say(` ${parts.join(" and ")}. ${probeTurnRan ? TURN_KEPT_ITS_FILES : "Nothing was written — this command only reads."}\n`);
|
|
3577
3788
|
return 1;
|
|
3578
3789
|
}
|
|
3579
3790
|
// The exit status stays 0: an unfinished install is not a broken one, and `--check` separates an
|
|
3580
3791
|
// absence from a misconfiguration. What changed is that the closing line no longer says nothing is
|
|
3581
3792
|
// wrong while something that stops the product stands above it.
|
|
3582
3793
|
if (blockers.length) {
|
|
3583
|
-
say(
|
|
3794
|
+
say(` Nothing is MISconfigured — fix those and nothing else here needs changing. ${probeTurnRan ? TURN_KEPT_ITS_FILES : "Nothing was written."}\n`);
|
|
3584
3795
|
return 0;
|
|
3585
3796
|
}
|
|
3586
|
-
say(
|
|
3797
|
+
say(` Nothing wrong with what is configured. ${probeTurnRan ? TURN_KEPT_ITS_FILES : "Nothing was written."}\n`);
|
|
3587
3798
|
return 0;
|
|
3588
3799
|
}
|
|
3589
3800
|
|
|
@@ -3773,7 +3984,7 @@ let aborted = null;
|
|
|
3773
3984
|
try {
|
|
3774
3985
|
say("\n Trademark clearance engine — setup\n");
|
|
3775
3986
|
say(" One question at a time. Enter takes the default in brackets.");
|
|
3776
|
-
say(" Nothing is written until
|
|
3987
|
+
say(" Nothing 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
3988
|
|
|
3778
3989
|
// ── BEFORE YOU START, derived from what the product declares it needs ──────
|
|
3779
3990
|
//
|
|
@@ -3781,13 +3992,13 @@ try {
|
|
|
3781
3992
|
// what to prepare by failing the question — the owner's own first run, in his words. The list below
|
|
3782
3993
|
// is DERIVED: the engines from ENGINE_BINARIES, the search vendors from the same adapter tables the
|
|
3783
3994
|
// 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
|
|
3995
|
+
// be the SERPAPI defect again, one screen earlier. Everything but the organisation's name is skippable.
|
|
3785
3996
|
// THE BANNER — once, on entry, named (ruling 2026-08-31). Not on every
|
|
3786
3997
|
// command: a banner every verb prints is how a product becomes tiresome to use twice. It sits here
|
|
3787
3998
|
// rather than at the top of main() so that `--check`, which writes nothing and is run repeatedly,
|
|
3788
3999
|
// does not wear it either.
|
|
3789
4000
|
say("");
|
|
3790
|
-
say(banner({ title: "Clearotron setup", subtitle: "one pass, and everything here is skippable", style,
|
|
4001
|
+
say(banner({ title: "Clearotron setup", subtitle: "one pass, and everything here but your organisation's name is skippable", style,
|
|
3791
4002
|
mark: bracketAsciiCells(), columns: process.stdout.columns }));
|
|
3792
4003
|
say("");
|
|
3793
4004
|
say(` ${style.bold("Before you start")} — what this setup can take, so nothing here surprises you:`);
|
|
@@ -3821,6 +4032,7 @@ try {
|
|
|
3821
4032
|
say("\n Engine");
|
|
3822
4033
|
say(" Clearotron runs each step of a search as a short, unattended session of an AI. One AI serves");
|
|
3823
4034
|
say(" every search on this computer, so it is not chosen per search.");
|
|
4035
|
+
let lastPick = null; // the AI picked on the pass before this one (engineMenuDefault)
|
|
3824
4036
|
engine: for (;;) {
|
|
3825
4037
|
// ── THE STATE FIRST, THE QUESTIONS OFF IT ──────────────────────────────
|
|
3826
4038
|
//
|
|
@@ -3836,8 +4048,10 @@ try {
|
|
|
3836
4048
|
// only honest answer to it, and a guessed "signed in" that the turn then contradicts costs more than
|
|
3837
4049
|
// no claim. Resolved once per pass, so a reader who mends something and comes back sees it mended.
|
|
3838
4050
|
const found = engineMenuState();
|
|
3839
|
-
const
|
|
4051
|
+
const options = engineOptions(found);
|
|
4052
|
+
const pick = await choose(ENGINE_QUESTION, options, engineMenuDefault(options, lastPick), PAY_PREAMBLE);
|
|
3840
4053
|
if (!pick.id) { sayNoEngine(); break; }
|
|
4054
|
+
lastPick = pick.id;
|
|
3841
4055
|
const eng = ENGINE_BINARIES[pick.id];
|
|
3842
4056
|
|
|
3843
4057
|
let bin = resolveEngineBin(process.env[eng.env] || eng.fallback, { engine: pick.id });
|
|
@@ -3974,7 +4188,7 @@ try {
|
|
|
3974
4188
|
if (authPick.id === "api-key") {
|
|
3975
4189
|
if (ambientKeyPresent) {
|
|
3976
4190
|
apiKey = process.env[eng.apiKeyEnv];
|
|
3977
|
-
info(`${eng.apiKeyEnv} is already in your environment — adopting it, so the .env this writes
|
|
4191
|
+
info(`${eng.apiKeyEnv} is already in your environment — adopting it, so the .env this writes carries the key the test turn uses.`);
|
|
3978
4192
|
} else {
|
|
3979
4193
|
apiKey = await askValue(`${eng.apiKeyEnv}:`, { secret: true });
|
|
3980
4194
|
}
|
|
@@ -4010,23 +4224,30 @@ try {
|
|
|
4010
4224
|
//
|
|
4011
4225
|
// THE CHECK IS UNCHANGED AND THE REFUSAL IS UNCHANGED. He valued both, and the issue puts them out
|
|
4012
4226
|
// of scope explicitly — what was wrong was the sentence around them, so only the sentence moved.
|
|
4013
|
-
//
|
|
4014
|
-
//
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4227
|
+
// proofPreamble says what a reader needs to decide with: what the turn costs, and that answering no
|
|
4228
|
+
// saves nothing.
|
|
4229
|
+
for (const line of proofPreamble({ product: eng.product, billing: authPick.id })) info(line);
|
|
4230
|
+
if (!await confirm(proveQuestion({ product: eng.product, billing: authPick.id }), true)) {
|
|
4231
|
+
// A WAY ON WITHOUT AN AI, BEFORE THE MENU. A declined proof went straight back to the menu, so a reader
|
|
4232
|
+
// taking every default went round the same setup again. The question the no-program path already asks
|
|
4233
|
+
// offers the way on; no returns to the menu, with this pick its default, and only that answer says so.
|
|
4234
|
+
if (await confirm("Continue with no engine configured?", true)) { sayNoEngine(); break engine; }
|
|
4018
4235
|
info("Not proven, so not written. Pick again — the last row configures no engine at all.");
|
|
4019
4236
|
continue;
|
|
4020
4237
|
}
|
|
4238
|
+
// A TOKEN PASTED BELOW IS SAVED ONLY WITH THE TURN IT PROVED. It was written into the settings as it was
|
|
4239
|
+
// pasted, so a reader whose turn still failed, and who then went on without an AI, had it saved unproved.
|
|
4240
|
+
let pastedToken = null;
|
|
4021
4241
|
for (;;) {
|
|
4022
4242
|
say(" Running one turn…");
|
|
4023
4243
|
// Read on every try, so a setting the reader fixes in the file between tries is the one the next turn uses.
|
|
4024
4244
|
const v = await probeEngineTurn(proofTurn({ engineId: pick.id, eng, bin, authEnv, settings: settingsInForce() }));
|
|
4025
4245
|
if (v.ok) {
|
|
4026
|
-
ok(`${
|
|
4246
|
+
ok(`${eng.product} completed a turn on ${PAYS_WITH[authPick.id]} — binary, credential, billing mode and model access all work.`);
|
|
4027
4247
|
const served = servedLine(v);
|
|
4028
4248
|
if (served) info(served);
|
|
4029
4249
|
candidate.CLEAROTRON_AI = pick.id;
|
|
4250
|
+
if (pastedToken !== null) candidate[eng.headless.tokenEnv] = pastedToken;
|
|
4030
4251
|
// ALWAYS WRITTEN, and for the copy Clearotron installed it is the engine's default word: see
|
|
4031
4252
|
// engineProgramSetting for why leaving it out was not enough.
|
|
4032
4253
|
candidate[eng.env] = engineProgramSetting(eng, bin);
|
|
@@ -4036,14 +4257,14 @@ try {
|
|
|
4036
4257
|
const cloudLines = Object.entries(cloudEnv ?? {}).filter(([k]) => k !== eng.authEnv);
|
|
4037
4258
|
for (const [k, val] of cloudLines) candidate[k] = val;
|
|
4038
4259
|
info(`CLEAROTRON_AI=${pick.id}`);
|
|
4039
|
-
info(`${eng.authEnv}=${authPick.id} —
|
|
4260
|
+
info(`${eng.authEnv}=${authPick.id} — how the turn above was paid for.`);
|
|
4040
4261
|
if (apiKey) info(`${eng.apiKeyEnv}=… — adopted, so a run bills the way you just proved.`);
|
|
4041
4262
|
for (const [k, val] of cloudLines) info(shownSetting(k, val));
|
|
4042
4263
|
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
4264
|
else info(`${eng.env}=${bin.path} — the absolute form, because a service's PATH is not your shell's.`);
|
|
4044
4265
|
break engine;
|
|
4045
4266
|
}
|
|
4046
|
-
problem(
|
|
4267
|
+
problem(proofFailureLine(v, eng.product));
|
|
4047
4268
|
// ── THE ENGINE'S OWN LAST LINES, UNDER EVERY VERDICT, ON BOTH LANES ──────────────────────────
|
|
4048
4269
|
//
|
|
4049
4270
|
// This used to be `if (v.detail)`, so a verdict carrying no detail printed a headline and nothing
|
|
@@ -4054,10 +4275,9 @@ try {
|
|
|
4054
4275
|
//
|
|
4055
4276
|
// SAY WHICH IT IS, INCLUDING WHEN THERE IS NOTHING. "The engine printed nothing" is itself the
|
|
4056
4277
|
// 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})`);
|
|
4278
|
+
// a reader unable to tell that from a wizard that decided not to show them. A program refused before it
|
|
4279
|
+
// started said nothing because it never ran, so proofEvidence shows no line for it.
|
|
4280
|
+
for (const line of proofEvidence(v)) info(line);
|
|
4061
4281
|
// — THE HAND-OFF. Signing in is the one step of this sequence nobody here can perform for
|
|
4062
4282
|
// someone, so the wizard names the command, waits, and re-probes rather than ending at a
|
|
4063
4283
|
// description of what is wrong. The text comes from ENGINE_BINARIES so the two adapters cannot
|
|
@@ -4065,6 +4285,20 @@ try {
|
|
|
4065
4285
|
// subscription's step, and on a cloud or under a key the verdict above has named what to check.
|
|
4066
4286
|
const handOff = signInHandOff(eng, bin, authPick.id);
|
|
4067
4287
|
for (const line of handOff.lines) info(line);
|
|
4288
|
+
// — found in review, and the same trap closed one prompt over. The default
|
|
4289
|
+
// was YES, so Enter re-ran a probe that CANNOT succeed until the reader has signed in somewhere
|
|
4290
|
+
// else — and the wizard's own header tells them Enter is the safe key. Driven with Enter it went
|
|
4291
|
+
// 19 attempts, no cap and no escape, in a wizard whose header says everything here is skippable.
|
|
4292
|
+
//
|
|
4293
|
+
// Enter now declines, and the question after it is the one the no-program path asks, whose Enter
|
|
4294
|
+
// goes on with no AI: a reader taking every default no longer goes round the menu again. No returns
|
|
4295
|
+
// to the engine menu with this AI its default, and that line says what going on without one costs.
|
|
4296
|
+
if (!await confirm("Fixed it? Run the turn again", false)) {
|
|
4297
|
+
if (await confirm("Continue with no engine configured?", true)) { sayNoEngine(); break engine; }
|
|
4298
|
+
info("Not proven, so not written. Back to the engine menu — its last row configures no engine: "
|
|
4299
|
+
+ "the demo and a replayed report still work, and a real clearance refuses by name until one is set.");
|
|
4300
|
+
continue engine;
|
|
4301
|
+
}
|
|
4068
4302
|
// ── THE HEADLESS ENDING ────────────────────────────────────────────────
|
|
4069
4303
|
//
|
|
4070
4304
|
// On a box with no browser the interactive sign-in cannot complete, and the documented route had
|
|
@@ -4074,30 +4308,21 @@ try {
|
|
|
4074
4308
|
// stream layout is not ours to guess at, and a paste works whatever it prints where. Codex's
|
|
4075
4309
|
// headless ending writes its own auth file and there is nothing to capture — the command is
|
|
4076
4310
|
// named, and the re-probe is the proof either way.
|
|
4311
|
+
//
|
|
4312
|
+
// ASKED AFTER THE RETRY'S YES, NOT BEFORE IT. The hand-off above asks for that yes by name, and a reader
|
|
4313
|
+
// who had signed in in the browser met this question first, which wants a no from them. The turn has not
|
|
4314
|
+
// run again yet, so a token pasted here is still the one it proves.
|
|
4077
4315
|
if (handOff.captureToken) {
|
|
4078
4316
|
// A TOKEN PASTED AT THE YES/NO IS THE ANSWER (confirmOrKey): taken, never shown, not asked for twice.
|
|
4079
4317
|
const answer = await confirmOrKey(`Did that give you a token to paste? Capture it into ${eng.headless.tokenEnv} now`, false, { what: "token" });
|
|
4080
4318
|
const tok = answer.value ?? (answer.yes
|
|
4081
4319
|
? await askValue(`${eng.headless.tokenEnv}:`, { secret: true, skippable: true, skipped: "Nothing captured." }) : null);
|
|
4082
4320
|
if (tok !== null) {
|
|
4083
|
-
|
|
4321
|
+
pastedToken = tok;
|
|
4084
4322
|
authEnv[eng.headless.tokenEnv] = tok; // the re-probe below must prove the sign-in WITH it
|
|
4085
4323
|
info(`${eng.headless.tokenEnv} captured — the turn below proves it before anything is written.`);
|
|
4086
4324
|
}
|
|
4087
4325
|
}
|
|
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
4326
|
}
|
|
4102
4327
|
}
|
|
4103
4328
|
|
|
@@ -4170,7 +4395,7 @@ try {
|
|
|
4170
4395
|
say("");
|
|
4171
4396
|
info("No register is selected, and nothing register-related will be written.");
|
|
4172
4397
|
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
|
|
4398
|
+
info(" Installation settings page says it too. Re-run setup when you have a credential.");
|
|
4174
4399
|
}
|
|
4175
4400
|
for (const k of registerSelected ? (spec.optionalCredentials ?? []) : []) {
|
|
4176
4401
|
if (present(candidate[k])) { ok(`${k} already adopted from your environment`); continue; }
|
|
@@ -4241,7 +4466,7 @@ try {
|
|
|
4241
4466
|
// table row carries. A live check runs where one exists, keyed on the credential's name.
|
|
4242
4467
|
say("\n Search credentials");
|
|
4243
4468
|
const liveChecks = { PERPLEXITY_API_KEY: validatePerplexity };
|
|
4244
|
-
for (const [tableLabel, table] of [["research", RESEARCH_PROVIDERS], ["the
|
|
4469
|
+
for (const [tableLabel, table] of [["research", RESEARCH_PROVIDERS], ["the Chinese marketplace search", SERP_PROVIDERS]]) {
|
|
4245
4470
|
for (const adapter of Object.values(table)) {
|
|
4246
4471
|
const name = adapter.credEnv;
|
|
4247
4472
|
say("");
|
|
@@ -4369,18 +4594,16 @@ try {
|
|
|
4369
4594
|
// consequence at the end. Its explanation of WHY an assistant reaches the box from a vendor's cloud is
|
|
4370
4595
|
// genuinely useful and is a document, not a prompt — it lives in mcp-server/CONNECT.md, and the prompt
|
|
4371
4596
|
// carries one line and a pointer.
|
|
4372
|
-
say("\n
|
|
4597
|
+
say("\n Optional: the public connector address");
|
|
4373
4598
|
prose("An assistant connects from its maker's servers, not from your machine, so this has to be an",
|
|
4374
4599
|
"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.");
|
|
4600
|
+
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
4601
|
prose("The usual shape, and why: mcp-server/CONNECT.md.");
|
|
4378
4602
|
const { clientDoorReachability } = await import(pathToFileURL(join(REPO, "shared", "client-door.mjs")).href);
|
|
4379
4603
|
for (;;) {
|
|
4380
4604
|
const clientUrl = await askValue("Public connector address:", {
|
|
4381
4605
|
skippable: true,
|
|
4382
|
-
skipped: "CLEAROTRON_CLIENT_MCP_URL left unset — the
|
|
4383
|
-
+ "show their empty state, which is correct for a local install",
|
|
4606
|
+
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
4607
|
});
|
|
4385
4608
|
if (clientUrl === null) break;
|
|
4386
4609
|
const trimmed = clientUrl.trim();
|
|
@@ -4418,8 +4641,7 @@ try {
|
|
|
4418
4641
|
// making a decision about where their customer data lives without being told they had made it.
|
|
4419
4642
|
const cfgDefault = join(base, "config");
|
|
4420
4643
|
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.");
|
|
4644
|
+
prose(configOutsideWhy(PACKAGED));
|
|
4423
4645
|
prose(`Enter accepts ${cfgDefault}, and your customers are written there.`);
|
|
4424
4646
|
const cfg = await askValue("Configuration directory:", { def: cfgDefault });
|
|
4425
4647
|
|
|
@@ -4428,9 +4650,9 @@ try {
|
|
|
4428
4650
|
// `<repo>-notes` is not mistaken for a path inside `<repo>`.
|
|
4429
4651
|
const cfgAbs = resolve(cfg);
|
|
4430
4652
|
if (isInsideCheckout(cfg, REPO)) {
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4653
|
+
const [inside, ...why] = configInsideRefusal(PACKAGED, cfgAbs, resolve(REPO));
|
|
4654
|
+
problem(inside);
|
|
4655
|
+
for (const line of why) say(` ${line}`);
|
|
4434
4656
|
aborted = "config-inside-checkout";
|
|
4435
4657
|
throw new Error("config-inside-checkout");
|
|
4436
4658
|
}
|
|
@@ -4466,10 +4688,7 @@ try {
|
|
|
4466
4688
|
//
|
|
4467
4689
|
// Note for whoever adds an overlay later: it needs this name set, which is why the line below says so
|
|
4468
4690
|
// 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.");
|
|
4691
|
+
info(customInstructionsNone(cfg));
|
|
4473
4692
|
|
|
4474
4693
|
// DELIBERATELY NOT SEEDED, and this reverses what the issue asked for. Copying the house `generic.json`
|
|
4475
4694
|
// in would make the store a working install — but since an EMPTY store already is one: profiles
|
|
@@ -4480,9 +4699,7 @@ try {
|
|
|
4480
4699
|
// PRECISELY what shows through, because the last wording said "bundled customers" and the loader
|
|
4481
4700
|
// says otherwise: the demo roster never layers into a deployment (a typo'd key must not resolve to
|
|
4482
4701
|
// 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.");
|
|
4702
|
+
prose(EMPTY_CONFIG_FOLDER);
|
|
4486
4703
|
|
|
4487
4704
|
// 7c ── YOUR ORGANISATION, AND WHO SIGNS IN
|
|
4488
4705
|
//
|
|
@@ -4512,9 +4729,9 @@ try {
|
|
|
4512
4729
|
// silently passed over. A reader who is told a preflight ran and passed, when it never ran, learns
|
|
4513
4730
|
// to trust a line that means nothing.
|
|
4514
4731
|
if (registerSelected) {
|
|
4515
|
-
say("\n Running the
|
|
4732
|
+
say("\n Running the register credential check over these values…");
|
|
4516
4733
|
const pf = await preflightCandidate(candidate);
|
|
4517
|
-
if (pf.ok) ok(
|
|
4734
|
+
if (pf.ok) ok(registerCheckPassed(pf.result.provider, pf.result.checked.join(" + ")));
|
|
4518
4735
|
else {
|
|
4519
4736
|
problem(pf.error);
|
|
4520
4737
|
say("\n Nothing has been written.");
|
|
@@ -4522,9 +4739,8 @@ try {
|
|
|
4522
4739
|
throw new Error("preflight");
|
|
4523
4740
|
}
|
|
4524
4741
|
} else {
|
|
4525
|
-
say("
|
|
4526
|
-
|
|
4527
|
-
say(" untouched, and this is only setup declining to fail an install it was told to allow.");
|
|
4742
|
+
say("");
|
|
4743
|
+
prose(REGISTER_CHECK_SKIPPED);
|
|
4528
4744
|
}
|
|
4529
4745
|
|
|
4530
4746
|
// 9 ── write, atomically
|
|
@@ -4558,7 +4774,7 @@ try {
|
|
|
4558
4774
|
// portal reads an empty folder the same way: it overrides nothing. It is here so that the place an
|
|
4559
4775
|
// override goes exists, and so the line below is true of both folders it describes.
|
|
4560
4776
|
mkdirSync(join(cfg, "skills"), { recursive: true });
|
|
4561
|
-
ok(
|
|
4777
|
+
ok(configFoldersMade(cfg));
|
|
4562
4778
|
|
|
4563
4779
|
// 9a ── PUT THE VERB ON THIS OPERATOR'S PATH
|
|
4564
4780
|
//
|
|
@@ -4625,23 +4841,29 @@ try {
|
|
|
4625
4841
|
// and asserts which command LEADS; a command named here would lead instead, and the guard that has
|
|
4626
4842
|
// twice caught this screen regressing would start reporting the wrong thing.
|
|
4627
4843
|
const stateLine = (label, value, absent) => `${value ? "set" : "not set"} — ${label}: ${value || absent}`;
|
|
4628
|
-
|
|
4629
|
-
|
|
4844
|
+
// The AI by the name the engine question gives it; none unless one passed its proof turn.
|
|
4845
|
+
const aiChosen = ENGINE_BINARIES[candidate.CLEAROTRON_AI]?.product ?? "";
|
|
4846
|
+
// "NOTHING HERE NEEDS RUNNING AGAIN" ONLY WITH AN AI AND A REGISTER CHOSEN. Without either, setup
|
|
4847
|
+
// has already told the reader to run it again (NO_AI_CHOSEN, and the warning under a missing register).
|
|
4848
|
+
say(`\n ${style.bold("Setup finished.")}${aiChosen && registerSelected ? " Nothing here needs running again." : ""}\n`);
|
|
4849
|
+
say(" What this install has now:");
|
|
4630
4850
|
for (const line of [
|
|
4631
4851
|
// THE ONE PLACE THE ADDRESS IS SHOWN (ruling, 2026-09-10): setup no longer asks for it.
|
|
4632
4852
|
stateLine("signs in as", candidate.PORTAL_LOCAL_USER, "the local account"),
|
|
4853
|
+
stateLine("AI", aiChosen, "none chosen; the demo works without one, and a real search needs one"),
|
|
4633
4854
|
stateLine("register", candidate.CLEAROTRON_DATABASE, "no register, so every search refuses until one is chosen"),
|
|
4634
4855
|
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
4856
|
stateLine("data directory", candidate.CLEAROTRON_REPORTS_DIR, "unset"),
|
|
4636
4857
|
stateLine("configuration store", candidate.CLEAROTRON_CUSTOMERS_DIR, "the bundled demo roster"),
|
|
4637
4858
|
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
|
|
4859
|
+
stateLine("client connector", candidate.CLEAROTRON_CLIENT_MCP_URL, "local install; the Connect your AI page shows its empty state"),
|
|
4639
4860
|
]) say(` ${line}`);
|
|
4640
4861
|
|
|
4641
4862
|
say(`\n ${style.bold("Start here:")}\n`);
|
|
4642
4863
|
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
|
|
4864
|
+
say(" Starts the portal, the engine door, the client door and the worker, and prints one address to");
|
|
4865
|
+
say(" open in your browser. That address is the product: you order a clearance from it and read the");
|
|
4866
|
+
say(" report there.\n");
|
|
4645
4867
|
// THE ONE SENTENCE A READER NEEDS BEFORE THEY OPEN THAT ADDRESS, and setup was the only one of the
|
|
4646
4868
|
// three commands that never said it. A port can be free where the product runs and taken where the
|
|
4647
4869
|
// BROWSER runs — a forwarding listener outside this environment answers 127.0.0.1 first — and the
|
|
@@ -4651,8 +4873,12 @@ try {
|
|
|
4651
4873
|
// use, with no number, so the three commands cannot drift into three answers.
|
|
4652
4874
|
for (const line of foreignPageHint("start")) say(` ${line}`);
|
|
4653
4875
|
say("");
|
|
4654
|
-
|
|
4655
|
-
|
|
4876
|
+
// A FIRST REAL CLEARANCE IS SUGGESTED ONLY WHERE ONE CAN RUN. With no register chosen, the line suggesting
|
|
4877
|
+
// `run` sat a few lines above the warning that `run` will refuse at its door.
|
|
4878
|
+
if (registerSelected) {
|
|
4879
|
+
say(` ${style.dim(`Also: \`${invocationPrefix()}clearotron demo\` replays a finished report with no keys and no model calls;`)}`);
|
|
4880
|
+
say(` ${style.dim(`\`${invocationPrefix()}clearotron run --job ${/\s/.test(EXAMPLE_JOB) ? `"${EXAMPLE_JOB}"` : EXAMPLE_JOB}\` runs a first real clearance on the EU register.`)}`);
|
|
4881
|
+
} else say(` ${style.dim(`Also: \`${invocationPrefix()}clearotron demo\` replays a finished report with no keys and no model calls.`)}`);
|
|
4656
4882
|
// THE OLD WAY IS A CHECKOUT'S. A package has no npm scripts where its reader stands.
|
|
4657
4883
|
if (!PACKAGED) say(` ${style.dim("Each still works the old way too — `npm start`, `node driver/pipeline.mjs`.")}`);
|
|
4658
4884
|
say("");
|
|
@@ -4710,7 +4936,7 @@ try {
|
|
|
4710
4936
|
if (needs.length && !enrollable.some((r) => r.configured)) {
|
|
4711
4937
|
say("\n Case law");
|
|
4712
4938
|
say(` ${needs.join(" and ")} reasons against case law and oppositions. No case-law source is`);
|
|
4713
|
-
say(" enrolled on this
|
|
4939
|
+
say(" enrolled on this install, so that search will run and its report will state the gap rather than");
|
|
4714
4940
|
say(" telling you what the courts have decided. Nothing here can set it up: it is a one-time OAuth");
|
|
4715
4941
|
say(" sign-in, described in providers/oauth-mcp-bridge/README.md, and every other search is");
|
|
4716
4942
|
say(` unaffected. \`${invocationPrefix()}clearotron doctor\` reports it at any time.\n`);
|
|
@@ -4722,7 +4948,7 @@ try {
|
|
|
4722
4948
|
say(` \`${invocationPrefix()}clearotron demo\` and \`${invocationPrefix()}clearotron start\` work now. A real`);
|
|
4723
4949
|
say(" clearance needs one register — any one is enough, and none requires another:");
|
|
4724
4950
|
say(` ${PROVIDERS.map((p) => p.id).join(", ")}`);
|
|
4725
|
-
say(` Set it by re-running \`${invocationPrefix()}clearotron install
|
|
4951
|
+
say(` Set it by re-running \`${invocationPrefix()}clearotron install\`.`);
|
|
4726
4952
|
say(` \`${invocationPrefix()}clearotron doctor\` says which state this install is in, at any time.\n`);
|
|
4727
4953
|
}
|
|
4728
4954
|
} catch (e) {
|