@indigoai-us/hq-cli 5.345.251 → 5.345.252
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/CHANGELOG.md +112 -0
- package/assets/scaffold/core/scripts/hq-session.sh +9 -0
- package/contracts/host-canary-release.json +9 -3
- package/dist/command-catalog.generated.d.ts +121 -1
- package/dist/command-catalog.generated.js +148 -1
- package/dist/commands/bot.js +7 -2
- package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
- package/dist/commands/core-hq-session-binding.d.ts +140 -0
- package/dist/commands/core-hq-session-binding.js +363 -0
- package/dist/commands/core-hq-session-native.d.ts +23 -0
- package/dist/commands/core-hq-session-native.js +59 -9
- package/dist/commands/core-stop-autosave.js +1 -1
- package/dist/commands/core.js +10 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +42 -5
- package/dist/commands/files.js +1 -1
- package/dist/commands/install-global.js +4 -2
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +2 -0
- package/dist/commands/ontology-graph.js +33 -0
- package/dist/commands/report.js +35 -2
- package/dist/commands/storage-gate.js +1 -1
- package/dist/commands/vault-retention-flag.js +2 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +48 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +35 -0
- package/dist/lib/bot/fleet-cron.js +54 -12
- package/dist/lib/bot/fleet-local.d.ts +18 -0
- package/dist/lib/bot/fleet-local.js +51 -5
- package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
- package/dist/lib/bot/signals-engine-flag.js +1 -1
- package/dist/lib/cli-invite-nudge.js +1 -1
- package/dist/lib/client-version.d.ts +2 -0
- package/dist/lib/client-version.js +24 -0
- package/dist/lib/company-flag-gate.d.ts +30 -0
- package/dist/lib/company-flag-gate.js +104 -0
- package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
- package/dist/lib/daemon/flag.js +2 -1
- package/dist/lib/daemon/legacy-journal-gate.js +3 -1
- package/dist/lib/daemon/shared-flag-reads.js +1 -1
- package/dist/lib/doctor/checks/host-core.js +22 -4
- package/dist/lib/doctor/checks/jq.d.ts +27 -6
- package/dist/lib/doctor/checks/jq.js +46 -8
- package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
- package/dist/lib/flag-client-gate-headers.d.ts +38 -0
- package/dist/lib/flag-client-gate-headers.js +62 -0
- package/dist/lib/flag-client-headers.d.ts +15 -0
- package/dist/lib/flag-client-headers.js +25 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/flag-registry-worker.js +35 -0
- package/dist/lib/flag-registry.d.ts +1 -20
- package/dist/lib/flag-registry.js +5 -81
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
- package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
- package/dist/lib/hook-engine/coverage.d.ts +50 -1
- package/dist/lib/hook-engine/coverage.js +111 -7
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
- package/dist/lib/hot-channels/signal-changes.js +683 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
- package/dist/lib/hot-channels/signals-pass.js +232 -12
- package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
- package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
- package/dist/lib/lanes/registry-flag.js +2 -1
- package/dist/lib/lanes/spawn.js +11 -1
- package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
- package/dist/lib/mesh/live/binding-intent.js +201 -0
- package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
- package/dist/lib/mesh/live/binding-receipt.js +365 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
- package/dist/lib/mesh/live/daemon/install.js +2 -1
- package/dist/lib/mesh/live/daemon/presence.js +9 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
- package/dist/lib/mesh/live/daemon/run.js +33 -1
- package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
- package/dist/lib/ontology-graph/lineage/index.js +1027 -0
- package/dist/lib/ontology-graph/model/index.d.ts +54 -0
- package/dist/lib/ontology-graph/model/index.js +112 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +75 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +166 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +6 -0
- package/dist/lib/ontology-graph/model/pass.js +9 -2
- package/dist/lib/ontology-graph/model/pending-items.d.ts +8 -0
- package/dist/lib/ontology-graph/model/pending-items.js +24 -1
- package/dist/lib/ontology-graph/model/step.d.ts +1 -1
- package/dist/lib/ontology-graph/model/tasks.d.ts +11 -3
- package/dist/lib/ontology-graph/model/tasks.js +20 -7
- package/dist/lib/ontology-graph/read/brief.js +41 -6
- package/dist/lib/ontology-graph/read/index.d.ts +4 -0
- package/dist/lib/ontology-graph/read/index.js +173 -29
- package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
- package/dist/lib/ontology-graph/read/lineage.js +262 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
- package/dist/lib/ontology-graph/replay/engine.js +213 -8
- package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
- package/dist/lib/ontology-graph/replay/extractors.js +25 -1
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
- package/dist/lib/ontology-graph/replay/index.js +9 -3
- package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
- package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
- package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
- package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +1 -0
- package/dist/lib/ontology-graph/schema/index.js +1 -0
- package/dist/lib/ontology-graph/setup/index.js +13 -3
- package/dist/lib/search-index/index.d.ts +33 -1
- package/dist/lib/search-index/index.js +180 -25
- package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
- package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
- package/dist/lib/signals/adapters-catalog.js +1 -1
- package/dist/lib/sync-core/engine-holds.d.ts +1 -0
- package/dist/lib/sync-core/engine-holds.js +26 -0
- package/dist/lib/sync-core/engine-home.d.ts +3 -0
- package/dist/lib/sync-core/engine-home.js +41 -1
- package/dist/lib/sync-core/flag.js +2 -1
- package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
- package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
- package/dist/lib/sync-core/legacy-journal-export.js +120 -55
- package/dist/lib/sync-core/reconcile.d.ts +2 -1
- package/dist/lib/sync-core/reconcile.js +30 -5
- package/dist/lib/sync-invalid-entity-warning.js +2 -1
- package/dist/lib/windows/install-followup.d.ts +41 -0
- package/dist/lib/windows/install-followup.js +87 -0
- package/dist/lib/windows/jq.d.ts +59 -0
- package/dist/lib/windows/jq.js +154 -3
- package/dist/lib/windows/user-path.d.ts +5 -0
- package/dist/lib/windows/user-path.js +1 -1
- package/dist/lib/work-context/auto-bind.d.ts +12 -0
- package/dist/lib/work-context/auto-bind.js +49 -3
- package/dist/lib/work-context/organize.d.ts +4 -2
- package/dist/lib/work-context/organize.js +18 -8
- package/dist/lib/work-context/reconcile.js +16 -1
- package/dist/main.js +12 -1
- package/dist/utils/client-health-contract.d.ts +30 -0
- package/dist/utils/client-health-contract.js +111 -0
- package/dist/utils/client-health.d.ts +5 -2
- package/dist/utils/client-health.js +74 -5
- package/dist/utils/exclusive-lock.d.ts +5 -1
- package/dist/utils/exclusive-lock.js +9 -2
- package/dist/utils/host-registration.d.ts +7 -0
- package/dist/utils/host-registration.js +10 -1
- package/dist/utils/pid.d.ts +31 -0
- package/dist/utils/pid.js +65 -0
- package/dist/utils/resident-package-preload.js +12 -4
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/package.json +8 -8
- package/scripts/install-hook-engine.mjs +5 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The statuses that say a decision no longer stands.
|
|
3
|
+
*
|
|
4
|
+
* One list, used by the rule that writes decision lineage from signals
|
|
5
|
+
* (replay/signal-changes.ts), by the readers (read/lineage.ts) and by the
|
|
6
|
+
* model pass (model/pass.ts), so the three agree on what "ended" means:
|
|
7
|
+
*
|
|
8
|
+
* - `superseded`, `reversed`, `withdrawn`: what the rule writes;
|
|
9
|
+
* - `replaced`: the word a person or a record may use for the same thing.
|
|
10
|
+
*
|
|
11
|
+
* A person or a record that writes one of these on a decision agrees with a
|
|
12
|
+
* link that says the decision was replaced. Any other status (`decided`,
|
|
13
|
+
* `active`, `accepted`, ...) says the decision stands, and disagrees with it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ENDED_DECISION_STATUSES: ReadonlySet<string>;
|
|
16
|
+
/** True for a status value that says the decision no longer stands. Letter case and outer spaces do not matter. */
|
|
17
|
+
export declare function endsDecision(status: string): boolean;
|
|
18
|
+
//# sourceMappingURL=decision-status.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The statuses that say a decision no longer stands.
|
|
3
|
+
*
|
|
4
|
+
* One list, used by the rule that writes decision lineage from signals
|
|
5
|
+
* (replay/signal-changes.ts), by the readers (read/lineage.ts) and by the
|
|
6
|
+
* model pass (model/pass.ts), so the three agree on what "ended" means:
|
|
7
|
+
*
|
|
8
|
+
* - `superseded`, `reversed`, `withdrawn`: what the rule writes;
|
|
9
|
+
* - `replaced`: the word a person or a record may use for the same thing.
|
|
10
|
+
*
|
|
11
|
+
* A person or a record that writes one of these on a decision agrees with a
|
|
12
|
+
* link that says the decision was replaced. Any other status (`decided`,
|
|
13
|
+
* `active`, `accepted`, ...) says the decision stands, and disagrees with it.
|
|
14
|
+
*/
|
|
15
|
+
export const ENDED_DECISION_STATUSES = new Set(["superseded", "reversed", "withdrawn", "replaced"]);
|
|
16
|
+
/** True for a status value that says the decision no longer stands. Letter case and outer spaces do not matter. */
|
|
17
|
+
export function endsDecision(status) {
|
|
18
|
+
return ENDED_DECISION_STATUSES.has(status.trim().toLowerCase());
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=decision-status.js.map
|
|
@@ -9,4 +9,5 @@ export { SchemaError } from "./default-schema.js";
|
|
|
9
9
|
export { validateEntityUpsert, validateRow } from "./validate.js";
|
|
10
10
|
export { GUESS_CONFIDENCE_BELOW, GUESS_EMPLOYER_VERBS, GUESS_FIELDS, GUESS_HIERARCHY_VERBS, GUESS_OWNERSHIP_VERBS, GUESS_VERBS, dropUnverifiedGuesses, effectiveFacts, isUnverifiedGuess, inverseEdge, isOpen, isSingleValued, planSupersession, rowCoversDay, singleValueKey, } from "./authority.js";
|
|
11
11
|
export type { SupersessionPlan } from "./authority.js";
|
|
12
|
+
export { ENDED_DECISION_STATUSES, endsDecision } from "./decision-status.js";
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,5 @@ export { DEFAULT_SCHEMA, parseSchemaYaml, renderSchemaYaml } from "./default-sch
|
|
|
7
7
|
export { SchemaError } from "./default-schema.js";
|
|
8
8
|
export { validateEntityUpsert, validateRow } from "./validate.js";
|
|
9
9
|
export { GUESS_CONFIDENCE_BELOW, GUESS_EMPLOYER_VERBS, GUESS_FIELDS, GUESS_HIERARCHY_VERBS, GUESS_OWNERSHIP_VERBS, GUESS_VERBS, dropUnverifiedGuesses, effectiveFacts, isUnverifiedGuess, inverseEdge, isOpen, isSingleValued, planSupersession, rowCoversDay, singleValueKey, } from "./authority.js";
|
|
10
|
+
export { ENDED_DECISION_STATUSES, endsDecision } from "./decision-status.js";
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import * as fs from "node:fs";
|
|
21
21
|
import * as path from "node:path";
|
|
22
22
|
import yaml from "js-yaml";
|
|
23
|
-
import { MODEL_STATE_PATHS, ONTOLOGY_MODEL_ENV, ONTOLOGY_SETTINGS_FILE, estimateTokens, isOntologyModelName, peekPendingMarkers, readModelSetting, resolveModelStateDir } from "../model/index.js";
|
|
23
|
+
import { MODEL_STATE_PATHS, ONTOLOGY_MODEL_ENV, ONTOLOGY_SETTINGS_FILE, estimateTokens, isOntologyModelName, heldMarkerCounts, modelTasksLine, modelTasksNotes, peekPendingMarkers, readModelSetting, readModelTasks, resolveModelStateDir } from "../model/index.js";
|
|
24
24
|
import { DEFAULT_ONTOLOGY_MODEL } from "../model/runner.js";
|
|
25
25
|
import { graphExists } from "../read/graph-index.js";
|
|
26
26
|
import { READER_SETTING_RELATIVE, parseReaderSetting, readReaderSetting, readerSettingFile } from "../read/reader-setting.js";
|
|
@@ -411,7 +411,7 @@ function pendingLook(context, env) {
|
|
|
411
411
|
const kind = typeof marker.kind === "string" ? marker.kind : "other";
|
|
412
412
|
byKind[kind] = (byKind[kind] ?? 0) + 1;
|
|
413
413
|
}
|
|
414
|
-
return { items: markers.length, byKind };
|
|
414
|
+
return { items: markers.length, byKind, held: { ...heldMarkerCounts(markers, readModelTasks(context.companyRoot).tasks) } };
|
|
415
415
|
}
|
|
416
416
|
const number = (value) => value.toLocaleString("en-US");
|
|
417
417
|
/** `hq ontology status`: reader, model, graph, counts, pending model work, last update and brief, on one screen. Reads only. */
|
|
@@ -427,6 +427,9 @@ export async function statusCommand(context, options = {}) {
|
|
|
427
427
|
const cursor = usable ? readCursorLook(context.graphRoot) : null;
|
|
428
428
|
const brief = usable ? readBriefLook(context.graphRoot) : null;
|
|
429
429
|
const pending = usable ? pendingLook(context, env) : null;
|
|
430
|
+
// The effective `model_tasks` setting, read the way a run reads it. It is shown whether or not a run would call a
|
|
431
|
+
// model at all (`--no-model`), so a person can check the file before a run sends anything.
|
|
432
|
+
const tasks = readModelTasks(context.companyRoot);
|
|
430
433
|
const shownRoot = rel(context.hqRoot, context.graphRoot);
|
|
431
434
|
const next = [];
|
|
432
435
|
if (graph.state === "missing") {
|
|
@@ -439,7 +442,7 @@ export async function statusCommand(context, options = {}) {
|
|
|
439
442
|
else {
|
|
440
443
|
if (graph.state === "unstamped")
|
|
441
444
|
next.push(`stamp the folder with a build: hq ontology update --company ${context.company}`);
|
|
442
|
-
if (pending && pending.items > 0)
|
|
445
|
+
if (pending && pending.items - Object.values(pending.held).reduce((sum, count) => sum + count, 0) > 0)
|
|
443
446
|
next.push(`send pending model work: hq ontology update --company ${context.company} --follow-up`);
|
|
444
447
|
if (brief && !brief.present)
|
|
445
448
|
next.push(`write the brief: hq ontology brief --company ${context.company}`);
|
|
@@ -449,6 +452,9 @@ export async function statusCommand(context, options = {}) {
|
|
|
449
452
|
const lines = [`ontology status for ${context.company}`];
|
|
450
453
|
lines.push(`reader: ${reader}${setting.present ? "" : " (no setting; the default)"}${setting.present && setting.reader === "graph" && setting.company !== context.company ? ` (the setting says graph for ${setting.company === "" ? "no company" : setting.company})` : ""}`);
|
|
451
454
|
lines.push(`model: ${model.model} (${sourceWords(model, context.company)}; per machine, not synced)`);
|
|
455
|
+
lines.push(`tasks: ${modelTasksLine(tasks.tasks)} (${tasks.source === "default" ? "no model_tasks setting; the default" : tasks.source === "setting" ? `model_tasks in ${ONTOLOGY_SETTINGS_FILE}` : `${ONTOLOGY_SETTINGS_FILE} could not be read as written; the setting fails closed`})`);
|
|
456
|
+
for (const note of modelTasksNotes(tasks))
|
|
457
|
+
lines.push(` ${note}`);
|
|
452
458
|
lines.push(`graph: ${graph.present ? "present" : "missing"}, ${graph.detail} (${shownRoot})`);
|
|
453
459
|
if (counts) {
|
|
454
460
|
const byType = Object.entries(counts.entitiesByType)
|
|
@@ -464,6 +470,9 @@ export async function statusCommand(context, options = {}) {
|
|
|
464
470
|
.map(([kind, count]) => `${kind} ${number(count)}`)
|
|
465
471
|
.join(", ");
|
|
466
472
|
lines.push(`pending: ${pending.items === 0 ? "no model work pending" : `${number(pending.items)} model ${pending.items === 1 ? "item" : "items"} pending (${kinds})`}`);
|
|
473
|
+
for (const [task, count] of Object.entries(pending.held).sort((a, b) => (a[0] < b[0] ? -1 : 1))) {
|
|
474
|
+
lines.push(` ${number(count)} ${count === 1 ? "item" : "items"} pending for ${task} ${count === 1 ? "is" : "are"} held because the task is off`);
|
|
475
|
+
}
|
|
467
476
|
}
|
|
468
477
|
if (cursor)
|
|
469
478
|
lines.push(`updated: ${cursor.updatedAt ? `${cursor.updatedAt}${cursor.lastDay ? `, replayed through ${cursor.lastDay}` : ""}` : "never"}`);
|
|
@@ -477,6 +486,7 @@ export async function statusCommand(context, options = {}) {
|
|
|
477
486
|
company: context.company,
|
|
478
487
|
reader: { effective: reader, setting: { ...setting, file: READER_SETTING_RELATIVE } },
|
|
479
488
|
model: { ...model, perMachine: true },
|
|
489
|
+
modelTasks: { ...tasks.tasks, source: tasks.source, problems: tasks.problems, warnings: tasks.warnings, file: ONTOLOGY_SETTINGS_FILE },
|
|
480
490
|
graph: { root: shownRoot, present: graph.present, stamp: graph.stamp, state: graph.state },
|
|
481
491
|
counts,
|
|
482
492
|
pending,
|
|
@@ -93,6 +93,25 @@ export declare class QmdBinaryMissingError extends Error {
|
|
|
93
93
|
readonly spawnDiagnostics?: QmdSpawnDiagnostics;
|
|
94
94
|
constructor(message: string, spawnDiagnostics?: QmdSpawnDiagnostics);
|
|
95
95
|
}
|
|
96
|
+
/** Bounded reason a qmd usability probe failed. Safe to use as a Sentry tag. */
|
|
97
|
+
export type QmdProbeFailureKind = 'spawn-failed' | 'native-bindings' | 'timed-out' | 'unusable';
|
|
98
|
+
/**
|
|
99
|
+
* Neither the bundled qmd nor the qmd on PATH passed the usability probe, so
|
|
100
|
+
* hq used neither (HQ-CLI-J4, HQ-CLI-HH). The message is the user-facing
|
|
101
|
+
* remedy: what happened and the one step that fixes it, with no raw qmd or
|
|
102
|
+
* cmd.exe output. Both probe reasons are kept as bounded kinds (for Sentry
|
|
103
|
+
* tags) and as redacted, length-bounded detail (for local debugging).
|
|
104
|
+
*/
|
|
105
|
+
export declare class QmdUnusableError extends QmdBinaryMissingError {
|
|
106
|
+
readonly bundledBin: string | undefined;
|
|
107
|
+
readonly bundledProbe: QmdProbeFailureKind | 'not-found';
|
|
108
|
+
readonly pathBin: string;
|
|
109
|
+
readonly pathProbe: QmdProbeFailureKind;
|
|
110
|
+
name: string;
|
|
111
|
+
readonly bundledDetail: string;
|
|
112
|
+
readonly pathDetail: string;
|
|
113
|
+
constructor(bundledBin: string | undefined, bundledProbe: QmdProbeFailureKind | 'not-found', bundledDetail: string, pathBin: string, pathProbe: QmdProbeFailureKind, pathDetail: string);
|
|
114
|
+
}
|
|
96
115
|
/**
|
|
97
116
|
* qmd could not be SPAWNED because its working directory does not exist:
|
|
98
117
|
* spawnSync returned ENOENT while chdir-ing into `cwd` (the resolved hq root at
|
|
@@ -121,6 +140,10 @@ export declare class QmdExitError extends Error {
|
|
|
121
140
|
entryPath?: QmdUpdateEntryPath;
|
|
122
141
|
/** Present only when the invoked executable is the bundled qmd. */
|
|
123
142
|
qmdVersion?: string;
|
|
143
|
+
/** `path-fallback` when hq ran the PATH qmd because the bundled copy failed its probe. */
|
|
144
|
+
qmdSource?: 'path-fallback';
|
|
145
|
+
/** Why the bundled qmd was skipped, when {@link qmdSource} is `path-fallback`. */
|
|
146
|
+
bundledProbe?: QmdProbeFailureKind;
|
|
124
147
|
constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string);
|
|
125
148
|
}
|
|
126
149
|
export declare class QmdCollectionMissingError extends QmdExitError {
|
|
@@ -490,7 +513,9 @@ export declare function ensureQmdStoreDir(env?: NodeJS.ProcessEnv, options?: Ens
|
|
|
490
513
|
export declare function __resetQmdProbeStateForTests(): void;
|
|
491
514
|
/** Backwards-compatible string form: probe a bare bin path shell-free (or via
|
|
492
515
|
* the shell plan when it is a Windows `.cmd`/`.bat`). */
|
|
493
|
-
export declare function isUsableQmd(bin: string
|
|
516
|
+
export declare function isUsableQmd(bin: string, options?: {
|
|
517
|
+
keepHome?: boolean;
|
|
518
|
+
}): boolean;
|
|
494
519
|
/**
|
|
495
520
|
* Honest one-line reason a package-local qmd probe failed, for the resolver's
|
|
496
521
|
* probes note. A spawn-level failure — the binary could not be executed at all
|
|
@@ -499,6 +524,13 @@ export declare function isUsableQmd(bin: string): boolean;
|
|
|
499
524
|
* the native-bindings story. Only a genuine better-sqlite3 load failure keeps it.
|
|
500
525
|
*/
|
|
501
526
|
export declare function describeProbeFailure(detail: string): string;
|
|
527
|
+
/** Bounded kind of a probe failure, from the same detail {@link describeProbeFailure} reads. */
|
|
528
|
+
export declare function qmdProbeFailureKind(detail: string): QmdProbeFailureKind;
|
|
529
|
+
/**
|
|
530
|
+
* The bundled qmd's failure kind when `bin` is a PATH copy hq chose because the
|
|
531
|
+
* bundled copy failed its probe; undefined otherwise.
|
|
532
|
+
*/
|
|
533
|
+
export declare function qmdPathFallbackReason(bin: string): QmdProbeFailureKind | undefined;
|
|
502
534
|
/**
|
|
503
535
|
* Derive the better-sqlite3 PACKAGE directory qmd tried to load, from a bindings
|
|
504
536
|
* failure. `bindings` lists every path it tried, each ending in
|
|
@@ -11,6 +11,7 @@ import { isQmdQueryDocumentError } from '../../utils/qmd-query-document-error.js
|
|
|
11
11
|
import { isQmdStoreMissingError } from '../../utils/qmd-store-missing-error.js';
|
|
12
12
|
import { isQmdStoreUnopenableError } from '../../utils/qmd-store-unopenable-error.js';
|
|
13
13
|
import { markExpectedUserError } from '../../utils/expected-cli-error.js';
|
|
14
|
+
import { HQ_CLI_NPM_REPAIR_COMMAND } from '../../utils/npm-install-flags.js';
|
|
14
15
|
import { redactErrorText } from '../../utils/redact-error-text.js';
|
|
15
16
|
import { planCommandSpawn } from '../../utils/windows-spawn.js';
|
|
16
17
|
import { resolveQmdConfigPath } from './max-doc-bytes.js';
|
|
@@ -46,6 +47,48 @@ export class QmdBinaryMissingError extends Error {
|
|
|
46
47
|
this.spawnDiagnostics = spawnDiagnostics;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
/** Longest probe detail kept on a QmdUnusableError (after redaction). */
|
|
51
|
+
const PROBE_DETAIL_MAX = 300;
|
|
52
|
+
/**
|
|
53
|
+
* Neither the bundled qmd nor the qmd on PATH passed the usability probe, so
|
|
54
|
+
* hq used neither (HQ-CLI-J4, HQ-CLI-HH). The message is the user-facing
|
|
55
|
+
* remedy: what happened and the one step that fixes it, with no raw qmd or
|
|
56
|
+
* cmd.exe output. Both probe reasons are kept as bounded kinds (for Sentry
|
|
57
|
+
* tags) and as redacted, length-bounded detail (for local debugging).
|
|
58
|
+
*/
|
|
59
|
+
export class QmdUnusableError extends QmdBinaryMissingError {
|
|
60
|
+
bundledBin;
|
|
61
|
+
bundledProbe;
|
|
62
|
+
pathBin;
|
|
63
|
+
pathProbe;
|
|
64
|
+
name = 'QmdUnusableError';
|
|
65
|
+
bundledDetail;
|
|
66
|
+
pathDetail;
|
|
67
|
+
constructor(bundledBin, bundledProbe, bundledDetail, pathBin, pathProbe, pathDetail) {
|
|
68
|
+
super(qmdUnusableMessage(bundledBin, bundledProbe, pathBin, pathProbe));
|
|
69
|
+
this.bundledBin = bundledBin;
|
|
70
|
+
this.bundledProbe = bundledProbe;
|
|
71
|
+
this.pathBin = pathBin;
|
|
72
|
+
this.pathProbe = pathProbe;
|
|
73
|
+
this.bundledDetail = redactErrorText(bundledDetail).slice(0, PROBE_DETAIL_MAX);
|
|
74
|
+
this.pathDetail = redactErrorText(pathDetail).slice(0, PROBE_DETAIL_MAX);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const PROBE_KIND_WORDS = {
|
|
78
|
+
'spawn-failed': 'it could not be started',
|
|
79
|
+
'native-bindings': 'its database module was not built',
|
|
80
|
+
'timed-out': 'it did not answer in time',
|
|
81
|
+
unusable: 'it exited with an error',
|
|
82
|
+
};
|
|
83
|
+
function qmdUnusableMessage(bundledBin, bundledProbe, pathBin, pathProbe) {
|
|
84
|
+
const found = Boolean(bundledBin) && bundledProbe !== 'not-found';
|
|
85
|
+
const bundled = bundledBin && bundledProbe !== 'not-found'
|
|
86
|
+
? `The qmd search engine bundled with hq failed its startup check (${PROBE_KIND_WORDS[bundledProbe]})`
|
|
87
|
+
: 'The qmd search engine bundled with hq was not found';
|
|
88
|
+
return (`hq search can't start. ${bundled}, and the qmd on your PATH (${pathBin}) ` +
|
|
89
|
+
`failed ${found ? 'the same' : 'its startup'} check (${PROBE_KIND_WORDS[pathProbe]}), so hq used neither. ` +
|
|
90
|
+
`To fix it, reinstall hq with \`${HQ_CLI_NPM_REPAIR_COMMAND}\`, then run the command again.`);
|
|
91
|
+
}
|
|
49
92
|
/**
|
|
50
93
|
* qmd could not be SPAWNED because its working directory does not exist:
|
|
51
94
|
* spawnSync returned ENOENT while chdir-ing into `cwd` (the resolved hq root at
|
|
@@ -79,6 +122,10 @@ export class QmdExitError extends Error {
|
|
|
79
122
|
entryPath;
|
|
80
123
|
/** Present only when the invoked executable is the bundled qmd. */
|
|
81
124
|
qmdVersion;
|
|
125
|
+
/** `path-fallback` when hq ran the PATH qmd because the bundled copy failed its probe. */
|
|
126
|
+
qmdSource;
|
|
127
|
+
/** Why the bundled qmd was skipped, when {@link qmdSource} is `path-fallback`. */
|
|
128
|
+
bundledProbe;
|
|
82
129
|
constructor(message, args, status, stdout, stderr) {
|
|
83
130
|
super(message);
|
|
84
131
|
this.args = args;
|
|
@@ -577,6 +624,12 @@ const usableQmdCache = new Map();
|
|
|
577
624
|
* and, from the bindings "Tried:" list, WHERE the unbuilt better-sqlite3 lives.
|
|
578
625
|
*/
|
|
579
626
|
const lastProbeFailure = new Map();
|
|
627
|
+
/**
|
|
628
|
+
* PATH qmd copies chosen because the bundled copy failed its probe, keyed by
|
|
629
|
+
* the PATH bin, with the bundled copy's bounded failure kind. runQmd stamps it
|
|
630
|
+
* onto a later QmdExitError so the bundled reason is not lost (HQ-CLI-J4/HH).
|
|
631
|
+
*/
|
|
632
|
+
const pathFallbackReasons = new Map();
|
|
580
633
|
/** At most one native-binding repair attempt per process (bounded, no retries). */
|
|
581
634
|
let nativeBindingRepairAttempted = false;
|
|
582
635
|
const storeEnsureByDir = new Map();
|
|
@@ -702,6 +755,7 @@ const REPAIR_LOCK_TTL_MS = 10 * 60_000;
|
|
|
702
755
|
export function __resetQmdProbeStateForTests() {
|
|
703
756
|
usableQmdCache.clear();
|
|
704
757
|
lastProbeFailure.clear();
|
|
758
|
+
pathFallbackReasons.clear();
|
|
705
759
|
nativeBindingRepairAttempted = false;
|
|
706
760
|
storeEnsureByDir.clear();
|
|
707
761
|
lastQmdStoreEnsure = undefined;
|
|
@@ -783,14 +837,23 @@ function probeQmd(invocation, options = {}) {
|
|
|
783
837
|
let scratch;
|
|
784
838
|
try {
|
|
785
839
|
scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'hq-qmd-probe-'));
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
840
|
+
// A PATH qmd may be a version-manager shim (mise, asdf) that finds its
|
|
841
|
+
// install through HOME/XDG, so its probe keeps them. qmd's store and config
|
|
842
|
+
// still point at scratch, so neither probe touches the user's real index.
|
|
843
|
+
const env = options.keepHome
|
|
844
|
+
? {
|
|
845
|
+
...process.env,
|
|
846
|
+
QMD_CONFIG_DIR: path.join(scratch, 'config'),
|
|
847
|
+
INDEX_PATH: path.join(scratch, 'probe-index.db'),
|
|
848
|
+
}
|
|
849
|
+
: {
|
|
850
|
+
...process.env,
|
|
851
|
+
HOME: scratch,
|
|
852
|
+
QMD_CONFIG_DIR: path.join(scratch, 'config'),
|
|
853
|
+
INDEX_PATH: path.join(scratch, 'probe-index.db'),
|
|
854
|
+
XDG_CONFIG_HOME: path.join(scratch, 'xdg-config'),
|
|
855
|
+
XDG_CACHE_HOME: path.join(scratch, 'xdg-cache'),
|
|
856
|
+
};
|
|
794
857
|
const probe = spawnQmd(invocation, ['collection', 'list'], {
|
|
795
858
|
cwd: scratch,
|
|
796
859
|
env,
|
|
@@ -834,8 +897,8 @@ function isUsableInvocation(invocation, options = {}) {
|
|
|
834
897
|
}
|
|
835
898
|
/** Backwards-compatible string form: probe a bare bin path shell-free (or via
|
|
836
899
|
* the shell plan when it is a Windows `.cmd`/`.bat`). */
|
|
837
|
-
export function isUsableQmd(bin) {
|
|
838
|
-
return isUsableInvocation({ command: bin, prefixArgs: [] });
|
|
900
|
+
export function isUsableQmd(bin, options = {}) {
|
|
901
|
+
return isUsableInvocation({ command: bin, prefixArgs: [] }, options);
|
|
839
902
|
}
|
|
840
903
|
/**
|
|
841
904
|
* Honest one-line reason a package-local qmd probe failed, for the resolver's
|
|
@@ -845,6 +908,8 @@ export function isUsableQmd(bin) {
|
|
|
845
908
|
* the native-bindings story. Only a genuine better-sqlite3 load failure keeps it.
|
|
846
909
|
*/
|
|
847
910
|
export function describeProbeFailure(detail) {
|
|
911
|
+
if (/\bETIMEDOUT\b/.test(detail))
|
|
912
|
+
return 'present but its check timed out';
|
|
848
913
|
if (/\b(?:EINVAL|ENOENT|EACCES|ENOEXEC)\b/.test(detail) || /^spawnSync\b/.test(detail)) {
|
|
849
914
|
return 'present but could not be spawned';
|
|
850
915
|
}
|
|
@@ -852,6 +917,61 @@ export function describeProbeFailure(detail) {
|
|
|
852
917
|
return 'present but native bindings unbuilt';
|
|
853
918
|
return 'present but unusable';
|
|
854
919
|
}
|
|
920
|
+
/** Bounded kind of a probe failure, from the same detail {@link describeProbeFailure} reads. */
|
|
921
|
+
export function qmdProbeFailureKind(detail) {
|
|
922
|
+
if (/\bETIMEDOUT\b/.test(detail))
|
|
923
|
+
return 'timed-out';
|
|
924
|
+
if (/\b(?:EINVAL|ENOENT|EACCES|ENOEXEC)\b/.test(detail) || /^spawnSync\b/.test(detail))
|
|
925
|
+
return 'spawn-failed';
|
|
926
|
+
if (isQmdNativeBindingError(detail))
|
|
927
|
+
return 'native-bindings';
|
|
928
|
+
return 'unusable';
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* The bundled qmd's failure kind when `bin` is a PATH copy hq chose because the
|
|
932
|
+
* bundled copy failed its probe; undefined otherwise.
|
|
933
|
+
*/
|
|
934
|
+
export function qmdPathFallbackReason(bin) {
|
|
935
|
+
return pathFallbackReasons.get(bin);
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Probe the PATH qmd the same way as the bundled copy before it may be used
|
|
939
|
+
* (HQ-CLI-J4, HQ-CLI-HH: an unprobed, corrupt `%APPDATA%\npm\qmd.cmd` was run
|
|
940
|
+
* after the bundled copy failed). Probed only when it is actually needed.
|
|
941
|
+
*
|
|
942
|
+
* A PATH probe that only TIMED OUT is inconclusive (a slow machine; the real
|
|
943
|
+
* run has no probe timeout), so that copy is still used, as it was before the
|
|
944
|
+
* probe existed. Only a definite failure rules it out.
|
|
945
|
+
*/
|
|
946
|
+
function choosePathFallback(onPath, executable, usable, bundledFailure) {
|
|
947
|
+
if (!onPath || !executable(onPath))
|
|
948
|
+
return { kind: 'none' };
|
|
949
|
+
const passed = usable(onPath);
|
|
950
|
+
const detail = passed ? '' : lastProbeFailure.get(onPath) ?? '';
|
|
951
|
+
const probe = qmdProbeFailureKind(detail);
|
|
952
|
+
if (passed || probe === 'timed-out') {
|
|
953
|
+
if (bundledFailure)
|
|
954
|
+
pathFallbackReasons.set(onPath, bundledFailure);
|
|
955
|
+
else
|
|
956
|
+
pathFallbackReasons.delete(onPath);
|
|
957
|
+
return { kind: 'use', bin: onPath };
|
|
958
|
+
}
|
|
959
|
+
return { kind: 'failed', bin: onPath, probe, detail };
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* What to do when the PATH copy definitely failed its probe: throw the remedy
|
|
963
|
+
* error, or return undefined so the caller keeps its classified last resort,
|
|
964
|
+
* the bundled copy. That last resort is kept when the bundled copy is
|
|
965
|
+
* bindings-broken (runQmd then prints the native-binding remedy) or when its
|
|
966
|
+
* probe only timed out (the real run may still succeed).
|
|
967
|
+
*/
|
|
968
|
+
function unusableBoth(bundledBin, bundledDetail, path) {
|
|
969
|
+
const bundledProbe = bundledBin && bundledDetail !== undefined ? qmdProbeFailureKind(bundledDetail) : 'not-found';
|
|
970
|
+
if (bundledProbe === 'native-bindings' || bundledProbe === 'timed-out') {
|
|
971
|
+
return undefined;
|
|
972
|
+
}
|
|
973
|
+
return new QmdUnusableError(bundledBin, bundledProbe, bundledDetail ?? '', path.bin, path.probe, path.detail);
|
|
974
|
+
}
|
|
855
975
|
/** Native-binding self-repair is on unless explicitly disabled. */
|
|
856
976
|
function repairEnabled(env) {
|
|
857
977
|
const flag = env.HQ_QMD_NO_REPAIR;
|
|
@@ -1040,9 +1160,11 @@ export function resolveQmdBin(options = {}) {
|
|
|
1040
1160
|
}
|
|
1041
1161
|
const installed = (options.packageBin ?? packageLocalBin)();
|
|
1042
1162
|
const onPath = (options.pathBin ?? pathBin)();
|
|
1043
|
-
const fallback = onPath && executable(onPath) ? onPath : undefined;
|
|
1044
1163
|
const isUsable = options.isUsable ?? isUsableQmd;
|
|
1045
|
-
|
|
1164
|
+
const installedPresent = Boolean(installed && executable(installed));
|
|
1165
|
+
// Undefined while the bundled copy has not failed (absent or not yet probed).
|
|
1166
|
+
let bundledDetail;
|
|
1167
|
+
if (installed && installedPresent) {
|
|
1046
1168
|
// Executable is not the same as usable: pnpm 10 skips better-sqlite3's build
|
|
1047
1169
|
// script for dependency installs, so the bundled qmd can be present yet
|
|
1048
1170
|
// unable to open its SQLite store. ALWAYS probe — the 5.94.2 short-circuit
|
|
@@ -1059,23 +1181,34 @@ export function resolveQmdBin(options = {}) {
|
|
|
1059
1181
|
return installed;
|
|
1060
1182
|
}
|
|
1061
1183
|
}
|
|
1062
|
-
|
|
1184
|
+
bundledDetail = lastProbeFailure.get(installed) ?? '';
|
|
1185
|
+
probes.push(`package-local @tobilu/qmd (${installed}, ${describeProbeFailure(bundledDetail)})`);
|
|
1063
1186
|
}
|
|
1064
1187
|
else {
|
|
1065
1188
|
probes.push(`package-local @tobilu/qmd (${installed ?? 'not found'})`);
|
|
1066
1189
|
}
|
|
1067
|
-
// A
|
|
1068
|
-
//
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1190
|
+
// A qmd on PATH is the right answer when the bundled one is broken, but only
|
|
1191
|
+
// when it passes the same probe (HQ-CLI-J4, HQ-CLI-HH).
|
|
1192
|
+
const pathChoice = choosePathFallback(onPath, executable, options.isUsable ?? ((bin) => isUsableQmd(bin, { keepHome: true })), bundledDetail !== undefined ? qmdProbeFailureKind(bundledDetail) : undefined);
|
|
1193
|
+
if (pathChoice.kind === 'use')
|
|
1194
|
+
return pathChoice.bin;
|
|
1195
|
+
if (pathChoice.kind === 'failed') {
|
|
1196
|
+
// With no bundled copy, a failed PATH copy always throws here.
|
|
1197
|
+
const unusable = unusableBoth(installedPresent ? installed : undefined, bundledDetail, pathChoice);
|
|
1198
|
+
if (unusable)
|
|
1199
|
+
throw unusable;
|
|
1200
|
+
probes.push(`qmd on PATH (${pathChoice.bin}, ${describeProbeFailure(pathChoice.detail)})`);
|
|
1201
|
+
}
|
|
1202
|
+
else {
|
|
1203
|
+
probes.push(`qmd on PATH (${onPath ?? 'not found'})`);
|
|
1204
|
+
}
|
|
1072
1205
|
// Last resort: no usable qmd anywhere, but the bundled binary IS present. Hand
|
|
1073
1206
|
// it back rather than throwing an opaque "qmd missing" error — running it
|
|
1074
1207
|
// yields a QmdExitError whose native-binding signature the top-level handler
|
|
1075
1208
|
// turns into an actionable remedy (and skips Sentry). This is the "never
|
|
1076
1209
|
// return an unusable binary SILENTLY" contract: we probed, we tried repair,
|
|
1077
1210
|
// and the ensuing failure is classified, not swallowed.
|
|
1078
|
-
if (installed &&
|
|
1211
|
+
if (installed && installedPresent)
|
|
1079
1212
|
return installed;
|
|
1080
1213
|
throw new QmdBinaryMissingError(`Unable to resolve qmd. Probed ${probes.join('; ')}. Install @tobilu/qmd or set HQ_QMD_BIN to an executable qmd binary.`);
|
|
1081
1214
|
}
|
|
@@ -1109,7 +1242,8 @@ export function resolveQmdInvocation(options = {}) {
|
|
|
1109
1242
|
const nodeEntry = (options.packageNodeEntry ?? packageLocalNodeEntry)();
|
|
1110
1243
|
const shim = (options.packageBin ?? packageLocalBin)();
|
|
1111
1244
|
const onPath = (options.pathBin ?? pathBin)();
|
|
1112
|
-
|
|
1245
|
+
// Undefined while the bundled copy has not failed (absent or not yet probed).
|
|
1246
|
+
let bundledDetail;
|
|
1113
1247
|
// The bundled qmd, PREFERRING the shell-free Node launcher over the `.cmd`/`.bat`
|
|
1114
1248
|
// shim. `bundledBin` keeps the qmd file identity (the launcher, else the shim)
|
|
1115
1249
|
// for probe-failure keying and repair-tree confinement. The launcher is read by
|
|
@@ -1154,15 +1288,29 @@ export function resolveQmdInvocation(options = {}) {
|
|
|
1154
1288
|
return bundled;
|
|
1155
1289
|
}
|
|
1156
1290
|
}
|
|
1157
|
-
|
|
1291
|
+
bundledDetail = lastProbeFailure.get(bundledBin) ?? '';
|
|
1292
|
+
probes.push(`package-local @tobilu/qmd (${bundledBin}, ${describeProbeFailure(bundledDetail)})`);
|
|
1158
1293
|
}
|
|
1159
1294
|
else {
|
|
1160
1295
|
probes.push(`package-local @tobilu/qmd (${shim ?? nodeEntry ?? 'not found'})`);
|
|
1161
1296
|
}
|
|
1162
|
-
// A
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1297
|
+
// A qmd on PATH is the right answer when the bundled one is broken, but only
|
|
1298
|
+
// when it passes the same probe (HQ-CLI-J4, HQ-CLI-HH).
|
|
1299
|
+
const pathChoice = choosePathFallback(onPath, executable, (bin) => options.isUsable
|
|
1300
|
+
? options.isUsable({ command: bin, prefixArgs: [] })
|
|
1301
|
+
: isUsableInvocation({ command: bin, prefixArgs: [] }, { platform, spawn: options.spawn, keepHome: true }), bundledDetail !== undefined ? qmdProbeFailureKind(bundledDetail) : undefined);
|
|
1302
|
+
if (pathChoice.kind === 'use')
|
|
1303
|
+
return { command: pathChoice.bin, prefixArgs: [] };
|
|
1304
|
+
if (pathChoice.kind === 'failed') {
|
|
1305
|
+
// With no bundled copy, a failed PATH copy always throws here.
|
|
1306
|
+
const unusable = unusableBoth(bundled ? bundledBin : undefined, bundledDetail, pathChoice);
|
|
1307
|
+
if (unusable)
|
|
1308
|
+
throw unusable;
|
|
1309
|
+
probes.push(`qmd on PATH (${pathChoice.bin}, ${describeProbeFailure(pathChoice.detail)})`);
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
probes.push(`qmd on PATH (${onPath ?? 'not found'})`);
|
|
1313
|
+
}
|
|
1166
1314
|
// Last resort: no usable qmd anywhere, but the bundled binary IS present. Hand
|
|
1167
1315
|
// it back rather than throwing an opaque error — running it yields a classified
|
|
1168
1316
|
// failure (native-binding remedy + no Sentry) instead of an unactionable crash.
|
|
@@ -1487,6 +1635,13 @@ function finishRunQmdWithDiagnostics(result, bin, args, options, attribution) {
|
|
|
1487
1635
|
const bundledBins = [packageLocalBin(), packageLocalNodeEntry()].filter((candidate) => Boolean(candidate));
|
|
1488
1636
|
if (bundledBins.includes(bin))
|
|
1489
1637
|
error.qmdVersion = resolveQmdVersion();
|
|
1638
|
+
// Keep the bundled copy's failure reason when this exit came from the
|
|
1639
|
+
// PATH copy hq fell back to (HQ-CLI-J4, HQ-CLI-HH).
|
|
1640
|
+
const bundledProbe = pathFallbackReasons.get(bin);
|
|
1641
|
+
if (bundledProbe) {
|
|
1642
|
+
error.qmdSource = 'path-fallback';
|
|
1643
|
+
error.bundledProbe = bundledProbe;
|
|
1644
|
+
}
|
|
1490
1645
|
}
|
|
1491
1646
|
throw error;
|
|
1492
1647
|
}
|
|
@@ -2,4 +2,11 @@
|
|
|
2
2
|
export declare function qmdExitCaptureContext(err: unknown): {
|
|
3
3
|
tags: Record<string, string>;
|
|
4
4
|
} | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Bounded Sentry tags for a QmdUnusableError (neither qmd copy passed its
|
|
7
|
+
* probe, HQ-CLI-J4/HH). Only the two closed probe kinds; never paths or detail.
|
|
8
|
+
*/
|
|
9
|
+
export declare function qmdUnusableCaptureContext(err: unknown): {
|
|
10
|
+
tags: Record<string, string>;
|
|
11
|
+
} | undefined;
|
|
5
12
|
//# sourceMappingURL=qmd-exit-diagnostics.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QmdExitError } from "./index.js";
|
|
1
|
+
import { QmdExitError, QmdUnusableError } from "./index.js";
|
|
2
2
|
const QMD_ERROR_CODE_TOKENS = [
|
|
3
3
|
"SQLITE_BUSY",
|
|
4
4
|
"SQLITE_CORRUPT",
|
|
@@ -35,6 +35,30 @@ export function qmdExitCaptureContext(err) {
|
|
|
35
35
|
if (typeof err.entryPath === "string" && QMD_UPDATE_ENTRY_PATHS.has(err.entryPath)) {
|
|
36
36
|
tags.qmd_entry_path = err.entryPath;
|
|
37
37
|
}
|
|
38
|
+
// HQ-CLI-J4/HH: this exit came from the PATH qmd hq fell back to; keep why
|
|
39
|
+
// the bundled copy was skipped.
|
|
40
|
+
if (err.qmdSource === "path-fallback") {
|
|
41
|
+
tags.qmd_source = "path-fallback";
|
|
42
|
+
tags.qmd_bundled_probe = probeKindTag(err.bundledProbe);
|
|
43
|
+
}
|
|
38
44
|
return { tags };
|
|
39
45
|
}
|
|
46
|
+
const QMD_PROBE_KINDS = new Set(["spawn-failed", "native-bindings", "timed-out", "unusable", "not-found"]);
|
|
47
|
+
function probeKindTag(kind) {
|
|
48
|
+
return typeof kind === "string" && QMD_PROBE_KINDS.has(kind) ? kind : "unknown";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Bounded Sentry tags for a QmdUnusableError (neither qmd copy passed its
|
|
52
|
+
* probe, HQ-CLI-J4/HH). Only the two closed probe kinds; never paths or detail.
|
|
53
|
+
*/
|
|
54
|
+
export function qmdUnusableCaptureContext(err) {
|
|
55
|
+
if (!(err instanceof QmdUnusableError))
|
|
56
|
+
return undefined;
|
|
57
|
+
return {
|
|
58
|
+
tags: {
|
|
59
|
+
qmd_bundled_probe: probeKindTag(err.bundledProbe),
|
|
60
|
+
qmd_path_probe: probeKindTag(err.pathProbe),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
40
64
|
//# sourceMappingURL=qmd-exit-diagnostics.js.map
|
|
@@ -101,7 +101,7 @@ export function companyAdapterFlagReader(companyUid, idToken, state) {
|
|
|
101
101
|
let hit = memo.get(key);
|
|
102
102
|
if (!hit) {
|
|
103
103
|
// Loaded on first read: the registry module embeds its worker source.
|
|
104
|
-
hit = import("../flag-
|
|
104
|
+
hit = import("../company-flag-gate.js").then(async ({ readCompanyFlag }) => {
|
|
105
105
|
const read = await readCompanyFlag(companyUid, idToken, flag, { fallback: defaultValue });
|
|
106
106
|
if (read === null) {
|
|
107
107
|
if (!defaultValue || !state)
|
|
@@ -25,6 +25,7 @@ export declare function writeHandbackKeep(home: string, vault: {
|
|
|
25
25
|
/** Test seam: runs after the temp file is written, before the re-read that guards the rename. */
|
|
26
26
|
beforeRename?: (attempt: number) => void): void;
|
|
27
27
|
export declare function engineHoldFile(engineHome: string, vaultUid: string): string;
|
|
28
|
+
export declare function readEngineHoldKinds(engineHome: string, vaultUid: string): string[];
|
|
28
29
|
export declare function readEngineHeldDeletes(engineHome: string, vaultUid: string, warn?: (line: string) => void): EngineHeldDeletes | "unreadable" | null;
|
|
29
30
|
export declare function heldDeletesHandoverLine(vaultUid: string, held: EngineHeldDeletes | "unreadable", engineHome: string, home: string): string;
|
|
30
31
|
//# sourceMappingURL=engine-holds.d.ts.map
|
|
@@ -78,6 +78,32 @@ function readTextOrNull(file) {
|
|
|
78
78
|
export function engineHoldFile(engineHome, vaultUid) {
|
|
79
79
|
return path.join(engineHome, ".hq", "sync-core", "holds", `${vaultUid}.json`);
|
|
80
80
|
}
|
|
81
|
+
const HOLD_KINDS_FILE_MAX_BYTES = 1024 * 1024;
|
|
82
|
+
export function readEngineHoldKinds(engineHome, vaultUid) {
|
|
83
|
+
try {
|
|
84
|
+
const file = engineHoldFile(engineHome, vaultUid);
|
|
85
|
+
const stat = fs.lstatSync(file);
|
|
86
|
+
if (!stat.isFile() || stat.size > HOLD_KINDS_FILE_MAX_BYTES)
|
|
87
|
+
return [];
|
|
88
|
+
const groups = record(JSON.parse(fs.readFileSync(file, "utf8")))?.groups;
|
|
89
|
+
if (!Array.isArray(groups))
|
|
90
|
+
return [];
|
|
91
|
+
const kinds = new Set();
|
|
92
|
+
for (const value of groups) {
|
|
93
|
+
const group = record(value);
|
|
94
|
+
if (typeof group?.direction !== "string")
|
|
95
|
+
continue;
|
|
96
|
+
const paths = Array.isArray(group.paths) ? group.paths.length : 0;
|
|
97
|
+
const declared = typeof group.count === "number" && Number.isSafeInteger(group.count) ? group.count : 0;
|
|
98
|
+
if (paths > 0 || declared > 0)
|
|
99
|
+
kinds.add(group.direction);
|
|
100
|
+
}
|
|
101
|
+
return [...kinds].sort();
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
81
107
|
export function readEngineHeldDeletes(engineHome, vaultUid, warn = () => { }) {
|
|
82
108
|
let text;
|
|
83
109
|
try {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SyncCoreVaultSettings } from "./vault-settings.js";
|
|
2
|
+
import { type ClientHealthSyncEngineSafety } from "../../utils/client-health-contract.js";
|
|
2
3
|
export type SyncCoreVaultKind = "personal" | "company";
|
|
3
4
|
export type SyncCoreVaultPhase = "warming" | "full";
|
|
4
5
|
export interface SyncCoreVault {
|
|
@@ -54,6 +55,7 @@ export interface SyncCoreFirstCycle {
|
|
|
54
55
|
truncated: boolean;
|
|
55
56
|
}
|
|
56
57
|
export declare const SYNC_CORE_STATUS_WORK_LIMIT = 20;
|
|
58
|
+
export declare const SYNC_CORE_STATUS_FILE_MAX_BYTES: number;
|
|
57
59
|
export declare function engineFirstCycle(engineHome: string, vaultUid: string, since: string): SyncCoreFirstCycle | null;
|
|
58
60
|
export interface SyncCoreLastCycle extends SyncCoreFirstCycle {
|
|
59
61
|
fullVault: boolean;
|
|
@@ -92,6 +94,7 @@ export interface SyncCoreEngineStatus {
|
|
|
92
94
|
wakeChannel?: SyncCoreWakeChannel;
|
|
93
95
|
cycle?: SyncCoreRunningCycle;
|
|
94
96
|
lastCycle?: SyncCoreLastCycle;
|
|
97
|
+
safety?: ClientHealthSyncEngineSafety;
|
|
95
98
|
}
|
|
96
99
|
export declare const SYNC_CORE_CYCLE_STALE_MS = 120000;
|
|
97
100
|
export declare function readEngineStatus(engineHome: string, vaultUid: string, now?: Date): SyncCoreEngineStatus | null;
|