@tpsdev-ai/flair 0.62.0 → 0.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/README.md +14 -13
  2. package/SECURITY.md +73 -43
  3. package/config.yaml +11 -11
  4. package/dist/bridges/runtime/execute.js +1 -0
  5. package/dist/bridges/runtime/import-runner.js +4 -0
  6. package/dist/bridges/types.js +1 -0
  7. package/dist/build-info.json +3 -3
  8. package/dist/cli.js +309 -205
  9. package/dist/commands/agent.js +325 -137
  10. package/dist/commands/attention.js +2 -0
  11. package/dist/commands/backup-approval.js +218 -0
  12. package/dist/commands/backup.js +37 -33
  13. package/dist/commands/bootstrap.js +5 -1
  14. package/dist/commands/bridge.js +10 -0
  15. package/dist/commands/deploy.js +37 -7
  16. package/dist/commands/doctor.js +206 -42
  17. package/dist/commands/export.js +144 -15
  18. package/dist/commands/federation.js +653 -68
  19. package/dist/commands/grant.js +5 -6
  20. package/dist/commands/help.js +25 -0
  21. package/dist/commands/idp.js +14 -19
  22. package/dist/commands/import.js +167 -34
  23. package/dist/commands/init.js +380 -164
  24. package/dist/commands/integrity.js +5 -6
  25. package/dist/commands/keys.js +12 -8
  26. package/dist/commands/mcp.js +157 -79
  27. package/dist/commands/memory.js +38 -17
  28. package/dist/commands/migrate-harness-memory.js +9 -3
  29. package/dist/commands/orgevent.js +5 -10
  30. package/dist/commands/principal.js +32 -39
  31. package/dist/commands/quality.js +26 -3
  32. package/dist/commands/reembed.js +468 -111
  33. package/dist/commands/rem.js +484 -65
  34. package/dist/commands/restore.js +352 -44
  35. package/dist/commands/search.js +2 -0
  36. package/dist/commands/service.js +109 -2
  37. package/dist/commands/soul.js +0 -6
  38. package/dist/commands/status.js +165 -124
  39. package/dist/commands/test.js +4 -1
  40. package/dist/commands/upgrade.js +53 -22
  41. package/dist/commands/workspace.js +7 -8
  42. package/dist/deploy.js +59 -3
  43. package/dist/doctor-client.js +9 -25
  44. package/dist/fabric-upgrade.js +12 -2
  45. package/dist/federation/presence-send.js +139 -0
  46. package/dist/federation/scheduler.js +148 -12
  47. package/dist/federation-verify.js +269 -177
  48. package/dist/install/clients.js +171 -35
  49. package/dist/keystore.js +77 -10
  50. package/dist/lib/agent-id-rule.js +44 -2
  51. package/dist/lib/agent-key-file.js +509 -0
  52. package/dist/lib/agent-rotation-lock.js +249 -0
  53. package/dist/lib/atomic-write.js +3 -3
  54. package/dist/lib/auth-resolve.js +1040 -64
  55. package/dist/lib/backup-approval-store.js +612 -0
  56. package/dist/lib/backup-artifact.js +343 -0
  57. package/dist/lib/config-critical-section.js +212 -25
  58. package/dist/lib/connect-phase.js +33 -0
  59. package/dist/lib/daemon-liveness.js +2 -1
  60. package/dist/lib/federation-pair-access.js +4 -0
  61. package/dist/lib/federation-retry-queue.js +283 -0
  62. package/dist/lib/federation-retry-row.js +101 -0
  63. package/dist/lib/instruction-event-contract.js +17 -0
  64. package/dist/lib/instruction-event-doctor.js +102 -0
  65. package/dist/lib/key-dir.js +203 -0
  66. package/dist/lib/launchd-management.js +21 -6
  67. package/dist/lib/local-instance-pair.js +8 -1
  68. package/dist/lib/mcp-enable.js +14 -15
  69. package/dist/lib/memory-attributes.js +2 -0
  70. package/dist/lib/memory-provider-timeout.js +33 -0
  71. package/dist/lib/mqtt-config.js +132 -0
  72. package/dist/lib/mqtt-listener-doctor.js +104 -0
  73. package/dist/lib/node-alias-path.js +50 -2
  74. package/dist/lib/open-live-row.js +20 -0
  75. package/dist/lib/ops-url.js +52 -0
  76. package/dist/lib/promotion-content-hash.js +20 -0
  77. package/dist/lib/remote-admin-pass.js +157 -0
  78. package/dist/lib/restore-archive.js +760 -0
  79. package/dist/lib/restore-verify.js +1 -1
  80. package/dist/lib/scheduler-platform.js +13 -0
  81. package/dist/lib/service-repoint.js +13 -4
  82. package/dist/lib/skill-assignment-preflight.js +159 -0
  83. package/dist/lib/skill-seed.js +125 -10
  84. package/dist/lib/skill-tombstone-doctor.js +133 -0
  85. package/dist/lib/soul-scope-fields.js +26 -0
  86. package/dist/lib/terminal-text.js +32 -0
  87. package/dist/lib/uninstall-purge.js +266 -11
  88. package/dist/lib/upgrade-prior-liveness.js +2 -1
  89. package/dist/mcp-client-assertion.js +7 -14
  90. package/dist/memory-id-checkpoint.js +28 -7
  91. package/dist/mqtt-off-deploy.js +550 -0
  92. package/dist/rem/promote-policy.js +3 -3
  93. package/dist/rem/restore.js +302 -26
  94. package/dist/rem/runner.js +220 -58
  95. package/dist/rem/scheduler.js +21 -4
  96. package/dist/resources/A2AAdapter.js +131 -178
  97. package/dist/resources/AdminMemory.js +2 -0
  98. package/dist/resources/AdminMemoryCandidates.js +116 -0
  99. package/dist/resources/Agent.js +155 -45
  100. package/dist/resources/AgentCard.js +4 -0
  101. package/dist/resources/AgentKeyRegister.js +56 -22
  102. package/dist/resources/AgentReadPosition.js +7 -0
  103. package/dist/resources/AgentSeed.js +232 -107
  104. package/dist/resources/AutoPromoteCandidates.js +413 -84
  105. package/dist/resources/Credential.js +6 -8
  106. package/dist/resources/Federation.js +219 -57
  107. package/dist/resources/FederationRetry.js +4 -4
  108. package/dist/resources/InstructionVersion.js +1 -1
  109. package/dist/resources/MCPClientMetadata.js +6 -3
  110. package/dist/resources/Memory.js +1348 -271
  111. package/dist/resources/MemoryArchive.js +149 -64
  112. package/dist/resources/MemoryBootstrap.js +12 -22
  113. package/dist/resources/MemoryCandidate.js +16 -2
  114. package/dist/resources/MemoryConsolidate.js +2 -2
  115. package/dist/resources/MemoryFeed.js +360 -147
  116. package/dist/resources/MemoryMaintenance.js +290 -72
  117. package/dist/resources/MemoryPurge.js +138 -22
  118. package/dist/resources/MemoryReflect.js +68 -14
  119. package/dist/resources/MemoryReindex.js +91 -13
  120. package/dist/resources/Message.js +11 -2
  121. package/dist/resources/OAuth.js +156 -39
  122. package/dist/resources/OAuthClient.js +1 -1
  123. package/dist/resources/OrgEvent.js +292 -29
  124. package/dist/resources/OrgEventCatchup.js +7 -0
  125. package/dist/resources/OrgEventMaintenance.js +48 -10
  126. package/dist/resources/PairingToken.js +1 -1
  127. package/dist/resources/Presence.js +31 -11
  128. package/dist/resources/PromoteMemoryCandidate.js +8 -2
  129. package/dist/resources/RecordUsage.js +2 -4
  130. package/dist/resources/Soul.js +2 -0
  131. package/dist/resources/SoulFeed.js +2 -1
  132. package/dist/resources/WorkspaceLatest.js +4 -0
  133. package/dist/resources/XAA.js +36 -10
  134. package/dist/resources/a2a-stream.js +313 -0
  135. package/dist/resources/a2a-url.js +4 -5
  136. package/dist/resources/agent-admin.js +10 -1
  137. package/dist/resources/agent-auth.js +98 -68
  138. package/dist/resources/agent-read-position-lib.js +4 -1
  139. package/dist/resources/agent-status-guard.js +9 -7
  140. package/dist/resources/auth-middleware.js +166 -42
  141. package/dist/resources/authority-field-guard.js +9 -11
  142. package/dist/resources/auto-promote-lib.js +8 -5
  143. package/dist/resources/basic-auth-header.js +21 -0
  144. package/dist/resources/bm25-index-service.js +4 -5
  145. package/dist/resources/dedup-cluster.js +6 -1
  146. package/dist/resources/embeddings-provider.js +25 -0
  147. package/dist/resources/federation-classify.js +89 -0
  148. package/dist/resources/federation-retry-lib.js +6 -81
  149. package/dist/resources/health.js +75 -19
  150. package/dist/resources/host-pointer/registry.js +29 -0
  151. package/dist/resources/host-pointer-adapter.js +1 -0
  152. package/dist/resources/in-process-api.js +74 -11
  153. package/dist/resources/in-process.js +24 -22
  154. package/dist/resources/instruction-version-record.js +251 -7
  155. package/dist/resources/internal-authority.js +13 -0
  156. package/dist/resources/mcp-client-metadata-fields.js +4 -0
  157. package/dist/resources/mcp-handler.js +146 -13
  158. package/dist/resources/mcp-oauth-flag.js +12 -14
  159. package/dist/resources/mcp-oauth.js +446 -53
  160. package/dist/resources/mcp-tool-scopes.js +69 -0
  161. package/dist/resources/mcp-tools.js +70 -22
  162. package/dist/resources/memory-declared-attributes.js +1 -0
  163. package/dist/resources/memory-embed-hash.js +56 -0
  164. package/dist/resources/memory-host-source.js +5 -2
  165. package/dist/resources/memory-reflect-lib.js +1 -1
  166. package/dist/resources/memory-write-lock.js +202 -23
  167. package/dist/resources/memory-write-response.js +1 -1
  168. package/dist/resources/memory-write-transaction.js +243 -0
  169. package/dist/resources/migration-boot.js +17 -12
  170. package/dist/resources/migrations/boot-progress.js +25 -0
  171. package/dist/resources/migrations/data-dir.js +16 -3
  172. package/dist/resources/migrations/dir-safety.js +60 -2
  173. package/dist/resources/migrations/embedding-stamp.js +315 -49
  174. package/dist/resources/migrations/graph-heal.js +9 -2
  175. package/dist/resources/migrations/ledger.js +5 -2
  176. package/dist/resources/migrations/lock.js +867 -80
  177. package/dist/resources/migrations/progress.js +71 -10
  178. package/dist/resources/migrations/runner.js +212 -18
  179. package/dist/resources/migrations/state.js +36 -1
  180. package/dist/resources/migrations/status.js +2 -13
  181. package/dist/resources/migrations/synthetic-test-migration.js +78 -12
  182. package/dist/resources/migrations/types.js +26 -1
  183. package/dist/resources/migrations/visibility-backfill.js +111 -70
  184. package/dist/resources/oauth-discovery.js +0 -5
  185. package/dist/resources/object-body-guard.js +12 -5
  186. package/dist/resources/org-event-reserved.js +92 -0
  187. package/dist/resources/org-event-write-fault.js +19 -0
  188. package/dist/resources/owner-field-guard.js +1 -1
  189. package/dist/resources/owner-scoped-write-policy.js +65 -21
  190. package/dist/resources/owner-scoped-writes.js +37 -6
  191. package/dist/resources/path-id-rewrite.js +76 -0
  192. package/dist/resources/presence-internal.js +5 -5
  193. package/dist/resources/promotion-binding.js +43 -0
  194. package/dist/resources/promotion-stamp.js +124 -33
  195. package/dist/resources/protocol-context.js +189 -0
  196. package/dist/resources/record-type-kit.js +2 -4
  197. package/dist/resources/request-target.js +28 -1
  198. package/dist/resources/request-transaction.js +11 -1
  199. package/dist/resources/seed-reservation.js +1 -2
  200. package/dist/resources/semantic-retrieval-core.js +7 -6
  201. package/dist/resources/server-row-validation.js +71 -0
  202. package/dist/resources/skill-manifest.js +4 -3
  203. package/dist/resources/skill-version-write.js +400 -27
  204. package/dist/resources/skill-write-fault.js +6 -3
  205. package/dist/resources/skill-write-policy.js +2 -1
  206. package/dist/resources/soul-write-policy.js +26 -7
  207. package/dist/resources/table-helpers.js +1 -1
  208. package/dist/resources/table-subscription-policy.js +518 -85
  209. package/dist/resources/table-subscriptions.js +20 -7
  210. package/dist/resources/txn-pause-point.js +122 -5
  211. package/dist/resources/usage-recording.js +54 -46
  212. package/dist/resources/write-back.js +176 -11
  213. package/dist/resources/write-journal-context.js +5 -0
  214. package/dist/resources/write-journal.js +289 -0
  215. package/dist/src/keystore.js +77 -10
  216. package/dist/src/lib/agent-id-rule.js +44 -2
  217. package/dist/src/lib/atomic-write.js +3 -3
  218. package/dist/src/lib/federation-retry-row.js +101 -0
  219. package/dist/src/lib/instruction-event-contract.js +17 -0
  220. package/dist/src/lib/key-dir.js +203 -0
  221. package/dist/src/lib/memory-attributes.js +2 -0
  222. package/dist/src/lib/open-live-row.js +20 -0
  223. package/dist/src/lib/scheduler-platform.js +13 -0
  224. package/dist/src/lib/soul-scope-fields.js +26 -0
  225. package/dist/src/rem/promote-policy.js +3 -3
  226. package/dist/src/rem/scheduler.js +21 -4
  227. package/docs/access-control.md +39 -21
  228. package/docs/api-reference.md +161 -52
  229. package/docs/auth.md +69 -38
  230. package/docs/claude-code.md +3 -3
  231. package/docs/deploying-on-fabric.md +118 -2
  232. package/docs/deployment.md +17 -0
  233. package/docs/embedding-in-a-harper-app.md +23 -21
  234. package/docs/entity-vocabulary.md +7 -11
  235. package/docs/federation.md +29 -2
  236. package/docs/hosted-on-fabric.md +1 -1
  237. package/docs/integrations.md +11 -11
  238. package/docs/mcp-clients.md +7 -5
  239. package/docs/notes/mcp-agent-auth-consumer.md +4 -9
  240. package/docs/notes/mcp-oauth-model2.md +6 -6
  241. package/docs/openclaw.md +1 -1
  242. package/docs/quickstart-fabric.md +2 -2
  243. package/docs/quickstart.md +3 -3
  244. package/docs/releasing.md +13 -13
  245. package/docs/rem.md +24 -3
  246. package/docs/secrets-and-keys.md +9 -14
  247. package/docs/standalone-local.md +29 -2
  248. package/docs/supply-chain-policy.md +28 -20
  249. package/docs/the-team.md +2 -2
  250. package/docs/upgrade.md +29 -5
  251. package/package.json +18 -11
  252. package/schemas/agent.graphql +3 -3
  253. package/schemas/federation.graphql +10 -7
  254. package/schemas/memory.graphql +7 -2
  255. package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
  256. package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
  257. package/dist/resources/soul-adk-guard.js +0 -68
