@tpsdev-ai/flair 0.59.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/README.md +10 -10
  2. package/SECURITY.md +49 -5
  3. package/config.yaml +23 -12
  4. package/dist/bridges/builtins/mem0.js +63 -28
  5. package/dist/bridges/runtime/execute.js +1 -0
  6. package/dist/bridges/runtime/import-runner.js +12 -0
  7. package/dist/bridges/runtime/load-plugin.js +42 -13
  8. package/dist/bridges/runtime/yaml-loader.js +4 -2
  9. package/dist/bridges/types.js +1 -0
  10. package/dist/build-info.json +3 -3
  11. package/dist/cli.js +1054 -367
  12. package/dist/commands/agent.js +233 -90
  13. package/dist/commands/attention.js +4 -3
  14. package/dist/commands/backup-approval.js +218 -0
  15. package/dist/commands/backup.js +211 -39
  16. package/dist/commands/bootstrap.js +3 -1
  17. package/dist/commands/bridge.js +172 -119
  18. package/dist/commands/deploy.js +71 -8
  19. package/dist/commands/doctor.js +711 -146
  20. package/dist/commands/export.js +57 -23
  21. package/dist/commands/federation.js +787 -82
  22. package/dist/commands/grant.js +5 -6
  23. package/dist/commands/help.js +25 -0
  24. package/dist/commands/hook.js +155 -2
  25. package/dist/commands/idp.js +27 -19
  26. package/dist/commands/import.js +136 -20
  27. package/dist/commands/init.js +469 -200
  28. package/dist/commands/integrity.js +387 -0
  29. package/dist/commands/keys.js +247 -58
  30. package/dist/commands/mcp.js +108 -52
  31. package/dist/commands/memory.js +203 -35
  32. package/dist/commands/migrate-harness-memory.js +3 -2
  33. package/dist/commands/orgevent.js +51 -47
  34. package/dist/commands/presence.js +4 -3
  35. package/dist/commands/principal.js +428 -62
  36. package/dist/commands/quality.js +13 -1
  37. package/dist/commands/reembed.js +141 -17
  38. package/dist/commands/relationship.js +2 -1
  39. package/dist/commands/rem.js +537 -80
  40. package/dist/commands/restore.js +413 -65
  41. package/dist/commands/search.js +6 -4
  42. package/dist/commands/service.js +235 -40
  43. package/dist/commands/soul.js +4 -9
  44. package/dist/commands/status.js +94 -38
  45. package/dist/commands/test.js +7 -3
  46. package/dist/commands/upgrade.js +77 -23
  47. package/dist/commands/workspace.js +13 -11
  48. package/dist/component-env.js +31 -41
  49. package/dist/deploy.js +136 -4
  50. package/dist/doctor-client.js +534 -92
  51. package/dist/engine-version-contract.js +1 -0
  52. package/dist/engine-version.js +23 -3
  53. package/dist/fabric-upgrade.js +12 -2
  54. package/dist/federation/presence-send.js +139 -0
  55. package/dist/federation-verify.js +273 -180
  56. package/dist/hook-install.js +670 -6
  57. package/dist/install/clients.js +171 -35
  58. package/dist/keystore.js +72 -0
  59. package/dist/lib/action-recall-runtime.js +328 -0
  60. package/dist/lib/agent-home-fields.js +132 -0
  61. package/dist/lib/agent-home.js +427 -0
  62. package/dist/lib/agent-id-rule.js +88 -0
  63. package/dist/lib/agent-roster.js +33 -0
  64. package/dist/lib/atomic-write.js +1 -1
  65. package/dist/lib/auth-resolve.js +1069 -60
  66. package/dist/lib/backup-approval-store.js +612 -0
  67. package/dist/lib/backup-artifact.js +343 -0
  68. package/dist/lib/capture-runtime.js +124 -0
  69. package/dist/lib/config-critical-section.js +212 -25
  70. package/dist/lib/connect-phase.js +33 -0
  71. package/dist/lib/credential-status-rule.js +78 -0
  72. package/dist/lib/daemon-liveness.js +43 -11
  73. package/dist/lib/doctor-run.js +75 -37
  74. package/dist/lib/durability-copy.js +10 -0
  75. package/dist/lib/embedding-space-doctor.js +75 -0
  76. package/dist/lib/federation-pair-access.js +4 -0
  77. package/dist/lib/federation-retry-queue.js +283 -0
  78. package/dist/lib/federation-retry-row.js +101 -0
  79. package/dist/lib/flair-agent-role.js +4 -0
  80. package/dist/lib/hub-url.js +12 -0
  81. package/dist/lib/init-admin-pass.js +88 -12
  82. package/dist/lib/init-listener-environ.js +1 -2
  83. package/dist/lib/init-occupied-listener.js +15 -111
  84. package/dist/lib/init-spawn-attribution.js +73 -0
  85. package/dist/lib/init-tcp-probe.js +33 -0
  86. package/dist/lib/instance-identity-row.js +20 -0
  87. package/dist/lib/instruction-event-contract.js +17 -0
  88. package/dist/lib/instruction-event-doctor.js +102 -0
  89. package/dist/lib/launchd-management.js +38 -3
  90. package/dist/lib/listener-table.js +268 -0
  91. package/dist/lib/local-delete-instance.js +27 -0
  92. package/dist/lib/local-instance-pair.js +256 -0
  93. package/dist/lib/mcp-enable.js +1182 -341
  94. package/dist/lib/mcp-oauth-env-core.js +133 -0
  95. package/dist/lib/mcp-oauth-env.js +125 -0
  96. package/dist/lib/mcp-spec.js +17 -1
  97. package/dist/lib/memory-attributes.js +4 -0
  98. package/dist/lib/memory-id-policy.js +46 -0
  99. package/dist/lib/memory-integrity.js +309 -0
  100. package/dist/lib/memory-provider-timeout.js +33 -0
  101. package/dist/lib/memory-purge-response.js +20 -0
  102. package/dist/lib/mqtt-config.js +132 -0
  103. package/dist/lib/mqtt-listener-doctor.js +104 -0
  104. package/dist/lib/open-live-row.js +20 -0
  105. package/dist/lib/ops-table-count.js +25 -0
  106. package/dist/lib/ops-url.js +52 -0
  107. package/dist/lib/owned-pins.js +67 -10
  108. package/dist/lib/peer-status.js +27 -0
  109. package/dist/lib/principal-status.js +29 -0
  110. package/dist/lib/process-start-time.js +76 -12
  111. package/dist/lib/promotion-content-hash.js +20 -0
  112. package/dist/lib/proto-safe-record.js +42 -0
  113. package/dist/lib/record-id-path.js +25 -0
  114. package/dist/lib/reembed-server-support.js +66 -0
  115. package/dist/lib/restore-archive.js +760 -0
  116. package/dist/lib/restore-verify.js +104 -0
  117. package/dist/lib/scheduler-platform.js +10 -6
  118. package/dist/lib/secret-keys.js +25 -0
  119. package/dist/lib/secrets-push.js +50 -22
  120. package/dist/lib/skill-assignment-preflight.js +159 -0
  121. package/dist/lib/skill-seed-pending.js +24 -0
  122. package/dist/lib/skill-seed.js +448 -0
  123. package/dist/lib/skill-tombstone-doctor.js +133 -0
  124. package/dist/lib/soul-scope-fields.js +26 -0
  125. package/dist/lib/stop-start-recovery.js +54 -0
  126. package/dist/lib/uninstall-purge.js +266 -11
  127. package/dist/lib/upgrade-prior-liveness.js +2 -1
  128. package/dist/lib/using-flair-skill.js +87 -0
  129. package/dist/mcp-client-assertion.js +114 -14
  130. package/dist/memory-id-checkpoint.js +347 -0
  131. package/dist/memory-node-compare.js +207 -0
  132. package/dist/mqtt-off-deploy.js +550 -0
  133. package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
  134. package/dist/rem/promote-policy.js +3 -3
  135. package/dist/rem/restore.js +303 -26
  136. package/dist/rem/runner.js +317 -96
  137. package/dist/rem/scheduler.js +21 -4
  138. package/dist/resources/A2AAdapter.js +131 -178
  139. package/dist/resources/AdminMemory.js +2 -0
  140. package/dist/resources/AdminMemoryCandidates.js +116 -0
  141. package/dist/resources/Agent.js +463 -33
  142. package/dist/resources/AgentCard.js +4 -0
  143. package/dist/resources/AgentKeyRegister.js +248 -0
  144. package/dist/resources/AgentKeyRegistration.js +28 -0
  145. package/dist/resources/AgentReadPosition.js +7 -0
  146. package/dist/resources/AgentSeed.js +238 -107
  147. package/dist/resources/AutoPromoteCandidates.js +413 -78
  148. package/dist/resources/Credential.js +183 -10
  149. package/dist/resources/Federation.js +915 -145
  150. package/dist/resources/FederationRetry.js +140 -0
  151. package/dist/resources/InstructionVersion.js +220 -0
  152. package/dist/resources/Integration.js +300 -25
  153. package/dist/resources/MCPClientMetadata.js +6 -3
  154. package/dist/resources/Memory.js +3300 -758
  155. package/dist/resources/MemoryArchive.js +171 -53
  156. package/dist/resources/MemoryBootstrap.js +122 -61
  157. package/dist/resources/MemoryCandidate.js +37 -3
  158. package/dist/resources/MemoryConsolidate.js +2 -2
  159. package/dist/resources/MemoryDedupStats.js +30 -1
  160. package/dist/resources/MemoryFeed.js +545 -50
  161. package/dist/resources/MemoryGrant.js +21 -1
  162. package/dist/resources/MemoryMaintenance.js +368 -46
  163. package/dist/resources/MemoryPurge.js +348 -0
  164. package/dist/resources/MemoryReflect.js +71 -12
  165. package/dist/resources/MemoryReindex.js +111 -17
  166. package/dist/resources/Message.js +16 -5
  167. package/dist/resources/OAuth.js +342 -48
  168. package/dist/resources/OAuthClient.js +1 -1
  169. package/dist/resources/OrgEvent.js +405 -19
  170. package/dist/resources/OrgEventCatchup.js +7 -0
  171. package/dist/resources/OrgEventMaintenance.js +48 -10
  172. package/dist/resources/PairingToken.js +1 -1
  173. package/dist/resources/Presence.js +166 -51
  174. package/dist/resources/PromoteMemoryCandidate.js +24 -7
  175. package/dist/resources/RecordUsage.js +2 -4
  176. package/dist/resources/Relationship.js +23 -0
  177. package/dist/resources/SemanticSearch.js +63 -32
  178. package/dist/resources/Soul.js +191 -76
  179. package/dist/resources/SoulFeed.js +2 -1
  180. package/dist/resources/TeamDirectory.js +35 -0
  181. package/dist/resources/WorkspaceLatest.js +4 -0
  182. package/dist/resources/WorkspaceState.js +21 -1
  183. package/dist/resources/XAA.js +207 -63
  184. package/dist/resources/a2a-stream.js +313 -0
  185. package/dist/resources/a2a-url.js +4 -5
  186. package/dist/resources/agent-admin.js +10 -1
  187. package/dist/resources/agent-auth.js +138 -83
  188. package/dist/resources/agent-read-position-lib.js +4 -1
  189. package/dist/resources/agent-status-guard.js +9 -7
  190. package/dist/resources/auth-middleware.js +534 -171
  191. package/dist/resources/authority-field-guard.js +9 -11
  192. package/dist/resources/auto-promote-lib.js +8 -5
  193. package/dist/resources/basic-auth-header.js +21 -0
  194. package/dist/resources/bm25-index-service.js +4 -5
  195. package/dist/resources/dedup-cluster.js +6 -1
  196. package/dist/resources/ed25519-auth.js +1 -1
  197. package/dist/resources/embedding-space-guard.js +366 -72
  198. package/dist/resources/embeddings-provider.js +25 -0
  199. package/dist/resources/engine-version-stamp-boot.js +53 -0
  200. package/dist/resources/federation-classify.js +161 -0
  201. package/dist/resources/federation-crypto.js +5 -5
  202. package/dist/resources/federation-retry-lib.js +60 -0
  203. package/dist/resources/grant-visibility.js +135 -0
  204. package/dist/resources/harper-routing.js +83 -0
  205. package/dist/resources/health.js +163 -22
  206. package/dist/resources/host-pointer/registry.js +29 -0
  207. package/dist/resources/host-pointer-adapter.js +1 -0
  208. package/dist/resources/host-source-citation.js +49 -0
  209. package/dist/resources/host-source-visibility.js +7 -6
  210. package/dist/resources/in-process.js +24 -22
  211. package/dist/resources/instance-create-lock.js +17 -0
  212. package/dist/resources/instance-identity.js +23 -0
  213. package/dist/resources/instruction-version-record.js +587 -0
  214. package/dist/resources/internal-authority.js +13 -0
  215. package/dist/resources/key-lock.js +3 -3
  216. package/dist/resources/mcp-handler.js +141 -19
  217. package/dist/resources/mcp-oauth-env-guard.js +36 -0
  218. package/dist/resources/mcp-oauth-flag.js +12 -14
  219. package/dist/resources/mcp-oauth.js +450 -56
  220. package/dist/resources/mcp-tool-arguments.js +4 -6
  221. package/dist/resources/mcp-tools.js +187 -40
  222. package/dist/resources/memory-bootstrap-lib.js +5 -15
  223. package/dist/resources/memory-declared-attributes.js +4 -1
  224. package/dist/resources/memory-deletion-history.js +55 -0
  225. package/dist/resources/memory-durability.js +54 -0
  226. package/dist/resources/memory-embed-hash.js +144 -0
  227. package/dist/resources/memory-embedding-value.js +8 -0
  228. package/dist/resources/memory-host-source.js +32 -7
  229. package/dist/resources/memory-id-guard.js +75 -0
  230. package/dist/resources/memory-redaction.js +236 -0
  231. package/dist/resources/memory-reflect-lib.js +1 -1
  232. package/dist/resources/memory-supplied-vector.js +72 -0
  233. package/dist/resources/memory-write-lock.js +489 -0
  234. package/dist/resources/memory-write-response.js +139 -0
  235. package/dist/resources/memory-write-transaction.js +243 -0
  236. package/dist/resources/migration-boot.js +17 -12
  237. package/dist/resources/migrations/boot-progress.js +25 -0
  238. package/dist/resources/migrations/data-dir.js +90 -19
  239. package/dist/resources/migrations/dir-safety.js +61 -3
  240. package/dist/resources/migrations/embedding-stamp.js +462 -82
  241. package/dist/resources/migrations/export.js +1 -0
  242. package/dist/resources/migrations/graph-heal.js +27 -27
  243. package/dist/resources/migrations/ledger.js +5 -2
  244. package/dist/resources/migrations/lock.js +870 -77
  245. package/dist/resources/migrations/progress.js +71 -10
  246. package/dist/resources/migrations/runner.js +212 -18
  247. package/dist/resources/migrations/snapshot.js +1 -0
  248. package/dist/resources/migrations/source-fields.js +5 -5
  249. package/dist/resources/migrations/state.js +36 -1
  250. package/dist/resources/migrations/status.js +2 -13
  251. package/dist/resources/migrations/synthetic-test-migration.js +81 -12
  252. package/dist/resources/migrations/types.js +26 -1
  253. package/dist/resources/migrations/visibility-backfill.js +113 -72
  254. package/dist/resources/oauth-discovery.js +0 -5
  255. package/dist/resources/object-body-guard.js +40 -0
  256. package/dist/resources/org-event-created-at.js +133 -0
  257. package/dist/resources/org-event-reserved.js +92 -0
  258. package/dist/resources/org-event-write-fault.js +19 -0
  259. package/dist/resources/originator-instance.js +39 -7
  260. package/dist/resources/owner-delete-recheck.js +78 -0
  261. package/dist/resources/owner-field-guard.js +39 -5
  262. package/dist/resources/owner-scoped-write-policy.js +256 -0
  263. package/dist/resources/owner-scoped-writes.js +89 -0
  264. package/dist/resources/path-id-rewrite.js +76 -0
  265. package/dist/resources/presence-internal.js +5 -5
  266. package/dist/resources/presence-receipt.js +236 -0
  267. package/dist/resources/promotion-binding.js +43 -0
  268. package/dist/resources/promotion-stamp.js +143 -17
  269. package/dist/resources/protocol-context.js +189 -0
  270. package/dist/resources/record-owner-guard.js +74 -26
  271. package/dist/resources/record-type-kit.js +2 -4
  272. package/dist/resources/record-types.js +1 -1
  273. package/dist/resources/relay-ops.js +78 -6
  274. package/dist/resources/replay-store.js +96 -19
  275. package/dist/resources/request-target.js +163 -0
  276. package/dist/resources/request-transaction.js +46 -1
  277. package/dist/resources/search-readiness.js +4 -1
  278. package/dist/resources/seed-ids.js +9 -0
  279. package/dist/resources/seed-reservation.js +116 -0
  280. package/dist/resources/semantic-retrieval-core.js +27 -15
  281. package/dist/resources/server-row-validation.js +71 -0
  282. package/dist/resources/skill-manifest.js +24 -14
  283. package/dist/resources/skill-subject.js +53 -0
  284. package/dist/resources/skill-version-write.js +789 -0
  285. package/dist/resources/skill-write-fault.js +20 -0
  286. package/dist/resources/skill-write-policy.js +68 -0
  287. package/dist/resources/skill-write.js +67 -7
  288. package/dist/resources/soul-write-policy.js +26 -7
  289. package/dist/resources/table-helpers.js +10 -7
  290. package/dist/resources/table-subscription-policy.js +518 -85
  291. package/dist/resources/table-subscriptions.js +20 -7
  292. package/dist/resources/team-directory.js +248 -0
  293. package/dist/resources/tool-descriptors/index.js +69 -8
  294. package/dist/resources/txn-pause-point.js +235 -0
  295. package/dist/resources/usage-recording.js +186 -70
  296. package/dist/resources/write-back.js +383 -0
  297. package/dist/resources/write-journal-context.js +5 -0
  298. package/dist/resources/write-journal.js +289 -0
  299. package/dist/src/engine-version-contract.js +1 -0
  300. package/dist/src/keystore.js +72 -0
  301. package/dist/src/lib/agent-home-fields.js +132 -0
  302. package/dist/src/lib/agent-id-rule.js +88 -0
  303. package/dist/src/lib/agent-key-register.js +80 -0
  304. package/dist/src/lib/atomic-write.js +256 -0
  305. package/dist/src/lib/credential-status-rule.js +78 -0
  306. package/dist/src/lib/expired-by-agent.js +37 -0
  307. package/dist/src/lib/federation-retry-row.js +101 -0
  308. package/dist/src/lib/flair-agent-role.js +4 -0
  309. package/dist/src/lib/idp-mapping-rule.js +81 -0
  310. package/dist/src/lib/instance-identity-row.js +20 -0
  311. package/dist/src/lib/instruction-event-contract.js +17 -0
  312. package/dist/src/lib/mcp-oauth-env-core.js +133 -0
  313. package/dist/src/lib/memory-attributes.js +4 -0
  314. package/dist/src/lib/memory-id-policy.js +46 -0
  315. package/dist/src/lib/open-live-row.js +20 -0
  316. package/dist/src/lib/principal-status.js +29 -0
  317. package/dist/src/lib/proto-safe-record.js +42 -0
  318. package/dist/src/lib/reembed-server-support.js +66 -0
  319. package/dist/src/lib/scheduler-platform.js +10 -6
  320. package/dist/src/lib/soul-scope-fields.js +26 -0
  321. package/dist/src/lib/systemd-agent-id.js +38 -0
  322. package/dist/src/rem/promote-policy.js +3 -3
  323. package/dist/src/rem/scheduler.js +21 -4
  324. package/docs/access-control.md +164 -54
  325. package/docs/api-reference.md +165 -32
  326. package/docs/auth.md +46 -30
  327. package/docs/bridges.md +11 -0
  328. package/docs/claude-code.md +37 -7
  329. package/docs/deploying-on-fabric.md +178 -0
  330. package/docs/deployment.md +19 -0
  331. package/docs/embedding-in-a-harper-app.md +17 -15
  332. package/docs/entity-vocabulary.md +3 -6
  333. package/docs/federation.md +61 -3
  334. package/docs/hosted-on-fabric.md +43 -36
  335. package/docs/integrations.md +14 -14
  336. package/docs/mcp-clients.md +12 -7
  337. package/docs/n8n.md +17 -11
  338. package/docs/notes/mcp-agent-auth-consumer.md +16 -13
  339. package/docs/notes/mcp-oauth-model2.md +40 -11
  340. package/docs/openclaw.md +1 -1
  341. package/docs/quickstart-fabric.md +4 -4
  342. package/docs/quickstart.md +12 -4
  343. package/docs/releasing.md +25 -19
  344. package/docs/rem.md +32 -3
  345. package/docs/secrets-and-keys.md +21 -4
  346. package/docs/standalone-local.md +30 -2
  347. package/docs/supply-chain-policy.md +34 -16
  348. package/docs/the-team.md +2 -2
  349. package/docs/upgrade.md +46 -6
  350. package/package.json +24 -12
  351. package/schemas/agent-key-registration.graphql +22 -0
  352. package/schemas/agent.graphql +6 -3
  353. package/schemas/federation.graphql +41 -1
  354. package/schemas/memory.graphql +91 -7
  355. package/schemas/oauth.graphql +19 -0
  356. package/schemas/schema.graphql +2 -0
  357. package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
  358. package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
  359. package/dist/resources/soul-adk-guard.js +0 -68
