@tpsdev-ai/flair 0.56.0 → 0.57.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 (63) hide show
  1. package/README.md +16 -17
  2. package/dist/build-info.json +3 -3
  3. package/dist/cli.js +115 -14
  4. package/dist/commands/agent.js +22 -15
  5. package/dist/commands/bridge.js +40 -3
  6. package/dist/commands/doctor.js +52 -0
  7. package/dist/commands/federation.js +263 -37
  8. package/dist/commands/init.js +29 -4
  9. package/dist/lib/auth-resolve.js +46 -0
  10. package/dist/lib/instance-identity-row.js +580 -0
  11. package/dist/lib/redact-token-id.js +197 -0
  12. package/dist/resources/AgentSeed.js +4 -1
  13. package/dist/resources/Asset.js +3 -11
  14. package/dist/resources/Credential.js +4 -10
  15. package/dist/resources/Federation.js +232 -78
  16. package/dist/resources/Integration.js +8 -32
  17. package/dist/resources/Memory.js +58 -16
  18. package/dist/resources/MemoryBootstrap.js +19 -12
  19. package/dist/resources/MemoryCandidate.js +3 -11
  20. package/dist/resources/MemoryDedupStats.js +1 -1
  21. package/dist/resources/MemoryFeed.js +10 -2
  22. package/dist/resources/MemoryGrant.js +19 -40
  23. package/dist/resources/MemoryUsage.js +7 -20
  24. package/dist/resources/Relationship.js +3 -11
  25. package/dist/resources/SemanticSearch.js +25 -13
  26. package/dist/resources/auth-middleware.js +32 -5
  27. package/dist/resources/bm25.js +13 -14
  28. package/dist/resources/federation-cleanup.js +289 -51
  29. package/dist/resources/health.js +48 -8
  30. package/dist/resources/in-process-api.js +2 -1
  31. package/dist/resources/instance-create-lock.js +363 -0
  32. package/dist/resources/instance-identity-rows.js +43 -0
  33. package/dist/resources/instance-identity.js +94 -10
  34. package/dist/resources/mcp-handler.js +9 -1
  35. package/dist/resources/mcp-tool-arguments.js +83 -0
  36. package/dist/resources/mcp-tools.js +4 -5
  37. package/dist/resources/memory-visibility.js +10 -7
  38. package/dist/resources/rate-limit.js +6 -4
  39. package/dist/resources/record-type-kit.js +47 -23
  40. package/dist/resources/search-readiness.js +7 -1
  41. package/dist/resources/semantic-retrieval-core.js +98 -3
  42. package/dist/resources/table-helpers.js +33 -0
  43. package/dist/resources/tool-descriptors/index.js +2 -2
  44. package/dist/src/lib/instance-identity-row.js +580 -0
  45. package/dist/src/lib/redact-token-id.js +197 -0
  46. package/docs/api-reference.md +1 -1
  47. package/docs/auth.md +5 -5
  48. package/docs/claude-code.md +5 -6
  49. package/docs/deploying-on-fabric.md +6 -3
  50. package/docs/embedding-in-a-harper-app.md +3 -3
  51. package/docs/federation.md +16 -9
  52. package/docs/hosted-on-fabric.md +4 -3
  53. package/docs/integrations.md +24 -15
  54. package/docs/mcp-clients.md +16 -12
  55. package/docs/n8n.md +8 -8
  56. package/docs/notes/mcp-oauth-model2.md +12 -17
  57. package/docs/openclaw.md +29 -28
  58. package/docs/spoke-bringup.md +14 -11
  59. package/docs/standalone-local.md +2 -2
  60. package/docs/supply-chain-policy.md +21 -8
  61. package/docs/system-requirements.md +1 -1
  62. package/docs/upgrade.md +2 -2
  63. package/package.json +1 -1
