@tpsdev-ai/flair 0.62.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.
Files changed (257) hide show
  1. package/README.md +14 -13
  2. package/SECURITY.md +73 -43
  3. package/config.yaml +11 -11
  4. package/dist/bridges/runtime/execute.js +1 -0
  5. package/dist/bridges/runtime/import-runner.js +4 -0
  6. package/dist/bridges/types.js +1 -0
  7. package/dist/build-info.json +3 -3
  8. package/dist/cli.js +309 -205
  9. package/dist/commands/agent.js +325 -137
  10. package/dist/commands/attention.js +2 -0
  11. package/dist/commands/backup-approval.js +218 -0
  12. package/dist/commands/backup.js +37 -33
  13. package/dist/commands/bootstrap.js +5 -1
  14. package/dist/commands/bridge.js +10 -0
  15. package/dist/commands/deploy.js +37 -7
  16. package/dist/commands/doctor.js +206 -42
  17. package/dist/commands/export.js +144 -15
  18. package/dist/commands/federation.js +653 -68
  19. package/dist/commands/grant.js +5 -6
  20. package/dist/commands/help.js +25 -0
  21. package/dist/commands/idp.js +14 -19
  22. package/dist/commands/import.js +167 -34
  23. package/dist/commands/init.js +380 -164
  24. package/dist/commands/integrity.js +5 -6
  25. package/dist/commands/keys.js +12 -8
  26. package/dist/commands/mcp.js +157 -79
  27. package/dist/commands/memory.js +38 -17
  28. package/dist/commands/migrate-harness-memory.js +9 -3
  29. package/dist/commands/orgevent.js +5 -10
  30. package/dist/commands/principal.js +32 -39
  31. package/dist/commands/quality.js +26 -3
  32. package/dist/commands/reembed.js +468 -111
  33. package/dist/commands/rem.js +484 -65
  34. package/dist/commands/restore.js +352 -44
  35. package/dist/commands/search.js +2 -0
  36. package/dist/commands/service.js +109 -2
  37. package/dist/commands/soul.js +0 -6
  38. package/dist/commands/status.js +165 -124
  39. package/dist/commands/test.js +4 -1
  40. package/dist/commands/upgrade.js +53 -22
  41. package/dist/commands/workspace.js +7 -8
  42. package/dist/deploy.js +59 -3
  43. package/dist/doctor-client.js +9 -25
  44. package/dist/fabric-upgrade.js +12 -2
  45. package/dist/federation/presence-send.js +139 -0
  46. package/dist/federation/scheduler.js +148 -12
  47. package/dist/federation-verify.js +269 -177
  48. package/dist/install/clients.js +171 -35
  49. package/dist/keystore.js +77 -10
  50. package/dist/lib/agent-id-rule.js +44 -2
  51. package/dist/lib/agent-key-file.js +509 -0
  52. package/dist/lib/agent-rotation-lock.js +249 -0
  53. package/dist/lib/atomic-write.js +3 -3
  54. package/dist/lib/auth-resolve.js +1040 -64
  55. package/dist/lib/backup-approval-store.js +612 -0
  56. package/dist/lib/backup-artifact.js +343 -0
  57. package/dist/lib/config-critical-section.js +212 -25
  58. package/dist/lib/connect-phase.js +33 -0
  59. package/dist/lib/daemon-liveness.js +2 -1
  60. package/dist/lib/federation-pair-access.js +4 -0
  61. package/dist/lib/federation-retry-queue.js +283 -0
  62. package/dist/lib/federation-retry-row.js +101 -0
  63. package/dist/lib/instruction-event-contract.js +17 -0
  64. package/dist/lib/instruction-event-doctor.js +102 -0
  65. package/dist/lib/key-dir.js +203 -0
  66. package/dist/lib/launchd-management.js +21 -6
  67. package/dist/lib/local-instance-pair.js +8 -1
  68. package/dist/lib/mcp-enable.js +14 -15
  69. package/dist/lib/memory-attributes.js +2 -0
  70. package/dist/lib/memory-provider-timeout.js +33 -0
  71. package/dist/lib/mqtt-config.js +132 -0
  72. package/dist/lib/mqtt-listener-doctor.js +104 -0
  73. package/dist/lib/node-alias-path.js +50 -2
  74. package/dist/lib/open-live-row.js +20 -0
  75. package/dist/lib/ops-url.js +52 -0
  76. package/dist/lib/promotion-content-hash.js +20 -0
  77. package/dist/lib/remote-admin-pass.js +157 -0
  78. package/dist/lib/restore-archive.js +760 -0
  79. package/dist/lib/restore-verify.js +1 -1
  80. package/dist/lib/scheduler-platform.js +13 -0
  81. package/dist/lib/service-repoint.js +13 -4
  82. package/dist/lib/skill-assignment-preflight.js +159 -0
  83. package/dist/lib/skill-seed.js +125 -10
  84. package/dist/lib/skill-tombstone-doctor.js +133 -0
  85. package/dist/lib/soul-scope-fields.js +26 -0
  86. package/dist/lib/terminal-text.js +32 -0
  87. package/dist/lib/uninstall-purge.js +266 -11
  88. package/dist/lib/upgrade-prior-liveness.js +2 -1
  89. package/dist/mcp-client-assertion.js +7 -14
  90. package/dist/memory-id-checkpoint.js +28 -7
  91. package/dist/mqtt-off-deploy.js +550 -0
  92. package/dist/rem/promote-policy.js +3 -3
  93. package/dist/rem/restore.js +302 -26
  94. package/dist/rem/runner.js +220 -58
  95. package/dist/rem/scheduler.js +21 -4
  96. package/dist/resources/A2AAdapter.js +131 -178
  97. package/dist/resources/AdminMemory.js +2 -0
  98. package/dist/resources/AdminMemoryCandidates.js +116 -0
  99. package/dist/resources/Agent.js +155 -45
  100. package/dist/resources/AgentCard.js +4 -0
  101. package/dist/resources/AgentKeyRegister.js +56 -22
  102. package/dist/resources/AgentReadPosition.js +7 -0
  103. package/dist/resources/AgentSeed.js +232 -107
  104. package/dist/resources/AutoPromoteCandidates.js +413 -84
  105. package/dist/resources/Credential.js +6 -8
  106. package/dist/resources/Federation.js +219 -57
  107. package/dist/resources/FederationRetry.js +4 -4
  108. package/dist/resources/InstructionVersion.js +1 -1
  109. package/dist/resources/MCPClientMetadata.js +6 -3
  110. package/dist/resources/Memory.js +1348 -271
  111. package/dist/resources/MemoryArchive.js +149 -64
  112. package/dist/resources/MemoryBootstrap.js +12 -22
  113. package/dist/resources/MemoryCandidate.js +16 -2
  114. package/dist/resources/MemoryConsolidate.js +2 -2
  115. package/dist/resources/MemoryFeed.js +360 -147
  116. package/dist/resources/MemoryMaintenance.js +290 -72
  117. package/dist/resources/MemoryPurge.js +138 -22
  118. package/dist/resources/MemoryReflect.js +68 -14
  119. package/dist/resources/MemoryReindex.js +91 -13
  120. package/dist/resources/Message.js +11 -2
  121. package/dist/resources/OAuth.js +156 -39
  122. package/dist/resources/OAuthClient.js +1 -1
  123. package/dist/resources/OrgEvent.js +292 -29
  124. package/dist/resources/OrgEventCatchup.js +7 -0
  125. package/dist/resources/OrgEventMaintenance.js +48 -10
  126. package/dist/resources/PairingToken.js +1 -1
  127. package/dist/resources/Presence.js +31 -11
  128. package/dist/resources/PromoteMemoryCandidate.js +8 -2
  129. package/dist/resources/RecordUsage.js +2 -4
  130. package/dist/resources/Soul.js +2 -0
  131. package/dist/resources/SoulFeed.js +2 -1
  132. package/dist/resources/WorkspaceLatest.js +4 -0
  133. package/dist/resources/XAA.js +36 -10
  134. package/dist/resources/a2a-stream.js +313 -0
  135. package/dist/resources/a2a-url.js +4 -5
  136. package/dist/resources/agent-admin.js +10 -1
  137. package/dist/resources/agent-auth.js +98 -68
  138. package/dist/resources/agent-read-position-lib.js +4 -1
  139. package/dist/resources/agent-status-guard.js +9 -7
  140. package/dist/resources/auth-middleware.js +166 -42
  141. package/dist/resources/authority-field-guard.js +9 -11
  142. package/dist/resources/auto-promote-lib.js +8 -5
  143. package/dist/resources/basic-auth-header.js +21 -0
  144. package/dist/resources/bm25-index-service.js +4 -5
  145. package/dist/resources/dedup-cluster.js +6 -1
  146. package/dist/resources/embeddings-provider.js +25 -0
  147. package/dist/resources/federation-classify.js +89 -0
  148. package/dist/resources/federation-retry-lib.js +6 -81
  149. package/dist/resources/health.js +75 -19
  150. package/dist/resources/host-pointer/registry.js +29 -0
  151. package/dist/resources/host-pointer-adapter.js +1 -0
  152. package/dist/resources/in-process-api.js +74 -11
  153. package/dist/resources/in-process.js +24 -22
  154. package/dist/resources/instruction-version-record.js +251 -7
  155. package/dist/resources/internal-authority.js +13 -0
  156. package/dist/resources/mcp-client-metadata-fields.js +4 -0
  157. package/dist/resources/mcp-handler.js +146 -13
  158. package/dist/resources/mcp-oauth-flag.js +12 -14
  159. package/dist/resources/mcp-oauth.js +446 -53
  160. package/dist/resources/mcp-tool-scopes.js +69 -0
  161. package/dist/resources/mcp-tools.js +70 -22
  162. package/dist/resources/memory-declared-attributes.js +1 -0
  163. package/dist/resources/memory-embed-hash.js +56 -0
  164. package/dist/resources/memory-host-source.js +5 -2
  165. package/dist/resources/memory-reflect-lib.js +1 -1
  166. package/dist/resources/memory-write-lock.js +202 -23
  167. package/dist/resources/memory-write-response.js +1 -1
  168. package/dist/resources/memory-write-transaction.js +243 -0
  169. package/dist/resources/migration-boot.js +17 -12
  170. package/dist/resources/migrations/boot-progress.js +25 -0
  171. package/dist/resources/migrations/data-dir.js +16 -3
  172. package/dist/resources/migrations/dir-safety.js +60 -2
  173. package/dist/resources/migrations/embedding-stamp.js +315 -49
  174. package/dist/resources/migrations/graph-heal.js +9 -2
  175. package/dist/resources/migrations/ledger.js +5 -2
  176. package/dist/resources/migrations/lock.js +867 -80
  177. package/dist/resources/migrations/progress.js +71 -10
  178. package/dist/resources/migrations/runner.js +212 -18
  179. package/dist/resources/migrations/state.js +36 -1
  180. package/dist/resources/migrations/status.js +2 -13
  181. package/dist/resources/migrations/synthetic-test-migration.js +78 -12
  182. package/dist/resources/migrations/types.js +26 -1
  183. package/dist/resources/migrations/visibility-backfill.js +111 -70
  184. package/dist/resources/oauth-discovery.js +0 -5
  185. package/dist/resources/object-body-guard.js +12 -5
  186. package/dist/resources/org-event-reserved.js +92 -0
  187. package/dist/resources/org-event-write-fault.js +19 -0
  188. package/dist/resources/owner-field-guard.js +1 -1
  189. package/dist/resources/owner-scoped-write-policy.js +65 -21
  190. package/dist/resources/owner-scoped-writes.js +37 -6
  191. package/dist/resources/path-id-rewrite.js +76 -0
  192. package/dist/resources/presence-internal.js +5 -5
  193. package/dist/resources/promotion-binding.js +43 -0
  194. package/dist/resources/promotion-stamp.js +124 -33
  195. package/dist/resources/protocol-context.js +189 -0
  196. package/dist/resources/record-type-kit.js +2 -4
  197. package/dist/resources/request-target.js +28 -1
  198. package/dist/resources/request-transaction.js +11 -1
  199. package/dist/resources/seed-reservation.js +1 -2
  200. package/dist/resources/semantic-retrieval-core.js +7 -6
  201. package/dist/resources/server-row-validation.js +71 -0
  202. package/dist/resources/skill-manifest.js +4 -3
  203. package/dist/resources/skill-version-write.js +400 -27
  204. package/dist/resources/skill-write-fault.js +6 -3
  205. package/dist/resources/skill-write-policy.js +2 -1
  206. package/dist/resources/soul-write-policy.js +26 -7
  207. package/dist/resources/table-helpers.js +1 -1
  208. package/dist/resources/table-subscription-policy.js +518 -85
  209. package/dist/resources/table-subscriptions.js +20 -7
  210. package/dist/resources/txn-pause-point.js +122 -5
  211. package/dist/resources/usage-recording.js +54 -46
  212. package/dist/resources/write-back.js +176 -11
  213. package/dist/resources/write-journal-context.js +5 -0
  214. package/dist/resources/write-journal.js +289 -0
  215. package/dist/src/keystore.js +77 -10
  216. package/dist/src/lib/agent-id-rule.js +44 -2
  217. package/dist/src/lib/atomic-write.js +3 -3
  218. package/dist/src/lib/federation-retry-row.js +101 -0
  219. package/dist/src/lib/instruction-event-contract.js +17 -0
  220. package/dist/src/lib/key-dir.js +203 -0
  221. package/dist/src/lib/memory-attributes.js +2 -0
  222. package/dist/src/lib/open-live-row.js +20 -0
  223. package/dist/src/lib/scheduler-platform.js +13 -0
  224. package/dist/src/lib/soul-scope-fields.js +26 -0
  225. package/dist/src/rem/promote-policy.js +3 -3
  226. package/dist/src/rem/scheduler.js +21 -4
  227. package/docs/access-control.md +39 -21
  228. package/docs/api-reference.md +161 -52
  229. package/docs/auth.md +69 -38
  230. package/docs/claude-code.md +3 -3
  231. package/docs/deploying-on-fabric.md +118 -2
  232. package/docs/deployment.md +17 -0
  233. package/docs/embedding-in-a-harper-app.md +23 -21
  234. package/docs/entity-vocabulary.md +7 -11
  235. package/docs/federation.md +29 -2
  236. package/docs/hosted-on-fabric.md +1 -1
  237. package/docs/integrations.md +11 -11
  238. package/docs/mcp-clients.md +7 -5
  239. package/docs/notes/mcp-agent-auth-consumer.md +4 -9
  240. package/docs/notes/mcp-oauth-model2.md +6 -6
  241. package/docs/openclaw.md +1 -1
  242. package/docs/quickstart-fabric.md +2 -2
  243. package/docs/quickstart.md +3 -3
  244. package/docs/releasing.md +13 -13
  245. package/docs/rem.md +24 -3
  246. package/docs/secrets-and-keys.md +9 -14
  247. package/docs/standalone-local.md +29 -2
  248. package/docs/supply-chain-policy.md +28 -20
  249. package/docs/the-team.md +2 -2
  250. package/docs/upgrade.md +29 -5
  251. package/package.json +18 -11
  252. package/schemas/agent.graphql +3 -3
  253. package/schemas/federation.graphql +10 -7
  254. package/schemas/memory.graphql +7 -2
  255. package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
  256. package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
  257. package/dist/resources/soul-adk-guard.js +0 -68
