@tpsdev-ai/flair 0.55.2 → 0.57.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 (106) hide show
  1. package/README.md +18 -19
  2. package/dist/bridges/builtins/markdown.js +2 -2
  3. package/dist/bridges/discover.js +2 -2
  4. package/dist/bridges/runtime/allow-list.js +2 -2
  5. package/dist/build-info.json +3 -3
  6. package/dist/cli.js +125 -26
  7. package/dist/commands/agent.js +22 -15
  8. package/dist/commands/attention.js +2 -2
  9. package/dist/commands/backup.js +2 -2
  10. package/dist/commands/bridge.js +40 -3
  11. package/dist/commands/doctor.js +91 -28
  12. package/dist/commands/export.js +2 -2
  13. package/dist/commands/federation.js +441 -68
  14. package/dist/commands/hook.js +4 -4
  15. package/dist/commands/init.js +59 -12
  16. package/dist/commands/mcp.js +2 -2
  17. package/dist/commands/migrate-harness-memory.js +8 -8
  18. package/dist/commands/rem.js +2 -2
  19. package/dist/commands/service.js +25 -1
  20. package/dist/commands/session.js +2 -2
  21. package/dist/commands/uninstall.js +2 -2
  22. package/dist/commands/upgrade.js +3 -3
  23. package/dist/doctor-client.js +5 -23
  24. package/dist/engine-version.js +2 -2
  25. package/dist/federation/scheduler.js +5 -5
  26. package/dist/install/clients.js +5 -10
  27. package/dist/keystore.js +10 -2
  28. package/dist/lib/auth-resolve.js +51 -5
  29. package/dist/lib/doctor-config-path.js +2 -2
  30. package/dist/lib/flair-paths.js +29 -0
  31. package/dist/lib/home.js +60 -0
  32. package/dist/lib/instance-identity-row.js +580 -0
  33. package/dist/lib/launchd-repair.js +6 -0
  34. package/dist/lib/mcp-enable.js +4 -4
  35. package/dist/lib/owned-pins.js +1 -13
  36. package/dist/lib/redact-token-id.js +197 -0
  37. package/dist/lib/socket-path-limit.js +120 -0
  38. package/dist/lib/uninstall-purge.js +2 -18
  39. package/dist/lib/upgrade-plain-tree.js +2 -2
  40. package/dist/mcp-client-assertion.js +3 -3
  41. package/dist/rem/runner.js +3 -3
  42. package/dist/rem/scheduler.js +5 -5
  43. package/dist/rem/snapshot.js +2 -2
  44. package/dist/resources/AgentSeed.js +4 -1
  45. package/dist/resources/Asset.js +3 -11
  46. package/dist/resources/Credential.js +4 -10
  47. package/dist/resources/Federation.js +232 -78
  48. package/dist/resources/Integration.js +8 -32
  49. package/dist/resources/Memory.js +58 -16
  50. package/dist/resources/MemoryBootstrap.js +19 -12
  51. package/dist/resources/MemoryCandidate.js +3 -11
  52. package/dist/resources/MemoryDedupStats.js +1 -1
  53. package/dist/resources/MemoryFeed.js +10 -2
  54. package/dist/resources/MemoryGrant.js +19 -40
  55. package/dist/resources/MemoryUsage.js +7 -20
  56. package/dist/resources/OAuth.js +62 -11
  57. package/dist/resources/Presence.js +135 -47
  58. package/dist/resources/Relationship.js +3 -11
  59. package/dist/resources/SemanticSearch.js +25 -13
  60. package/dist/resources/admin-layout.js +7 -2
  61. package/dist/resources/auth-middleware.js +32 -5
  62. package/dist/resources/bm25.js +13 -14
  63. package/dist/resources/federation-cleanup.js +289 -51
  64. package/dist/resources/health.js +48 -8
  65. package/dist/resources/in-process-api.js +2 -1
  66. package/dist/resources/instance-create-lock.js +363 -0
  67. package/dist/resources/instance-identity-rows.js +43 -0
  68. package/dist/resources/instance-identity.js +94 -10
  69. package/dist/resources/mcp-handler.js +9 -1
  70. package/dist/resources/mcp-tool-arguments.js +83 -0
  71. package/dist/resources/mcp-tools.js +4 -5
  72. package/dist/resources/memory-reflect-lib.js +17 -1
  73. package/dist/resources/memory-visibility.js +10 -7
  74. package/dist/resources/rate-limit.js +6 -4
  75. package/dist/resources/record-type-kit.js +47 -23
  76. package/dist/resources/search-readiness.js +7 -1
  77. package/dist/resources/semantic-retrieval-core.js +98 -3
  78. package/dist/resources/table-helpers.js +33 -0
  79. package/dist/resources/tool-descriptors/index.js +2 -2
  80. package/dist/src/keystore.js +10 -2
  81. package/dist/src/lib/home.js +60 -0
  82. package/dist/src/lib/instance-identity-row.js +580 -0
  83. package/dist/src/lib/redact-token-id.js +197 -0
  84. package/dist/src/rem/scheduler.js +5 -5
  85. package/dist/version-check.js +2 -2
  86. package/dist/version-handshake.js +2 -2
  87. package/docs/api-reference.md +32 -7
  88. package/docs/auth.md +19 -7
  89. package/docs/claude-code.md +5 -6
  90. package/docs/deploying-on-fabric.md +8 -4
  91. package/docs/deployment.md +26 -37
  92. package/docs/embedding-in-a-harper-app.md +4 -2
  93. package/docs/entity-vocabulary.md +5 -5
  94. package/docs/federation.md +48 -21
  95. package/docs/hosted-on-fabric.md +7 -4
  96. package/docs/integrations.md +24 -15
  97. package/docs/mcp-clients.md +44 -23
  98. package/docs/n8n.md +8 -8
  99. package/docs/notes/mcp-oauth-model2.md +12 -17
  100. package/docs/openclaw.md +29 -28
  101. package/docs/spoke-bringup.md +44 -22
  102. package/docs/standalone-local.md +12 -16
  103. package/docs/supply-chain-policy.md +21 -8
  104. package/docs/system-requirements.md +1 -1
  105. package/docs/upgrade.md +2 -2
  106. package/package.json +1 -1