@@ -0,0 +1,197 @@
1
+ /**
2
+ * redact-token-id.ts — the ONE pairing-token-id redactor (flair#1902).
3
+ *
4
+ * A pairing-token id IS the credential a spoke redeems, so only its 8-character
5
+ * prefix may ever reach a log line. Three sites grew their own copy of this rule
6
+ * in one day (the cleanup sweep's per-token lines, its table-level lines, and the
7
+ * rollback reporter), so the class is fixed here rather than at each site: one
8
+ * deep redactor every line that can carry a token id passes through.
9
+ *
10
+ * This is HYGIENE, not a security boundary — an operator holds admin credentials
11
+ * and can read the table directly. But a token id printed in full in a log is a
12
+ * credential handed to whoever reads the log, and the same gap reappearing at a
13
+ * new site is the failure this module exists to end.
14
+ *
15
+ * What "deep" means: a string (a message OR a string field at any depth, an array
16
+ * element, or an object KEY) has each secret replaced; numbers, booleans and null
17
+ * pass through untouched; a PLAIN object is rebuilt with redacted keys and values.
18
+ * Object keys are redacted too — a `{ "<token-id>": ... }` map is exactly as much
19
+ * a leak as one in a value. A NON-plain object — a Date, Error, Map, Set or class
20
+ * instance — passes through unchanged: rebuilding it through `Object.entries`
21
+ * would lose its message or entries, and its String form is what a caller should
22
+ * log. A cyclic value terminates: a container already on the path is returned
23
+ * as-is rather than recursed into (a log helper must never crash the sweep).
24
+ *
25
+ * Two properties the naive `split(secret).join(prefix)` gets wrong, and this
26
+ * module gets right:
27
+ *
28
+ * - LENGTH GUARD: a secret shorter than MIN_SECRET_LENGTH characters is
29
+ * replaced by "[redacted]" in full. Cutting an 11-character id to its
30
+ * 8-character prefix leaves most of the id visible, which is not a redaction.
31
+ * Empty secrets are ignored (never a replacement of "" that would splice the
32
+ * replacement between every character).
33
+ * - ONE PASS, LONGEST FIRST: the secrets are matched in a SINGLE pass over the
34
+ * original text, longest secret first. Sequential replaces let a short secret
35
+ * that is a prefix of a longer one match first and strand the longer id's
36
+ * suffix — and let a later secret match inside text a previous replacement
37
+ * just inserted. A single left-to-right scan avoids both, and it deliberately
38
+ * does NOT build a RegExp: a pattern assembled from the secrets would run on
39
+ * caller-supplied text, and a ReDoS there is a worse failure than the leak.
40
+ *
41
+ * `createTokenRedactor(secrets)` compiles the matcher once; the sweep reuses one
42
+ * per tick rather than rebuilding the replacement rules (or copying the id list)
43
+ * for every line it logs.
44
+ */
45
+ /** How many leading characters of a long secret are kept. */
46
+ export const TOKEN_ID_PREFIX_LENGTH = 8;
47
+ /**
48
+ * Below this length, a secret is replaced in full: its "prefix" would be most of
49
+ * it. Pairing-token ids are 32 characters (`randomBytes(24).toString("base64url")`),
50
+ * so this bound is an untested assumption made explicit, not a live path — the
51
+ * guard exists so a short id can never be printed whole by a prefix rule.
52
+ */
53
+ export const MIN_SECRET_LENGTH = 12;
54
+ /** What a secret too short to prefix-cut becomes. */
55
+ export const FULLY_REDACTED = "[redacted]";
56
+ /** The replacement text for one secret. */
57
+ function replacementFor(secret) {
58
+ return secret.length < MIN_SECRET_LENGTH
59
+ ? FULLY_REDACTED
60
+ : `${secret.slice(0, TOKEN_ID_PREFIX_LENGTH)}…`;
61
+ }
62
+ /** Non-empty, de-duplicated secrets paired with their replacement, longest first. */
63
+ function secretReplacements(secrets) {
64
+ const seen = new Set();
65
+ const out = [];
66
+ for (const secret of secrets) {
67
+ if (typeof secret !== "string" || secret.length === 0)
68
+ continue;
69
+ if (seen.has(secret))
70
+ continue;
71
+ seen.add(secret);
72
+ out.push([secret, replacementFor(secret)]);
73
+ }
74
+ // Longest-first: the scan takes the LONGEST secret that starts at a position,
75
+ // so where two secrets overlap the longer one wins and no suffix of it is left
76
+ // stranded by a shorter secret matching first.
77
+ out.sort((a, b) => b[0].length - a[0].length);
78
+ return out;
79
+ }
80
+ /**
81
+ * Compile `secrets` into a redactor. Build it ONCE for a batch of lines and reuse
82
+ * it — the sweep logs many lines per tick, and recompiling per line is the
83
+ * quadratic cost this avoids.
84
+ *
85
+ * The scan walks the ORIGINAL text once: at each position it takes the longest
86
+ * secret that starts there (the list is longest-first), emits that secret's
87
+ * replacement, and advances past it; otherwise it copies one character. Text a
88
+ * replacement inserts is never re-scanned, and no RegExp is built from the
89
+ * secrets (so a token id can never become a pattern).
90
+ */
91
+ export function createTokenRedactor(secrets) {
92
+ const replacements = secretReplacements(secrets);
93
+ const redactMessage = (message) => {
94
+ if (replacements.length === 0 || message.length === 0)
95
+ return message;
96
+ let out = "";
97
+ let i = 0;
98
+ while (i < message.length) {
99
+ let matched;
100
+ for (const pair of replacements) {
101
+ if (message.startsWith(pair[0], i)) {
102
+ matched = pair;
103
+ break;
104
+ }
105
+ }
106
+ if (matched) {
107
+ out += matched[1];
108
+ i += matched[0].length;
109
+ }
110
+ else {
111
+ out += message[i];
112
+ i += 1;
113
+ }
114
+ }
115
+ return out;
116
+ };
117
+ return {
118
+ redactMessage,
119
+ redactValue: (value) => (replacements.length === 0 ? value : walk(value, redactMessage)),
120
+ };
121
+ }
122
+ function walk(value, redact) {
123
+ return walkDeep(value, redact, new Map());
124
+ }
125
+ /**
126
+ * A plain object: its prototype is `Object.prototype` or null. A Date, Error,
127
+ * Map, Set or class instance is NOT a plain object, so it is not rebuilt — it
128
+ * passes through UNREDACTED, and its String form is what a caller should log
129
+ * (every call site stringifies an error before it reaches the redactor).
130
+ */
131
+ function isPlainObject(value) {
132
+ const proto = Object.getPrototypeOf(value);
133
+ return proto === Object.prototype || proto === null;
134
+ }
135
+ /**
136
+ * Rebuild `value` with every string redacted. `copies` maps each container
137
+ * already rebuilt to its REDACTED copy, and the copy is registered before its
138
+ * children are walked: a sub-object reached twice (an alias) is the same
139
+ * redacted copy both times, and a cyclic value terminates by pointing at its own
140
+ * redacted copy. Returning the original for a repeated reference would hand back
141
+ * the unredacted container — the leak flair#1905's review found.
142
+ */
143
+ function walkDeep(value, redact, copies) {
144
+ if (typeof value === "string")
145
+ return redact(value);
146
+ if (Array.isArray(value)) {
147
+ const known = copies.get(value);
148
+ if (known !== undefined)
149
+ return known;
150
+ const out = [];
151
+ copies.set(value, out);
152
+ for (const v of value)
153
+ out.push(walkDeep(v, redact, copies));
154
+ return out;
155
+ }
156
+ if (value && typeof value === "object") {
157
+ if (!isPlainObject(value))
158
+ return value;
159
+ const known = copies.get(value);
160
+ if (known !== undefined)
161
+ return known;
162
+ const out = {};
163
+ copies.set(value, out);
164
+ for (const [key, v] of Object.entries(value)) {
165
+ // Define each rebuilt key as an OWN property. A bracket assignment
166
+ // (`out[redact(key)] = …`) for the key `__proto__` would set the COPY's
167
+ // prototype instead of defining a key, dropping it and giving the copy an
168
+ // attacker-chosen prototype — reachable whenever the input came from
169
+ // JSON.parse or Object.defineProperty (flair#1907).
170
+ Object.defineProperty(out, redact(key), {
171
+ value: walkDeep(v, redact, copies),
172
+ enumerable: true,
173
+ writable: true,
174
+ configurable: true,
175
+ });
176
+ }
177
+ return out;
178
+ }
179
+ // Numbers, booleans, null, undefined, functions, symbols: untouched.
180
+ return value;
181
+ }
182
+ /**
183
+ * A string with every secret replaced by its prefix (or `[redacted]` when the
184
+ * secret is too short to cut). The string-only convenience over the same
185
+ * implementation the deep redactor uses.
186
+ */
187
+ export function redactTokenMessage(message, secrets) {
188
+ return createTokenRedactor(secrets).redactMessage(message);
189
+ }
190
+ /**
191
+ * `value` with every secret replaced in every string at any depth — a message, a
192
+ * string field, an array element, and an object KEY — rebuilt so keys and values
193
+ * are both redacted. Non-string scalars pass through untouched.
194
+ */
195
+ export function redactTokenIds(value, secrets) {
196
+ return createTokenRedactor(secrets).redactValue(value);
197
+ }
@@ -197,7 +197,7 @@ The remedy is `flair upgrade` (the adapter), not a server upgrade alone.
197
197
  | Method | Path | Auth | Notes |
