@tpsdev-ai/flair 0.55.0 → 0.55.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.
- package/dist/build-info.json +3 -3
- package/dist/commands/doctor.js +33 -8
- package/dist/commands/upgrade.js +6 -0
- package/dist/lib/embed-gpu-doctor.js +40 -7
- package/dist/lib/upgrade-plain-tree.js +293 -48
- package/docs/deployment.md +38 -5
- package/docs/standalone-local.md +7 -4
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.55.
|
|
3
|
-
"commit": "
|
|
4
|
-
"builtAt": "2026-09-
|
|
2
|
+
"version": "0.55.1",
|
|
3
|
+
"commit": "e048d3b1bb538c8c8e5c57df2802f416b3bed104",
|
|
4
|
+
"builtAt": "2026-09-21T06:28:01.245Z",
|
|
5
5
|
"builder": "tsc"
|
|
6
6
|
}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -102,6 +102,33 @@ export function summarizeDoctorRun(found, fixed, autoFix) {
|
|
|
102
102
|
exitCode: 1,
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* flair#1761 — the single place a Health-derived Metal finding becomes doctor
|
|
107
|
+
* output and exit-code weight. Extracted from the action callback so the
|
|
108
|
+
* detected-vs-env-vs-unrecognized severity is exercised on the real
|
|
109
|
+
* rendering/counting path (the action's Harper probe, console side effects
|
|
110
|
+
* and process.exit cannot be driven directly — see doctor-summary.test.ts for
|
|
111
|
+
* the same extraction convention).
|
|
112
|
+
*
|
|
113
|
+
* The finding carries its own icon and issue weight: a derived ("detected")
|
|
114
|
+
* Metal default is rendered as a persistent warning and does NOT increment
|
|
115
|
+
* the issue count, while an explicit request or an unrecognized source is a
|
|
116
|
+
* blocking `✗` that does. `lines` is returned for tests; production passes a
|
|
117
|
+
* writer (default: console.log).
|
|
118
|
+
*/
|
|
119
|
+
export function renderEmbedGpuDoctorFinding(embedding, write = (line) => console.log(line)) {
|
|
120
|
+
const finding = describeEmbedGpuDoctorFinding(embedding);
|
|
121
|
+
if (!finding)
|
|
122
|
+
return { lines: [], issueDelta: 0 };
|
|
123
|
+
const icon = finding.icon === "warn" ? render.icons.warn : render.icons.error;
|
|
124
|
+
const lines = [
|
|
125
|
+
` ${icon} ${finding.message}`,
|
|
126
|
+
` ${render.wrap(render.c.dim, "Fix:")} ${finding.fixHint}`,
|
|
127
|
+
];
|
|
128
|
+
for (const line of lines)
|
|
129
|
+
write(line);
|
|
130
|
+
return { lines, issueDelta: finding.isIssue ? 1 : 0 };
|
|
131
|
+
}
|
|
105
132
|
// ─── flair doctor ─────────────────────────────────────────────────────────────
|
|
106
133
|
export function register(program) {
|
|
107
134
|
const __pkgVersion = cli.__pkgVersion;
|
|
@@ -422,14 +449,12 @@ export function register(program) {
|
|
|
422
449
|
else {
|
|
423
450
|
console.log(` ${render.icons.warn} Could not determine the running server's version`);
|
|
424
451
|
}
|
|
425
|
-
// flair#1437
|
|
426
|
-
// read doctor.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
issues++;
|
|
432
|
-
}
|
|
452
|
+
// flair#1437 (severity split flair#1761): Health states an unconfirmed
|
|
453
|
+
// Metal offload; operators read doctor. The finding carries its own
|
|
454
|
+
// severity — a derived ("detected") default is an advisory warning that
|
|
455
|
+
// does NOT fail the run, while an explicit request or an unrecognized
|
|
456
|
+
// source still fails closed. A stated CPU default is silent here.
|
|
457
|
+
issues += renderEmbedGpuDoctorFinding(embedGpuFromHealth).issueDelta;
|
|
433
458
|
}
|
|
434
459
|
// 2. Keys directory
|
|
435
460
|
const keysDir = defaultKeysDir();
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -985,6 +985,12 @@ export function register(program) {
|
|
|
985
985
|
let treePlan = null;
|
|
986
986
|
if (treeLane) {
|
|
987
987
|
const flairFindingForPlan = findings.find((f) => f.name === FLAIR_PKG_NAME);
|
|
988
|
+
// flair#1758: unit discovery is captured HERE, into the plan, while apply
|
|
989
|
+
// later renames the selected canonical tree (applyPlainTreeUpgrade). A
|
|
990
|
+
// concurrent symlink retarget between discovery and apply can therefore
|
|
991
|
+
// make the restart launch a DIFFERENT tree than the one that matched.
|
|
992
|
+
// Resolving both sides fresh narrows the window; it is not transaction
|
|
993
|
+
// locking.
|
|
988
994
|
treePlan = planPlainTreeUpgrade({
|
|
989
995
|
treeDir: treeLane.dir,
|
|
990
996
|
fromVersion: treeLane.version,
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* embed-gpu-doctor.ts — the flair doctor line for
|
|
3
|
-
* (flair#1437 PLAN ACCEPTED condition 1).
|
|
2
|
+
* embed-gpu-doctor.ts — the flair doctor line for an unconfirmed Metal offload
|
|
3
|
+
* (flair#1437 PLAN ACCEPTED condition 1; severity split added by flair#1761).
|
|
4
4
|
*
|
|
5
5
|
* /Health already carries `embedding.fallback` when offload was requested
|
|
6
|
-
* and
|
|
7
|
-
* This is the single decision: given the public
|
|
8
|
-
* what (if anything) doctor prints
|
|
6
|
+
* and the GPU log heuristic did not confirm Metal. Operators read
|
|
7
|
+
* `flair doctor`, not Health. This is the single decision: given the public
|
|
8
|
+
* Health embedding field, what (if anything) doctor prints, and whether it
|
|
9
|
+
* weighs on doctor's exit code.
|
|
10
|
+
*
|
|
11
|
+
* flair#1761: the finding is NOT one severity. The fallback sentence is a log
|
|
12
|
+
* heuristic, not an observation (it can err in both directions), and since
|
|
13
|
+
* 0.55.0 the derived Metal default requests offload on every darwin-arm64
|
|
14
|
+
* host without the operator asking. So the severity is read off `source`:
|
|
15
|
+
*
|
|
16
|
+
* source === "detected" → the default chose for the operator; advisory
|
|
17
|
+
* WARNING, does not count as an issue.
|
|
18
|
+
* source === "env" → the operator explicitly set
|
|
19
|
+
* FLAIR_EMBED_GPU_LAYERS; blocking ERROR.
|
|
20
|
+
* missing / unrecognized → FAIL CLOSED: blocking ERROR, exactly as before.
|
|
21
|
+
* An unknown state is never softened to advisory.
|
|
9
22
|
*/
|
|
10
23
|
export const EMBED_GPU_DOCTOR_MARKER = "requested GPU offload; Metal did not engage";
|
|
24
|
+
/** Advisory wording (flair#1761). We cannot observe engagement, only that it
|
|
25
|
+
* was NOT confirmed — the old "did not engage" over-claimed. */
|
|
26
|
+
export const EMBED_GPU_DETECTED_MESSAGE = "Automatic Metal acceleration was requested, but engagement could not be verified.";
|
|
11
27
|
/**
|
|
12
|
-
*
|
|
28
|
+
* Doctor finding, or null when there is nothing to say.
|
|
13
29
|
* Only the Health `fallback` sentence is a finding — a stated CPU default
|
|
14
|
-
* or a confirmed Metal run is not an issue.
|
|
30
|
+
* or a confirmed Metal run is not an issue. The severity depends on
|
|
31
|
+
* `source` (flair#1761): an operator-requested offload that was not
|
|
32
|
+
* confirmed still fails loud, but the derived Metal default is advisory and
|
|
33
|
+
* an unrecognized source fails closed.
|
|
15
34
|
*/
|
|
16
35
|
export function describeEmbedGpuDoctorFinding(embedding) {
|
|
17
36
|
if (embedding == null || typeof embedding !== "object" || Array.isArray(embedding)) {
|
|
@@ -21,6 +40,20 @@ export function describeEmbedGpuDoctorFinding(embedding) {
|
|
|
21
40
|
if (typeof fallback !== "string" || !fallback.includes(EMBED_GPU_DOCTOR_MARKER)) {
|
|
22
41
|
return null;
|
|
23
42
|
}
|
|
43
|
+
const source = embedding.source;
|
|
44
|
+
if (source === "detected") {
|
|
45
|
+
// The Metal default requested offload for the operator; nothing was
|
|
46
|
+
// chosen. Working embeddings on CPU is a standing, benign condition —
|
|
47
|
+
// keep it visible as a persistent warning, never a blocking finding.
|
|
48
|
+
return {
|
|
49
|
+
isIssue: false,
|
|
50
|
+
icon: "warn",
|
|
51
|
+
message: EMBED_GPU_DETECTED_MESSAGE,
|
|
52
|
+
fixHint: "Pin CPU with FLAIR_EMBED_GPU_LAYERS=0.",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// A source the operator set ("env"), or one we do not recognize at all
|
|
56
|
+
// (missing/unknown) — fail closed and keep the existing fail-loud finding.
|
|
24
57
|
return {
|
|
25
58
|
isIssue: true,
|
|
26
59
|
icon: "error",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
* (b) — the exec-path mismatch warning — already shipped in #1560
|
|
18
18
|
* (`upgrade-exec-path.ts`). This file does not change that wording.
|
|
19
19
|
*/
|
|
20
|
-
import { existsSync, mkdirSync, renameSync, rmSync, cpSync, readdirSync, readFileSync, statSync, lstatSync, } from "node:fs";
|
|
21
|
-
import { basename, dirname, join } from "node:path";
|
|
20
|
+
import { existsSync, mkdirSync, renameSync, rmSync, cpSync, readdirSync, readFileSync, statSync, lstatSync, realpathSync, } from "node:fs";
|
|
21
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
22
22
|
import { homedir } from "node:os";
|
|
23
23
|
import { execFileSync } from "node:child_process";
|
|
24
24
|
import { extract as tarExtract } from "tar";
|
|
@@ -227,61 +227,302 @@ export function formatPlainTreePlan(plan) {
|
|
|
227
227
|
function formatUnitRef(u) {
|
|
228
228
|
return `${u.name} (${u.scope}: ${u.path})`;
|
|
229
229
|
}
|
|
230
|
+
// ─── unit path operands (flair#1758) ────────────────────────────────────────
|
|
231
|
+
//
|
|
232
|
+
// Discovery compares the tree against the PATHS A UNIT ACTUALLY USES, not
|
|
233
|
+
// against arbitrary text. The original matcher scanned the whole file with only
|
|
234
|
+
// a trailing-boundary check, so a canonical path inside a COMMENT matched, and
|
|
235
|
+
// any unrelated value that merely CONTAINED the tree path matched too. Because
|
|
236
|
+
// the caller already canonicalizes the tree (readFlairPackageAt →
|
|
237
|
+
// canonicalPath), the "also try canonicalPath(treeDir)" variant here was dead
|
|
238
|
+
// code: the operand that needs resolving is the one read out of the unit file,
|
|
239
|
+
// not the tree.
|
|
240
|
+
//
|
|
241
|
+
// So: extract operands from ACTIVE `[Service]` `WorkingDirectory` and
|
|
242
|
+
// `ExecStart` directives, then compare canonical-to-canonical.
|
|
243
|
+
//
|
|
244
|
+
// - `WorkingDirectory` is a directory: its resolved path must EQUAL the tree.
|
|
245
|
+
// - `ExecStart` operands are executables/scripts/arguments: keep the original
|
|
246
|
+
// tree-DESCENDANT intent, on PATH-COMPONENT boundaries (so `/opt/flair-spoke`
|
|
247
|
+
// is not "inside" `/opt/flair`).
|
|
248
|
+
//
|
|
249
|
+
// Explicitly NOT done: the whole command line is never canonicalized as one
|
|
250
|
+
// string; quoted values are tokenized with systemd quoting rules rather than
|
|
251
|
+
// split on whitespace; and an operand carrying a systemd specifier (`%i`, `%n`)
|
|
252
|
+
// or a shell variable (`$VAR`) is not a literal host path, so it is skipped
|
|
253
|
+
// rather than matched.
|
|
254
|
+
//
|
|
255
|
+
// KNOWN LIMIT — `RootDirectory=`, `RootImage=` and service-specific bind mounts
|
|
256
|
+
// mean a unit can see DIFFERENT content at the same host pathname, so host
|
|
257
|
+
// `realpath` is not proof of service identity. Automatic matching stays scoped
|
|
258
|
+
// to host-path semantics; `FLAIR_SYSTEMD_UNIT` remains the escape hatch for
|
|
259
|
+
// namespaced configurations.
|
|
260
|
+
/** True when `child` is `root` itself or a path-component descendant of it. */
|
|
261
|
+
function isPathInside(child, root) {
|
|
262
|
+
if (child === root)
|
|
263
|
+
return true;
|
|
264
|
+
return child.startsWith(root.endsWith("/") ? root : `${root}/`);
|
|
265
|
+
}
|
|
266
|
+
/** Strip a leading systemd ExecStart/WorkingDirectory prefix (`-`, `@`, `+`, `!`, `:`). */
|
|
267
|
+
function stripSystemdExecPrefix(word) {
|
|
268
|
+
let i = 0;
|
|
269
|
+
while (i < word.length && "-@+!:".includes(word[i]))
|
|
270
|
+
i++;
|
|
271
|
+
return word.slice(i);
|
|
272
|
+
}
|
|
230
273
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
274
|
+
* Canonicalize a path even when its leaf — or a middle segment — does not
|
|
275
|
+
* exist, by realpath-ing the deepest EXISTING ancestor and re-appending the
|
|
276
|
+
* remainder.
|
|
277
|
+
*
|
|
278
|
+
* `canonicalPath` alone is not enough: `realpathSync("/opt/flair/flair")`
|
|
279
|
+
* throws when that file is absent, and its fallback returns the LEXICAL path,
|
|
280
|
+
* so a symlinked `/opt/flair` would never resolve for a unit naming a file
|
|
281
|
+
* inside it. Resolving the ancestor is what makes the unit operand and the tree
|
|
282
|
+
* comparable.
|
|
234
283
|
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
284
|
+
* Only ABSOLUTE host paths are canonicalized — a relative operand is not a path
|
|
285
|
+
* into the tree. Returns null for anything that is not a literal host path
|
|
286
|
+
* (relative, or containing an unresolved `%`/`$`).
|
|
238
287
|
*/
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
288
|
+
function canonicalizeOperand(rawPath) {
|
|
289
|
+
const raw = rawPath.trim();
|
|
290
|
+
if (!raw.startsWith("/"))
|
|
291
|
+
return null;
|
|
292
|
+
if (raw.includes("%") || raw.includes("$"))
|
|
293
|
+
return null;
|
|
294
|
+
const abs = resolve(raw);
|
|
295
|
+
let cur = abs;
|
|
296
|
+
const tail = [];
|
|
297
|
+
for (;;) {
|
|
298
|
+
// `existsSync` is the STRICT check in both runtimes; gate `realpathSync` on
|
|
299
|
+
// it. Bun's `realpathSync` is lenient — for a path ending in a literal
|
|
300
|
+
// backslash it silently drops the backslash and returns the canonical dir,
|
|
301
|
+
// where Node throws ENOENT — so relying on `realpathSync` alone makes the
|
|
302
|
+
// matcher depend on the runtime (production ships Node, tests run Bun).
|
|
303
|
+
// With the gate, a backslash operand falls through to the ancestor walk on
|
|
304
|
+
// both, yielding `path + "\\"` (≠ the tree).
|
|
305
|
+
if (existsSync(cur)) {
|
|
306
|
+
let real = cur;
|
|
307
|
+
try {
|
|
308
|
+
real = realpathSync(cur);
|
|
309
|
+
}
|
|
310
|
+
catch { /* unreadable — fall back to the existing lexical prefix */ }
|
|
311
|
+
return tail.length > 0 ? join(real, ...tail.reverse()) : real;
|
|
312
|
+
}
|
|
313
|
+
const parent = dirname(cur);
|
|
314
|
+
if (parent === cur)
|
|
315
|
+
return abs; // nothing on this path exists — lexical
|
|
316
|
+
tail.push(basename(cur));
|
|
317
|
+
cur = parent;
|
|
258
318
|
}
|
|
259
319
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Tokenize a systemd directive value the way systemd splits ExecStart /
|
|
322
|
+
* WorkingDirectory: whitespace-separated words, single quotes literal, double
|
|
323
|
+
* quotes literal except for `\"`, `\\`, `\$`, and backslash escaping outside
|
|
324
|
+
* quotes. No variable/specifier expansion — callers treat those as non-paths.
|
|
325
|
+
*/
|
|
326
|
+
function splitSystemdWords(value) {
|
|
327
|
+
const words = [];
|
|
328
|
+
let cur = "";
|
|
329
|
+
let started = false;
|
|
330
|
+
let inSingle = false;
|
|
331
|
+
let inDouble = false;
|
|
332
|
+
for (let i = 0; i < value.length; i++) {
|
|
333
|
+
const ch = value[i];
|
|
334
|
+
if (inSingle) {
|
|
335
|
+
if (ch === "'")
|
|
336
|
+
inSingle = false;
|
|
337
|
+
else
|
|
338
|
+
cur += ch;
|
|
339
|
+
started = true;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (inDouble) {
|
|
343
|
+
if (ch === "\\" && i + 1 < value.length && "\"\\$".includes(value[i + 1])) {
|
|
344
|
+
cur += value[++i];
|
|
345
|
+
started = true;
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (ch === "\"")
|
|
349
|
+
inDouble = false;
|
|
350
|
+
else
|
|
351
|
+
cur += ch;
|
|
352
|
+
started = true;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (ch === "'") {
|
|
356
|
+
inSingle = true;
|
|
357
|
+
started = true;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (ch === "\"") {
|
|
361
|
+
inDouble = true;
|
|
362
|
+
started = true;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (ch === "\\" && i + 1 < value.length) {
|
|
366
|
+
cur += value[++i];
|
|
367
|
+
started = true;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
if (ch === " " || ch === "\t") {
|
|
371
|
+
if (started) {
|
|
372
|
+
words.push(cur);
|
|
373
|
+
cur = "";
|
|
374
|
+
started = false;
|
|
375
|
+
}
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
cur += ch;
|
|
379
|
+
started = true;
|
|
269
380
|
}
|
|
270
|
-
|
|
381
|
+
if (started)
|
|
382
|
+
words.push(cur);
|
|
383
|
+
return words;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* True when `line` ends in an unescaped backslash — systemd's continuation
|
|
387
|
+
* marker. Counts the run of trailing backslashes so an escaped `\\` is not
|
|
388
|
+
* treated as a continuation.
|
|
389
|
+
*/
|
|
390
|
+
function endsWithUnescapedBackslash(line) {
|
|
391
|
+
const stripped = line.replace(/[ \t]+$/, "");
|
|
392
|
+
let n = 0;
|
|
393
|
+
for (let i = stripped.length - 1; i >= 0 && stripped[i] === "\\"; i--)
|
|
394
|
+
n++;
|
|
395
|
+
return n % 2 === 1;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Fold systemd line continuations into logical lines before parsing: a physical
|
|
399
|
+
* line ending in an unescaped backslash joins the next line (the backslash and
|
|
400
|
+
* the newline become a single space). Folding first means a directive whose
|
|
401
|
+
* value lands on the continuation line is still read as one directive —
|
|
402
|
+
* otherwise it looks like an empty (reset) assignment.
|
|
403
|
+
*
|
|
404
|
+
* Comment lines (`#`/`;`) are dropped BEFORE the continuation logic, matching
|
|
405
|
+
* systemd's `config_parse()` (`src/shared/conf-parser.c:358` skips a comment at
|
|
406
|
+
* the top of the loop and does NOT touch the pending `continuation`;
|
|
407
|
+
* `:372-401` appends only after that check; `:432` parses a leftover
|
|
408
|
+
* continuation at EOF). A comment block after a backslash-continued line is
|
|
409
|
+
* therefore IGNORED, and the continuation joins whatever follows it —
|
|
410
|
+
* `systemd.syntax(7)`:
|
|
411
|
+
* KeyThree=value 3\
|
|
412
|
+
* # this line is ignored
|
|
413
|
+
* ; this line is ignored too
|
|
414
|
+
* value 3 continued -> KeyThree=value 3 value 3 continued
|
|
415
|
+
*/
|
|
416
|
+
function foldSystemdContinuations(unitText) {
|
|
417
|
+
const logical = [];
|
|
418
|
+
let acc = "";
|
|
419
|
+
let accumulating = false;
|
|
420
|
+
for (const raw of unitText.split(/\r?\n/)) {
|
|
421
|
+
// Comments first: systemd skips them before continuation handling, so a
|
|
422
|
+
// comment line must not terminate (or be flushed into) a pending fold.
|
|
423
|
+
if (raw.trimStart().startsWith("#") || raw.trimStart().startsWith(";"))
|
|
424
|
+
continue;
|
|
425
|
+
const line = accumulating ? raw.replace(/^[ \t]+/, "") : raw;
|
|
426
|
+
if (endsWithUnescapedBackslash(line)) {
|
|
427
|
+
acc += line.replace(/[ \t]+$/, "").slice(0, -1) + " ";
|
|
428
|
+
accumulating = true;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (accumulating) {
|
|
432
|
+
logical.push(acc + line);
|
|
433
|
+
acc = "";
|
|
434
|
+
accumulating = false;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
logical.push(line);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (accumulating)
|
|
441
|
+
logical.push(acc);
|
|
442
|
+
return logical;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* The values of every active `key` directive inside `[Service]`. systemd's
|
|
446
|
+
* RESET semantics are honoured: a blank value (`WorkingDirectory=` /
|
|
447
|
+
* `ExecStart=`) clears the values collected so far for that key, and later
|
|
448
|
+
* non-blank values accumulate again. Comments, directives in other sections,
|
|
449
|
+
* and continued lines (folded first) are handled.
|
|
450
|
+
*
|
|
451
|
+
* Directive names are case-SENSITIVE. `config_item_table_lookup` matches with
|
|
452
|
+
* `streq` (`src/shared/conf-parser.c:67`) and the gperf table carries no
|
|
453
|
+
* `%ignore-case` (`src/core/load-fragment-gperf.gperf.in`), so a mis-cased key
|
|
454
|
+
* (e.g. `workingdirectory=`) is logged as "Unknown key … ignoring" and has NO
|
|
455
|
+
* effect. Matching it here would select a unit systemd does not configure.
|
|
456
|
+
*
|
|
457
|
+
* `opts.single` selects the storage rule for the key. systemd treats
|
|
458
|
+
* `WorkingDirectory` as SINGLE-valued (`config_parse_working_directory` does
|
|
459
|
+
* `free_and_replace`, so the LAST non-blank assignment wins) but `ExecStart` as
|
|
460
|
+
* a genuine LIST whose assignments accumulate. Sharing this scanner — rather
|
|
461
|
+
* than a second reader — keeps reset/continuation/comment handling identical.
|
|
462
|
+
*/
|
|
463
|
+
function activeServiceDirectiveValues(unitText, key, opts = {}) {
|
|
464
|
+
const values = [];
|
|
465
|
+
let section = "";
|
|
466
|
+
for (const rawLine of foldSystemdContinuations(unitText)) {
|
|
467
|
+
const line = rawLine.trim();
|
|
468
|
+
if (line === "" || line.startsWith("#") || line.startsWith(";"))
|
|
469
|
+
continue;
|
|
470
|
+
if (line.startsWith("[")) {
|
|
471
|
+
section = line.slice(1).replace(/\].*$/, "").trim().toLowerCase();
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
if (section !== "service")
|
|
475
|
+
continue;
|
|
476
|
+
const eq = line.indexOf("=");
|
|
477
|
+
if (eq < 0)
|
|
478
|
+
continue;
|
|
479
|
+
// Exact case — systemd is case-sensitive for directive names (see above).
|
|
480
|
+
if (line.slice(0, eq).trim() !== key)
|
|
481
|
+
continue;
|
|
482
|
+
const value = line.slice(eq + 1).trim();
|
|
483
|
+
if (value === "") {
|
|
484
|
+
// Blank assignment RESETS the list for this key — it is NOT a no-op.
|
|
485
|
+
// Drop everything collected so far; later non-blank values accumulate.
|
|
486
|
+
values.length = 0;
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
// Single-valued key: the LAST non-blank assignment wins. List key: every
|
|
490
|
+
// non-blank value is an operand.
|
|
491
|
+
if (opts.single)
|
|
492
|
+
values.length = 0;
|
|
493
|
+
values.push(value);
|
|
494
|
+
}
|
|
495
|
+
return values;
|
|
271
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* Does this unit's ACTIVE, parsed path operands name the tree? Canonicalizes the
|
|
499
|
+
* unit-side operand (resolving symlinks via its existing ancestor) and the tree,
|
|
500
|
+
* then compares. See the block comment above for what is deliberately excluded.
|
|
501
|
+
*/
|
|
272
502
|
export function unitTextMentionsTree(unitText, treeDir) {
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
503
|
+
const tree = canonicalPath(treeDir);
|
|
504
|
+
// WorkingDirectory: SINGLE-valued — only the last non-blank assignment counts
|
|
505
|
+
// — and its resolved path must BE the tree.
|
|
506
|
+
for (const value of activeServiceDirectiveValues(unitText, "WorkingDirectory", { single: true })) {
|
|
507
|
+
const [first] = splitSystemdWords(value);
|
|
508
|
+
if (first === undefined)
|
|
509
|
+
continue;
|
|
510
|
+
const resolved = canonicalizeOperand(stripSystemdExecPrefix(first));
|
|
511
|
+
if (resolved !== null && resolved === tree)
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
// ExecStart: a path operand that lives INSIDE the tree (executable / script /
|
|
515
|
+
// argument), on path-component boundaries.
|
|
516
|
+
for (const value of activeServiceDirectiveValues(unitText, "ExecStart")) {
|
|
517
|
+
const words = splitSystemdWords(value);
|
|
518
|
+
for (let i = 0; i < words.length; i++) {
|
|
519
|
+
const operand = i === 0 ? stripSystemdExecPrefix(words[i]) : words[i];
|
|
520
|
+
const resolved = canonicalizeOperand(operand);
|
|
521
|
+
if (resolved !== null && isPathInside(resolved, tree))
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
282
524
|
}
|
|
283
|
-
|
|
284
|
-
return [...variants].some((v) => textMentionsDir(unitText, v));
|
|
525
|
+
return false;
|
|
285
526
|
}
|
|
286
527
|
const SYSTEM_UNIT_DIRS = ["/etc/systemd/system"];
|
|
287
528
|
export function userSystemdDir(home = homedir()) {
|
|
@@ -444,6 +685,10 @@ export async function applyPlainTreeUpgrade(plan, hooks = {}) {
|
|
|
444
685
|
if (existsSync(plan.previousDir)) {
|
|
445
686
|
rmSync(plan.previousDir, { recursive: true, force: true });
|
|
446
687
|
}
|
|
688
|
+
// flair#1758: this rename moves the tree discovery matched. If a symlink in
|
|
689
|
+
// the tree's path is retargeted between discovery (upgrade.ts) and here, the
|
|
690
|
+
// restart can launch a different tree. Documented, not solved — fresh
|
|
691
|
+
// comparison is not locking.
|
|
447
692
|
try {
|
|
448
693
|
renameSync(plan.treeDir, plan.previousDir);
|
|
449
694
|
}
|
package/docs/deployment.md
CHANGED
|
@@ -136,9 +136,40 @@ Then set `FLAIR_URL=http://localhost:19926` on the client.
|
|
|
136
136
|
|
|
137
137
|
### Direct network access
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
Flair reads the HTTP bind host from three places — the first one set wins:
|
|
140
|
+
|
|
141
|
+
1. `flair init --http-bind <host>`
|
|
142
|
+
2. `FLAIR_HTTP_BIND` in the Flair process environment
|
|
143
|
+
3. a **top-level** `httpBind:` key in `~/.flair/config.yaml`
|
|
144
|
+
|
|
145
|
+
`127.0.0.1` is the default when none is set. **Only hosts that include IPv4
|
|
146
|
+
loopback are accepted** — `127.0.0.1` itself, or a wildcard (`0.0.0.0` / `::`).
|
|
147
|
+
Every credentialed self-call Flair makes hardcodes `127.0.0.1`, so a bind that
|
|
148
|
+
excludes it is refused: it would leave those calls pointing at a dead port
|
|
149
|
+
while every bind check still passed.
|
|
150
|
+
|
|
151
|
+
To widen deliberately, pass the flag — or record it in config so the choice
|
|
152
|
+
survives `flair restart` / `flair upgrade`, neither of which takes the flag:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
flair init --http-bind 0.0.0.0
|
|
156
|
+
```
|
|
140
157
|
|
|
141
158
|
```yaml
|
|
159
|
+
# ~/.flair/config.yaml — top-level, NOT nested under `http:`
|
|
160
|
+
httpBind: 0.0.0.0
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
> **`http.host` is not read.** Earlier versions of this page told you to widen
|
|
164
|
+
> the bind with a nested `http.host:` key. **Flair never read that key**, and
|
|
165
|
+
> from 0.55.0 it is ignored outright: an install that was only ever wide
|
|
166
|
+
> because the old default bound every interface will narrow to `127.0.0.1` on
|
|
167
|
+
> the next `flair restart` or `flair upgrade`. The block below is kept so this
|
|
168
|
+
> section stays findable from a snippet you may already have — **do not copy
|
|
169
|
+
> it**; use `httpBind:` (or `--http-bind` / `FLAIR_HTTP_BIND`) instead.
|
|
170
|
+
|
|
171
|
+
```yaml
|
|
172
|
+
# OLD — ignored by Flair. Replace with `httpBind:` as above.
|
|
142
173
|
http:
|
|
143
174
|
port: 19926
|
|
144
175
|
host: 0.0.0.0 # listen on all interfaces
|
|
@@ -154,7 +185,7 @@ All configuration lives in `~/.flair/`:
|
|
|
154
185
|
|
|
155
186
|
```
|
|
156
187
|
~/.flair/
|
|
157
|
-
├── config.yaml # port, host, embedding model
|
|
188
|
+
├── config.yaml # port, bind host, embedding model
|
|
158
189
|
├── data/ # Harper database
|
|
159
190
|
├── keys/ # Ed25519 keypairs per agent
|
|
160
191
|
└── backups/ # flair backup output
|
|
@@ -163,9 +194,10 @@ All configuration lives in `~/.flair/`:
|
|
|
163
194
|
### Key config options (`~/.flair/config.yaml`)
|
|
164
195
|
|
|
165
196
|
```yaml
|
|
166
|
-
http
|
|
167
|
-
|
|
168
|
-
|
|
197
|
+
# Top-level keys — Flair's config has no nested `http:` block, and no
|
|
198
|
+
# `http.host`.
|
|
199
|
+
port: 19926 # API port (ops port = this - 1)
|
|
200
|
+
httpBind: 127.0.0.1 # HTTP bind host (see "Direct network access" above)
|
|
169
201
|
|
|
170
202
|
clustering:
|
|
171
203
|
nodeName: flair
|
|
@@ -185,6 +217,7 @@ Set these in the Flair process environment (`~/Library/LaunchAgents/ai.tpsdev.fl
|
|
|
185
217
|
| `HDB_ADMIN_PASSWORD` | Bootstrap password for the embedded Harper. After first start, the persisted user record is the source of truth; rotate via the Harper ops API, not by changing this env var. | Set at install time. See [secrets-and-keys.md](secrets-and-keys.md) for rotation. |
|
|
186
218
|
| `FLAIR_KEY_PASSPHRASE` | Passphrase used to derive the AES-256-GCM key that wraps federation private-key seeds at rest. Auto-generated to `~/.flair/keys/.passphrase` if unset. | Set explicitly for production federation deployments so the passphrase isn't auto-generated and lost on disk wipe. |
|
|
187
219
|
| `HTTP_PORT` | Override the Harper HTTP port. Useful for sandboxes; production deployments should configure the port in `config.yaml` instead. | Rare. |
|
|
220
|
+
| `FLAIR_HTTP_BIND` | Bind address for the Harper **HTTP API**. Resolution order: `flair init --http-bind` > this variable > the top-level `httpBind` key `flair init` persists in `~/.flair/config.yaml` > `127.0.0.1`. Only `127.0.0.1` or a wildcard (`0.0.0.0` / `::`) is accepted — the listener must include IPv4 loopback for Flair's own `127.0.0.1` self-calls. Every Flair-managed Harper start re-asserts the resolved value, so the persisted key is what survives `flair restart` / `flair upgrade`. | Only for deployments that need the HTTP API reachable off-host — set it to `0.0.0.0`, or record it once with `flair init --http-bind 0.0.0.0`. Single-host installs want the loopback default. |
|
|
188
221
|
| `FLAIR_OPS_BIND` | Bind address for the Harper **ops API**. Resolution order: `flair init --ops-bind` > this variable > the `opsBind` key `flair init` persists in `~/.flair/config.yaml` > `127.0.0.1`. Every Flair-managed Harper start re-asserts the resolved value, so the persisted key is what makes a choice survive `flair restart` / `flair upgrade`. | Only for deployments that genuinely need remote ops admin (multi-host / Fabric) — set it to `0.0.0.0`, or record it once with `flair init --ops-bind 0.0.0.0`. Single-host installs want the loopback default. |
|
|
189
222
|
|
|
190
223
|
### Performance-related environment variables
|
package/docs/standalone-local.md
CHANGED
|
@@ -79,7 +79,7 @@ All configuration lives in `~/.flair/`:
|
|
|
79
79
|
|
|
80
80
|
```
|
|
81
81
|
~/.flair/
|
|
82
|
-
├── config.yaml # port, host, embedding model
|
|
82
|
+
├── config.yaml # port, bind host, embedding model
|
|
83
83
|
├── data/ # Harper database (RocksDB)
|
|
84
84
|
├── keys/ # Ed25519 keypairs per agent (mode 0600)
|
|
85
85
|
└── backups/ # flair backup output
|
|
@@ -87,10 +87,12 @@ All configuration lives in `~/.flair/`:
|
|
|
87
87
|
|
|
88
88
|
### Key config options (`~/.flair/config.yaml`)
|
|
89
89
|
|
|
90
|
+
Flair's own config file uses **top-level** keys — there is no nested `http:`
|
|
91
|
+
block, and no `http.host` (see [`deployment.md` — Direct network access](deployment.md#direct-network-access) for widening):
|
|
92
|
+
|
|
90
93
|
```yaml
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
host: 127.0.0.1 # bind address (0.0.0.0 for remote access)
|
|
94
|
+
port: 19926 # API port (ops port = this - 1)
|
|
95
|
+
httpBind: 127.0.0.1 # HTTP bind host; 0.0.0.0 widens (must include IPv4 loopback)
|
|
94
96
|
|
|
95
97
|
clustering:
|
|
96
98
|
nodeName: flair
|
|
@@ -108,6 +110,7 @@ logging:
|
|
|
108
110
|
| `HDB_ADMIN_PASSWORD` | Bootstrap password for the embedded Harper. After first start, the persisted user record is the source of truth. | Set at install time. See [secrets-and-keys.md](secrets-and-keys.md) for rotation. |
|
|
109
111
|
| `FLAIR_KEY_PASSPHRASE` | Passphrase for AES-256-GCM encryption of federation private-key seeds. | Set explicitly for production federation deployments. |
|
|
110
112
|
| `FLAIR_URL` | Override the Flair base URL for CLI commands (points to a remote instance). | When connecting from a different machine. |
|
|
113
|
+
| `FLAIR_HTTP_BIND` | HTTP API bind host. Resolution order: `flair init --http-bind` > this variable > top-level `httpBind` in `~/.flair/config.yaml` > `127.0.0.1`. Only `127.0.0.1` or a wildcard (`0.0.0.0` / `::`) is accepted. | When the HTTP API must be reachable off-host; prefer recording it once with `flair init --http-bind 0.0.0.0`. See [deployment.md](deployment.md#direct-network-access). |
|
|
111
114
|
| `FLAIR_EMBED_THREADS` | CPU threads for in-process embedding. Default is `max(1, availableParallelism() − 1)` — host-aware, one core left for Harper. | Pin a positive integer on a dedicated ingest host, or when the default leaves cores idle / oversubscribed. See [deployment.md](deployment.md#performance-related-environment-variables). |
|
|
112
115
|
| `FLAIR_EMBED_GPU_LAYERS` | GPU layers to offload. Unset derives Metal (`99`) on Apple Silicon with a usable Metal prebuilt, else CPU (`0`). Stated on `/Health`. | Pin CPU with `0` on a Metal Mac, or force a layer count. See [deployment.md](deployment.md#performance-related-environment-variables). |
|
|
113
116
|
| `FLAIR_HYBRID_RETRIEVAL` | Hybrid BM25 + vector retrieval (default on). | Set `false` to revert to HNSW-only. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpsdev-ai/flair",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.1",
|
|
4
4
|
"packageManager": "bun@1.3.10",
|
|
5
5
|
"description": "Identity, memory, and soul for AI agents. Cryptographic identity (Ed25519), semantic memory with local embeddings, and persistent personality — all in a single process.",
|
|
6
6
|
"type": "module",
|