@@ -0,0 +1,66 @@
1
+ /**
2
+ * reembed-server-support.ts — the server-support check `flair reembed` runs
3
+ * before its first write (flair#2337).
4
+ *
5
+ * flair#2298 made the CLI re-embed a row by sending `PATCH /Memory/<id>` with
6
+ * `{"embedding": null, "embeddingModel": null}`; the server recognises that
7
+ * body and re-embeds the stored row. A server built before #2298 does not. A
8
+ * CLI newer than its server is a supported state (`flair upgrade
9
+ * --no-restart`, a bare npm install, an unrestarted service), so the CLI reads
10
+ * the server's advertised capabilities from `GET /Health` before any write and
11
+ * refuses when the token is absent or the response cannot be parsed.
12
+ *
13
+ * The parser and message builders are pure; the fetch adapter lives in
14
+ * src/commands/reembed.ts.
15
+ */
16
+ /**
17
+ * This build advertises this /Health capability for the re-embed PATCH.
18
+ * The shared constant aligns this build's CLI and server literals.
19
+ * A missing token is intentionally refused even if an intermediate server
20
+ * supports the PATCH.
21
+ */
22
+ export const MEMORY_REEMBED_PATCH_CAPABILITY = "memory-reembed-patch";
23
+ /**
24
+ * The capability names a /Health body advertises.
25
+ *
26
+ * - an array of strings — the advertised capabilities (empty when the field
27
+ * is absent: an older server, or a build from before #2337 added it);
28
+ * - `null` — the field is present but not a string array. The client cannot
29
+ * interpret this shape, so the caller must treat the read as unverified
30
+ * rather than as "no capabilities".
31
+ */
32
+ export function parseHealthCapabilities(body) {
33
+ if (typeof body !== "object" || body === null || Array.isArray(body))
34
+ return null;
35
+ const caps = body.capabilities;
36
+ if (caps === undefined)
37
+ return [];
38
+ if (!Array.isArray(caps) || caps.some((c) => typeof c !== "string"))
39
+ return null;
40
+ return caps;
41
+ }
42
+ /** The server version a /Health body reports, or null when it carries none. */
43
+ export function healthVersion(body) {
44
+ if (typeof body !== "object" || body === null)
45
+ return null;
46
+ const v = body.version;
47
+ return typeof v === "string" && v.length > 0 ? v : null;
48
+ }
49
+ /** The remedy both refusal messages end with. */
50
+ export const REEMBED_SUPPORT_REMEDY = "Restart or upgrade the server, then re-run `flair reembed`.";
51
+ /** The refusal for a server that answered but does not advertise the capability. */
52
+ export function reembedUnsupportedMessage(version) {
53
+ return [
54
+ "❌ flair reembed stopped before its first write: the server does not advertise the re-embed PATCH.",
55
+ ` Found: server version ${version ?? "unknown"}, with no "${MEMORY_REEMBED_PATCH_CAPABILITY}" capability.`,
56
+ ` ${REEMBED_SUPPORT_REMEDY}`,
57
+ ].join("\n");
58
+ }
59
+ /** The refusal for a failed or unparseable /Health read. */
60
+ export function reembedUnverifiedMessage(detail) {
61
+ return [
62
+ "❌ flair reembed stopped before its first write: could not confirm the server supports the re-embed PATCH.",
63
+ ` Found: ${detail}.`,
64
+ ` ${REEMBED_SUPPORT_REMEDY}`,
65
+ ].join("\n");
66
+ }
@@ -214,9 +214,11 @@ export function resolveNodeBin(explicit) {
214
214
  if (!process.versions.bun && process.execPath && isAbsolute(process.execPath)) {
215
215
  return process.execPath;
216
216
  }
217
- const r = spawnReport(["/bin/sh", "-c", "command -v node"], STATUS_CHECK_TIMEOUT_MS);
218
- const found = r.stdout.trim().split("\n")[0]?.trim() ?? "";
219
- if (r.code === 0 && found && isAbsolute(found) && existsSync(found))
217
+ const r = spawnSync("/bin/sh", ["-s"], {
218
+ input: "command -v node\n", encoding: "utf8", timeout: STATUS_CHECK_TIMEOUT_MS,
219
+ });
220
+ const found = r.stdout?.trim().split("\n")[0]?.trim() ?? "";
221
+ if (r.status === 0 && found && isAbsolute(found) && existsSync(found))
220
222
  return found;
221
223
  throw new Error("unable to resolve an absolute path to a node binary (not running under node, and `command -v node` " +
222
224
  "found nothing). The scheduler shim runs `<node> <flair-script>` with the node path baked in at " +
@@ -280,9 +282,11 @@ export function formatFlairBinWarning(baked, publicBin, enableCommand) {
280
282
  return lines;
281
283
  }
282
284
  function lookupPublicFlairBin() {
283
- const r = spawnReport(["/bin/sh", "-c", "command -v flair"], STATUS_CHECK_TIMEOUT_MS);
284
- const found = r.stdout.trim().split("\n")[0]?.trim() ?? "";
285
- if (r.code === 0 && found && isAbsolute(found) && existsSync(found))
285
+ const r = spawnSync("/bin/sh", ["-s"], {
286
+ input: "command -v flair\n", encoding: "utf8", timeout: STATUS_CHECK_TIMEOUT_MS,
287
+ });
288
+ const found = r.stdout?.trim().split("\n")[0]?.trim() ?? "";
289
+ if (r.status === 0 && found && isAbsolute(found) && existsSync(found))
286
290
  return found;
287
291
  return null;
288
292
  }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Soul is scoped to an `agentId` and has no dedicated or enforced per-user
3
+ * scope field (schemas/memory.graphql).
4
+ * A write that would store a non-empty `scopeTag` or a non-empty `tags` array
5
+ * is refused by name when earlier guards permit the request, whatever the tag's
6
+ * prefix: POST and PUT check the request body, PATCH the merged row
7
+ * (flair#1540).
8
+ *
9
+ * The predicate runs in the server's write policy. The refusal name is
10
+ * imported by `flair import` and `flair restore`, which report a row refused
11
+ * with it; `flair rem restore` reports its generic HTTP error and imports
12
+ * neither.
13
+ */
14
+ /** The named refusal for a Soul write that would store a non-empty `scopeTag` or a non-empty `tags` array. */
15
+ export const SOUL_SCOPE_FIELDS_REFUSAL = "soul_scope_fields_not_writable";
16
+ /**
17
+ * Whether a row would carry a non-empty `scopeTag` or a non-empty `tags`
18
+ * array. POST and PUT pass the request body; PATCH passes the merged row.
19
+ */
20
+ export function suppliesSoulScopeFields(content) {
21
+ const scopeTag = content?.scopeTag;
22
+ if (scopeTag !== undefined && scopeTag !== null && scopeTag !== "")
23
+ return true;
24
+ const tags = content?.tags;
25
+ return Array.isArray(tags) && tags.length > 0;
26
+ }
@@ -0,0 +1,38 @@
1
+ export function systemdAgentId(unit) {
2
+ let agent = null;
3
+ let section = null;
4
+ for (const raw of unit.split(/\r?\n/)) {
5
+ const line = raw.trim();
6
+ if (!line || /^[#;]/.test(line))
7
+ continue;
8
+ if (line.startsWith("[")) {
9
+ section = line.slice(1, -1);
10
+ continue;
11
+ }
12
+ if (section !== "Service")
13
+ continue;
14
+ if (line.endsWith("\\"))
15
+ return null;
16
+ const assignment = line.match(/^Environment\s*=\s*(.*)$/);
17
+ if (!assignment)
18
+ continue;
19
+ const value = assignment[1];
20
+ if (!value) {
21
+ agent = null;
22
+ continue;
23
+ }
24
+ const words = value.match(/"[^"\\]*"|'[^'\\]*'|[^\s"'\\]+/g);
25
+ if (!words || words.join(" ") !== value.replace(/\s+/g, " "))
26
+ return null;
27
+ for (const word of words) {
28
+ const token = /^["']/.test(word) ? word.slice(1, -1) : word;
29
+ if (!/^[A-Za-z_][A-Za-z0-9_]*=/.test(token))
30
+ return null;
31
+ if (token.startsWith("FLAIR_AGENT_ID=")) {
32
+ const id = token.slice("FLAIR_AGENT_ID=".length);
33
+ agent = /^[A-Za-z0-9._-]+$/.test(id) ? id : null;
34
+ }
35
+ }
36
+ }
37
+ return agent;
38
+ }
@@ -207,9 +207,9 @@ export function validateHumanReviewerId(reviewerId) {
207
207
  // lives server-side in resources/auto-promote-lib.ts (decideAutoPromote — the
208
208
  // UNATTENDED path), which IMPORTS these from here. The direction is deliberate
209
209
  // and established in this repo: a server file may import a PURE helper from src/
210
- // (resources/PromoteMemoryCandidate.ts and resources/soul-adk-guard.ts already
211
- // import this very module); it is a CLI file importing FROM resources/ that does
212
- // not survive npm packaging. Defining it here lets the CLI side
210
+ // (resources/PromoteMemoryCandidate.ts already imports this very module); it is
211
+ // a CLI file importing FROM resources/ that does not survive npm packaging.
212
+ // Defining it here lets the CLI side
213
213
  // (src/commands/rem.ts, `flair rem candidates`) and the server gate share ONE
214
214
  // implementation rather than a hand-kept pair.
215
215
  //
@@ -14,7 +14,7 @@
14
14
  * invokes `flair rem nightly run-once`, the runner module does the work.
15
15
  */
16
16
  import { existsSync, mkdirSync, chmodSync, rmSync } from "node:fs";
17
- import { resolve, dirname } from "node:path";
17
+ import { resolve, dirname, join } from "node:path";
18
18
  import { spawn } from "node:child_process";
19
19
  import { fileURLToPath } from "node:url";
20
20
  import { escapeXml } from "../lib/xml-escape.js";
@@ -93,16 +93,26 @@ function validateSchedule(hour, minute) {
93
93
  throw new Error(`minute must be an integer 0-59, got ${minute}`);
94
94
  }
95
95
  }
96
+ /**
97
+ * Quote a value as ONE POSIX shell word. Embedded single quotes are closed,
98
+ * escaped, and reopened, so the shell reads the value literally and never
99
+ * interprets `$()`, backticks, or quotes inside it.
100
+ */
101
+ export function quoteShimArg(value) {
102
+ return `'${value.replace(/'/g, "'\\''")}'`;
103
+ }
96
104
  function buildSubstitutions(opts, shimPath, flairBin, nodeBin) {
97
105
  validateSchedule(opts.hour, opts.minute);
98
106
  if (!/^[a-zA-Z0-9_-]+$/.test(opts.agentId)) {
99
107
  throw new Error(`invalid agent id: ${opts.agentId}`);
100
108
  }
109
+ const home = opts.homeOverride ?? resolveHome();
101
110
  return {
102
111
  FLAIR_BIN: flairBin,
103
112
  NODE_BIN: nodeBin,
104
113
  SHIM_PATH: shimPath,
105
- HOME: opts.homeOverride ?? resolveHome(),
114
+ ADMIN_PASS_FILE: resolve(opts.adminPassFile ?? join(home, ".flair", "admin-pass")),
115
+ HOME: home,
106
116
  AGENT_ID: opts.agentId,
107
117
  FLAIR_URL: opts.flairUrl,
108
118
  HOUR: String(opts.hour),
@@ -369,8 +379,15 @@ export function enableScheduler(opts) {
369
379
  `\`flair rem nightly enable\`.`);
370
380
  }
371
381
  const stderrLogPath = resolve(logsDir, "rem-nightly.stderr.log");
372
- // 1. Deploy the shim (always — both platforms invoke it).
373
- const shimContents = renderTemplate(readTemplate(templateRoot, "bin/flair-rem-nightly.sh.tmpl"), subs);
382
+ // 1. Deploy the shim (always — both platforms invoke it). Every path passed
383
+ // to the command is one POSIX single-quoted argument; none is double-quoted,
384
+ // so shell syntax inside a path stays literal.
385
+ const shimContents = renderTemplate(readTemplate(templateRoot, "bin/flair-rem-nightly.sh.tmpl"), {
386
+ ...subs,
387
+ NODE_BIN: quoteShimArg(subs.NODE_BIN),
388
+ FLAIR_BIN: quoteShimArg(subs.FLAIR_BIN),
389
+ ADMIN_PASS_FILE: quoteShimArg(subs.ADMIN_PASS_FILE),
390
+ });
374
391
  writeFileWithDir(shimPath, shimContents, 0o700);
375
392
  chmodSync(shimPath, 0o700);
376
393
  // 2. Write the scheduler entry.
@@ -27,12 +27,12 @@ server, which has them sign in at the identity provider configured under
27
27
  configures GitHub. The access token the app receives carries the login as its
28
28
  subject; for GitHub, that is the account's username.
29
29
 
30
- `/mcp` answers `initialize`, `ping` and `tools/list` for any valid token, and
31
- refuses a `tools/call` for an unknown tool name, before it looks at the mapping.
30
+ `/mcp` answers `initialize` and `ping` for any valid token, and refuses a
31
+ `tools/call` for an unknown tool name, before it looks at the mapping.
32
32
  On a `tools/call` for a known tool, Flair looks for a `Credential` of kind `idp`
33
33
  whose `idpSubject` is that login, that names a principal, and whose status is
34
- not `revoked`, and acts as that principal. There is no fallback to an anonymous
35
- or admin identity:
34
+ exactly `active`, and acts as that principal. There is no fallback to an
35
+ anonymous or admin identity:
36
36
 
37
37
  - **No mapping:** the call is refused. `/mcp` answers HTTP 200 with a JSON-RPC
38
38
  error:
@@ -41,6 +41,10 @@ or admin identity:
41
41
  {"jsonrpc":"2.0","id":1,"error":{"code":-32001,"message":"forbidden: token subject is not a provisioned flair agent"}}
42
42
  ```
43
43
 
44
+ - **The login's credentials are not `active` or name no principal:** refused
45
+ with code `-32001`. The message names one of those credentials and its stored
46
+ status (`revoked`, any other value, or no status), and says an operator must
47
+ re-link it.
44
48
  - **Mapped to a principal that does not exist:** refused with code `-32001` and
45
49
  a message naming the principal.
46
50
  - **Mapped to a deactivated principal:** refused; see
@@ -48,6 +52,10 @@ or admin identity:
48
52
  - **The credential or the principal could not be read:** refused with code
49
53
  `-32000` and a message starting `unavailable:`.
50
54
 
55
+ A `tools/list` reads the mapping the same way and answers each case above
56
+ except **No mapping** with the same error; with no mapping it returns a tool
57
+ list.
58
+
51
59
  ### Map a person to a principal
52
60
 
53
61
  `flair mcp enable` writes the mapping in its `identity-mapping` step:
@@ -90,10 +98,41 @@ read-back described under [One mapping per login](#one-mapping-per-login)
90
98
  passed. The command stops before restarting the instance, reports the
91
99
  `secrets-provisioning` step as not applied, and exits non-zero.
92
100
 
101
+ ### Link or unlink one login
102
+
103
+ `flair principal link` does only the mapping step, on an instance that is
104
+ already enabled:
105
+
106
+ ```bash
107
+ flair principal link alice --instance https://flair.example.com \
108
+ --idp-subject alice --admin-pass "$TARGET_ADMIN_PASS"
109
+ ```
110
+
111
+ The principal must already exist: a missing one is refused by name. A subject
112
+ already mapped to that principal is reported with nothing written; a subject
113
+ mapped to a different principal is refused unless `--replace` moves it, which
114
+ prints the prior principal and any superseded credential. More than one active
115
+ principal mapped to the subject is refused before writing.
116
+ `--instance` (else `FLAIR_URL`) must be HTTPS: these commands
117
+ send the target's admin credential to its operations API, which on a hosted
118
+ instance is the instance host at port 9925. <!-- docs-freshness-allow: hosted operations API port, not the data port -->
119
+ An unparseable URL, `localhost`, a `.local` name, or a loopback, unspecified,
120
+ RFC1918, link-local or IPv6 unique-local address literal is refused before any
121
+ request, and a REMOTE target gets no `--admin-pass` fallback (the rule
122
+ `flair mcp enable` applies).
123
+
124
+ `flair principal unlink <principal> --idp-subject <login>` defaults to provider
125
+ `github`; pass `--idp-provider <name>` for a different provider. Unlink reports
126
+ success only after confirmed updates and no resolvable subject mapping on
127
+ readback. With `FLAIR_MCP_JIT_PROVISION` on, a known tool call after an
128
+ unmapped login may provision a new principal.
129
+ `flair principal links <principal>` lists a principal's current mappings, and
130
+ both take the same `--instance` and `--admin-pass`.
131
+
93
132
  ### One mapping per login
94
133
 
95
- `flair mcp enable` and the resolver both count a login's `idp` credential unless
96
- its status is `revoked` (the resolver also skips one that names no principal).
134
+ `flair mcp enable` and the resolver both treat a login's `idp` credential as a
135
+ mapping only when its status is exactly `active` and it names a principal.
97
136
  `flair mcp enable` keeps one such credential per login, whatever the provider
98
137
  name:
99
138
 
@@ -102,14 +141,38 @@ name:
102
141
  says `re-pointed`. Calls from that login then act as the principal the
103
142
  credential names. Memories are not moved or merged; each principal keeps its
104
143
  own.
105
- - If the login has a credential that is not `revoked` under a different
106
- provider name, the run revokes it (the row stays, with status `revoked`) and
107
- prints its id after `SUPERSEDED:`.
108
- - After writing, it reads the login's credentials back and fails unless exactly
109
- one of them is not `revoked` and that one is the credential it wrote. It does
110
- not compare the principal that credential names: `bootstrap`'s `agentId` (see
111
- [Check who you are](#check-who-you-are)) shows which principal the login
112
- resolves to.
144
+ - If the login has a credential under a different provider name whose status
145
+ is `active` and that names a principal, the run revokes it (the row stays,
146
+ with status `revoked`) and prints its id after `SUPERSEDED:`. A credential
147
+ whose status is anything else is not changed.
148
+ - After writing, it requires exactly one resolvable (principal-bearing) active
149
+ credential matching the written id and principal.
150
+ Principal-less legacy rows are skipped and may remain active.
151
+
152
+ ### Who writes a mapping
153
+
154
+ Through the `Credential` resource, only an administrator or Flair itself
155
+ creates an `idp` credential, changes its kind or identity fields, or
156
+ reactivates it. Flair writes mappings through `flair mcp enable`,
157
+ `flair principal link` and `unlink`, and just-in-time provisioning (below, and
158
+ the XAA grant's); an administrator can also write one through the `Credential`
159
+ resource.
160
+
161
+ On POST, PUT and PATCH, the checks that run first decide before this rule:
162
+ authentication, the owner checks, and the request checks (the rate limit and
163
+ kind validation on POST and PUT, the single-record body on PATCH). For a
164
+ non-admin agent, the owner checks keep their own 403: on PATCH and PUT the
165
+ owner-field guard refuses a change to the credential's principal, PUT refuses
166
+ a body that names another principal, and PATCH, PUT and DELETE refuse a write
167
+ to another principal's credential. On POST, a non-admin agent's credential is
168
+ stamped with its own principal; a `principalId` in the body is not used. An
169
+ administrator may write another principal's credential. A non-admin agent's
170
+ write that passes those checks gets HTTP 403
171
+ with the error `idp_mapping_admin_only` when it would create an `idp`
172
+ credential, change a credential's kind to or from `idp`, change an `idp`
173
+ credential's provider or subject, or change its status to anything other than
174
+ `revoked` (so it cannot reactivate one). A non-admin agent may relabel its own
175
+ `idp` credential, set its status to `revoked`, and delete it.
113
176
 
114
177
  ### Just-in-time provisioning
115
178
 
@@ -165,17 +228,20 @@ instead (see below).
165
228
  `client_id` before it sends the person to the identity provider; the person
166
229
  continues from there.
167
230
  - **Public clients with PKCE.** The document of an app that signs people in
168
- must declare `token_endpoint_auth_method: none`, or leave the field out. Any
169
- other value is refused with `invalid_client`. Every authorization request must
170
- carry a PKCE `code_challenge` with method `S256`. With the shipped
171
- `config.yaml`, the server's metadata advertises `none`, `client_secret_basic`
172
- and `client_secret_post` as token endpoint auth methods (the last two apply
173
- only to registered clients) and does not advertise `private_key_jwt`. Setting
231
+ may declare its token endpoint auth method. With the shipped `config.yaml` it
232
+ must be `token_endpoint_auth_method: none`, or the field left out; any other
233
+ value is refused with `invalid_client`. Every authorization request must
234
+ carry a PKCE `code_challenge` with method `S256`. With MCP enabled and a
235
+ provider configured, the shipped server advertises `none`,
236
+ `client_secret_basic` and `client_secret_post` as token endpoint auth methods (the last two apply only to registered clients)
237
+ and does not advertise `private_key_jwt`. Setting
174
238
  `mcp.clientCredentials.enabled: true`, which turns on the headless grant,
175
239
  changes the metadata: it then also lists `private_key_jwt`, the
176
- `client_credentials` grant type and `EdDSA` as the assertion signing
177
- algorithm. The document of an app that signs people in is still refused
178
- unless it declares `none` or leaves the field out.
240
+ `client_credentials` grant type and `RS256`, `ES256` and `EdDSA` as the
241
+ assertion signing algorithms. Setting
242
+ `mcp.clientIdMetadataDocuments.privateKeyJwt.enabled: true` also lists
243
+ `private_key_jwt` and those three algorithms. With either setting, a document
244
+ may declare `private_key_jwt` (with usable keys) instead of `none`.
179
245
 
180
246
  ### Changing the list
181
247
 
@@ -216,19 +282,31 @@ an upgrade replaces that file, run the command again or edit the file.
216
282
 
217
283
  ### ChatGPT
218
284
 
219
- ChatGPT's published metadata document, `https://chatgpt.com/oauth/client.json`,
220
- declares `token_endpoint_auth_method: private_key_jwt`. The `@harperfast/oauth`
221
- version Flair pins, 2.5.0, accepts only `none` in the metadata document of an
222
- app that signs people in, so ChatGPT's CIMD client is refused on 2.5.0 even with
223
- `chatgpt.com` on the list. A sign-in that presents that document gets HTTP 400,
224
- error `invalid_client`, and the description
225
- `token_endpoint_auth_method 'private_key_jwt' is not supported for interactive CIMD clients; use 'none'`.
226
- Stored registrations are a separate path (see [2. Which apps](#2-which-apps)),
227
- and registration of new clients is off.
285
+ With MCP enabled and a provider configured, admitting ChatGPT's CIMD client
286
+ requires `chatgpt.com` in `mcp.clientIdMetadataDocuments.allowedHosts` and
287
+ `mcp.clientIdMetadataDocuments.privateKeyJwt.enabled: true`. ChatGPT's assertion
288
+ uses the token-endpoint URL as its audience, so the pinned `@harperfast/oauth`
289
+ 2.9.0 also requires this exception in the deployed `config.yaml`:
290
+
291
+ ```yaml
292
+ '@harperfast/oauth':
293
+ mcp:
294
+ clientIdMetadataDocuments:
295
+ allowedHosts:
296
+ - claude.ai
297
+ - claude.com
298
+ - chatgpt.com
299
+ privateKeyJwt:
300
+ enabled: true
301
+ tokenEndpointAudience:
302
+ clientIds:
303
+ - https://chatgpt.com/oauth/client.json
304
+ expiresAt: '2026-11-01T00:00:00Z'
305
+ ```
228
306
 
229
- > **Upstream:** verification of `private_key_jwt` for interactive clients is in
230
- > progress upstream in
231
- > [HarperFast/oauth#245](https://github.com/HarperFast/oauth/pull/245).
307
+ Use the exact client ID and an operator-chosen future ISO 8601 `expiresAt`;
308
+ the exception stops accepting the token-endpoint audience at that expiry.
309
+ Restart Flair after editing the configuration.
232
310
 
233
311
  ## 3. What they can touch
234
312
 
@@ -269,24 +347,57 @@ A connection acts as its principal:
269
347
 
270
348
  ### Revoking access
271
349
 
272
- Deactivate the principal, on the Flair host, with `FLAIR_ADMIN_PASS` set or
273
- `--admin-pass`:
350
+ Deactivate or reactivate a local principal with `FLAIR_ADMIN_PASS` set or
351
+ `--admin-pass` (and neither `--instance` nor `FLAIR_URL` set):
274
352
 
275
353
  ```bash
276
354
  flair principal disable alice
355
+ flair principal enable alice
356
+ ```
357
+
358
+ For a principal on a remote instance, pass the instance URL and its admin
359
+ password explicitly. These commands share two precedence and credential rules
360
+ with `flair mcp enable`: an explicit `--instance` wins over `FLAIR_URL`, and a
361
+ remote operation requires an explicit `--admin-pass`. The principal commands accept
362
+ explicit loopback targets; `flair mcp enable` accepts loopback or unspecified targets
363
+ for the local restart but refuses local issuers.
364
+
365
+ ```bash
366
+ flair principal disable alice \
367
+ --instance https://flair.example.com \
368
+ --admin-pass "$TARGET_ADMIN_PASS"
369
+ flair principal enable alice \
370
+ --instance https://flair.example.com \
371
+ --admin-pass "$TARGET_ADMIN_PASS"
277
372
  ```
278
373
 
279
- When the operations API accepts the update, it prints
280
- `✅ Principal 'alice' deactivated`.
281
-
282
- - It sends an `update` to the operations API at `127.0.0.1` on the machine it
283
- runs on (port from `--ops-port`, `FLAIR_OPS_PORT` or the local Flair config).
284
- It has no option for a remote instance.
285
- - The update sets the principal's `status` to `deactivated`, and its
286
- `updatedAt`, and nothing else: the principal's memories and its login mapping
287
- stay. The operations API of Harper 5.2.8, the version Flair pins, also accepts
288
- an update for an id that has no record, so the ✅ line does not show that the
289
- principal exists.
374
+ Set `TARGET_ADMIN_PASS` to that instance's admin password before running the
375
+ remote example. A success line appears only after the command reads `alice`,
376
+ the operations API names it in the update result, and a read-back shows the
377
+ requested status; the line reports that read-back status.
378
+
379
+ - On the local path it sends an `update` to the operations API at `127.0.0.1`
380
+ on the machine it runs on. The port precedence is a valid explicit
381
+ `--ops-port`, then `FLAIR_OPS_PORT`, then `opsPort` in the local Flair config,
382
+ then one less than the resolved HTTP port. An invalid explicit `--ops-port`
383
+ is refused with a remedy; it never falls through to a lower-precedence port.
384
+ - With `--instance` (or `FLAIR_URL`) it sends the same `update` to the ops API
385
+ derived from that served instance URL, using the `flair mcp enable` hosted
386
+ operations port convention. A remote target requires an explicit
387
+ `--admin-pass`: `FLAIR_ADMIN_PASS` and `~/.flair/admin-pass` are
388
+ this machine's local credentials and are never sent to another instance.
389
+ `FLAIR_TARGET` and `FLAIR_OPS_TARGET` do not select a principal target.
390
+ Redirects, unconfirmed results, and requests that fail or time out are
391
+ refused with a non-zero exit. Diagnostics omit URL userinfo, query values,
392
+ and unexpected response values; an unparseable target is printed only as
393
+ `<unparseable URL>`.
394
+ - Disable sets the principal's `status` to `deactivated`; enable sets it to
395
+ `active`. Both update its `updatedAt` and nothing else: the principal's
396
+ memories and its login mapping stay. Harper can accept an update for an id
397
+ that has no record, so the command reads the principal first and refuses
398
+ `no principal <id>` before any update when no row exists; a read that fails
399
+ or returns an unreadable body is refused as unverified rather than as
400
+ missing.
290
401
  - Flair reads the principal's status on every `tools/call` for a known tool, and
291
402
  refuses those calls for a deactivated principal, including calls that carry a
292
403
  token issued before the change:
@@ -299,8 +410,8 @@ When the operations API accepts the update, it prints
299
410
  401 `{"error":"principal_deactivated"}`.
300
411
  - Disabling does not revoke OAuth tokens: they stay valid until they expire,
301
412
  and their tool calls are refused. Setting the status back to `active`
302
- restores access for tokens that are still valid. There is no
303
- `flair principal enable` command.
413
+ restores access for tokens that are still valid. `flair principal enable`
414
+ sets the status to `active`.
304
415
 
305
416
  To close `/mcp` for everyone, unset `FLAIR_MCP_OAUTH` in the instance's
306
417
  environment (or set it to `0`) and restart the instance; `flair mcp disable`
@@ -339,7 +450,9 @@ instance's admin password.
339
450
 
340
451
  Create a GitHub OAuth app whose callback URL is
341
452
  `https://flair.example.com/oauth/github/callback` (the command prints this URL
342
- too). Then run:
453
+ too). The command stages `OAUTH_GITHUB_CLIENT_ID`, `OAUTH_GITHUB_CLIENT_SECRET`
454
+ and `OAUTH_GITHUB_REDIRECT_URI=<public-origin>/oauth` using `--issuer`
455
+ (default: `--instance`). Then run:
343
456
 
344
457
  ```bash
345
458
  flair mcp enable \
@@ -352,8 +465,6 @@ flair mcp enable \
352
465
  When it finishes, it prints each step it ran, marked ✓ or ✗. The steps that
353
466
  act:
354
467
 
355
- - `signing-key` creates `~/.flair/mcp-signing-key.pem` (or the
356
- `--signing-key-file` path), or reuses the file if it exists.
357
468
  - `idp-credentials` checks that the OAuth app's client id and secret are
358
469
  present; in a terminal, the command prompts for them before the steps run.
359
470
  - `secrets-provisioning` always stages the secrets the instance needs in a local
@@ -441,7 +552,6 @@ shares her connector's memories.
441
552
 
442
553
  **How to choose:** use one principal when both apps should see the same private
443
554
  memories. Keep two when you want to revoke or audit them separately.
444
- ChatGPT's CIMD client cannot be the second app yet; see [ChatGPT](#chatgpt).
445
555
 
446
556
  **Check:** `bootstrap` in each app returns the `agentId` you chose.
447
557
  **Revoke:** `flair principal disable` for the principal you want to stop.