198
198
  |--------|------|------|-------|
199
199
  | GET | `/FederationInstance` | Admin Basic | Local instance identity (CLI / admin). Peers do not call this during pair. |
200
- | POST | `/FederationPair` | Pairing token + body-sig | Public at the Harper role gate. Handler validates token, signature, anti-replay. Response includes `instance {id, publicKey}` when this hub has an Instance row; `instance` is null if it does not (flair#839). The spoke CLI must not store an empty hub key (flair#822). Fabric uses the bootstrap-user triple from `flair federation token`. |
200
+ | POST | `/FederationPair` | Pairing token + body-sig | Public at the Harper role gate. Handler validates token, signature, anti-replay. Response includes `instance {id, publicKey}` when this hub has an Instance row; `instance` is null if it does not (flair#839). With several rows it answers `409 multiple_instance_rows` before the token is consumed, naming no row (the hub's log names them; flair#1883). The spoke CLI must not store an empty hub key (flair#822). Fabric uses the bootstrap-user triple from `flair federation token`. |
201
201
  | POST | `/FederationSync` | Peer body-sig | Public at the role gate. Merge Memory / Soul / Agent / Relationship (and classifier-ready Message). Originator + per-record signature checks. |
202
202
  | GET | `/FederationPeers` | Admin Basic | Known peers. |
203
203
  | GET / write | `/Instance` | Read: Ed25519. Write: admin | Instance row (`flair_…` id, role hub/spoke). |
package/docs/auth.md CHANGED
@@ -9,12 +9,12 @@ Different surfaces authenticate differently. The model in one place:
9
9
 
10
10
  | Surface | Auth | Scope | Notes |
11
11
  |---------|------|-------|-------|
12
- | **CLI / SDK clients** (`flair`, `flair-client`) | **Ed25519 per-agent** | Own writes; org-wide non-private reads | Default, recommended. Signs every request; an agent can never write as another, and reads are scoped to its own memories (any visibility) plus every other agent's **non-private** memories on the instance. |
13
- | **MCP server** (`@tpsdev-ai/flair-mcp`) | **Ed25519 per-agent** | Own writes; org-wide non-private reads | Same per-agent identity as the CLI — key auto-resolved from `~/.flair/keys/<agent>.key`. |
14
- | **OpenClaw / pi / Hermes plugins** | **Ed25519 per-agent** | Own writes; org-wide non-private reads | Same secure path; auto-detect agent identity. |
12
+ | **CLI / SDK clients** (`flair`, `flair-client`) | Ed25519 agent keys; administrator Basic on supported paths | Ordinary signed agents: own writes; own and org-wide non-private reads | Administrator agent roles and Basic credentials have broader authority. |
13
+ | **MCP server** (`@tpsdev-ai/flair-mcp`) | Ed25519 agent key; configured administrator Basic fallback | Ordinary signed agents: own writes; own and org-wide non-private reads | The key is auto-resolved from `~/.flair/keys/<agent>.key`; Basic is used when no key resolves and administrator credentials are configured. |
14
+ | **OpenClaw / pi / Hermes plugins** | Ed25519 agent keys; Pi can use configured administrator Basic fallback | Ordinary signed agents: own writes; own and org-wide non-private reads | OpenClaw identity comes from host context; Pi requires `FLAIR_AGENT_ID`; Hermes defaults to `hermes`. |
15
15
  | **`n8n-nodes-flair`** | **Harper admin-password Basic auth** | ⚠️ **Whole instance, read + write, including `private`** | The admin credential bypasses agent scoping entirely — every workflow gets read/write on the *entire* memory store, including other agents' `private`-marked memories, not just the org-wide non-private pool an Ed25519 identity would see. |
16
16
 
17
- **The default, secure path is Ed25519 per-agent** (see below): each agent holds its own key and signs every request. That guarantees **write isolation** — no agent can write as another — and identity-verified reads. It does **not** mean cross-agent reads are refused: within one Flair instance (one org), any verified agent can read any other agent's memory unless that memory is explicitly marked `visibility: private` (owner-only). The hard access boundary is the **federation edge** (a separate Flair instance / org), not reads within an instance. See [SECURITY.md](../SECURITY.md) for the full model. Use Ed25519 per-agent everywhere you can regardless — it's still what makes writes and identity trustworthy.
17
+ **The default, secure path is Ed25519 per-agent** (see below): each agent holds its own key and signs every request. For ordinary signed agents, this enforces write ownership: they can write only their own records and read their own plus other agents' non-private records. Administrator credentials and administrator agent roles have broader authority, including access to private records. The hard access boundary is the **federation edge** (a separate Flair instance / org), not reads within an instance. See [SECURITY.md](../SECURITY.md) for the full model. Use Ed25519 per-agent everywhere you can regardless — it's still what makes writes and identity trustworthy.
18
18
 
19
19
  ### Known limitation — n8n uses admin-password Basic auth
20
20
 
@@ -49,7 +49,7 @@ never an existence signal. The adapter write-up is
49
49
 
50
50
  Flair has no `mode`/`shape` config setting — the shape you get is emergent from *how you provision principals*, not something you declare:
51
51
 
52
- - **Personal (the default).** `flair init` mints ONE agent identity and wires that same `FLAIR_AGENT_ID` into every MCP client it configures (Claude Code, Codex, Gemini, Cursor). One human driving several AI clients ends up with one canonical principal and one Ed25519 keypair — all clients share ownership of the same memory. This is intentional, not a limitation: all clients see each other's private rows (one human's memory, one view), a fact re-asserted from two different clients dedups to one memory, and usage counting treats the principal as one contributor.
52
+ - **Personal.** `flair init --agent <id>` creates (or reuses) ONE agent identity and wires that same `FLAIR_AGENT_ID` into every MCP client it configures (Claude Code, Codex, Gemini, Cursor). One human driving several AI clients ends up with one canonical principal and one Ed25519 keypair — all clients share ownership of the same memory. This is intentional, not a limitation: all clients see each other's private rows (one human's memory, one view). Writes with fresh IDs create separate records even when the server reports a dedup match; writes that reuse an existing ID update that record. Usage counting treats the shared principal as one contributor.
53
53
  - **Org (multiple real agents).** `flair agent add <id>` mints a distinct principal — its own keypair, its own ownership boundary — for each real agent that should be a separate identity. Wire each principal's own `FLAIR_AGENT_ID` into its own client(s).
