@tpsdev-ai/flair 0.63.0 → 0.63.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/SECURITY.md +55 -33
- package/dist/bridges/runtime/import-runner.js +4 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +243 -83
- package/dist/commands/agent.js +298 -72
- package/dist/commands/attention.js +2 -0
- package/dist/commands/bootstrap.js +2 -0
- package/dist/commands/bridge.js +10 -0
- package/dist/commands/doctor.js +87 -42
- package/dist/commands/export.js +141 -11
- package/dist/commands/import.js +36 -15
- package/dist/commands/init.js +373 -157
- package/dist/commands/keys.js +12 -8
- package/dist/commands/mcp.js +146 -62
- package/dist/commands/memory.js +5 -2
- package/dist/commands/migrate-harness-memory.js +9 -3
- package/dist/commands/principal.js +19 -14
- package/dist/commands/quality.js +23 -3
- package/dist/commands/reembed.js +468 -111
- package/dist/commands/search.js +2 -0
- package/dist/commands/service.js +25 -0
- package/dist/commands/status.js +130 -107
- package/dist/doctor-client.js +2 -23
- package/dist/federation/scheduler.js +148 -12
- package/dist/keystore.js +77 -10
- package/dist/lib/agent-key-file.js +509 -0
- package/dist/lib/agent-rotation-lock.js +249 -0
- package/dist/lib/atomic-write.js +2 -2
- package/dist/lib/auth-resolve.js +14 -14
- package/dist/lib/key-dir.js +203 -0
- package/dist/lib/launchd-management.js +7 -3
- package/dist/lib/local-instance-pair.js +8 -1
- package/dist/lib/node-alias-path.js +50 -2
- package/dist/lib/remote-admin-pass.js +157 -0
- package/dist/lib/scheduler-platform.js +13 -0
- package/dist/lib/service-repoint.js +13 -4
- package/dist/lib/skill-seed.js +35 -3
- package/dist/lib/terminal-text.js +32 -0
- package/dist/mcp-client-assertion.js +5 -4
- package/dist/resources/Memory.js +47 -3
- package/dist/resources/health.js +39 -22
- package/dist/resources/in-process-api.js +74 -11
- package/dist/resources/mcp-client-metadata-fields.js +4 -0
- package/dist/resources/mcp-handler.js +40 -1
- package/dist/resources/mcp-oauth.js +17 -1
- package/dist/resources/mcp-tool-scopes.js +69 -0
- package/dist/resources/mcp-tools.js +10 -0
- package/dist/resources/skill-version-write.js +16 -0
- package/dist/src/keystore.js +77 -10
- package/dist/src/lib/atomic-write.js +2 -2
- package/dist/src/lib/key-dir.js +203 -0
- package/dist/src/lib/scheduler-platform.js +13 -0
- package/docs/access-control.md +21 -12
- package/docs/api-reference.md +35 -24
- package/docs/auth.md +31 -22
- package/docs/deploying-on-fabric.md +10 -2
- package/docs/embedding-in-a-harper-app.md +7 -7
- package/docs/entity-vocabulary.md +4 -5
- package/docs/hosted-on-fabric.md +1 -1
- package/docs/secrets-and-keys.md +8 -13
- package/docs/upgrade.md +15 -5
- package/package.json +1 -1
package/dist/commands/search.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { buildEd25519Auth, requestTarget, requestUrl, resolveKeyPath } from "../lib/auth-resolve.js";
|
|
2
|
+
import { requireAgentId } from "../lib/key-dir.js";
|
|
2
3
|
import * as render from "../render.js";
|
|
3
4
|
import { DURABILITY_CAVEAT } from "../lib/durability-copy.js";
|
|
4
5
|
let cli;
|
|
@@ -113,6 +114,7 @@ export function register(program) {
|
|
|
113
114
|
console.error("error: --agent <id> required (or set FLAIR_AGENT_ID)");
|
|
114
115
|
process.exit(2);
|
|
115
116
|
}
|
|
117
|
+
requireAgentId(agentId);
|
|
116
118
|
const baseUrl = resolveBaseUrl(opts);
|
|
117
119
|
const url = requestUrl(baseUrl, "/SemanticSearch");
|
|
118
120
|
const headers = { "content-type": "application/json" };
|
package/dist/commands/service.js
CHANGED
|
@@ -201,6 +201,31 @@ async function stopDirectlyStartedFlair(port, dataDir, label) {
|
|
|
201
201
|
}
|
|
202
202
|
await waitForProcessExit(pid, cli.STARTUP_TIMEOUT_MS);
|
|
203
203
|
removeStaleSidecarIfConfirmedDead(dataDir, pid);
|
|
204
|
+
// The recorded pid exiting is not proof that Flair is down. Read the
|
|
205
|
+
// instance, then launchd so a load during the awaited probe is visible;
|
|
206
|
+
// require NOT_RUNNING and not-loaded.
|
|
207
|
+
const after = classifyDaemonState(await gatherDaemonEvidence(port, dataDir), { port, dataDir });
|
|
208
|
+
const managedAfter = observeLaunchdManagement(dataDir, port);
|
|
209
|
+
if (managedAfter.jobLoaded !== "not-loaded" || after.state !== "NOT_RUNNING") {
|
|
210
|
+
const afterDetail = "detail" in after && after.detail ? ` ${after.detail}` : "";
|
|
211
|
+
console.error(`❌ flair stop: pid ${pid} exited, but Flair is not confirmed down for ${dataDir} — ` +
|
|
212
|
+
`the launchd job ${label} now reads ${managedAfter.jobLoaded ?? "unknown"} and the instance reads ${after.state}.${afterDetail}`);
|
|
213
|
+
// Name the step that handles this observation, next to the diagnostic.
|
|
214
|
+
if (managedAfter.jobLoaded === "loaded") {
|
|
215
|
+
console.error(" Run 'flair stop' again to take the unload path.");
|
|
216
|
+
}
|
|
217
|
+
else if (managedAfter.jobLoaded === "not-loaded" && after.state === "RUNNING") {
|
|
218
|
+
// This step prints only when the job reads not-loaded and the
|
|
219
|
+
// instance reads RUNNING: the classifier verified the hdb.pid pid
|
|
220
|
+
// against the identity sidecar (pid and start time), found it alive,
|
|
221
|
+
// and got Flair's /Health. A re-run that reads the same job state and
|
|
222
|
+
// verified pid signals that pid. RUNNING does not establish that the
|
|
223
|
+
// pid owns the port.
|
|
224
|
+
console.error(" Run 'flair stop' again to stop the verified recorded pid (the instance has recorded its identity).");
|
|
225
|
+
}
|
|
226
|
+
console.error(" Inspect it with: flair doctor");
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
204
229
|
console.log(`✅ stopped the directly started Flair (pid ${pid}); the launchd job ${label} was not loaded`);
|
|
205
230
|
return;
|
|
206
231
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { resolveAdminUser } from "../lib/auth-resolve.js";
|
|
2
2
|
import { opsApiBindFinding } from "../lib/ops-api-bind.js";
|
|
3
|
+
import { agentKeyLocations, formatKeyModeFinding, keyModesUnsupported, KEY_MODES_UNSUPPORTED_MESSAGE, scanAgentKeyModes } from "../lib/key-dir.js";
|
|
4
|
+
import { escapeTerminalText } from "../lib/terminal-text.js";
|
|
3
5
|
import * as render from "../render.js";
|
|
4
6
|
import { checkVersion, formatVersionNudge, FLAIR_PKG_NAME } from "../version-check.js";
|
|
5
7
|
import { formatServingTreeLine, formatTreeAssessmentLines, treeAssessmentJson, } from "../lib/tree-divergence.js";
|
|
@@ -97,9 +99,7 @@ export function statusVersionAdvice(input) {
|
|
|
97
99
|
* Only judged for a loopback target: the LOCAL install's config says nothing
|
|
98
100
|
* about a remote instance, and warning about the wrong machine is its own lie.
|
|
99
101
|
*
|
|
100
|
-
* `
|
|
101
|
-
* and `status deep`) behave as before. It is injectable so a test can drive the
|
|
102
|
-
* decision against a temp data dir, without touching process.env.
|
|
102
|
+
* Both `flair status` and `flair status deep` use this local install check.
|
|
103
103
|
*/
|
|
104
104
|
export function localOpsApiWarnings(baseUrl, dataDir = defaultDataDir()) {
|
|
105
105
|
const out = [];
|
|
@@ -113,6 +113,25 @@ export function localOpsApiWarnings(baseUrl, dataDir = defaultDataDir()) {
|
|
|
113
113
|
}
|
|
114
114
|
return out;
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Local agent-key mode warnings (flair#3077). Read-only, and judged for a
|
|
118
|
+
* loopback URL only: the keys directory belongs to this host.
|
|
119
|
+
*/
|
|
120
|
+
export function localKeyModeWarnings(baseUrl, locations = agentKeyLocations()) {
|
|
121
|
+
if (!isLocalhostUrl(baseUrl))
|
|
122
|
+
return [];
|
|
123
|
+
if (keyModesUnsupported())
|
|
124
|
+
return [{ level: "info", message: KEY_MODES_UNSUPPORTED_MESSAGE }];
|
|
125
|
+
const scan = scanAgentKeyModes(locations);
|
|
126
|
+
const warnings = scan.unreadable.map(({ dir, code }) => ({
|
|
127
|
+
level: "warn",
|
|
128
|
+
message: `agent key directory ${dir} could not be read (${code}) — key file modes not checked`,
|
|
129
|
+
}));
|
|
130
|
+
for (const finding of scan.findings) {
|
|
131
|
+
warnings.push({ level: "warn", message: formatKeyModeFinding(finding) });
|
|
132
|
+
}
|
|
133
|
+
return warnings;
|
|
134
|
+
}
|
|
116
135
|
function federationPeerCountParts(peers) {
|
|
117
136
|
const connected = Number(peers?.connected ?? 0);
|
|
118
137
|
const disconnected = Number(peers?.disconnected ?? 0);
|
|
@@ -315,7 +334,7 @@ export function register(program) {
|
|
|
315
334
|
// harper-config.yaml; the two commands must not disagree. A bare ops port
|
|
316
335
|
// is Harper's all-interfaces default, so reporting "all checks passing"
|
|
317
336
|
// while it is exposed is a lying green.
|
|
318
|
-
const localWarnings = localOpsApiWarnings(baseUrl);
|
|
337
|
+
const localWarnings = [...localOpsApiWarnings(baseUrl), ...localKeyModeWarnings(baseUrl)];
|
|
319
338
|
// When unreachable on a localhost URL, probe candidate ports to detect
|
|
320
339
|
// config-vs-daemon port drift. Surface the actually-listening
|
|
321
340
|
// port with a fix recipe — better UX than just "unreachable."
|
|
@@ -388,6 +407,8 @@ export function register(program) {
|
|
|
388
407
|
if (!healthy) {
|
|
389
408
|
console.log(`Flair v${__pkgVersion} — 🔴 unreachable`);
|
|
390
409
|
console.log(` URL: ${baseUrl}`);
|
|
410
|
+
for (const warning of localWarnings)
|
|
411
|
+
console.log(` ⚠ ${warning.message}`);
|
|
391
412
|
if (registryNotice.line)
|
|
392
413
|
console.log(` ${registryNotice.line}`);
|
|
393
414
|
if (registryNotice.error)
|
|
@@ -427,44 +448,41 @@ export function register(program) {
|
|
|
427
448
|
const pid = healthData?.pid ?? "";
|
|
428
449
|
const agents = healthData?.agents;
|
|
429
450
|
const memories = healthData?.memories;
|
|
430
|
-
const warnings = [
|
|
431
|
-
...localWarnings,
|
|
432
|
-
...(Array.isArray(healthData?.warnings) ? healthData.warnings : []),
|
|
433
|
-
];
|
|
451
|
+
const warnings = Array.isArray(healthData?.warnings) ? healthData.warnings : [];
|
|
434
452
|
// Scope warnings to the filtered agent if --agent is set
|
|
435
|
-
const scopedWarnings = opts.agent && healthData?.agents?.perAgent
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
const scopedWarnings = [...localWarnings, ...(opts.agent && healthData?.agents?.perAgent
|
|
454
|
+
? warnings.filter((w) => {
|
|
455
|
+
// Hash-fallback warnings contain agent-specific counts
|
|
456
|
+
if (w.message.includes("hash-fallback")) {
|
|
457
|
+
const match = w.message.match(/\b(\d+)\/(\d+) \((\d+)%\)/);
|
|
458
|
+
if (match) {
|
|
459
|
+
const hashCount = parseInt(match[1]);
|
|
460
|
+
const totalCount = parseInt(match[2]);
|
|
461
|
+
const agentRow = healthData.agents.perAgent.find((r) => r.id === opts.agent);
|
|
462
|
+
if (agentRow && agentRow.hashFallback === hashCount && agentRow.memoryCount === totalCount) {
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
465
|
+
return false;
|
|
446
466
|
}
|
|
447
|
-
return false;
|
|
448
467
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
: warnings;
|
|
468
|
+
// Mixed-model / outstanding stamp-migration warnings are fleet-wide; keep them
|
|
469
|
+
if (w.message.includes("multiple embedding models"))
|
|
470
|
+
return true;
|
|
471
|
+
if (w.message.includes("embedding-stamp") || w.message.includes("duplicate detection is inactive"))
|
|
472
|
+
return true;
|
|
473
|
+
// Federation warnings are fleet-wide; keep them
|
|
474
|
+
if (w.message.includes("federation"))
|
|
475
|
+
return true;
|
|
476
|
+
// REM warnings are fleet-wide; keep them
|
|
477
|
+
if (w.message.includes("REM") || w.message.includes("nightly"))
|
|
478
|
+
return true;
|
|
479
|
+
// Ops-API bind is a host fact, not per-agent; keep it
|
|
480
|
+
if (w.message.includes("Ops API bound"))
|
|
481
|
+
return true;
|
|
482
|
+
// Default: keep fleet-wide warnings
|
|
483
|
+
return !w.message.includes(opts.agent);
|
|
484
|
+
})
|
|
485
|
+
: warnings)];
|
|
468
486
|
const hasWarn = scopedWarnings.some((w) => w.level === "warn");
|
|
469
487
|
const headerIcon = hasWarn ? render.icons.warn : render.icons.ok;
|
|
470
488
|
const versionStr = render.wrap(render.c.bold, `Flair v${__pkgVersion}`);
|
|
@@ -496,7 +514,7 @@ export function register(program) {
|
|
|
496
514
|
console.log(`\n${render.wrap(render.c.bold, "Warnings")} ${render.wrap(render.c.dim, `(${scopedWarnings.length})`)}`);
|
|
497
515
|
for (const w of scopedWarnings) {
|
|
498
516
|
const icon = w.level === "warn" ? render.icons.warn : render.icons.info;
|
|
499
|
-
console.log(` ${icon} ${w.message}`);
|
|
517
|
+
console.log(` ${icon} ${escapeTerminalText(w.message)}`);
|
|
500
518
|
}
|
|
501
519
|
}
|
|
502
520
|
if (memories) {
|
|
@@ -510,7 +528,7 @@ export function register(program) {
|
|
|
510
528
|
.filter(([, n]) => n > 0)
|
|
511
529
|
.sort((a, b) => b[1] - a[1]);
|
|
512
530
|
if (entries.length > 0) {
|
|
513
|
-
const formatted = entries.map(([k, n]) => `${render.wrap(render.c.cyan, k)}:${n}`).join(render.wrap(render.c.dim, ", "));
|
|
531
|
+
const formatted = entries.map(([k, n]) => `${render.wrap(render.c.cyan, escapeTerminalText(k))}:${n}`).join(render.wrap(render.c.dim, ", "));
|
|
514
532
|
console.log(render.kv("Embeddings", formatted));
|
|
515
533
|
}
|
|
516
534
|
}
|
|
@@ -534,26 +552,33 @@ export function register(program) {
|
|
|
534
552
|
}
|
|
535
553
|
const bm25Line = formatBm25StatusLine(healthData?.bm25);
|
|
536
554
|
if (bm25Line)
|
|
537
|
-
console.log(render.kv("BM25 index", bm25Line));
|
|
555
|
+
console.log(render.kv("BM25 index", escapeTerminalText(bm25Line)));
|
|
538
556
|
if (agents) {
|
|
539
557
|
if (agents.count > 0) {
|
|
540
558
|
console.log(`\n${render.wrap(render.c.bold, "Agents")}`);
|
|
541
|
-
const nameStr = agents.names?.length > 0 ? ` ${render.wrap(render.c.dim, "—")} ${agents.names.join(render.wrap(render.c.dim, ", "))}` : "";
|
|
559
|
+
const nameStr = agents.names?.length > 0 ? ` ${render.wrap(render.c.dim, "—")} ${agents.names.map((n) => escapeTerminalText(n)).join(render.wrap(render.c.dim, ", "))}` : "";
|
|
542
560
|
console.log(render.kv("Total", `${render.wrap(render.c.bold, String(agents.count))}${nameStr}`));
|
|
543
561
|
if (Array.isArray(agents.perAgent) && agents.perAgent.length > 0) {
|
|
562
|
+
// When the Memory scan did not complete, every row's memory-derived
|
|
563
|
+
// value is null (unknown), never zero. The plain table displays
|
|
564
|
+
// memoryCount and lastWriteAt; the deep table displays those plus
|
|
565
|
+
// hashFallback and writes24h. usageCount is not displayed.
|
|
566
|
+
const idCell = (v) => escapeTerminalText(String(v ?? ""));
|
|
567
|
+
const countCell = (v) => (typeof v === "number" ? String(v) : "unknown");
|
|
568
|
+
const lastWriteCell = (v, row) => typeof row.memoryCount === "number" ? render.relativeTime(v) : "unknown";
|
|
544
569
|
const hasDeep = agents.perAgent.some((r) => typeof r.hashFallback === "number" || typeof r.writes24h === "number");
|
|
545
570
|
const cols = hasDeep
|
|
546
571
|
? [
|
|
547
|
-
{ label: "id", key: "id" },
|
|
548
|
-
{ label: "memories", key: "memoryCount", align: "right" },
|
|
549
|
-
{ label: "hash_fb", key: "hashFallback", align: "right", format: (v) => (typeof v === "number" ? String(v) : "—") },
|
|
550
|
-
{ label: "24h", key: "writes24h", align: "right", format: (v) => (typeof v === "number" ? String(v) : "—") },
|
|
551
|
-
{ label: "last_write", key: "lastWriteAt", format:
|
|
572
|
+
{ label: "id", key: "id", format: idCell },
|
|
573
|
+
{ label: "memories", key: "memoryCount", align: "right", format: countCell },
|
|
574
|
+
{ label: "hash_fb", key: "hashFallback", align: "right", format: (v, row) => (typeof v === "number" ? String(v) : typeof row.memoryCount === "number" ? "—" : "unknown") },
|
|
575
|
+
{ label: "24h", key: "writes24h", align: "right", format: (v, row) => (typeof v === "number" ? String(v) : typeof row.memoryCount === "number" ? "—" : "unknown") },
|
|
576
|
+
{ label: "last_write", key: "lastWriteAt", format: lastWriteCell },
|
|
552
577
|
]
|
|
553
578
|
: [
|
|
554
|
-
{ label: "id", key: "id" },
|
|
555
|
-
{ label: "memories", key: "memoryCount", align: "right" },
|
|
556
|
-
{ label: "last_write", key: "lastWriteAt", format:
|
|
579
|
+
{ label: "id", key: "id", format: idCell },
|
|
580
|
+
{ label: "memories", key: "memoryCount", align: "right", format: countCell },
|
|
581
|
+
{ label: "last_write", key: "lastWriteAt", format: lastWriteCell },
|
|
557
582
|
];
|
|
558
583
|
console.log(render.table(cols, agents.perAgent));
|
|
559
584
|
}
|
|
@@ -562,7 +587,7 @@ export function register(program) {
|
|
|
562
587
|
console.log(render.kv("Unregistered memory owners", render.wrap(render.c.dim, "unavailable — memory scan did not complete")));
|
|
563
588
|
}
|
|
564
589
|
else if (Array.isArray(agents.unregisteredMemoryAuthors) && agents.unregisteredMemoryAuthors.length > 0) {
|
|
565
|
-
const owners = agents.unregisteredMemoryAuthors.map((r) => `${r.id} (${r.memoryCount} ${r.memoryCount === 1 ? "memory" : "memories"})`);
|
|
590
|
+
const owners = agents.unregisteredMemoryAuthors.map((r) => `${escapeTerminalText(String(r.id ?? ""))} (${r.memoryCount} ${r.memoryCount === 1 ? "memory" : "memories"})`);
|
|
566
591
|
console.log(render.kv("Unregistered memory owners", owners.join(render.wrap(render.c.dim, ", "))));
|
|
567
592
|
}
|
|
568
593
|
}
|
|
@@ -575,7 +600,7 @@ export function register(program) {
|
|
|
575
600
|
const s = healthData.soul;
|
|
576
601
|
console.log(`\n${render.wrap(render.c.bold, "Soul")}`);
|
|
577
602
|
const entries = sortSoulKeyEntries(s.byKey ?? {});
|
|
578
|
-
const parts = entries.map(([k, n]) => `${render.wrap(render.c.cyan, k)}:${n}`);
|
|
603
|
+
const parts = entries.map(([k, n]) => `${render.wrap(render.c.cyan, escapeTerminalText(k))}:${n}`);
|
|
579
604
|
const suffix = parts.length > 0
|
|
580
605
|
? ` ${render.wrap(render.c.dim, "—")} ${parts.join(render.wrap(render.c.dim, " · "))}`
|
|
581
606
|
: "";
|
|
@@ -616,7 +641,7 @@ export function register(program) {
|
|
|
616
641
|
console.log(`\n${render.wrap(render.c.bold, "Federation")}`);
|
|
617
642
|
if (f.instance) {
|
|
618
643
|
const statusColor = f.instance.status === "active" ? render.c.green : render.c.yellow;
|
|
619
|
-
console.log(render.kv("Instance", `${f.instance.id} ${render.wrap(render.c.dim, "(")}${f.instance.role ?? "—"}${render.wrap(render.c.dim, ", ")}${render.wrap(statusColor, f.instance.status ?? "—")}${render.wrap(render.c.dim, ")")}`));
|
|
644
|
+
console.log(render.kv("Instance", `${escapeTerminalText(String(f.instance.id ?? ""))} ${render.wrap(render.c.dim, "(")}${escapeTerminalText(String(f.instance.role ?? "—"))}${render.wrap(render.c.dim, ", ")}${render.wrap(statusColor, escapeTerminalText(String(f.instance.status ?? "—")))}${render.wrap(render.c.dim, ")")}`));
|
|
620
645
|
}
|
|
621
646
|
if (f.peers) {
|
|
622
647
|
const parts = federationPeerCountParts(f.peers);
|
|
@@ -642,7 +667,7 @@ export function register(program) {
|
|
|
642
667
|
const b = healthData.bridges;
|
|
643
668
|
console.log(`\n${render.wrap(render.c.bold, "Bridges")}`);
|
|
644
669
|
if (Array.isArray(b.installed) && b.installed.length > 0)
|
|
645
|
-
console.log(render.kv("Installed", b.installed.join(render.wrap(render.c.dim, ", "))));
|
|
670
|
+
console.log(render.kv("Installed", b.installed.map((n) => escapeTerminalText(n)).join(render.wrap(render.c.dim, ", "))));
|
|
646
671
|
if (b.lastImport)
|
|
647
672
|
console.log(render.kv("Last import", render.relativeTime(b.lastImport)));
|
|
648
673
|
if (b.lastExport)
|
|
@@ -654,8 +679,8 @@ export function register(program) {
|
|
|
654
679
|
if (healthData?.disk) {
|
|
655
680
|
const d = healthData.disk;
|
|
656
681
|
console.log(`\n${render.wrap(render.c.bold, "Disk")}`);
|
|
657
|
-
console.log(render.kv("Data", `${render.wrap(render.c.dim, d.dataDir)} ${render.wrap(render.c.dim, "—")} ${render.wrap(render.c.bold, render.humanBytes(d.dataBytes ?? 0))}`));
|
|
658
|
-
console.log(render.kv("Snapshots", `${render.wrap(render.c.dim, d.snapshotDir)} ${render.wrap(render.c.dim, "—")} ${render.wrap(render.c.bold, render.humanBytes(d.snapshotBytes ?? 0))}`));
|
|
682
|
+
console.log(render.kv("Data", `${render.wrap(render.c.dim, escapeTerminalText(String(d.dataDir ?? "")))} ${render.wrap(render.c.dim, "—")} ${render.wrap(render.c.bold, render.humanBytes(d.dataBytes ?? 0))}`));
|
|
683
|
+
console.log(render.kv("Snapshots", `${render.wrap(render.c.dim, escapeTerminalText(String(d.snapshotDir ?? "")))} ${render.wrap(render.c.dim, "—")} ${render.wrap(render.c.bold, render.humanBytes(d.snapshotBytes ?? 0))}`));
|
|
659
684
|
}
|
|
660
685
|
console.log("");
|
|
661
686
|
if (scopedWarnings.length > 0) {
|
|
@@ -698,7 +723,7 @@ export function register(program) {
|
|
|
698
723
|
: render.wrap(render.c.dim, "unknown");
|
|
699
724
|
console.log(render.kv("Nightly", nightlyTxt, 18));
|
|
700
725
|
if (r.lastNightlyAt) {
|
|
701
|
-
console.log(render.kv("Last nightly", `${render.relativeTime(r.lastNightlyAt)} ${render.wrap(render.c.dim, `(${r.lastNightlyAt})`)}`, 18));
|
|
726
|
+
console.log(render.kv("Last nightly", `${render.relativeTime(r.lastNightlyAt)} ${render.wrap(render.c.dim, `(${escapeTerminalText(String(r.lastNightlyAt))})`)}`, 18));
|
|
702
727
|
}
|
|
703
728
|
const ds = distillationStaleness(r);
|
|
704
729
|
if (typeof r.pendingCandidates === "number") {
|
|
@@ -738,7 +763,7 @@ export function register(program) {
|
|
|
738
763
|
console.log(render.wrap(render.c.bold, "Federation"));
|
|
739
764
|
if (f.instance) {
|
|
740
765
|
const statusColor = f.instance.status === "active" ? render.c.green : render.c.yellow;
|
|
741
|
-
console.log(render.kv("Instance", `${f.instance.id} ${render.wrap(render.c.dim, "(")}${f.instance.role ?? "—"}${render.wrap(render.c.dim, ", ")}${render.wrap(statusColor, f.instance.status ?? "—")}${render.wrap(render.c.dim, ")")}`));
|
|
766
|
+
console.log(render.kv("Instance", `${escapeTerminalText(String(f.instance.id ?? ""))} ${render.wrap(render.c.dim, "(")}${escapeTerminalText(String(f.instance.role ?? "—"))}${render.wrap(render.c.dim, ", ")}${render.wrap(statusColor, escapeTerminalText(String(f.instance.status ?? "—")))}${render.wrap(render.c.dim, ")")}`));
|
|
742
767
|
}
|
|
743
768
|
else {
|
|
744
769
|
console.log(render.kv("Instance", render.wrap(render.c.dim, "—")));
|
|
@@ -753,15 +778,15 @@ export function register(program) {
|
|
|
753
778
|
if (Array.isArray(f.peerList) && f.peerList.length > 0) {
|
|
754
779
|
console.log();
|
|
755
780
|
const cols = [
|
|
756
|
-
{ label: "peer", key: "id" },
|
|
757
|
-
{ label: "role", key: "role", format: (v) => String(v ?? "—") },
|
|
781
|
+
{ label: "peer", key: "id", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
782
|
+
{ label: "role", key: "role", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
758
783
|
{
|
|
759
784
|
label: "status",
|
|
760
785
|
key: "status",
|
|
761
786
|
format: (v) => {
|
|
762
787
|
const s = String(v ?? "—");
|
|
763
788
|
const color = s === "paired" || s === "connected" ? render.c.green : s === "revoked" ? render.c.red : render.c.yellow;
|
|
764
|
-
return render.wrap(color, s);
|
|
789
|
+
return render.wrap(color, escapeTerminalText(s));
|
|
765
790
|
},
|
|
766
791
|
},
|
|
767
792
|
{
|
|
@@ -770,7 +795,7 @@ export function register(program) {
|
|
|
770
795
|
format: (v) => {
|
|
771
796
|
const s = String(v ?? "—");
|
|
772
797
|
const color = s === "connected" ? render.c.green : s === "disconnected" ? render.c.yellow : s === "revoked" ? render.c.red : render.c.dim;
|
|
773
|
-
return render.wrap(color, s);
|
|
798
|
+
return render.wrap(color, escapeTerminalText(s));
|
|
774
799
|
},
|
|
775
800
|
},
|
|
776
801
|
{
|
|
@@ -780,7 +805,7 @@ export function register(program) {
|
|
|
780
805
|
const iso = v;
|
|
781
806
|
if (!iso)
|
|
782
807
|
return render.wrap(render.c.dim, "never");
|
|
783
|
-
return `${render.relativeTime(iso)} ${render.wrap(render.c.dim, `(${iso})`)}`;
|
|
808
|
+
return `${render.relativeTime(iso)} ${render.wrap(render.c.dim, `(${escapeTerminalText(String(iso))})`)}`;
|
|
784
809
|
},
|
|
785
810
|
},
|
|
786
811
|
];
|
|
@@ -817,19 +842,19 @@ export function register(program) {
|
|
|
817
842
|
if (Array.isArray(o?.clientList) && o.clientList.length > 0) {
|
|
818
843
|
console.log(`\n ${render.wrap(render.c.dim, "Clients")}`);
|
|
819
844
|
const cols = [
|
|
820
|
-
{ label: "id", key: "id" },
|
|
821
|
-
{ label: "name", key: "name", format: (v) => String(v ?? "—") },
|
|
822
|
-
{ label: "registered_by", key: "registeredBy", format: (v) => String(v ?? "—") },
|
|
823
|
-
{ label: "created_at", key: "createdAt", format: (v) => String(v ?? "—") },
|
|
845
|
+
{ label: "id", key: "id", format: (v) => escapeTerminalText(String(v ?? "")) },
|
|
846
|
+
{ label: "name", key: "name", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
847
|
+
{ label: "registered_by", key: "registeredBy", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
848
|
+
{ label: "created_at", key: "createdAt", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
824
849
|
];
|
|
825
850
|
console.log(render.table(cols, o.clientList));
|
|
826
851
|
}
|
|
827
852
|
if (Array.isArray(o?.idpList) && o.idpList.length > 0) {
|
|
828
853
|
console.log(`\n ${render.wrap(render.c.dim, "IdPs")}`);
|
|
829
854
|
const cols = [
|
|
830
|
-
{ label: "id", key: "id" },
|
|
831
|
-
{ label: "name", key: "name", format: (v) => String(v ?? "—") },
|
|
832
|
-
{ label: "issuer", key: "issuer", format: (v) => String(v ?? "—") },
|
|
855
|
+
{ label: "id", key: "id", format: (v) => escapeTerminalText(String(v ?? "")) },
|
|
856
|
+
{ label: "name", key: "name", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
857
|
+
{ label: "issuer", key: "issuer", format: (v) => escapeTerminalText(String(v ?? "—")) },
|
|
833
858
|
];
|
|
834
859
|
console.log(render.table(cols, o.idpList));
|
|
835
860
|
}
|
|
@@ -865,17 +890,11 @@ export function register(program) {
|
|
|
865
890
|
if (b.lastExport)
|
|
866
891
|
console.log(render.kv("Last export", render.relativeTime(b.lastExport)));
|
|
867
892
|
});
|
|
868
|
-
//
|
|
869
|
-
//
|
|
870
|
-
// Deeper observability than the default `flair status` summary — full
|
|
871
|
-
// per-section detail with no condensing. Optional --bootstrap measures
|
|
872
|
-
// cold-start context bytes per agent (slow; calls /MemoryBootstrap once per
|
|
873
|
-
// agent, admin-auth required).
|
|
893
|
+
// `flair status deep` adds verbose sections. Its optional `--bootstrap` posts to
|
|
894
|
+
// `/BootstrapMemories` for each selected agent to measure context size.
|
|
874
895
|
//
|
|
875
|
-
//
|
|
876
|
-
//
|
|
877
|
-
// pattern" — questions the default `flair status` summarizes but doesn't
|
|
878
|
-
// surface in full. Agents should be able to self-audit via this too.
|
|
896
|
+
// Plain status summarizes instance health; deep status shows additional
|
|
897
|
+
// per-section details and optional bootstrap measurements.
|
|
879
898
|
statusCmd
|
|
880
899
|
.command("deep")
|
|
881
900
|
.description("Verbose status + optional bootstrap context size per agent (ops-yph)")
|
|
@@ -884,16 +903,17 @@ export function register(program) {
|
|
|
884
903
|
.action(async function () {
|
|
885
904
|
const opts = this.optsWithGlobals();
|
|
886
905
|
const { healthy, baseUrl, healthData } = await fetchHealthDetail(opts);
|
|
887
|
-
//
|
|
888
|
-
|
|
889
|
-
const localWarnings = localOpsApiWarnings(baseUrl);
|
|
906
|
+
// `flair status deep` reports the same local install warnings as plain status.
|
|
907
|
+
const localWarnings = [...localOpsApiWarnings(baseUrl), ...localKeyModeWarnings(baseUrl)];
|
|
890
908
|
if (!healthy) {
|
|
891
909
|
if (opts.json) {
|
|
892
|
-
console.log(JSON.stringify({ healthy: false, url: baseUrl, error: "unreachable" }, null, 2));
|
|
910
|
+
console.log(JSON.stringify({ healthy: false, url: baseUrl, error: "unreachable", warnings: localWarnings }, null, 2));
|
|
893
911
|
}
|
|
894
912
|
else {
|
|
895
913
|
console.log(`Flair v${__pkgVersion} — 🔴 unreachable`);
|
|
896
914
|
console.log(` URL: ${baseUrl}`);
|
|
915
|
+
for (const warning of localWarnings)
|
|
916
|
+
console.log(` ⚠ ${warning.message}`);
|
|
897
917
|
console.log(`\n Run: flair start or flair doctor`);
|
|
898
918
|
}
|
|
899
919
|
process.exit(1);
|
|
@@ -985,7 +1005,7 @@ export function register(program) {
|
|
|
985
1005
|
.sort((a, b) => b[1] - a[1]);
|
|
986
1006
|
for (const [k, n] of entries) {
|
|
987
1007
|
const pct = ((n / memories.total) * 100).toFixed(1);
|
|
988
|
-
console.log(` ${k.padEnd(28)} ${String(n).padStart(6)} (${pct}%)`);
|
|
1008
|
+
console.log(` ${escapeTerminalText(k).padEnd(28)} ${String(n).padStart(6)} (${pct}%)`);
|
|
989
1009
|
}
|
|
990
1010
|
}
|
|
991
1011
|
if (memories.byDurability) {
|
|
@@ -995,26 +1015,29 @@ export function register(program) {
|
|
|
995
1015
|
console.log(`Archived: ${memories.archived ?? 0}`);
|
|
996
1016
|
console.log(`Expired: ${memories.expired ?? 0}`);
|
|
997
1017
|
if (healthData?.lastWrite)
|
|
998
|
-
console.log(`Last write: ${relativeTime(healthData.lastWrite)} (${healthData.lastWrite})`);
|
|
1018
|
+
console.log(`Last write: ${relativeTime(healthData.lastWrite)} (${escapeTerminalText(String(healthData.lastWrite))})`);
|
|
999
1019
|
}
|
|
1000
1020
|
const bm25DeepLine = formatBm25StatusLine(healthData?.bm25);
|
|
1001
1021
|
if (bm25DeepLine)
|
|
1002
|
-
console.log(`BM25 index: ${bm25DeepLine}`);
|
|
1022
|
+
console.log(`BM25 index: ${escapeTerminalText(bm25DeepLine)}`);
|
|
1003
1023
|
const agents = healthData?.agents;
|
|
1004
1024
|
if (agents) {
|
|
1005
1025
|
if (agents.count > 0) {
|
|
1006
1026
|
console.log("\n═══ Agents ═══════════════════════════════════════");
|
|
1007
1027
|
console.log(`Total: ${agents.count}`);
|
|
1008
1028
|
if (Array.isArray(agents.names) && agents.names.length > 0) {
|
|
1009
|
-
console.log(`Names: ${agents.names.join(", ")}`);
|
|
1029
|
+
console.log(`Names: ${agents.names.map((n) => escapeTerminalText(n)).join(", ")}`);
|
|
1010
1030
|
}
|
|
1011
1031
|
if (Array.isArray(agents.perAgent) && agents.perAgent.length > 0) {
|
|
1012
|
-
const idW = Math.max(2, ...agents.perAgent.map((r) => (r.id ?? "").length));
|
|
1032
|
+
const idW = Math.max(2, ...agents.perAgent.map((r) => escapeTerminalText(String(r.id ?? "")).length));
|
|
1013
1033
|
console.log(`\n ${"id".padEnd(idW)} memories hash_fb 24h last_write`);
|
|
1014
1034
|
for (const r of agents.perAgent) {
|
|
1015
|
-
const
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1035
|
+
const known = typeof r.memoryCount === "number";
|
|
1036
|
+
const fb = !known ? "unknown" : typeof r.hashFallback === "number" ? String(r.hashFallback) : "—";
|
|
1037
|
+
const w24 = !known ? "unknown" : typeof r.writes24h === "number" ? String(r.writes24h) : "—";
|
|
1038
|
+
const mems = known ? String(r.memoryCount).padStart(8) : "unknown".padStart(8);
|
|
1039
|
+
const lastWrite = known ? relativeTime(r.lastWriteAt) : "unknown";
|
|
1040
|
+
console.log(` ${escapeTerminalText(String(r.id ?? "")).padEnd(idW)} ${mems} ${fb.padStart(7)} ${w24.padStart(3)} ${lastWrite}`);
|
|
1018
1041
|
}
|
|
1019
1042
|
}
|
|
1020
1043
|
}
|
|
@@ -1022,7 +1045,7 @@ export function register(program) {
|
|
|
1022
1045
|
console.log("Unregistered memory owners: unavailable — memory scan did not complete");
|
|
1023
1046
|
}
|
|
1024
1047
|
else if (Array.isArray(agents.unregisteredMemoryAuthors) && agents.unregisteredMemoryAuthors.length > 0) {
|
|
1025
|
-
const owners = agents.unregisteredMemoryAuthors.map((r) => `${r.id} (${r.memoryCount} ${r.memoryCount === 1 ? "memory" : "memories"})`);
|
|
1048
|
+
const owners = agents.unregisteredMemoryAuthors.map((r) => `${escapeTerminalText(String(r.id ?? ""))} (${r.memoryCount} ${r.memoryCount === 1 ? "memory" : "memories"})`);
|
|
1026
1049
|
console.log(`Unregistered memory owners: ${owners.join(", ")}`);
|
|
1027
1050
|
}
|
|
1028
1051
|
}
|
|
@@ -1043,8 +1066,8 @@ export function register(program) {
|
|
|
1043
1066
|
const bytesStr = info.error ? "error" : humanBytes(info.bytes);
|
|
1044
1067
|
const tok = info.tokenEstimate != null ? String(info.tokenEstimate) : "—";
|
|
1045
1068
|
const mems = info.memoriesIncluded != null ? String(info.memoriesIncluded) : "—";
|
|
1046
|
-
const status = info.error ? info.error.slice(0, 40) : "ok";
|
|
1047
|
-
console.log(` ${agentId.padEnd(idW)} ${bytesStr.padStart(9)} ${tok.padStart(7)} ${mems.padStart(4)} ${status}`);
|
|
1069
|
+
const status = info.error ? escapeTerminalText(info.error.slice(0, 40)) : "ok";
|
|
1070
|
+
console.log(` ${escapeTerminalText(agentId).padEnd(idW)} ${bytesStr.padStart(9)} ${tok.padStart(7)} ${mems.padStart(4)} ${status}`);
|
|
1048
1071
|
}
|
|
1049
1072
|
}
|
|
1050
1073
|
if (healthData?.relationships) {
|
|
@@ -1058,7 +1081,7 @@ export function register(program) {
|
|
|
1058
1081
|
console.log(`Total: ${s.total} entries`);
|
|
1059
1082
|
const entries = sortSoulKeyEntries(s.byKey ?? {});
|
|
1060
1083
|
if (entries.length > 0) {
|
|
1061
|
-
console.log(`Keys: ${entries.map(([k, n]) => `${n} ${k}`).join(" / ")}`);
|
|
1084
|
+
console.log(`Keys: ${entries.map(([k, n]) => `${n} ${escapeTerminalText(k)}`).join(" / ")}`);
|
|
1062
1085
|
}
|
|
1063
1086
|
}
|
|
1064
1087
|
else if (typeof healthData?.soulEntries === "number" && healthData.soulEntries > 0) {
|
|
@@ -1074,12 +1097,12 @@ export function register(program) {
|
|
|
1074
1097
|
const nightly = r.nightlyEnabled === true ? "enabled" : r.nightlyEnabled === false ? "disabled" : "unknown";
|
|
1075
1098
|
console.log(`Nightly: ${nightly}`);
|
|
1076
1099
|
if (r.lastNightlyAt)
|
|
1077
|
-
console.log(`Last nightly: ${relativeTime(r.lastNightlyAt)} (${r.lastNightlyAt})`);
|
|
1100
|
+
console.log(`Last nightly: ${relativeTime(r.lastNightlyAt)} (${escapeTerminalText(String(r.lastNightlyAt))})`);
|
|
1078
1101
|
if (typeof r.pendingCandidates === "number")
|
|
1079
1102
|
console.log(`Pending candidates: ${r.pendingCandidates}`);
|
|
1080
1103
|
const ds = distillationStaleness(r);
|
|
1081
1104
|
if (typeof r.pendingCandidates === "number" || ds.lastDistilledAt || ds.stale) {
|
|
1082
|
-
const base = ds.lastDistilledAt ? `${relativeTime(ds.lastDistilledAt)} (${ds.lastDistilledAt})` : "not observed";
|
|
1105
|
+
const base = ds.lastDistilledAt ? `${relativeTime(ds.lastDistilledAt)} (${escapeTerminalText(ds.lastDistilledAt)})` : "not observed";
|
|
1083
1106
|
console.log(`Last distilled: ${base} (server-local log tail)${ds.stale ? DISTILL_STALE_HINT : ""}`);
|
|
1084
1107
|
}
|
|
1085
1108
|
}
|
|
@@ -1087,7 +1110,7 @@ export function register(program) {
|
|
|
1087
1110
|
const f = healthData.federation;
|
|
1088
1111
|
console.log("\n═══ Federation ═══════════════════════════════════");
|
|
1089
1112
|
if (f.instance)
|
|
1090
|
-
console.log(`Instance: ${f.instance.id} (${f.instance.role ?? "—"}, ${f.instance.status ?? "—"})`);
|
|
1113
|
+
console.log(`Instance: ${escapeTerminalText(String(f.instance.id ?? ""))} (${escapeTerminalText(String(f.instance.role ?? "—"))}, ${escapeTerminalText(String(f.instance.status ?? "—"))})`);
|
|
1091
1114
|
if (f.peers) {
|
|
1092
1115
|
const unknown = Number(f.peers.unknown ?? 0);
|
|
1093
1116
|
const unknownBit = unknown > 0 ? `, ${unknown} unknown` : "";
|
|
@@ -1096,10 +1119,10 @@ export function register(program) {
|
|
|
1096
1119
|
if (typeof f.pendingTokens === "number" && f.pendingTokens > 0)
|
|
1097
1120
|
console.log(`Pairing: ${f.pendingTokens} unconsumed token(s)`);
|
|
1098
1121
|
if (Array.isArray(f.peerList) && f.peerList.length > 0) {
|
|
1099
|
-
const idW = Math.max(4, ...f.peerList.map((p) => (p.id ?? "").length));
|
|
1122
|
+
const idW = Math.max(4, ...f.peerList.map((p) => escapeTerminalText(String(p.id ?? "")).length));
|
|
1100
1123
|
console.log(`\n ${"peer".padEnd(idW)} ${"role".padEnd(5)} ${"status".padEnd(13)} ${"liveness".padEnd(13)} last_sync`);
|
|
1101
1124
|
for (const p of f.peerList) {
|
|
1102
|
-
console.log(` ${(p.id ?? "").padEnd(idW)} ${(p.role ?? "—").padEnd(5)} ${(p.status ?? "—").padEnd(13)} ${(p.liveness ?? "—").padEnd(13)} ${p.lastSyncAt ? `${relativeTime(p.lastSyncAt)} (${p.lastSyncAt})` : "never"}`);
|
|
1125
|
+
console.log(` ${escapeTerminalText(String(p.id ?? "")).padEnd(idW)} ${escapeTerminalText(String(p.role ?? "—")).padEnd(5)} ${escapeTerminalText(String(p.status ?? "—")).padEnd(13)} ${escapeTerminalText(String(p.liveness ?? "—")).padEnd(13)} ${p.lastSyncAt ? `${relativeTime(p.lastSyncAt)} (${escapeTerminalText(String(p.lastSyncAt))})` : "never"}`);
|
|
1103
1126
|
}
|
|
1104
1127
|
}
|
|
1105
1128
|
}
|
|
@@ -1116,7 +1139,7 @@ export function register(program) {
|
|
|
1116
1139
|
if (Array.isArray(o.clientList) && o.clientList.length > 0) {
|
|
1117
1140
|
console.log(`\n Clients:`);
|
|
1118
1141
|
for (const c of o.clientList) {
|
|
1119
|
-
console.log(` ${c.id} ${c.name ?? "—"} ${c.registeredBy ?? "—"} ${c.createdAt ?? "—"}`);
|
|
1142
|
+
console.log(` ${escapeTerminalText(String(c.id ?? ""))} ${escapeTerminalText(String(c.name ?? "—"))} ${escapeTerminalText(String(c.registeredBy ?? "—"))} ${escapeTerminalText(String(c.createdAt ?? "—"))}`);
|
|
1120
1143
|
}
|
|
1121
1144
|
}
|
|
1122
1145
|
}
|
|
@@ -1124,7 +1147,7 @@ export function register(program) {
|
|
|
1124
1147
|
const b = healthData.bridges;
|
|
1125
1148
|
console.log("\n═══ Bridges ══════════════════════════════════════");
|
|
1126
1149
|
if (Array.isArray(b.installed) && b.installed.length > 0)
|
|
1127
|
-
console.log(`Installed: ${b.installed.join(", ")}`);
|
|
1150
|
+
console.log(`Installed: ${b.installed.map((n) => escapeTerminalText(n)).join(", ")}`);
|
|
1128
1151
|
if (b.lastImport)
|
|
1129
1152
|
console.log(`Last import: ${relativeTime(b.lastImport)}`);
|
|
1130
1153
|
if (b.lastExport)
|
|
@@ -1133,8 +1156,8 @@ export function register(program) {
|
|
|
1133
1156
|
if (healthData?.disk) {
|
|
1134
1157
|
const d = healthData.disk;
|
|
1135
1158
|
console.log("\n═══ Disk ═════════════════════════════════════════");
|
|
1136
|
-
console.log(`Data: ${d.dataDir} — ${humanBytes(d.dataBytes ?? 0)}`);
|
|
1137
|
-
console.log(`Snapshots: ${d.snapshotDir} — ${humanBytes(d.snapshotBytes ?? 0)}`);
|
|
1159
|
+
console.log(`Data: ${escapeTerminalText(String(d.dataDir ?? ""))} — ${humanBytes(d.dataBytes ?? 0)}`);
|
|
1160
|
+
console.log(`Snapshots: ${escapeTerminalText(String(d.snapshotDir ?? ""))} — ${humanBytes(d.snapshotBytes ?? 0)}`);
|
|
1138
1161
|
console.log(`Total: ${humanBytes((d.dataBytes ?? 0) + (d.snapshotBytes ?? 0))}`);
|
|
1139
1162
|
}
|
|
1140
1163
|
const warnings = [
|
|
@@ -1144,7 +1167,7 @@ export function register(program) {
|
|
|
1144
1167
|
if (warnings.length > 0) {
|
|
1145
1168
|
console.log("\n═══ Warnings ═════════════════════════════════════");
|
|
1146
1169
|
for (const w of warnings)
|
|
1147
|
-
console.log(` ${w.level === "warn" ? "⚠" : "ℹ"} ${w.message}`);
|
|
1170
|
+
console.log(` ${w.level === "warn" ? "⚠" : "ℹ"} ${escapeTerminalText(w.message)}`);
|
|
1148
1171
|
}
|
|
1149
1172
|
else {
|
|
1150
1173
|
console.log("\n✅ no warnings");
|
package/dist/doctor-client.js
CHANGED
|
@@ -33,6 +33,8 @@ import { decidePinWrite } from "./lib/pin-write-guard.js";
|
|
|
33
33
|
import { withConfigCriticalSection } from "./lib/config-critical-section.js";
|
|
34
34
|
import { backupBytesTo, encodeConfig, parseSettingsBytes, } from "./lib/settings-bytes.js";
|
|
35
35
|
import { decodeWiringSpec, decodeWiringSpecs, isComparableWiringPin, wiringPinString, } from "./lib/wiring-spec.js";
|
|
36
|
+
import { isNodeKeyId, partitionKeyIds } from "./lib/key-dir.js";
|
|
37
|
+
export { isNodeKeyId, partitionKeyIds };
|
|
36
38
|
// The exact substring `flair init` writes into CLAUDE.md (src/cli.ts, the
|
|
37
39
|
// `init` action) and that the doctor check + fix both key off of.
|
|
38
40
|
export const CLAUDE_MD_BOOTSTRAP_MARKER = "mcp__flair__bootstrap";
|
|
@@ -2122,29 +2124,6 @@ export function orphanInstanceSeedAdvisory(input) {
|
|
|
2122
2124
|
return null;
|
|
2123
2125
|
return `${candidates} orphan candidate(s) in ${keysDir}, absent from the Instance and Agent tables on ${baseUrl} (HTTP/ops Instance id matched); ownership cannot be proven; not removed (see #2200)`;
|
|
2124
2126
|
}
|
|
2125
|
-
/** Node-shaped file ids. */
|
|
2126
|
-
const NODE_KEY_ID_RE = /^flair_[0-9a-f]{8}$/;
|
|
2127
|
-
/** Match node-shaped ids without a sibling .pub; file type is unproven. */
|
|
2128
|
-
export function isNodeKeyId(id, keysDir) {
|
|
2129
|
-
if (!NODE_KEY_ID_RE.test(id))
|
|
2130
|
-
return false;
|
|
2131
|
-
return !existsSync(join(keysDir, `${id}.pub`));
|
|
2132
|
-
}
|
|
2133
|
-
/**
|
|
2134
|
-
* Partition `.key`-derived ids into agent signing keys and node-scoped
|
|
2135
|
-
* federation keys (see isNodeKeyId). Node keys must never feed agent handling —
|
|
2136
|
-
* Ed25519 parsing, registration checks, or connector-identity inference
|
|
2137
|
-
* (flair#1193) — so callers keep only `agentKeyIds` for those paths and report
|
|
2138
|
-
* `nodeKeyIds` informatively.
|
|
2139
|
-
*/
|
|
2140
|
-
export function partitionKeyIds(ids, keysDir) {
|
|
2141
|
-
const agentKeyIds = [];
|
|
2142
|
-
const nodeKeyIds = [];
|
|
2143
|
-
for (const id of ids) {
|
|
2144
|
-
(isNodeKeyId(id, keysDir) ? nodeKeyIds : agentKeyIds).push(id);
|
|
2145
|
-
}
|
|
2146
|
-
return { agentKeyIds, nodeKeyIds };
|
|
2147
|
-
}
|
|
2148
2127
|
/**
|
|
2149
2128
|
* Resolve the agent id `doctor --fix` should wire a connector as, or undefined
|
|
2150
2129
|
* when none can be safely determined. A node-scoped federation id is NEVER
|