@@ -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
- * `dataDir` defaults to `defaultDataDir()`, so both call sites (plain `status`
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
- ? warnings.filter((w) => {
437
- // Hash-fallback warnings contain agent-specific counts
438
- if (w.message.includes("hash-fallback")) {
439
- const match = w.message.match(/\b(\d+)\/(\d+) \((\d+)%\)/);
440
- if (match) {
441
- const hashCount = parseInt(match[1]);
442
- const totalCount = parseInt(match[2]);
443
- const agentRow = healthData.agents.perAgent.find((r) => r.id === opts.agent);
444
- if (agentRow && agentRow.hashFallback === hashCount && agentRow.memoryCount === totalCount) {
445
- return true;
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
- // Mixed-model / outstanding stamp-migration warnings are fleet-wide; keep them
451
- if (w.message.includes("multiple embedding models"))
452
- return true;
453
- if (w.message.includes("embedding-stamp") || w.message.includes("duplicate detection is inactive"))
454
- return true;
455
- // Federation warnings are fleet-wide; keep them
456
- if (w.message.includes("federation"))
457
- return true;
458
- // REM warnings are fleet-wide; keep them
459
- if (w.message.includes("REM") || w.message.includes("nightly"))
460
- return true;
461
- // Ops-API bind is a host fact, not per-agent; keep it
462
- if (w.message.includes("Ops API bound"))
463
- return true;
464
- // Default: keep fleet-wide warnings
465
- return !w.message.includes(opts.agent);
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,27 +552,43 @@ 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));
538
- if (agents && agents.count > 0) {
539
- console.log(`\n${render.wrap(render.c.bold, "Agents")}`);
540
- const nameStr = agents.names?.length > 0 ? ` ${render.wrap(render.c.dim, "—")} ${agents.names.join(render.wrap(render.c.dim, ", "))}` : "";
541
- console.log(render.kv("Total", `${render.wrap(render.c.bold, String(agents.count))}${nameStr}`));
542
- if (agents.count > 1 && Array.isArray(agents.perAgent) && agents.perAgent.length > 0) {
543
- const hasDeep = agents.perAgent.some((r) => typeof r.hashFallback === "number" || typeof r.writes24h === "number");
544
- const cols = hasDeep
545
- ? [
546
- { label: "id", key: "id" },
547
- { label: "memories", key: "memoryCount", align: "right" },
548
- { label: "hash_fb", key: "hashFallback", align: "right", format: (v) => (typeof v === "number" ? String(v) : "—") },
549
- { label: "24h", key: "writes24h", align: "right", format: (v) => (typeof v === "number" ? String(v) : "—") },
550
- { label: "last_write", key: "lastWriteAt", format: (v) => render.relativeTime(v) },
551
- ]
552
- : [
553
- { label: "id", key: "id" },
554
- { label: "memories", key: "memoryCount", align: "right" },
555
- { label: "last_write", key: "lastWriteAt", format: (v) => render.relativeTime(v) },
556
- ];
557
- console.log(render.table(cols, agents.perAgent));
555
+ console.log(render.kv("BM25 index", escapeTerminalText(bm25Line)));
556
+ if (agents) {
557
+ if (agents.count > 0) {
558
+ console.log(`\n${render.wrap(render.c.bold, "Agents")}`);
559
+ const nameStr = agents.names?.length > 0 ? ` ${render.wrap(render.c.dim, "—")} ${agents.names.map((n) => escapeTerminalText(n)).join(render.wrap(render.c.dim, ", "))}` : "";
560
+ console.log(render.kv("Total", `${render.wrap(render.c.bold, String(agents.count))}${nameStr}`));
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";
569
+ const hasDeep = agents.perAgent.some((r) => typeof r.hashFallback === "number" || typeof r.writes24h === "number");
570
+ const cols = hasDeep
571
+ ? [
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 },
577
+ ]
578
+ : [
579
+ { label: "id", key: "id", format: idCell },
580
+ { label: "memories", key: "memoryCount", align: "right", format: countCell },
581
+ { label: "last_write", key: "lastWriteAt", format: lastWriteCell },
582
+ ];
583
+ console.log(render.table(cols, agents.perAgent));
584
+ }
585
+ }
586
+ if (agents.unregisteredMemoryAuthors === null) {
587
+ console.log(render.kv("Unregistered memory owners", render.wrap(render.c.dim, "unavailable — memory scan did not complete")));
588
+ }
589
+ else if (Array.isArray(agents.unregisteredMemoryAuthors) && agents.unregisteredMemoryAuthors.length > 0) {
590
+ const owners = agents.unregisteredMemoryAuthors.map((r) => `${escapeTerminalText(String(r.id ?? ""))} (${r.memoryCount} ${r.memoryCount === 1 ? "memory" : "memories"})`);
591
+ console.log(render.kv("Unregistered memory owners", owners.join(render.wrap(render.c.dim, ", "))));
558
592
  }
559
593
  }
560
594
  if (healthData?.relationships) {
@@ -566,7 +600,7 @@ export function register(program) {
566
600
  const s = healthData.soul;
567
601
  console.log(`\n${render.wrap(render.c.bold, "Soul")}`);
568
602
  const entries = sortSoulKeyEntries(s.byKey ?? {});
569
- 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}`);
570
604
  const suffix = parts.length > 0
571
605
  ? ` ${render.wrap(render.c.dim, "—")} ${parts.join(render.wrap(render.c.dim, " · "))}`
572
606
  : "";
@@ -607,7 +641,7 @@ export function register(program) {
607
641
  console.log(`\n${render.wrap(render.c.bold, "Federation")}`);
608
642
  if (f.instance) {
609
643
  const statusColor = f.instance.status === "active" ? render.c.green : render.c.yellow;
610
- 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, ")")}`));
611
645
  }
612
646
  if (f.peers) {
613
647
  const parts = federationPeerCountParts(f.peers);
@@ -633,7 +667,7 @@ export function register(program) {
633
667
  const b = healthData.bridges;
634
668
  console.log(`\n${render.wrap(render.c.bold, "Bridges")}`);
635
669
  if (Array.isArray(b.installed) && b.installed.length > 0)
636
- 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, ", "))));
637
671
  if (b.lastImport)