@@ -14,8 +14,8 @@
14
14
  * as "no peers" and the driver check would be silenced — the #1514 hazard).
15
15
  */
16
16
  import { existsSync, readFileSync } from "node:fs";
17
- import { homedir } from "node:os";
18
17
  import { join, resolve } from "node:path";
18
+ import { resolveHome } from "./home.js";
19
19
  const CONFIG_BASENAMES = ["config.yaml", "config.yml"];
20
20
  function configFilesIn(dir) {
21
21
  return CONFIG_BASENAMES.map((name) => join(dir, name));
@@ -27,7 +27,7 @@ function configFilesIn(dir) {
27
27
  */
28
28
  export function flairConfigYamlCandidates(opts = {}) {
29
29
  const cwd = resolve(opts.cwd ?? process.cwd());
30
- const homeDir = opts.homeDir ?? homedir();
30
+ const homeDir = opts.homeDir ?? resolveHome();
31
31
  const out = [...configFilesIn(cwd)];
32
32
  if (opts.componentDir) {
33
33
  const componentDir = resolve(opts.componentDir);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * flair-paths.ts — the home-derived paths every subsystem must agree on (flair#1858).
3
+ *
4
+ * Each of these used to compute `~` itself (`os.homedir()` in cli.ts and
5
+ * backup.ts). `os.homedir()` is cached at process START, so a `HOME` set later in
6
+ * the process — which the keystore and the client writers now honour — was
7
+ * invisible to them, and doctor could inspect a different home from the one the
8
+ * writers used. They all resolve through `resolveHome()` now, with an explicit
9
+ * `home` argument available to tests and callers that already resolved one.
10
+ */
11
+ import { existsSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import { resolveHome } from "./home.js";
14
+ /** `~/.flair/data` — the instance data dir. */
15
+ export function flairDataDir(home = resolveHome()) {
16
+ return join(home, ".flair", "data");
17
+ }
18
+ /** `~/.flair/config.yaml`, or `config.yml` when only that exists. */
19
+ export function flairConfigPath(home = resolveHome()) {
20
+ const yamlPath = join(home, ".flair", "config.yaml");
21
+ const ymlPath = join(home, ".flair", "config.yml");
22
+ if (existsSync(ymlPath) && !existsSync(yamlPath))
23
+ return ymlPath;
24
+ return yamlPath;
25
+ }
26
+ /** Default `flair backup` output: `~/.flair/backups/flair-backup-<timestamp>.json`. */
27
+ export function flairBackupOutputPath(timestamp, home = resolveHome()) {
28
+ return join(home, ".flair", "backups", `flair-backup-${timestamp}.json`);
29
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The user's home directory, resolved at CALL time (flair#1853).
3
+ *
4
+ * `os.homedir()` is cached at process start, so a HOME set later in the same
5
+ * process is invisible to it. Every Flair surface that resolves `~` — the
6
+ * keystore and the client config writers — must land on the SAME home, and it
7
+ * must be the one the calling shell actually uses.
8
+ *
9
+ * Which environment variable names that home differs by platform:
10
+ *
11
+ * - **Windows** — `USERPROFILE` is authoritative. Node's `os.homedir()` reads
12
+ * it, but a POSIX-style shell (Git Bash, MSYS, Cygwin) may set `HOME` to a
13
+ * different path. Preferring `HOME` there would move `~/.flair/keys` away
14
+ * from where the keys actually live, so an existing key would read as
15
+ * missing (and a new one would be written somewhere nothing looks).
16
+ * - **Everywhere else** — `HOME` is authoritative (and is how the test harness
17
+ * redirects a process), with `os.homedir()` as the fallback.
18
+ */
19
+ import { homedir } from "node:os";
20
+ /** The home directory for this invocation, resolved at call time. */
21
+ export function resolveHome() {
22
+ return process.platform === "win32"
23
+ ? process.env.USERPROFILE || homedir()
24
+ : process.env.HOME || homedir();
25
+ }
26
+ /**
27
+ * Run `fn` with BOTH `HOME` and `USERPROFILE` pointed at `homeDir`, then restore
28
+ * both to exactly what they were — including the previously-UNSET case, and even
29
+ * when `fn` throws. Returns `fn`'s value.
30
+ *
31
+ * `resolveHome()` reads `USERPROFILE` on win32 and `HOME` elsewhere, so setting
32
+ * only `HOME` silently ignored the override on Windows: doctor, the pin refresh
33
+ * and uninstall's `unwire()` then acted on the real profile instead of the
34
+ * directory the caller named. Both are set here, so the override holds on every
35
+ * platform.
36
+ *
37
+ * `fn` MUST be synchronous. The parameter type REJECTS a Promise-returning
38
+ * callback at compile time (a Promise is not assignable to the `never` branch),
39
+ * because a sync save/restore around async work would restore the environment
40
+ * before the work runs.
41
+ */
42
+ export function withHome(homeDir, fn) {
43
+ const prevHome = process.env.HOME;
44
+ const prevProfile = process.env.USERPROFILE;
45
+ process.env.HOME = homeDir;
46
+ process.env.USERPROFILE = homeDir;
47
+ try {
48
+ return fn();
49
+ }
50
+ finally {
51
+ if (prevHome === undefined)
52
+ delete process.env.HOME;
53
+ else
54
+ process.env.HOME = prevHome;
55
+ if (prevProfile === undefined)
56
+ delete process.env.USERPROFILE;
57
+ else
58
+ process.env.USERPROFILE = prevProfile;
59
+ }
60
+ }