54
54
 
55
55
  Nothing in flair validates which shape you're in; a personal install that later grows into an org just runs `flair agent add` for the new distinct identities it needs.
@@ -82,7 +82,7 @@ Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`
82
82
 
83
83
  ---
84
84
 
85
- That's it. Claude Code will now bootstrap context on start and store important things as it works.
85
+ This is a prompt-driven CLI setup: Claude must choose to run these commands. For MCP tools and automatic startup recall, run `flair init --agent my-project --client claude-code`, restart Claude Code, and verify the hook with `flair hook status --harness claude-code`; these prompt instructions do not guarantee automatic capture.
86
86
 
87
87
  ## Multiple Projects
88
88
 
@@ -94,19 +94,18 @@ flair agent add project-beta
94
94
  flair agent add infra-ops
95
95
  ```
96
96
 
97
- Each project's `CLAUDE.md` uses its own agent ID. Memories are fully isolated between projects.
97
+ Each project's `CLAUDE.md` uses its own agent ID. Writes carry an `agentId` field (tags are optional); reads use owner plus visibility.
98
98
 
99
99
  ## Subagents
100
100
 
101
101
  Claude Code subagents (spawned via `/run` or background tasks) can share the parent's memory:
102
102
 
103
103
  ### Subagents
104
- Subagents share memory with the parent session. Use the same agent ID:
105
- FLAIR_AGENT_ID=my-project
104
+ Subagents share memory with the parent session when they use the same agent ID (to share, set `FLAIR_AGENT_ID=my-project`). A subagent with its own agent ID owns what it writes, but this is not isolation: only its private records are hidden from other agents, and it can still read other agents' non-private records. Writes without an explicit visibility default by durability: persistent and permanent are shared, standard and ephemeral are private.
106
105
 
107
106
  When spawning subagents, pass the agent ID so they can access shared context.
108
107
 
109
- Or give subagents their own identity for isolation:
108
+ Or give subagents their own identity, so each owns what it writes (ownership, not isolation):
110
109
 
111
110
  ```bash
112
111
  flair agent add my-project-review # code review subagent
@@ -206,4 +205,4 @@ const context = await flair.bootstrap({ maxTokens: 4000 })
206
205
  - **Use durability wisely.** Most things are `standard`. Only promote to `persistent` for things that should survive months.
207
206
  - **Search is semantic.** "deployment issues" finds memories about "CI pipeline failures" — you don't need exact keywords.
208
207
  - **Temporal queries work.** "What happened today" and "what did we ship recently" are understood.
209
- - **Dedup is automatic.** Writing the same fact twice won't create duplicates (0.7 similarity threshold).
208
+ - **Dedup is a report, not a write guard.** A successful create is stored even when it matches an earlier memory. For eligible creates, the server checks the top active candidate from the same agent using writer-overridable cosine and Jaccard thresholds, and returns `deduplicated` and `matchedId` on a match.
@@ -164,16 +164,19 @@ No shell on the hub, so mint the token remotely rather than over `ssh`:
164
164
 
165
165
  ```bash
