@tpsdev-ai/flair 0.55.0 → 0.55.2
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/cli.js +191 -83
- package/dist/commands/doctor.js +172 -27
- package/dist/commands/federation.js +44 -57
- package/dist/commands/init.js +64 -62
- package/dist/commands/rem.js +29 -2
- package/dist/commands/upgrade.js +85 -60
- package/dist/doctor-client.js +336 -138
- package/dist/hook-install.js +359 -176
- package/dist/install/clients.js +907 -208
- package/dist/lib/config-critical-section.js +557 -0
- package/dist/lib/doctor-run.js +107 -27
- package/dist/lib/embed-gpu-doctor.js +40 -7
- package/dist/lib/launchd-repair.js +103 -0
- package/dist/lib/owned-pins.js +255 -81
- package/dist/lib/pin-write-guard.js +87 -0
- package/dist/lib/settings-bytes.js +85 -0
- package/dist/lib/upgrade-plain-tree.js +293 -48
- package/dist/lib/upgrade-status.js +164 -0
- package/dist/lib/wiring-spec.js +238 -0
- package/dist/rem/promote-policy.js +102 -0
- package/dist/resources/MemoryReflect.js +10 -0
- package/dist/resources/auto-promote-lib.js +56 -0
- package/dist/resources/health.js +26 -0
- package/dist/resources/memory-reflect-lib.js +199 -6
- package/dist/resources/migrations/progress.js +17 -0
- package/dist/resources/migrations/runner.js +46 -27
- package/dist/resources/migrations/status.js +2 -1
- package/dist/src/rem/promote-policy.js +102 -0
- package/docs/deployment.md +38 -5
- package/docs/federation.md +19 -0
- package/docs/releasing.md +66 -22
- package/docs/standalone-local.md +7 -4
- package/package.json +3 -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.2",
|
|
3
|
+
"commit": "317166c7daa24f519a43dce78571acdf36532ced",
|
|
4
|
+
"builtAt": "2026-09-23T19:19:42.752Z",
|
|
5
5
|
"builder": "tsc"
|
|
6
6
|
}
|
package/dist/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ import { readInstalledHarperVersion, writeEngineVersionStamp, checkEngineVersion
|
|
|
18
18
|
import { checkServerHandshake, formatHandshakeNudge, invalidateHandshakeCache } from "./version-handshake.js";
|
|
19
19
|
import { fleetSweepShouldAbort, } from "./fleet-verify.js";
|
|
20
20
|
import { detectClients } from "./install/clients.js";
|
|
21
|
-
import { flairCliVersion, mcpServerSpec
|
|
21
|
+
import { flairCliVersion, mcpServerSpec } from "./lib/mcp-spec.js";
|
|
22
22
|
import { harperPortValue } from "./lib/harper-port-value.js";
|
|
23
23
|
import { httpBind, httpCorsAccessList, preserveHttpPortValue, preserveSecurePort, qualifySecureBindValue, DEFAULT_HTTP_BIND_HOST, } from "./lib/http-bind.js";
|
|
24
24
|
import { isNodeKeyId, partitionKeyIds, } from "./doctor-client.js";
|
|
@@ -28,10 +28,11 @@ import { resolveSigningIdentity, emitSigningIdentityDebug, } from "./lib/signing
|
|
|
28
28
|
import { entityFormatHint, parseEntitiesCsv } from "./lib/entity-vocab-cli.js";
|
|
29
29
|
import { escapeXml, unescapeXml } from "./lib/xml-escape.js";
|
|
30
30
|
import { assessLaunchdManagement, diagnoseLaunchdPlistPaths, isDetached, pickInstancePid, plistCarriesInlineAdminPassword, readLaunchctlJobState, readPlistProgramRefs, LAUNCHCTL_QUERY_TIMEOUT_MS, } from "./lib/launchd-management.js";
|
|
31
|
-
import { classifyPlist, planLaunchdRepair, mapRepairThrow,
|
|
31
|
+
import { classifyPlist, planLaunchdRepair, mapRepairThrow, decideAdoptStopWithWait, verifyAdoptServingWithWait, } from "./lib/launchd-repair.js";
|
|
32
32
|
import { stabilizeMqttNetworkKeyOrder } from "./lib/stabilize-mqtt-network.js";
|
|
33
33
|
import { detectOpsApiAllInterfacesBind } from "./lib/ops-api-bind.js";
|
|
34
34
|
import { applyUpgradeHookConsent, runDoctorChecks, } from "./lib/doctor-run.js";
|
|
35
|
+
import { classifyInstalledVersion, shouldPrintUpgradeLine, upgradeStatusSuffix } from "./lib/upgrade-status.js";
|
|
35
36
|
import { classifyDaemonState, verifyIdentity, parseSidecarJson, classifyHealthProbe, classifyPortOwner, classifyInstanceMatch, shouldAdoptMissingSidecar, parseNullSeparatedEnviron, extractRootPath, } from "./lib/daemon-liveness.js";
|
|
36
37
|
import { readProcessStartTimeMs } from "./lib/process-start-time.js";
|
|
37
38
|
import { bindCli as bindFederationCli, register as registerFederation, signRequestBody, parseTokenFromFile, runFederationSyncOnce, persistLocalPeerLastSyncAt, runFederationWatch, federationStatusUrlSetting, describeFederationStatusFetchFailed, isFederationStatusConnectFailure, rewriteFederationStatusFetchFailed, isFederationStatusAuthFailure, isFederationStatusAuthRemedy, } from "./commands/federation.js";
|
|
@@ -2350,6 +2351,140 @@ function opsAuth401Hint(adminUser) {
|
|
|
2350
2351
|
* or hardened instance. Hardening the ops-API loopback posture is tracked in
|
|
2351
2352
|
* flair#654.
|
|
2352
2353
|
*/
|
|
2354
|
+
// ─── flair#1790: the ops-API seed names its failure and retries once ──────────
|
|
2355
|
+
//
|
|
2356
|
+
// Both seed helpers below insert through the operations API with a single bare
|
|
2357
|
+
// `fetch` under a 10 s client timeout. On a timeout that surfaced ONLY as an
|
|
2358
|
+
// undici `DOMException [TimeoutError]` stack — no operation, no target, no
|
|
2359
|
+
// timeout value — so a post-restart `flair init` that timed out produced an
|
|
2360
|
+
// unactionable failure and no daemon evidence.
|
|
2361
|
+
//
|
|
2362
|
+
// The wrap here names the failure and retries the insert ONCE, on the CLIENT
|
|
2363
|
+
// timeout only. The retry is safe because the insert is idempotent: a duplicate
|
|
2364
|
+
// answers 409 (or a "duplicate"/"already exists" body) and is treated as
|
|
2365
|
+
// success below, so a retried insert cannot double-apply. What is NOT retried:
|
|
2366
|
+
// an auth failure (401 keeps its existing hint) or any other HTTP or network
|
|
2367
|
+
// error — those are answers, not stalls.
|
|
2368
|
+
//
|
|
2369
|
+
// This is diagnosis + ergonomics, NOT a claim about WHY a seed timed out; the
|
|
2370
|
+
// mechanism is unknown (flair#1790).
|
|
2371
|
+
const OPS_AGENT_SEED_TIMEOUT_MS = 10_000;
|
|
2372
|
+
const OPS_AGENT_SEED_ATTEMPTS = 2;
|
|
2373
|
+
/**
|
|
2374
|
+
* A target URL safe to print: userinfo and query/fragment stripped. The seed
|
|
2375
|
+
* target is operator-supplied (`--target` / `--ops-target`), so it may carry
|
|
2376
|
+
* credentials or query values that must never reach init output or a log line.
|
|
2377
|
+
*/
|
|
2378
|
+
function sanitizeOpsTargetUrl(raw) {
|
|
2379
|
+
try {
|
|
2380
|
+
const u = new URL(raw);
|
|
2381
|
+
u.username = "";
|
|
2382
|
+
u.password = "";
|
|
2383
|
+
u.search = "";
|
|
2384
|
+
u.hash = "";
|
|
2385
|
+
return u.toString();
|
|
2386
|
+
}
|
|
2387
|
+
catch {
|
|
2388
|
+
return raw.replace(/\/\/[^/@]*@/, "//").split(/[?#]/)[0];
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* True only for the abort our OWN AbortSignal.timeout raises (never a server
|
|
2393
|
+
* answer, never a foreign abort). Checked by name AND by the attempt's own
|
|
2394
|
+
* signal being aborted (flair#1790 review S1), so a stray TimeoutError from some
|
|
2395
|
+
* other AbortSignal is not retried as if it were ours.
|
|
2396
|
+
*/
|
|
2397
|
+
function isOwnedSeedTimeout(err, signal) {
|
|
2398
|
+
const name = err?.name;
|
|
2399
|
+
if (name !== "TimeoutError" && name !== "AbortError")
|
|
2400
|
+
return false;
|
|
2401
|
+
return signal ? signal.aborted : true;
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* The concise both-attempts-timed-out CLI error. `flairFriendly` makes runCli
|
|
2405
|
+
* print just this sentence (no undici/Node stack); the cause stays attached for
|
|
2406
|
+
* `--verbose`/diagnostics and is never printed by the default handler.
|
|
2407
|
+
*/
|
|
2408
|
+
function opsSeedBothAttemptsTimedOut(req, sanitizedUrl, cause) {
|
|
2409
|
+
const message = `Flair could not seed ${req.noun} '${req.id}': Operations API insert into ${req.tableName} at ` +
|
|
2410
|
+
`${sanitizedUrl} timed out on both attempts (${OPS_AGENT_SEED_TIMEOUT_MS} ms per attempt). ` +
|
|
2411
|
+
`Inspect the target daemon's logs, then rerun the same init command.\n` +
|
|
2412
|
+
`A timed-out insert may still complete; retrying the same ${req.noun} ID is supported.`;
|
|
2413
|
+
const err = new Error(message, { cause });
|
|
2414
|
+
err.flairFriendly = true;
|
|
2415
|
+
return err;
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* POST one ops-API insert, retrying once on the client timeout. The response
|
|
2419
|
+
* body is read under the SAME attempt's signal, so each attempt's fresh
|
|
2420
|
+
* deadline covers the body read too. Returns normally on success or on the
|
|
2421
|
+
* idempotent duplicate path; throws a named error otherwise.
|
|
2422
|
+
*/
|
|
2423
|
+
async function opsSeedInsertWithRetry(req) {
|
|
2424
|
+
const sanitizedUrl = sanitizeOpsTargetUrl(req.url);
|
|
2425
|
+
const headers = {
|
|
2426
|
+
"Content-Type": "application/json",
|
|
2427
|
+
...(req.auth ? { Authorization: `Basic ${req.auth}` } : {}),
|
|
2428
|
+
};
|
|
2429
|
+
const overallStart = Date.now();
|
|
2430
|
+
for (let attempt = 1; attempt <= OPS_AGENT_SEED_ATTEMPTS; attempt++) {
|
|
2431
|
+
const attemptStart = Date.now();
|
|
2432
|
+
// A FRESH deadline per attempt; the response-body read runs under the SAME
|
|
2433
|
+
// signal, so it too is bounded by this attempt's timeout.
|
|
2434
|
+
const signal = AbortSignal.timeout(OPS_AGENT_SEED_TIMEOUT_MS);
|
|
2435
|
+
try {
|
|
2436
|
+
const res = await fetch(req.url, {
|
|
2437
|
+
method: "POST",
|
|
2438
|
+
headers,
|
|
2439
|
+
body: JSON.stringify(req.body),
|
|
2440
|
+
signal,
|
|
2441
|
+
});
|
|
2442
|
+
let text;
|
|
2443
|
+
try {
|
|
2444
|
+
text = await res.text();
|
|
2445
|
+
}
|
|
2446
|
+
catch (e) {
|
|
2447
|
+
// flair#1790 follow-up (A): an owned BODY-READ timeout is retryable ONLY
|
|
2448
|
+
// for an OK response — a 2xx whose body stalled is OUR stall, so retry
|
|
2449
|
+
// it. For a NON-OK response the STATUS is the answer: use empty text and
|
|
2450
|
+
// fall through to the status handling (401 → auth error first, then
|
|
2451
|
+
// 409/marker → duplicate) instead of retrying away the real error. A 401
|
|
2452
|
+
// whose body read stalls must stay the auth error, not become a
|
|
2453
|
+
// bogus "timed out on both attempts".
|
|
2454
|
+
if (res.ok && isOwnedSeedTimeout(e, signal))
|
|
2455
|
+
throw e;
|
|
2456
|
+
text = "";
|
|
2457
|
+
}
|
|
2458
|
+
// flair#1790 review C2: 401 FIRST. An auth failure must never be masked by
|
|
2459
|
+
// a body that happens to carry a "duplicate"/"already exists" marker.
|
|
2460
|
+
if (res.status === 401)
|
|
2461
|
+
throw new Error(req.auth401Message(text));
|
|
2462
|
+
// THEN the idempotent duplicate path: an unconditional 409, then the
|
|
2463
|
+
// marker match for the remaining non-OK shapes.
|
|
2464
|
+
const duplicate = res.status === 409 || text.includes("duplicate") || text.includes("already exists");
|
|
2465
|
+
if (!res.ok && !duplicate)
|
|
2466
|
+
throw new Error(req.httpErrorMessage(res.status, text));
|
|
2467
|
+
// Success, or the idempotent duplicate path.
|
|
2468
|
+
const outcome = res.ok ? "inserted" : "already exists";
|
|
2469
|
+
if (attempt > 1) {
|
|
2470
|
+
console.log(`${req.kind} seed attempt ${attempt} completed in ${Date.now() - attemptStart} ms (${outcome}); ` +
|
|
2471
|
+
`total ${Date.now() - overallStart} ms.`);
|
|
2472
|
+
}
|
|
2473
|
+
return;
|
|
2474
|
+
}
|
|
2475
|
+
catch (err) {
|
|
2476
|
+
// Auth / HTTP / other network errors are answers, not stalls: never retried.
|
|
2477
|
+
if (!isOwnedSeedTimeout(err, signal))
|
|
2478
|
+
throw err;
|
|
2479
|
+
if (attempt < OPS_AGENT_SEED_ATTEMPTS) {
|
|
2480
|
+
console.warn(`${req.kind} seed attempt ${attempt} timed out after ${OPS_AGENT_SEED_TIMEOUT_MS} ms; retrying once. ` +
|
|
2481
|
+
`Target: ${sanitizedUrl} (${req.noun} '${req.id}').`);
|
|
2482
|
+
continue;
|
|
2483
|
+
}
|
|
2484
|
+
throw opsSeedBothAttemptsTimedOut(req, sanitizedUrl, err);
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2353
2488
|
export async function seedAgentViaOpsApi(opsPortOrUrl, agentId, pubKeyB64url, adminUser, adminPass) {
|
|
2354
2489
|
const url = typeof opsPortOrUrl === "number"
|
|
2355
2490
|
? `http://127.0.0.1:${opsPortOrUrl}/`
|
|
@@ -2381,21 +2516,17 @@ export async function seedAgentViaOpsApi(opsPortOrUrl, agentId, pubKeyB64url, ad
|
|
|
2381
2516
|
updatedAt: now,
|
|
2382
2517
|
}],
|
|
2383
2518
|
};
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
body
|
|
2388
|
-
|
|
2519
|
+
await opsSeedInsertWithRetry({
|
|
2520
|
+
url,
|
|
2521
|
+
auth,
|
|
2522
|
+
body,
|
|
2523
|
+
kind: "Agent",
|
|
2524
|
+
noun: "agent",
|
|
2525
|
+
tableName: "flair.Agent",
|
|
2526
|
+
id: agentId,
|
|
2527
|
+
auth401Message: (text) => `Operations API insert failed (401): ${text}${opsAuth401Hint(auth === undefined ? undefined : adminUser)}`,
|
|
2528
|
+
httpErrorMessage: (status, text) => `Operations API insert failed (${status}): ${text}`,
|
|
2389
2529
|
});
|
|
2390
|
-
if (!res.ok) {
|
|
2391
|
-
const text = await res.text().catch(() => "");
|
|
2392
|
-
if (res.status === 409 || text.includes("duplicate") || text.includes("already exists"))
|
|
2393
|
-
return;
|
|
2394
|
-
if (res.status === 401) {
|
|
2395
|
-
throw new Error(`Operations API insert failed (401): ${text}${opsAuth401Hint(auth === undefined ? undefined : adminUser)}`);
|
|
2396
|
-
}
|
|
2397
|
-
throw new Error(`Operations API insert failed (${res.status}): ${text}`);
|
|
2398
|
-
}
|
|
2399
2530
|
}
|
|
2400
2531
|
// NOTE: agent records are seeded exclusively via the Harper operations API
|
|
2401
2532
|
// (seedAgentViaOpsApi above). A former seedAgentViaRestApi() helper POSTed the
|
|
@@ -2435,21 +2566,17 @@ export async function seedFederationInstanceViaOpsApi(opsPortOrUrl, instanceId,
|
|
|
2435
2566
|
updatedAt: now,
|
|
2436
2567
|
}],
|
|
2437
2568
|
};
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
body
|
|
2442
|
-
|
|
2569
|
+
await opsSeedInsertWithRetry({
|
|
2570
|
+
url,
|
|
2571
|
+
auth,
|
|
2572
|
+
body,
|
|
2573
|
+
kind: "Federation Instance",
|
|
2574
|
+
noun: "federation instance",
|
|
2575
|
+
tableName: "flair.Instance",
|
|
2576
|
+
id: instanceId,
|
|
2577
|
+
auth401Message: (text) => `Federation Instance insert via ops API failed (401): ${text}${opsAuth401Hint(auth === undefined ? undefined : adminUser)}`,
|
|
2578
|
+
httpErrorMessage: (status, text) => `Federation Instance insert via ops API failed (${status}): ${text}`,
|
|
2443
2579
|
});
|
|
2444
|
-
if (!res.ok) {
|
|
2445
|
-
const text = await res.text().catch(() => "");
|
|
2446
|
-
if (res.status === 409 || text.includes("duplicate") || text.includes("already exists"))
|
|
2447
|
-
return;
|
|
2448
|
-
if (res.status === 401) {
|
|
2449
|
-
throw new Error(`Federation Instance insert via ops API failed (401): ${text}${opsAuth401Hint(auth === undefined ? undefined : adminUser)}`);
|
|
2450
|
-
}
|
|
2451
|
-
throw new Error(`Federation Instance insert via ops API failed (${res.status}): ${text}`);
|
|
2452
|
-
}
|
|
2453
2580
|
}
|
|
2454
2581
|
// ─── Provision Flair on Harper Fabric ──────────────────────────────────────
|
|
2455
2582
|
//
|
|
@@ -2991,43 +3118,13 @@ export function probeOpenclawPluginVersion(extensionName) {
|
|
|
2991
3118
|
}
|
|
2992
3119
|
}
|
|
2993
3120
|
/**
|
|
2994
|
-
*
|
|
2995
|
-
*
|
|
2996
|
-
*
|
|
2997
|
-
* (
|
|
3121
|
+
* Per-package status for the `flair upgrade` listing — the state set, the
|
|
3122
|
+
* direction-aware classifier and the renderers live ONCE in
|
|
3123
|
+
* src/lib/upgrade-status.ts and are re-exported here so existing importers keep
|
|
3124
|
+
* working (flair#1778). src/commands/upgrade.ts cannot import this file, so the
|
|
3125
|
+
* shared definition has to live outside both.
|
|
2998
3126
|
*/
|
|
2999
|
-
export
|
|
3000
|
-
if (status === "optional" && !showAll)
|
|
3001
|
-
return false;
|
|
3002
|
-
return true;
|
|
3003
|
-
}
|
|
3004
|
-
/**
|
|
3005
|
-
* Returns the human-readable suffix for a package status line in
|
|
3006
|
-
* `flair upgrade` / `flair upgrade --check` output.
|
|
3007
|
-
*
|
|
3008
|
-
* flair-mcp is zero-install via npx — its suffix must never suggest a
|
|
3009
|
-
* global install (flair#1168).
|
|
3010
|
-
*/
|
|
3011
|
-
export function upgradeStatusSuffix(name, status) {
|
|
3012
|
-
if (status === "current")
|
|
3013
|
-
return " (current)";
|
|
3014
|
-
if (status === "missing") {
|
|
3015
|
-
return name === FLAIR_MCP_PACKAGE
|
|
3016
|
-
? " (zero-install via npx — run: flair doctor --fix)"
|
|
3017
|
-
: " (run: npm install -g)";
|
|
3018
|
-
}
|
|
3019
|
-
if (status === "optional")
|
|
3020
|
-
return " (install via: openclaw plugins install @tpsdev-ai/openclaw-flair)";
|
|
3021
|
-
// flair-mcp is refreshed by re-pinning its wiring, never `npm install -g` —
|
|
3022
|
-
// a global bin does nothing for an `npx -y -p @tpsdev-ai/flair-mcp`
|
|
3023
|
-
// invocation (flair#1208). The re-pin is `flair upgrade`'s own job (the
|
|
3024
|
-
// #1135/#1167 pin refresh) — never advise `doctor --fix` for it
|
|
3025
|
-
// (flair#1324).
|
|
3026
|
-
if (status === "outdated" && name === FLAIR_MCP_PACKAGE) {
|
|
3027
|
-
return " (npx-wired — flair upgrade refreshes the pin)";
|
|
3028
|
-
}
|
|
3029
|
-
return "";
|
|
3030
|
-
}
|
|
3127
|
+
export { shouldPrintUpgradeLine, upgradeStatusSuffix };
|
|
3031
3128
|
/**
|
|
3032
3129
|
* Resolve the `flair upgrade` finding for flair-mcp from its ACTUAL wiring,
|
|
3033
3130
|
* not a global-install probe (flair#1208).
|
|
@@ -3042,7 +3139,8 @@ export function upgradeStatusSuffix(name, status) {
|
|
|
3042
3139
|
* 2. Not wired anywhere — genuinely missing; the remedy (upgradeStatusSuffix)
|
|
3043
3140
|
* is `flair doctor --fix`, never `npm install -g`.
|
|
3044
3141
|
* 3. Wired with a concrete pin — that pin IS the installed version
|
|
3045
|
-
* (current
|
|
3142
|
+
* (current / ahead / outdated by semver direction; outdated → re-pin via
|
|
3143
|
+
* doctor, ahead never re-pins down — flair#1778).
|
|
3046
3144
|
* 4. Wired but unpinned (a bare npx spec / a pre-#1143 SessionStart hook) —
|
|
3047
3145
|
* `npx -y` re-resolves latest every session, so the effective version IS
|
|
3048
3146
|
* latest → current.
|
|
@@ -3050,7 +3148,7 @@ export function upgradeStatusSuffix(name, status) {
|
|
|
3050
3148
|
export function resolveFlairMcpFinding(globalProbe, latest, wiring) {
|
|
3051
3149
|
// 1. Legacy global install.
|
|
3052
3150
|
if (globalProbe !== null) {
|
|
3053
|
-
return { installed: globalProbe, status: globalProbe
|
|
3151
|
+
return { installed: globalProbe, status: classifyInstalledVersion(globalProbe, latest) };
|
|
3054
3152
|
}
|
|
3055
3153
|
// 2. Not wired anywhere.
|
|
3056
3154
|
if (!wiring.wired) {
|
|
@@ -3060,7 +3158,7 @@ export function resolveFlairMcpFinding(globalProbe, latest, wiring) {
|
|
|
3060
3158
|
if (wiring.pinnedVersion) {
|
|
3061
3159
|
return {
|
|
3062
3160
|
installed: wiring.pinnedVersion,
|
|
3063
|
-
status: wiring.pinnedVersion
|
|
3161
|
+
status: classifyInstalledVersion(wiring.pinnedVersion, latest),
|
|
3064
3162
|
};
|
|
3065
3163
|
}
|
|
3066
3164
|
// 4. Wired but unpinned — npx resolves latest on every session.
|
|
@@ -3688,7 +3786,6 @@ bindUpgradeCli({
|
|
|
3688
3786
|
probeLibVersion,
|
|
3689
3787
|
probeOpenclawPluginVersion,
|
|
3690
3788
|
relativeTime,
|
|
3691
|
-
resolveAgentIdOrEnv,
|
|
3692
3789
|
resolveFabricCredentials,
|
|
3693
3790
|
resolveFlairMcpFinding,
|
|
3694
3791
|
resolveHttpPort,
|
|
@@ -4763,16 +4860,21 @@ async function repairLaunchdManagement(dataDir, port) {
|
|
|
4763
4860
|
// launchd's reported pid for this label.
|
|
4764
4861
|
if (plan.kind === "adopt") {
|
|
4765
4862
|
const label = after.label ?? resolveLaunchdLabel(dataDir).label;
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4863
|
+
// flair#1827: poll — the launchd-started Harper may not have written
|
|
4864
|
+
// hdb.pid or bound the port yet. Wait for it to serve (and for the
|
|
4865
|
+
// pre-adopt process to be gone), THEN prove identity with
|
|
4866
|
+
// verifyAdoptServing UNCHANGED on the final observation.
|
|
4867
|
+
const waited = await verifyAdoptServingWithWait({
|
|
4868
|
+
observe: () => ({
|
|
4869
|
+
directPid,
|
|
4870
|
+
managedPid: readLaunchctlJobState(label, realLaunchctlLister).pid,
|
|
4871
|
+
servingPid: resolveInstanceServingPid(dataDir, port),
|
|
4872
|
+
directPidAlive: directPid !== null && isProcessAlive(directPid),
|
|
4873
|
+
}),
|
|
4874
|
+
deadlineMs: STARTUP_TIMEOUT_MS,
|
|
4773
4875
|
});
|
|
4774
|
-
if (proof) {
|
|
4775
|
-
return { kind: "failed", detail: proof.detail, remedy: ["flair stop", "flair doctor --fix"] };
|
|
4876
|
+
if (waited.proof) {
|
|
4877
|
+
return { kind: "failed", detail: waited.proof.detail, remedy: ["flair stop", "flair doctor --fix"] };
|
|
4776
4878
|
}
|
|
4777
4879
|
}
|
|
4778
4880
|
// flair#1701: the launchd bounce (adopt and regenerate) is a first
|
|
@@ -4821,10 +4923,16 @@ async function stopDirectProcessForAdopt(port, dataDir) {
|
|
|
4821
4923
|
}
|
|
4822
4924
|
catch { /* best-effort — the port check below surfaces the real problem */ }
|
|
4823
4925
|
}
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4926
|
+
// flair#1827: poll the post-stop health until the port is provably free — a
|
|
4927
|
+
// single observation that caught the listener mid-release flaked with "port
|
|
4928
|
+
// not confirmed free". decideAdoptStop is UNCHANGED; it decides on the final
|
|
4929
|
+
// observation, and a timeout names the wait and the last probe.
|
|
4930
|
+
const decision = await decideAdoptStopWithWait(state, {
|
|
4931
|
+
observe: () => probeHealth(port),
|
|
4932
|
+
deadlineMs: STARTUP_TIMEOUT_MS,
|
|
4933
|
+
});
|
|
4934
|
+
if (decision.decision !== "proceed")
|
|
4935
|
+
return decision.decision;
|
|
4828
4936
|
// Belt-and-suspenders: lsof confirms no TCP listener remains before the
|
|
4829
4937
|
// caller loads the plist. probeHealth "refused" (ECONNREFUSED) already means
|
|
4830
4938
|
// nothing is listening, but a port that is BOUND yet refuses connections
|