@@ -1,10 +1,13 @@
1
1
  import nacl from "tweetnacl";
2
- import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync, unlinkSync, realpathSync } from "node:fs";
3
- import { join } from "node:path";
2
+ import { existsSync, writeFileSync, unlinkSync, realpathSync, readdirSync } from "node:fs";
3
+ import { join, basename } from "node:path";
4
4
  import * as render from "../render.js";
5
- import { resolveAdminPassFromSources, defaultKeysDir, resolveLocalAdminPass, resolveAdminUser, resolveKeyPath, authFetch, } from "../lib/auth-resolve.js";
5
+ import { addAdminPassOptions, credentialsInHeader, defaultKeysDir, describeHttpFailure, resolveLocalAdminPass, resolveAdminUser, resolveKeyPath, authFetch, authFetchWithSentCredentials, } from "../lib/auth-resolve.js";
6
6
  import { encodeRecordId } from "../lib/record-id-path.js";
7
7
  import { resolveLocalDeleteInstance } from "../lib/local-delete-instance.js";
8
+ import { AgentKeyFileRefusal, createAgentKeyBackup, ensureAgentKeysDir, isAgentKeyRotationBackup, readAgentKeyForRotation, readOrCreateAgentKey, replaceAgentKeyFile, rotationBackupStamp, stageAgentKeyFile, } from "../lib/agent-key-file.js";
9
+ import { acquireAgentRotationLock, agentRotationTestPause } from "../lib/agent-rotation-lock.js";
10
+ import { agentKeyPath, agentPubKeyPath } from "../lib/key-dir.js";
8
11
  import { invalidAgentIdMessage, isValidAgentId } from "../lib/agent-id-rule.js";
