@tpsdev-ai/flair 0.63.0 → 0.63.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/SECURITY.md +55 -33
- package/dist/bridges/runtime/import-runner.js +4 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +243 -83
- package/dist/commands/agent.js +298 -72
- package/dist/commands/attention.js +2 -0
- package/dist/commands/bootstrap.js +2 -0
- package/dist/commands/bridge.js +10 -0
- package/dist/commands/doctor.js +87 -42
- package/dist/commands/export.js +141 -11
- package/dist/commands/import.js +36 -15
- package/dist/commands/init.js +373 -157
- package/dist/commands/keys.js +12 -8
- package/dist/commands/mcp.js +146 -62
- package/dist/commands/memory.js +5 -2
- package/dist/commands/migrate-harness-memory.js +9 -3
- package/dist/commands/principal.js +19 -14
- package/dist/commands/quality.js +23 -3
- package/dist/commands/reembed.js +468 -111
- package/dist/commands/search.js +2 -0
- package/dist/commands/service.js +25 -0
- package/dist/commands/status.js +130 -107
- package/dist/doctor-client.js +2 -23
- package/dist/federation/scheduler.js +148 -12
- package/dist/keystore.js +77 -10
- package/dist/lib/agent-key-file.js +509 -0
- package/dist/lib/agent-rotation-lock.js +249 -0
- package/dist/lib/atomic-write.js +2 -2
- package/dist/lib/auth-resolve.js +14 -14
- package/dist/lib/key-dir.js +203 -0
- package/dist/lib/launchd-management.js +7 -3
- package/dist/lib/local-instance-pair.js +8 -1
- package/dist/lib/node-alias-path.js +50 -2
- package/dist/lib/remote-admin-pass.js +157 -0
- package/dist/lib/scheduler-platform.js +13 -0
- package/dist/lib/service-repoint.js +13 -4
- package/dist/lib/skill-seed.js +35 -3
- package/dist/lib/terminal-text.js +32 -0
- package/dist/mcp-client-assertion.js +5 -4
- package/dist/resources/Memory.js +47 -3
- package/dist/resources/health.js +39 -22
- package/dist/resources/in-process-api.js +74 -11
- package/dist/resources/mcp-client-metadata-fields.js +4 -0
- package/dist/resources/mcp-handler.js +40 -1
- package/dist/resources/mcp-oauth.js +17 -1
- package/dist/resources/mcp-tool-scopes.js +69 -0
- package/dist/resources/mcp-tools.js +10 -0
- package/dist/resources/skill-version-write.js +16 -0
- package/dist/src/keystore.js +77 -10
- package/dist/src/lib/atomic-write.js +2 -2
- package/dist/src/lib/key-dir.js +203 -0
- package/dist/src/lib/scheduler-platform.js +13 -0
- package/docs/access-control.md +21 -12
- package/docs/api-reference.md +35 -24
- package/docs/auth.md +31 -22
- package/docs/deploying-on-fabric.md +10 -2
- package/docs/embedding-in-a-harper-app.md +7 -7
- package/docs/entity-vocabulary.md +4 -5
- package/docs/hosted-on-fabric.md +1 -1
- package/docs/secrets-and-keys.md +8 -13
- package/docs/upgrade.md +15 -5
- package/package.json +1 -1
package/docs/access-control.md
CHANGED
|
@@ -301,7 +301,7 @@ uses the token-endpoint URL as its audience, so the pinned `@harperfast/oauth`
|
|
|
301
301
|
tokenEndpointAudience:
|
|
302
302
|
clientIds:
|
|
303
303
|
- https://chatgpt.com/oauth/client.json
|
|
304
|
-
expiresAt: '
|
|
304
|
+
expiresAt: '<future ISO 8601 expiry>'
|
|
305
305
|
```
|
|
306
306
|
|
|
307
307
|
Use the exact client ID and an operator-chosen future ISO 8601 `expiresAt`;
|
|
@@ -323,6 +323,11 @@ A connection acts as its principal:
|
|
|
323
323
|
- **Admin** authority applies to a `/mcp` connection only when the principal's
|
|
324
324
|
Agent record has `role: admin`. The principals that `flair mcp enable` and
|
|
325
325
|
just-in-time provisioning create are not admins.
|
|
326
|
+
- **Scopes** narrow a connection: each tool requires one OAuth scope (listed in
|
|
327
|
+
[auth.md](auth.md#scopes)), and a call whose access token does not grant it is
|
|
328
|
+
refused with `insufficient_scope`. A refreshed token keeps the scope of its
|
|
329
|
+
sign-in, so a connection that signed in without a tool's scope is refused
|
|
330
|
+
that tool until it signs in again requesting it.
|
|
326
331
|
|
|
327
332
|
### Tokens
|
|
328
333
|
|
|
@@ -331,7 +336,8 @@ A connection acts as its principal:
|
|
|
331
336
|
the headless `client_credentials` grant is enabled, its access tokens last
|
|
332
337
|
300 seconds unless `mcp.clientCredentials.accessTokenTtl` is set. A request
|
|
333
338
|
with an expired or invalid token gets HTTP 401 with
|
|
334
|
-
error `invalid_token` and a
|
|
339
|
+
error `invalid_token` and a
|
|
340
|
+
`WWW-Authenticate: Bearer resource_metadata="…", scope="memory:read memory:write principal:read"`
|
|
335
341
|
header.
|
|
336
342
|
- With the shipped `config.yaml`, which does not set
|
|
337
343
|
`mcp.refreshTokenRequiresOfflineAccess`, the app also gets a refresh token
|
|
@@ -664,20 +670,22 @@ and read `agentId` and `scope`.
|
|
|
664
670
|
**Revoke:** `flair principal disable bob-the-bot` on the Flair host; its next
|
|
665
671
|
request gets `{"error":"principal_deactivated"}`.
|
|
666
672
|
|
|
667
|
-
`flair agent remove bob-the-bot`, also run on the Flair host,
|
|
668
|
-
`yes` (or takes `--force`), then:
|
|
673
|
+
`flair agent remove bob-the-bot`, also run on the Flair host, scans the agent's
|
|
674
|
+
`Memory` and `Soul` rows, asks you to type `yes` (or takes `--force`), then:
|
|
669
675
|
|
|
670
|
-
-
|
|
671
|
-
|
|
676
|
+
- purges scanned `Memory` rows when present and confirms the purge receipt,
|
|
677
|
+
deletes scanned `Soul` rows when present and checks each delete response,
|
|
678
|
+
then re-scans `Soul` to confirm no rows for the agent remain before deleting
|
|
679
|
+
the Agent record;
|
|
672
680
|
- sends a delete for the `Agent` record, and stops with an error if the
|
|
673
681
|
operations API rejects it;
|
|
674
682
|
- unless you pass `--keep-keys`, attempts to delete the agent's key files
|
|
675
|
-
(private, public
|
|
676
|
-
on
|
|
677
|
-
|
|
683
|
+
(private, public, `.bak`, `<key>.bak.<UTC timestamp>` backups and
|
|
684
|
+
`.<agentId>.key.tmp-<hex>` staging keys) from the keys directory on the machine
|
|
685
|
+
it runs on, ignoring any failure;
|
|
686
|
+
- prints `Removed N key file(s).` (with `--keep-keys`,
|
|
678
687
|
`Key files preserved (--keep-keys).`) and then
|
|
679
|
-
`✅ Agent 'bob-the-bot' removed successfully
|
|
680
|
-
Soul and key-file deletions.
|
|
688
|
+
`✅ Agent 'bob-the-bot' removed successfully`.
|
|
681
689
|
|
|
682
690
|
Rows the agent owns in other tables, such as its workspace state, are left in
|
|
683
691
|
place.
|
|
@@ -701,7 +709,8 @@ bytes). With `FLAIR_MCP_ISSUER=https://flair.example.com`, the document for
|
|
|
701
709
|
"client_name": "bob-the-bot",
|
|
702
710
|
"jwks": { "keys": [ { "kty": "OKP", "crv": "Ed25519", "x": "<public key>", "kid": "bob-the-bot" } ] },
|
|
703
711
|
"token_endpoint_auth_method": "private_key_jwt",
|
|
704
|
-
"grant_types": ["client_credentials"]
|
|
712
|
+
"grant_types": ["client_credentials"],
|
|
713
|
+
"scope": "memory:read memory:write principal:read"
|
|
705
714
|
}
|
|
706
715
|
```
|
|
707
716
|
|
package/docs/api-reference.md
CHANGED
|
@@ -17,7 +17,7 @@ fails when a GraphQL `@table` type is missing from this file, so a new table
|
|
|
17
17
|
cannot land undocumented.
|
|
18
18
|
|
|
19
19
|
Default REST port is `19926` (`DEFAULT_PORT` in `src/cli.ts`). Override with
|
|
20
|
-
|
|
20
|
+
`flair init --port <port>`; CLI commands also read `FLAIR_URL`. Sign remote requests as
|
|
21
21
|
`agentId:timestamp:nonce:METHOD:/path?query` and send
|
|
22
22
|
`Authorization: TPS-Ed25519 <agentId>:<ts>:<nonce>:<sig>`. Protocol detail is
|
|
23
23
|
in [SECURITY.md](../SECURITY.md).
|
|
@@ -54,7 +54,7 @@ the schema section so the catalog is complete.
|
|
|
54
54
|
| **Admin Basic** | Harper `HDB_ADMIN_PASSWORD` / `FLAIR_ADMIN_PASSWORD` | Whole-instance operator. Bypasses agent scoping, including `private` memory. Used by the web admin and `n8n-nodes-flair`. |
|
|
55
55
|
| **Operator / internal** | Admin Basic, or a deliberate `internalContext()` call inside the process | Soul mutations, `OrgSkillAssignment` writes and `AgentSeed`. Agent Ed25519 keys — including admin-agent keys — cannot author Soul. |
|
|
56
56
|
| **Federation body-sig** | Ed25519 over the request body + timestamp/nonce; pairing uses a one-time token | `/FederationPair`, `/FederationSync`. Harper role gate is open; the handler is the auth boundary. |
|
|
57
|
-
| **OAuth bearer** | Access token from
|
|
57
|
+
| **OAuth bearer** | Access token from `@harperfast/oauth` | Native `/mcp` authentication. Off by default. |
|
|
58
58
|
|
|
59
59
|
Anonymous HTTP is denied on every agent-facing table (and on `GET /Presence`, which needs a verified reader unless the instance enables the public-roster opt-in). By-id refusal
|
|
60
60
|
status is resource-specific: Memory returns **404** for missing or unreadable rows, while Credential
|
|
@@ -156,9 +156,10 @@ principal. A body that names a different owner is rejected or overwritten
|
|
|
156
156
|
per the table's attribution mode — never trusted.
|
|
157
157
|
|
|
158
158
|
Federation sync currently pushes **Memory** (non-`private`), **Soul**,
|
|
159
|
-
**Agent**, and **Relationship**.
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
**Agent**, and **Relationship**. **Presence** send and receive are opt-in via
|
|
160
|
+
`FLAIR_FEDERATION_PRESENCE_SEND` and `FLAIR_FEDERATION_PRESENCE_RECEIVE`.
|
|
161
|
+
`Message` has a classifier policy for a later cross-host slice; it is not in
|
|
162
|
+
today's spoke push list.
|
|
162
163
|
|
|
163
164
|
---
|
|
164
165
|
|
|
@@ -202,17 +203,17 @@ does not apply this rule: its `params.agentId` is only an assignee filter.
|
|
|
202
203
|
| Method | Path | Auth | Read / write |
|
|
203
204
|
|--------|------|------|--------------|
|
|
204
205
|
| GET | `/Agent`, `/Agent/<id>` | Ed25519 | Any verified agent may read principals (discovery). |
|
|
205
|
-
| POST | `/Agent` | Admin Basic | Create principal. Also `POST /AgentSeed` (operator/internal only — not an admin-agent key). |
|
|
206
|
+
| POST | `/Agent` | Admin Basic / Ed25519 admin | Create principal. Also `POST /AgentSeed` (operator/internal only — not an admin-agent key). |
|
|
206
207
|
| PUT | `/Agent/<id>` | Ed25519 admin / Admin Basic | An administrator operation. An administrator (an Ed25519 agent whose record has `role: "admin"` or whose id `FLAIR_ADMIN_AGENTS` names, or Admin Basic) may PUT any existing record. For a request that reaches `Agent.put()`, the target id is checked first: an id outside the agent-id rule is refused 400 before the handler's authorization and existence checks. Authentication, routing and Harper's resource admission (for a missing target, `allowCreate()`, administrators only) can refuse earlier. For a valid id, a PUT from any other verified agent is refused 403: `agent_put_admin_only` when the record exists, Harper's create check (`allowCreate()`, administrators only) when it does not; such an agent updates its own record with PATCH. An unauthenticated request is refused. The PUT is a full replacement of an existing record. The server sets these fields whatever the body says: the id is the URL's; `createdAt`, `publicKey`, `originatorInstanceId` and the receiver federation fields (`_originatorInstanceId`, `_syncedFrom`, `_syncedAt`) are kept from the stored record; `updatedAt` is set by the handler; `role` and `admin` are reconciled (an admin role or `admin: true` sets both, otherwise `admin` is false). Every other field comes from the body, so an ordinary field the body omits (`status` and `role` included) is not kept, and an absent `status` reads as active. An administrator's PUT to a valid id with no record is refused 404 `agent_put_requires_existing` (a body `id` that disagrees with the URL's is refused instead). |
|
|
207
208
|
| PATCH | `/Agent/<id>` | Ed25519 / Admin Basic | Merges the body into the stored record. A verified agent that is not an administrator may PATCH only its own record, may not write `status`, and may not change the record's admin status (403); the admin-status decision compares the `role` of the row it reads with the role that row would have once the body is merged and reconciled. An administrator may PATCH any record. An unauthenticated request is refused. |
|
|
208
|
-
| DELETE | `/Agent/<id>` | Admin Basic | Deprovision. |
|
|
209
|
+
| DELETE | `/Agent/<id>` | Admin Basic / Ed25519 admin | Deprovision. |
|
|
209
210
|
| POST | `/AgentKeyRegister` | Basic admin / Ed25519 agent with the admin annotation | Register an agent key. Under Flair's per-agent registration lock, reads a fresh local, non-deactivated row with `publicKey: "pending"` and, at the confirmation read, requires the committed row to equal the fresh-read snapshot and still be `pending` before commit. The lock serializes registrations for that agent within one Harper process; raw operations-API writes and other processes do not take it. The post-commit read-back detects surviving differences in compared fields or identity and reports the registered key only when the committed row still has the registered key's identity and the staged `publicKey` and `updatedAt`, and the `AgentKeyRegistration` row this attempt wrote under its `registrationId` is present; otherwise it refuses 503 `registration_unavailable` with outcome `unconfirmed`. A change restored before the confirmation read is not observed; a commit-time pending check is a follow-up. Unsupported schemes that reach the handler receive 401 before Flair's `resolveAgentAuth`, body validation and table reads. Harper handles some Authorization values upstream: a Bearer refresh token receives Harper's 404 before any resource runs. Refuses 409 `agent_key_not_pending` (a non-`pending` row points to key rotation), 403 `agent_not_local` / `agent_inactive`, 404 `agent_not_found`, 400 `registration_request_invalid`, 409 `registration_conflict`, 503 `registration_unavailable`. Writes an `AgentKeyRegistration` audit row and an `agent_key_registered` OrgEvent. The audit `keyFingerprint` and the event `detail` carry the key fingerprint, not the key; the audit `agentId` and the event `refId` carry the target agent's id, which the event `summary` names in text. |
|
|
210
211
|
| GET | `/Presence` | Verified reader | Roster. Requires a valid `TPS-Ed25519` agent signature or the admin credential; an anonymous request gets 401. An instance may opt in to a public roster with `PRESENCE_PUBLIC_ROSTER=true`, in which case an unverified reader gets the allowlisted roster with `currentTask`, `flairVersion`, and `harperVersion` as null. Thresholds: [Presence for API consumers](#presence-for-api-consumers). |
|
|
211
212
|
| POST | `/Presence` | Ed25519 | Heartbeat. Agent writes only its own row (403 cross-agent). Stamps `flairVersion` / `harperVersion` on the row. |
|
|
212
213
|
| PUT / DELETE | `/Presence/<id>` | Ed25519 | Own row only. Collection PUT is not a public bypass. |
|
|
213
214
|
| GET | `/Soul`, `/Soul/<id>` | Ed25519 | Any verified agent; unscoped (identity/discovery). |
|
|
214
215
|
| POST / PUT / PATCH / DELETE | `/Soul` | **Operator / internal** | Not Ed25519. Learned Memory text cannot be copied in as Soul. See [docs/auth.md](auth.md#soul-authorship). |
|
|
215
|
-
|
|
|
216
|
+
| GET (SSE / WebSocket) | `/FeedSouls` | Ed25519 | Soul subscription. |
|
|
216
217
|
|
|
217
218
|
`Credential` (extra credentials for a principal) requires authenticated HTTP
|
|
218
219
|
access: non-admin by-id reads and writes are limited to the caller's
|
|
@@ -246,10 +247,10 @@ registrations; its key field is the fingerprint, not the key.
|
|
|
246
247
|
| POST | `/FeedMemories` | Ed25519 | Ingest path; `agentId` stamped from the caller (`stamp-strict`). |
|
|
247
248
|
| POST | `/MemoryArchive` | Ed25519 | Basement / restore. Accepts `{ id, action: "basement" \| "restore" }`; a successful ordinary-memory operation returns HTTP 200 with Memory.put()'s write receipt, including `id`, `written`, `deduplicated` and any returned visibility or redaction fields. Read the memory to inspect its archive state. Read/write refusals retain their HTTP status and body; a persisted-row change detected by the archive's re-read returns `409 memory_changed`. |
|
|
248
249
|
| POST | `/MemoryMaintenance` | Ed25519 or admin | Hygiene: expire ephemeral, archive old standard. An agent's own run is scoped to the caller; an admin run with no `agentId` is fleet-wide, and one that names an `agentId` is scoped to that agent. Fleet-wide maintenance expires and archives eligible rows of every agent. A supplied admin `agentId` that is not a conforming string (the agent-id rule `^[a-zA-Z0-9_-]{1,64}$` included) is refused 400 with the rule and a `remedy`: run that agent's own authenticated non-admin maintenance, which reaches its rows, when the stored id can authenticate (the signed TPS-Ed25519 header cannot carry a colon or whitespace); for an id the header cannot represent, run fleet-wide, which reaches that agent's rows and expires or archives every other agent's eligible rows. |
|
|
249
|
-
| POST | `/MemoryReindex` | Admin /
|
|
250
|
-
| POST | `/
|
|
251
|
-
| POST | `/
|
|
252
|
-
| POST | `/MemoryDedupStats` | Admin Basic | Dedup diagnostics. Fleet-wide sweep; `allowCreate` is `allowAdmin`. |
|
|
250
|
+
| POST | `/MemoryReindex` | Admin Basic / Ed25519 admin | Secondary-index (`agentId`) heal via primary-store re-PUT (no embedding regeneration). |
|
|
251
|
+
| POST | `/ConsolidateMemories` | Ed25519 | Dedup / consolidate. |
|
|
252
|
+
| POST | `/ReflectMemories` | Ed25519 | REM distill → MemoryCandidate. |
|
|
253
|
+
| POST | `/MemoryDedupStats` | Admin Basic / Ed25519 admin | Dedup diagnostics. Fleet-wide sweep; `allowCreate` is `allowAdmin`. |
|
|
253
254
|
| POST | `/MemoryPurge` | **Operator / internal** | Not Ed25519, admin-agent keys included. Physical removal of Memory rows by id; a skill-tagged row expands to its whole skill lineage. `removedIds` lists the rows a read after the commit finds gone; a target not stored before the delete fails the call (404). A target still stored after the commit keeps its pointer row. Unconfirmed history cleanup returns 500 `memory_purge_history_cleanup_unconfirmed` before pointer-cleanup failure (500 `memory_purge_pointer_cleanup_failed`) or a still-stored target (409 `memory_purge_unconfirmed`). Does not change `DELETE /Memory/<id>`. An accepted DELETE of a non-reserved skill closes its head; the reserved `using-flair` seed is physically deleted. |
|
|
254
255
|
| POST | `/SkillScan` | Ed25519 | Skill-tag scan on Memory writes. |
|
|
255
256
|
| GET | `/OrgSkillAssignment`, `/OrgSkillAssignment/<id>` | Ed25519 | Any verified agent. Org-scope skill assignments; see the `skills` paragraph in [docs/mcp-clients.md](mcp-clients.md). Not federated. |
|
|
@@ -312,12 +313,13 @@ The remedy is `flair upgrade` (the adapter), not a server upgrade alone.
|
|
|
312
313
|
|--------|------|------|--------------|
|
|
313
314
|
| GET / POST / PUT | `/Relationship` | Ed25519 / Admin Basic | Owner-only for non-admin agents; administrators can read across owners. POST creates; a create that is otherwise admitted, valid and within the rate limit is 409 when its id already exists. PUT upserts. For a verified non-admin agent both stamp the owner from the caller (a body naming another agent is 403); an administrator keeps the owner it supplies. A write that passes validation gets provenance built server-side. |
|
|
314
315
|
| GET / POST / PUT | `/WorkspaceState` | Ed25519 | Owner-only. POST stamps `agentId`; PUT rejects a mismatch. |
|
|
315
|
-
| GET | `/WorkspaceLatest
|
|
316
|
+
| GET | `/WorkspaceLatest/<agentId>` | Ed25519 | Latest workspace row for the caller. |
|
|
316
317
|
| GET / POST / PUT / PATCH | `/OrgEvent` | Ed25519 / Admin Basic | Any verified agent reads every event. `authorId` for a non-admin agent: POST sets it from the caller, whatever the body says; PUT requires the body to name the caller (403 otherwise, including when it is absent); PATCH leaves the stored value unless the body names one, and refuses a change (403). An administrator (an admin agent key or credentialed Basic admin) may supply `authorId` on any verb; POST defaults it to the administrator's own id. The server assigns an OrgEvent's `createdAt` on create. After the earlier checks, a `createdAt` check reads the stored row under each event's id. A stored row's `createdAt` is authoritative whatever its value (an empty string included): an update that omits it keeps it, and one that names a different value is refused with 409 `created_at_immutable`. An event that reaches the check and is not an object, or whose id is not a non-empty string or a non-empty array of strings, is refused with 400 `invalid_event_id` before any write, as is an administrator's PATCH to the collection (for a non-admin's collection PUT, PATCH or DELETE, if reached, the table guard returns the 403 collection refusal; existing DELETE middleware may refuse earlier). Before validation, an addressed POST binds a missing or `null` body id to the addressed id, and a string or number body id when its text matches the address; any other id type is left unchanged by this step. At the root collection, POST generates an id when the body's id is missing, `null` or empty. At POST id validation, at the root collection or an addressed path whose body id was not bound, a remaining id that is not a non-empty string or a non-empty array of strings receives 400 `invalid_event_id`. |
|
|
317
|
-
| GET / POST | `/OrgEventCatchup
|
|
318
|
-
| GET / POST | `/AgentReadPosition
|
|
319
|
-
| POST | `/OrgEventMaintenance` |
|
|
318
|
+
| GET / POST | `/OrgEventCatchup/<agentId>` | Ed25519 | Catch-up feed for the caller. `after` defaults to the per-agent watermark; `since` is an optional ISO `createdAt` floor. GET pages; POST acks `{ position }` (advance-on-ack). |
|
|
319
|
+
| GET / POST | `/AgentReadPosition/<agentId>` | Ed25519 | Owner-only watermark (`stream`, default `org-event`). Foundation for light-comms catch-up. |
|
|
320
|
+
| POST | `/OrgEventMaintenance` | Admin Basic / Ed25519 admin | Expire / sweep org events. |
|
|
320
321
|
| POST | `/AttentionQuery` | Ed25519 | Cross-table “what touches entity E”. Entity strings: [docs/entity-vocabulary.md](entity-vocabulary.md). |
|
|
322
|
+
| GET | `/TeamDirectory` | Verified active agent | Team directory; filters `id`, `name`, `cursor`, `limit`. |
|
|
321
323
|
|
|
322
324
|
#### Instruction-change events (Soul and skill)
|
|
323
325
|
|
|
@@ -337,6 +339,7 @@ Instruction events are readable by any verified agent. Three things a reader sho
|
|
|
337
339
|
| 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`. |
|
|
338
340
|
| POST | `/FederationSync` | Peer body-sig | Public at the role gate. Merge Memory / Soul / Agent / Relationship (and classifier-ready Message). Originator + per-record signature checks. |
|
|
339
341
|
| GET | `/FederationPeers` | Admin Basic | Known peers. |
|
|
342
|
+
| GET | `/FederationRetries` | Admin Basic / Ed25519 admin | Pending, terminal, and malformed retry rows. |
|
|
340
343
|
| GET / write | `/Instance` | Read: Ed25519. Write: admin | Instance row (`flair_…` id, role hub/spoke). |
|
|
341
344
|
| GET / write | `/Peer` | Admin Basic | Pinned peer keys and sync cursors. |
|
|
342
345
|
| GET / write | `/PairingToken` | Admin Basic | One-time tokens; default TTL 1 hour. |
|
|
@@ -353,7 +356,7 @@ operator audit trail.
|
|
|
353
356
|
| GET | `/MessageInbox` | Ed25519 | Inbox for the caller. |
|
|
354
357
|
| POST | `/MessageAck` | Ed25519 | Consume a delivered message. |
|
|
355
358
|
| GET | `/MessageDeadLetter` | Ed25519 | Visible failures for the sender (`deadline`, `inbox_full`, …). |
|
|
356
|
-
|
|
|
359
|
+
| POST | `/MessageSweep` | Admin / internal | Deadline sweep. |
|
|
357
360
|
|
|
358
361
|
### OAuth, MCP, XAA
|
|
359
362
|
|
|
@@ -362,10 +365,10 @@ operator audit trail.
|
|
|
362
365
|
| GET | `/.well-known/oauth-authorization-server`, `/OAuthMetadata` | Public | RFC 8414. CORS `*`. |
|
|
363
366
|
| GET | `/.well-known/oauth-protected-resource`, `…/mcp` | Public | RFC 9728. |
|
|
364
367
|
| POST | `/OAuthRegister` | `X-Flair-Initial-Access-Token` | DCR. **Off** unless `FLAIR_OAUTH_DCR_TOKEN` is set (32–508 chars). Rate-limited. |
|
|
365
|
-
| GET / POST | `/OAuthAuthorize` | Public
|
|
368
|
+
| GET / POST | `/OAuthAuthorize` | Public consent page; approval requires Basic admin / signed agent | Authorization code + PKCE (`S256` required). |
|
|
366
369
|
| POST | `/OAuthToken` | Public (client + code/assertion) | Token + `jwt-bearer` (XAA). |
|
|
367
370
|
| POST | `/OAuthRevoke` | Public (token) | Revocation. |
|
|
368
|
-
|
|
|
371
|
+
| POST | `/mcp` | OAuth bearer | Curated tools. **Unmounted** until `FLAIR_MCP_OAUTH=true` and an issuer. |
|
|
369
372
|
| GET / write | `/OAuthClient` | Admin Basic | Durable client rows. |
|
|
370
373
|
| GET / write | `/IdpConfig` | Admin Basic | XAA IdP registration (`flair idp add`). |
|
|
371
374
|
| GET | `/MCPClientMetadata` | Public / handler-gated | CIMD documents for allowed hosts. |
|
|
@@ -387,8 +390,8 @@ Reads of the `/Admin*` routes below are admin-only: **Admin Basic**, or a `TPS-E
|
|
|
387
390
|
| Path | Purpose |
|
|
388
391
|
|------|---------|
|
|
389
392
|
| `/Admin`, `/AdminDashboard` | Server-rendered console |
|
|
390
|
-
| `/AdminPrincipals` |
|
|
391
|
-
| `/AdminConnectors` | OAuth clients
|
|
393
|
+
| `/AdminPrincipals` | List agents / users; management via `flair principal` |
|
|
394
|
+
| `/AdminConnectors` | List OAuth clients |
|
|
392
395
|
| `/AdminIdp` | IdP configuration |
|
|
393
396
|
| `/AdminMemory` | Browse / search memory as operator |
|
|
394
397
|
| `/AdminMemoryCandidates/{agentId}` | JSON: one agent's MemoryCandidate ids in id order (`limit`, default 200, max 500; `after=<id>` for the ids after that one), used by `flair rem restore` |
|
|
@@ -417,6 +420,7 @@ comes from the token `sub`, never from tool arguments.
|
|
|
417
420
|
| `flair_workspace_set` | `POST /WorkspaceState` |
|
|
418
421
|
| `flair_orgevent` | `POST /OrgEvent` |
|
|
419
422
|
| `attention` | `POST /AttentionQuery` |
|
|
423
|
+
| `team_directory` | `GET /TeamDirectory` |
|
|
420
424
|
| `record_usage` | `POST /RecordUsage` |
|
|
421
425
|
|
|
422
426
|
The stdio package `@tpsdev-ai/flair-mcp` is a separate HTTP client, not this
|
|
@@ -441,6 +445,8 @@ client-writable even if a client sends them. Full comments live in
|
|
|
441
445
|
| `activityUpdatedAt` | BigInt | When activity/task were asserted |
|
|
442
446
|
| `flairVersion` | String | Serving `@tpsdev-ai/flair` version. Null when redacted or never stamped — see below. |
|
|
443
447
|
| `harperVersion` | String | Serving Harper version. Same redaction. Also null when the server could not resolve Harper's version. |
|
|
448
|
+
| `originatorInstanceId` | String | Local instance id on local create when resolvable, otherwise null; stored value on local update; verified sender on federation receipt. |
|
|
449
|
+
| `receivedAt` | BigInt | Local receipt time in Unix ms; stamped on federation receipt. |
|
|
444
450
|
|
|
445
451
|
### Presence for API consumers
|
|
446
452
|
|
|
@@ -475,6 +481,7 @@ A peer can therefore show `presenceStatus: "offline"`, `activity: "idle"`, `last
|
|
|
475
481
|
| `agentId` | String! | Owner; no-forge |
|
|
476
482
|
| `content` | String! | Embedded text (non-skill) |
|
|
477
483
|
| `contentHash` | String | Near-duplicate key |
|
|
484
|
+
| `embeddedContentHash` | String | Stored embedding-text hash; may be absent, null, or retained from an earlier vector. |
|
|
478
485
|
| `trigger` | String | Skill “when to use”; skill rows embed from this |
|
|
479
486
|
| `visibility` | String | `shared` \| `private` (durability default if omitted) |
|
|
480
487
|
| `embedding` | [Float] | HNSW, M:16 |
|
|
@@ -482,6 +489,10 @@ A peer can therefore show `presenceStatus: "offline"`, `activity: "idle"`, `last
|
|
|
482
489
|
| `tags` | [String] | |
|
|
483
490
|
| `durability` | String | `permanent` \| `persistent` \| `standard` \| `ephemeral` |
|
|
484
491
|
| `source` | String | |
|
|
492
|
+
| `type` | String | |
|
|
493
|
+
| `instanceToken` | String | Server-stamped row incarnation token. |
|
|
494
|
+
| `writeBackWriteId` | String | |
|
|
495
|
+
| `skillSubjectId` | String | Nullable, server-owned skill subject. |
|
|
485
496
|
| `createdAt` / `updatedAt` | String | |
|
|
486
497
|
| `expiresAt` | String | Ephemeral TTL |
|
|
487
498
|
| `retrievalCount` / `lastRetrieved` | | Search-hit counters (weak signal). Incremented on `MemoryHitStat` and overlaid on Memory reads — search no longer rewrites the Memory row. |
|
|
@@ -563,7 +574,7 @@ agents.
|
|
|
563
574
|
|-------|------|-------|
|
|
564
575
|
| `id` | ID PK | Agent id |
|
|
565
576
|
| `name` | String! | |
|
|
566
|
-
| `role` / `type` | String |
|
|
577
|
+
| `role` / `type` | String | Role / legacy type; see [admin authority](auth.md#jit-provisioning) |
|
|
567
578
|
| `kind` | String | `human` \| `agent` |
|
|
568
579
|
| `displayName` | String | |
|
|
569
580
|
| `status` | String | `active` \| `deactivated` |
|
|
@@ -585,7 +596,7 @@ ed25519 / idp) and **Integration** (legacy platform connection).
|
|
|
585
596
|
| **Instance** | yes | One row per Flair instance (`id`, `publicKey`, `role` hub/spoke, `fabricEndpoint`, `status`) |
|
|
586
597
|
| **PairingToken** | yes | One-time token (`expiresAt`, `consumedBy`) |
|
|
587
598
|
| **Peer** | yes | Pinned peer (`publicKey`, `endpoint`, `status`, `lastSyncAt` / `lastMergeAt`, `lastSyncCursor`, `relayOnly`) |
|
|
588
|
-
| **FederationRetry** | yes | Sender-owned federation retry bookkeeping, shaped for one row per (peer, table, record) refused for a reason a later re-offer could clear (`state`, `attempts`, `firstRefusedAt`, `lastReason`, `resolution`, `bound`).
|
|
599
|
+
| **FederationRetry** | yes | Sender-owned federation retry bookkeeping, shaped for one row per (peer, table, record) refused for a reason a later re-offer could clear (`state`, `attempts`, `firstRefusedAt`, `lastReason`, `resolution`, `bound`). The sync sender writes and confirms retry rows. `@sealed`: a write naming an undeclared field is refused. Admin-only on every operation; excluded from federation policy and the receive mapping. |
|
|
589
600
|
| **ReplayNonce** | no | `schemas/replay.graphql`. Anti-replay record shared by agent auth (`a:<agentId>:<nonce>`) and federation body signatures (`f:<nonce>`). Local to the instance (`replicate: false`); rows expire after 120 s |
|
|
590
601
|
| **SyncLog** | no | Per-sync audit (`peerId`, `direction`, counts, `skippedReasons`, `status`) |
|
|
591
602
|
|
|
@@ -605,7 +616,7 @@ ed25519 / idp) and **Integration** (legacy platform connection).
|
|
|
605
616
|
| **InstructionVersion** | memory.graphql | yes (read only) | History for single-row Soul resource writes and skill writes through Memory post/put/delete and FeedMemories (excluding `_reindex` and reserved-seed deletes). InstructionVersion resource REST clients cannot write or delete version records; the server appends them, and when a request's close fails it attempts to remove the version that request appended only while that version is still the head, reporting a compensation failure when the removal cannot be confirmed. Soul collection deletes and InstructionVersion REST writes are refused. The administrator operations API (`upsert` / `delete` under admin auth) is the separate raw-table exception described below. The operator's reserved seed row keeps its fixed id and is versioned in place. Skill writers share a subject-type lock, select rows where `archived !== true`, `validTo` is not a nonempty string, and `expiresAt` is absent or a valid future timestamp, and refuse stale create/update targets or predecessors and ambiguous heads. Reads authorize `soul` subjects under Soul's verified-agent rule. Ordinary skill readers require readable stored visibility and current authority: matching subjects, a live skill Memory row owned by the head's owner, or a delete head with null `memoryId`; authority references require nonempty owners and explicit private/shared visibility. Admin/internal keep unfiltered skill reads; unknown subject types deny. `Memory.skillSubjectId` is nullable and server-owned. |
|
|
606
617
|
| **WorkspaceState** | workspace.graphql | yes | Current work (`ref`, `provider`, `phase`, `entities`) |
|
|
607
618
|
| **OrgEvent** | event.graphql | yes | Org-visible event (`authorId`, `kind`, `summary`, `entities`) |
|
|
608
|
-
| **AgentReadPosition** | agent.graphql | no | Per-agent watermark (`agentId`, `stream`, `position`). HTTP via `/AgentReadPosition
|
|
619
|
+
| **AgentReadPosition** | agent.graphql | no | Per-agent watermark (`agentId`, `stream`, `position`). HTTP via `/AgentReadPosition/<agentId>`, not raw-table REST. |
|
|
609
620
|
| **AgentKeyRegistration** | agent-key-registration.graphql | yes (admin read only) | Audit log of committed `POST /AgentKeyRegister` calls (`actorId`, `operator`, `agentId`, `instanceId`, `keyFingerprint`, `createdAt`). The Flair resource route refuses every write; the registration operation is its only application writer. The operations API is a separate raw-table trust root. `replicate: true` is declared explicitly to state the database default (a table replicates unless it opts out). |
|
|
610
621
|
| **Message** | message.graphql | yes | Signed envelope (`from`, `to`, `threadId`, `seq`, `state`, `signature`) |
|
|
611
622
|
| **OAuthClient** | oauth.graphql | yes | Registered OAuth clients |
|
package/docs/auth.md
CHANGED
|
@@ -22,7 +22,7 @@ With **Agent Private Key** selected, `n8n-nodes-flair` signs as the credential's
|
|
|
22
22
|
|
|
23
23
|
## Ed25519 Agent Auth (Default)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Each signing agent has an Ed25519 key pair. Requests are signed with `agentId:timestamp:nonce:METHOD:/path?query` and verified against the agent's registered public key. 30-second replay window with nonce deduplication.
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
# Register an agent
|
|
@@ -43,22 +43,22 @@ never an existence signal. The adapter write-up is
|
|
|
43
43
|
|
|
44
44
|
Flair has no `mode`/`shape` config setting — the shape you get is emergent from *how you provision principals*, not something you declare:
|
|
45
45
|
|
|
46
|
-
- **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.
|
|
46
|
+
- **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, Antigravity). When pi is selected, it registers the native extension and prints the agent environment to export at launch. 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.
|
|
47
47
|
- **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).
|
|
48
48
|
|
|
49
49
|
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.
|
|
50
50
|
|
|
51
51
|
### Authorship: which client wrote a row
|
|
52
52
|
|
|
53
|
-
The personal shape's one shared principal means `agentId` alone can't answer "was this written by Claude Code or Codex?" — every write it receives has the same owner. `flair init`'s per-client wiring closes that gap by setting an additional env var per client: `FLAIR_CLIENT` (`"claude-code"` / `"codex"` / `"gemini"` / `"cursor"`). `flair-client` and `flair-mcp` forward it on memory writes as `claimedClient`, and the server folds it into the write's `provenance` blob as `claimed.client` — self-reported, unverified metadata recording *which tool* authored a row, alongside the existing `claimed.model`.
|
|
53
|
+
The personal shape's one shared principal means `agentId` alone can't answer "was this written by Claude Code or Codex?" — every write it receives has the same owner. `flair init`'s per-client MCP wiring closes that gap by setting an additional env var per client: `FLAIR_CLIENT` (`"claude-code"` / `"codex"` / `"gemini"` / `"cursor"` / `"antigravity"`). `flair-client` and `flair-mcp` forward it on memory writes as `claimedClient`, and the server folds it into the write's `provenance` blob as `claimed.client` — self-reported, unverified metadata recording *which tool* authored a row, alongside the existing `claimed.model`.
|
|
54
54
|
|
|
55
55
|
This is deliberately in `claimed`, never `verified`: it carries **zero authority**. It is never read for access control, read-scope, attribution weighting, or dedup decisions — it exists purely for audit/analysis. Absent on any install that predates this field (no backfill, no migration) and absent whenever a client doesn't set `FLAIR_CLIENT`.
|
|
56
56
|
|
|
57
|
-
The native `/mcp`
|
|
57
|
+
The native `/mcp` handler stamps `claimed.client` from the token's verified `client_id` when present, so the label is tied to the authenticated client rather than its display name; it remains claimed metadata.
|
|
58
58
|
|
|
59
59
|
## OAuth 2.1
|
|
60
60
|
|
|
61
|
-
Flair
|
|
61
|
+
Flair's legacy OAuth endpoints are separate from the native `/mcp` authorization server.
|
|
62
62
|
|
|
63
63
|
The native `/mcp` endpoint is guarded by the `@harperfast/oauth` authorization server instead; who can connect through it, and how to revoke that access, is in [access-control.md](access-control.md).
|
|
64
64
|
|
|
@@ -140,8 +140,8 @@ metadata's `code_challenge_methods_supported` lists `["S256"]` as the supported
|
|
|
140
140
|
1. Client generates a PKCE `code_verifier` and its `S256` `code_challenge`
|
|
141
141
|
(`BASE64URL(SHA256(code_verifier))`, RFC 7636)
|
|
142
142
|
2. Client redirects user to `GET /OAuthAuthorize?response_type=code&client_id=...&redirect_uri=...&code_challenge=...&code_challenge_method=S256`
|
|
143
|
-
3. User approves or denies on the consent page
|
|
144
|
-
4. Flair redirects
|
|
143
|
+
3. User approves with administrator Basic auth or a signed agent request, or denies on the consent page
|
|
144
|
+
4. Flair redirects to `https://claude.com/api/mcp/auth_callback` with an authorization code on approve, or with `error=access_denied` on deny
|
|
145
145
|
5. Client exchanges code and `code_verifier` for access token at `POST /OAuthToken`
|
|
146
146
|
|
|
147
147
|
After the earlier request, scope and client checks pass, `GET /OAuthAuthorize`
|
|
@@ -168,7 +168,7 @@ A PKCE refusal does not redeem the code.
|
|
|
168
168
|
| `/OAuthToken` | POST | Token endpoint |
|
|
169
169
|
| `/.well-known/oauth-authorization-server` | GET | Authorization server metadata (RFC 8414) |
|
|
170
170
|
| `/.well-known/oauth-protected-resource` | GET | Protected resource metadata (RFC 9728) |
|
|
171
|
-
| `/OAuthMetadata` | GET |
|
|
171
|
+
| `/OAuthMetadata` | GET | Legacy authorization-server metadata; matches the well-known document when OAuth MCP is off |
|
|
172
172
|
|
|
173
173
|
Both well-known documents are public — RFC 8414 §3 and RFC 9728 §3 require them
|
|
174
174
|
to be retrievable without authentication — and are served with
|
|
@@ -237,14 +237,14 @@ localhost. See [deploying-on-fabric.md](deploying-on-fabric.md).
|
|
|
237
237
|
|
|
238
238
|
## XAA (Enterprise-Managed Authorization)
|
|
239
239
|
|
|
240
|
-
For organizations using an Identity Provider (IdP), XAA
|
|
240
|
+
For organizations using an Identity Provider (IdP), XAA maps IdP identities to Flair principals.
|
|
241
241
|
|
|
242
242
|
### How It Works
|
|
243
243
|
|
|
244
244
|
1. User authenticates with the organization's IdP (Google, Azure AD, Okta)
|
|
245
245
|
2. IdP issues an ID token (JWT) with user identity and group claims
|
|
246
246
|
3. Client sends the ID token to Flair's token endpoint using the `jwt-bearer` grant type
|
|
247
|
-
4. Flair
|
|
247
|
+
4. Flair verifies the JWT signature and issuer, applies any configured domain restriction, maps to a Principal, and issues an access token.
|
|
248
248
|
|
|
249
249
|
A `jti` claim, when present, must be a nonempty string, and the assertion must then carry an `exp` no more than 24 hours (plus 30 seconds of clock skew) ahead. Flair records the `jti` before it issues tokens, and refuses the assertion if it is presented to this Harper instance again.
|
|
250
250
|
|
|
@@ -265,6 +265,8 @@ flair idp add \
|
|
|
265
265
|
--name "Google Workspace" \
|
|
266
266
|
--issuer "https://accounts.google.com" \
|
|
267
267
|
--jwks-uri "https://www.googleapis.com/oauth2/v3/certs" \
|
|
268
|
+
--client-id "<client-id-at-google>" \
|
|
269
|
+
--admin-pass-file ~/.flair/admin-pass \
|
|
268
270
|
--required-domain "yourcompany.com"
|
|
269
271
|
```
|
|
270
272
|
|
|
@@ -278,14 +280,21 @@ flair idp add \
|
|
|
278
280
|
|
|
279
281
|
### Scopes
|
|
280
282
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
|
284
|
-
|
|
285
|
-
| `memory:
|
|
286
|
-
| `
|
|
287
|
-
| `
|
|
288
|
-
| `
|
|
283
|
+
Discovery advertises these scope names:
|
|
284
|
+
|
|
285
|
+
| Scope | `/mcp` tools that require it |
|
|
286
|
+
|-------|------------------------------|
|
|
287
|
+
| `memory:read` | `memory_search`, `memory_get`, `skill_search`, `skill_get`, `bootstrap`, `soul_get`, `attention` |
|
|
288
|
+
| `memory:write` | `memory_store`, `memory_update`, `memory_delete`, `memory_basement`, `memory_restore`, `skill_store`, `flair_workspace_set`, `flair_orgevent`, `record_usage` |
|
|
289
|
+
| `memory:admin` | none |
|
|
290
|
+
| `principal:read` | `team_directory` |
|
|
291
|
+
| `principal:admin` | `soul_set`, which then refuses the write (`soul_write_requires_operator`) |
|
|
292
|
+
| `connector:read` | none |
|
|
293
|
+
| `connector:admin` | none |
|
|
294
|
+
|
|
295
|
+
The jwt-bearer grant above issues opaque `flair_at_` tokens, which native `/mcp` does not accept; `/mcp` accepts the access tokens from its own OAuth sign-in. For native `/mcp` tool calls, the access token must grant the tool's scope above. A missing `scope` claim grants no scope. A call missing its tool's scope returns HTTP 403 with a JSON-RPC `insufficient_scope` error naming the required scope and a `WWW-Authenticate: Bearer error="insufficient_scope", scope="…"` challenge, before resolving the principal or running the tool. A permitted call runs with the mapped principal's authority.
|
|
296
|
+
|
|
297
|
+
The `/mcp` 401 challenge names `memory:read memory:write principal:read`. Refresh preserves the scopes from sign-in; existing connectors missing a required scope must sign in again requesting it.
|
|
289
298
|
|
|
290
299
|
### JIT Provisioning
|
|
291
300
|
|
|
@@ -299,7 +308,7 @@ flair principal promote <principal-id> <tier>
|
|
|
299
308
|
|
|
300
309
|
`<tier>` is one of `endorsed`, `corroborated`, or `unverified`. There is no `verified` tier and no `admin` tier. The command writes `defaultTrustTier` and does not write `role` or `admin`, so it cannot grant admin.
|
|
301
310
|
|
|
302
|
-
Admin authority is `role: admin` on the Agent record
|
|
311
|
+
Admin authority is `role: admin` on the Agent record; the auth gate does not read the `admin` mirror. Administrator POST, PUT and ordinary PATCH writes through the Agent resource reconcile `admin: true` to `role: admin`; guarded `flairPrincipalWriteBack`/`flairStampHome` PATCH writes do not. Non-admin PATCH cannot change admin status. The CLI that writes both is:
|
|
303
312
|
|
|
304
313
|
```bash
|
|
305
314
|
flair principal add <principal-id> --admin
|
|
@@ -320,10 +329,10 @@ For a request signed with an agent key, the admin decision uses the Agent row th
|
|
|
320
329
|
|
|
321
330
|
## Web Admin
|
|
322
331
|
|
|
323
|
-
The web admin at `/AdminDashboard` provides
|
|
332
|
+
The web admin at `/AdminDashboard` provides read-only views:
|
|
324
333
|
|
|
325
|
-
- **Principals:**
|
|
326
|
-
- **Connectors:** OAuth clients
|
|
334
|
+
- **Principals:** list agents and users
|
|
335
|
+
- **Connectors:** list OAuth clients
|
|
327
336
|
- **IdP:** enterprise identity provider configuration
|
|
328
337
|
- **Memory:** browse and search stored memories
|
|
329
338
|
- **Instance:** federation status, peer connections
|
|
@@ -58,8 +58,16 @@ flair init --target https://<cluster>.<org>.harperfabric.com \
|
|
|
58
58
|
- `--force` is required — this writes to a live instance.
|
|
59
59
|
- `--remote` marks it a federation **hub** and creates the `flair_pair_initiator` role;
|
|
60
60
|
without it, pairing later fails role-not-found.
|
|
61
|
-
-
|
|
62
|
-
`--flair-admin-pass`
|
|
61
|
+
- Before attempting to set `admin`'s password, init saves the chosen or generated
|
|
62
|
+
password locally in a mode-`0600` file; `--flair-admin-pass` chooses your own. The
|
|
63
|
+
final credential path is `~/.tps/secrets/flair-fabric-hdb`. Init attempts this save
|
|
64
|
+
only when it selects the branch that will try to create or update `admin`; an
|
|
65
|
+
existing `super_user` cluster administrator is reused without writing a password
|
|
66
|
+
file. With no file present the password is written directly and kept even if the
|
|
67
|
+
deployment is refused; with one present, the new value is staged beside it and moved
|
|
68
|
+
into place after the cluster accepts it and the staged copy verifies. If the cluster
|
|
69
|
+
accepts the change but the saved copy cannot be confirmed, init prints the recovery
|
|
70
|
+
step.
|
|
63
71
|
|
|
64
72
|
Run **once**, before serving multi-region traffic — see
|
|
65
73
|
[Multi-region](#multi-region-replication-vs-federation).
|
|
@@ -35,8 +35,8 @@ That is the whole API. No deep import, no `server.resources`, no `.Resource`, no
|
|
|
35
35
|
**3. Read it back, scoped to that agent.**
|
|
36
36
|
|
|
37
37
|
```javascript
|
|
38
|
-
const hits = await planner.recall("deploy schedule", { limit: 5 });
|
|
39
|
-
const record = await planner.memory.get(hits[0].id);
|
|
38
|
+
const hits = await planner.recall("deploy schedule", { limit: 5 }); // an array of hits
|
|
39
|
+
const record = await planner.memory.get(hits[0].id); // the stored row, or null
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
**4. Register an agent, no CLI.**
|
|
@@ -50,7 +50,7 @@ await flair.admin.registerAgent("planner", { publicKey: "pending" });
|
|
|
50
50
|
**5. Verify it worked.**
|
|
51
51
|
|
|
52
52
|
```javascript
|
|
53
|
-
console.log(await planner.memory.search({ limit: 10 }));
|
|
53
|
+
console.log(await planner.memory.search({ limit: 10 })); // an array of at most 10 rows
|
|
54
54
|
console.log([...server.resources.keys()].sort()); // what Flair registered
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -80,9 +80,9 @@ planner.agentId; // "planner"
|
|
|
80
80
|
| Method | Description |
|
|
81
81
|
|---|---|
|
|
82
82
|
| `handle.memory.write(content, opts?)` | Write a memory as this agent. `agentId` is stamped from the handle — the caller never passes it. |
|
|
83
|
-
| `handle.memory.get(id)` | Read a memory by id, scoped to this agent. |
|
|
84
|
-
| `handle.memory.search(opts?)` | Search memories scoped to this agent. |
|
|
85
|
-
| `handle.recall(query, opts?)` | Semantic search scoped to this agent. |
|
|
83
|
+
| `handle.memory.get(id)` | Read a memory by id, scoped to this agent. Resolves to the stored row, or `null` when that id is not readable by this agent. |
|
|
84
|
+
| `handle.memory.search(opts?)` | Search memories scoped to this agent. Resolves to an array of rows, at most `opts.limit` of them when that option is set. |
|
|
85
|
+
| `handle.recall(query, opts?)` | Semantic search scoped to this agent. Resolves to an array of hits. |
|
|
86
86
|
|
|
87
87
|
### `flair.admin`
|
|
88
88
|
|
|
@@ -93,7 +93,7 @@ Admin operations — unfiltered reads, cross-agent writes. Every call site is gr
|
|
|
93
93
|
| Method | Description |
|
|
94
94
|
|---|---|
|
|
95
95
|
| `flair.admin.registerAgent(id, opts?)` | Register an agent through the Agent resource (full Principal shape). |
|
|
96
|
-
| `flair.admin.memory.get(id)` | Read any memory by id, unfiltered. |
|
|
96
|
+
| `flair.admin.memory.get(id)` | Read any memory by id, unfiltered. Resolves to the stored row, or `null` when no record has that id. |
|
|
97
97
|
| `flair.admin.memory.write(asAgentId, content, opts?)` | Write a memory attributed to another agent. |
|
|
98
98
|
|
|
99
99
|
### `flair.internal`
|
|
@@ -53,8 +53,8 @@ Rules that apply across every type:
|
|
|
53
53
|
|
|
54
54
|
## The validator
|
|
55
55
|
|
|
56
|
-
`resources/entity-vocab.ts`
|
|
57
|
-
|
|
56
|
+
`resources/entity-vocab.ts` validates `entities` on Memory and WorkspaceState
|
|
57
|
+
POST/PUT, and on single-record OrgEvent POST/PUT.
|
|
58
58
|
|
|
59
59
|
```ts
|
|
60
60
|
import { isValidEntity, validateEntities, invalidEntitiesResponse } from "./entity-vocab.js";
|
|
@@ -71,7 +71,7 @@ validateEntities(undefined);
|
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
`invalidEntitiesResponse(entities)` is a thin convenience wrapper for Harper resource write
|
|
74
|
-
paths: it returns a ready-to-return `400 { error: "invalid_entities", invalid: [...] }`
|
|
74
|
+
paths: it returns a ready-to-return `400 { error: "invalid_entities", invalid: [...], message: "..." }`
|
|
75
75
|
`Response` when validation fails, or `null` when the field is absent or every entry is valid.
|
|
76
76
|
`WorkspaceState.ts`, `OrgEvent.ts`, and `Memory.ts` all call it early in `post()`/`put()`.
|
|
77
77
|
|
|
@@ -97,8 +97,7 @@ flair memory add --agent flint --entities "repo:tpsdev-ai/flair,issue:tpsdev-ai/
|
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
The CLI validates each value before writing (a malformed value is rejected with the
|
|
100
|
-
`type:value` format and the valid type list)
|
|
101
|
-
regardless. The CLI's validator is an inlined copy of this module
|
|
100
|
+
`type:value` format and the valid type list). The CLI's validator is an inlined copy of this module
|
|
102
101
|
(`src/lib/entity-vocab-cli.ts` — `src/` can't import across the packaging boundary into
|
|
103
102
|
`resources/`), pinned to it by `test/unit/cli-entities-option.test.ts`; the server-side gate
|
|
104
103
|
remains this module alone.
|
package/docs/hosted-on-fabric.md
CHANGED
|
@@ -39,7 +39,7 @@ flair init --target https://<cluster>.<org>.harperfabric.com \
|
|
|
39
39
|
|
|
40
40
|
- `--force` is required — this writes to a live instance.
|
|
41
41
|
- `--remote` marks it a federation **hub** and creates the `flair_pair_initiator` role; without it, pairing later fails role-not-found.
|
|
42
|
-
-
|
|
42
|
+
- Before attempting to set `admin`'s password, init saves the chosen or generated password locally in a mode-`0600` file; `--flair-admin-pass` chooses your own. The final credential path is `~/.tps/secrets/flair-fabric-hdb`. Init attempts this save only when it selects the branch that will try to create or update `admin`; an existing `super_user` cluster administrator is reused without writing a password file. With no file present the password is written directly and kept even if the deployment is refused; with one present, the new value is staged beside it and moved into place after the cluster accepts it and the staged copy verifies. If the cluster accepts the change but the saved copy cannot be confirmed, init prints the recovery step.
|
|
43
43
|
|
|
44
44
|
### Operations endpoint
|
|
45
45
|
|
package/docs/secrets-and-keys.md
CHANGED
|
@@ -7,11 +7,11 @@ Flair owns **identity**. Flair does **not** own arbitrary secrets. This page dra
|
|
|
7
7
|
For each registered agent, Flair stores:
|
|
8
8
|
|
|
9
9
|
- A **public key** in the `Agent` table (server-side; used to verify signed requests).
|
|
10
|
-
- A **private key** at `~/.flair/keys/<agent>.key` on the host that owns that agent —
|
|
10
|
+
- A **private key** at `~/.flair/keys/<agent>.key` on the host that owns that agent — a 32-byte Ed25519 seed, or an exported base64 key string that `flair import` restores unchanged. `flair init --agent <id>`, `flair agent add <id>`, `flair principal add`, `flair import`, and `flair agent rotate-key <id>` create or stage a new key owner-only (`0600`) from the first byte on POSIX; an existing key with group or world bits is refused with `chmod 600 <path>` and left unchanged on the create and reuse paths, while rotation reports it. A successful rotation replaces the file; a failed update leaves it. The keys directory is requested with mode `0700` (the umask may make it narrower; an owned directory with group or world bits is tightened). On Windows mode bits do not establish owner-only.
|
|
11
11
|
|
|
12
|
-
Agents sign
|
|
12
|
+
Agents sign requests to Flair with this key. The server verifies signatures against the registered public key. The signed payload is `<agentId>:<timestamp>:<nonce>:<METHOD>:<path+query>` with a 30-second replay window and nonce dedup — replays inside that window are rejected.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Lose the key file and the agent is locked out (`flair agent rotate-key <id>` to issue a new pair).
|
|
15
15
|
|
|
16
16
|
## Flair admin password (Harper instance)
|
|
17
17
|
- Fresh local `flair init` writes the supplied or generated admin password to `~/.flair/admin-pass` (mode `0o600`).
|
|
@@ -117,7 +117,7 @@ The pattern is identical across CLIs: the CLI config references env var names, y
|
|
|
117
117
|
|
|
118
118
|
`claude` reads `ANTHROPIC_API_KEY` from the env. Set it via the wrapper-from-Keychain pattern above; never `claude --api-key sk-ant-...` (writes to shell history).
|
|
119
119
|
|
|
120
|
-
The flair-mcp server (`@tpsdev-ai/flair-mcp`) reads `FLAIR_AGENT_ID` and (optionally) `FLAIR_KEY_PATH` from its own env block in `.mcp.json`. The Flair private key isn't a "secret" you load from Keychain — it's a key file
|
|
120
|
+
The flair-mcp server (`@tpsdev-ai/flair-mcp`) reads `FLAIR_AGENT_ID` and (optionally) `FLAIR_KEY_PATH` from its own env block in `.mcp.json`. The Flair private key isn't a "secret" you load from Keychain — it's a key file on the signing host.
|
|
121
121
|
|
|
122
122
|
### Gemini CLI
|
|
123
123
|
|
|
@@ -137,10 +137,11 @@ Hermes uses `~/.hermes/.env` for provider API keys (managed by `hermes auth`). T
|
|
|
137
137
|
|
|
138
138
|
## What to do with the Flair private key itself
|
|
139
139
|
|
|
140
|
-
`~/.flair/keys/<agent>.key`
|
|
140
|
+
Treat `~/.flair/keys/<agent>.key` like an SSH private key:
|
|
141
141
|
|
|
142
142
|
- **Stays on the host that owns the agent.** If your agent runs on a given host, the key lives on that host. If you spin up the same agent on another machine, **don't copy the key** — register a new agent identity (`flair agent add <id>-on-<other-host>`) on that machine. Different identities, same Flair instance can store memories for both, you decide cross-agent visibility.
|
|
143
|
-
-
|
|
143
|
+
- **On POSIX, created owner-only (`0600`) from the first byte** by `flair agent add`, `flair init`, `flair principal add`, and `flair import`; an existing key with group or world bits is refused, not changed (`chmod 600 <path>`). `flair doctor` warns about such a key file, and `flair status` does the same for a local target, naming its mode and the fix; the check covers the standard `resolveKeyPath` locations: `$FLAIR_KEY_DIR/<agent>.key` when set, `~/.flair/keys/<agent>.key` and the legacy `~/.tps/secrets/flair/<agent>-priv.key`; explicit key paths (such as `--key`) are outside this scan; a symlinked agent key is reported as not checked. Don't relax it.
|
|
144
|
+
- `flair export --include-key` creates its default output exclusively at `0600` and refuses an existing path; with an explicit `--output` it replaces the file through a `0600` temp file. Keystore seeds replace existing files through a `0600` temp file. A generated passphrase is published at `0600` if its path is absent; when the generated passphrase file is used (`FLAIR_KEY_PASSPHRASE` unset), an existing file with group or world bits is refused unchanged before reading (`chmod 600 <path>`). On Windows the mode bits do not apply.
|
|
144
145
|
- **Don't check it into git.** `.gitignore` should already exclude `~/.flair/keys/`; if you're ever tempted to share keys for "convenience," rotate first (`flair agent rotate-key <id>`).
|
|
145
146
|
- **Backup separately**, encrypted. The `flair backup` command excludes private keys by default. Roll your own backup of `~/.flair/keys/` via age-encrypted archive if you want offsite recovery.
|
|
146
147
|
|
|
@@ -161,12 +162,6 @@ original path.
|
|
|
161
162
|
|
|
162
163
|
Unreadable reference rows leave node-shaped files unidentified.
|
|
163
164
|
|
|
164
|
-
## What about a `flair secret` CLI?
|
|
165
|
-
|
|
166
|
-
Considered, deferred. Flair could ship a thin wrapper around the OS keyring (`flair secret get/set/list`) — but the OS primitives already work and are universally trusted. Adding a Flair-shaped wrapper would mean we own the bug surface for marginal ergonomic gain. Better path: document the OS primitives well (this page) and stay focused on identity + memory.
|
|
167
|
-
|
|
168
|
-
If you find yourself wanting one anyway, your agent can call `security find-generic-password` / `secret-tool lookup` / `op read` directly — no Flair involvement needed.
|
|
169
|
-
|
|
170
165
|
## Threat model summary
|
|
171
166
|
|
|
172
167
|
| Asset | Owned by | If compromised → |
|
|
@@ -180,7 +175,7 @@ If you find yourself wanting one anyway, your agent can call `security find-gene
|
|
|
180
175
|
|
|
181
176
|
Writes are scoped per `agentId` and isolation is enforced **server-side** by Ed25519 signature verification — not by client convention. An attacker with another agent's key can write memories as that agent, but cannot forge writes under *your* agent's identity without *your* key.
|
|
182
177
|
|
|
183
|
-
Reads are a different, and intentionally more open, story: within one Flair instance (one org), any verified agent — not just an attacker with a stolen key — passes the base visibility check for another agent's non-private memory; non-admin by-id and collection reads of retained closed skills additionally require readable current authority. That's the shipped access model (open-within-org read; see [SECURITY.md](../SECURITY.md)), not a consequence of key compromise. A key leak's actual *incremental* exposure is narrower than "read your agent's memories": it's (1) the ability to write under that agent's identity, and (2) the ability to read that agent's `visibility: private` memories, which
|
|
178
|
+
Reads are a different, and intentionally more open, story: within one Flair instance (one org), any verified agent — not just an attacker with a stolen key — passes the base visibility check for another agent's non-private memory; non-admin by-id and collection reads of retained closed skills additionally require readable current authority. That's the shipped access model (open-within-org read; see [SECURITY.md](../SECURITY.md)), not a consequence of key compromise. A key leak's actual *incremental* exposure is narrower than "read your agent's memories": it's (1) the ability to write under that agent's identity, and (2) the ability to read that agent's `visibility: private` memories, which restrict non-admin reads to their owner. Non-private memories pass the org-wide base visibility check, while non-admin Memory by-id and collection reads of retained closed skills remain subject to current authority.
|
|
184
179
|
|
|
185
180
|
The hard boundary in this model is the **federation edge** — a separate Flair instance / org. That's a different threat model from password-based or API-key-based memory services where a leaked key gives access to the full namespace across every trust boundary, not just one org.
|
|
186
181
|
|