638
672
  console.log(render.kv("Last import", render.relativeTime(b.lastImport)));
639
673
  if (b.lastExport)
@@ -645,8 +679,8 @@ export function register(program) {
645
679
  if (healthData?.disk) {
646
680
  const d = healthData.disk;
647
681
  console.log(`\n${render.wrap(render.c.bold, "Disk")}`);
648
- 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))}`));
649
- 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))}`));
650
684
  }
651
685
  console.log("");
652
686
  if (scopedWarnings.length > 0) {
@@ -689,7 +723,7 @@ export function register(program) {
689
723
  : render.wrap(render.c.dim, "unknown");
690
724
  console.log(render.kv("Nightly", nightlyTxt, 18));
691
725
  if (r.lastNightlyAt) {
692
- 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));
693
727
  }
694
728
  const ds = distillationStaleness(r);
695
729
  if (typeof r.pendingCandidates === "number") {
@@ -729,7 +763,7 @@ export function register(program) {
729
763
  console.log(render.wrap(render.c.bold, "Federation"));
730
764
  if (f.instance) {
731
765
  const statusColor = f.instance.status === "active" ? render.c.green : render.c.yellow;
732
- 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, ")")}`));
733
767
  }
734
768
  else {
735
769
  console.log(render.kv("Instance", render.wrap(render.c.dim, "—")));
@@ -744,15 +778,15 @@ export function register(program) {
744
778
  if (Array.isArray(f.peerList) && f.peerList.length > 0) {
745
779
  console.log();
746
780
  const cols = [
747
- { label: "peer", key: "id" },
748
- { 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 ?? "—")) },
749
783
  {
750
784
  label: "status",
751
785
  key: "status",
752
786
  format: (v) => {
753
787
  const s = String(v ?? "—");
754
788
  const color = s === "paired" || s === "connected" ? render.c.green : s === "revoked" ? render.c.red : render.c.yellow;
755
- return render.wrap(color, s);
789
+ return render.wrap(color, escapeTerminalText(s));
756
790
  },
757
791
  },
758
792
  {
@@ -761,7 +795,7 @@ export function register(program) {
761
795
  format: (v) => {
762
796
  const s = String(v ?? "—");
763
797
  const color = s === "connected" ? render.c.green : s === "disconnected" ? render.c.yellow : s === "revoked" ? render.c.red : render.c.dim;
764
- return render.wrap(color, s);
798
+ return render.wrap(color, escapeTerminalText(s));
765
799
  },
766
800
  },
767
801
  {
@@ -771,7 +805,7 @@ export function register(program) {
771
805
  const iso = v;
772
806
  if (!iso)
773
807
  return render.wrap(render.c.dim, "never");
774
- return `${render.relativeTime(iso)} ${render.wrap(render.c.dim, `(${iso})`)}`;
808
+ return `${render.relativeTime(iso)} ${render.wrap(render.c.dim, `(${escapeTerminalText(String(iso))})`)}`;
775
809
  },
776
810
  },
777
811
  ];
@@ -808,19 +842,19 @@ export function register(program) {
808
842
  if (Array.isArray(o?.clientList) && o.clientList.length > 0) {
809
843
  console.log(`\n ${render.wrap(render.c.dim, "Clients")}`);
810
844
  const cols = [
811
- { label: "id", key: "id" },
812
- { label: "name", key: "name", format: (v) => String(v ?? "—") },
813
- { label: "registered_by", key: "registeredBy", format: (v) => String(v ?? "—") },
814
- { 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 ?? "—")) },
815
849
  ];
816
850
  console.log(render.table(cols, o.clientList));
817
851
  }
818
852
  if (Array.isArray(o?.idpList) && o.idpList.length > 0) {
819
853
  console.log(`\n ${render.wrap(render.c.dim, "IdPs")}`);
820
854
  const cols = [
821
- { label: "id", key: "id" },
822
- { label: "name", key: "name", format: (v) => String(v ?? "—") },
823
- { 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 ?? "—")) },
824
858
  ];
825
859
  console.log(render.table(cols, o.idpList));
826
860
  }
@@ -856,17 +890,11 @@ export function register(program) {
856
890
  if (b.lastExport)
857
891
  console.log(render.kv("Last export", render.relativeTime(b.lastExport)));
858
892
  });
859
- // ─── flair status --deep ──────────────────────────────────────────────────────
893
+ // `flair status deep` adds verbose sections. Its optional `--bootstrap` posts to
894
+ // `/BootstrapMemories` for each selected agent to measure context size.
860
895
  //
861
- // Deeper observability than the default `flair status` summary — full
862
- // per-section detail with no condensing. Optional --bootstrap measures
863
- // cold-start context bytes per agent (slow; calls /MemoryBootstrap once per
864
- // agent, admin-auth required).
865
- //
866
- // Addresses ops-yph: Nathan's 2026-04-22 ask for "how much storage does my
867
- // memory take, how much context are bootstraps pulling, what's the real usage
868
- // pattern" — questions the default `flair status` summarizes but doesn't
869
- // 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.
870
898
  statusCmd
871
899
  .command("deep")
872
900
  .description("Verbose status + optional bootstrap context size per agent (ops-yph)")
@@ -875,16 +903,17 @@ export function register(program) {
875
903
  .action(async function () {
876
904
  const opts = this.optsWithGlobals();
877
905
  const { healthy, baseUrl, healthData } = await fetchHealthDetail(opts);
878
- // Same local install-health facts the plain `status` renders, so `--deep`
879
- // cannot end on "✅ no warnings" while the ops API is exposed (flair#852).
880
- const localWarnings = localOpsApiWarnings(baseUrl);
906
+ // `flair status deep` reports the same local install warnings as plain status.
907
+ const localWarnings = [...localOpsApiWarnings(baseUrl), ...localKeyModeWarnings(baseUrl)];
881
908
  if (!healthy) {
882
909
  if (opts.json) {
883
- 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));
884
911
  }
885
912
  else {
886
913
  console.log(`Flair v${__pkgVersion} — 🔴 unreachable`);
887
914
  console.log(` URL: ${baseUrl}`);
915
+ for (const warning of localWarnings)
916
+ console.log(` ⚠ ${warning.message}`);
888
917
  console.log(`\n Run: flair start or flair doctor`);
889
918
  }
890
919
  process.exit(1);
@@ -976,7 +1005,7 @@ export function register(program) {
976
1005
  .sort((a, b) => b[1] - a[1]);
977
1006
  for (const [k, n] of entries) {
978
1007
  const pct = ((n / memories.total) * 100).toFixed(1);
979
- console.log(` ${k.padEnd(28)} ${String(n).padStart(6)} (${pct}%)`);
1008
+ console.log(` ${escapeTerminalText(k).padEnd(28)} ${String(n).padStart(6)} (${pct}%)`);
980
1009
  }
981
1010
  }
982
1011
  if (memories.byDurability) {
@@ -986,26 +1015,38 @@ export function register(program) {
986
1015
  console.log(`Archived: ${memories.archived ?? 0}`);
987
1016
  console.log(`Expired: ${memories.expired ?? 0}`);
988
1017
  if (healthData?.lastWrite)
989
- console.log(`Last write: ${relativeTime(healthData.lastWrite)} (${healthData.lastWrite})`);
1018
+ console.log(`Last write: ${relativeTime(healthData.lastWrite)} (${escapeTerminalText(String(healthData.lastWrite))})`);
990
1019
  }
991
1020
  const bm25DeepLine = formatBm25StatusLine(healthData?.bm25);
992
1021
  if (bm25DeepLine)
993
- console.log(`BM25 index: ${bm25DeepLine}`);
1022
+ console.log(`BM25 index: ${escapeTerminalText(bm25DeepLine)}`);
994
1023
  const agents = healthData?.agents;
995
- if (agents && agents.count > 0) {
996
- console.log("\n═══ Agents ═══════════════════════════════════════");
997
- console.log(`Total: ${agents.count}`);
998
- if (Array.isArray(agents.names) && agents.names.length > 0) {
999
- console.log(`Names: ${agents.names.join(", ")}`);
1000
- }
1001
- if (Array.isArray(agents.perAgent) && agents.perAgent.length > 0) {
1002
- const idW = Math.max(2, ...agents.perAgent.map((r) => (r.id ?? "").length));
1003
- console.log(`\n ${"id".padEnd(idW)} memories hash_fb 24h last_write`);
1004
- for (const r of agents.perAgent) {
1005
- const fb = typeof r.hashFallback === "number" ? String(r.hashFallback) : "—";
1006
- const w24 = typeof r.writes24h === "number" ? String(r.writes24h) : "—";
1007
- console.log(` ${(r.id ?? "").padEnd(idW)} ${String(r.memoryCount).padStart(8)} ${fb.padStart(7)} ${w24.padStart(3)} ${relativeTime(r.lastWriteAt)}`);
1024
+ if (agents) {
1025
+ if (agents.count > 0) {
1026
+ console.log("\n═══ Agents ═══════════════════════════════════════");
1027
+ console.log(`Total: ${agents.count}`);
1028
+ if (Array.isArray(agents.names) && agents.names.length > 0) {
1029
+ console.log(`Names: ${agents.names.map((n) => escapeTerminalText(n)).join(", ")}`);
1008
1030
  }
1031
+ if (Array.isArray(agents.perAgent) && agents.perAgent.length > 0) {
1032
+ const idW = Math.max(2, ...agents.perAgent.map((r) => escapeTerminalText(String(r.id ?? "")).length));
1033
+ console.log(`\n ${"id".padEnd(idW)} memories hash_fb 24h last_write`);
1034
+ for (const r of agents.perAgent) {
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}`);
1041
+ }
1042
+ }
1043
+ }
1044
+ if (agents.unregisteredMemoryAuthors === null) {
1045
+ console.log("Unregistered memory owners: unavailable — memory scan did not complete");
1046
+ }
1047
+ else if (Array.isArray(agents.unregisteredMemoryAuthors) && agents.unregisteredMemoryAuthors.length > 0) {
1048
+ const owners = agents.unregisteredMemoryAuthors.map((r) => `${escapeTerminalText(String(r.id ?? ""))} (${r.memoryCount} ${r.memoryCount === 1 ? "memory" : "memories"})`);
1049
+ console.log(`Unregistered memory owners: ${owners.join(", ")}`);
1009
1050
  }