166
166
  # On any machine — note --ops-target, this hits the ops API
167
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat /path/to/hub-admin-pass)" flair federation token \
167
+ (umask 077; set -C; flair federation token --admin-pass-file /path/to/hub-admin-pass \
168
168
  --target https://<cluster>.<org>.harperfabric.com \
169
169
  --ops-target <ops-url> > ./pair-triple.json)
170
170
 
171
171
  # On the spoke
172
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<cluster>.<org>.harperfabric.com \
172
+ flair federation pair https://<cluster>.<org>.harperfabric.com \
173
+ --admin-pass-file ~/.flair/admin-pass \
173
174
  --token-from ./pair-triple.json
174
175
  ```
175
176
 
176
- `federation token` takes `--admin-pass`, **not** `--admin-pass-file`. The triple holds a
177
+ `federation token` and `federation pair` both take `--admin-pass-file`, reading the
178
+ password in-process (mode 0600 enforced) so it stays out of shell history and the process
179
+ list; `--admin-pass` still works but lands in both, and `FLAIR_ADMIN_PASS` suits CI. The triple holds a
177
180
  one-time credential — delete it after pairing (60-min TTL, `--ttl`). `set -C` refuses to
178
181
  overwrite an existing `pair-triple.json`, so remove an old one first.
179
182
 
@@ -272,13 +272,13 @@ flair memory search "deploy schedule" --agent mybot
272
272
  Federation, which has no in-process equivalent:
273
273
 
274
274
  ```bash
275
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token > triple.json)
276
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from ./triple.json
275
+ (umask 077; set -C; flair federation token --admin-pass-file ~/.flair/admin-pass > triple.json)
276
+ flair federation pair <hub-url> --admin-pass-file ~/.flair/admin-pass --token-from ./triple.json
277
277
  flair federation sync enable --interval 300
278
278
  flair federation status
279
279
  ```
280
280
 
281
- `set -C` makes the redirect refuse an existing `triple.json` (and `umask 077` only modes a file it creates); remove an old one first (`rm triple.json`). `--admin-pass` is also accepted but puts the password in shell history and process listings; prefer the environment form above (or a secret manager).
281
+ `set -C` makes the redirect refuse an existing `triple.json` (and `umask 077` only modes a file it creates); remove an old one first (`rm triple.json`). `--admin-pass-file` reads the password in-process (mode 0600 enforced), so it stays out of shell history and the process list; `--admin-pass` is also accepted but lands in both, and `FLAIR_ADMIN_PASS` suits CI.
282
282
 
283
283
  `sync enable` landed **after 0.30.0**; on an older install, schedule the one-shot yourself.
284
284
 
@@ -35,7 +35,7 @@ Pairing connects a spoke to a hub with mutual key pinning and an auth-aware hand
35
35
  On the hub machine, the admin runs `flair federation token`. The command emits a JSON triple containing a one-time bootstrap credential:
36
36
 
37
37
  ```bash
38
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token
38
+ flair federation token --admin-pass-file ~/.flair/admin-pass
39
39
  ```
40
40
 
41
41
  Output (a single JSON object):
@@ -56,10 +56,10 @@ On the spoke machine:
56
56
 
57
57
  ```bash
58
58
  # From a file
59
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from /path/to/triple.json
59
+ flair federation pair <hub-url> --admin-pass-file ~/.flair/admin-pass --token-from /path/to/triple.json
60
60
 
61
61
  # From stdin
62
- cat triple.json | FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from -
62
+ cat triple.json | flair federation pair <hub-url> --admin-pass-file ~/.flair/admin-pass --token-from -
63
63
  ```
64
64
 
65
65
  **4. Behind the scenes**
@@ -76,20 +76,21 @@ Earlier designs relied on `allowCreate=true` combined with body-only authenticat
76
76
 
77
77
  ## Fabric Pairing Example
78
78
 
79
- A managed Harper Fabric hub has no shell. Mint the triple from any machine that can reach it, then pair from the spoke. `FLAIR_ADMIN_PASS` on that mint is the **hub/cluster** admin (the admin file on the hub host, or a secret manager), not the spoke's `~/.flair/admin-pass`. `--admin-pass` is also accepted but puts the password in shell history and process listings; prefer the environment form below. The full bring-up, including why `--ops-target` names port 9925, is [spoke-bringup.md §5a](spoke-bringup.md#harper-fabric-hub-no-shell). <!-- docs-freshness-allow: Fabric ops API port, not legacy data port -->
79
+ A managed Harper Fabric hub has no shell. Mint the triple from any machine that can reach it, then pair from the spoke. The `--admin-pass-file` on that mint is the **hub/cluster** admin (the admin file on the hub host, or a secret manager), not the spoke's `~/.flair/admin-pass`. `--admin-pass-file` reads the password in-process (mode 0600 enforced) so it stays out of shell history and the process list; `--admin-pass` is also accepted but lands in both, and `FLAIR_ADMIN_PASS` suits CI. The full bring-up, including why `--ops-target` names port 9925, is [spoke-bringup.md §5a](spoke-bringup.md#harper-fabric-hub-no-shell). <!-- docs-freshness-allow: Fabric ops API port, not legacy data port -->
80
80
 
81
81
  ```bash
82
82
  # 1. On any machine (the spoke itself is fine) — no ssh, no scp.
83
83
  # umask 077 sets the mode of a file the redirect CREATES; set -C makes the redirect
84
84
  # refuse to overwrite an existing one, so a retry cannot truncate-and-reuse a looser file.
