@tpsdev-ai/flair 0.59.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/SECURITY.md +49 -5
- package/config.yaml +23 -12
- package/dist/bridges/builtins/mem0.js +63 -28
- package/dist/bridges/runtime/execute.js +1 -0
- package/dist/bridges/runtime/import-runner.js +12 -0
- package/dist/bridges/runtime/load-plugin.js +42 -13
- package/dist/bridges/runtime/yaml-loader.js +4 -2
- package/dist/bridges/types.js +1 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +1054 -367
- package/dist/commands/agent.js +233 -90
- package/dist/commands/attention.js +4 -3
- package/dist/commands/backup-approval.js +218 -0
- package/dist/commands/backup.js +211 -39
- package/dist/commands/bootstrap.js +3 -1
- package/dist/commands/bridge.js +172 -119
- package/dist/commands/deploy.js +71 -8
- package/dist/commands/doctor.js +711 -146
- package/dist/commands/export.js +57 -23
- package/dist/commands/federation.js +787 -82
- package/dist/commands/grant.js +5 -6
- package/dist/commands/help.js +25 -0
- package/dist/commands/hook.js +155 -2
- package/dist/commands/idp.js +27 -19
- package/dist/commands/import.js +136 -20
- package/dist/commands/init.js +469 -200
- package/dist/commands/integrity.js +387 -0
- package/dist/commands/keys.js +247 -58
- package/dist/commands/mcp.js +108 -52
- package/dist/commands/memory.js +203 -35
- package/dist/commands/migrate-harness-memory.js +3 -2
- package/dist/commands/orgevent.js +51 -47
- package/dist/commands/presence.js +4 -3
- package/dist/commands/principal.js +428 -62
- package/dist/commands/quality.js +13 -1
- package/dist/commands/reembed.js +141 -17
- package/dist/commands/relationship.js +2 -1
- package/dist/commands/rem.js +537 -80
- package/dist/commands/restore.js +413 -65
- package/dist/commands/search.js +6 -4
- package/dist/commands/service.js +235 -40
- package/dist/commands/soul.js +4 -9
- package/dist/commands/status.js +94 -38
- package/dist/commands/test.js +7 -3
- package/dist/commands/upgrade.js +77 -23
- package/dist/commands/workspace.js +13 -11
- package/dist/component-env.js +31 -41
- package/dist/deploy.js +136 -4
- package/dist/doctor-client.js +534 -92
- package/dist/engine-version-contract.js +1 -0
- package/dist/engine-version.js +23 -3
- package/dist/fabric-upgrade.js +12 -2
- package/dist/federation/presence-send.js +139 -0
- package/dist/federation-verify.js +273 -180
- package/dist/hook-install.js +670 -6
- package/dist/install/clients.js +171 -35
- package/dist/keystore.js +72 -0
- package/dist/lib/action-recall-runtime.js +328 -0
- package/dist/lib/agent-home-fields.js +132 -0
- package/dist/lib/agent-home.js +427 -0
- package/dist/lib/agent-id-rule.js +88 -0
- package/dist/lib/agent-roster.js +33 -0
- package/dist/lib/atomic-write.js +1 -1
- package/dist/lib/auth-resolve.js +1069 -60
- package/dist/lib/backup-approval-store.js +612 -0
- package/dist/lib/backup-artifact.js +343 -0
- package/dist/lib/capture-runtime.js +124 -0
- package/dist/lib/config-critical-section.js +212 -25
- package/dist/lib/connect-phase.js +33 -0
- package/dist/lib/credential-status-rule.js +78 -0
- package/dist/lib/daemon-liveness.js +43 -11
- package/dist/lib/doctor-run.js +75 -37
- package/dist/lib/durability-copy.js +10 -0
- package/dist/lib/embedding-space-doctor.js +75 -0
- package/dist/lib/federation-pair-access.js +4 -0
- package/dist/lib/federation-retry-queue.js +283 -0
- package/dist/lib/federation-retry-row.js +101 -0
- package/dist/lib/flair-agent-role.js +4 -0
- package/dist/lib/hub-url.js +12 -0
- package/dist/lib/init-admin-pass.js +88 -12
- package/dist/lib/init-listener-environ.js +1 -2
- package/dist/lib/init-occupied-listener.js +15 -111
- package/dist/lib/init-spawn-attribution.js +73 -0
- package/dist/lib/init-tcp-probe.js +33 -0
- package/dist/lib/instance-identity-row.js +20 -0
- package/dist/lib/instruction-event-contract.js +17 -0
- package/dist/lib/instruction-event-doctor.js +102 -0
- package/dist/lib/launchd-management.js +38 -3
- package/dist/lib/listener-table.js +268 -0
- package/dist/lib/local-delete-instance.js +27 -0
- package/dist/lib/local-instance-pair.js +256 -0
- package/dist/lib/mcp-enable.js +1182 -341
- package/dist/lib/mcp-oauth-env-core.js +133 -0
- package/dist/lib/mcp-oauth-env.js +125 -0
- package/dist/lib/mcp-spec.js +17 -1
- package/dist/lib/memory-attributes.js +4 -0
- package/dist/lib/memory-id-policy.js +46 -0
- package/dist/lib/memory-integrity.js +309 -0
- package/dist/lib/memory-provider-timeout.js +33 -0
- package/dist/lib/memory-purge-response.js +20 -0
- package/dist/lib/mqtt-config.js +132 -0
- package/dist/lib/mqtt-listener-doctor.js +104 -0
- package/dist/lib/open-live-row.js +20 -0
- package/dist/lib/ops-table-count.js +25 -0
- package/dist/lib/ops-url.js +52 -0
- package/dist/lib/owned-pins.js +67 -10
- package/dist/lib/peer-status.js +27 -0
- package/dist/lib/principal-status.js +29 -0
- package/dist/lib/process-start-time.js +76 -12
- package/dist/lib/promotion-content-hash.js +20 -0
- package/dist/lib/proto-safe-record.js +42 -0
- package/dist/lib/record-id-path.js +25 -0
- package/dist/lib/reembed-server-support.js +66 -0
- package/dist/lib/restore-archive.js +760 -0
- package/dist/lib/restore-verify.js +104 -0
- package/dist/lib/scheduler-platform.js +10 -6
- package/dist/lib/secret-keys.js +25 -0
- package/dist/lib/secrets-push.js +50 -22
- package/dist/lib/skill-assignment-preflight.js +159 -0
- package/dist/lib/skill-seed-pending.js +24 -0
- package/dist/lib/skill-seed.js +448 -0
- package/dist/lib/skill-tombstone-doctor.js +133 -0
- package/dist/lib/soul-scope-fields.js +26 -0
- package/dist/lib/stop-start-recovery.js +54 -0
- package/dist/lib/uninstall-purge.js +266 -11
- package/dist/lib/upgrade-prior-liveness.js +2 -1
- package/dist/lib/using-flair-skill.js +87 -0
- package/dist/mcp-client-assertion.js +114 -14
- package/dist/memory-id-checkpoint.js +347 -0
- package/dist/memory-node-compare.js +207 -0
- package/dist/mqtt-off-deploy.js +550 -0
- package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
- package/dist/rem/promote-policy.js +3 -3
- package/dist/rem/restore.js +303 -26
- package/dist/rem/runner.js +317 -96
- package/dist/rem/scheduler.js +21 -4
- package/dist/resources/A2AAdapter.js +131 -178
- package/dist/resources/AdminMemory.js +2 -0
- package/dist/resources/AdminMemoryCandidates.js +116 -0
- package/dist/resources/Agent.js +463 -33
- package/dist/resources/AgentCard.js +4 -0
- package/dist/resources/AgentKeyRegister.js +248 -0
- package/dist/resources/AgentKeyRegistration.js +28 -0
- package/dist/resources/AgentReadPosition.js +7 -0
- package/dist/resources/AgentSeed.js +238 -107
- package/dist/resources/AutoPromoteCandidates.js +413 -78
- package/dist/resources/Credential.js +183 -10
- package/dist/resources/Federation.js +915 -145
- package/dist/resources/FederationRetry.js +140 -0
- package/dist/resources/InstructionVersion.js +220 -0
- package/dist/resources/Integration.js +300 -25
- package/dist/resources/MCPClientMetadata.js +6 -3
- package/dist/resources/Memory.js +3300 -758
- package/dist/resources/MemoryArchive.js +171 -53
- package/dist/resources/MemoryBootstrap.js +122 -61
- package/dist/resources/MemoryCandidate.js +37 -3
- package/dist/resources/MemoryConsolidate.js +2 -2
- package/dist/resources/MemoryDedupStats.js +30 -1
- package/dist/resources/MemoryFeed.js +545 -50
- package/dist/resources/MemoryGrant.js +21 -1
- package/dist/resources/MemoryMaintenance.js +368 -46
- package/dist/resources/MemoryPurge.js +348 -0
- package/dist/resources/MemoryReflect.js +71 -12
- package/dist/resources/MemoryReindex.js +111 -17
- package/dist/resources/Message.js +16 -5
- package/dist/resources/OAuth.js +342 -48
- package/dist/resources/OAuthClient.js +1 -1
- package/dist/resources/OrgEvent.js +405 -19
- package/dist/resources/OrgEventCatchup.js +7 -0
- package/dist/resources/OrgEventMaintenance.js +48 -10
- package/dist/resources/PairingToken.js +1 -1
- package/dist/resources/Presence.js +166 -51
- package/dist/resources/PromoteMemoryCandidate.js +24 -7
- package/dist/resources/RecordUsage.js +2 -4
- package/dist/resources/Relationship.js +23 -0
- package/dist/resources/SemanticSearch.js +63 -32
- package/dist/resources/Soul.js +191 -76
- package/dist/resources/SoulFeed.js +2 -1
- package/dist/resources/TeamDirectory.js +35 -0
- package/dist/resources/WorkspaceLatest.js +4 -0
- package/dist/resources/WorkspaceState.js +21 -1
- package/dist/resources/XAA.js +207 -63
- package/dist/resources/a2a-stream.js +313 -0
- package/dist/resources/a2a-url.js +4 -5
- package/dist/resources/agent-admin.js +10 -1
- package/dist/resources/agent-auth.js +138 -83
- package/dist/resources/agent-read-position-lib.js +4 -1
- package/dist/resources/agent-status-guard.js +9 -7
- package/dist/resources/auth-middleware.js +534 -171
- package/dist/resources/authority-field-guard.js +9 -11
- package/dist/resources/auto-promote-lib.js +8 -5
- package/dist/resources/basic-auth-header.js +21 -0
- package/dist/resources/bm25-index-service.js +4 -5
- package/dist/resources/dedup-cluster.js +6 -1
- package/dist/resources/ed25519-auth.js +1 -1
- package/dist/resources/embedding-space-guard.js +366 -72
- package/dist/resources/embeddings-provider.js +25 -0
- package/dist/resources/engine-version-stamp-boot.js +53 -0
- package/dist/resources/federation-classify.js +161 -0
- package/dist/resources/federation-crypto.js +5 -5
- package/dist/resources/federation-retry-lib.js +60 -0
- package/dist/resources/grant-visibility.js +135 -0
- package/dist/resources/harper-routing.js +83 -0
- package/dist/resources/health.js +163 -22
- package/dist/resources/host-pointer/registry.js +29 -0
- package/dist/resources/host-pointer-adapter.js +1 -0
- package/dist/resources/host-source-citation.js +49 -0
- package/dist/resources/host-source-visibility.js +7 -6
- package/dist/resources/in-process.js +24 -22
- package/dist/resources/instance-create-lock.js +17 -0
- package/dist/resources/instance-identity.js +23 -0
- package/dist/resources/instruction-version-record.js +587 -0
- package/dist/resources/internal-authority.js +13 -0
- package/dist/resources/key-lock.js +3 -3
- package/dist/resources/mcp-handler.js +141 -19
- package/dist/resources/mcp-oauth-env-guard.js +36 -0
- package/dist/resources/mcp-oauth-flag.js +12 -14
- package/dist/resources/mcp-oauth.js +450 -56
- package/dist/resources/mcp-tool-arguments.js +4 -6
- package/dist/resources/mcp-tools.js +187 -40
- package/dist/resources/memory-bootstrap-lib.js +5 -15
- package/dist/resources/memory-declared-attributes.js +4 -1
- package/dist/resources/memory-deletion-history.js +55 -0
- package/dist/resources/memory-durability.js +54 -0
- package/dist/resources/memory-embed-hash.js +144 -0
- package/dist/resources/memory-embedding-value.js +8 -0
- package/dist/resources/memory-host-source.js +32 -7
- package/dist/resources/memory-id-guard.js +75 -0
- package/dist/resources/memory-redaction.js +236 -0
- package/dist/resources/memory-reflect-lib.js +1 -1
- package/dist/resources/memory-supplied-vector.js +72 -0
- package/dist/resources/memory-write-lock.js +489 -0
- package/dist/resources/memory-write-response.js +139 -0
- package/dist/resources/memory-write-transaction.js +243 -0
- package/dist/resources/migration-boot.js +17 -12
- package/dist/resources/migrations/boot-progress.js +25 -0
- package/dist/resources/migrations/data-dir.js +90 -19
- package/dist/resources/migrations/dir-safety.js +61 -3
- package/dist/resources/migrations/embedding-stamp.js +462 -82
- package/dist/resources/migrations/export.js +1 -0
- package/dist/resources/migrations/graph-heal.js +27 -27
- package/dist/resources/migrations/ledger.js +5 -2
- package/dist/resources/migrations/lock.js +870 -77
- package/dist/resources/migrations/progress.js +71 -10
- package/dist/resources/migrations/runner.js +212 -18
- package/dist/resources/migrations/snapshot.js +1 -0
- package/dist/resources/migrations/source-fields.js +5 -5
- package/dist/resources/migrations/state.js +36 -1
- package/dist/resources/migrations/status.js +2 -13
- package/dist/resources/migrations/synthetic-test-migration.js +81 -12
- package/dist/resources/migrations/types.js +26 -1
- package/dist/resources/migrations/visibility-backfill.js +113 -72
- package/dist/resources/oauth-discovery.js +0 -5
- package/dist/resources/object-body-guard.js +40 -0
- package/dist/resources/org-event-created-at.js +133 -0
- package/dist/resources/org-event-reserved.js +92 -0
- package/dist/resources/org-event-write-fault.js +19 -0
- package/dist/resources/originator-instance.js +39 -7
- package/dist/resources/owner-delete-recheck.js +78 -0
- package/dist/resources/owner-field-guard.js +39 -5
- package/dist/resources/owner-scoped-write-policy.js +256 -0
- package/dist/resources/owner-scoped-writes.js +89 -0
- package/dist/resources/path-id-rewrite.js +76 -0
- package/dist/resources/presence-internal.js +5 -5
- package/dist/resources/presence-receipt.js +236 -0
- package/dist/resources/promotion-binding.js +43 -0
- package/dist/resources/promotion-stamp.js +143 -17
- package/dist/resources/protocol-context.js +189 -0
- package/dist/resources/record-owner-guard.js +74 -26
- package/dist/resources/record-type-kit.js +2 -4
- package/dist/resources/record-types.js +1 -1
- package/dist/resources/relay-ops.js +78 -6
- package/dist/resources/replay-store.js +96 -19
- package/dist/resources/request-target.js +163 -0
- package/dist/resources/request-transaction.js +46 -1
- package/dist/resources/search-readiness.js +4 -1
- package/dist/resources/seed-ids.js +9 -0
- package/dist/resources/seed-reservation.js +116 -0
- package/dist/resources/semantic-retrieval-core.js +27 -15
- package/dist/resources/server-row-validation.js +71 -0
- package/dist/resources/skill-manifest.js +24 -14
- package/dist/resources/skill-subject.js +53 -0
- package/dist/resources/skill-version-write.js +789 -0
- package/dist/resources/skill-write-fault.js +20 -0
- package/dist/resources/skill-write-policy.js +68 -0
- package/dist/resources/skill-write.js +67 -7
- package/dist/resources/soul-write-policy.js +26 -7
- package/dist/resources/table-helpers.js +10 -7
- package/dist/resources/table-subscription-policy.js +518 -85
- package/dist/resources/table-subscriptions.js +20 -7
- package/dist/resources/team-directory.js +248 -0
- package/dist/resources/tool-descriptors/index.js +69 -8
- package/dist/resources/txn-pause-point.js +235 -0
- package/dist/resources/usage-recording.js +186 -70
- package/dist/resources/write-back.js +383 -0
- package/dist/resources/write-journal-context.js +5 -0
- package/dist/resources/write-journal.js +289 -0
- package/dist/src/engine-version-contract.js +1 -0
- package/dist/src/keystore.js +72 -0
- package/dist/src/lib/agent-home-fields.js +132 -0
- package/dist/src/lib/agent-id-rule.js +88 -0
- package/dist/src/lib/agent-key-register.js +80 -0
- package/dist/src/lib/atomic-write.js +256 -0
- package/dist/src/lib/credential-status-rule.js +78 -0
- package/dist/src/lib/expired-by-agent.js +37 -0
- package/dist/src/lib/federation-retry-row.js +101 -0
- package/dist/src/lib/flair-agent-role.js +4 -0
- package/dist/src/lib/idp-mapping-rule.js +81 -0
- package/dist/src/lib/instance-identity-row.js +20 -0
- package/dist/src/lib/instruction-event-contract.js +17 -0
- package/dist/src/lib/mcp-oauth-env-core.js +133 -0
- package/dist/src/lib/memory-attributes.js +4 -0
- package/dist/src/lib/memory-id-policy.js +46 -0
- package/dist/src/lib/open-live-row.js +20 -0
- package/dist/src/lib/principal-status.js +29 -0
- package/dist/src/lib/proto-safe-record.js +42 -0
- package/dist/src/lib/reembed-server-support.js +66 -0
- package/dist/src/lib/scheduler-platform.js +10 -6
- package/dist/src/lib/soul-scope-fields.js +26 -0
- package/dist/src/lib/systemd-agent-id.js +38 -0
- package/dist/src/rem/promote-policy.js +3 -3
- package/dist/src/rem/scheduler.js +21 -4
- package/docs/access-control.md +164 -54
- package/docs/api-reference.md +165 -32
- package/docs/auth.md +46 -30
- package/docs/bridges.md +11 -0
- package/docs/claude-code.md +37 -7
- package/docs/deploying-on-fabric.md +178 -0
- package/docs/deployment.md +19 -0
- package/docs/embedding-in-a-harper-app.md +17 -15
- package/docs/entity-vocabulary.md +3 -6
- package/docs/federation.md +61 -3
- package/docs/hosted-on-fabric.md +43 -36
- package/docs/integrations.md +14 -14
- package/docs/mcp-clients.md +12 -7
- package/docs/n8n.md +17 -11
- package/docs/notes/mcp-agent-auth-consumer.md +16 -13
- package/docs/notes/mcp-oauth-model2.md +40 -11
- package/docs/openclaw.md +1 -1
- package/docs/quickstart-fabric.md +4 -4
- package/docs/quickstart.md +12 -4
- package/docs/releasing.md +25 -19
- package/docs/rem.md +32 -3
- package/docs/secrets-and-keys.md +21 -4
- package/docs/standalone-local.md +30 -2
- package/docs/supply-chain-policy.md +34 -16
- package/docs/the-team.md +2 -2
- package/docs/upgrade.md +46 -6
- package/package.json +24 -12
- package/schemas/agent-key-registration.graphql +22 -0
- package/schemas/agent.graphql +6 -3
- package/schemas/federation.graphql +41 -1
- package/schemas/memory.graphql +91 -7
- package/schemas/oauth.graphql +19 -0
- package/schemas/schema.graphql +2 -0
- package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
- package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
- package/dist/resources/soul-adk-guard.js +0 -68
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Full walkthrough with expected output at every step: **[docs/quickstart.md](docs
|
|
|
64
64
|
Two MCP paths, on purpose. A client on this machine and a remote connector are different trust situations, and each has its own mechanism. The write-up that joins them is [docs/mcp-clients.md — Two MCP paths](docs/mcp-clients.md#two-mcp-paths).
|
|
65
65
|
|
|
66
66
|
- **Local client: the `npx` stdio adapter.** `@tpsdev-ai/flair-mcp` is a separate package and is not installed globally. `flair init --agent <id>` attempts to wire detected clients when wiring is enabled, using `npx -y @tpsdev-ai/flair-mcp@<version>` pinned to the CLI's version. The adapter sends requests to `FLAIR_URL`, signing with an Ed25519 key when one resolves and otherwise using configured administrator Basic credentials when available. Loopback HTTP is the right scheme on this machine (the default is `http://127.0.0.1:19926`). A remote `FLAIR_URL` should use HTTPS. This is the path for Claude Code, Cursor, Codex, Gemini, and every other local MCP client.
|
|
67
|
-
- **Remote client: native `/mcp`.** A JSON-RPC endpoint inside the server, OAuth bearer, exposing the curated tools that the JSON-RPC `tools/list` method on `/mcp` returns. It is off by default: an unset `FLAIR_MCP_OAUTH` leaves `/mcp` unregistered; a truthy flag and a configured issuer make Flair attempt to mount it, while only the literal value `true` also enables the OAuth component. `true` is the value that turns on both Flair's route and the OAuth component; `1`, `yes`, and `on` leave the component off and every call 401s. OAuth client-metadata is fetched over HTTPS and refuses a private, loopback, or link-local host
|
|
67
|
+
- **Remote client: native `/mcp`.** A JSON-RPC endpoint inside the server, OAuth bearer, exposing the curated tools that the JSON-RPC `tools/list` method on `/mcp` returns. It is off by default: an unset `FLAIR_MCP_OAUTH` leaves `/mcp` unregistered; a truthy flag and a configured issuer make Flair attempt to mount it, while only the literal value `true` also enables the OAuth component. `true` is the value that turns on both Flair's route and the OAuth component; `1`, `yes`, and `on` leave the component off and every call 401s. OAuth client-metadata is fetched over HTTPS and refuses a private, loopback, or link-local host. Remote connectors need a publicly reachable HTTPS origin; `flair mcp enable` accepts loopback or unspecified targets for the local restart but refuses local issuers, while route registration itself does not enforce a public HTTPS issuer.
|
|
68
68
|
`@tpsdev-ai/flair-client` is likewise its own package: add it to a project when you want to call Flair from your own code ([JavaScript / TypeScript](#javascript--typescript)).
|
|
69
69
|
|
|
70
70
|
### Where the agent's key lives
|
|
@@ -166,14 +166,14 @@ Embeddings are generated in-process by [nomic-embed-text](https://huggingface.co
|
|
|
166
166
|
|
|
167
167
|
Requests are signed as `agentId:timestamp:nonce:METHOD:/path` and verified against the agent's registered public key, with a 30-second replay window and nonce deduplication.
|
|
168
168
|
|
|
169
|
-
See **[DESIGN.md](DESIGN.md)** for the invariants behind the three primitives — why they're shaped the way they are.
|
|
169
|
+
See **[DESIGN.md](https://github.com/tpsdev-ai/flair/blob/main/DESIGN.md)** for the invariants behind the three primitives — why they're shaped the way they are.
|
|
170
170
|
|
|
171
171
|
## Features
|
|
172
172
|
|
|
173
173
|
| Feature | What it does |
|
|
174
174
|
|---|---|
|
|
175
175
|
| **Semantic memory** | Auto-embedded on write. Search by meaning, not keywords. |
|
|
176
|
-
| **Tiered durability** |
|
|
176
|
+
| **Tiered durability** | Four tiers; each states what it does and does not guarantee. permanent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it); it never decays; bootstrap considers the bootstrapping agent's own permanent memories before recent rows, subject to scope, expiry/closure and the token budget. persistent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it). standard — routine maintenance archives it once its validTo passes or, as a session note, after 30 days. ephemeral — routine maintenance reaps it once its TTL (24h by default) passes. No tier adds a flush, fsync, backup or replica acknowledgement: an explicit delete (owner or admin) or a store failure can end any of them. |
|
|
177
177
|
| **Temporal validity** | `validFrom` / `validTo` bounds. Expired memories drop out of search and bootstrap automatically. |
|
|
178
178
|
| **Trust-graded recall** | Opt-in per-result evidence: provenance, usage signal, freshness, supersession. Confidence bands (`strong`/`moderate`/`breadcrumb`) and first-class **abstention** when nothing clears the floor. |
|
|
179
179
|
| **Relationship graph** | Entity-to-entity triples with temporal bounds, queryable alongside semantic memory. |
|
|
@@ -187,7 +187,7 @@ See **[DESIGN.md](DESIGN.md)** for the invariants behind the three primitives
|
|
|
187
187
|
| **OAuth 2.1 server** | PKCE, dynamic client registration, standards-compliant token endpoint. Delegate auth to Flair without a separate IdP. [docs/auth.md](docs/auth.md) |
|
|
188
188
|
| **XAA** | Bind agent identities to Google Workspace, Azure AD or Okta accounts. |
|
|
189
189
|
| **Web admin** | Server-rendered UI for principals, connectors, IdPs and instance config. No separate dashboard service. |
|
|
190
|
-
| **Benchmarks** | [`flair-bench`](packages/flair-bench/README.md) scores candidate embedding models against the same recall corpus Flair's CI gates on. Runs standalone — no Flair install, no server. |
|
|
190
|
+
| **Benchmarks** | [`flair-bench`](https://github.com/tpsdev-ai/flair/blob/main/packages/flair-bench/README.md) scores candidate embedding models against the same recall corpus Flair's CI gates on. Runs standalone — no Flair install, no server. |
|
|
191
191
|
|
|
192
192
|
Trust-graded recall reaches the authenticated HTTP API and the built-in `/mcp` tools today — the latter being off by default, see [One install, one binary](#one-install-one-binary). CLI, `@tpsdev-ai/flair-client` and `flair-mcp` exposure is a follow-up. REM needs a configured generative backend (Ollama, OpenAI, Anthropic, …) — without one, `flair rem rapid` fails with `Reflection error: No generative backend configured`.
|
|
193
193
|
|
|
@@ -227,7 +227,7 @@ Flair works with any agent runtime. Pick the path that fits yours — **[full ca
|
|
|
227
227
|
}
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
-
Then add to your `CLAUDE.md`:
|
|
230
|
+
Then add to your `CLAUDE.md`: <!-- docs-freshness-allow: names a file in the reader's project -->
|
|
231
231
|
|
|
232
232
|
At the start of every session, run mcp__flair__bootstrap before responding.
|
|
233
233
|
|
|
@@ -243,7 +243,7 @@ Per-CLI config snippets (Gemini CLI's `~/.gemini/settings.json`, Codex CLI's `~/
|
|
|
243
243
|
openclaw plugins install @tpsdev-ai/openclaw-flair
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
Auto-detects the agent identity, provides `memory_store` / `memory_search` / `memory_get`, and provides bootstrap context from `before_prompt_build` (requires host opt-in). See the [plugin README](packages/openclaw-flair/README.md).
|
|
246
|
+
Auto-detects the agent identity, provides `memory_store` / `memory_search` / `memory_get`, and provides bootstrap context from `before_prompt_build` (requires host opt-in). See the [plugin README](https://github.com/tpsdev-ai/flair/blob/main/packages/openclaw-flair/README.md).
|
|
247
247
|
|
|
248
248
|
### n8n
|
|
249
249
|
|
|
@@ -263,10 +263,10 @@ flair search --agent mybot "that important thing"
|
|
|
263
263
|
flair soul set --agent mybot --key role --value "Security reviewer" --admin-pass-file ~/.flair/admin-pass
|
|
264
264
|
flair bootstrap --agent mybot --max-tokens 4000 # cold-start: soul + relevant memories
|
|
265
265
|
flair backup --admin-pass-file ~/.flair/admin-pass # logical JSON export
|
|
266
|
-
flair restore ./backup.json
|
|
266
|
+
FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair restore ./backup.json
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
`--admin-pass-file
|
|
269
|
+
For commands that declare `--admin-pass-file`, prefer it over `--admin-pass` to keep the secret out of `ps` and your shell history.
|
|
270
270
|
|
|
271
271
|
### JavaScript / TypeScript
|
|
272
272
|
|
|
@@ -289,7 +289,7 @@ const ctx = await flair.bootstrap({ maxTokens: 4000 })
|
|
|
289
289
|
await flair.soul.get('role')
|
|
290
290
|
```
|
|
291
291
|
|
|
292
|
-
No Harper, no embeddings — just HTTP and auth. Full API in the [client README](packages/flair-client/README.md).
|
|
292
|
+
No Harper, no embeddings — just HTTP and auth. Full API in the [client README](https://github.com/tpsdev-ai/flair/blob/main/packages/flair-client/README.md).
|
|
293
293
|
|
|
294
294
|
### HTTP API (any language)
|
|
295
295
|
|
|
@@ -415,7 +415,7 @@ bun run build # compile TypeScript → dist/
|
|
|
415
415
|
bun test # unit + integration tests
|
|
416
416
|
```
|
|
417
417
|
|
|
418
|
-
Integration tests spin up a real Harper instance on a random port and tear it down afterwards — no mocks for the database layer.
|
|
418
|
+
Integration tests spin up a real Harper instance on a random port and tear it down afterwards — no mocks for the database layer. CI for pull requests to main and pushes to main runs unit and integration tests, type checks, dependency audit, Semgrep and CodeQL SAST. See [CONTRIBUTING.md](https://github.com/tpsdev-ai/flair/blob/main/CONTRIBUTING.md).
|
|
419
419
|
|
|
420
420
|
## Status
|
|
421
421
|
|
package/SECURITY.md
CHANGED
|
@@ -63,8 +63,8 @@ Reads are open **within an org**; writes are isolated per agent. Enforced at
|
|
|
63
63
|
the database layer (Harper resource `search()` override via a single
|
|
64
64
|
centralized read-scope rule), not application logic:
|
|
65
65
|
|
|
66
|
-
- `GET /Memory/` —
|
|
67
|
-
|
|
66
|
+
- `GET /Memory/` — applies the owner/visibility base scope and omits retained
|
|
67
|
+
closed skill payloads that fail the non-admin reader's current-authority check
|
|
68
68
|
- `POST /MemorySearch` — same read scope: own memories plus all non-private
|
|
69
69
|
- `POST /Memory` — writes are attributed to the authenticated agent; an
|
|
70
70
|
agent cannot write as another (write isolation)
|
|
@@ -79,11 +79,55 @@ so a write naming neither is stamped `private` and is owner-only. An explicit
|
|
|
79
79
|
`visibility` on the write always overrides the rule, and the response to a
|
|
80
80
|
create names the value the record actually landed on.
|
|
81
81
|
|
|
82
|
+
### Record Ownership on Writes
|
|
83
|
+
|
|
84
|
+
For a verified non-admin agent's HTTP write to an owner-scoped table served by
|
|
85
|
+
a resource that extends that table (Memory, Relationship, Soul, Credential,
|
|
86
|
+
Integration, Asset, MemoryCandidate, MemoryGrant, MemoryUsage, Message,
|
|
87
|
+
OrgEvent, WorkspaceState, Presence):
|
|
88
|
+
|
|
89
|
+
- The middleware can return
|
|
90
|
+
`403 forbidden: cannot modify <Table> owned by another principal` before the
|
|
91
|
+
table guard runs on a request target of exactly `/<Table>/<id>` (two
|
|
92
|
+
non-empty path segments, no `.` in the decoded id), for which Harper resolves
|
|
93
|
+
the same record id. Other addressed forms are left to the guard, which uses
|
|
94
|
+
Harper's resolved id.
|
|
95
|
+
- If reached, the guard checks the body `id` on POST/PUT/PATCH first, then
|
|
96
|
+
stored ownership (the same owner refusal), using Harper's resolved record id.
|
|
97
|
+
An absent, null or matching body `id` passes the body-id check; a differing
|
|
98
|
+
string or number `id` gets `403 write_id_not_addressed`, and a present,
|
|
99
|
+
non-null `id` of any other type that is not the addressed key gets
|
|
100
|
+
`400 id_target_mismatch`. Each
|
|
101
|
+
object element of an array body is checked the same way. OrgEvent and Memory
|
|
102
|
+
bind an addressed POST's missing body `id` to the addressed id.
|
|
103
|
+
- For a collection PUT, PATCH or DELETE, if reached, the table guard returns
|
|
104
|
+
`403 forbidden: a non-admin write to <Table> must address one record by its id`;
|
|
105
|
+
existing DELETE middleware may refuse earlier.
|
|
106
|
+
|
|
107
|
+
A refusal by this guard leaves its target row unchanged and carries no record
|
|
108
|
+
content. A POST to a collection is delegated to each resource's own
|
|
109
|
+
POST handling — its create and attribution rules (for example, an OrgEvent
|
|
110
|
+
collection POST that names an existing event owned by another agent reaches
|
|
111
|
+
OrgEvent's ownership check and is refused, one that names the caller's own
|
|
112
|
+
existing event can update it when OrgEvent's other checks pass (a changed
|
|
113
|
+
`createdAt` is refused with 409), and a
|
|
114
|
+
Presence heartbeat writes the caller's own row). Routes served
|
|
115
|
+
by a custom resource rather than a table-backed one are outside this table
|
|
116
|
+
guard and apply their own rules; `/AgentReadPosition`, for example, enforces
|
|
117
|
+
its own ownership rule.
|
|
118
|
+
The guard exempts administrator and in-process calls. OrgEvent POST id
|
|
119
|
+
selection also applies to administrator and in-process calls.
|
|
120
|
+
|
|
121
|
+
Credential records are owner-scoped by `principalId`: non-admin callers read and
|
|
122
|
+
modify only their own records, and administrators and trusted internal callers
|
|
123
|
+
are unscoped. Anonymous HTTP access is refused.
|
|
124
|
+
|
|
82
125
|
### Cross-Agent Access (within an org)
|
|
83
126
|
|
|
84
|
-
Within an org,
|
|
85
|
-
|
|
86
|
-
|
|
127
|
+
Within an org, non-private memories pass the base read-scope check without a
|
|
128
|
+
grant; non-admin by-id and collection reads of retained closed skills
|
|
129
|
+
additionally require readable current authority. This is deliberate: the goal
|
|
130
|
+
is relevance (surface what's useful to the org) over secrecy. A writer keeps something private by marking it
|
|
87
131
|
`visibility: private`, which keeps it strictly owner-only. The access boundary
|
|
88
132
|
that stays hard is the **federation edge** (cross-instance / cross-org), not
|
|
89
133
|
within-org reads.
|
package/config.yaml
CHANGED
|
@@ -15,6 +15,13 @@ authentication:
|
|
|
15
15
|
github:
|
|
16
16
|
clientId: ${OAUTH_GITHUB_CLIENT_ID}
|
|
17
17
|
clientSecret: ${OAUTH_GITHUB_CLIENT_SECRET}
|
|
18
|
+
# WHOLE-TOKEN env reference, like the two above. Since @harperfast/oauth
|
|
19
|
+
# 2.7.0 a CONFIGURED provider (both credentials set) needs a redirectUri;
|
|
20
|
+
# 2.8.1 skips an UNCONFIGURED one before that check
|
|
21
|
+
# (HarperFast/oauth#259). Set it to this instance's public origin plus
|
|
22
|
+
# /oauth — the component appends '/github/callback'. With the credentials
|
|
23
|
+
# set, an unset or unresolved value here fails the plugin's load.
|
|
24
|
+
redirectUri: ${OAUTH_GITHUB_REDIRECT_URI}
|
|
18
25
|
mcp:
|
|
19
26
|
# WHOLE-TOKEN env reference — the same FLAIR_MCP_OAUTH flag flair's
|
|
20
27
|
# in-process /mcp route gates on (resources/mcp-oauth-flag.ts). The on/off
|
|
@@ -23,20 +30,20 @@ authentication:
|
|
|
23
30
|
# (flair#1152). Requires @harperfast/oauth >= 2.5.0 (resolved-version
|
|
24
31
|
# assertion + behavioral gate: test/integration/mcp-oauth-boot-safety.test.ts).
|
|
25
32
|
#
|
|
26
|
-
# ASYMMETRY (load-bearing, measured on oauth 2.
|
|
27
|
-
# this flag accept DIFFERENT vocabularies. The component's
|
|
28
|
-
# coerceConfigBoolean
|
|
29
|
-
#
|
|
30
|
-
#
|
|
33
|
+
# ASYMMETRY (load-bearing, measured on @harperfast/oauth 2.9.0): the two
|
|
34
|
+
# readers of this flag accept DIFFERENT vocabularies. The component's
|
|
35
|
+
# coerceConfigBoolean trims and lowercases, mapping "true"/"false" to a
|
|
36
|
+
# boolean, and normalizeBooleanField deletes strings it cannot coerce
|
|
37
|
+
# (unresolved placeholder, "1", "yes", garbage), so its disabled default
|
|
38
|
+
# applies (dist/lib/config.js). flair's mcpOAuthEnabled() accepts
|
|
39
|
+
# 1/true/yes/on.
|
|
31
40
|
#
|
|
32
|
-
# Failure modes (oauth 2.
|
|
41
|
+
# Failure modes (oauth 2.9.0):
|
|
33
42
|
# unset -> placeholder deleted -> both sides OFF, clean boot
|
|
34
|
-
# true ->
|
|
35
|
-
# (`flair mcp enable` stages exactly this)
|
|
43
|
+
# true -> both flag readers accept this value
|
|
36
44
|
# false -> both sides OFF
|
|
37
|
-
# 1 / yes / on -> flair
|
|
38
|
-
#
|
|
39
|
-
# no AS is advertised. Use "true" instead.
|
|
45
|
+
# 1 / yes / on -> flair's reader is ON, the component deletes the
|
|
46
|
+
# value (AS stays OFF); /mcp is not mounted.
|
|
40
47
|
# garbage (maybe) -> deleted -> component OFF; flair strict -> OFF.
|
|
41
48
|
# Inert: no /mcp handler, no data path (flair's own
|
|
42
49
|
# discovery documents still serve, by design).
|
|
@@ -62,4 +69,8 @@ authentication:
|
|
|
62
69
|
allowedHosts:
|
|
63
70
|
- claude.ai
|
|
64
71
|
- claude.com
|
|
65
|
-
|
|
72
|
+
# Optional pin; the algorithm follows the PEM (RSA -> RS256, EC P-256 -> ES256).
|
|
73
|
+
# Without a pin, minting reuses a persisted key or generates and persists
|
|
74
|
+
# one if oauth.harper_oauth_mcp_keys is empty.
|
|
75
|
+
# To pin, add the line below and stage the variable:
|
|
76
|
+
# signingKeyPem: ${FLAIR_MCP_SIGNING_KEY_PEM}
|
|
@@ -31,14 +31,34 @@
|
|
|
31
31
|
* from malformed responses — easier to express in TS.
|
|
32
32
|
*
|
|
33
33
|
* Usage:
|
|
34
|
-
* flair bridge import mem0 --user <id> --
|
|
34
|
+
* MEM0_API_KEY=<token> flair bridge import mem0 --user <id> --agent <flair-id>
|
|
35
|
+
* flair bridge import mem0 --user <id> --api-key-file <path> --agent <flair-id>
|
|
35
36
|
* flair bridge import mem0 --user <id> --base-url https://mem0.example.com --agent <flair-id>
|
|
36
|
-
* MEM0_API_KEY=<key> flair bridge import mem0 --user <id> --agent <flair-id>
|
|
37
37
|
*/
|
|
38
38
|
import { BridgeRuntimeError } from "../types.js";
|
|
39
39
|
function isPaginatedEnvelope(body) {
|
|
40
40
|
return !Array.isArray(body) && typeof body === "object" && body !== null && Array.isArray(body.results);
|
|
41
41
|
}
|
|
42
|
+
function mem0BaseUrl(value) {
|
|
43
|
+
if (value === undefined)
|
|
44
|
+
return "https://api.mem0.ai";
|
|
45
|
+
// An explicit value must never select the cloud default by accident.
|
|
46
|
+
if (typeof value !== "string" || !value || value !== value.trim()) {
|
|
47
|
+
throw new Error("--base-url must be a non-empty HTTP(S) URL");
|
|
48
|
+
}
|
|
49
|
+
let url;
|
|
50
|
+
try {
|
|
51
|
+
url = new URL(value);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new Error("--base-url must be a valid HTTP(S) URL");
|
|
55
|
+
}
|
|
56
|
+
if (!['http:', 'https:'].includes(url.protocol) || !url.hostname || url.username || url.password ||
|
|
57
|
+
url.href.includes('?') || url.href.includes('#')) {
|
|
58
|
+
throw new Error("--base-url must be an HTTP(S) URL without credentials, query, or fragment");
|
|
59
|
+
}
|
|
60
|
+
return url.href.replace(/\/+$/, "");
|
|
61
|
+
}
|
|
42
62
|
async function* importMem0(opts, ctx) {
|
|
43
63
|
const userId = typeof opts.user === "string" ? opts.user : "";
|
|
44
64
|
if (!userId) {
|
|
@@ -48,7 +68,7 @@ async function* importMem0(opts, ctx) {
|
|
|
48
68
|
field: "user",
|
|
49
69
|
expected: "Mem0 user_id string",
|
|
50
70
|
got: "missing",
|
|
51
|
-
hint: "pass --user <id>; example: flair bridge import mem0 --user <id> --
|
|
71
|
+
hint: "pass --user <id>; example: MEM0_API_KEY=<token> flair bridge import mem0 --user <id> --agent <flair-id>",
|
|
52
72
|
});
|
|
53
73
|
}
|
|
54
74
|
const apiKey = typeof opts.apiKey === "string" ? opts.apiKey : "";
|
|
@@ -59,18 +79,22 @@ async function* importMem0(opts, ctx) {
|
|
|
59
79
|
field: "apiKey",
|
|
60
80
|
expected: "Mem0 API token (cloud or self-hosted)",
|
|
61
81
|
got: "missing",
|
|
62
|
-
hint: "pass --api-key <
|
|
82
|
+
hint: "pass --api-key-file <path> or set MEM0_API_KEY; example: MEM0_API_KEY=<token> flair bridge import mem0 --user <id> --agent <flair-id>",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
let baseUrl;
|
|
86
|
+
try {
|
|
87
|
+
baseUrl = mem0BaseUrl(opts.baseUrl);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
throw new BridgeRuntimeError({
|
|
91
|
+
bridge: "mem0", op: "import", field: "baseUrl", expected: "valid HTTP(S) URL",
|
|
92
|
+
got: "invalid explicit --base-url", hint: err.message,
|
|
63
93
|
});
|
|
64
94
|
}
|
|
65
|
-
const baseUrl = typeof opts.baseUrl === "string" && opts.baseUrl.length > 0
|
|
66
|
-
? opts.baseUrl.replace(/\/+$/, "")
|
|
67
|
-
: "https://api.mem0.ai";
|
|
68
95
|
const maxPages = typeof opts.maxPages === "number" ? opts.maxPages : 0;
|
|
69
96
|
const pageSize = 100;
|
|
70
|
-
ctx.log.info("starting mem0 import"
|
|
71
|
-
user_id: userId,
|
|
72
|
-
base_url: baseUrl,
|
|
73
|
-
});
|
|
97
|
+
ctx.log.info("starting mem0 import");
|
|
74
98
|
let pageCount = 0;
|
|
75
99
|
let totalKept = 0;
|
|
76
100
|
let pageNum = 1;
|
|
@@ -80,24 +104,24 @@ async function* importMem0(opts, ctx) {
|
|
|
80
104
|
ctx.log.info("stopping at max-pages limit", { pages: pageCount, kept: totalKept });
|
|
81
105
|
break;
|
|
82
106
|
}
|
|
83
|
-
ctx.log.debug("fetching page", {
|
|
107
|
+
ctx.log.debug("fetching page", { page: pageCount + 1 });
|
|
84
108
|
let res;
|
|
85
109
|
try {
|
|
86
110
|
res = await ctx.fetch(cursor, {
|
|
111
|
+
redirect: "manual",
|
|
87
112
|
headers: {
|
|
88
113
|
Authorization: `Token ${apiKey}`,
|
|
89
114
|
Accept: "application/json",
|
|
90
115
|
},
|
|
91
116
|
});
|
|
92
117
|
}
|
|
93
|
-
catch
|
|
118
|
+
catch {
|
|
94
119
|
throw new BridgeRuntimeError({
|
|
95
120
|
bridge: "mem0",
|
|
96
121
|
op: "import",
|
|
97
|
-
path: cursor,
|
|
98
122
|
field: "fetch",
|
|
99
123
|
expected: "HTTP 200",
|
|
100
|
-
got:
|
|
124
|
+
got: "network error",
|
|
101
125
|
hint: "check the base URL is reachable and the network is up",
|
|
102
126
|
});
|
|
103
127
|
}
|
|
@@ -105,7 +129,6 @@ async function* importMem0(opts, ctx) {
|
|
|
105
129
|
throw new BridgeRuntimeError({
|
|
106
130
|
bridge: "mem0",
|
|
107
131
|
op: "import",
|
|
108
|
-
path: cursor,
|
|
109
132
|
field: "apiKey",
|
|
110
133
|
expected: "valid Mem0 API token",
|
|
111
134
|
got: "HTTP 401 Unauthorized",
|
|
@@ -116,7 +139,6 @@ async function* importMem0(opts, ctx) {
|
|
|
116
139
|
throw new BridgeRuntimeError({
|
|
117
140
|
bridge: "mem0",
|
|
118
141
|
op: "import",
|
|
119
|
-
path: cursor,
|
|
120
142
|
field: "apiKey",
|
|
121
143
|
expected: "authorized token",
|
|
122
144
|
got: "HTTP 403 Forbidden",
|
|
@@ -127,23 +149,20 @@ async function* importMem0(opts, ctx) {
|
|
|
127
149
|
throw new BridgeRuntimeError({
|
|
128
150
|
bridge: "mem0",
|
|
129
151
|
op: "import",
|
|
130
|
-
path: cursor,
|
|
131
152
|
field: "user",
|
|
132
153
|
expected: "existing user_id",
|
|
133
154
|
got: "HTTP 404 Not Found",
|
|
134
|
-
hint:
|
|
155
|
+
hint: "user_id was not found on this Mem0 instance",
|
|
135
156
|
});
|
|
136
157
|
}
|
|
137
158
|
if (!res.ok) {
|
|
138
|
-
const body = await res.text().catch(() => "(could not read body)");
|
|
139
159
|
throw new BridgeRuntimeError({
|
|
140
160
|
bridge: "mem0",
|
|
141
161
|
op: "import",
|
|
142
|
-
path: cursor,
|
|
143
162
|
field: "response",
|
|
144
163
|
expected: "HTTP 200",
|
|
145
|
-
got: `HTTP ${res.status}
|
|
146
|
-
hint: `unexpected response (${res.status})
|
|
164
|
+
got: `HTTP ${res.status}`,
|
|
165
|
+
hint: `unexpected response (HTTP ${res.status}); check the Mem0 API server logs`,
|
|
147
166
|
});
|
|
148
167
|
}
|
|
149
168
|
let body;
|
|
@@ -153,7 +172,6 @@ async function* importMem0(opts, ctx) {
|
|
|
153
172
|
throw new BridgeRuntimeError({
|
|
154
173
|
bridge: "mem0",
|
|
155
174
|
op: "import",
|
|
156
|
-
path: cursor,
|
|
157
175
|
field: "(response)",
|
|
158
176
|
expected: "JSON body",
|
|
159
177
|
got: "empty response",
|
|
@@ -168,11 +186,10 @@ async function* importMem0(opts, ctx) {
|
|
|
168
186
|
throw new BridgeRuntimeError({
|
|
169
187
|
bridge: "mem0",
|
|
170
188
|
op: "import",
|
|
171
|
-
path: cursor,
|
|
172
189
|
field: "(response)",
|
|
173
190
|
expected: "valid JSON: bare array OR { results: [...], next: string|null }",
|
|
174
191
|
got: "parse error",
|
|
175
|
-
hint:
|
|
192
|
+
hint: "could not parse Mem0 API response as JSON",
|
|
176
193
|
});
|
|
177
194
|
}
|
|
178
195
|
let mems;
|
|
@@ -189,19 +206,37 @@ async function* importMem0(opts, ctx) {
|
|
|
189
206
|
// v3 / DRF-style envelope — use server-provided next URL.
|
|
190
207
|
mems = body.results;
|
|
191
208
|
nextCursor = typeof body.next === "string" && body.next.length > 0 ? body.next : null;
|
|
209
|
+
if (nextCursor !== null) {
|
|
210
|
+
let nextUrl;
|
|
211
|
+
try {
|
|
212
|
+
nextUrl = new URL(nextCursor, baseUrl);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
throw new BridgeRuntimeError({
|
|
216
|
+
bridge: "mem0", op: "import", field: "next", expected: "same-origin HTTP(S) pagination URL",
|
|
217
|
+
got: "invalid pagination URL", hint: "Mem0 API returned an invalid pagination URL",
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (nextUrl.origin !== new URL(baseUrl).origin || nextUrl.username || nextUrl.password) {
|
|
221
|
+
throw new BridgeRuntimeError({
|
|
222
|
+
bridge: "mem0", op: "import", field: "next", expected: "same-origin HTTP(S) pagination URL",
|
|
223
|
+
got: "unsafe pagination URL", hint: "Mem0 API returned an unsafe pagination URL",
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
nextCursor = nextUrl.href;
|
|
227
|
+
}
|
|
192
228
|
}
|
|
193
229
|
else {
|
|
194
230
|
throw new BridgeRuntimeError({
|
|
195
231
|
bridge: "mem0",
|
|
196
232
|
op: "import",
|
|
197
|
-
path: cursor,
|
|
198
233
|
field: "(response)",
|
|
199
234
|
expected: "bare array OR { results: [...], next: string|null }",
|
|
200
235
|
got: typeof body,
|
|
201
236
|
hint: `unexpected response shape — got ${typeof body}, expected an array or paginated envelope`,
|
|
202
237
|
});
|
|
203
238
|
}
|
|
204
|
-
ctx.log.debug("received page", { count: mems.length,
|
|
239
|
+
ctx.log.debug("received page", { count: mems.length, hasNext: nextCursor !== null });
|
|
205
240
|
for (const m of mems) {
|
|
206
241
|
const content = typeof m?.memory === "string" ? m.memory : "";
|
|
207
242
|
if (!content || content.trim() === "")
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { randomUUID } from "node:crypto";
|
|
17
17
|
import { BridgeRuntimeError } from "../types.js";
|
|
18
18
|
import { importFromYaml } from "./execute.js";
|
|
19
|
+
import { endsWithContentSelectorSuffix } from "../../lib/memory-id-policy.js";
|
|
19
20
|
const VALID_DURABILITY = new Set(["ephemeral", "standard", "persistent", "permanent"]);
|
|
20
21
|
/**
|
|
21
22
|
* Drive a YAML descriptor's `import` block all the way through to PUTs
|
|
@@ -51,6 +52,17 @@ export async function runImport(opts) {
|
|
|
51
52
|
? m.durability
|
|
52
53
|
: "standard";
|
|
53
54
|
const id = m.id ?? `${resolvedAgent}-${Date.now()}-${shortRand()}`;
|
|
55
|
+
if (endsWithContentSelectorSuffix(id)) {
|
|
56
|
+
throw new BridgeRuntimeError({
|
|
57
|
+
bridge: opts.bridgeName,
|
|
58
|
+
op: "import",
|
|
59
|
+
record: total,
|
|
60
|
+
field: "id",
|
|
61
|
+
expected: "a Memory id that does not end in .content",
|
|
62
|
+
got: id,
|
|
63
|
+
hint: `Memory ids must not end in ".content". Change the bridge's id mapping for ${id}.`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
54
66
|
const body = {
|
|
55
67
|
id,
|
|
56
68
|
agentId: resolvedAgent,
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dynamic loader for Shape B code-plugin bridges.
|
|
3
|
-
*
|
|
4
|
-
* Given a discovered `npm-package` source, dynamic-import the package,
|
|
5
|
-
* validate that it exports a `MemoryBridge`, and return the loaded module.
|
|
6
|
-
* The import is done via `createRequire` relative to the package root so
|
|
7
|
-
* scoped packages and deep nested deps resolve correctly.
|
|
8
|
-
*
|
|
9
|
-
* Validation is deliberately minimal: `name`, `version`, `kind`, and at
|
|
10
|
-
* least one of `import` / `export` must be present and look right. The
|
|
11
|
-
* spec §6 contract is "duck-type at runtime, strict error messages."
|
|
12
3
|
*/
|
|
4
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
5
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
13
6
|
import { pathToFileURL } from "node:url";
|
|
14
7
|
import { BridgeRuntimeError } from "../types.js";
|
|
15
8
|
const DEFAULT_IMPORTER = (spec) => import(spec);
|
|
@@ -25,15 +18,15 @@ export async function loadCodePlugin(discovered, opts = {}) {
|
|
|
25
18
|
});
|
|
26
19
|
}
|
|
27
20
|
const importer = opts.importer ?? DEFAULT_IMPORTER;
|
|
28
|
-
|
|
29
|
-
// "main"/"exports" fields. Use a file:// URL so Node resolves it as a
|
|
30
|
-
// filesystem path rather than a bare specifier.
|
|
31
|
-
const spec = pathToFileURL(discovered.path + "/").href;
|
|
21
|
+
let spec = pathToFileURL(discovered.path).href;
|
|
32
22
|
let mod;
|
|
33
23
|
try {
|
|
24
|
+
spec = pathToFileURL(await resolveEntry(discovered)).href;
|
|
34
25
|
mod = await importer(spec);
|
|
35
26
|
}
|
|
36
27
|
catch (err) {
|
|
28
|
+
if (err instanceof BridgeRuntimeError)
|
|
29
|
+
throw err;
|
|
37
30
|
throw new BridgeRuntimeError({
|
|
38
31
|
bridge: discovered.name,
|
|
39
32
|
op: "import",
|
|
@@ -61,6 +54,42 @@ export async function loadCodePlugin(discovered, opts = {}) {
|
|
|
61
54
|
validateBridge(discovered, candidate);
|
|
62
55
|
return candidate;
|
|
63
56
|
}
|
|
57
|
+
function importTarget(value) {
|
|
58
|
+
if (typeof value === "string")
|
|
59
|
+
return value;
|
|
60
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
61
|
+
return undefined;
|
|
62
|
+
const conditions = value;
|
|
63
|
+
return importTarget(conditions.import) ?? importTarget(conditions.default);
|
|
64
|
+
}
|
|
65
|
+
async function resolveEntry(discovered) {
|
|
66
|
+
const root = await realpath(discovered.path);
|
|
67
|
+
const pkg = JSON.parse(await readFile(resolve(root, "package.json"), "utf8"));
|
|
68
|
+
const exported = importTarget(pkg.exports && typeof pkg.exports === "object" && Object.hasOwn(pkg.exports, ".")
|
|
69
|
+
? pkg.exports["."]
|
|
70
|
+
: pkg.exports);
|
|
71
|
+
const field = exported !== undefined ? "exports" : typeof pkg.main === "string" ? "main" : "index.js";
|
|
72
|
+
const target = exported ?? (typeof pkg.main === "string" ? pkg.main : "index.js");
|
|
73
|
+
const entry = resolve(root, target);
|
|
74
|
+
const assertInside = (path) => {
|
|
75
|
+
const rel = relative(root, path);
|
|
76
|
+
if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
77
|
+
throw new BridgeRuntimeError({
|
|
78
|
+
bridge: discovered.name,
|
|
79
|
+
op: "import",
|
|
80
|
+
path: discovered.path,
|
|
81
|
+
field,
|
|
82
|
+
expected: "entry inside package directory",
|
|
83
|
+
got: target,
|
|
84
|
+
hint: `package.json ${field} resolves outside the package directory`,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
assertInside(entry);
|
|
89
|
+
const resolved = await realpath(entry);
|
|
90
|
+
assertInside(resolved);
|
|
91
|
+
return resolved;
|
|
92
|
+
}
|
|
64
93
|
function pickBridgeExport(mod) {
|
|
65
94
|
if (!mod || typeof mod !== "object")
|
|
66
95
|
return null;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { promises as fsp } from "node:fs";
|
|
13
13
|
import yaml from "js-yaml";
|
|
14
14
|
import { BridgeRuntimeError } from "../types.js";
|
|
15
|
+
import { protoSafeRecord } from "../../lib/proto-safe-record.js";
|
|
15
16
|
const VALID_FORMATS = [
|
|
16
17
|
"jsonl",
|
|
17
18
|
"json",
|
|
@@ -58,13 +59,14 @@ function normalizeSourceTarget(bridge, path, fieldBase, raw) {
|
|
|
58
59
|
fail(bridge, path, `${fieldBase}.map`, "object", obj.map, `${fieldBase}.map must be an object of BridgeMemory-field → mapping expression`);
|
|
59
60
|
}
|
|
60
61
|
const mapIn = obj.map;
|
|
61
|
-
const map = {};
|
|
62
62
|
for (const [k, v] of Object.entries(mapIn)) {
|
|
63
63
|
if (typeof v !== "string") {
|
|
64
64
|
fail(bridge, path, `${fieldBase}.map.${k}`, "string expression", v, `map entries must be strings; got ${typeof v} for ${k}`);
|
|
65
65
|
}
|
|
66
|
-
map[k] = v;
|
|
67
66
|
}
|
|
67
|
+
// A null-prototype copy: an own `__proto__` map key survives as a key rather
|
|
68
|
+
// than being silently dropped by `[[Set]]` (flair#2235).
|
|
69
|
+
const map = protoSafeRecord(mapIn);
|
|
68
70
|
const out = {
|
|
69
71
|
path: obj.path,
|
|
70
72
|
format: obj.format,
|
package/dist/bridges/types.js
CHANGED
package/dist/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"commit": "
|
|
4
|
-
"builtAt": "2026-
|
|
2
|
+
"version": "0.63.0",
|
|
3
|
+
"commit": "2684290e86191bdaf14560a45c5d1d0ec6c7d3e4",
|
|
4
|
+
"builtAt": "2026-11-24T15:09:23.643Z",
|
|
5
5
|
"builder": "tsc"
|
|
6
6
|
}
|