1010
1051
  }
1011
1052
  // Bootstrap context section — always printed so users see how to opt in.
@@ -1025,8 +1066,8 @@ export function register(program) {
1025
1066
  const bytesStr = info.error ? "error" : humanBytes(info.bytes);
1026
1067
  const tok = info.tokenEstimate != null ? String(info.tokenEstimate) : "—";
1027
1068
  const mems = info.memoriesIncluded != null ? String(info.memoriesIncluded) : "—";
1028
- const status = info.error ? info.error.slice(0, 40) : "ok";
1029
- 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}`);
1030
1071
  }
1031
1072
  }
1032
1073
  if (healthData?.relationships) {
@@ -1040,7 +1081,7 @@ export function register(program) {
1040
1081
  console.log(`Total: ${s.total} entries`);
1041
1082
  const entries = sortSoulKeyEntries(s.byKey ?? {});
1042
1083
  if (entries.length > 0) {
1043
- console.log(`Keys: ${entries.map(([k, n]) => `${n} ${k}`).join(" / ")}`);
1084
+ console.log(`Keys: ${entries.map(([k, n]) => `${n} ${escapeTerminalText(k)}`).join(" / ")}`);
1044
1085
  }
1045
1086
  }
1046
1087
  else if (typeof healthData?.soulEntries === "number" && healthData.soulEntries > 0) {
@@ -1056,12 +1097,12 @@ export function register(program) {
1056
1097
  const nightly = r.nightlyEnabled === true ? "enabled" : r.nightlyEnabled === false ? "disabled" : "unknown";
1057
1098
  console.log(`Nightly: ${nightly}`);
1058
1099
  if (r.lastNightlyAt)
1059
- console.log(`Last nightly: ${relativeTime(r.lastNightlyAt)} (${r.lastNightlyAt})`);
1100
+ console.log(`Last nightly: ${relativeTime(r.lastNightlyAt)} (${escapeTerminalText(String(r.lastNightlyAt))})`);
1060
1101
  if (typeof r.pendingCandidates === "number")
1061
1102
  console.log(`Pending candidates: ${r.pendingCandidates}`);
1062
1103
  const ds = distillationStaleness(r);
1063
1104
  if (typeof r.pendingCandidates === "number" || ds.lastDistilledAt || ds.stale) {
1064
- const base = ds.lastDistilledAt ? `${relativeTime(ds.lastDistilledAt)} (${ds.lastDistilledAt})` : "not observed";
1105
+ const base = ds.lastDistilledAt ? `${relativeTime(ds.lastDistilledAt)} (${escapeTerminalText(ds.lastDistilledAt)})` : "not observed";
1065
1106
  console.log(`Last distilled: ${base} (server-local log tail)${ds.stale ? DISTILL_STALE_HINT : ""}`);
1066
1107
  }
1067
1108
  }
@@ -1069,7 +1110,7 @@ export function register(program) {
1069
1110
  const f = healthData.federation;
1070
1111
  console.log("\n═══ Federation ═══════════════════════════════════");
1071
1112
  if (f.instance)
1072
- 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 ?? "—"))})`);
1073
1114
  if (f.peers) {
1074
1115
  const unknown = Number(f.peers.unknown ?? 0);
1075
1116
  const unknownBit = unknown > 0 ? `, ${unknown} unknown` : "";
@@ -1078,10 +1119,10 @@ export function register(program) {
1078
1119
  if (typeof f.pendingTokens === "number" && f.pendingTokens > 0)
1079
1120
  console.log(`Pairing: ${f.pendingTokens} unconsumed token(s)`);
1080
1121
  if (Array.isArray(f.peerList) && f.peerList.length > 0) {
1081
- 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));
1082
1123
  console.log(`\n ${"peer".padEnd(idW)} ${"role".padEnd(5)} ${"status".padEnd(13)} ${"liveness".padEnd(13)} last_sync`);
1083
1124
  for (const p of f.peerList) {
1084
- 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"}`);
1085
1126
  }
1086
1127
  }