85
- # /path/to/hub-admin-pass is a 0600 file holding the HUB admin password, not ~/.flair/admin-pass on this machine; a literal here would land in shell history.
86
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat /path/to/hub-admin-pass)" flair federation token \
85
+ # /path/to/hub-admin-pass is a 0600 file holding the HUB admin password, not ~/.flair/admin-pass on this machine.
86
+ (umask 077; set -C; flair federation token --admin-pass-file /path/to/hub-admin-pass \
87
87
  --target https://<hub>.<org>.harperfabric.com \
88
88
  --ttl 60 \
89
89
  --ops-target https://<hub>.<org>.harperfabric.com:9925 > ./pair-triple.json) # docs-freshness-allow: Fabric ops API port, not legacy data port
90
90
 
91
91
  # 2. On the spoke — the SPOKE admin password (its own ~/.flair/admin-pass) writes the local Peer row; the mint above used the hub admin
92
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<hub>.<org>.harperfabric.com \
92
+ flair federation pair https://<hub>.<org>.harperfabric.com \
93
+ --admin-pass-file ~/.flair/admin-pass \
93
94
  --token-from ./pair-triple.json
94
95
  ```
95
96
 
@@ -105,10 +106,16 @@ the observability limits of a node you have no shell on. See
105
106
  Push local changes to the hub, once:
106
107
 
107
108
  ```bash
108
- flair federation sync --admin-pass <password>
109
+ flair federation sync --admin-pass-file ~/.flair/admin-pass
109
110
  # Output: ✅ Synced 12 records (0 skipped) in 145ms
110
111
  ```
111
112
 
113
+ `sync` and `verify` take the admin password from `--admin-pass-file` (an owner-only
114
+ file, mode 0600 enforced). In CI, where a file is awkward, set `FLAIR_ADMIN_PASS`
115
+ instead: an explicit `--admin-pass-file` or `--admin-pass` overrides it, and giving
116
+ both the file and `--admin-pass` is a usage error. Avoid `--admin-pass` itself — it
117
+ lands in shell history and the process list.
118
+
112
119
  ### What a push sends
113
120
 
114
121
  Each sync pushes rows changed since the cursor from four tables: `Memory`, `Soul`, `Agent`, and `Relationship`. `Presence` is not in that set.
@@ -262,7 +269,7 @@ Records with `updatedAt` more than 5 minutes in the future are rejected. This pr
262
269
  | `flair federation sync disable [--remove-shim]` | Remove the scheduled sync driver |
263
270
  | `flair federation sync status` | Show whether the driver is installed and genuinely active |
264
271
  | `flair federation watch [--interval <s>]` | Run sync in a foreground loop for an interactive session (default 30s) |
265
- | `flair federation verify [--wait <s>] [--admin-pass <pass>]` | Write a canary, push it, and check each peer. Flag/file admin credentials authenticate the admin-gated peer listing. 401/403, unreachable, and revoked are UNVERIFIABLE (warning, exit 0); a reachable peer missing the canary still FAILs (exit 1). |
272
+ | `flair federation verify [--wait <s>] [--admin-pass-file <path>]` | Write a canary, push it, and check each peer. Flag/file admin credentials authenticate the admin-gated peer listing. 401/403, unreachable, and revoked are UNVERIFIABLE (warning, exit 0); a reachable peer missing the canary still FAILs (exit 1). |
266
273
  | `flair federation reachability` | Probe local instance + each paired peer (read-only) |
267
274
  | `flair federation token [--ttl <min>]` | Generate a one-time pairing token triple (hub only) |
268
275
 
@@ -213,13 +213,14 @@ See [upgrade.md](upgrade.md#upgrading-a-fabric-deployed-instance) for the full w
213
213
  Available. Pair a local spoke to a Fabric-hosted hub:
214
214
 
215
215
  ```bash
216
- # On any machine (no shell on the hub) — generate a pairing token triple. /path/to/hub-admin-pass is a 0600 file holding the HUB admin password (never a literal on the command line: it would land in shell history)
217
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat /path/to/hub-admin-pass)" flair federation token \
216
+ # On any machine (no shell on the hub) — generate a pairing token triple. /path/to/hub-admin-pass is a 0600 file holding the HUB admin password; --admin-pass-file reads it in-process, never as a literal on the command line
217
+ (umask 077; set -C; flair federation token --admin-pass-file /path/to/hub-admin-pass \
218
218
  --target https://<cluster>.<org>.harperfabric.com \
219
219
  --ops-target <ops-url> > ./pair-triple.json)
220
220
 
221
221
  # On the spoke — the SPOKE admin password (its own ~/.flair/admin-pass) writes the local Peer row
222
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<cluster>.<org>.harperfabric.com \
222
+ flair federation pair https://<cluster>.<org>.harperfabric.com \
223
+ --admin-pass-file ~/.flair/admin-pass \
223
224
  --token-from ./pair-triple.json