9
12
  import { agentHomeEndpoint, resolveTargetInstanceId, runAgentHomeStamp, stampLeftoverLines, } from "../lib/agent-home.js";
10
13
  import { confirmedPurgeIds } from "../lib/memory-purge-response.js";
@@ -32,7 +35,8 @@ export function removeAgentKeyFiles(agentId, keysDir) {
32
35
  return { removed: [], manual: false }; // directory resolution failed
33
36
  }
34
37
  const removed = [];
35
- for (const name of [`${agentId}.key`, `${agentId}.pub`, `${agentId}.key.bak`]) {
38
+ const keyName = basename(agentKeyPath(keysDir, agentId));
39
+ for (const name of [keyName, basename(agentPubKeyPath(keysDir, agentId)), `${keyName}.bak`]) {
36
40
  let real;
37
41
  try {
38
42
  real = realpathSync(join(keysDir, name));
@@ -48,6 +52,29 @@ export function removeAgentKeyFiles(agentId, keysDir) {
48
52
  }
49
53
  catch { /* best effort */ }
50
54
  }
55
+ // Rotation retains timestamped backups and staged replacement keys.
56
+ let backups = [];
57
+ try {
58
+ backups = readdirSync(keysDir).filter((name) => isAgentKeyRotationBackup(name, keyName) ||
59
+ (name.startsWith(`.${keyName}.tmp-`) && /^[0-9a-f]{16}$/.test(name.slice(`.${keyName}.tmp-`.length))));
60
+ }
61
+ catch { /* keys directory resolution failed */ }
62
+ for (const name of backups) {
63
+ let real;
64
+ try {
65
+ real = realpathSync(join(keysDir, name));
66
+ }
67
+ catch {
68
+ continue;
69
+ }
70
+ if (real !== join(root, name))
71
+ continue;
72
+ try {
73
+ unlinkSync(real);
74
+ removed.push(real);
75
+ }
76
+ catch { /* best effort */ }
77
+ }
51
78
  return { removed, manual: false };
52
79
  }
53
80
  const shouldShowInlineSecretWarning = (optValue, fromEnv, secretFlagNames, flagName) => cli.shouldShowInlineSecretWarning(optValue, fromEnv, secretFlagNames, flagName);
@@ -202,17 +229,98 @@ async function readStoredAgent(opsPortOrUrl, id, adminUser, adminPass) {
202
229
  }
203
230
  return parsed.row;
204
231
  }
232
+ /**
233
+ * Read the Agent row's stored public key after a rotation update without
234
+ * exiting: a failed read is a rotation failure that keeps the staged key.
235
+ */
236
+ async function readAgentPublicKeyAfterUpdate(opsPortOrUrl, id, adminUser, adminPass) {
237
+ const auth = Buffer.from(`${adminUser}:${adminPass}`).toString("base64");
238
+ let res;
239
+ try {
240
+ res = await fetch(opsApiUrl(opsPortOrUrl), {
241
+ method: "POST",
242
+ headers: { "Content-Type": "application/json", Authorization: `Basic ${auth}` },
243
+ body: JSON.stringify({
244
+ operation: "search_by_value",
245
+ database: "flair",
246
+ table: "Agent",
247
+ search_attribute: "id",
248
+ search_value: id,
249
+ get_attributes: ["id", "publicKey"],
250
+ }),
251
+ signal: AbortSignal.timeout(10_000),
252
+ });
253
+ }
254
+ catch (err) {
255
+ const message = err instanceof Error ? err.message : String(err);
256
+ return { ok: false, reason: `the read request failed (${message})` };
257
+ }
258
+ let text;
259
+ try {
260
+ text = await res.text();
261
+ }
262
+ catch (err) {
263
+ const message = err instanceof Error ? err.message : String(err);
264
+ return { ok: false, reason: `the read response could not be read (${message})` };
265
+ }
266
+ if (!res.ok)
267
+ return { ok: false, reason: `the read returned ${res.status}` };
268
+ if (text.trim().length === 0)
269
+ return { ok: false, reason: "the read returned an empty body" };
270
+ let body;
271
+ try {
272
+ body = JSON.parse(text);
273
+ }
274
+ catch {
275
+ return { ok: false, reason: "the read returned a body that is not JSON" };
276
+ }
277
+ if (!Array.isArray(body))
278
+ return { ok: false, reason: "the read returned an unexpected body" };
279
+ if (body.length === 0)
280
+ return { ok: false, reason: "the read found no Agent row" };
281
+ if (body.length !== 1)
282
+ return { ok: false, reason: `the read returned ${body.length} rows` };
283
+ const row = body[0];
284
+ if (!row || typeof row !== "object" || Array.isArray(row)) {
285
+ return { ok: false, reason: "the read returned a malformed Agent row" };
286
+ }
287
+ if (typeof row.id !== "string")
288
+ return { ok: false, reason: "the read returned a non-string Agent id" };
289
+ if (row.id !== id)
290
+ return { ok: false, reason: `the read returned Agent '${row.id}' while looking up '${id}'` };
291
+ if (typeof row.publicKey !== "string" || row.publicKey.length === 0) {
292
+ return { ok: false, reason: "the read returned no public key" };
293
+ }
294
+ return { ok: true, publicKey: row.publicKey };
295
+ }
296
+ function quotePosixPath(path) {
297
+ return "'" + path.replace(/'/g, "'\\''") + "'";
298
+ }
299
+ /** A kept staged key after the update request was sent but the rename did not run. */
300
+ function rotationStagedKeyMessage(id, stagedPath, currentPath, detail) {
301
+ return (`Error: ${detail} Flair may now hold the new public key for '${id}'. ` +
302
+ `The current private key ${currentPath} is unchanged. The new private key is kept at ${stagedPath}. ` +
303
+ `If Flair holds the new public key, move it into place: mv -- ${quotePosixPath(stagedPath)} ${quotePosixPath(currentPath)}, then chmod -- 600 ${quotePosixPath(currentPath)}. ` +
304
+ `If it does not, delete the staged file: rm -- ${quotePosixPath(stagedPath)}.`);
305
+ }
306
+ /** A failure after the rename: the private key on disk is the new one. */
307
+ function rotationReplacedKeyMessage(currentPath, detail, backupPath) {
308
+ const backup = backupPath
309
+ ? `The old key backup is ${backupPath}.`
310
+ : "No key existed before this rotation, so there is no backup.";
311
+ return `Error: ${detail} The private key at ${currentPath} was already replaced. ${backup}`;
312
+ }
205
313
  /** Register the `flair agent` command group (flair#1630). */
206
314
  export function register(program) {
207
315
  // ─── flair agent ─────────────────────────────────────────────────────────────
208
316
  const agent = program.command("agent").description("Manage Flair agents");
209
- agent
317
+ addAdminPassOptions(agent
210
318
  .command("add <id>")
211
319
  .description("Register a new agent. Refuses an id whose Agent record already exists")
212
320
  .option("--name <name>", "Display name (defaults to id)")
213
- .option("--port <port>", "Harper HTTP port")
214
- .option("--admin-pass <pass>", "Admin password for registration")
215
- .option("--admin-pass-file <path>", "Read the admin password from a file (chmod 600 enforced). Preferred over inline --admin-pass — keeps the secret out of ps and shell history; works for remote targets too (an explicit flag is operator intent).")
321
+ .option("--port <port>", "Harper HTTP port"), "Admin password for registration", {
322
+ adminPassFileHelp: "Read the admin password from a file (owner-only permissions enforced). Preferred over inline --admin-pass — keeps the secret out of ps and shell history; works for remote targets too (an explicit flag is operator intent).",
323
+ })
216
324
  .option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
217
325
  .option("--keys-dir <dir>", "Directory for Ed25519 keys")
218
326
  .option("--ops-port <port>", "Harper operations API port")
@@ -236,29 +344,13 @@ export function register(program) {
236
344
  // `flair import`: explicit --ops-target > derive from --target > localhost.
237
345
  const seedOpsTarget = resolveEffectiveOpsUrl({ target: opts.target, opsTarget: opts.opsTarget }) ?? opsPort;
238
346
  const isRemoteTarget = typeof seedOpsTarget === "string";
239
- // flair#1259 / #1910 — --admin-pass-file and --admin-pass resolve through
240
- // the ONE resolver (resolveAdminPassFromSources), the file read in-process
241
- // via readAdminPassFileSecure so the secret never appears in ps or shell
242
- // history. Combining the file and the flag is a usage error (the flag used
243
- // to silently win). This does NOT weaken the #1085 remote guard below: an
244
- // explicit flag naming a file IS operator intent toward this target,
245
- // exactly like an explicit inline --admin-pass — what the guard blocks is
246
- // the AMBIENT env/local-file fallbacks silently traveling to a third-party
247
- // host.
248
- let explicitPass;
249
- try {
250
- explicitPass =
251
- resolveAdminPassFromSources({
252
- adminPassFile: opts.adminPassFile,
253
- adminPass: opts.adminPass,
254
- envPass: undefined,
255
- }) || undefined;
256
- }
257
- catch (err) {
258
- console.error(`Error: ${err.message}`);
259
- process.exit(1);
260
- }
261
- opts.adminPass = explicitPass;
347
+ // flair#1259 / #1910 — the pair is resolved by addAdminPassOptions' preAction
348
+ // hook, before this action runs. This does NOT weaken the #1085 remote guard
349
+ // below: an explicit flag naming a file IS operator intent toward this
350
+ // target, exactly like an explicit inline --admin-pass — what the guard
351
+ // blocks is the AMBIENT env/local-file fallbacks silently traveling to a
352
+ // third-party host.
353
+ //
262
354
  // #590 — local convenience fallback: FLAIR_ADMIN_PASS env, then the secure
263
355
  // ~/.flair/admin-pass file `flair init` already writes (mode 0600). Never
264
356
  // applied for a remote target — see resolveLocalAdminPass.
@@ -292,25 +384,30 @@ export function register(program) {
292
384
  console.error(agentAlreadyExistsMessage(id));
293
385
  process.exit(1);
294
386
  }
295
- mkdirSync(keysDir, { recursive: true });
296
387
  const privPath = privKeyPath(id, keysDir);
297
388
  const pubPath = pubKeyPath(id, keysDir);
298
389
  let pubKeyB64url;
299
- if (existsSync(privPath)) {
300
- console.log(`Reusing existing key: ${privPath}`);
301
- const seed = new Uint8Array(readFileSync(privPath));
302
- const kp = nacl.sign.keyPair.fromSeed(seed);
303
- pubKeyB64url = b64url(kp.publicKey);
390
+ let keyFile;
391
+ try {
392
+ ensureAgentKeysDir(keysDir);
393
+ keyFile = readOrCreateAgentKey(privPath, () => {
394
+ const kp = nacl.sign.keyPair();
395
+ return Buffer.from(kp.secretKey.slice(0, 32));
396
+ });
304
397
  }
305
- else {
306
- const kp = nacl.sign.keyPair();
307
- const seed = kp.secretKey.slice(0, 32);
308
- writeFileSync(privPath, Buffer.from(seed));
309
- chmodSync(privPath, 0o600);
398
+ catch (err) {
399
+ console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
400
+ process.exit(1);
401
+ }
402
+ const kp = nacl.sign.keyPair.fromSeed(new Uint8Array(keyFile.bytes));
403
+ pubKeyB64url = b64url(kp.publicKey);
404
+ if (keyFile.created) {
310
405
  writeFileSync(pubPath, Buffer.from(kp.publicKey));
311
- pubKeyB64url = b64url(kp.publicKey);
312
406
  console.log(`Keypair written: ${privPath}`);
313
407
  }
408
+ else {
409
+ console.log(`Reusing existing key: ${privPath}`);
410
+ }
314
411
  await seedAgentWithLocalHome(seedOpsTarget, id, pubKeyB64url, adminUser, adminPass);
315
412
  const stored = await readStoredAgent(seedOpsTarget, id, adminUser, adminPass);
316
413
  if (!stored || stored.publicKey !== pubKeyB64url) {
@@ -330,10 +427,7 @@ export function register(program) {
330
427
  console.log(` Note: an OAuth /mcp connector maps its own IdP subject to an Agent (distinct from '${id}' by default).\n` +
331
428
  ` To point a connector at '${id}': flair mcp enable --principal ${id} --idp-subject <your-idp-login>`);
332
429
  });
333
- agent
334
- .command("list")
335
- .description("List all agents")
336
- .option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
430
+ addAdminPassOptions(agent.command("list").description("List all agents"), "Admin password (or set FLAIR_ADMIN_PASS env)")
337
431
  .option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
338
432
  .option("--agent <id>", "Agent ID to authenticate as via Ed25519 (or FLAIR_AGENT_ID env) when no admin pass")
339
433
  .option("--keys-dir <dir>", "Directory holding the agent's Ed25519 key")
@@ -341,9 +435,7 @@ export function register(program) {
341
435
  .option("--json", "Emit raw JSON array (also: pipe + FLAIR_OUTPUT=json)")
342
436
  .action(async (opts) => {
343
437
  const port = resolveHttpPort(opts);
344
- // fromEnv is true ONLY when the resolved value came from env (no inline override).
345
- const adminPassFromEnv = !opts.adminPass && (!!process.env.FLAIR_ADMIN_PASS || !!process.env.HDB_ADMIN_PASSWORD);
346
- if (shouldShowInlineSecretWarning(opts.adminPass, adminPassFromEnv, new Set(["--admin-pass"]), "--admin-pass")) {
438
+ if (shouldShowInlineSecretWarning(opts.inlineAdminPass, false, new Set(["--admin-pass"]), "--admin-pass")) {
347
439
  console.error(INLINE_ADMIN_PASS_WARNING);
348
440
  }
349
441
  const adminPass = opts.adminPass ?? process.env.FLAIR_ADMIN_PASS ?? process.env.HDB_ADMIN_PASSWORD ?? "";
@@ -365,7 +457,8 @@ export function register(program) {
365
457
  });
366
458
  if (!res.ok) {
367
459
  const text = await res.text().catch(() => "");
368
- console.error(`${render.icons.error} ${res.status} ${text}`);
460
+ const sent = credentialsInHeader(`Basic ${auth}`);
461
+ console.error(`${render.icons.error} ${describeHttpFailure(res.status, text, sent.values, sent.withhold)}`);
369
462
  process.exit(1);
370
463
  }
371
464
  agents = await res.json();
@@ -378,15 +471,20 @@ export function register(program) {
378
471
  // the principal table for discovery, so sign the request with its key.
379
472
  const baseUrl = `http://127.0.0.1:${port}`;
380
473
  const agentId = opts.agent ?? process.env.FLAIR_AGENT_ID;
474
+ if (agentId && !isValidAgentId(agentId)) {
475
+ console.error(`Error: ${invalidAgentIdMessage(agentId)}`);
476
+ process.exit(1);
477
+ }
381
478
  const keysDir = opts.keysDir ?? process.env.FLAIR_KEY_DIR ?? defaultKeysDir();
382
479
  let res;
480
+ let sent = { values: [], withhold: false };
383
481
  if (agentId) {
384
- const keyPath = resolveKeyPath(agentId) ?? join(keysDir, `${agentId}.key`);
482
+ const keyPath = resolveKeyPath(agentId) ?? agentKeyPath(keysDir, agentId);
385
483
  if (!existsSync(keyPath)) {
386
484
  console.error(`${render.icons.error} no key for agent '${agentId}' (looked in ${keysDir}). Pass --admin-pass, --keys-dir, or a registered --agent.`);
387
485
  process.exit(1);
388
486
  }
389
- res = await authFetch(baseUrl, agentId, keyPath, "GET", "/Agent");
487
+ ({ res, sent } = await authFetchWithSentCredentials(baseUrl, agentId, keyPath, "GET", "/Agent"));
390
488
  }
391
489
  else {
392
490
  // No agent identity available either. Try anonymously, but if it 403s
@@ -402,7 +500,7 @@ export function register(program) {
402
500
  console.error(` or ${render.wrap(render.c.cyan, "--admin-pass")} / FLAIR_ADMIN_PASS for the admin view.`);
403
501
  }
404
502
  else {
405
- console.error(`${render.icons.error} ${res.status} ${text}`);
503
+ console.error(`${render.icons.error} ${describeHttpFailure(res.status, text, sent.values, sent.withhold)}`);
406
504
  }
407
505
  process.exit(1);
408
506
  }
@@ -465,20 +563,23 @@ export function register(program) {
465
563
  console.log(render.kv("updated", `${render.relativeTime(out.updatedAt)} ${render.wrap(render.c.dim, `(${out.updatedAt})`)}`));
466
564
  }
467
565
  });
468
- agent
566
+ addAdminPassOptions(agent
469
567
  .command("rotate-key <id>")
470
568
  .description("Rotate an agent's Ed25519 keypair")
471
569
  .option("--port <port>", "Harper HTTP port")
472
- .option("--ops-port <port>", "Harper operations API port")
473
- .option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
570
+ .option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS env)")
474
571
  .option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
475
572
  .option("--keys-dir <dir>", "Directory for Ed25519 keys")
476
573
  .action(async (id, opts) => {
574
+ // flair#2359 — the ONE agent-ID rule, before any key file is read or
575
+ // written, and before any `fetch` call made by the command action.
576
+ if (!isValidAgentId(id)) {
577
+ console.error(`Error: ${invalidAgentIdMessage(id)}`);
578
+ process.exit(1);
579
+ }
477
580
  const httpPort = resolveHttpPort(opts);
478
581
  const opsPort = resolveOpsPort(opts);
479
- // fromEnv is true ONLY when the resolved value came from env (no inline override).
480
- const adminPassFromEnv = !opts.adminPass && !!process.env.FLAIR_ADMIN_PASS;
481
- if (shouldShowInlineSecretWarning(opts.adminPass, adminPassFromEnv, new Set(["--admin-pass"]), "--admin-pass")) {
582
+ if (shouldShowInlineSecretWarning(opts.inlineAdminPass, false, new Set(["--admin-pass"]), "--admin-pass")) {
482
583
  console.error(INLINE_ADMIN_PASS_WARNING);
483
584
  }
484
585
  const adminPass = opts.adminPass ?? process.env.FLAIR_ADMIN_PASS ?? "";
@@ -488,73 +589,175 @@ export function register(program) {
488
589
  console.error("Error: --admin-pass or FLAIR_ADMIN_PASS required for key rotation");
489
590
  process.exit(1);
490
591
  }
491
- mkdirSync(keysDir, { recursive: true });
492
- const currentPrivPath = privKeyPath(id, keysDir);
493
- const currentPubPath = pubKeyPath(id, keysDir);
494
- const backupPrivPath = currentPrivPath + ".bak";
495
- // Generate new keypair
496
- console.log(`Generating new keypair for agent '${id}'...`);
497
- const kp = nacl.sign.keyPair();
498
- const newSeed = kp.secretKey.slice(0, 32);
499
- const newPubKeyB64url = b64url(kp.publicKey);
500
- // Back up old key if it exists
501
- if (existsSync(currentPrivPath)) {
502
- writeFileSync(backupPrivPath, readFileSync(currentPrivPath));
503
- chmodSync(backupPrivPath, 0o600);
504
- console.log(`Old key backed up to: ${backupPrivPath}`);
505
- }
506
- // Update publicKey in Flair via operations API
507
- console.log(`Updating public key in Flair via operations API...`);
508
- const opsUrl = `http://127.0.0.1:${opsPort}/`;
509
- const auth = Buffer.from(`${adminUser}:${adminPass}`).toString("base64");
510
- const updateBody = {
511
- operation: "update",
512
- database: "flair",
513
- table: "Agent",
514
- records: [{ id, publicKey: newPubKeyB64url, updatedAt: new Date().toISOString() }],
515
- };
516
- const updateRes = await fetch(opsUrl, {
517
- method: "POST",
518
- headers: { "Content-Type": "application/json", Authorization: `Basic ${auth}` },
519
- body: JSON.stringify(updateBody),
520
- signal: AbortSignal.timeout(10_000),
521
- });
522
- if (!updateRes.ok) {
523
- const text = await updateRes.text().catch(() => "");
524
- // Roll back: keep old key in place (don't write new key yet)
525
- if (existsSync(backupPrivPath)) {
526
- // Restore not needed — we haven't written new key yet
527
- }
528
- throw new Error(`Failed to update public key in Flair (${updateRes.status}): ${text}`);
529
- }
530
- console.log(`Public key updated in Flair ✓`);
531
- // Write new private key (only after Flair update succeeds)
532
- writeFileSync(currentPrivPath, Buffer.from(newSeed));
533
- chmodSync(currentPrivPath, 0o600);
534
- writeFileSync(currentPubPath, Buffer.from(kp.publicKey));
535
- console.log(`New private key written: ${currentPrivPath} ✓`);
536
- // Verify new key works
537
- console.log(`Verifying new Ed25519 auth...`);
538
- const httpUrl = `http://127.0.0.1:${httpPort}`;
539
- const verifyRes = await authFetch(httpUrl, id, currentPrivPath, "GET", `/Agent/${encodeRecordId(id)}`);
540
- if (!verifyRes.ok) {
541
- console.error(`⚠️ Auth verification failed (${verifyRes.status}). Old key is backed up at: ${backupPrivPath}`);
592
+ try {
593
+ ensureAgentKeysDir(keysDir);
594
+ }
595
+ catch (err) {
596
+ if (err instanceof AgentKeyFileRefusal) {
597
+ console.error(`Error: ${err.message}`);
598
+ process.exit(1);
599
+ }
600
+ throw err;
601
+ }
602
+ // flair#3151 — the lock serializes rotations of this agent that use this
603
+ // keys directory on a filesystem with reliable exclusive create. It is
604
+ // taken before the current key is read and held through the read-back
605
+ // check, the rename and the public-key write. A
606
+ // second rotation of this agent in this keys directory retries and, if the
607
+ // lock still exists, refuses here; a rotation in a different keys
608
+ // directory uses a different lock file.
609
+ const lockResult = acquireAgentRotationLock({ id, keysDir });
610
+ if (lockResult.ok === false) {
611
+ console.error(`Error: ${lockResult.message}`);
542
612
  process.exit(1);
543
613
  }
544
- console.log(`Ed25519 auth verified ✓`);
545
- console.log(`\n✅ Key rotation complete for agent '${id}'`);
546
- console.log(` New public key: ${newPubKeyB64url}`);
547
- console.log(` Private key: ${currentPrivPath}`);
548
- console.log(` Old key backup: ${backupPrivPath}`);
614
+ const rotationLock = lockResult.lock;
615
+ try {
616
+ const currentPrivPath = privKeyPath(id, keysDir);
617
+ const currentPubPath = pubKeyPath(id, keysDir);
618
+ // Read before writing: POSIX uses a no-follow descriptor; Windows reads by path.
619
+ // A wide POSIX mode is reported; successful rotation replaces the file.
620
+ let current;
621
+ try {
622
+ current = readAgentKeyForRotation(currentPrivPath);
623
+ }
624
+ catch (err) {
625
+ if (err instanceof AgentKeyFileRefusal) {
626
+ console.error(`Error: ${err.message}`);
627
+ process.exit(1);
628
+ }
629
+ throw err;
630
+ }
631
+ if (current?.widerThanOwnerOnly) {
632
+ console.log(`Old key ${currentPrivPath} has group or world permission bits and is being replaced.`);
633
+ }
634
+ // Generate new keypair
635
+ console.log(`Generating new keypair for agent '${id}'...`);
636
+ const kp = nacl.sign.keyPair();
637
+ const newSeed = kp.secretKey.slice(0, 32);
638
+ const newPubKeyB64url = b64url(kp.publicKey);
639
+ // Back up the current key to a NEW timestamped file. An existing backup
640
+ // is never replaced or written into.
641
+ let backupPrivPath;
642
+ if (current) {
643
+ backupPrivPath = `${currentPrivPath}.bak.${rotationBackupStamp()}`;
644
+ try {
645
+ createAgentKeyBackup(backupPrivPath, current.bytes);
646
+ }
647
+ catch (err) {
648
+ if (err?.code === "EEXIST") {
649
+ console.error(`Error: backup path ${backupPrivPath} already exists; move it aside and run again.`);
650
+ process.exit(1);
651
+ }
652
+ throw err;
653
+ }
654
+ console.log(`Old key backed up to: ${backupPrivPath}`);
655
+ }
656
+ // Stage the new private key before the update is sent. A staging failure
657
+ // sends nothing and leaves the current key unchanged.
658
+ let stagedPrivPath;
659
+ try {
660
+ stagedPrivPath = stageAgentKeyFile(currentPrivPath, newSeed);
661
+ }
662
+ catch (err) {
663
+ const message = err instanceof Error ? err.message : String(err);
664
+ console.error(`Error: could not stage the new private key next to ${currentPrivPath}: ${message}. No update was sent; the current key is unchanged.`);
665
+ process.exit(1);
666
+ }
667
+ // Update publicKey in Flair via operations API
668
+ console.log(`Updating public key in Flair via operations API...`);
669
+ const opsUrl = `http://127.0.0.1:${opsPort}/`;
670
+ const auth = Buffer.from(`${adminUser}:${adminPass}`).toString("base64");
671
+ const updateBody = {
672
+ operation: "update",
673
+ database: "flair",
674
+ table: "Agent",
675
+ records: [{ id, publicKey: newPubKeyB64url, updatedAt: new Date().toISOString() }],
676
+ };
677
+ let updateRes;
678
+ try {
679
+ updateRes = await fetch(opsUrl, {
680
+ method: "POST",
681
+ headers: { "Content-Type": "application/json", Authorization: `Basic ${auth}` },
682
+ body: JSON.stringify(updateBody),
683
+ signal: AbortSignal.timeout(10_000),
684
+ });
685
+ }
686
+ catch (err) {
687
+ const message = err instanceof Error ? err.message : String(err);
688
+ console.error(rotationStagedKeyMessage(id, stagedPrivPath, currentPrivPath, `the update request failed (${message}).`));
689
+ process.exit(1);
690
+ }
691
+ if (!updateRes.ok) {
692
+ const text = await updateRes.text().catch(() => "");
693
+ console.error(rotationStagedKeyMessage(id, stagedPrivPath, currentPrivPath, `Flair refused the update (${updateRes.status}): ${text}`));
694
+ process.exit(1);
695
+ }
696
+ // A 2xx that changed no row is a failure: require the stored public key
697
+ // to match the staged key before the rename.
698
+ const readback = await readAgentPublicKeyAfterUpdate(opsPort, id, adminUser, adminPass);
699
+ if (readback.ok === false) {
700
+ console.error(rotationStagedKeyMessage(id, stagedPrivPath, currentPrivPath, `the update was sent, but reading the Agent row back failed: ${readback.reason}.`));
701
+ process.exit(1);
702
+ }
703
+ if (readback.publicKey !== newPubKeyB64url) {
704
+ console.error(rotationStagedKeyMessage(id, stagedPrivPath, currentPrivPath, "the update was sent, but the Agent row's public key does not match the new key."));
705
+ process.exit(1);
706
+ }
707
+ console.log(`Public key updated in Flair ✓`);
708
+ // Replace the current key by rename. A failed rename keeps the staged file.
709
+ try {
710
+ replaceAgentKeyFile(currentPrivPath, stagedPrivPath);
711
+ }
712
+ catch (err) {
713
+ const message = err instanceof Error ? err.message : String(err);
714
+ console.error(rotationStagedKeyMessage(id, stagedPrivPath, currentPrivPath, `the update was verified, but replacing ${currentPrivPath} failed (${message}).`));
715
+ process.exit(1);
716
+ }
717
+ try {
718
+ writeFileSync(currentPubPath, Buffer.from(kp.publicKey));
719
+ }
720
+ catch (err) {
721
+ const message = err instanceof Error ? err.message : String(err);
722
+ console.error(rotationReplacedKeyMessage(currentPrivPath, `writing the public key to ${currentPubPath} failed (${message}).`, backupPrivPath));
723
+ process.exit(1);
724
+ }
725
+ console.log(`New private key written: ${currentPrivPath} ✓`);
726
+ await agentRotationTestPause();
727
+ // Verify new key works
728
+ console.log(`Verifying new Ed25519 auth...`);
729
+ const httpUrl = `http://127.0.0.1:${httpPort}`;
730
+ let verifyRes;
731
+ try {
732
+ verifyRes = await authFetch(httpUrl, id, currentPrivPath, "GET", `/Agent/${encodeRecordId(id)}`);
733
+ }
734
+ catch (err) {
735
+ const message = err instanceof Error ? err.message : String(err);
736
+ console.error(rotationReplacedKeyMessage(currentPrivPath, `the new key's auth verification failed (${message}).`, backupPrivPath));
737
+ process.exit(1);
738
+ }
739
+ if (!verifyRes.ok) {
740
+ console.error(rotationReplacedKeyMessage(currentPrivPath, `the new key's auth verification failed (${verifyRes.status}).`, backupPrivPath));
741
+ process.exit(1);
742
+ }
743
+ console.log(`Ed25519 auth verified ✓`);
744
+ console.log(`\n✅ Key rotation complete for agent '${id}'`);
745
+ console.log(` New public key: ${newPubKeyB64url}`);
746
+ console.log(` Private key: ${currentPrivPath}`);
747
+ if (backupPrivPath)
748
+ console.log(` Old key backup: ${backupPrivPath}`);
749
+ }
750
+ finally {
751
+ rotationLock.release();
752
+ }
549
753
  });
550
754
  // ─── flair agent remove ──────────────────────────────────────────────────────
551
- agent
755
+ addAdminPassOptions(agent
552
756
  .command("remove <id>")
553
757
  .description("Remove an agent and all its data from Flair")
554
758
  .option("--keep-keys", "Do not delete key files from disk")
555
759
  .option("--port <port>", "Harper HTTP port")
556
- .option("--ops-port <port>", "Harper operations API port")
557
- .option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS env)")
760
+ .option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS env)")
558
761
  .option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
559
762
  .option("--keys-dir <dir>", "Directory for Ed25519 keys")
560
763
  .option("--force", "Skip interactive confirmation (required when stdin is not a TTY)")
@@ -707,13 +910,11 @@ export function register(program) {
707
910
  }
708
911
  console.log(`\n✅ Agent '${id}' removed successfully`);
709
912
  });
710
- agent
913
+ addAdminPassOptions(agent
711
914
  .command("stamp-home")
712
915
  .description("Back-fill the home instance (originatorInstanceId) on home-less Agent rows with no federation-sync provenance")
713
916
  .option("--port <port>", "Harper HTTP port")
714
- .option("--ops-port <port>", "Harper operations API port")
715
- .option("--admin-pass <pass>", "Admin password (or set FLAIR_ADMIN_PASS)")
716
- .option("--admin-pass-file <path>", "Read the admin password from a file (chmod 600 enforced)")
917
+ .option("--ops-port <port>", "Harper operations API port"), "Admin password (or set FLAIR_ADMIN_PASS)", { adminPassFileHelp: "Read the admin password from a file (owner-only permissions enforced)" })
717
918
  .option("--admin-user <name>", "Admin username for Basic auth (env: FLAIR_ADMIN_USER; default: admin)")
718
919
  .option("--apply", "Write the home; without it the command is a dry run and writes nothing")
719
920
  .action(async (opts) => {
@@ -731,22 +932,9 @@ export function register(program) {
731
932
  }
732
933
  const opsPort = target.opsPort;
733
934
  const adminUser = resolveAdminUser(opts.adminUser);
734
- let explicitPass;
735
- try {
736
- explicitPass =
737
- resolveAdminPassFromSources({
738
- adminPassFile: opts.adminPassFile,
739
- adminPass: opts.adminPass,
740
- envPass: undefined,
741
- }) || undefined;
742
- }
743
- catch (err) {
744
- console.error(`Error: ${err.message}`);
745
- process.exit(1);
746
- }
747
935
  let adminPass;
748
936
  try {
749
- adminPass = resolveLocalAdminPass(explicitPass);
937
+ adminPass = resolveLocalAdminPass(opts.adminPass);
750
938
  }
751
939
  catch (err) {
752
940
  console.error(`Error: ${err.message}`);
@@ -1,4 +1,5 @@
1
1
  import { buildEd25519Auth, requestTarget, requestUrl, resolveKeyPath } from "../lib/auth-resolve.js";
2
+ import { requireAgentId } from "../lib/key-dir.js";
2
3
  import * as render from "../render.js";
3
4
  let cli;
4
5
  /** Bind the cli-locals this module depends on. */
@@ -57,6 +58,7 @@ export function register(program) {
57
58
  console.error("error: --agent <id> required (or set FLAIR_AGENT_ID)");
58
59
  process.exit(2);
59
60
  }
61
+ requireAgentId(agentId);
60
62
  const payload = { entity };
61
63
  if (opts.days !== undefined) {
62
64
  const n = Number.parseInt(opts.days, 10);