1087
1128
  }
@@ -1098,7 +1139,7 @@ export function register(program) {
1098
1139
  if (Array.isArray(o.clientList) && o.clientList.length > 0) {
1099
1140
  console.log(`\n Clients:`);
1100
1141
  for (const c of o.clientList) {
1101
- 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 ?? "—"))}`);
1102
1143
  }
1103
1144
  }
1104
1145
  }
@@ -1106,7 +1147,7 @@ export function register(program) {
1106
1147
  const b = healthData.bridges;
1107
1148
  console.log("\n═══ Bridges ══════════════════════════════════════");
1108
1149
  if (Array.isArray(b.installed) && b.installed.length > 0)
1109
- console.log(`Installed: ${b.installed.join(", ")}`);
1150
+ console.log(`Installed: ${b.installed.map((n) => escapeTerminalText(n)).join(", ")}`);
1110
1151
  if (b.lastImport)
1111
1152
  console.log(`Last import: ${relativeTime(b.lastImport)}`);
1112
1153
  if (b.lastExport)
@@ -1115,8 +1156,8 @@ export function register(program) {
1115
1156
  if (healthData?.disk) {
1116
1157
  const d = healthData.disk;
1117
1158
  console.log("\n═══ Disk ═════════════════════════════════════════");
1118
- console.log(`Data: ${d.dataDir} — ${humanBytes(d.dataBytes ?? 0)}`);
1119
- 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)}`);
1120
1161
  console.log(`Total: ${humanBytes((d.dataBytes ?? 0) + (d.snapshotBytes ?? 0))}`);