224
225
  ```
225
226
 
@@ -1,8 +1,8 @@
1
1
  # Flair integrations
2
2
 
3
- Where Flair already runs. Each integration shown here is a working surface — the same memory, federated across all of them, scoped per-agent by Ed25519 keys.
3
+ Where Flair already runs. Each integration can reach one shared Flair memory store; signed requests identify an agent, while other verified agents may read its non-private records, and n8n uses admin Basic auth.
4
4
 
5
- > **The point.** Memory should follow the agent across orchestrators. Every entry below pulls from the same Flair instance, sees the same `agentId` namespace, respects the same isolation. Pick whichever harness you're shipping in; the memory layer doesn't care.
5
+ > **The point.** Memory can follow an agent across orchestrators. Integrations using an ordinary Ed25519 agent key can write under that identity and read their own plus other agents' non-private records. Administrator agent roles have broader authority. n8n uses Harper administrator Basic auth; stdio MCP, Pi, LangGraph, and the wake runner can also use it when no signing key resolves. Administrator Basic auth can read private records and write under any agent ID. Choose an integration with its authentication and recall behavior in mind.
6
6
 
7
7
  ---
8
8
 
@@ -18,11 +18,11 @@ Where Flair already runs. Each integration shown here is a working surface — t
18
18
  | **Antigravity CLI** (`agy`) | [`flair-mcp`](#claude-code-cursor-codex-gemini-cli-continuedev-via-flair-mcp) | MCP config | `~/.gemini/config/mcp_config.json`; pickup by a live `agy` pending verification |
19
19
  | **Goose** (block/goose) | [`flair-mcp`](#claude-code-cursor-codex-gemini-cli-continuedev-via-flair-mcp) | MCP config | Goose ships native MCP support |
20
20
  | **DeepSeek Harness** (`dsh`) | [`flair-mcp`](deepseek-harness.md) | Cordis overlay | First-party MCP bridge; tools-only, reactive recall — [dedicated page](deepseek-harness.md) |
21
- | **LangGraph (TS)** | [`langgraph-flair`](#langgraph-typescript) | FlairClient | Drop-in `BaseStore` |
22
- | **OpenClaw** | [`openclaw-flair`](#openclaw) | Ed25519 | Native plugin + context engine |
21
+ | **LangGraph (TS)** | [`langgraph-flair`](#langgraph-typescript) | FlairClient | FlairStore provides get, put, delete, search, and batch (limitations apply) |
22
+ | **OpenClaw** | [`openclaw-flair`](#openclaw) | Ed25519 | Native plugin (context-engine slot left intact) |
23
23
  | **n8n** | [`n8n-nodes-flair`](#n8n) | FlairApi credential | Three nodes (chat memory, search, store) |
24
24
  | **Hermes Agent** | [`hermes-flair`](#hermes-agent) | Ed25519 | Python `MemoryProvider` |
25
- | **Pi agent** | [`pi-flair`](#pi-agent) | Ed25519 | Native pi extension (pi has no MCP support); `flair init --client pi` wires it, `flair doctor` checks it |
25
+ | **Pi agent** | [`pi-flair`](#pi-agent) | Ed25519 | Native pi extension (pi has no MCP support); with `--agent <id>` and wiring enabled, `flair init` attempts Pi wiring for `--client pi`, for detected Pi under `--client all`, or for detected Pi when `--client` is omitted; `--client none` and `--no-mcp` skip it. |
26
26
  | **Google ADK** (Python) | [`adk-flair`](../packages/adk-flair/README.md) | Ed25519 | `BaseMemoryService`; see [hosted auth](#hosted-flair-auth--your-agent-got-a-404) if you just got a 404 |
27
27
  | **Google ADK** (JS/TS) | [`@tpsdev-ai/adk-flair`](../packages/adk-flair-js/README.md) | Ed25519 | Same identity model as the Python package |
28
28
 
@@ -76,9 +76,12 @@ A verified agent that is not allowed the row gets 404, never 403. Anonymous by-i
76
76
 
77
77
  | Adapter | URL | Agent id | Keyfile | Hosted extras |
78
78
  |---|---|---|---|---|
79
- | **adk-flair** / **adk-flair-js** | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEYFILE` | `FLAIR_ALLOW_REMOTE_URL=1`, `FLAIR_HTTP_TIMEOUT` — [adk-flair README](../packages/adk-flair/README.md#hosted-flair) |
79
+ | **adk-flair** (Python) | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEYFILE` | `FLAIR_ALLOW_REMOTE_URL=1`, `FLAIR_HTTP_TIMEOUT` — [adk-flair README](../packages/adk-flair/README.md#hosted-flair) |
80
+ | **adk-flair-js** (JS/TS) | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEYFILE` | For a non-localhost URL, set `FLAIR_ALLOW_REMOTE_URL=1`; request timeout comes from constructor `timeoutMs` (default 2000 ms), not `FLAIR_HTTP_TIMEOUT` — [adk-flair-js README](../packages/adk-flair-js/README.md) |
80
81
  | **flair-mcp** / Cursor plugin | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEY_PATH` (optional; auto-resolved) | Key must be on the **npx host** |
81
- | **Hermes / pi / LangGraph** | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEY_PATH` or client `keyPath` | Same Ed25519 model |
82
+ | **Hermes** | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEY_PATH` or Hermes `key_path` | Same Ed25519 model |
83
+ | **Pi** | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEY_PATH` or Pi client `keyPath` | Same Ed25519 model |
84
+ | **LangGraph** | `FLAIR_URL` | `config.agentId` (required) | Signed requests use `config.privateKey`, `config.keyPath`, or automatic key candidates (`FLAIR_KEY_DIR`, then standard paths); it does not read `FLAIR_KEY_PATH`. | Admin credentials provide a Basic-auth fallback when no key is available. |
82
85
 
83
86
  n8n still uses Harper admin Basic auth — it is not this path. See [n8n.md](n8n.md#security).
84
87
 
@@ -88,7 +91,7 @@ n8n still uses Harper admin Basic auth — it is not this path. See [n8n.md](n8n
88
91
 
89
92
  [`@tpsdev-ai/flair-mcp`](https://www.npmjs.com/package/@tpsdev-ai/flair-mcp) is a [Model Context Protocol](https://modelcontextprotocol.io/) server that exposes Flair as a memory tool to any MCP-speaking client. One server, every MCP client.
90
93
 
91
- No install step needed — every snippet below uses `npx -y @tpsdev-ai/flair-mcp`, which fetches and runs the server on demand (zero-install). The fastest path is `flair init`, which detects and wires these clients for you. To wire by hand, drop the relevant snippet into each tool's MCP config:
94
+ No install step needed — every snippet below uses `npx -y @tpsdev-ai/flair-mcp`, which fetches and runs the server on demand (zero-install). The fastest path is `flair init --agent <id>`, which attempts to wire detected clients when wiring is enabled. To wire by hand, drop the relevant snippet into each tool's MCP config:
92
95
 
93
96
  **Claude Code** (user scope lives in `~/.claude.json` — the file `claude mcp add`, `flair init`, and `flair doctor` all read and write):
94
97
  ```bash
@@ -156,7 +159,7 @@ Full per-tool walkthrough including troubleshooting: [`docs/mcp-clients.md`](mcp
156
159
 
157
160
  ## LangGraph (TypeScript)
158
161
 
159
- [`@tpsdev-ai/langgraph-flair`](https://www.npmjs.com/package/@tpsdev-ai/langgraph-flair) implements LangGraph's `BaseStore`. Drop-in for `InMemoryStore`.
162
+ [`@tpsdev-ai/langgraph-flair`](https://www.npmjs.com/package/@tpsdev-ai/langgraph-flair) implements LangGraph's `BaseStore`. FlairStore provides get, put, delete, search, and batch, with the limitations below.
160
163
 
161
164
  ```bash
162
165
  npm install @tpsdev-ai/langgraph-flair
@@ -178,13 +181,13 @@ LangGraph **Python** support is on the roadmap (same `BaseStore` shape, Python a
178
181
 
179
182
  ## OpenClaw
180
183
 
181
- [`@tpsdev-ai/openclaw-flair`](https://www.npmjs.com/package/@tpsdev-ai/openclaw-flair) is the native OpenClaw plugin. Adds Flair as a memory provider AND registers the `flair` context engine that re-injects PERMANENT-tier rules (SOUL.md, IDENTITY.md, AGENTS.md) every turn.
184
+ [`@tpsdev-ai/openclaw-flair`](https://www.npmjs.com/package/@tpsdev-ai/openclaw-flair) is the native OpenClaw plugin. Adds Flair as a memory provider AND provides bootstrap through a `before_prompt_build` hook (context-engine slot left intact; the host's native memory section stays untouched).
182
185
 
183
186
  ```bash
184
187
  openclaw plugins install @tpsdev-ai/openclaw-flair
185
188
  ```
186
189
 
187
- Configuration via OpenClaw's standard plugin surface. See [`docs/openclaw.md`](openclaw.md) for the per-agent install pattern, including how to wire SOUL.md so behavioral anchors persist across long sessions without drift.
190
+ Configuration via OpenClaw's standard plugin surface. See [`docs/openclaw.md`](openclaw.md) for the per-agent install pattern. The host's own workspace files load each agent's `SOUL.md` / `AGENTS.md`; Flair does not manage or anchor these.
188
191
 
189
192
  ---
190
193
 
@@ -194,7 +197,11 @@ Configuration via OpenClaw's standard plugin surface. See [`docs/openclaw.md`](o
194
197
 
195
198
  - **FlairChatMemory** — drop-in chat-memory for n8n's AI Agent / LangChain workflow nodes. Same role as Postgres / Redis chat memory but with cross-orchestrator portability.
196
199
  - **FlairSearch** — semantic search over your Flair memories from any workflow.
197
- - **FlairApi** credential — Ed25519 keypair entry point for the agentId.
200
+ - **FlairWrite** — pipeline-mode node that writes a memory into Flair.
201
+
202
+ The FlairApi credential provides authentication.
203
+
204
+ **FlairApi credential** — Harper administrator password for Basic authentication; Agent ID selects memory ownership and does not restrict the credential's instance-wide authority.
198
205
 
199
206
  Install via the standard n8n community-node UI (Settings → Community nodes → `@tpsdev-ai/n8n-nodes-flair`) or:
200
207
 
@@ -222,15 +229,15 @@ Auth: TPS-Ed25519 (the same model the rest of Flair uses) — writes are isolate
222
229
 
223
230
  [`@tpsdev-ai/pi-flair`](https://www.npmjs.com/package/@tpsdev-ai/pi-flair) is the **native pi extension** for the [Pi coding agent](https://github.com/mariozechner/pi-coding-agent) — pi has no MCP client support, so this is a first-party plugin, not an MCP bridge. Memory + identity (`memory_search`, `memory_store`, `bootstrap`) for the pi runtime.
224
231
 
225
- Wire it (either form is equivalent):
232
+ To provision an agent and wire Pi, use the init command below; if the agent is already provisioned, install the extension with Pi's installer.
226
233
 
227
234
  ```bash
228
- flair init --client pi # writes a pinned "packages" entry into ~/.pi/agent/settings.json
235
+ flair init --agent my-agent --client pi # attempts to wire Pi with a CLI-version pin
229
236
  # or
230
237
  pi install npm:@tpsdev-ai/pi-flair
231
238
  ```
232
239
 
233
- Which produces:
240
+ When Flair writes a new Pi package entry, it uses this version-pinned form:
234
241
 
235
242
  ```json
236
243
  {
@@ -238,6 +245,8 @@ Which produces:
238
245
  }
239
246
  ```
240
247
 
248
+ `pi install npm:@tpsdev-ai/pi-flair` records the unpinned source `npm:@tpsdev-ai/pi-flair` instead.
249
+
241
250
  **Known trap:** the `extensions` settings key takes local file paths only — an `npm:` spec there is *silently ignored* by pi, so the tools never register ([#1346](https://github.com/tpsdev-ai/flair/issues/1346)). Package sources belong under `packages`. `flair doctor` detects pi, verifies the wiring, calls this exact misconfiguration out, and `flair doctor --fix` moves the entry.
242
251
 
243
252
  pi settings carry no per-package env, so identity comes from the environment that launches pi: