@tpsdev-ai/flair 0.58.0 → 0.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/README.md +7 -6
  2. package/SECURITY.md +36 -0
  3. package/config.yaml +15 -1
  4. package/dist/bridges/builtins/mem0.js +63 -28
  5. package/dist/bridges/runtime/import-runner.js +12 -0
  6. package/dist/bridges/runtime/load-plugin.js +42 -13
  7. package/dist/bridges/runtime/yaml-loader.js +4 -2
  8. package/dist/build-info.json +3 -3
  9. package/dist/cli.js +1030 -343
  10. package/dist/commands/agent.js +384 -45
  11. package/dist/commands/attention.js +4 -3
  12. package/dist/commands/backup.js +202 -34
  13. package/dist/commands/bridge.js +172 -119
  14. package/dist/commands/deploy.js +37 -4
  15. package/dist/commands/doctor.js +601 -163
  16. package/dist/commands/export.js +54 -19
  17. package/dist/commands/federation.js +141 -21
  18. package/dist/commands/hook.js +155 -2
  19. package/dist/commands/idp.js +14 -1
  20. package/dist/commands/import.js +7 -3
  21. package/dist/commands/init.js +462 -193
  22. package/dist/commands/integrity.js +388 -0
  23. package/dist/commands/keys.js +247 -58
  24. package/dist/commands/mcp.js +146 -53
  25. package/dist/commands/memory.js +171 -21
  26. package/dist/commands/migrate-harness-memory.js +3 -2
  27. package/dist/commands/orgevent.js +46 -37
  28. package/dist/commands/presence.js +4 -3
  29. package/dist/commands/principal.js +426 -48
  30. package/dist/commands/quality.js +10 -1
  31. package/dist/commands/reembed.js +141 -17
  32. package/dist/commands/relationship.js +2 -1
  33. package/dist/commands/rem.js +56 -18
  34. package/dist/commands/restore.js +101 -61
  35. package/dist/commands/search.js +6 -4
  36. package/dist/commands/service.js +151 -38
  37. package/dist/commands/soul.js +4 -3
  38. package/dist/commands/status.js +43 -5
  39. package/dist/commands/test.js +3 -2
  40. package/dist/commands/upgrade.js +24 -1
  41. package/dist/commands/workspace.js +6 -3
  42. package/dist/component-env.js +31 -41
  43. package/dist/deploy.js +77 -1
  44. package/dist/doctor-client.js +529 -92
  45. package/dist/engine-version-contract.js +1 -0
  46. package/dist/engine-version.js +23 -3
  47. package/dist/federation-verify.js +4 -3
  48. package/dist/hook-install.js +670 -6
  49. package/dist/keystore.js +72 -0
  50. package/dist/lib/action-recall-runtime.js +328 -0
  51. package/dist/lib/agent-home-fields.js +132 -0
  52. package/dist/lib/agent-home.js +427 -0
  53. package/dist/lib/agent-id-rule.js +46 -0
  54. package/dist/lib/agent-roster.js +33 -0
  55. package/dist/lib/auth-resolve.js +49 -16
  56. package/dist/lib/capture-runtime.js +124 -0
  57. package/dist/lib/credential-status-rule.js +78 -0
  58. package/dist/lib/daemon-liveness.js +81 -8
  59. package/dist/lib/doctor-run.js +140 -35
  60. package/dist/lib/durability-copy.js +10 -0
  61. package/dist/lib/embedding-space-doctor.js +75 -0
  62. package/dist/lib/flair-agent-role.js +120 -0
  63. package/dist/lib/hub-url.js +12 -0
  64. package/dist/lib/init-admin-pass.js +88 -12
  65. package/dist/lib/init-listener-environ.js +1 -2
  66. package/dist/lib/init-occupied-listener.js +15 -111
  67. package/dist/lib/init-spawn-attribution.js +73 -0
  68. package/dist/lib/init-tcp-probe.js +33 -0
  69. package/dist/lib/instance-identity-row.js +20 -0
  70. package/dist/lib/launchd-management.js +27 -2
  71. package/dist/lib/listener-table.js +268 -0
  72. package/dist/lib/local-delete-instance.js +27 -0
  73. package/dist/lib/local-instance-pair.js +256 -0
  74. package/dist/lib/mcp-enable.js +1775 -338
  75. package/dist/lib/mcp-oauth-env-core.js +133 -0
  76. package/dist/lib/mcp-oauth-env.js +125 -0
  77. package/dist/lib/mcp-spec.js +17 -1
  78. package/dist/lib/memory-attributes.js +2 -0
  79. package/dist/lib/memory-id-policy.js +46 -0
  80. package/dist/lib/memory-integrity.js +309 -0
  81. package/dist/lib/memory-purge-response.js +20 -0
  82. package/dist/lib/ops-table-count.js +25 -0
  83. package/dist/lib/owned-pins.js +67 -10
  84. package/dist/lib/peer-status.js +27 -0
  85. package/dist/lib/principal-status.js +29 -0
  86. package/dist/lib/process-start-time.js +103 -7
  87. package/dist/lib/proto-safe-record.js +42 -0
  88. package/dist/lib/record-id-path.js +25 -0
  89. package/dist/lib/reembed-server-support.js +66 -0
  90. package/dist/lib/restore-verify.js +104 -0
  91. package/dist/lib/scheduler-platform.js +10 -6
  92. package/dist/lib/secret-keys.js +25 -0
  93. package/dist/lib/secrets-push.js +50 -22
  94. package/dist/lib/skill-seed-pending.js +24 -0
  95. package/dist/lib/skill-seed.js +365 -0
  96. package/dist/lib/stop-start-recovery.js +54 -0
  97. package/dist/lib/using-flair-skill.js +87 -0
  98. package/dist/mcp-client-assertion.js +112 -4
  99. package/dist/memory-id-checkpoint.js +326 -0
  100. package/dist/memory-node-compare.js +207 -0
  101. package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
  102. package/dist/rem/restore.js +6 -5
  103. package/dist/rem/runner.js +103 -44
  104. package/dist/resources/Agent.js +348 -8
  105. package/dist/resources/AgentKeyRegister.js +214 -0
  106. package/dist/resources/AgentKeyRegistration.js +28 -0
  107. package/dist/resources/AgentSeed.js +19 -4
  108. package/dist/resources/AutoPromoteCandidates.js +7 -1
  109. package/dist/resources/Credential.js +177 -2
  110. package/dist/resources/Federation.js +752 -132
  111. package/dist/resources/FederationRetry.js +140 -0
  112. package/dist/resources/InstructionVersion.js +220 -0
  113. package/dist/resources/Integration.js +300 -25
  114. package/dist/resources/Memory.js +2113 -604
  115. package/dist/resources/MemoryArchive.js +75 -42
  116. package/dist/resources/MemoryBootstrap.js +227 -64
  117. package/dist/resources/MemoryCandidate.js +21 -1
  118. package/dist/resources/MemoryDedupStats.js +30 -1
  119. package/dist/resources/MemoryFeed.js +327 -45
  120. package/dist/resources/MemoryGrant.js +21 -1
  121. package/dist/resources/MemoryMaintenance.js +129 -25
  122. package/dist/resources/MemoryPurge.js +232 -0
  123. package/dist/resources/MemoryReflect.js +7 -2
  124. package/dist/resources/MemoryReindex.js +24 -8
  125. package/dist/resources/Message.js +5 -3
  126. package/dist/resources/OAuth.js +186 -9
  127. package/dist/resources/OrgEvent.js +126 -3
  128. package/dist/resources/OrgSkillAssignment.js +209 -0
  129. package/dist/resources/Presence.js +144 -49
  130. package/dist/resources/PromoteMemoryCandidate.js +18 -7
  131. package/dist/resources/Relationship.js +23 -0
  132. package/dist/resources/SemanticSearch.js +63 -32
  133. package/dist/resources/Soul.js +189 -76
  134. package/dist/resources/TeamDirectory.js +35 -0
  135. package/dist/resources/WorkspaceState.js +21 -1
  136. package/dist/resources/XAA.js +212 -65
  137. package/dist/resources/agent-auth.js +40 -15
  138. package/dist/resources/agent-status-guard.js +63 -0
  139. package/dist/resources/auth-middleware.js +402 -162
  140. package/dist/resources/ed25519-auth.js +1 -1
  141. package/dist/resources/embedding-space-guard.js +366 -72
  142. package/dist/resources/engine-version-stamp-boot.js +53 -0
  143. package/dist/resources/federation-classify.js +94 -0
  144. package/dist/resources/federation-crypto.js +5 -5
  145. package/dist/resources/federation-retry-lib.js +135 -0
  146. package/dist/resources/flair-agent-role-boot.js +26 -0
  147. package/dist/resources/grant-visibility.js +135 -0
  148. package/dist/resources/harper-routing.js +83 -0
  149. package/dist/resources/health.js +130 -20
  150. package/dist/resources/host-source-citation.js +49 -0
  151. package/dist/resources/host-source-visibility.js +7 -6
  152. package/dist/resources/instance-create-lock.js +17 -0
  153. package/dist/resources/instance-identity.js +23 -0
  154. package/dist/resources/instruction-version-record.js +343 -0
  155. package/dist/resources/key-lock.js +31 -0
  156. package/dist/resources/mcp-handler.js +36 -8
  157. package/dist/resources/mcp-oauth-env-guard.js +36 -0
  158. package/dist/resources/mcp-oauth.js +26 -12
  159. package/dist/resources/mcp-tool-arguments.js +4 -6
  160. package/dist/resources/mcp-tools.js +150 -23
  161. package/dist/resources/memory-bootstrap-lib.js +5 -15
  162. package/dist/resources/memory-declared-attributes.js +3 -1
  163. package/dist/resources/memory-deletion-history.js +55 -0
  164. package/dist/resources/memory-durability.js +54 -0
  165. package/dist/resources/memory-embed-hash.js +88 -0
  166. package/dist/resources/memory-embedding-value.js +8 -0
  167. package/dist/resources/memory-host-source.js +27 -5
  168. package/dist/resources/memory-id-guard.js +75 -0
  169. package/dist/resources/memory-redaction.js +236 -0
  170. package/dist/resources/memory-supplied-vector.js +72 -0
  171. package/dist/resources/memory-write-lock.js +310 -0
  172. package/dist/resources/memory-write-response.js +139 -0
  173. package/dist/resources/migrations/data-dir.js +74 -16
  174. package/dist/resources/migrations/dir-safety.js +1 -1
  175. package/dist/resources/migrations/embedding-stamp.js +193 -79
  176. package/dist/resources/migrations/export.js +1 -0
  177. package/dist/resources/migrations/graph-heal.js +18 -25
  178. package/dist/resources/migrations/lock.js +7 -1
  179. package/dist/resources/migrations/snapshot.js +1 -0
  180. package/dist/resources/migrations/source-fields.js +5 -5
  181. package/dist/resources/migrations/synthetic-test-migration.js +14 -11
  182. package/dist/resources/migrations/visibility-backfill.js +29 -29
  183. package/dist/resources/multi-worker-guard.js +121 -0
  184. package/dist/resources/oauth-discovery.js +1 -0
  185. package/dist/resources/oauth-wellknown.js +8 -4
  186. package/dist/resources/object-body-guard.js +33 -0
  187. package/dist/resources/org-event-created-at.js +133 -0
  188. package/dist/resources/originator-instance.js +39 -7
  189. package/dist/resources/owner-delete-recheck.js +78 -0
  190. package/dist/resources/owner-field-guard.js +39 -5
  191. package/dist/resources/owner-scoped-write-policy.js +212 -0
  192. package/dist/resources/owner-scoped-writes.js +58 -0
  193. package/dist/resources/presence-receipt.js +236 -0
  194. package/dist/resources/promotion-stamp.js +47 -12
  195. package/dist/resources/record-owner-guard.js +74 -26
  196. package/dist/resources/record-types.js +17 -1
  197. package/dist/resources/relay-ops.js +78 -6
  198. package/dist/resources/replay-store.js +145 -21
  199. package/dist/resources/request-target.js +136 -0
  200. package/dist/resources/request-transaction.js +35 -0
  201. package/dist/resources/search-readiness.js +4 -1
  202. package/dist/resources/seed-ids.js +9 -0
  203. package/dist/resources/seed-reservation.js +117 -0
  204. package/dist/resources/semantic-retrieval-core.js +20 -9
  205. package/dist/resources/skill-manifest.js +190 -0
  206. package/dist/resources/skill-provenance.js +15 -10
  207. package/dist/resources/skill-subject.js +53 -0
  208. package/dist/resources/skill-version-write.js +432 -0
  209. package/dist/resources/skill-write-fault.js +17 -0
  210. package/dist/resources/skill-write-policy.js +67 -0
  211. package/dist/resources/skill-write.js +67 -7
  212. package/dist/resources/table-helpers.js +10 -7
  213. package/dist/resources/team-directory.js +248 -0
  214. package/dist/resources/tool-descriptors/index.js +69 -8
  215. package/dist/resources/txn-pause-point.js +118 -0
  216. package/dist/resources/usage-recording.js +171 -63
  217. package/dist/resources/write-back.js +218 -0
  218. package/dist/src/engine-version-contract.js +1 -0
  219. package/dist/src/keystore.js +72 -0
  220. package/dist/src/lib/agent-home-fields.js +132 -0
  221. package/dist/src/lib/agent-id-rule.js +46 -0
  222. package/dist/src/lib/agent-key-register.js +80 -0
  223. package/dist/src/lib/atomic-write.js +256 -0
  224. package/dist/src/lib/credential-status-rule.js +78 -0
  225. package/dist/src/lib/expired-by-agent.js +37 -0
  226. package/dist/src/lib/flair-agent-role.js +120 -0
  227. package/dist/src/lib/idp-mapping-rule.js +81 -0
  228. package/dist/src/lib/instance-identity-row.js +20 -0
  229. package/dist/src/lib/mcp-oauth-env-core.js +133 -0
  230. package/dist/src/lib/memory-attributes.js +2 -0
  231. package/dist/src/lib/memory-id-policy.js +46 -0
  232. package/dist/src/lib/principal-status.js +29 -0
  233. package/dist/src/lib/proto-safe-record.js +42 -0
  234. package/dist/src/lib/reembed-server-support.js +66 -0
  235. package/dist/src/lib/scheduler-platform.js +10 -6
  236. package/dist/src/lib/systemd-agent-id.js +38 -0
  237. package/docs/access-control.md +768 -0
  238. package/docs/api-reference.md +52 -13
  239. package/docs/auth.md +10 -12
  240. package/docs/bridges.md +11 -0
  241. package/docs/claude-code.md +34 -4
  242. package/docs/deepseek-harness.md +1 -1
  243. package/docs/deploying-on-fabric.md +70 -0
  244. package/docs/deployment.md +2 -0
  245. package/docs/embedding-in-a-harper-app.md +1 -1
  246. package/docs/federation.md +33 -2
  247. package/docs/hosted-on-fabric.md +43 -36
  248. package/docs/integrations.md +6 -6
  249. package/docs/mcp-clients.md +10 -5
  250. package/docs/n8n.md +17 -11
  251. package/docs/notes/mcp-agent-auth-consumer.md +12 -4
  252. package/docs/notes/mcp-oauth-model2.md +34 -5
  253. package/docs/quickstart-fabric.md +2 -2
  254. package/docs/quickstart.md +9 -1
  255. package/docs/releasing.md +34 -28
  256. package/docs/rem.md +8 -0
  257. package/docs/secrets-and-keys.md +19 -2
  258. package/docs/standalone-local.md +1 -0
  259. package/docs/supply-chain-policy.md +13 -3
  260. package/docs/upgrade.md +32 -6
  261. package/package.json +12 -6
  262. package/schemas/agent-key-registration.graphql +22 -0
  263. package/schemas/agent.graphql +3 -0
  264. package/schemas/federation.graphql +38 -1
  265. package/schemas/memory.graphql +115 -5
  266. package/schemas/oauth.graphql +27 -4
  267. package/schemas/schema.graphql +2 -0
  268. package/templates/launchd/start-flair-with-admin-pass.sh +89 -16
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The ids a POST /MemoryPurge response lists as removed. Throws when the
3
+ * response is not `{ removed, removedIds }` with `removed` equal to the list's
4
+ * length, or when the list leaves out a requested id.
5
+ */
6
+ export function confirmedPurgeIds(response, requested) {
7
+ const body = response;
8
+ const removedIds = body?.removedIds;
9
+ if (!Array.isArray(removedIds) ||
10
+ !removedIds.every((id) => typeof id === "string") ||
11
+ body?.removed !== removedIds.length) {
12
+ throw new Error(`POST /MemoryPurge returned a response that does not list the removed rows: ${String(JSON.stringify(response)).slice(0, 200)}`);
13
+ }
14
+ const removed = new Set(removedIds);
15
+ const unconfirmed = requested.filter((id) => !removed.has(id));
16
+ if (unconfirmed.length > 0) {
17
+ throw new Error(`POST /MemoryPurge did not list ${unconfirmed.length} requested row(s) as removed: ${unconfirmed.slice(0, 5).join(", ")}`);
18
+ }
19
+ return removedIds;
20
+ }
@@ -0,0 +1,25 @@
1
+ export async function readExactTableCount(opsPost, table) {
2
+ const parsed = await opsPost({ operation: "describe_table", database: "flair", table, exact_count: true }, `${table} row count`);
3
+ const n = parsed?.record_count;
4
+ if (!Number.isSafeInteger(n) || n < 0) {
5
+ throw new Error(`${table} row count via the operations API: response carried no record_count`);
6
+ }
7
+ return n;
8
+ }
9
+ /**
10
+ * The exact count of the rows a bounded table read matches — those with
11
+ * `attribute` at or after `since` — through the operations API (`describe_table`
12
+ * counts a whole table, not a range). The bounded deletion-history read is
13
+ * bracketed against this the way a whole-table read is bracketed against
14
+ * `readExactTableCount`: a result the count does not match is a read error, never
15
+ * a history that would read as an unexplained loss.
16
+ */
17
+ export async function readExactCountSince(opsPost, table, attribute, since) {
18
+ const parsed = await opsPost({ operation: "sql", sql: `SELECT COUNT(*) AS n FROM flair.${table} WHERE ${attribute} >= '${since}'` }, `${table} bounded row count`);
19
+ const row = Array.isArray(parsed) ? parsed[0] : Array.isArray(parsed?.results) ? parsed.results[0] : undefined;
20
+ const n = row?.n;
21
+ if (!Number.isSafeInteger(n) || n < 0) {
22
+ throw new Error(`${table} bounded row count via the operations API: response carried no n`);
23
+ }
24
+ return n;
25
+ }
@@ -17,7 +17,7 @@ import { existsSync, lstatSync, readFileSync, statSync } from "node:fs";
17
17
  import { dirname, join } from "node:path";
18
18
  import { withHome } from "./home.js";
19
19
  import { ALL_CLIENTS, clientConfigPath, codexWiringPin, repinCodexPin, repinJsonMcpPin, } from "../install/clients.js";
20
- import { checkSessionStartHook, isFlairHookCommand, SESSION_START_HOOK_INVOCATION_RE, readClientMcpBlock, } from "../doctor-client.js";
20
+ import { checkSessionStartHook, fixSessionStartHook, hookHarnessFromSettingsPath, isFlairHookCommand, SESSION_START_HOOK_INVOCATION_RE, readClientMcpBlock, sessionStartHookHint, } from "../doctor-client.js";
21
21
  import { decodeWiringSpec, decodeWiringSpecs, isComparableWiringPin, wiringPinString, } from "./wiring-spec.js";
22
22
  import { isUnsafeAdapterPin } from "./stale-client-pin.js";
23
23
  import { hookInstallHint, parseInstallerHookForm, hookSettingsPath, repinSessionStartHook, SUPPORTED_HARNESSES, } from "../hook-install.js";
@@ -68,15 +68,46 @@ function readFileText(path) {
68
68
  return null;
69
69
  }
70
70
  }
71
+ const SESSION_START_HOOK_INVOCATIONS_RE = new RegExp(SESSION_START_HOOK_INVOCATION_RE.source, "g");
72
+ /** Read the pin named by a captured installer span or matching command text.
73
+ * Hold multiple `npx -y -p <spec>` spans or a pin without a matching span. */
74
+ function hookInvocationSpec(command) {
75
+ const invocations = (command.match(/\bnpx -y -p (?=\S)/g) ?? []).length;
76
+ if (invocations > 1)
77
+ return { spec: null, invocations, held: true };
78
+ const form = parseInstallerHookForm(command);
79
+ if (form)
80
+ return { spec: form.pkgSpec, invocations, held: false };
81
+ const matches = command.match(SESSION_START_HOOK_INVOCATIONS_RE) ?? [];
82
+ if (invocations === 1 && matches.length === 1) {
83
+ return { spec: matches[0].slice("npx -y -p ".length, -" flair-session-start".length), invocations, held: false };
84
+ }
85
+ const pinned = decodeWiringSpecs(command, FLAIR_MCP_PACKAGE).some((s) => wiringPinString(s) !== null);
86
+ return { spec: null, invocations, held: pinned };
87
+ }
71
88
  export function readOwnedPin(target, homeDir) {
72
89
  if (target.kind === "session-start-hook") {
73
90
  const hook = checkSessionStartHook(homeDir, target.path);
74
- const present = !!(hook.present && hook.command && isFlairHookCommand(hook.command));
91
+ // flair#2291: more than one marker match is held, the writer's own rule
92
+ // (repinSessionStartHook holds on it too).
93
+ const duplicates = hook.present && (hook.matches ?? 1) > 1;
94
+ const present = duplicates || !!(hook.present && hook.command && isFlairHookCommand(hook.command));
95
+ if (!present)
96
+ return { target, present, entryExists: present, pin: null };
97
+ const span = duplicates ? null : hookInvocationSpec(hook.command);
98
+ const held = duplicates
99
+ ? `${hook.matches} Flair SessionStart hooks match in ${target.displayPath} — pin not read, not re-pinned; remove all but one`
100
+ : span.held
101
+ ? span.invocations === 1
102
+ ? `No \`npx -y -p\` span invokes Flair in ${target.displayPath} — pin not read, not re-pinned; use \`npx -y -p ${FLAIR_MCP_PACKAGE} flair-session-start\``
103
+ : `${span.invocations} \`npx -y -p\` spans in ${target.displayPath} — pin not read, not re-pinned; edit the hook to one`
104
+ : undefined;
75
105
  return {
76
106
  target,
77
107
  present,
78
108
  entryExists: present,
79
- pin: present ? wiringPinString(decodeWiringSpec(hook.command ?? "", FLAIR_MCP_PACKAGE)) : null,
109
+ pin: held || !span || span.spec === null ? null : wiringPinString(decodeWiringSpec(span.spec, FLAIR_MCP_PACKAGE)),
110
+ ...(held ? { held } : {}),
80
111
  };
81
112
  }
82
113
  const block = readClientMcpBlock(target.id, homeDir);
@@ -227,10 +258,41 @@ export function pinDirection(pin, target) {
227
258
  * surface with its own rendering.
228
259
  */
229
260
  export function sessionStartHookPinFindings(homeDir, expectedVersion = flairCliVersion()) {
230
- return staleSessionStartHookPins(homeDir, expectedVersion).map((reading) => ({
261
+ const stale = staleSessionStartHookPins(homeDir, expectedVersion).map((reading) => ({
231
262
  reading,
232
263
  direction: pinDirection(reading.pin, expectedVersion),
233
264
  }));
265
+ // flair#2291: a HELD hook (no pin read) is a finding too, direction "unknown".
266
+ const held = listOwnedPinTargets(homeDir)
267
+ .filter((t) => t.kind === "session-start-hook")
268
+ .map((t) => readOwnedPin(t, homeDir))
269
+ .filter((r) => r.held)
270
+ .map((reading) => ({ reading, direction: "unknown" }));
271
+ return [...stale, ...held];
272
+ }
273
+ export function applyOrRepinSessionStartHook(homeDir, agentId, skip, settingsPath) {
274
+ const existing = checkSessionStartHook(homeDir, settingsPath);
275
+ if (existing.present) {
276
+ const harness = hookHarnessFromSettingsPath(existing.path);
277
+ const finding = sessionStartHookPinFindings(homeDir).find((f) => f.reading.target.id === harness);
278
+ if (!finding) {
279
+ return { applied: false, ok: true, message: `SessionStart hook already wired in ${existing.path}` };
280
+ }
281
+ if (finding.reading.held) {
282
+ return { applied: false, ok: false, message: finding.reading.held };
283
+ }
284
+ if (skip) {
285
+ return { applied: false, ok: false, message: `SessionStart hook in ${existing.path} not re-pinned (--skip-hook)` };
286
+ }
287
+ const repin = repinSessionStartHookGuarded(homeDir, harness);
288
+ return { applied: repin.action === "update", ok: repin.ok, message: repin.message };
289
+ }
290
+ const hint = sessionStartHookHint(agentId, existing.path);
291
+ if (skip) {
292
+ return { applied: false, ok: false, message: "SessionStart hook skipped (--skip-hook)", hint };
293
+ }
294
+ const fix = fixSessionStartHook(homeDir, agentId, settingsPath ?? existing.path);
295
+ return { applied: fix.ok, ok: fix.ok, message: fix.message, hint: fix.ok ? undefined : hint };
234
296
  }
235
297
  /**
236
298
  * Stale MCP-client pins, each annotated with its direction — the client-side
@@ -284,12 +346,7 @@ export function repinSessionStartHookGuarded(homeDir, harness, target) {
284
346
  const wouldWrite = flairCliVersion();
285
347
  const command = checkSessionStartHook(homeDir, resolved.path).command;
286
348
  const form = command ? parseInstallerHookForm(command) : null;
287
- // A form supplies the exact span the writer replaces. For a rejected form,
288
- // the status-only match may recover an unreadable pin for a HOLD; it cannot
289
- // authorize a write. The writer still validates the full command in-lock.
290
- const invocation = form ? undefined : command?.match(SESSION_START_HOOK_INVOCATION_RE)?.[0];
291
- const spec = form?.pkgSpec
292
- ?? invocation?.slice("npx -y -p ".length, -" flair-session-start".length);
349
+ const spec = command ? hookInvocationSpec(command).spec : null;
293
350
  const existing = spec ? wiringPinString(decodeWiringSpec(spec, FLAIR_MCP_PACKAGE)) : null;
294
351
  // A comparable pin in a non-installer command is a shape refusal, not an
295
352
  // unknown pin. Let the writer retain its "not one of the installer forms"
@@ -0,0 +1,27 @@
1
+ /** Documented Peer.status CLI vocabulary. */
2
+ export const PEER_STATUS = {
3
+ PAIRED: "paired",
4
+ CONNECTED: "connected",
5
+ DISCONNECTED: "disconnected",
6
+ REVOKED: "revoked",
7
+ };
8
+ /** Values listed in the Peer.status schema comment. */
9
+ export const PEER_STATUS_VALUES = [
10
+ PEER_STATUS.PAIRED,
11
+ PEER_STATUS.CONNECTED,
12
+ PEER_STATUS.DISCONNECTED,
13
+ PEER_STATUS.REVOKED,
14
+ ];
15
+ export const PEER_MEMBERSHIP_STATUSES = [
16
+ PEER_STATUS.PAIRED,
17
+ PEER_STATUS.CONNECTED,
18
+ PEER_STATUS.DISCONNECTED,
19
+ ];
20
+ /** Classify the documented CLI vocabulary. */
21
+ export function isPeerStatus(value) {
22
+ return typeof value === "string" && PEER_STATUS_VALUES.includes(value);
23
+ }
24
+ /** Classify the documented membership statuses. */
25
+ export function isPeerMemberStatus(value) {
26
+ return typeof value === "string" && PEER_MEMBERSHIP_STATUSES.includes(value);
27
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * principal-status.ts — the ONE "is this principal deactivated?" predicate
3
+ * (flair#2378).
4
+ *
5
+ * `Agent.status` is a principal's lifecycle state. The auth path decides it
6
+ * here: a principal is deactivated when `status` is present and is not exactly
7
+ * "active". An ABSENT (undefined) `status` means active.
8
+ *
9
+ * The human-readable `flair principal show` and `principal list` outputs call
10
+ * this function and read the principal as stored — `show` over REST, `list` from an
11
+ * unprojected row — so an absent `status` (active) stays distinct from an
12
+ * explicit `null`, which the gate treats as deactivated.
13
+ *
14
+ * Deliberately dependency-free (no `harper`, no resource) so both the CLI
15
+ * (`src/`) and the server (`resources/`) import it: `src/` must not import
16
+ * `resources/`, because those imports do not survive npm packaging.
17
+ */
18
+ /**
19
+ * True iff this principal is deactivated: its `status` is present and is not
20
+ * exactly the string "active". A null/undefined principal, or one whose
21
+ * `status` is undefined, is not deactivated.
22
+ */
23
+ export function isPrincipalDeactivated(agent) {
24
+ if (agent == null)
25
+ return false;
26
+ if (agent.status === undefined)
27
+ return false;
28
+ return agent.status !== "active";
29
+ }
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * Parsers and the ±2s match live in `daemon-liveness.ts` (pure). This file
5
5
  * is the I/O adapter those parsers need: Linux `/proc/<pid>/stat` field 22
6
- * plus `/proc/uptime`, macOS `ps -o lstart=`. One reader for the production
6
+ * plus `/proc/stat` btime (whole seconds) or `/proc/uptime` (full ms), and
7
+ * macOS `ps -o lstart=`. One reader for the production
7
8
  * daemon identity check and the harness scratch-owner stamp (flair#1372).
8
9
  *
9
10
  * Darwin `ps -o lstart=` prints local time without a zone. `Date.parse` of
@@ -31,23 +32,118 @@ import { parseProcStatStartTime, parsePsLstart, procStartTimeToEpochMs, } from "
31
32
  export function applyLstartZoneOffset(targetParsedMs, ownParsedMs, ownTrueStartMs) {
32
33
  return targetParsedMs - (ownParsedMs - ownTrueStartMs);
33
34
  }
34
- function readPsLstart(pid) {
35
+ function readPsLstart(pid, deadline = Infinity) {
36
+ const timeout = Math.min(2000, deadline - Date.now());
37
+ if (timeout <= 0)
38
+ return null;
35
39
  try {
36
40
  return execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
37
41
  encoding: "utf-8",
38
42
  env: { ...process.env, LC_ALL: "C" },
39
- timeout: 2000,
43
+ timeout,
44
+ killSignal: "SIGKILL",
40
45
  });
41
46
  }
42
47
  catch {
43
48
  return null;
44
49
  }
45
50
  }
46
- export function readProcessStartTimeMs(pid) {
51
+ let cachedClockTicksPerSecond;
52
+ function clockTicksPerSecond() {
53
+ if (cachedClockTicksPerSecond !== undefined)
54
+ return cachedClockTicksPerSecond;
55
+ try {
56
+ const raw = execFileSync("getconf", ["CLK_TCK"], {
57
+ encoding: "utf-8",
58
+ timeout: 2000,
59
+ stdio: ["ignore", "pipe", "ignore"],
60
+ }).trim();
61
+ if (/^[1-9][0-9]*$/.test(raw)) {
62
+ const ticks = Number(raw);
63
+ if (Number.isSafeInteger(ticks))
64
+ return (cachedClockTicksPerSecond = ticks);
65
+ }
66
+ }
67
+ catch {
68
+ // Unknown rate cannot establish a process's start time.
69
+ }
70
+ // Retry on a later read: getconf failure may be transient. Cache only a
71
+ // verified positive rate, never a guessed value.
72
+ return null;
73
+ }
74
+ /**
75
+ * Linux's whole start second from `/proc/stat` boot time and `/proc` start
76
+ * ticks when the host tick rate is known. `/proc/uptime` plus `Date.now()`
77
+ * is sampled at two different moments, so its reconstructed boot epoch can
78
+ * move across a second boundary between reads of the same pid.
79
+ *
80
+ * `/proc/<pid>/stat` reports starttime in USER_HZ ticks, and
81
+ * `/proc/stat` reports btime in whole epoch seconds. Truncate the tick count
82
+ * before adding btime so the answer is stable across sampling and wall-clock
83
+ * second boundaries while btime is unchanged.
84
+ */
85
+ export function procStartSecondMsFromStat(processStat, systemStat, clkTck) {
86
+ const starttimeTicks = parseProcStatStartTime(processStat);
87
+ const bootTimeMatch = /^btime[ \t]+([0-9]+)[ \t]*$/m.exec(systemStat);
88
+ if (starttimeTicks === null || !Number.isSafeInteger(starttimeTicks) || starttimeTicks < 0 || bootTimeMatch === null || !Number.isSafeInteger(clkTck) || clkTck <= 0)
89
+ return null;
90
+ const bootTimeSeconds = Number(bootTimeMatch[1]);
91
+ if (!Number.isSafeInteger(bootTimeSeconds) || bootTimeSeconds <= 0)
92
+ return null;
93
+ const startSecondMs = (bootTimeSeconds + Math.floor(starttimeTicks / clkTck)) * 1000;
94
+ return Number.isSafeInteger(startSecondMs) ? startSecondMs : null;
95
+ }
96
+ /**
97
+ * The pid's start time truncated to a whole second, in epoch ms when readable
98
+ * (flair#2056).
99
+ *
100
+ * macOS: the second `ps -o lstart=` reports. The zone correction is the
101
+ * `applyLstartZoneOffset` offset rounded to a whole minute: that offset is the
102
+ * parser's zone error (whole minutes) minus this process's sub-second start
103
+ * fraction, and the rounding drops the fraction. Linux: btime plus the
104
+ * `/proc` start ticks truncated to the second, only with a verified CLK_TCK.
105
+ */
106
+ export function readProcessStartSecondMs(pid) {
107
+ if (!Number.isInteger(pid) || pid <= 0)
108
+ return null;
109
+ if (process.platform === "linux") {
110
+ try {
111
+ const clkTck = clockTicksPerSecond();
112
+ if (clkTck === null)
113
+ return null;
114
+ return procStartSecondMsFromStat(readFileSync(`/proc/${pid}/stat`, "utf-8"), readFileSync("/proc/stat", "utf-8"), clkTck);
115
+ }
116
+ catch {
117
+ return null;
118
+ }
119
+ }
120
+ if (process.platform === "darwin") {
121
+ const targetRaw = readPsLstart(pid);
122
+ if (targetRaw === null)
123
+ return null;
124
+ const targetParsed = parsePsLstart(targetRaw);
125
+ if (targetParsed === null)
126
+ return null;
127
+ const ownRaw = pid === process.pid ? targetRaw : readPsLstart(process.pid);
128
+ if (ownRaw === null)
129
+ return null;
130
+ const ownParsed = parsePsLstart(ownRaw);
131
+ if (ownParsed === null)
132
+ return null;
133
+ const ownTrueStartMs = Date.now() - process.uptime() * 1000;
134
+ const zoneErrorMs = Math.round((ownParsed - ownTrueStartMs) / 60_000) * 60_000;
135
+ return targetParsed - zoneErrorMs;
136
+ }
137
+ return null;
138
+ }
139
+ export function readProcessStartTimeMs(pid, deadline = Infinity) {
47
140
  if (!Number.isInteger(pid) || pid <= 0)
48
141
  return null;
49
142
  if (process.platform === "linux") {
50
143
  try {
144
+ const clkTck = clockTicksPerSecond();
145
+ if (clkTck === null)
146
+ return null;
51
147
  const stat = readFileSync(`/proc/${pid}/stat`, "utf-8");
52
148
  const starttime = parseProcStatStartTime(stat);
53
149
  if (starttime === null)
@@ -56,20 +152,20 @@ export function readProcessStartTimeMs(pid) {
56
152
  const uptime = Number(uptimeRaw);
57
153
  if (!Number.isFinite(uptime))
58
154
  return null;
59
- return procStartTimeToEpochMs(starttime, uptime, Date.now());
155
+ return procStartTimeToEpochMs(starttime, uptime, Date.now(), clkTck);
60
156
  }
61
157
  catch {
62
158
  return null;
63
159
  }
64
160
  }
65
161
  if (process.platform === "darwin") {
66
- const targetRaw = readPsLstart(pid);
162
+ const targetRaw = readPsLstart(pid, deadline);
67
163
  if (targetRaw === null)
68
164
  return null;
69
165
  const targetParsed = parsePsLstart(targetRaw);
70
166
  if (targetParsed === null)
71
167
  return null;
72
- const ownRaw = pid === process.pid ? targetRaw : readPsLstart(process.pid);
168
+ const ownRaw = pid === process.pid ? targetRaw : readPsLstart(process.pid, deadline);
73
169
  if (ownRaw === null)
74
170
  return null;
75
171
  const ownParsed = parsePsLstart(ownRaw);
@@ -0,0 +1,42 @@
1
+ /**
2
+ * proto-safe-record.ts — shared helper for these converted sites, copying own
3
+ * keys into a null-prototype record, entry by entry (flair#2235).
4
+ *
5
+ * Why this exists. A copy built with `Object.assign(target, source)` or an
6
+ * explicit `target[key] = value` loop goes through [[Set]]. For the key
7
+ * `__proto__` on a plain object that runs the inherited `Object.prototype`
8
+ * accessor instead of creating a key, so an own `__proto__` key is either
9
+ * turned into the copy's prototype (object value) or dropped (primitive
10
+ * value). A comparison or checkpoint that reads the copy then silently
11
+ * ignores a value the source carried (flair#2225, #2233).
12
+ *
13
+ * The copy here is built on `Object.create(null)` and each entry is defined as
14
+ * an OWN property with `Object.defineProperty`, so every own enumerable string
15
+ * key it copies survives, `__proto__` included, and the copy can never inherit
16
+ * a prototype it did not ask for.
17
+ */
18
+ /**
19
+ * Build a null-prototype record from `source`, own key by own key. Each key is
20
+ * defined as an own enumerable property, so `__proto__` is a data key and never
21
+ * the record's prototype. With `validate`, the first refused value throws a
22
+ * `TypeError` naming the key, with no record returned.
23
+ */
24
+ export function protoSafeRecord(source, options = {}) {
25
+ const src = source;
26
+ const keys = options.keys ?? Object.keys(src);
27
+ const out = Object.create(null);
28
+ for (const key of keys) {
29
+ const raw = src[key];
30
+ const refused = options.validate?.(raw, key);
31
+ if (refused !== undefined) {
32
+ throw new TypeError(`protoSafeRecord: refused value for "${key}": ${refused}`);
33
+ }
34
+ Object.defineProperty(out, key, {
35
+ value: options.map ? options.map(raw, key) : raw,
36
+ enumerable: true,
37
+ writable: true,
38
+ configurable: true,
39
+ });
40
+ }
41
+ return out;
42
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * record-id-path.ts — build a request path from a record id (flair#1970).
3
+ *
4
+ * An id is arbitrary data; a URL path segment is not. Interpolating an id raw
5
+ * changes the request: `/` splits it into two segments, `?` and `#` start a
6
+ * query or fragment, `%` is read as an escape, and URL normalization folds a
7
+ * `.` or `..` segment away (RFC 3986 §5.2.4). `encodeURIComponent` keeps the id
8
+ * one segment that decodes back to it — the same rule flair-client has applied
9
+ * since #1969.
10
+ *
11
+ * `.` and `..` are refused rather than sent: no encoding makes them address a
12
+ * record as one segment, because normalization removes them first. A caller
13
+ * gets an error instead of a request to the wrong path.
14
+ */
15
+ export function encodeRecordId(id) {
16
+ if (id === "." || id === "..") {
17
+ throw new Error(`record id ${JSON.stringify(id)} is a URL path dot-segment ("." or ".."); ` +
18
+ "it cannot be addressed as one path segment. Use a different id.");
19
+ }
20
+ return encodeURIComponent(id);
21
+ }
22
+ /** `/<collection>/<encoded id>` — the record's own path, one id segment. */
23
+ export function recordIdPath(collection, id) {
24
+ return `/${collection}/${encodeRecordId(id)}`;
25
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * reembed-server-support.ts — the server-support check `flair reembed` runs
3
+ * before its first write (flair#2337).
4
+ *
5
+ * flair#2298 made the CLI re-embed a row by sending `PATCH /Memory/<id>` with
6
+ * `{"embedding": null, "embeddingModel": null}`; the server recognises that
7
+ * body and re-embeds the stored row. A server built before #2298 does not. A
8
+ * CLI newer than its server is a supported state (`flair upgrade
9
+ * --no-restart`, a bare npm install, an unrestarted service), so the CLI reads
10
+ * the server's advertised capabilities from `GET /Health` before any write and
11
+ * refuses when the token is absent or the response cannot be parsed.
12
+ *
13
+ * The parser and message builders are pure; the fetch adapter lives in
14
+ * src/commands/reembed.ts.
15
+ */
16
+ /**
17
+ * This build advertises this /Health capability for the re-embed PATCH.
18
+ * The shared constant aligns this build's CLI and server literals.
19
+ * A missing token is intentionally refused even if an intermediate server
20
+ * supports the PATCH.
21
+ */
22
+ export const MEMORY_REEMBED_PATCH_CAPABILITY = "memory-reembed-patch";
23
+ /**
24
+ * The capability names a /Health body advertises.
25
+ *
26
+ * - an array of strings — the advertised capabilities (empty when the field
27
+ * is absent: an older server, or a build from before #2337 added it);
28
+ * - `null` — the field is present but not a string array. The client cannot
29
+ * interpret this shape, so the caller must treat the read as unverified
30
+ * rather than as "no capabilities".
31
+ */
32
+ export function parseHealthCapabilities(body) {
33
+ if (typeof body !== "object" || body === null || Array.isArray(body))
34
+ return null;
35
+ const caps = body.capabilities;
36
+ if (caps === undefined)
37
+ return [];
38
+ if (!Array.isArray(caps) || caps.some((c) => typeof c !== "string"))
39
+ return null;
40
+ return caps;
41
+ }
42
+ /** The server version a /Health body reports, or null when it carries none. */
43
+ export function healthVersion(body) {
44
+ if (typeof body !== "object" || body === null)
45
+ return null;
46
+ const v = body.version;
47
+ return typeof v === "string" && v.length > 0 ? v : null;
48
+ }
49
+ /** The remedy both refusal messages end with. */
50
+ export const REEMBED_SUPPORT_REMEDY = "Restart or upgrade the server, then re-run `flair reembed`.";
51
+ /** The refusal for a server that answered but does not advertise the capability. */
52
+ export function reembedUnsupportedMessage(version) {
53
+ return [
54
+ "❌ flair reembed stopped before its first write: the server does not advertise the re-embed PATCH.",
55
+ ` Found: server version ${version ?? "unknown"}, with no "${MEMORY_REEMBED_PATCH_CAPABILITY}" capability.`,
56
+ ` ${REEMBED_SUPPORT_REMEDY}`,
57
+ ].join("\n");
58
+ }
59
+ /** The refusal for a failed or unparseable /Health read. */
60
+ export function reembedUnverifiedMessage(detail) {
61
+ return [
62
+ "❌ flair reembed stopped before its first write: could not confirm the server supports the re-embed PATCH.",
63
+ ` Found: ${detail}.`,
64
+ ` ${REEMBED_SUPPORT_REMEDY}`,
65
+ ].join("\n");
66
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Restore compares archived Memory and Soul fields, excluding the server stamps
3
+ * and derived fields below.
4
+ *
5
+ * Memory.put() (resources/Memory.ts):
6
+ * - excluded: `updatedAt`, `provenance`, and `instanceToken` (new on create,
7
+ * stored on update).
8
+ * - excluded: `originatorInstanceId` (local on create, stored on update) and
9
+ * `_originatorInstanceId`/`_syncedFrom`/`_syncedAt` (dropped on create,
10
+ * stored on update; resources/originator-instance.ts).
11
+ * - excluded: `retrievalCount`/`lastRetrieved` (MemoryHitStat read overlay).
12
+ * - compared: supplied `embedding` and its `embeddingModel`. Without an
13
+ * embedding, exclude both when embedding text permits generation; the
14
+ * generated model comes from getModelId() (Memory.ts:505-544, 1750-1753).
15
+ * - compared: `_safetyFlags` when neither content safety nor SkillScan runs;
16
+ * exclude during scans because they can replace or append flags
17
+ * (Memory.ts:1689-1712; skill-write.ts:125-157).
18
+ * - compared: `visibility` (defaulted on create when nullish), `createdAt`
19
+ * and `archived` (defaulted when nullish).
20
+ * - compared: `archivedAt`, `expiresAt`, `validFrom`; falsy values, including
21
+ * empty strings, can be replaced when archiving, writing an effective
22
+ * ephemeral durability, or supplying `supersedes`, respectively.
23
+ * - compared: `durability`; accepted skill writes force it to `persistent`
24
+ * (resources/skill-write.ts).
25
+ * - compared: the remaining listed attributes, including `meta`/`kind`.
26
+ *
27
+ * Soul.put() (resources/Soul.ts):
28
+ * - excluded: `updatedAt`, `provenance`, and `originatorInstanceId` (local on
29
+ * create, stored on update).
30
+ * - compared: `id`, `agentId`, `key`, `value`, `priority`, `metadata`,
31
+ * `durability`, `createdAt`.
32
+ *
33
+ * Agent rows retain the id-only check.
34
+ * A field is compared only when the archived row owns it; conditional write
35
+ * transformations of compared fields still fail closed on a mismatch.
36
+ * `undefined` and `null` values compare equal; missing nested keys remain distinct;
37
+ * objects compare with sorted keys;
38
+ * arrays compare in order.
39
+ */
40
+ import { protoSafeRecord } from "./proto-safe-record.js";
41
+ /** The columns restore compares per table. */
42
+ export const RESTORE_PRESERVED_FIELDS = Object.freeze({
43
+ Memory: Object.freeze([
44
+ "id", "agentId", "content", "contentHash", "trigger", "visibility",
45
+ "tags", "durability", "source", "type",
46
+ "createdAt", "expiresAt", "usageCount", "promotionStatus", "promotedAt",
47
+ "promotedBy", "archived", "archivedAt", "archivedBy", "parentId",
48
+ "derivedFrom", "sessionId", "lastReflected", "supersedes", "subject",
49
+ "summary", "validFrom", "validTo", "metadata", "entities",
50
+ "meta", "kind",
51
+ ]),
52
+ Soul: Object.freeze([
53
+ "id", "agentId", "key", "value", "priority", "metadata", "durability", "createdAt",
54
+ ]),
55
+ });
56
+ /** Undefined values equal null; missing nested keys remain distinct. */
57
+ function normalize(value) {
58
+ if (value === undefined || value === null)
59
+ return null;
60
+ if (Array.isArray(value))
61
+ return value.map(normalize);
62
+ if (typeof value === "object") {
63
+ const src = value;
64
+ // A null-prototype copy built entry by entry: an own `__proto__` key
65
+ // survives and stays visible to the comparison below (flair#2233, #2235).
66
+ return protoSafeRecord(src, { keys: Object.keys(src).sort(), map: normalize });
67
+ }
68
+ return value;
69
+ }
70
+ function sameValue(a, b) {
71
+ return JSON.stringify(normalize(a)) === JSON.stringify(normalize(b));
72
+ }
73
+ /**
74
+ * Compare the archived row against the restored row over the listed fields
75
+ * and return the NAMES of the fields that differ. Values are never returned,
76
+ * so a caller can log the mismatch without leaking record content.
77
+ * Non-`Memory`/`Soul` tables have no extra compared fields and return `[]`.
78
+ */
79
+ export function comparePreservedFields(table, archived, restored) {
80
+ const fields = [...(RESTORE_PRESERVED_FIELDS[table] ?? [])];
81
+ if (!archived || typeof archived !== "object" || Array.isArray(archived))
82
+ return [];
83
+ if (!restored || typeof restored !== "object" || Array.isArray(restored))
84
+ return [];
85
+ const from = archived;
86
+ const to = restored;
87
+ if (table === "Memory") {
88
+ const skill = Array.isArray(from.tags) && from.tags.includes("skill");
89
+ const skillTrigger = skill && typeof from.trigger === "string" && from.trigger.length > 0;
90
+ const embedText = skillTrigger ? from.trigger : from.content;
91
+ if (from.embedding || !embedText)
92
+ fields.push("embedding", "embeddingModel");
93
+ if (!from.content && !from.summary && !skillTrigger)
94
+ fields.push("_safetyFlags");
95
+ }
96
+ const mismatched = [];
97
+ for (const field of fields) {
98
+ if (!Object.prototype.hasOwnProperty.call(from, field))
99
+ continue;
100
+ if (!sameValue(from[field], to[field]))
101
+ mismatched.push(field);
102
+ }
103
+ return mismatched;
104
+ }
@@ -214,9 +214,11 @@ export function resolveNodeBin(explicit) {
214
214
  if (!process.versions.bun && process.execPath && isAbsolute(process.execPath)) {
215
215
  return process.execPath;
216
216
  }
217
- const r = spawnReport(["/bin/sh", "-c", "command -v node"], STATUS_CHECK_TIMEOUT_MS);
218
- const found = r.stdout.trim().split("\n")[0]?.trim() ?? "";
219
- if (r.code === 0 && found && isAbsolute(found) && existsSync(found))
217
+ const r = spawnSync("/bin/sh", ["-s"], {
218
+ input: "command -v node\n", encoding: "utf8", timeout: STATUS_CHECK_TIMEOUT_MS,
219
+ });
220
+ const found = r.stdout?.trim().split("\n")[0]?.trim() ?? "";
221
+ if (r.status === 0 && found && isAbsolute(found) && existsSync(found))
220
222
  return found;
221
223
  throw new Error("unable to resolve an absolute path to a node binary (not running under node, and `command -v node` " +
222
224
  "found nothing). The scheduler shim runs `<node> <flair-script>` with the node path baked in at " +
@@ -280,9 +282,11 @@ export function formatFlairBinWarning(baked, publicBin, enableCommand) {
280
282
  return lines;
281
283
  }
282
284
  function lookupPublicFlairBin() {
283
- const r = spawnReport(["/bin/sh", "-c", "command -v flair"], STATUS_CHECK_TIMEOUT_MS);
284
- const found = r.stdout.trim().split("\n")[0]?.trim() ?? "";
285
- if (r.code === 0 && found && isAbsolute(found) && existsSync(found))
285
+ const r = spawnSync("/bin/sh", ["-s"], {
286
+ input: "command -v flair\n", encoding: "utf8", timeout: STATUS_CHECK_TIMEOUT_MS,
287
+ });
288
+ const found = r.stdout?.trim().split("\n")[0]?.trim() ?? "";
289
+ if (r.status === 0 && found && isAbsolute(found) && existsSync(found))
286
290
  return found;
287
291
  return null;
288
292
  }