1121
1162
  }
1122
1163
  const warnings = [
@@ -1126,7 +1167,7 @@ export function register(program) {
1126
1167
  if (warnings.length > 0) {
1127
1168
  console.log("\n═══ Warnings ═════════════════════════════════════");
1128
1169
  for (const w of warnings)
1129
- console.log(` ${w.level === "warn" ? "⚠" : "ℹ"} ${w.message}`);
1170
+ console.log(` ${w.level === "warn" ? "⚠" : "ℹ"} ${escapeTerminalText(w.message)}`);
1130
1171
  }
1131
1172
  else {
1132
1173
  console.log("\n✅ no warnings");
@@ -1,5 +1,6 @@
1
1
  import * as render from "../render.js";
2
2
  import { encodeRecordId } from "../lib/record-id-path.js";
3
+ import { ApiRequestOutcomeUnknown } from "../lib/auth-resolve.js";
3
4
  let cli;
4
5
  /** Bind the cli-locals this module depends on. */
5
6
  export function bindCli(fns) {
@@ -45,13 +46,15 @@ export function register(program) {
45
46
  }
46
47
  }
47
48
  catch (e) {
49
+ if (e instanceof ApiRequestOutcomeUnknown)
50
+ throw e;
48
51
  const message = e instanceof Error ? e.message : String(e);
49
52
  console.log(` ${render.icons.error} ${render.wrap(render.c.red, "FAIL")} ${name}: ${render.wrap(render.c.dim, message?.slice(0, 120))}`);
50
53
  failed++;
51
54
  }
52
55
  };
53
56
  // 1. Write a test memory via PUT /Memory/<id>.
54
- // Schema only exposes PUT — POST returns 'Memory does not have a post method implemented'.
57
+ // The CLI writes through PUT /Memory/<id>; a bare POST /Memory reaches Memory.post() too.
55
58
  await check("Write test memory (PUT /Memory/<id>)", async () => {
56
59
  const id = `flair-test-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
57
60
  const body = {