@tpsdev-ai/flair 0.62.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 +6 -6
- package/SECURITY.md +18 -10
- package/config.yaml +11 -11
- package/dist/bridges/runtime/execute.js +1 -0
- package/dist/bridges/types.js +1 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +66 -122
- package/dist/commands/agent.js +27 -65
- package/dist/commands/backup-approval.js +218 -0
- package/dist/commands/backup.js +37 -33
- package/dist/commands/bootstrap.js +3 -1
- package/dist/commands/deploy.js +37 -7
- package/dist/commands/doctor.js +119 -0
- package/dist/commands/export.js +3 -4
- package/dist/commands/federation.js +653 -68
- package/dist/commands/grant.js +5 -6
- package/dist/commands/help.js +25 -0
- package/dist/commands/idp.js +14 -19
- package/dist/commands/import.js +131 -19
- package/dist/commands/init.js +7 -7
- package/dist/commands/integrity.js +5 -6
- package/dist/commands/mcp.js +11 -17
- package/dist/commands/memory.js +33 -15
- package/dist/commands/orgevent.js +5 -10
- package/dist/commands/principal.js +13 -25
- package/dist/commands/quality.js +3 -0
- package/dist/commands/rem.js +484 -65
- package/dist/commands/restore.js +352 -44
- package/dist/commands/service.js +84 -2
- package/dist/commands/soul.js +0 -6
- package/dist/commands/status.js +51 -33
- package/dist/commands/test.js +4 -1
- package/dist/commands/upgrade.js +53 -22
- package/dist/commands/workspace.js +7 -8
- package/dist/deploy.js +59 -3
- package/dist/doctor-client.js +7 -2
- package/dist/fabric-upgrade.js +12 -2
- package/dist/federation/presence-send.js +139 -0
- package/dist/federation-verify.js +269 -177
- package/dist/install/clients.js +171 -35
- package/dist/lib/agent-id-rule.js +44 -2
- package/dist/lib/atomic-write.js +1 -1
- package/dist/lib/auth-resolve.js +1028 -52
- package/dist/lib/backup-approval-store.js +612 -0
- package/dist/lib/backup-artifact.js +343 -0
- package/dist/lib/config-critical-section.js +212 -25
- package/dist/lib/connect-phase.js +33 -0
- package/dist/lib/daemon-liveness.js +2 -1
- 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/instruction-event-contract.js +17 -0
- package/dist/lib/instruction-event-doctor.js +102 -0
- package/dist/lib/launchd-management.js +14 -3
- package/dist/lib/mcp-enable.js +14 -15
- package/dist/lib/memory-attributes.js +2 -0
- package/dist/lib/memory-provider-timeout.js +33 -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-url.js +52 -0
- package/dist/lib/promotion-content-hash.js +20 -0
- package/dist/lib/restore-archive.js +760 -0
- package/dist/lib/restore-verify.js +1 -1
- package/dist/lib/skill-assignment-preflight.js +159 -0
- package/dist/lib/skill-seed.js +91 -8
- package/dist/lib/skill-tombstone-doctor.js +133 -0
- package/dist/lib/soul-scope-fields.js +26 -0
- package/dist/lib/uninstall-purge.js +266 -11
- package/dist/lib/upgrade-prior-liveness.js +2 -1
- package/dist/mcp-client-assertion.js +2 -10
- package/dist/memory-id-checkpoint.js +28 -7
- package/dist/mqtt-off-deploy.js +550 -0
- package/dist/rem/promote-policy.js +3 -3
- package/dist/rem/restore.js +302 -26
- package/dist/rem/runner.js +220 -58
- 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 +155 -45
- package/dist/resources/AgentCard.js +4 -0
- package/dist/resources/AgentKeyRegister.js +56 -22
- package/dist/resources/AgentReadPosition.js +7 -0
- package/dist/resources/AgentSeed.js +232 -107
- package/dist/resources/AutoPromoteCandidates.js +413 -84
- package/dist/resources/Credential.js +6 -8
- package/dist/resources/Federation.js +219 -57
- package/dist/resources/FederationRetry.js +4 -4
- package/dist/resources/InstructionVersion.js +1 -1
- package/dist/resources/MCPClientMetadata.js +6 -3
- package/dist/resources/Memory.js +1303 -270
- package/dist/resources/MemoryArchive.js +149 -64
- package/dist/resources/MemoryBootstrap.js +12 -22
- package/dist/resources/MemoryCandidate.js +16 -2
- package/dist/resources/MemoryConsolidate.js +2 -2
- package/dist/resources/MemoryFeed.js +360 -147
- package/dist/resources/MemoryMaintenance.js +290 -72
- package/dist/resources/MemoryPurge.js +138 -22
- package/dist/resources/MemoryReflect.js +68 -14
- package/dist/resources/MemoryReindex.js +91 -13
- package/dist/resources/Message.js +11 -2
- package/dist/resources/OAuth.js +156 -39
- package/dist/resources/OAuthClient.js +1 -1
- package/dist/resources/OrgEvent.js +292 -29
- 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 +31 -11
- package/dist/resources/PromoteMemoryCandidate.js +8 -2
- package/dist/resources/RecordUsage.js +2 -4
- package/dist/resources/Soul.js +2 -0
- package/dist/resources/SoulFeed.js +2 -1
- package/dist/resources/WorkspaceLatest.js +4 -0
- package/dist/resources/XAA.js +36 -10
- 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 +98 -68
- 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 +166 -42
- 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/embeddings-provider.js +25 -0
- package/dist/resources/federation-classify.js +89 -0
- package/dist/resources/federation-retry-lib.js +6 -81
- package/dist/resources/health.js +43 -4
- package/dist/resources/host-pointer/registry.js +29 -0
- package/dist/resources/host-pointer-adapter.js +1 -0
- package/dist/resources/in-process.js +24 -22
- package/dist/resources/instruction-version-record.js +251 -7
- package/dist/resources/internal-authority.js +13 -0
- package/dist/resources/mcp-handler.js +106 -12
- package/dist/resources/mcp-oauth-flag.js +12 -14
- package/dist/resources/mcp-oauth.js +430 -53
- package/dist/resources/mcp-tools.js +60 -22
- package/dist/resources/memory-declared-attributes.js +1 -0
- package/dist/resources/memory-embed-hash.js +56 -0
- package/dist/resources/memory-host-source.js +5 -2
- package/dist/resources/memory-reflect-lib.js +1 -1
- package/dist/resources/memory-write-lock.js +202 -23
- package/dist/resources/memory-write-response.js +1 -1
- 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 +16 -3
- package/dist/resources/migrations/dir-safety.js +60 -2
- package/dist/resources/migrations/embedding-stamp.js +315 -49
- package/dist/resources/migrations/graph-heal.js +9 -2
- package/dist/resources/migrations/ledger.js +5 -2
- package/dist/resources/migrations/lock.js +867 -80
- package/dist/resources/migrations/progress.js +71 -10
- package/dist/resources/migrations/runner.js +212 -18
- package/dist/resources/migrations/state.js +36 -1
- package/dist/resources/migrations/status.js +2 -13
- package/dist/resources/migrations/synthetic-test-migration.js +78 -12
- package/dist/resources/migrations/types.js +26 -1
- package/dist/resources/migrations/visibility-backfill.js +111 -70
- package/dist/resources/oauth-discovery.js +0 -5
- package/dist/resources/object-body-guard.js +12 -5
- package/dist/resources/org-event-reserved.js +92 -0
- package/dist/resources/org-event-write-fault.js +19 -0
- package/dist/resources/owner-field-guard.js +1 -1
- package/dist/resources/owner-scoped-write-policy.js +65 -21
- package/dist/resources/owner-scoped-writes.js +37 -6
- package/dist/resources/path-id-rewrite.js +76 -0
- package/dist/resources/presence-internal.js +5 -5
- package/dist/resources/promotion-binding.js +43 -0
- package/dist/resources/promotion-stamp.js +124 -33
- package/dist/resources/protocol-context.js +189 -0
- package/dist/resources/record-type-kit.js +2 -4
- package/dist/resources/request-target.js +28 -1
- package/dist/resources/request-transaction.js +11 -1
- package/dist/resources/seed-reservation.js +1 -2
- package/dist/resources/semantic-retrieval-core.js +7 -6
- package/dist/resources/server-row-validation.js +71 -0
- package/dist/resources/skill-manifest.js +4 -3
- package/dist/resources/skill-version-write.js +384 -27
- package/dist/resources/skill-write-fault.js +6 -3
- package/dist/resources/skill-write-policy.js +2 -1
- package/dist/resources/soul-write-policy.js +26 -7
- package/dist/resources/table-helpers.js +1 -1
- package/dist/resources/table-subscription-policy.js +518 -85
- package/dist/resources/table-subscriptions.js +20 -7
- package/dist/resources/txn-pause-point.js +122 -5
- package/dist/resources/usage-recording.js +54 -46
- package/dist/resources/write-back.js +176 -11
- package/dist/resources/write-journal-context.js +5 -0
- package/dist/resources/write-journal.js +289 -0
- package/dist/src/lib/agent-id-rule.js +44 -2
- package/dist/src/lib/atomic-write.js +1 -1
- package/dist/src/lib/federation-retry-row.js +101 -0
- package/dist/src/lib/instruction-event-contract.js +17 -0
- package/dist/src/lib/memory-attributes.js +2 -0
- package/dist/src/lib/open-live-row.js +20 -0
- package/dist/src/lib/soul-scope-fields.js +26 -0
- package/dist/src/rem/promote-policy.js +3 -3
- package/dist/src/rem/scheduler.js +21 -4
- package/docs/access-control.md +18 -9
- package/docs/api-reference.md +126 -28
- package/docs/auth.md +40 -18
- package/docs/claude-code.md +3 -3
- package/docs/deploying-on-fabric.md +108 -0
- package/docs/deployment.md +17 -0
- package/docs/embedding-in-a-harper-app.md +16 -14
- package/docs/entity-vocabulary.md +3 -6
- package/docs/federation.md +29 -2
- package/docs/integrations.md +11 -11
- package/docs/mcp-clients.md +7 -5
- package/docs/notes/mcp-agent-auth-consumer.md +4 -9
- package/docs/notes/mcp-oauth-model2.md +6 -6
- package/docs/openclaw.md +1 -1
- package/docs/quickstart-fabric.md +2 -2
- package/docs/quickstart.md +3 -3
- package/docs/releasing.md +13 -13
- package/docs/rem.md +24 -3
- package/docs/secrets-and-keys.md +2 -2
- package/docs/standalone-local.md +29 -2
- package/docs/supply-chain-policy.md +28 -20
- package/docs/the-team.md +2 -2
- package/docs/upgrade.md +14 -0
- package/package.json +18 -11
- package/schemas/agent.graphql +3 -3
- package/schemas/federation.graphql +10 -7
- package/schemas/memory.graphql +7 -2
- 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/dist/commands/grant.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addAdminPassOptions } from "../lib/auth-resolve.js";
|
|
1
2
|
let cli;
|
|
2
3
|
/** Bind the cli-locals this module depends on. */
|
|
3
4
|
export function bindCli(fns) {
|
|
@@ -14,13 +15,12 @@ function resolveAdminUser(...args) {
|
|
|
14
15
|
}
|
|
15
16
|
export function register(program) {
|
|
16
17
|
// ─── flair grant / revoke ─────────────────────────────────────────────────────
|
|
17
|
-
program
|
|
18
|
+
addAdminPassOptions(program
|
|
18
19
|
.command("grant <from-agent> <to-agent>")
|
|
19
20
|
.description("Grant an agent read access to another agent's memories")
|
|
20
21
|
.option("--scope <scope>", "Grant scope: read or search", "read")
|
|
21
22
|
.option("--port <port>", "Harper HTTP port")
|
|
22
|
-
.option("--ops-port <port>", "Harper operations API port")
|
|
23
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
23
|
+
.option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
24
24
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
25
25
|
.option("--keys-dir <dir>", "Directory for Ed25519 keys (for from-agent Ed25519 auth)")
|
|
26
26
|
.action(async (fromAgent, toAgent, opts) => {
|
|
@@ -65,12 +65,11 @@ export function register(program) {
|
|
|
65
65
|
console.log(` ID: ${grantId}`);
|
|
66
66
|
console.log(` Scope: ${scope}`);
|
|
67
67
|
});
|
|
68
|
-
program
|
|
68
|
+
addAdminPassOptions(program
|
|
69
69
|
.command("revoke <from-agent> <to-agent>")
|
|
70
70
|
.description("Revoke a memory grant between two agents")
|
|
71
71
|
.option("--port <port>", "Harper HTTP port")
|
|
72
|
-
.option("--ops-port <port>", "Harper operations API port")
|
|
73
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
72
|
+
.option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
74
73
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
75
74
|
.action(async (fromAgent, toAgent, opts) => {
|
|
76
75
|
const httpPort = resolveHttpPort(opts);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Register `flair help`. Called last, so the root listing keeps the help entry at the bottom. */
|
|
2
|
+
export function registerHelp(program) {
|
|
3
|
+
program
|
|
4
|
+
.command("help")
|
|
5
|
+
.argument("[command...]")
|
|
6
|
+
.description("display help for command")
|
|
7
|
+
.action((path) => {
|
|
8
|
+
let target = program;
|
|
9
|
+
let unknown;
|
|
10
|
+
for (const name of path) {
|
|
11
|
+
const next = target.commands.find((candidate) => candidate.name() === name || candidate.aliases().includes(name));
|
|
12
|
+
if (!next) {
|
|
13
|
+
unknown = name;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
target = next;
|
|
17
|
+
}
|
|
18
|
+
target.outputHelp();
|
|
19
|
+
if (unknown !== undefined) {
|
|
20
|
+
// Same wording as commander's own unknown-command error, on stderr.
|
|
21
|
+
process.stderr.write(`error: unknown command '${unknown}'\n`);
|
|
22
|
+
process.exitCode = 1;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
package/dist/commands/idp.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { encodeRecordId } from "../lib/record-id-path.js";
|
|
14
14
|
import { randomUUID } from "node:crypto";
|
|
15
15
|
import * as render from "../render.js";
|
|
16
|
-
import { resolveAdminUser } from "../lib/auth-resolve.js";
|
|
16
|
+
import { resolveAdminUser, addAdminPassOptions, ApiHttpError } from "../lib/auth-resolve.js";
|
|
17
17
|
let cli;
|
|
18
18
|
/** Bind shared CLI helpers. cli.ts calls this immediately before register(program). */
|
|
19
19
|
export function bindCli(fns) {
|
|
@@ -30,7 +30,7 @@ export function register(program) {
|
|
|
30
30
|
// ─── flair idp ───────────────────────────────────────────────────────────────
|
|
31
31
|
// XAA Enterprise IdP configuration (per FLAIR-XAA spec § 4).
|
|
32
32
|
const idp = program.command("idp").description("Manage enterprise IdP configurations (XAA)");
|
|
33
|
-
idp
|
|
33
|
+
addAdminPassOptions(idp
|
|
34
34
|
.command("add")
|
|
35
35
|
.description("Register a trusted enterprise IdP")
|
|
36
36
|
.requiredOption("--name <name>", "Display name (e.g., 'Harper Corporate')")
|
|
@@ -39,8 +39,7 @@ export function register(program) {
|
|
|
39
39
|
.requiredOption("--client-id <id>", "Flair's client_id at this IdP")
|
|
40
40
|
.option("--required-domain <domain>", "Reject tokens without this domain (hd/tid claim)")
|
|
41
41
|
.option("--no-jit-provision", "Disable auto-creation of principals for new IdP users")
|
|
42
|
-
.option("--default-trust <tier>", "Trust tier for JIT principals", "unverified")
|
|
43
|
-
.option("--admin-pass <pass>", "Admin password")
|
|
42
|
+
.option("--default-trust <tier>", "Trust tier for JIT principals", "unverified"), "Admin password")
|
|
44
43
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
45
44
|
.option("--ops-port <port>", "Harper operations API port")
|
|
46
45
|
.action(async (opts) => {
|
|
@@ -84,10 +83,7 @@ export function register(program) {
|
|
|
84
83
|
console.log(` Domain: ${opts.requiredDomain}`);
|
|
85
84
|
console.log(` JIT: ${opts.jitProvision !== false}`);
|
|
86
85
|
});
|
|
87
|
-
idp
|
|
88
|
-
.command("list")
|
|
89
|
-
.description("List configured IdPs")
|
|
90
|
-
.option("--admin-pass <pass>", "Admin password")
|
|
86
|
+
addAdminPassOptions(idp.command("list").description("List configured IdPs"), "Admin password")
|
|
91
87
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
92
88
|
.option("--ops-port <port>", "Harper operations API port")
|
|
93
89
|
.option("--json", "Emit raw JSON array (also: pipe + FLAIR_OUTPUT=json)")
|
|
@@ -139,10 +135,7 @@ export function register(program) {
|
|
|
139
135
|
console.log();
|
|
140
136
|
}
|
|
141
137
|
});
|
|
142
|
-
idp
|
|
143
|
-
.command("remove <id>")
|
|
144
|
-
.description("Remove an IdP configuration")
|
|
145
|
-
.option("--admin-pass <pass>", "Admin password")
|
|
138
|
+
addAdminPassOptions(idp.command("remove <id>").description("Remove an IdP configuration"), "Admin password")
|
|
146
139
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
147
140
|
.option("--ops-port <port>", "Harper operations API port")
|
|
148
141
|
.action(async (id, opts) => {
|
|
@@ -165,10 +158,8 @@ export function register(program) {
|
|
|
165
158
|
}
|
|
166
159
|
console.log(`✅ IdP '${id}' removed`);
|
|
167
160
|
});
|
|
168
|
-
idp
|
|
169
|
-
.
|
|
170
|
-
.description("Test IdP connectivity (fetches JWKS)")
|
|
171
|
-
.option("--admin-pass <pass>", "Admin password")
|
|
161
|
+
addAdminPassOptions(idp.command("test <id>").description("Test IdP connectivity (fetches JWKS)"), "Admin password")
|
|
162
|
+
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
172
163
|
.option("--ops-port <port>", "Harper operations API port")
|
|
173
164
|
.action(async (id, opts) => {
|
|
174
165
|
const opsPort = resolveOpsPort(opts);
|
|
@@ -179,10 +170,14 @@ export function register(program) {
|
|
|
179
170
|
}
|
|
180
171
|
let cfg;
|
|
181
172
|
try {
|
|
182
|
-
cfg = await api("GET", `/IdpConfig/${encodeRecordId(id)}
|
|
173
|
+
cfg = await api("GET", `/IdpConfig/${encodeRecordId(id)}`, undefined, {
|
|
174
|
+
explicitAdminPass: adminPass, adminUser: opts.adminUser, agentId: null,
|
|
175
|
+
});
|
|
183
176
|
}
|
|
184
|
-
catch {
|
|
185
|
-
console.error(
|
|
177
|
+
catch (err) {
|
|
178
|
+
console.error(err instanceof ApiHttpError && err.status === 404
|
|
179
|
+
? `IdP '${id}' not found`
|
|
180
|
+
: `Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
186
181
|
process.exit(1);
|
|
187
182
|
}
|
|
188
183
|
console.log(`Testing IdP: ${cfg.name} (${cfg.issuer})`);
|
package/dist/commands/import.js
CHANGED
|
@@ -1,8 +1,92 @@
|
|
|
1
|
-
import { defaultKeysDir, resolveAdminUser } from "../lib/auth-resolve.js";
|
|
1
|
+
import { addAdminPassOptions, ApiHttpError, ApiRequestOutcomeUnknown, apiErrorRawBody, defaultKeysDir, isLocalBase, resolveAdminUser, sendJsonRequest, } from "../lib/auth-resolve.js";
|
|
2
2
|
import { encodeRecordId } from "../lib/record-id-path.js";
|
|
3
|
+
import { SOUL_SCOPE_FIELDS_REFUSAL, suppliesSoulScopeFields } from "../lib/soul-scope-fields.js";
|
|
3
4
|
import * as render from "../render.js";
|
|
4
5
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
6
|
import nacl from "tweetnacl";
|
|
7
|
+
/** The fixed error names Flair's write guards return for a Soul or Memory
|
|
8
|
+
* write. A response body's `error` is displayed only when it is one of these;
|
|
9
|
+
* any other server-supplied text is not displayed by the import report. The
|
|
10
|
+
* writes also withhold the response body from the FLAIR_DEBUG HTTP-error
|
|
11
|
+
* line. */
|
|
12
|
+
const WRITE_GUARD_ERROR_NAMES = new Set([
|
|
13
|
+
// Soul write guards (resources/Soul.ts, resources/soul-write-policy.ts).
|
|
14
|
+
"soul_owner_required",
|
|
15
|
+
"soul_scope_fields_not_writable",
|
|
16
|
+
"soul_value_is_learned_content",
|
|
17
|
+
"soul_write_requires_one_record",
|
|
18
|
+
// Memory write guards (resources/Memory.ts and the guards it runs).
|
|
19
|
+
"content_safety_violation",
|
|
20
|
+
"derived_from_self",
|
|
21
|
+
"embedding_unavailable",
|
|
22
|
+
"id_target_mismatch",
|
|
23
|
+
"invalid_durability",
|
|
24
|
+
"invalid_expiry",
|
|
25
|
+
"invalid_visibility",
|
|
26
|
+
"invalid_visibility_for_durability",
|
|
27
|
+
"memory_id_required",
|
|
28
|
+
"owner_lookup_failed",
|
|
29
|
+
"reembed_no_text",
|
|
30
|
+
"reembed_row_changed",
|
|
31
|
+
"skill_durability",
|
|
32
|
+
"skill_lineage_tag_removed",
|
|
33
|
+
"skill_metadata_duplicate_key",
|
|
34
|
+
"skill_opt_out_not_boolean",
|
|
35
|
+
"skill_source_not_durable",
|
|
36
|
+
"skill_state_requires_delete",
|
|
37
|
+
"skill_update_compensation_failed",
|
|
38
|
+
"skill_update_not_closed",
|
|
39
|
+
"skill_update_not_confirmed",
|
|
40
|
+
"skill_update_unconfirmed",
|
|
41
|
+
"skill_write_path",
|
|
42
|
+
"storage_quota_exceeded",
|
|
43
|
+
"stored_row_changed",
|
|
44
|
+
"stored_row_lookup_failed",
|
|
45
|
+
"stored_row_read_failed",
|
|
46
|
+
"unresolved_request_target",
|
|
47
|
+
"write_body_unreadable",
|
|
48
|
+
"write_id_not_addressed",
|
|
49
|
+
]);
|
|
50
|
+
/** A recognised error name from a refused response body; undefined for any
|
|
51
|
+
* other server-supplied text, which the import report does not display. */
|
|
52
|
+
function responseErrorName(raw) {
|
|
53
|
+
if (!raw)
|
|
54
|
+
return undefined;
|
|
55
|
+
try {
|
|
56
|
+
const body = JSON.parse(raw);
|
|
57
|
+
return typeof body?.error === "string" && WRITE_GUARD_ERROR_NAMES.has(body.error) ? body.error : undefined;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** Write one imported row. Only a 2xx response counts as imported. */
|
|
64
|
+
async function writeRow(baseUrl, table, row, auth) {
|
|
65
|
+
try {
|
|
66
|
+
await sendJsonRequest(new URL(`${baseUrl}/${table}/${encodeRecordId(row.id)}`), "PUT", row, auth, isLocalBase(baseUrl), { withholdResponseBodyDebug: true });
|
|
67
|
+
return { kind: "imported" };
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (err instanceof ApiRequestOutcomeUnknown) {
|
|
71
|
+
return { kind: "unknown", status: err.status, message: err.message };
|
|
72
|
+
}
|
|
73
|
+
if (err instanceof ApiHttpError) {
|
|
74
|
+
return { kind: "failed", status: err.status, error: responseErrorName(apiErrorRawBody(err)) };
|
|
75
|
+
}
|
|
76
|
+
// The shared sender parses a 2xx body as JSON; a 2xx body that is not JSON
|
|
77
|
+
// still arrived as a successful write.
|
|
78
|
+
if (err instanceof SyntaxError)
|
|
79
|
+
return { kind: "imported" };
|
|
80
|
+
return { kind: "failed", status: undefined, error: err instanceof Error ? err.message : String(err) };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** The per-row failure text: an HTTP status and a recognised error name, or
|
|
84
|
+
* the thrown error. Never the row's content. */
|
|
85
|
+
function failureText(row) {
|
|
86
|
+
if (row.status === undefined)
|
|
87
|
+
return row.error ?? "no response";
|
|
88
|
+
return `HTTP ${row.status}${row.error ? ` ${row.error}` : ""}`;
|
|
89
|
+
}
|
|
6
90
|
let cli;
|
|
7
91
|
/** Bind the cli-locals this module depends on. */
|
|
8
92
|
export function bindCli(fns) {
|
|
@@ -31,14 +115,13 @@ function seedAgentWithLocalHome(...args) {
|
|
|
31
115
|
}
|
|
32
116
|
export function register(program) {
|
|
33
117
|
// ─── flair import ────────────────────────────────────────────────────────────
|
|
34
|
-
program
|
|
118
|
+
addAdminPassOptions(program
|
|
35
119
|
.command("import <path>")
|
|
36
120
|
.description("Import an agent from an export file into this Flair instance")
|
|
37
121
|
.option("--port <port>", "Harper HTTP port")
|
|
38
122
|
.option("--ops-port <port>", "Harper operations API port")
|
|
39
123
|
.option("--url <url>", "Flair base URL (overrides --port)")
|
|
40
|
-
.option("--ops-target <url>", "Explicit ops API URL for the Agent seed (env: FLAIR_OPS_TARGET; bypasses port derivation). Use when --url is remote and the ops port isn't HTTP-1.")
|
|
41
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
124
|
+
.option("--ops-target <url>", "Explicit ops API URL for the Agent seed (env: FLAIR_OPS_TARGET; bypasses port derivation). Use when --url is remote and the ops port isn't HTTP-1."), "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
42
125
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
43
126
|
.option("--keys-dir <dir>", "Keys directory", defaultKeysDir())
|
|
44
127
|
.action(async (importPath, opts) => {
|
|
@@ -107,32 +190,61 @@ export function register(program) {
|
|
|
107
190
|
// Restore souls before memories: refuseLearnedSoulWrite matches Memory text.
|
|
108
191
|
const auth = `Basic ${Buffer.from(`${resolveAdminUser(opts.adminUser)}:${adminPass}`).toString("base64")}`;
|
|
109
192
|
let soulCount = 0;
|
|
193
|
+
let memCount = 0;
|
|
194
|
+
let failedCount = 0;
|
|
195
|
+
let unknownCount = 0;
|
|
110
196
|
for (const soul of data.souls ?? []) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
method: "PUT",
|
|
114
|
-
headers: { "Content-Type": "application/json", Authorization: auth },
|
|
115
|
-
body: JSON.stringify(soul),
|
|
116
|
-
});
|
|
197
|
+
const outcome = await writeRow(baseUrl, "Soul", soul, auth);
|
|
198
|
+
if (outcome.kind === "imported") {
|
|
117
199
|
soulCount++;
|
|
200
|
+
continue;
|
|
118
201
|
}
|
|
119
|
-
|
|
202
|
+
// A row the server refuses with HTTP 403 for supplying a non-empty
|
|
203
|
+
// `scopeTag` or a non-empty `tags` array is reported with its id and
|
|
204
|
+
// left out of the count; the rest of the export is imported as before
|
|
205
|
+
// (flair#1540).
|
|
206
|
+
if (outcome.kind === "failed" &&
|
|
207
|
+
outcome.status === 403 &&
|
|
208
|
+
outcome.error === SOUL_SCOPE_FIELDS_REFUSAL &&
|
|
209
|
+
suppliesSoulScopeFields(soul)) {
|
|
210
|
+
console.log(`${render.icons.warn} Soul ${soul.id} refused: ${outcome.error}`);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (outcome.kind === "unknown") {
|
|
214
|
+
unknownCount++;
|
|
215
|
+
console.error(`${render.icons.warn} Soul ${soul.id} unknown: ${outcome.message}`);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
failedCount++;
|
|
219
|
+
console.error(`${render.icons.error} Soul ${soul.id} failed: ${failureText(outcome)}`);
|
|
120
220
|
}
|
|
121
|
-
let memCount = 0;
|
|
122
221
|
for (const mem of data.memories ?? []) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
method: "PUT",
|
|
126
|
-
headers: { "Content-Type": "application/json", Authorization: auth },
|
|
127
|
-
body: JSON.stringify(mem),
|
|
128
|
-
});
|
|
222
|
+
const outcome = await writeRow(baseUrl, "Memory", mem, auth);
|
|
223
|
+
if (outcome.kind === "imported") {
|
|
129
224
|
memCount++;
|
|
225
|
+
continue;
|
|
130
226
|
}
|
|
131
|
-
|
|
227
|
+
if (outcome.kind === "unknown") {
|
|
228
|
+
unknownCount++;
|
|
229
|
+
console.error(`${render.icons.warn} Memory ${mem.id} unknown: ${outcome.message}`);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
failedCount++;
|
|
233
|
+
console.error(`${render.icons.error} Memory ${mem.id} failed: ${failureText(outcome)}`);
|
|
132
234
|
}
|
|
133
235
|
console.log(`\n${render.icons.ok} ${render.wrap(render.c.green, `Agent '${agentId}' imported`)}`);
|
|
134
236
|
console.log(render.kv("Memories", `${render.wrap(render.c.bold, String(memCount))}${render.wrap(render.c.dim, `/${(data.memories ?? []).length}`)}`));
|
|
135
237
|
console.log(render.kv("Souls", `${render.wrap(render.c.bold, String(soulCount))}${render.wrap(render.c.dim, `/${(data.souls ?? []).length}`)}`));
|
|
238
|
+
if (failedCount > 0)
|
|
239
|
+
console.log(render.kv("Failed", String(failedCount)));
|
|
240
|
+
if (unknownCount > 0)
|
|
241
|
+
console.log(render.kv("Unknown", String(unknownCount)));
|
|
136
242
|
console.log(render.kv("Key", render.wrap(render.c.dim, privPath)));
|
|
243
|
+
// An unknown write outcome exits 3, as the REM runner and `flair memory
|
|
244
|
+
// verify` use it, distinct from the 1 a definite failure exits with.
|
|
245
|
+
if (unknownCount > 0)
|
|
246
|
+
process.exit(3);
|
|
247
|
+
if (failedCount > 0)
|
|
248
|
+
process.exit(1);
|
|
137
249
|
});
|
|
138
250
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -2,7 +2,7 @@ import { applyOrReportClaudeMdBootstrap } from "../doctor-client.js";
|
|
|
2
2
|
import { applyOrRepinSessionStartHook } from "../lib/owned-pins.js";
|
|
3
3
|
import { hookSettingsPath } from "../hook-install.js";
|
|
4
4
|
import { claudeCodeMcpEntry, detectClients, renderWiringSummary, wireAntigravity, wireClaudeCodeJson, wireCodex, wireCursor, wireGemini, wirePi } from "../install/clients.js";
|
|
5
|
-
import { DEFAULT_ADMIN_USER, authFetch, defaultAdminPassPath, defaultKeysDir, readAdminPassFileSecure, resolveAdminUser } from "../lib/auth-resolve.js";
|
|
5
|
+
import { DEFAULT_ADMIN_USER, ApiRequestOutcomeUnknown, addAdminPassOptions, authFetch, defaultAdminPassPath, defaultKeysDir, readAdminPassFileSecure, resolveAdminUser } from "../lib/auth-resolve.js";
|
|
6
6
|
import { INIT_RESET_ADMIN_PASS_COMMAND, detectPersistedAdminUser, executeAdminPasswordRotate, initAdminPassRefusalMessage, resolveInitAdminPasswordRefuseReason, resolveInitAdminPasswordSource, } from "../lib/init-admin-pass.js";
|
|
7
7
|
import { canonicalLexicalPath } from "../lib/daemon-liveness.js";
|
|
8
8
|
import { encodeRecordId } from "../lib/record-id-path.js";
|
|
@@ -217,7 +217,7 @@ export function register(program) {
|
|
|
217
217
|
const MQTT_DISABLED_CONFIG = cli.MQTT_DISABLED_CONFIG;
|
|
218
218
|
const STARTUP_TIMEOUT_MS = cli.STARTUP_TIMEOUT_MS;
|
|
219
219
|
// ─── flair init ──────────────────────────────────────────────────────────────
|
|
220
|
-
program
|
|
220
|
+
addAdminPassOptions(program
|
|
221
221
|
.command("init")
|
|
222
222
|
.description("One-command Flair setup — bootstrap the instance, register an agent, and wire MCP clients")
|
|
223
223
|
.option("--agent-id <id>", "Agent ID to register (omit to bootstrap instance without agent)")
|
|
@@ -230,9 +230,7 @@ export function register(program) {
|
|
|
230
230
|
.option("--port <port>", "Harper HTTP port (default: this instance's current port, or 19926 for a new one)")
|
|
231
231
|
.option("--ops-port <port>", "Harper operations API port")
|
|
232
232
|
.option("--ops-bind <addr>", "Harper ops API bind address (env: FLAIR_OPS_BIND; default: 127.0.0.1 loopback-only for single-host — pass e.g. 0.0.0.0 for multi-host/Fabric remote admin)")
|
|
233
|
-
.option("--http-bind <addr>", "Harper HTTP bind address (env: FLAIR_HTTP_BIND; default: 127.0.0.1 loopback-only). The listener MUST include IPv4 loopback (Flair's self-calls hardcode 127.0.0.1), so only 127.0.0.1 or a wildcard (0.0.0.0 / ::) is accepted; a specific non-loopback host is refused.")
|
|
234
|
-
.option("--admin-pass <pass>", "Admin password (generated if omitted)")
|
|
235
|
-
.option("--admin-pass-file <path>", "Read admin password from file (chmod 600 recommended)")
|
|
233
|
+
.option("--http-bind <addr>", "Harper HTTP bind address (env: FLAIR_HTTP_BIND; default: 127.0.0.1 loopback-only). The listener MUST include IPv4 loopback (Flair's self-calls hardcode 127.0.0.1), so only 127.0.0.1 or a wildcard (0.0.0.0 / ::) is accepted; a specific non-loopback host is refused."), "Admin password (generated if omitted)", { adminPassFileHelp: "Read admin password from file (chmod 600 recommended)" })
|
|
236
234
|
.option("--reset-admin-pass", "Rotate Harper's persisted admin hash via the operations socket, then write ~/.flair/admin-pass")
|
|
237
235
|
.option("--admin-user <name>", "Admin username when authenticating to an already-running instance via --target/--ops-target (env: FLAIR_ADMIN_USER; default: admin — local bootstrap and Fabric provisioning always create 'admin')")
|
|
238
236
|
.option("--keys-dir <dir>", "Directory for Ed25519 keys")
|
|
@@ -703,8 +701,8 @@ export function register(program) {
|
|
|
703
701
|
resetRequested: !!opts.resetAdminPass,
|
|
704
702
|
opsSocketAvailable: alreadyRunning || !opts.skipStart,
|
|
705
703
|
};
|
|
706
|
-
// Warn if --admin-pass is passed inline (not from env)
|
|
707
|
-
if (shouldShowInlineSecretWarning(opts.
|
|
704
|
+
// Warn if --admin-pass is passed inline (not from env or a file)
|
|
705
|
+
if (shouldShowInlineSecretWarning(opts.inlineAdminPass, false, new Set(["--admin-pass"]), "--admin-pass")) {
|
|
708
706
|
console.error("warning: --admin-pass passed inline. Consider --admin-pass-file <path> or FLAIR_ADMIN_PASS env " +
|
|
709
707
|
"to keep secrets out of shell history.");
|
|
710
708
|
}
|
|
@@ -1389,6 +1387,8 @@ export function register(program) {
|
|
|
1389
1387
|
console.log(` ✓ soul:${key} set`);
|
|
1390
1388
|
}
|
|
1391
1389
|
catch (err) {
|
|
1390
|
+
if (err instanceof ApiRequestOutcomeUnknown)
|
|
1391
|
+
throw err;
|
|
1392
1392
|
const message = err instanceof Error ? err.message : String(err);
|
|
1393
1393
|
console.warn(` ⚠ soul:${key} failed: ${message}`);
|
|
1394
1394
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addAdminPassOptions } from "../lib/auth-resolve.js";
|
|
1
2
|
import { readExactCountSince, readExactTableCount } from "../lib/ops-table-count.js";
|
|
2
3
|
import { InconsistentReadError, readTableByIdPaged } from "../memory-id-checkpoint.js";
|
|
3
4
|
import { writeConfirmed } from "../lib/instance-identity-row.js";
|
|
@@ -272,14 +273,13 @@ export function register(program) {
|
|
|
272
273
|
const integrity = program
|
|
273
274
|
.command("integrity")
|
|
274
275
|
.description("Detect missing checkpointed durable Memory IDs or changed or missing previously nonempty tokens");
|
|
275
|
-
integrity
|
|
276
|
+
addAdminPassOptions(integrity
|
|
276
277
|
.command("check")
|
|
277
278
|
.description("Report missing checkpointed durable IDs or changed or missing previously nonempty tokens; rows created and lost entirely between scans are not observed")
|
|
278
279
|
.option("--json", "Print the verdict as JSON")
|
|
279
280
|
.option("--accept", "On an alert, advance the whole checkpoint only if no reported replacement lacks a token; otherwise write no checkpoint, even with other losses")
|
|
280
281
|
.option("--checkpoint <path>", "Checkpoint file path (default: ~/.flair/integrity-checkpoint.json)")
|
|
281
|
-
.option("--ops-port <port>", "Harper operations API port")
|
|
282
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
282
|
+
.option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
283
283
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
284
284
|
.action(async (opts) => {
|
|
285
285
|
const opsPort = cli.resolveOpsPort(opts);
|
|
@@ -344,15 +344,14 @@ export function register(program) {
|
|
|
344
344
|
// bounded one-shot process, and the next run simply omits --apply. It prunes
|
|
345
345
|
// nothing — with a named reason — when a checkpoint is missing or a watermark
|
|
346
346
|
// is unreadable.
|
|
347
|
-
integrity
|
|
347
|
+
addAdminPassOptions(integrity
|
|
348
348
|
.command("prune-history")
|
|
349
349
|
.description("Prune MemoryDeletionHistory rows older than the oldest named checkpoint watermark minus a margin; dry-run unless --apply")
|
|
350
350
|
.option("--checkpoint <path...>", "Checkpoint file whose watermark bounds the prune; repeat for several (default: ~/.flair/integrity-checkpoint.json)")
|
|
351
351
|
.option("--apply", "Delete the eligible rows; without it nothing is deleted")
|
|
352
352
|
.option("--max <n>", "Hard cap on rows pruned in one run (default: 500)")
|
|
353
353
|
.option("--json", "Print the plan as JSON")
|
|
354
|
-
.option("--ops-port <port>", "Harper operations API port")
|
|
355
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
354
|
+
.option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS env)")
|
|
356
355
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
357
356
|
.action(async (opts) => {
|
|
358
357
|
const opsPort = cli.resolveOpsPort(opts);
|
package/dist/commands/mcp.js
CHANGED
|
@@ -2,7 +2,7 @@ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "n
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import nacl from "tweetnacl";
|
|
4
4
|
import * as render from "../render.js";
|
|
5
|
-
import { defaultKeysDir, resolveAdminUser, resolveLocalAdminPass } from "../lib/auth-resolve.js";
|
|
5
|
+
import { defaultKeysDir, resolveAdminUser, resolveLocalAdminPass, addAdminPassOptions } from "../lib/auth-resolve.js";
|
|
6
6
|
import { resolveAgentKeyPath, loadEd25519PrivateKeyFromFile, signClientAssertion, buildTokenRequestForm, getMcpAccessToken, McpTokenRequestError, defaultMcpClientId, defaultMcpTokenEndpoint, defaultMcpResource, defaultMcpIssuer, MAX_ASSERTION_LIFETIME_SECONDS, clientAssertionAudienceForm, resolveClientAssertionAudience, oauthMetadataUrl, } from "../mcp-client-assertion.js";
|
|
7
7
|
import { enableMcp, refreshMcpOAuthFlag, disableMcp, mcpStatus, checkLocalOriginRefusal, fabricLoopbackRefusal, targetOriginRefusal, selfVerifyMcpMetadata, cimdAllowedHostsFromFlag, claudeAiExcludedNote, } from "../lib/mcp-enable.js";
|
|
8
8
|
import { resolveHome } from "../lib/home.js";
|
|
@@ -445,14 +445,13 @@ export function register(program) {
|
|
|
445
445
|
process.exit(1);
|
|
446
446
|
}
|
|
447
447
|
});
|
|
448
|
-
mcp
|
|
448
|
+
addAdminPassOptions(mcp
|
|
449
449
|
.command("grant <name>")
|
|
450
450
|
.description("Provision a named, individually-revocable machine client for the /mcp OAuth surface " +
|
|
451
451
|
"(flair Agent + Ed25519 keypair; the existing CIMD path — see `flair mcp token` — makes it usable).")
|
|
452
452
|
.option("--issuer <url>", "Public origin for the CIMD client_id (defaults to FLAIR_MCP_ISSUER/FLAIR_PUBLIC_URL)")
|
|
453
453
|
.option("--keys-dir <dir>", "Directory to write the new key pair into (else FLAIR_KEY_DIR, ~/.flair/keys)")
|
|
454
|
-
.option("--manifest <path>", "Path to the local machine-client manifest (else ~/.flair/mcp-clients.json)")
|
|
455
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS)")
|
|
454
|
+
.option("--manifest <path>", "Path to the local machine-client manifest (else ~/.flair/mcp-clients.json)"), "Admin password (or set FLAIR_ADMIN_PASS)")
|
|
456
455
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
457
456
|
.option("--port <port>", "Harper HTTP port")
|
|
458
457
|
.option("--ops-port <port>", "Harper operations API port")
|
|
@@ -509,11 +508,10 @@ export function register(program) {
|
|
|
509
508
|
process.exit(1);
|
|
510
509
|
}
|
|
511
510
|
});
|
|
512
|
-
mcp
|
|
511
|
+
addAdminPassOptions(mcp
|
|
513
512
|
.command("revoke <name>")
|
|
514
513
|
.description("Server-side revoke a granted machine client (deletes its backing Agent record), then clean up locally.")
|
|
515
|
-
.option("--manifest <path>", "Path to the local machine-client manifest (else ~/.flair/mcp-clients.json)")
|
|
516
|
-
.option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS)")
|
|
514
|
+
.option("--manifest <path>", "Path to the local machine-client manifest (else ~/.flair/mcp-clients.json)"), "Admin password (or set FLAIR_ADMIN_PASS)")
|
|
517
515
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
518
516
|
.option("--issuer <url>", "Public origin of the /mcp OAuth surface — used only for the enable-gate probe (defaults to FLAIR_MCP_ISSUER/FLAIR_PUBLIC_URL)")
|
|
519
517
|
.option("--ops-port <port>", "Harper operations API port")
|
|
@@ -580,7 +578,7 @@ export function register(program) {
|
|
|
580
578
|
];
|
|
581
579
|
console.log(render.table(cols, entries));
|
|
582
580
|
});
|
|
583
|
-
mcp
|
|
581
|
+
addAdminPassOptions(mcp
|
|
584
582
|
.command("enable")
|
|
585
583
|
.description("Enable the OAuth /mcp surface for claude.ai. " +
|
|
586
584
|
"Rejects invalid issuer URLs, localhost/.localhost/.local hosts, " +
|
|
@@ -602,8 +600,7 @@ export function register(program) {
|
|
|
602
600
|
"Without --dry-run, refused unless a preflight match links the host and pid the target reports, a readable " +
|
|
603
601
|
"process on this machine, and that file (by realpath); --dry-run skips the match and writes nothing. " +
|
|
604
602
|
"Always refused with --fabric or a *.harperfabric.com instance. " +
|
|
605
|
-
"Without it the list is not changed (shipped: claude.ai,claude.com)")
|
|
606
|
-
.option("--admin-pass <pass>", "Admin password for the TARGET instance. Required explicitly for a remote target — FLAIR_ADMIN_PASS and ~/.flair/admin-pass are this machine's local credentials and are never sent to a remote instance")
|
|
603
|
+
"Without it the list is not changed (shipped: claude.ai,claude.com)"), "Admin password for the TARGET instance. Required explicitly for a remote target — FLAIR_ADMIN_PASS and ~/.flair/admin-pass are this machine's local credentials and are never sent to a remote instance")
|
|
607
604
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
608
605
|
.option("--confirm-secrets-applied", "Confirm the staged secrets are already live on the target instance's environment (skips the interactive confirm)")
|
|
609
606
|
.option("--fabric", "Use the Fabric branch and default to Fabric secrets staging; refused for a localhost, *.localhost, 127/8, ::1, ::ffff:127/8, 0.0.0.0 or :: target host")
|
|
@@ -637,7 +634,7 @@ export function register(program) {
|
|
|
637
634
|
const dryRun = Boolean(opts.dryRun);
|
|
638
635
|
const adminPass = dryRun ? (opts.adminPass ?? process.env.FLAIR_ADMIN_PASS ?? "") : resolveLocalAdminPass(opts.adminPass, /* isRemoteTarget */ true);
|
|
639
636
|
if (!dryRun && !adminPass) {
|
|
640
|
-
console.error("Error: --admin-pass <pass> is required for a
|
|
637
|
+
console.error("Error: --admin-pass <pass> or --admin-pass-file <path> is required for a target instance " +
|
|
641
638
|
"(the command authenticates to the target instance's operations API with it).\n" +
|
|
642
639
|
" FLAIR_ADMIN_PASS and ~/.flair/admin-pass are deliberately NOT used here: they are THIS machine's " +
|
|
643
640
|
"local admin credentials, and sending them to another instance is how a local secret ends up on someone " +
|
|
@@ -736,11 +733,10 @@ export function register(program) {
|
|
|
736
733
|
for (const line of enableSuccessLines(result))
|
|
737
734
|
console.log(line);
|
|
738
735
|
});
|
|
739
|
-
mcp
|
|
736
|
+
addAdminPassOptions(mcp
|
|
740
737
|
.command("disable")
|
|
741
738
|
.description("Flag off + restart = byte-identical boot (Model-2 contract) — removes the /mcp OAuth surface.")
|
|
742
|
-
.option("--instance <url>", "
|
|
743
|
-
.option("--admin-pass <pass>", "Admin password for the remote target instance; pass it explicitly with --admin-pass")
|
|
739
|
+
.option("--instance <url>", "Flair instance to disable against (else FLAIR_URL)"), "Admin password for the target instance; use --admin-pass or --admin-pass-file", { adminPassFileHelp: "Read the target instance's admin password from an owner-only file (group and world permission bits are refused; an owner-only mode such as 0600 or 0400 is accepted)" })
|
|
744
740
|
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
745
741
|
.option("--confirm-flag-off", "Confirm FLAIR_MCP_OAUTH is already unset on the target instance's environment (skips the interactive confirm)")
|
|
746
742
|
.option("--json", "Print machine-readable JSON instead of a human summary")
|
|
@@ -750,11 +746,9 @@ export function register(program) {
|
|
|
750
746
|
console.error("Error: --instance is required (or set FLAIR_URL).");
|
|
751
747
|
process.exit(1);
|
|
752
748
|
}
|
|
753
|
-
// --instance is always remote for this command — see the matching
|
|
754
|
-
// comment in `mcp enable` above.
|
|
755
749
|
const adminPass = resolveLocalAdminPass(opts.adminPass, /* isRemoteTarget */ true);
|
|
756
750
|
if (!adminPass) {
|
|
757
|
-
console.error("Error: --admin-pass <pass> is required for a
|
|
751
|
+
console.error("Error: --admin-pass <pass> or --admin-pass-file <path> is required for a target instance. Pass the target instance's admin password explicitly.");
|
|
758
752
|
process.exit(1);
|
|
759
753
|
}
|
|
760
754
|
const result = await disableMcp({ instance, adminUser: resolveAdminUser(opts.adminUser), adminPass, confirmFlagOff: Boolean(opts.confirmFlagOff) }, { confirmPrompt: confirmYesNo });
|
package/dist/commands/memory.js
CHANGED
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { Option } from "commander";
|
|
15
15
|
import * as render from "../render.js";
|
|
16
|
-
import { resolveAdminUser } from "../lib/auth-resolve.js";
|
|
16
|
+
import { resolveAdminUser, addAdminPassOptions } from "../lib/auth-resolve.js";
|
|
17
17
|
import { encodeRecordId } from "../lib/record-id-path.js";
|
|
18
18
|
import { DURABILITY_TIERS_HELP } from "../lib/durability-copy.js";
|
|
19
19
|
import { resolveLocalDeleteInstance } from "../lib/local-delete-instance.js";
|
|
20
20
|
import { confirmedPurgeIds } from "../lib/memory-purge-response.js";
|
|
21
21
|
import { resolveHome } from "../lib/home.js";
|
|
22
22
|
import { ALL_TIERS } from "../lib/memory-integrity.js";
|
|
23
|
+
import { MEMORY_PROVIDER_RETRY_DELAY_MS, isProviderTimeoutRefusal, } from "../lib/memory-provider-timeout.js";
|
|
23
24
|
import { normalizeOrigin, buildCheckpoint, buildOpsPost, readMemoryRowCount, readMemoryRowsPaged, readCheckpointFile, writeCheckpointFile, checkpointPath, unknownVerify, verifyCheckpoint, renderVerifyHuman, VERIFY_EXIT_CODES, } from "../memory-id-checkpoint.js";
|
|
24
25
|
import { classifyNodeSets, readNode, renderCompareNodesHuman, COMPARE_EXIT_CODES, } from "../memory-node-compare.js";
|
|
25
26
|
let cli;
|
|
@@ -36,9 +37,6 @@ function resolveBaseUrl(opts) {
|
|
|
36
37
|
function resolveSigningAgentId(opts, command) {
|
|
37
38
|
return cli.resolveSigningAgentId(opts, command);
|
|
38
39
|
}
|
|
39
|
-
function applyAdminPassFile(opts) {
|
|
40
|
-
cli.applyAdminPassFile(opts);
|
|
41
|
-
}
|
|
42
40
|
function addSharedCredentialOptions(cmd) {
|
|
43
41
|
return cli.addSharedCredentialOptions(cmd);
|
|
44
42
|
}
|
|
@@ -80,6 +78,11 @@ export function categorizeForHygiene(row, opts) {
|
|
|
80
78
|
export function register(program) {
|
|
81
79
|
// ─── flair memory ──────────────────────────────────────────────────────────
|
|
82
80
|
const ENTITIES_OPTION_DESCRIPTION = cli.ENTITIES_OPTION_DESCRIPTION;
|
|
81
|
+
// A write refused with 503 memory_provider_timeout wrote nothing (the
|
|
82
|
+
// write-lock contract), so `memory add` replays it with the same id. The
|
|
83
|
+
// bounded attempt count keeps a slow provider from turning one command into
|
|
84
|
+
// an unbounded wait.
|
|
85
|
+
const MEMORY_ADD_MAX_ATTEMPTS = 3;
|
|
83
86
|
const memory = program.command("memory").description("Manage agent memories");
|
|
84
87
|
addSharedCredentialOptions(addSharedIdentityOption(memory.command("add [content]")
|
|
85
88
|
.description("Write a new memory row for an agent (content via positional arg or --content)")))
|
|
@@ -96,7 +99,6 @@ export function register(program) {
|
|
|
96
99
|
console.error("error: content required (positional arg or --content)");
|
|
97
100
|
process.exit(1);
|
|
98
101
|
}
|
|
99
|
-
applyAdminPassFile(opts);
|
|
100
102
|
const { agentId, source } = resolveSigningAgentId(opts, "memory add");
|
|
101
103
|
if (!agentId) {
|
|
102
104
|
console.error("error: --agent <id> required (or set FLAIR_AGENT_ID)");
|
|
@@ -137,12 +139,27 @@ export function register(program) {
|
|
|
137
139
|
if (entities.length > 0)
|
|
138
140
|
body.entities = entities;
|
|
139
141
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
let out;
|
|
143
|
+
for (let attempt = 1;; attempt++) {
|
|
144
|
+
try {
|
|
145
|
+
out = await api("PUT", `/Memory/${encodeRecordId(memId)}`, body, {
|
|
146
|
+
agentId,
|
|
147
|
+
agentIdSource: source,
|
|
148
|
+
explicitAdminPass: opts.adminPass,
|
|
149
|
+
adminUser: opts.adminUser,
|
|
150
|
+
});
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
if (!isProviderTimeoutRefusal(err))
|
|
155
|
+
throw err;
|
|
156
|
+
if (attempt >= MEMORY_ADD_MAX_ATTEMPTS) {
|
|
157
|
+
console.error(`error: memory add: the embedding provider timed out (503 memory_provider_timeout) on all ${attempt} attempts; nothing was written — retry when the provider is responsive`);
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
await new Promise((resolve) => setTimeout(resolve, MEMORY_PROVIDER_RETRY_DELAY_MS * attempt));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
146
163
|
console.log(JSON.stringify(out, null, 2));
|
|
147
164
|
});
|
|
148
165
|
// ─── flair memory write-task-summary ────────────────────────────────────────
|
|
@@ -225,10 +242,11 @@ export function register(program) {
|
|
|
225
242
|
// without parsing a JSON blob.
|
|
226
243
|
console.log(memId);
|
|
227
244
|
});
|
|
228
|
-
memory
|
|
245
|
+
addAdminPassOptions(memory
|
|
246
|
+
.command("search [query]")
|
|
229
247
|
.description("Semantic search over an agent's memories (query via positional arg or --q)")
|
|
230
|
-
.option("--agent <id>", "Agent ID (or set FLAIR_AGENT_ID env)")
|
|
231
|
-
.option("--admin-
|
|
248
|
+
.option("--agent <id>", "Agent ID (or set FLAIR_AGENT_ID env)"), "Admin password — sign as admin while --agent names whose memories to search (flair#1500: a flag-pinned agent with no key no longer falls back to FLAIR_ADMIN_PASS)")
|
|
249
|
+
.option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
|
|
232
250
|
.option("--q <query>", "search query (alias for positional arg)")
|
|
233
251
|
.option("--json", "Output raw JSON array")
|
|
234
252
|
.option("--limit <n>", "Max results", "5")
|
|
@@ -254,7 +272,7 @@ export function register(program) {
|
|
|
254
272
|
if (opts.includeArchived)
|
|
255
273
|
body.includeArchived = true;
|
|
256
274
|
const baseUrl = resolveBaseUrl(opts);
|
|
257
|
-
const res = await api("POST", "/SemanticSearch", body, { baseUrl, agentId, agentIdSource: source, explicitAdminPass: opts.adminPass });
|
|
275
|
+
const res = await api("POST", "/SemanticSearch", body, { baseUrl, agentId, agentIdSource: source, explicitAdminPass: opts.adminPass, adminUser: opts.adminUser });
|
|
258
276
|
if (opts.json) {
|
|
259
277
|
const results = res.results || res || [];
|
|
260
278
|
console.log(render.asJSON(Array.isArray(results) ? results : []));
|